Skip to content

Commit ab25fdf

Browse files
JiafeiPankartben
authored andcommitted
boards: imx8mp_evk: add i2c support
Added i2c3 support on imx8mp_evk A53 board. Signed-off-by: Jiafei Pan <[email protected]>
1 parent 95e7a08 commit ab25fdf

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

boards/nxp/imx8mp_evk/imx8mp_evk-pinctrl.dtsi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,16 @@
6666
drive-strength = "x1";
6767
};
6868
};
69+
70+
pinmux_i2c3: pinmux_i2c3 {
71+
group0 {
72+
pinmux = <&iomuxc_i2c3_scl_i2c_scl_i2c3_scl>,
73+
<&iomuxc_i2c3_sda_i2c_sda_i2c3_sda>;
74+
bias-pull-up;
75+
input-schmitt-enable;
76+
slew-rate = "slow";
77+
drive-strength = "x4";
78+
input-enable;
79+
};
80+
};
6981
};

boards/nxp/imx8mp_evk/imx8mp_evk_mimx8ml8_a53.dts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/dts-v1/;
88

9+
#include <zephyr/dt-bindings/i2c/i2c.h>
910
#include <nxp/nxp_mimx8mp_a53.dtsi>
1011
#include "imx8mp_evk-pinctrl.dtsi"
1112

@@ -69,3 +70,10 @@
6970
pinctrl-0 = <&uart4_default>;
7071
pinctrl-names = "default";
7172
};
73+
74+
&i2c3 {
75+
status = "okay";
76+
pinctrl-0 = <&pinmux_i2c3>;
77+
pinctrl-names = "default";
78+
clock-frequency = <I2C_BITRATE_STANDARD>;
79+
};

soc/nxp/imx/imx8m/a53/soc.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,32 @@ static void soc_rdc_init(void)
4545
periphConfig.policy = RDC_DT_VAL(enet);
4646
RDC_SetPeriphAccessConfig(rdc_inst, &periphConfig);
4747
#endif
48+
49+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(i2c3)) && DT_NODE_HAS_PROP(DT_NODELABEL(i2c3), rdc)
50+
periphConfig.periph = kRDC_Periph_I2C3;
51+
periphConfig.policy = RDC_DT_VAL(i2c3);
52+
RDC_SetPeriphAccessConfig(rdc_inst, &periphConfig);
53+
#endif
4854
}
4955
#else
5056

5157
#define soc_rdc_init() do { } while (false)
5258

5359
#endif
5460

61+
static void soc_clock_init(void)
62+
{
63+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(i2c3))
64+
/* Set I2C source to SysPLL1 Div5 160MHZ */
65+
CLOCK_SetRootMux(kCLOCK_RootI2c3, kCLOCK_I2cRootmuxSysPll1Div5);
66+
/* Set root clock to 160MHZ / 10 = 16MHZ */
67+
CLOCK_SetRootDivider(kCLOCK_RootI2c3, 1U, 10U);
68+
CLOCK_EnableClock(kCLOCK_I2c3);
69+
#endif
70+
}
71+
5572
void soc_prep_hook(void)
5673
{
5774
soc_rdc_init();
75+
soc_clock_init();
5876
}

0 commit comments

Comments
 (0)