board.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * board.h
  3. *
  4. * (C) Copyright 2016
  5. * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  6. *
  7. * Based on:
  8. * TI AM335x boards information header
  9. *
  10. * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  11. *
  12. * SPDX-License-Identifier: GPL-2.0+
  13. */
  14. #ifndef _BOARD_H_
  15. #define _BOARD_H_
  16. /* Definition to control the GPIOs (for LEDs and Reset) */
  17. #define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
  18. static inline int board_is_b_sample(void)
  19. {
  20. #if defined CONFIG_B_SAMPLE
  21. return 1;
  22. #else
  23. return 0;
  24. #endif
  25. }
  26. static inline int board_is_c_sample(void)
  27. {
  28. #if defined CONFIG_C_SAMPLE
  29. return 1;
  30. #else
  31. return 0;
  32. #endif
  33. }
  34. static inline int board_is_c3_sample(void)
  35. {
  36. #if defined CONFIG_C3_SAMPLE
  37. return 1;
  38. #else
  39. return 0;
  40. #endif
  41. }
  42. static inline int board_is_series(void)
  43. {
  44. #if defined CONFIG_SERIES
  45. return 1;
  46. #else
  47. return 0;
  48. #endif
  49. }
  50. /*
  51. * Definitions for pinmuxing header and Board ID strings
  52. */
  53. #if defined CONFIG_B_SAMPLE
  54. # define BOARD_ID_STR "SHC B-Sample\n"
  55. #elif defined CONFIG_B2_SAMPLE
  56. # define BOARD_ID_STR "SHC B2-Sample\n"
  57. #elif defined CONFIG_C_SAMPLE
  58. # if defined(CONFIG_SHC_NETBOOT)
  59. # define BOARD_ID_STR "#### NETBOOT ####\nSHC C-Sample\n"
  60. # elif defined(CONFIG_SHC_SDBOOT)
  61. # define BOARD_ID_STR "#### SDBOOT ####\nSHC C-Sample\n"
  62. # else
  63. # define BOARD_ID_STR "SHC C-Sample\n"
  64. # endif
  65. #elif defined CONFIG_C2_SAMPLE
  66. # if defined(CONFIG_SHC_ICT)
  67. # define BOARD_ID_STR "#### ICT ####\nSHC C2-Sample\n"
  68. # elif defined(CONFIG_SHC_NETBOOT)
  69. # define BOARD_ID_STR "#### NETBOOT ####\nSHC C2-Sample\n"
  70. # elif defined(CONFIG_SHC_SDBOOT)
  71. # define BOARD_ID_STR "#### SDBOOT ####\nSHC C2-Sample\n"
  72. # else
  73. # define BOARD_ID_STR "SHC C2-Sample\n"
  74. # endif
  75. #elif defined CONFIG_C3_SAMPLE
  76. # if defined(CONFIG_SHC_ICT)
  77. # define BOARD_ID_STR "#### ICT ####\nSHC C3-Sample\n"
  78. # elif defined(CONFIG_SHC_NETBOOT)
  79. # define BOARD_ID_STR "#### NETBOOT ####\nSHC C3-Sample\n"
  80. # elif defined(CONFIG_SHC_SDBOOT)
  81. # define BOARD_ID_STR "#### SDBOOT ####\nSHC C3-Sample\n"
  82. # else
  83. # define BOARD_ID_STR "SHC C3-Sample\n"
  84. # endif
  85. #elif defined CONFIG_SERIES
  86. # if defined(CONFIG_SHC_ICT)
  87. # define BOARD_ID_STR "#### ICT ####\nSHC\n"
  88. # elif defined(CONFIG_SHC_NETBOOT)
  89. # define BOARD_ID_STR "#### NETBOOT ####\nSHC\n"
  90. # elif defined(CONFIG_SHC_SDBOOT)
  91. # define BOARD_ID_STR "#### SDBOOT ####\nSHC\n"
  92. # else
  93. # define BOARD_ID_STR "SHC\n"
  94. # endif
  95. #else
  96. # define BOARD_ID_STR "Unknown device!\n"
  97. #endif
  98. /*
  99. * Definitions for GPIO pin assignments
  100. */
  101. #if defined CONFIG_B_SAMPLE
  102. # define LED_PWR_BL_GPIO GPIO_TO_PIN(1, 17)
  103. # define LED_PWR_RD_GPIO GPIO_TO_PIN(1, 18)
  104. # define LED_PWR_GN_GPIO GPIO_TO_PIN(1, 19)
  105. # define LED_CONN_BL_GPIO GPIO_TO_PIN(0, 26)
  106. # define LED_CONN_RD_GPIO GPIO_TO_PIN(0, 22)
  107. # define LED_CONN_GN_GPIO GPIO_TO_PIN(0, 23)
  108. # define RESET_GPIO GPIO_TO_PIN(1, 29)
  109. # define WIFI_REGEN_GPIO GPIO_TO_PIN(1, 16)
  110. # define WIFI_RST_GPIO GPIO_TO_PIN(0, 27)
  111. # define ZIGBEE_RST_GPIO GPIO_TO_PIN(3, 18)
  112. # define BIDCOS_RST_GPIO GPIO_TO_PIN(0, 12)
  113. # define ENOC_RST_GPIO GPIO_TO_PIN(1, 22)
  114. #else
  115. # define LED_PWR_BL_GPIO GPIO_TO_PIN(0, 22)
  116. # define LED_PWR_RD_GPIO GPIO_TO_PIN(0, 23)
  117. # define LED_LAN_BL_GPIO GPIO_TO_PIN(1, 17)
  118. # define LED_LAN_RD_GPIO GPIO_TO_PIN(0, 26)
  119. # define LED_CLOUD_BL_GPIO GPIO_TO_PIN(1, 18)
  120. # define LED_CLOUD_RD_GPIO GPIO_TO_PIN(2, 2)
  121. # define LED_PWM_GPIO GPIO_TO_PIN(1, 19)
  122. # define RESET_GPIO GPIO_TO_PIN(1, 29)
  123. # define WIFI_REGEN_GPIO GPIO_TO_PIN(1, 16)
  124. # define WIFI_RST_GPIO GPIO_TO_PIN(0, 27)
  125. # define ZIGBEE_RST_GPIO GPIO_TO_PIN(3, 18)
  126. # define BIDCOS_RST_GPIO GPIO_TO_PIN(1, 24)
  127. # define Z_WAVE_RST_GPIO GPIO_TO_PIN(1, 21)
  128. # define ENOC_RST_GPIO GPIO_TO_PIN(1, 22)
  129. #endif
  130. #define BACK_BUTTON_GPIO GPIO_TO_PIN(1, 29)
  131. #define FRONT_BUTTON_GPIO GPIO_TO_PIN(1, 25)
  132. /* Reset is on GPIO pin 29 of GPIO bank 1 */
  133. #define RESET_MASK (0x1 << 29)
  134. #define HDR_MAGIC 0x43485342
  135. #define HDR_ETH_ALEN 6
  136. #define HDR_NAME_LEN 8
  137. #define HDR_REV_LEN 8
  138. #define HDR_SER_LEN 16
  139. #define HDR_ROOT_LEN 12
  140. #define HDR_FATC_LEN 12
  141. /*
  142. * SHC parameters held in On-Board I²C EEPROM device.
  143. *
  144. * Header Format
  145. *
  146. * Name Size Contents
  147. *-------------------------------------------------------------
  148. * Magic 4 0x42 0x53 0x48 0x43 [BSHC]
  149. *
  150. * Version 2 0x0100 for v1.0
  151. *
  152. * Lenght 2 The length of the complete structure, not only this header
  153. *
  154. * Eth-MAC 6 Ethernet MAC Address
  155. * SHC Pool: 7C:AC:B2:00:10:01 - TBD
  156. *
  157. * --- Further values follow, not important for Bootloader ---
  158. */
  159. struct shc_eeprom {
  160. u32 magic;
  161. u16 version;
  162. u16 lenght;
  163. uint8_t mac_addr[HDR_ETH_ALEN];
  164. };
  165. void enable_uart0_pin_mux(void);
  166. void enable_shc_board_pin_mux(void);
  167. void enable_shc_board_pwm_pin_mux(void);
  168. #endif