Developer World
Spresense SDK Library v3.2.0-ebc0364
board.h
1/****************************************************************************
2 * boards/arm/cxd56xx/spresense/include/board.h
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership. The
7 * ASF licenses this file to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance with the
9 * License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 * License for the specific language governing permissions and limitations
17 * under the License.
18 *
19 ****************************************************************************/
20
21#ifndef __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_BOARD_H
22#define __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_BOARD_H
23
24/****************************************************************************
25 * Included Files
26 ****************************************************************************/
27
28#include <nuttx/config.h>
29#include <nuttx/irq.h>
30#include <sys/boardctl.h>
31#include <stdbool.h>
32#include <arch/chip/pin.h>
33
34#include "board_lcdpins.h"
35
36#include "cxd56_clock.h"
37#include "cxd56_power.h"
38#include "cxd56_flash.h"
39#include "cxd56_gauge.h"
40#include "cxd56_charger.h"
41#include "cxd56_gs2200m.h"
42#include "cxd56_wiznet.h"
43#include "cxd56_i2cdev.h"
44#include "cxd56_spidev.h"
45#include "cxd56_sdcard.h"
46#include "cxd56_automount.h"
47#include "cxd56_wdt.h"
48#include "cxd56_gpioif.h"
49
50#include "cxd56_audio.h"
51#include "cxd56_alt1250.h"
52#include "cxd56_ak09912.h"
53#include "cxd56_apds9930.h"
54#include "cxd56_apds9960.h"
55#include "cxd56_bcm20706.h"
56#include "cxd56_bh1721fvc.h"
57#include "cxd56_bh1745nuc.h"
58#include "cxd56_bm1383glv.h"
59#include "cxd56_bm1422gmv.h"
60#include "cxd56_bmi160.h"
61#include "cxd56_bmi270.h"
62#include "cxd56_bmp280.h"
63#include "cxd56_emmcdev.h"
64#include "cxd56_spisd.h"
65#include "cxd56_kx022.h"
66#include "cxd56_lt1pa01.h"
67#include "cxd56_rpr0521rs.h"
68#include "cxd56_scd41.h"
69#include "cxd56_sensors.h"
70#include "cxd56_gnss_addon.h"
71#include "cxd56_cxd5602pwbimu.h"
72
73#ifdef CONFIG_VIDEO_ISX012
74# include "cxd56_isx012.h"
75#endif /* CONFIG_VIDEO_ISX012 */
76#ifdef CONFIG_VIDEO_ISX019
77# include "cxd56_isx019.h"
78#endif /* CONFIG_VIDEO_ISX019 */
79
80/****************************************************************************
81 * Pre-processor Definitions
82 ****************************************************************************/
83
84/* Clocking *****************************************************************/
85
86#ifdef CONFIG_CXD56_80MHz
87# define BOARD_FCLKOUT_FREQUENCY (80000000)
88#else
89# define BOARD_FCLKOUT_FREQUENCY (100000000)
90#endif
91
92/* UART clocking ************************************************************/
93
94/* Configure all UARTs to use the XTAL input frequency */
95
96#define BOARD_UART0_BASEFREQ CONFIG_CXD56_XOSC_CLOCK
97#define BOARD_UART1_BASEFREQ BOARD_FCLKOUT_FREQUENCY
98#define BOARD_UART2_BASEFREQ CONFIG_CXD56_XOSC_CLOCK
99
100/* LED definitions **********************************************************/
101
102#define GPIO_LED1 (PIN_I2S1_BCK)
103#define GPIO_LED2 (PIN_I2S1_LRCK)
104#define GPIO_LED3 (PIN_I2S1_DATA_IN)
105#define GPIO_LED4 (PIN_I2S1_DATA_OUT)
106
107#define BOARD_LED1 (0)
108#define BOARD_LED2 (1)
109#define BOARD_LED3 (2)
110#define BOARD_LED4 (3)
111#define BOARD_NLEDS (4)
112
113/* LED bits for use with board_userled_all() */
114
115#define BOARD_LED1_BIT (1 << BOARD_LED1)
116#define BOARD_LED2_BIT (1 << BOARD_LED2)
117#define BOARD_LED3_BIT (1 << BOARD_LED3)
118#define BOARD_LED4_BIT (1 << BOARD_LED4)
119
120/* LED pattern for use with board_autoled_on() and board_autoled_off() */
121
122#define LED_STARTED (BOARD_LED1_BIT)
123#define LED_HEAPALLOCATE (BOARD_LED2_BIT)
124#define LED_IRQSENABLED (BOARD_LED1_BIT | BOARD_LED2_BIT)
125#define LED_STACKCREATED (BOARD_LED3_BIT)
126#define LED_INIRQ (BOARD_LED1_BIT | BOARD_LED3_BIT)
127#define LED_SIGNAL (BOARD_LED2_BIT | BOARD_LED3_BIT)
128#define LED_ASSERTION (BOARD_LED1_BIT | BOARD_LED2_BIT | BOARD_LED3_BIT)
129#define LED_PANIC (BOARD_LED4_BIT)
130
131#ifdef CONFIG_ARCH_LEDS_CPU_ACTIVITY
132/* NOTE: LED_CPUx is not a bit pattern but just a number which
133 * does not conflict with existing LED bit patterns
134 */
135
136#define LED_CPU0 (100)
137#define LED_CPU1 (101)
138#define LED_CPU2 (102)
139#define LED_CPU3 (103)
140#define LED_CPU (LED_CPU0 + up_cpu_index())
141#endif
142
143/* Buttons definitions ******************************************************/
144
145#define BOARD_NUM_BUTTONS (2)
146
147/* Power Control definitions ************************************************/
148
149/* For SPRESENSE board:
150 *
151 * Switch Device
152 * --------- -------------------------------
153 * LDO_EMMC GNSS A-ANT
154 * DDC_ANA N/A
155 * LDO_PERI N/A
156 * LSW2 CXD5247 Audio Digital VDD
157 * LSW3 SPI-Flash
158 * LSW4 TCXO & GNSS LNA
159 * GPO0
160 * GPO1 CXD5247 Audio Analog VDD
161 * GPO2
162 * GPO3
163 * GPO4 Camera
164 * GPO5 Camera
165 * GPO6 Audio External Amp.
166 * GPO7 Camera
167 *
168 */
169
170#define PMIC_NONE (0)
171#define PMIC_TYPE_LSW (1u << 8)
172#define PMIC_TYPE_GPO (1u << 9)
173#define PMIC_TYPE_DDCLDO (1u << 10)
174#define CHIP_TYPE_GPIO (1u << 11)
175#define PMIC_GET_TYPE(v) ((v) & 0xff00)
176#define PMIC_GET_CH(v) ((v) & 0x00ff)
177#define PMIC_LSW(n) (PMIC_TYPE_LSW | (1u << (n)))
178#define PMIC_GPO(n) (PMIC_TYPE_GPO | (1u << (n)))
179#define PMIC_DDCLDO(n) (PMIC_TYPE_DDCLDO | (1u << (n)))
180#define CHIP_GPIO(n) (CHIP_TYPE_GPIO | (n))
181
182enum board_power_device
183{
184 /* DDC/LDO */
185
186 POWER_DDC_IO = PMIC_DDCLDO(0),
187 POWER_LDO_EMMC = PMIC_DDCLDO(1),
188 POWER_DDC_ANA = PMIC_DDCLDO(2),
189 POWER_LDO_ANA = PMIC_DDCLDO(3),
190 POWER_DDC_CORE = PMIC_DDCLDO(4),
191 POWER_LDO_PERI = PMIC_DDCLDO(5),
192
193 /* Load Switch */
194
195 POWER_AUDIO_DVDD = PMIC_LSW(2),
196 POWER_FLASH = PMIC_LSW(3),
197 POWER_TCXO = PMIC_LSW(4),
198 POWER_LNA = PMIC_LSW(4),
199
200 /* GPO */
201
202 POWER_AUDIO_AVDD = PMIC_GPO(1),
203 POWER_AUDIO_MUTE = PMIC_GPO(6),
204 POWER_IMAGE_SENSOR = PMIC_GPO(4),
205
206 POWER_BTBLE = PMIC_NONE,
207 POWER_SENSOR = PMIC_NONE,
208#if defined(CONFIG_CXD56_EMMC_POWER_PIN_I2S0_BCK)
209 POWER_EMMC = CHIP_GPIO(PIN_I2S0_BCK),
210#elif defined(CONFIG_CXD56_EMMC_POWER_PIN_UART2_CTS)
211 POWER_EMMC = CHIP_GPIO(PIN_UART2_CTS),
212#else
213 POWER_EMMC = PMIC_NONE,
214#endif
215 POWER_LTE = PMIC_GPO(2),
216};
217
218/* Power Off Level definitions **********************************************/
219
220#define BOARD_POWEROFF_DEEP (0)
221#define BOARD_POWEROFF_COLD (1)
222
223/* Power domain definitions *************************************************/
224
225#define BOARD_PM_IDLE (0)
226#define BOARD_PM_APPS (1)
227
228/* CXD5247 audio control definitions ****************************************/
229
230#define CXD5247_XRST PIN_SPI3_CS2_X
231#define CXD5247_AVDD (0x01)
232#define CXD5247_DVDD (0x02)
233
234/* LCD Display clocking *****************************************************/
235
236#define ILI9340_SPI_MAXFREQUENCY 40000000
237
238/* Display device pin definitions *******************************************/
239
240#if defined(CONFIG_LCD_ON_MAIN_BOARD) /* Display connected to main board. */
241
242#define DISPLAY_SPI 5
243
244#define DISPLAY_DMA_TXCH (4)
245#define DISPLAY_DMA_RXCH (5)
246#define DISPLAY_DMA_TXCH_CFG CXD56_DMA_PERIPHERAL_SPI5_TX
247#define DISPLAY_DMA_RXCH_CFG CXD56_DMA_PERIPHERAL_SPI5_RX
248#define DISPLAY_DMA_TX_MAXSIZE (192000)
249#define DISPLAY_DMA_RX_MAXSIZE (192000)
250
251#elif defined(CONFIG_LCD_ON_LTE_EXTENSION_BOARD)
252
253/* Display connected to LTE extension board. */
254
255#define DISPLAY_SPI 3
256
257/* Specify invalid channels because DMA cannot be used */
258
259#define DISPLAY_DMA_TXCH (-1)
260#define DISPLAY_DMA_RXCH (-1)
261#define DISPLAY_DMA_TXCH_CFG (-1)
262#define DISPLAY_DMA_RXCH_CFG (-1)
263#define DISPLAY_DMA_TX_MAXSIZE (192000)
264#define DISPLAY_DMA_RX_MAXSIZE (192000)
265
266#else /* Display is connected through extension board. */
267
268#define DISPLAY_SPI 4
269
270#define DISPLAY_DMA_TXCH (2)
271#define DISPLAY_DMA_RXCH (3)
272#define DISPLAY_DMA_TXCH_CFG CXD56_DMA_PERIPHERAL_SPI4_TX
273#define DISPLAY_DMA_RXCH_CFG CXD56_DMA_PERIPHERAL_SPI4_RX
274#define DISPLAY_DMA_TX_MAXSIZE (192000)
275#define DISPLAY_DMA_RX_MAXSIZE (192000)
276
277#endif
278
279#define DISPLAY_RST ILI934X_RST_PIN
280#define DISPLAY_DC ILI934X_DC_PIN
281
282/* Sensor device bus definitions ********************************************/
283
284#define SENSOR_I2C 0
285#define SENSOR_SPI 3
286
287/* Imager device pin definitions ********************************************/
288
289#define IMAGER_RST PIN_SDIO_DIR1_3
290#define IMAGER_SLEEP PIN_SDIO_DIR0
291
292#define IMAGER_I2C 2
293
294/* Set signal id for notify USB device connection status and
295 * supply current value.
296 * signal returns "usbdev_notify_s" struct pointer in sival_ptr.
297 *
298 * Arg: Value of sinal number
299 */
300
301#define BOARDIOC_USBDEV_SETNOTIFYSIG (BOARDIOC_USER+0x0001)
302
303/* Altair modem device pin definitions **************************************/
304
305#define ALT1250_SLAVE_REQ PIN_SPI2_SCK
306#define ALT1250_MASTER_REQ PIN_RTC_IRQ_OUT
307#define ALT1250_WAKEUP PIN_SPI2_MOSI
308#define ALT1250_SHUTDOWN PIN_SPI2_MISO
309#define ALT1250_LTE_POWER_BUTTON PIN_AP_CLK
310
311/* WIZnet ethernet device pin definitions ***********************************/
312
313#if defined(CONFIG_CXD56_WIZNET_RST_EMMC_DATA3)
314#define WIZNET_PIN_RST PIN_EMMC_DATA3
315#elif defined(CONFIG_CXD56_WIZNET_RST_I2S0_BCK)
316#define WIZNET_PIN_RST PIN_I2S0_BCK
317#endif
318
319#if defined(CONFIG_CXD56_WIZNET_INT_EMMC_DATA2)
320#define WIZNET_PIN_INT PIN_EMMC_DATA2
321#elif defined(CONFIG_CXD56_WIZNET_INT_I2S0_LRCK)
322#define WIZNET_PIN_INT PIN_I2S0_LRCK
323#endif
324
325#ifdef CONFIG_CXD56_WIZNET_USE_SWCS
326#define WIZNET_PIN_CS PIN_I2S0_DATA_IN
327#endif
328
329/****************************************************************************
330 * Public Types
331 ****************************************************************************/
332
333#ifndef __ASSEMBLY__
334
335/****************************************************************************
336 * Public Data
337 ****************************************************************************/
338
339#undef EXTERN
340#if defined(__cplusplus)
341#define EXTERN extern "C"
342extern "C"
343{
344#else
345#define EXTERN extern
346#endif
347
348/****************************************************************************
349 * Public Function Prototypes
350 ****************************************************************************/
351
352/****************************************************************************
353 * Name: cxd56_boardinitialize
354 *
355 * Description:
356 *
357 ****************************************************************************/
358
359void cxd56_boardinitialize(void);
360
361#undef EXTERN
362#if defined(__cplusplus)
363}
364#endif
365
366#endif /* __ASSEMBLY__ */
367#endif /* __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_BOARD_H */