Skip to content

Commit 8405754

Browse files
peterwangszkartben
authored andcommitted
boards: frdm_mcxa166, frdm_mcxa276: add i2c support
1. enable i2c support 2. verified tests/drivers/i2c/i2c_target_api Signed-off-by: Peter Wang <chaoyi.wang@nxp.com>
1 parent 073e04c commit 8405754

File tree

13 files changed

+280
-0
lines changed

13 files changed

+280
-0
lines changed

boards/nxp/frdm_mcxa166/board.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,26 @@ void board_early_init_hook(void)
200200
CLOCK_EnableClock(kCLOCK_GateADC1);
201201
#endif
202202

203+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpi2c0))
204+
CLOCK_SetClockDiv(kCLOCK_DivLPI2C0, 1u);
205+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPI2C0);
206+
#endif
207+
208+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpi2c1))
209+
CLOCK_SetClockDiv(kCLOCK_DivLPI2C1, 1u);
210+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPI2C1);
211+
#endif
212+
213+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpi2c2))
214+
CLOCK_SetClockDiv(kCLOCK_DivLPI2C2, 1u);
215+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPI2C2);
216+
#endif
217+
218+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpi2c3))
219+
CLOCK_SetClockDiv(kCLOCK_DivLPI2C3, 1u);
220+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPI2C3);
221+
#endif
222+
203223
#endif
204224

205225
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lptmr0))

boards/nxp/frdm_mcxa166/frdm_mcxa166-pinctrl.dtsi

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,39 @@
3434
drive-strength = "low";
3535
};
3636
};
37+
38+
pinmux_lpi2c1: pinmux_lpi2c1 {
39+
group0 {
40+
pinmux = <LPI2C1_SDA_P1_0>,
41+
<LPI2C1_SCL_P1_1>;
42+
slew-rate = "fast";
43+
drive-strength = "low";
44+
input-enable;
45+
bias-pull-up;
46+
drive-open-drain;
47+
};
48+
};
49+
pinmux_lpi2c2: pinmux_lpi2c2 {
50+
group0 {
51+
pinmux = <LPI2C2_SDA_P1_8>,
52+
<LPI2C2_SCL_P1_9>;
53+
slew-rate = "fast";
54+
drive-strength = "low";
55+
input-enable;
56+
bias-pull-up;
57+
drive-open-drain;
58+
};
59+
};
60+
pinmux_lpi2c3: pinmux_lpi2c3 {
61+
group0 {
62+
pinmux = <LPI2C3_SDA_P3_28>,
63+
<LPI2C3_SCL_P3_27>;
64+
slew-rate = "fast";
65+
drive-strength = "low";
66+
input-enable;
67+
bias-pull-up;
68+
drive-open-drain;
69+
};
70+
};
71+
3772
};

boards/nxp/frdm_mcxa166/frdm_mcxa166.dts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@
126126
pinctrl-names = "default";
127127
};
128128

129+
&lpi2c1 {
130+
status = "okay";
131+
pinctrl-0 = <&pinmux_lpi2c1>;
132+
pinctrl-names = "default";
133+
};
134+
135+
&lpi2c3 {
136+
status = "okay";
137+
pinctrl-0 = <&pinmux_lpi2c3>;
138+
pinctrl-names = "default";
139+
};
140+
129141
&flash {
130142
partitions {
131143
compatible = "fixed-partitions";

boards/nxp/frdm_mcxa166/frdm_mcxa166.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ supported:
1818
- uart
1919
- flash
2020
- adc
21+
- i2c
2122
- watchdog
2223
- counter
2324
- dma

boards/nxp/frdm_mcxa276/board.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,26 @@ void board_early_init_hook(void)
200200
CLOCK_EnableClock(kCLOCK_GateADC1);
201201
#endif
202202

203+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpi2c0))
204+
CLOCK_SetClockDiv(kCLOCK_DivLPI2C0, 1u);
205+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPI2C0);
206+
#endif
207+
208+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpi2c1))
209+
CLOCK_SetClockDiv(kCLOCK_DivLPI2C1, 1u);
210+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPI2C1);
211+
#endif
212+
213+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpi2c2))
214+
CLOCK_SetClockDiv(kCLOCK_DivLPI2C2, 1u);
215+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPI2C2);
216+
#endif
217+
218+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpi2c3))
219+
CLOCK_SetClockDiv(kCLOCK_DivLPI2C3, 1u);
220+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPI2C3);
221+
#endif
222+
203223
#endif
204224

205225
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lptmr0))

boards/nxp/frdm_mcxa276/frdm_mcxa276-pinctrl.dtsi

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,39 @@
3434
drive-strength = "low";
3535
};
3636
};
37+
38+
pinmux_lpi2c1: pinmux_lpi2c1 {
39+
group0 {
40+
pinmux = <LPI2C1_SDA_P1_0>,
41+
<LPI2C1_SCL_P1_1>;
42+
slew-rate = "fast";
43+
drive-strength = "low";
44+
input-enable;
45+
bias-pull-up;
46+
drive-open-drain;
47+
};
48+
};
49+
pinmux_lpi2c2: pinmux_lpi2c2 {
50+
group0 {
51+
pinmux = <LPI2C2_SDA_P1_8>,
52+
<LPI2C2_SCL_P1_9>;
53+
slew-rate = "fast";
54+
drive-strength = "low";
55+
input-enable;
56+
bias-pull-up;
57+
drive-open-drain;
58+
};
59+
};
60+
pinmux_lpi2c3: pinmux_lpi2c3 {
61+
group0 {
62+
pinmux = <LPI2C3_SDA_P3_28>,
63+
<LPI2C3_SCL_P3_27>;
64+
slew-rate = "fast";
65+
drive-strength = "low";
66+
input-enable;
67+
bias-pull-up;
68+
drive-open-drain;
69+
};
70+
};
71+
3772
};

boards/nxp/frdm_mcxa276/frdm_mcxa276.dts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@
126126
pinctrl-names = "default";
127127
};
128128

129+
&lpi2c1 {
130+
status = "okay";
131+
pinctrl-0 = <&pinmux_lpi2c1>;
132+
pinctrl-names = "default";
133+
};
134+
135+
&lpi2c3 {
136+
status = "okay";
137+
pinctrl-0 = <&pinmux_lpi2c3>;
138+
pinctrl-names = "default";
139+
};
140+
129141
&flash {
130142
partitions {
131143
compatible = "fixed-partitions";

boards/nxp/frdm_mcxa276/frdm_mcxa276.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ supported:
1818
- uart
1919
- flash
2020
- adc
21+
- i2c
2122
- watchdog
2223
- counter
2324
- dma

dts/arm/nxp/nxp_mcxa166.dtsi

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <arm/armv8-m.dtsi>
99
#include <zephyr/dt-bindings/clock/mcux_lpc_syscon_clock.h>
1010
#include <zephyr/dt-bindings/gpio/gpio.h>
11+
#include <zephyr/dt-bindings/i2c/i2c.h>
1112

1213
/ {
1314
cpus {
@@ -318,6 +319,50 @@
318319
clocks = <&syscon MCUX_LPADC2_CLK>;
319320
};
320321

322+
lpi2c0: i2c@4009a000 {
323+
compatible = "nxp,lpi2c";
324+
clock-frequency = <I2C_BITRATE_STANDARD>;
325+
#address-cells = <1>;
326+
#size-cells = <0>;
327+
reg = <0x4009a000 0x1000>;
328+
interrupts = <26 0>;
329+
clocks = <&syscon MCUX_LPI2C0_CLK>;
330+
status = "disabled";
331+
};
332+
333+
lpi2c1: i2c@4009b000 {
334+
compatible = "nxp,lpi2c";
335+
clock-frequency = <I2C_BITRATE_STANDARD>;
336+
#address-cells = <1>;
337+
#size-cells = <0>;
338+
reg = <0x4009b000 0x1000>;
339+
interrupts = <27 0>;
340+
clocks = <&syscon MCUX_LPI2C1_CLK>;
341+
status = "disabled";
342+
};
343+
344+
lpi2c2: i2c@400d4000 {
345+
compatible = "nxp,lpi2c";
346+
clock-frequency = <I2C_BITRATE_STANDARD>;
347+
#address-cells = <1>;
348+
#size-cells = <0>;
349+
reg = <0x400d4000 0x1000>;
350+
interrupts = <77 0>;
351+
clocks = <&syscon MCUX_LPI2C2_CLK>;
352+
status = "disabled";
353+
};
354+
355+
lpi2c3: i2c@400d5000 {
356+
compatible = "nxp,lpi2c";
357+
clock-frequency = <I2C_BITRATE_STANDARD>;
358+
#address-cells = <1>;
359+
#size-cells = <0>;
360+
reg = <0x400d5000 0x1000>;
361+
interrupts = <78 0>;
362+
clocks = <&syscon MCUX_LPI2C3_CLK>;
363+
status = "disabled";
364+
};
365+
321366
wwdt0: watchdog@4000c000 {
322367
compatible = "nxp,lpc-wwdt";
323368
reg = <0x4000c000 0x1000>;

dts/arm/nxp/nxp_mcxa276.dtsi

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <arm/armv8-m.dtsi>
99
#include <zephyr/dt-bindings/clock/mcux_lpc_syscon_clock.h>
1010
#include <zephyr/dt-bindings/gpio/gpio.h>
11+
#include <zephyr/dt-bindings/i2c/i2c.h>
1112

1213
/ {
1314
cpus {
@@ -318,6 +319,50 @@
318319
clocks = <&syscon MCUX_LPADC2_CLK>;
319320
};
320321

322+
lpi2c0: i2c@4009a000 {
323+
compatible = "nxp,lpi2c";
324+
clock-frequency = <I2C_BITRATE_STANDARD>;
325+
#address-cells = <1>;
326+
#size-cells = <0>;
327+
reg = <0x4009a000 0x1000>;
328+
interrupts = <26 0>;
329+
clocks = <&syscon MCUX_LPI2C0_CLK>;
330+
status = "disabled";
331+
};
332+
333+
lpi2c1: i2c@4009b000 {
334+
compatible = "nxp,lpi2c";
335+
clock-frequency = <I2C_BITRATE_STANDARD>;
336+
#address-cells = <1>;
337+
#size-cells = <0>;
338+
reg = <0x4009b000 0x1000>;
339+
interrupts = <27 0>;
340+
clocks = <&syscon MCUX_LPI2C1_CLK>;
341+
status = "disabled";
342+
};
343+
344+
lpi2c2: i2c@400d4000 {
345+
compatible = "nxp,lpi2c";
346+
clock-frequency = <I2C_BITRATE_STANDARD>;
347+
#address-cells = <1>;
348+
#size-cells = <0>;
349+
reg = <0x400d4000 0x1000>;
350+
interrupts = <77 0>;
351+
clocks = <&syscon MCUX_LPI2C2_CLK>;
352+
status = "disabled";
353+
};
354+
355+
lpi2c3: i2c@400d5000 {
356+
compatible = "nxp,lpi2c";
357+
clock-frequency = <I2C_BITRATE_STANDARD>;
358+
#address-cells = <1>;
359+
#size-cells = <0>;
360+
reg = <0x400d5000 0x1000>;
361+
interrupts = <78 0>;
362+
clocks = <&syscon MCUX_LPI2C3_CLK>;
363+
status = "disabled";
364+
};
365+
321366
wwdt0: watchdog@4000c000 {
322367
compatible = "nxp,lpc-wwdt";
323368
reg = <0x4000c000 0x1000>;

0 commit comments

Comments
 (0)