board.h 4.7 KB

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