Skip to content

Commit 37e4660

Browse files
committed
arch: Add imx7d_m4 i2c definitions
Adds all necessary i2c definitions and configurations for imx7d_m4 soc. Signed-off-by: Diego Sueiro <[email protected]>
1 parent 6ec7af0 commit 37e4660

File tree

5 files changed

+146
-0
lines changed

5 files changed

+146
-0
lines changed

arch/arm/soc/nxp_imx/mcimx7_m4/Kconfig.defconfig.mcimx7_m4

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ config UART_IMX
4343

4444
endif # SERIAL
4545

46+
if I2C
47+
48+
config I2C_IMX
49+
def_bool y
50+
51+
endif # I2C
52+
4653
config DOMAIN_ID
4754
int
4855
default 1

arch/arm/soc/nxp_imx/mcimx7_m4/Kconfig.soc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config SOC_MCIMX7_M4
1313
bool "SOC_MCIMX7_M4"
1414
select HAS_IMX_HAL
1515
select HAS_IMX_GPIO
16+
select HAS_IMX_I2C
1617

1718
endchoice
1819

arch/arm/soc/nxp_imx/mcimx7_m4/soc.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,62 @@ static void nxp_mcimx7_uart_config(void)
9999
}
100100
#endif /* CONFIG_UART_IMX */
101101

102+
103+
#ifdef CONFIG_I2C_IMX
104+
static void nxp_mcimx7_i2c_config(void)
105+
{
106+
107+
#ifdef CONFIG_I2C_1
108+
/* In this example, we need to grasp board I2C exclusively */
109+
RDC_SetPdapAccess(RDC, rdcPdapI2c1,
110+
RDC_DOMAIN_PERM(CONFIG_DOMAIN_ID, RDC_DOMAIN_PERM_RW),
111+
false, false);
112+
/* Select I2C clock derived from OSC clock(24M) */
113+
CCM_UpdateRoot(CCM, ccmRootI2c1, ccmRootmuxI2cOsc24m, 0, 0);
114+
/* Enable I2C clock */
115+
CCM_EnableRoot(CCM, ccmRootI2c1);
116+
CCM_ControlGate(CCM, ccmCcgrGateI2c1, ccmClockNeededRunWait);
117+
#endif /* CONFIG_I2C_1 */
118+
119+
#ifdef CONFIG_I2C_2
120+
/* In this example, we need to grasp board I2C exclusively */
121+
RDC_SetPdapAccess(RDC, rdcPdapI2c2,
122+
RDC_DOMAIN_PERM(CONFIG_DOMAIN_ID, RDC_DOMAIN_PERM_RW),
123+
false, false);
124+
/* Select I2C clock derived from OSC clock(24M) */
125+
CCM_UpdateRoot(CCM, ccmRootI2c2, ccmRootmuxI2cOsc24m, 0, 0);
126+
/* Enable I2C clock */
127+
CCM_EnableRoot(CCM, ccmRootI2c2);
128+
CCM_ControlGate(CCM, ccmCcgrGateI2c2, ccmClockNeededRunWait);
129+
#endif /* CONFIG_I2C_2 */
130+
131+
#ifdef CONFIG_I2C_3
132+
/* In this example, we need to grasp board I2C exclusively */
133+
RDC_SetPdapAccess(RDC, rdcPdapI2c3,
134+
RDC_DOMAIN_PERM(CONFIG_DOMAIN_ID, RDC_DOMAIN_PERM_RW),
135+
false, false);
136+
/* Select I2C clock derived from OSC clock(24M) */
137+
CCM_UpdateRoot(CCM, ccmRootI2c3, ccmRootmuxI2cOsc24m, 0, 0);
138+
/* Enable I2C clock */
139+
CCM_EnableRoot(CCM, ccmRootI2c3);
140+
CCM_ControlGate(CCM, ccmCcgrGateI2c3, ccmClockNeededRunWait);
141+
#endif /* CONFIG_I2C_3 */
142+
143+
#ifdef CONFIG_I2C_4
144+
/* In this example, we need to grasp board I2C exclusively */
145+
RDC_SetPdapAccess(RDC, rdcPdapI2c4,
146+
RDC_DOMAIN_PERM(CONFIG_DOMAIN_ID, RDC_DOMAIN_PERM_RW),
147+
false, false);
148+
/* Select I2C clock derived from OSC clock(24M) */
149+
CCM_UpdateRoot(CCM, ccmRootI2c4, ccmRootmuxI2cOsc24m, 0, 0);
150+
/* Enable I2C clock */
151+
CCM_EnableRoot(CCM, ccmRootI2c4);
152+
CCM_ControlGate(CCM, ccmCcgrGateI2c4, ccmClockNeededRunWait);
153+
#endif /* CONFIG_I2C_4 */
154+
155+
}
156+
#endif /* CONFIG_I2C_IMX */
157+
102158
static int nxp_mcimx7_init(struct device *arg)
103159
{
104160
ARG_UNUSED(arg);
@@ -117,6 +173,10 @@ static int nxp_mcimx7_init(struct device *arg)
117173
nxp_mcimx7_uart_config();
118174
#endif /* CONFIG_UART_IMX */
119175

176+
#ifdef CONFIG_I2C_IMX
177+
nxp_mcimx7_i2c_config();
178+
#endif /* CONFIG_I2C_IMX */
179+
120180
return 0;
121181
}
122182

dts/arm/nxp/nxp_imx7d_m4.dtsi

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

77
#include <arm/armv7-m.dtsi>
88
#include <dt-bindings/gpio/gpio.h>
9+
#include <dt-bindings/i2c/i2c.h>
910

1011
/ {
1112
cpus {
@@ -201,6 +202,50 @@
201202
label = "UART_7";
202203
status = "disabled";
203204
};
205+
206+
i2c1: i2c@30A20000 {
207+
compatible = "fsl,imx7d-i2c";
208+
clock-frequency = <I2C_BITRATE_STANDARD>;
209+
#address-cells = <1>;
210+
#size-cells = <0>;
211+
reg = <0x30A20000 0x10000>;
212+
interrupts = <35 0>;
213+
label = "I2C_1";
214+
status = "disabled";
215+
};
216+
217+
i2c2: i2c@30A30000 {
218+
compatible = "fsl,imx7d-i2c";
219+
clock-frequency = <I2C_BITRATE_STANDARD>;
220+
#address-cells = <1>;
221+
#size-cells = <0>;
222+
reg = <0x30A30000 0x10000>;
223+
interrupts = <36 0>;
224+
label = "I2C_2";
225+
status = "disabled";
226+
};
227+
228+
i2c3: i2c@30A40000 {
229+
compatible = "fsl,imx7d-i2c";
230+
clock-frequency = <I2C_BITRATE_STANDARD>;
231+
#address-cells = <1>;
232+
#size-cells = <0>;
233+
reg = <0x30A40000 0x10000>;
234+
interrupts = <37 0>;
235+
label = "I2C_3";
236+
status = "disabled";
237+
};
238+
239+
i2c4: i2c@30A50000 {
240+
compatible = "fsl,imx7d-i2c";
241+
clock-frequency = <I2C_BITRATE_STANDARD>;
242+
#address-cells = <1>;
243+
#size-cells = <0>;
244+
reg = <0x30A50000 0x10000>;
245+
interrupts = <38 0>;
246+
label = "I2C_4";
247+
status = "disabled";
248+
};
204249
};
205250
};
206251

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (c) 2018 Linaro Limited
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
---
7+
title: i.MX I2C Controller
8+
version: 0.1
9+
10+
description: >
11+
This is a representation of the i.MX I2C nodes
12+
13+
inherits:
14+
!include i2c.yaml
15+
16+
properties:
17+
compatible:
18+
type: string
19+
category: required
20+
description: compatible strings
21+
constraint: "fsl,imx7d-i2c"
22+
23+
reg:
24+
type: int
25+
description: mmio register space
26+
generation: define
27+
category: required
28+
29+
interrupts:
30+
type: compound
31+
category: required
32+
description: required interrupts
33+
generation: define

0 commit comments

Comments
 (0)