blob: 46167fe59ecb0f64c72694596e168a96d872ad44 [file] [log] [blame]
Heiko Schocherd8ccbe92016-06-07 08:31:25 +02001/*
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
15#ifndef _BOARD_H_
16#define _BOARD_H_
17
18/* Definition to control the GPIOs (for LEDs and Reset) */
19#define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
20
21static inline int board_is_b_sample(void)
22{
23#if defined CONFIG_B_SAMPLE
24 return 1;
25#else
26 return 0;
27#endif
28}
29
30static inline int board_is_c_sample(void)
31{
32#if defined CONFIG_C_SAMPLE
33 return 1;
34#else
35 return 0;
36#endif
37}
38
39static inline int board_is_c3_sample(void)
40{
41#if defined CONFIG_C3_SAMPLE
42 return 1;
43#else
44 return 0;
45#endif
46}
47
48static inline int board_is_series(void)
49{
50#if defined CONFIG_SERIES
51 return 1;
52#else
53 return 0;
54#endif
55}
56
57/*
58 * Definitions for pinmuxing header and Board ID strings
59 */
60#if defined CONFIG_B_SAMPLE
61# define BOARD_ID_STR "SHC B-Sample\n"
62#elif defined CONFIG_B2_SAMPLE
63# define BOARD_ID_STR "SHC B2-Sample\n"
64#elif defined CONFIG_C_SAMPLE
65# if defined(CONFIG_SHC_NETBOOT)
66# define BOARD_ID_STR "#### NETBOOT ####\nSHC C-Sample\n"
67# elif defined(CONFIG_SHC_SDBOOT)
68# define BOARD_ID_STR "#### SDBOOT ####\nSHC C-Sample\n"
69# else
70# define BOARD_ID_STR "SHC C-Sample\n"
71# endif
72#elif defined CONFIG_C2_SAMPLE
73# if defined(CONFIG_SHC_ICT)
74# define BOARD_ID_STR "#### ICT ####\nSHC C2-Sample\n"
75# elif defined(CONFIG_SHC_NETBOOT)
76# define BOARD_ID_STR "#### NETBOOT ####\nSHC C2-Sample\n"
77# elif defined(CONFIG_SHC_SDBOOT)
78# define BOARD_ID_STR "#### SDBOOT ####\nSHC C2-Sample\n"
79# else
80# define BOARD_ID_STR "SHC C2-Sample\n"
81# endif
82#elif defined CONFIG_C3_SAMPLE
83# if defined(CONFIG_SHC_ICT)
84# define BOARD_ID_STR "#### ICT ####\nSHC C3-Sample\n"
85# elif defined(CONFIG_SHC_NETBOOT)
86# define BOARD_ID_STR "#### NETBOOT ####\nSHC C3-Sample\n"
87# elif defined(CONFIG_SHC_SDBOOT)
88# define BOARD_ID_STR "#### SDBOOT ####\nSHC C3-Sample\n"
89# else
90# define BOARD_ID_STR "SHC C3-Sample\n"
91# endif
92#elif defined CONFIG_SERIES
93# if defined(CONFIG_SHC_ICT)
94# define BOARD_ID_STR "#### ICT ####\nSHC\n"
95# elif defined(CONFIG_SHC_NETBOOT)
96# define BOARD_ID_STR "#### NETBOOT ####\nSHC\n"
97# elif defined(CONFIG_SHC_SDBOOT)
98# define BOARD_ID_STR "#### SDBOOT ####\nSHC\n"
99# else
100# define BOARD_ID_STR "SHC\n"
101# endif
102#else
103# define BOARD_ID_STR "Unknown device!\n"
104#endif
105
106/*
107 * Definitions for GPIO pin assignments
108 */
109#if defined CONFIG_B_SAMPLE
110
111# define LED_PWR_BL_GPIO GPIO_TO_PIN(1, 17)
112# define LED_PWR_RD_GPIO GPIO_TO_PIN(1, 18)
113# define LED_PWR_GN_GPIO GPIO_TO_PIN(1, 19)
114# define LED_CONN_BL_GPIO GPIO_TO_PIN(0, 26)
115# define LED_CONN_RD_GPIO GPIO_TO_PIN(0, 22)
116# define LED_CONN_GN_GPIO GPIO_TO_PIN(0, 23)
117# define RESET_GPIO GPIO_TO_PIN(1, 29)
118# define WIFI_REGEN_GPIO GPIO_TO_PIN(1, 16)
119# define WIFI_RST_GPIO GPIO_TO_PIN(0, 27)
120# define ZIGBEE_RST_GPIO GPIO_TO_PIN(3, 18)
121# define BIDCOS_RST_GPIO GPIO_TO_PIN(0, 12)
122# define ENOC_RST_GPIO GPIO_TO_PIN(1, 22)
123
124#else
125
126# define LED_PWR_BL_GPIO GPIO_TO_PIN(0, 22)
127# define LED_PWR_RD_GPIO GPIO_TO_PIN(0, 23)
128# define LED_LAN_BL_GPIO GPIO_TO_PIN(1, 17)
129# define LED_LAN_RD_GPIO GPIO_TO_PIN(0, 26)
130# define LED_CLOUD_BL_GPIO GPIO_TO_PIN(1, 18)
131# define LED_CLOUD_RD_GPIO GPIO_TO_PIN(2, 2)
132# define LED_PWM_GPIO GPIO_TO_PIN(1, 19)
133# define RESET_GPIO GPIO_TO_PIN(1, 29)
134# define WIFI_REGEN_GPIO GPIO_TO_PIN(1, 16)
135# define WIFI_RST_GPIO GPIO_TO_PIN(0, 27)
136# define ZIGBEE_RST_GPIO GPIO_TO_PIN(3, 18)
137# define BIDCOS_RST_GPIO GPIO_TO_PIN(1, 24)
138# define Z_WAVE_RST_GPIO GPIO_TO_PIN(1, 21)
139# define ENOC_RST_GPIO GPIO_TO_PIN(1, 22)
140
141#endif
142
143#define BACK_BUTTON_GPIO GPIO_TO_PIN(1, 29)
144#define FRONT_BUTTON_GPIO GPIO_TO_PIN(1, 25)
145
146/* Reset is on GPIO pin 29 of GPIO bank 1 */
147#define RESET_MASK (0x1 << 29)
148
149#define HDR_MAGIC 0x43485342
150#define HDR_ETH_ALEN 6
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 I²C 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
176struct shc_eeprom {
177 u32 magic;
178 u16 version;
179 u16 lenght;
180 uint8_t mac_addr[HDR_ETH_ALEN];
181};
182
183void enable_uart0_pin_mux(void);
184void enable_shc_board_pin_mux(void);
185void enable_shc_board_pwm_pin_mux(void);
186
187#endif