From c5ef6dc73f21648b063c739f6fa36dc661ddf714 Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Sun, 8 Dec 2019 14:38:02 -0600 Subject: [PATCH] boards: lpcxpresso54114: Enable i2c instance 4 Enables i2c instance 4 on the lpcxpresso54114 board. Configures pinmuxes and clocks, and updates board documentation accordingly. Signed-off-by: Maureen Helm --- boards/arm/lpcxpresso54114/Kconfig.defconfig | 4 ++++ boards/arm/lpcxpresso54114/doc/index.rst | 6 ++++++ .../arm/lpcxpresso54114/lpcxpresso54114.dtsi | 2 ++ .../lpcxpresso54114/lpcxpresso54114_m4.dts | 4 ++++ .../lpcxpresso54114/lpcxpresso54114_m4.yaml | 2 ++ boards/arm/lpcxpresso54114/pinmux.c | 20 +++++++++++++++++++ soc/arm/nxp_lpc/lpc54xxx/soc.c | 8 ++++++++ soc/arm/nxp_lpc/lpc54xxx/soc.h | 3 +++ 8 files changed, 49 insertions(+) diff --git a/boards/arm/lpcxpresso54114/Kconfig.defconfig b/boards/arm/lpcxpresso54114/Kconfig.defconfig index 3ce5495acb3..95ea74da2b6 100644 --- a/boards/arm/lpcxpresso54114/Kconfig.defconfig +++ b/boards/arm/lpcxpresso54114/Kconfig.defconfig @@ -33,6 +33,10 @@ config GPIO_MCUX_LPC_PORT1 endif # GPIO_MCUX_LPC +config I2C_4 + default y + depends on I2C + config SPI_5 default y depends on SPI diff --git a/boards/arm/lpcxpresso54114/doc/index.rst b/boards/arm/lpcxpresso54114/doc/index.rst index 73f0b680373..ee3a6b67e48 100644 --- a/boards/arm/lpcxpresso54114/doc/index.rst +++ b/boards/arm/lpcxpresso54114/doc/index.rst @@ -62,6 +62,8 @@ features: +-----------+------------+-------------------------------------+ | GPIO | on-chip | gpio | +-----------+------------+-------------------------------------+ +| I2C | on-chip | i2c | ++-----------+------------+-------------------------------------+ | SPI | on-chip | spi | +-----------+------------+-------------------------------------+ | USART | on-chip | serial port-polling | @@ -93,6 +95,10 @@ functionality of a pin. +---------+-----------------+----------------------------+ | PIO0_20 | SPI | SPI MOSI | +---------+-----------------+----------------------------+ +| PIO0_25 | I2C | I2C SCL | ++---------+-----------------+----------------------------+ +| PIO0_26 | I2C | I2C SDA | ++---------+-----------------+----------------------------+ | PIO0_29 | GPIO | RED LED | +---------+-----------------+----------------------------+ | PIO1_1 | SPI | SPI SSEL2 | diff --git a/boards/arm/lpcxpresso54114/lpcxpresso54114.dtsi b/boards/arm/lpcxpresso54114/lpcxpresso54114.dtsi index 6c99bfb84c4..b4a85d41fca 100644 --- a/boards/arm/lpcxpresso54114/lpcxpresso54114.dtsi +++ b/boards/arm/lpcxpresso54114/lpcxpresso54114.dtsi @@ -31,4 +31,6 @@ }; }; +arduino_i2c: &i2c4 {}; + arduino_spi: &spi5 {}; diff --git a/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.dts b/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.dts index f487061ff74..a40f9e6d9b7 100644 --- a/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.dts +++ b/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.dts @@ -68,6 +68,10 @@ status = "okay"; }; +&i2c4 { + status = "okay"; +}; + &spi5 { status = "okay"; }; diff --git a/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.yaml b/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.yaml index f11c81d2fe4..5451d22000d 100644 --- a/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.yaml +++ b/boards/arm/lpcxpresso54114/lpcxpresso54114_m4.yaml @@ -15,6 +15,8 @@ toolchain: - gnuarmemb - xtools supported: + - arduino_i2c - arduino_spi - gpio + - i2c - spi diff --git a/boards/arm/lpcxpresso54114/pinmux.c b/boards/arm/lpcxpresso54114/pinmux.c index d66e31d50b1..454ca69b66e 100644 --- a/boards/arm/lpcxpresso54114/pinmux.c +++ b/boards/arm/lpcxpresso54114/pinmux.c @@ -107,6 +107,26 @@ static int lpcxpresso_54114_pinmux_init(struct device *dev) pinmux_pin_set(port1, 10, port1_pin10_config); #endif +#ifdef CONFIG_I2C_4 + /* PORT0 PIN25 is configured as FC4_RTS_SCL_SSEL1 */ + pinmux_pin_set(port0, 25, IOCON_PIO_FUNC1 | + IOCON_PIO_I2CSLEW_I2C | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_INPFILT_OFF | + IOCON_PIO_I2CDRIVE_LOW | + IOCON_PIO_I2CFILTER_EN); + + /* PORT0 PIN26 is configured as FC4_CTS_SDA_SSEL0 */ + pinmux_pin_set(port0, 26, IOCON_PIO_FUNC1 | + IOCON_PIO_I2CSLEW_I2C | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_INPFILT_OFF | + IOCON_PIO_I2CDRIVE_LOW | + IOCON_PIO_I2CFILTER_EN); +#endif /* CONFIG_I2C_4 */ + #ifdef CONFIG_SPI_5 /* PORT0 PIN18 is configured as FC5_TXD_SCL_MISO */ pinmux_pin_set(port0, 18, IOCON_PIO_FUNC1 | diff --git a/soc/arm/nxp_lpc/lpc54xxx/soc.c b/soc/arm/nxp_lpc/lpc54xxx/soc.c index 93cb09d9828..a3d1bc03865 100644 --- a/soc/arm/nxp_lpc/lpc54xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc54xxx/soc.c @@ -66,6 +66,14 @@ static ALWAYS_INLINE void clock_init(void) /* Attach 12 MHz clock to FLEXCOMM0 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0); +#ifdef CONFIG_I2C_4 + /* attach 12 MHz clock to FLEXCOMM4 */ + CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4); + + /* reset FLEXCOMM for I2C */ + RESET_PeripheralReset(kFC4_RST_SHIFT_RSTn); +#endif /* CONFIG_I2C_4 */ + #ifdef CONFIG_SPI_5 /* Attach 12 MHz clock to FLEXCOMM5 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM5); diff --git a/soc/arm/nxp_lpc/lpc54xxx/soc.h b/soc/arm/nxp_lpc/lpc54xxx/soc.h index 492cefac919..8e8e7d9571c 100644 --- a/soc/arm/nxp_lpc/lpc54xxx/soc.h +++ b/soc/arm/nxp_lpc/lpc54xxx/soc.h @@ -30,6 +30,9 @@ #define IOCON_PIO_FUNC2 0x02u #define IOCON_PIO_FUNC3 0x03u #define IOCON_PIO_FUNC4 0x04u +#define IOCON_PIO_I2CDRIVE_LOW 0x00u +#define IOCON_PIO_I2CFILTER_EN 0x00u +#define IOCON_PIO_I2CSLEW_I2C 0x00u #define IOCON_PIO_INPFILT_OFF 0x0100u #define IOCON_PIO_INV_DI 0x00u #define IOCON_PIO_MODE_INACT 0x00u