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