diff --git a/boards/arm/lpcxpresso54114/Kconfig.defconfig b/boards/arm/lpcxpresso54114/Kconfig.defconfig index 7f68e3cdbbd..ce13a096144 100644 --- a/boards/arm/lpcxpresso54114/Kconfig.defconfig +++ b/boards/arm/lpcxpresso54114/Kconfig.defconfig @@ -36,4 +36,11 @@ config GPIO_MCUX_LPC_PORT1 endif # GPIO_MCUX_LPC +if SPI + +config SPI_5 + default y + +endif # SPI + endif # BOARD_LPCXPRESSO54114_M4 || BOARD_LPCXPRESSO54114_M0 diff --git a/boards/arm/lpcxpresso54114/doc/index.rst b/boards/arm/lpcxpresso54114/doc/index.rst index 6027ba9d65c..73f0b680373 100644 --- a/boards/arm/lpcxpresso54114/doc/index.rst +++ b/boards/arm/lpcxpresso54114/doc/index.rst @@ -62,6 +62,8 @@ features: +-----------+------------+-------------------------------------+ | GPIO | on-chip | gpio | +-----------+------------+-------------------------------------+ +| SPI | on-chip | spi | ++-----------+------------+-------------------------------------+ | USART | on-chip | serial port-polling | +-----------+------------+-------------------------------------+ @@ -85,8 +87,16 @@ functionality of a pin. +---------+-----------------+----------------------------+ | PIO0_1 | USART | USART TX | +---------+-----------------+----------------------------+ +| PIO0_18 | SPI | SPI MISO | ++---------+-----------------+----------------------------+ +| PIO0_19 | SPI | SPI SCK | ++---------+-----------------+----------------------------+ +| PIO0_20 | SPI | SPI MOSI | ++---------+-----------------+----------------------------+ | PIO0_29 | GPIO | RED LED | +---------+-----------------+----------------------------+ +| PIO1_1 | SPI | SPI SSEL2 | ++---------+-----------------+----------------------------+ | PIO1_9 | GPIO | BLUE_LED | +---------+-----------------+----------------------------+ | PIO1_10 | GPIO | GREEN LED | diff --git a/boards/arm/lpcxpresso54114/lpcxpresso54114.dtsi b/boards/arm/lpcxpresso54114/lpcxpresso54114.dtsi index 14e3ed2b297..a592b3b77b2 100644 --- a/boards/arm/lpcxpresso54114/lpcxpresso54114.dtsi +++ b/boards/arm/lpcxpresso54114/lpcxpresso54114.dtsi @@ -11,6 +11,7 @@ led0 = &red_led; led1 = &green_led; led2 = &blue_led; + spi-5 = &spi5; }; leds { @@ -32,3 +33,5 @@ }; }; }; + +arduino_spi: &spi5 {}; diff --git a/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.dts b/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.dts index 6886b884118..14520b73ac0 100644 --- a/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.dts +++ b/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.dts @@ -67,3 +67,7 @@ &blue_led { status = "okay"; }; + +&spi5 { + status = "okay"; +}; diff --git a/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.yaml b/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.yaml index 599723ae745..f11c81d2fe4 100644 --- a/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.yaml +++ b/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.yaml @@ -15,4 +15,6 @@ toolchain: - gnuarmemb - xtools supported: + - arduino_spi - gpio + - spi diff --git a/boards/arm/lpcxpresso54114/pinmux.c b/boards/arm/lpcxpresso54114/pinmux.c index eb1abb2b4da..3b78cfce36a 100644 --- a/boards/arm/lpcxpresso54114/pinmux.c +++ b/boards/arm/lpcxpresso54114/pinmux.c @@ -106,6 +106,40 @@ static int lpcxpresso_54114_pinmux_init(struct device *dev) pinmux_pin_set(port1, 10, port1_pin10_config); #endif +#ifdef CONFIG_SPI_5 + /* PORT0 PIN18 is configured as FC5_TXD_SCL_MISO */ + pinmux_pin_set(port0, 18, IOCON_PIO_FUNC1 | + IOCON_PIO_MODE_PULLUP | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_SLEW_STANDARD | + IOCON_PIO_OPENDRAIN_DI); + + /* PORT0 PIN19 is configured as FC5_SCK-SPIFI_CSn */ + pinmux_pin_set(port0, 19, IOCON_PIO_FUNC1 | + IOCON_PIO_MODE_PULLUP | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_SLEW_STANDARD | + IOCON_PIO_OPENDRAIN_DI); + + /* PORT0 PIN20 is configured as FC5_RXD_SDA_MOSI */ + pinmux_pin_set(port0, 20, IOCON_PIO_FUNC1 | + IOCON_PIO_MODE_PULLUP | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_SLEW_STANDARD | + IOCON_PIO_OPENDRAIN_DI); + + /* PORT1 PIN1 is configured as FC5_SSEL2 */ + pinmux_pin_set(port1, 1, IOCON_PIO_FUNC4 | + IOCON_PIO_MODE_PULLUP | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_SLEW_STANDARD | + IOCON_PIO_OPENDRAIN_DI); +#endif /* CONFIG_SPI_5 */ + return 0; } diff --git a/soc/arm/nxp_lpc/lpc54xxx/soc.c b/soc/arm/nxp_lpc/lpc54xxx/soc.c index a9273d7769d..dbd4b1a13bb 100644 --- a/soc/arm/nxp_lpc/lpc54xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc54xxx/soc.c @@ -65,6 +65,15 @@ static ALWAYS_INLINE void clock_init(void) /* Attach 12 MHz clock to FLEXCOMM0 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0); + +#ifdef CONFIG_SPI_5 + /* Attach 12 MHz clock to FLEXCOMM5 */ + CLOCK_AttachClk(kFRO12M_to_FLEXCOMM5); + + /* reset FLEXCOMM for SPI */ + RESET_PeripheralReset(kFC5_RST_SHIFT_RSTn); +#endif /* CONFIG_SPI_5 */ + #endif /* CONFIG_SOC_LPC54114_M4 */ } diff --git a/soc/arm/nxp_lpc/lpc54xxx/soc.h b/soc/arm/nxp_lpc/lpc54xxx/soc.h index 3372c51ab10..8484cb0ec7d 100644 --- a/soc/arm/nxp_lpc/lpc54xxx/soc.h +++ b/soc/arm/nxp_lpc/lpc54xxx/soc.h @@ -28,6 +28,8 @@ #define IOCON_PIO_FUNC0 0x00u #define IOCON_PIO_FUNC1 0x01u #define IOCON_PIO_FUNC2 0x02u +#define IOCON_PIO_FUNC3 0x03u +#define IOCON_PIO_FUNC4 0x04u #define IOCON_PIO_INPFILT_OFF 0x0100u #define IOCON_PIO_INV_DI 0x00u #define IOCON_PIO_MODE_INACT 0x00u