From b18aefdfd3cfffa987414ef2cab9c352e02fedd8 Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Tue, 21 Sep 2021 14:12:23 -0500 Subject: [PATCH] dts: rt685: enabled flexcomm15 the RT685 contains an additional flexcomm peripheral, that supports only I2C. This commit adds this peripheral to the device tree, and enables pins and clocks for flexcomm15. Signed-off-by: Daniel DeGrasse --- boards/arm/mimxrt685_evk/pinmux.c | 44 +++++++++++++++++++ .../clock_control/clock_control_mcux_syscon.c | 3 ++ dts/arm/nxp/nxp_rt6xx_common.dtsi | 9 ++++ .../dt-bindings/clock/mcux_lpc_syscon_clock.h | 1 + soc/arm/nxp_imx/rt6xx/soc.c | 4 ++ 5 files changed, 61 insertions(+) diff --git a/boards/arm/mimxrt685_evk/pinmux.c b/boards/arm/mimxrt685_evk/pinmux.c index b45009f30bb..9b56a0543bf 100644 --- a/boards/arm/mimxrt685_evk/pinmux.c +++ b/boards/arm/mimxrt685_evk/pinmux.c @@ -961,6 +961,50 @@ static int mimxrt685_evk_pinmux_init(const struct device *dev) IOPCTL_PinMuxSet(IOPCTL, 2U, 9U, port2_pin9_config); #endif +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pmic_i2c), nxp_lpc_i2c, okay) && CONFIG_I2C + const uint32_t fc15_i2c_scl_config = (/* Pin is configured as I2C_SCL */ + IOPCTL_PIO_FUNC0 | + /* Enable pull-up / pull-down function */ + IOPCTL_PIO_PUPD_EN | + /* Enable pull-up function */ + IOPCTL_PIO_PULLUP_EN | + /* Enables input buffer function */ + IOPCTL_PIO_INBUF_EN | + /* Normal mode */ + IOPCTL_PIO_SLEW_RATE_NORMAL | + /* Normal drive */ + IOPCTL_PIO_FULLDRIVE_DI | + /* Analog mux is disabled */ + IOPCTL_PIO_ANAMUX_DI | + /* Pseudo Output Drain is enabled */ + IOPCTL_PIO_PSEDRAIN_EN | + /* Input function is not inverted */ + IOPCTL_PIO_INV_DI); + /* FC15_SCL PIN (coords: E16) is configured as I2C SCL */ + IOPCTL->FC15_I2C_SCL = fc15_i2c_scl_config; + + const uint32_t fc15_i2c_sda_config = (/* Pin is configured as I2C_SDA */ + IOPCTL_PIO_FUNC0 | + /* Enable pull-up / pull-down function */ + IOPCTL_PIO_PUPD_EN | + /* Enable pull-up function */ + IOPCTL_PIO_PULLUP_EN | + /* Enables input buffer function */ + IOPCTL_PIO_INBUF_EN | + /* Normal mode */ + IOPCTL_PIO_SLEW_RATE_NORMAL | + /* Normal drive */ + IOPCTL_PIO_FULLDRIVE_DI | + /* Analog mux is disabled */ + IOPCTL_PIO_ANAMUX_DI | + /* Pseudo Output Drain is enabled */ + IOPCTL_PIO_PSEDRAIN_EN | + /* Input function is not inverted */ + IOPCTL_PIO_INV_DI); + /* FC15_SDA PIN (coords: F16) is configured as I2C SDA */ + IOPCTL->FC15_I2C_SDA = fc15_i2c_sda_config; +#endif + #if DT_NODE_HAS_STATUS(DT_NODELABEL(lpadc0), okay) && CONFIG_ADC /* * The current test and sample applications uses a single channel for diff --git a/drivers/clock_control/clock_control_mcux_syscon.c b/drivers/clock_control/clock_control_mcux_syscon.c index e2a6627fb32..7691563e7d1 100644 --- a/drivers/clock_control/clock_control_mcux_syscon.c +++ b/drivers/clock_control/clock_control_mcux_syscon.c @@ -64,6 +64,9 @@ static int mcux_lpc_syscon_clock_control_get_subsys_rate( case MCUX_FLEXCOMM7_CLK: *rate = CLOCK_GetFlexCommClkFreq(7); break; + case MCUX_PMIC_I2C_CLK: + *rate = CLOCK_GetFlexCommClkFreq(15); + break; case MCUX_HS_SPI_CLK: #if defined(FSL_FEATURE_FLEXCOMM8_SPI_INDEX) *rate = CLOCK_GetHsLspiClkFreq(); diff --git a/dts/arm/nxp/nxp_rt6xx_common.dtsi b/dts/arm/nxp/nxp_rt6xx_common.dtsi index 3bf99ebb2a7..7f81c2adbd4 100644 --- a/dts/arm/nxp/nxp_rt6xx_common.dtsi +++ b/dts/arm/nxp/nxp_rt6xx_common.dtsi @@ -189,6 +189,15 @@ status = "disabled"; }; + pmic_i2c: i2c@127000 { + compatible = "nxp,lpc-i2c"; + reg = <0x127000 0x1000>; + interrupts = <21 0>; + label = "PMIC_I2C"; + clocks = <&clkctl1 MCUX_PMIC_I2C_CLK>; + status = "disabled"; + }; + usbhs: usbhs@144000 { compatible = "nxp,mcux-usbd"; reg = <0x144000 0x1000>; diff --git a/include/dt-bindings/clock/mcux_lpc_syscon_clock.h b/include/dt-bindings/clock/mcux_lpc_syscon_clock.h index cea10c3c3b4..7c29d200573 100644 --- a/include/dt-bindings/clock/mcux_lpc_syscon_clock.h +++ b/include/dt-bindings/clock/mcux_lpc_syscon_clock.h @@ -15,6 +15,7 @@ #define MCUX_FLEXCOMM5_CLK 5 #define MCUX_FLEXCOMM6_CLK 6 #define MCUX_FLEXCOMM7_CLK 7 +#define MCUX_PMIC_I2C_CLK 16 #define MCUX_HS_SPI_CLK 8 #define MCUX_USDHC1_CLK 9 #define MCUX_USDHC2_CLK 10 diff --git a/soc/arm/nxp_imx/rt6xx/soc.c b/soc/arm/nxp_imx/rt6xx/soc.c index 63fa0dabbbb..6f9fb99ecb2 100644 --- a/soc/arm/nxp_imx/rt6xx/soc.c +++ b/soc/arm/nxp_imx/rt6xx/soc.c @@ -235,6 +235,10 @@ static ALWAYS_INLINE void clock_init(void) CLOCK_AttachClk(kSFRO_to_FLEXCOMM2); #endif +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pmic_i2c), nxp_lpc_i2c, okay) + CLOCK_AttachClk(kFFRO_to_FLEXCOMM15); +#endif + #if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_usart, okay) CLOCK_AttachClk(kSFRO_to_FLEXCOMM4); #endif