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