From ab949b023ba12ee5a2c8e55f5be43497b564b789 Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Sun, 8 Dec 2019 13:58:29 -0600 Subject: [PATCH] boards: lpcxpresso55s69: Enable i2c instance 4 Enables i2c instance 4 on the lpcxpresso55s69 board. Configures pinmuxes and clocks, and updates board documentation accordingly. Signed-off-by: Maureen Helm --- boards/arm/lpcxpresso55s69/Kconfig.defconfig | 8 ++++++ boards/arm/lpcxpresso55s69/doc/index.rst | 6 ++++ .../arm/lpcxpresso55s69/lpcxpresso55s69.dtsi | 9 ++++++ .../lpcxpresso55s69/lpcxpresso55s69_cpu0.dts | 4 +++ .../lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml | 2 ++ boards/arm/lpcxpresso55s69/pinmux.c | 28 +++++++++++++++++++ soc/arm/nxp_lpc/lpc55xxx/soc.c | 8 ++++++ 7 files changed, 65 insertions(+) diff --git a/boards/arm/lpcxpresso55s69/Kconfig.defconfig b/boards/arm/lpcxpresso55s69/Kconfig.defconfig index 723c8080d83..7f5f54b5e8e 100644 --- a/boards/arm/lpcxpresso55s69/Kconfig.defconfig +++ b/boards/arm/lpcxpresso55s69/Kconfig.defconfig @@ -33,8 +33,16 @@ config GPIO_MCUX_LPC_PORT1 endif # GPIO_MCUX_LPC +config I2C_4 + default y + depends on I2C + config SPI_8 default y depends on SPI +config FXOS8700_DRDY_INT1 + default y + depends on FXOS8700_TRIGGER + endif # BOARD_LPCXPRESSO55S69_CPU0 || BOARD_LPCXPRESSO55S69_CPU1 diff --git a/boards/arm/lpcxpresso55s69/doc/index.rst b/boards/arm/lpcxpresso55s69/doc/index.rst index 06831316de4..0bd4e9a0f6a 100644 --- a/boards/arm/lpcxpresso55s69/doc/index.rst +++ b/boards/arm/lpcxpresso55s69/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 | @@ -108,6 +110,10 @@ functionality of a pin. +---------+-----------------+----------------------------+ | PIO1_7 | GPIO | GREEN LED | +---------+-----------------+----------------------------+ +| PIO1_20 | I2C | I2C SCL | ++---------+-----------------+----------------------------+ +| PIO1_21 | I2C | I2C SDA | ++---------+-----------------+----------------------------+ System Clock ============ diff --git a/boards/arm/lpcxpresso55s69/lpcxpresso55s69.dtsi b/boards/arm/lpcxpresso55s69/lpcxpresso55s69.dtsi index 06ca4e3db87..91bd8241e0c 100644 --- a/boards/arm/lpcxpresso55s69/lpcxpresso55s69.dtsi +++ b/boards/arm/lpcxpresso55s69/lpcxpresso55s69.dtsi @@ -31,4 +31,13 @@ }; }; +arduino_i2c: &i2c4 { + mma8652fc@1d { + compatible = "nxp,fxos8700","nxp,mma8652fc"; + reg = <0x1d>; + label = "MMA8652FC"; + int1-gpios = <&gpio1 19 GPIO_ACTIVE_LOW>; + }; +}; + arduino_spi: &spi8 {}; diff --git a/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.dts b/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.dts index a71221bc8c6..daf019f92ed 100644 --- a/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.dts +++ b/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.dts @@ -69,6 +69,10 @@ status = "okay"; }; +&i2c4 { + status = "okay"; +}; + &spi8 { status = "okay"; }; diff --git a/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml b/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml index e86ef0cb14a..6ccba958447 100644 --- a/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml +++ b/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml @@ -15,6 +15,8 @@ toolchain: - gnuarmemb - xtools supported: + - arduino_i2c - arduino_spi - gpio + - i2c - spi diff --git a/boards/arm/lpcxpresso55s69/pinmux.c b/boards/arm/lpcxpresso55s69/pinmux.c index 1e0f51ef892..48c2703f596 100644 --- a/boards/arm/lpcxpresso55s69/pinmux.c +++ b/boards/arm/lpcxpresso55s69/pinmux.c @@ -87,6 +87,34 @@ static int lpcxpresso_55s69_pinmux_init(struct device *dev) pinmux_pin_set(port1, DT_ALIAS_SW2_GPIOS_PIN, sw2_config); #endif +#ifdef CONFIG_I2C_4 + /* PORT1 PIN20 is configured as FC4_TXD_SCL_MISO_WS */ + pinmux_pin_set(port1, 20, IOCON_PIO_FUNC5 | + IOCON_PIO_MODE_INACT | + IOCON_PIO_SLEW_STANDARD | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_OPENDRAIN_DI); + + /* PORT1 PIN21 is configured as FC4_RXD_SDA_MOSI_DATA */ + pinmux_pin_set(port1, 21, IOCON_PIO_FUNC5 | + IOCON_PIO_MODE_INACT | + IOCON_PIO_SLEW_STANDARD | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_OPENDRAIN_DI); +#endif /* CONFIG_I2C_4 */ + +#ifdef CONFIG_FXOS8700_TRIGGER + pinmux_pin_set(port1, 19, IOCON_PIO_FUNC0 | + IOCON_PIO_MODE_PULLUP | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_INPFILT_OFF | + IOCON_PIO_SLEW_STANDARD | + IOCON_PIO_OPENDRAIN_DI); +#endif + #ifdef CONFIG_SPI_8 /* PORT0 PIN26 is configured as HS_SPI_MOSI */ pinmux_pin_set(port0, 26, IOCON_PIO_FUNC9 | diff --git a/soc/arm/nxp_lpc/lpc55xxx/soc.c b/soc/arm/nxp_lpc/lpc55xxx/soc.c index 732d9fa792f..375ec32b0b4 100644 --- a/soc/arm/nxp_lpc/lpc55xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc55xxx/soc.c @@ -61,6 +61,14 @@ static ALWAYS_INLINE void clock_init(void) /* Enables the clock for the I/O controller.: Enable Clock. */ CLOCK_EnableClock(kCLOCK_Iocon); +#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_8 /* Attach 12 MHz clock to FLEXCOMM8 */ CLOCK_AttachClk(kFRO12M_to_HSLSPI);