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