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