i2c: mcux: Convert to supporting device tree

Update the MCUX I2C driver and related platforms to get their I2C
information from the device tree.  We also updated a few of the sensor
drivers found on the FRDM & Hexiwear boards to get their I2C bus name
from the device tree instead of directly from Kconfig.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2017-07-11 10:38:09 -05:00 committed by Kumar Gala
commit 563f8f1464
25 changed files with 199 additions and 47 deletions

View file

@ -86,9 +86,6 @@ if I2C_0
config I2C_0_DEFAULT_CFG
default 0x12
config I2C_0_IRQ_PRI
default 0
endif # I2C_0
config I2C_1
@ -99,9 +96,6 @@ if I2C_1
config I2C_1_DEFAULT_CFG
default 0x12
config I2C_1_IRQ_PRI
default 0
endif # I2C_1
endif # I2C
@ -115,9 +109,6 @@ endif # ADC
if FXOS8700
config FXOS8700_I2C_NAME
default I2C_0_NAME
config FXOS8700_I2C_ADDRESS
default 0x1d

View file

@ -83,9 +83,6 @@ if I2C_0
config I2C_0_DEFAULT_CFG
default 0x12
config I2C_0_IRQ_PRI
default 0
endif # I2C_0
endif # I2C

View file

@ -65,9 +65,6 @@ if I2C_1
config I2C_1_DEFAULT_CFG
default 0x12
config I2C_1_IRQ_PRI
default 0
endif # I2C_1
endif # I2C
@ -81,9 +78,6 @@ endif # ADC
if FXOS8700
config FXOS8700_I2C_NAME
default I2C_1_NAME
config FXOS8700_I2C_ADDRESS
default 0x1f

View file

@ -86,9 +86,6 @@ if I2C_0
config I2C_0_DEFAULT_CFG
default 0x12
config I2C_0_IRQ_PRI
default 0
endif # I2C_0
config I2C_1
@ -99,9 +96,6 @@ if I2C_1
config I2C_1_DEFAULT_CFG
default 0x12
config I2C_1_IRQ_PRI
default 0
endif # I2C_1
endif # I2C
@ -115,9 +109,6 @@ endif # ADC
if FXOS8700
config FXOS8700_I2C_NAME
default I2C_1_NAME
config FXOS8700_I2C_ADDRESS
default 0x1e
@ -131,9 +122,6 @@ endif # FXOS8700
if FXAS21002
config FXAS21002_I2C_NAME
default I2C_1_NAME
config FXAS21002_I2C_ADDRESS
default 0x20
@ -145,13 +133,6 @@ config FXAS21002_GPIO_PIN
endif # FXAS21002
if MAX30101
config MAX30101_I2C_NAME
default I2C_0_NAME
endif # MAX30101
if PWM_K64_FTM
config PWM_K64_FTM_0

View file

@ -57,9 +57,6 @@ if I2C
config I2C_1
def_bool y
config I2C_1_IRQ_PRI
default 0
endif # I2C
if ADC

View file

@ -63,6 +63,7 @@ config TWIHS_SAM
config I2C_MCUX
bool "MCUX I2C driver"
depends on HAS_MCUX
select HAS_DTS_I2C
default n
help
Enable the mcux I2C driver.

View file

@ -186,7 +186,7 @@ static const struct i2c_driver_api i2c_mcux_driver_api = {
static void i2c_mcux_config_func_0(struct device *dev);
static const struct i2c_mcux_config i2c_mcux_config_0 = {
.base = I2C0,
.base = (I2C_Type *)CONFIG_I2C_MCUX_0_BASE_ADDRESS,
.clock_source = I2C0_CLK_SRC,
.irq_config_func = i2c_mcux_config_func_0,
.default_cfg.raw = CONFIG_I2C_0_DEFAULT_CFG,
@ -203,10 +203,10 @@ static void i2c_mcux_config_func_0(struct device *dev)
{
ARG_UNUSED(dev);
IRQ_CONNECT(IRQ_I2C0, CONFIG_I2C_0_IRQ_PRI,
IRQ_CONNECT(CONFIG_I2C_MCUX_0_IRQ, CONFIG_I2C_MCUX_0_IRQ_PRI,
i2c_mcux_isr, DEVICE_GET(i2c_mcux_0), 0);
irq_enable(I2C0_IRQn);
irq_enable(CONFIG_I2C_MCUX_0_IRQ);
}
#endif /* CONFIG_I2C_0 */
@ -214,7 +214,7 @@ static void i2c_mcux_config_func_0(struct device *dev)
static void i2c_mcux_config_func_1(struct device *dev);
static const struct i2c_mcux_config i2c_mcux_config_1 = {
.base = I2C1,
.base = (I2C_Type *)CONFIG_I2C_MCUX_1_BASE_ADDRESS,
.clock_source = I2C1_CLK_SRC,
.irq_config_func = i2c_mcux_config_func_1,
.default_cfg.raw = CONFIG_I2C_1_DEFAULT_CFG,
@ -229,9 +229,9 @@ DEVICE_AND_API_INIT(i2c_mcux_1, CONFIG_I2C_1_NAME, &i2c_mcux_init,
static void i2c_mcux_config_func_1(struct device *dev)
{
IRQ_CONNECT(IRQ_I2C1, CONFIG_I2C_1_IRQ_PRI,
IRQ_CONNECT(CONFIG_I2C_MCUX_1_IRQ, CONFIG_I2C_MCUX_1_IRQ_PRI,
i2c_mcux_isr, DEVICE_GET(i2c_mcux_1), 0);
irq_enable(I2C1_IRQn);
irq_enable(CONFIG_I2C_MCUX_1_IRQ);
}
#endif /* CONFIG_I2C_1 */

View file

@ -20,6 +20,7 @@ config FXAS21002_NAME
config FXAS21002_I2C_NAME
string "I2C device name"
depends on !HAS_DTS_I2C
default I2C_0_NAME
config FXAS21002_I2C_ADDRESS

View file

@ -19,7 +19,7 @@ config FXOS8700_NAME
config FXOS8700_I2C_NAME
string "I2C device name"
depends on FXOS8700
depends on FXOS8700 && !HAS_DTS_I2C
default I2C_0_NAME
config FXOS8700_I2C_ADDRESS

View file

@ -21,6 +21,7 @@ config MAX30101_NAME
config MAX30101_I2C_NAME
string
prompt "I2C device name"
depends on !HAS_DTS_I2C
default "I2C_0"
config MAX30101_SMP_AVE

View file

@ -21,6 +21,9 @@
gpio_c = &gpioc;
gpio_d = &gpiod;
gpio_e = &gpioe;
i2c_0 = &i2c0;
i2c_1 = &i2c1;
i2c_2 = &i2c2;
};
chosen {
@ -39,6 +42,10 @@
status = "ok";
};
&i2c0 {
status = "ok";
};
&uart0 {
status = "ok";
current-speed = <115200>;

View file

@ -33,3 +33,9 @@
#define CONFIG_ADC_1_IRQ NXP_KINETIS_ADC16_400BB000_IRQ_0
#define CONFIG_ADC_1_IRQ_PRI NXP_KINETIS_ADC16_400BB000_IRQ_0_PRIORITY
#define CONFIG_ADC_1_NAME NXP_KINETIS_ADC16_400BB000_LABEL
#define CONFIG_I2C_0_NAME NXP_KINETIS_I2C_40066000_LABEL
#define CONFIG_FXOS8700_I2C_NAME NXP_KINETIS_I2C_40066000_LABEL
#define CONFIG_I2C_MCUX_0_BASE_ADDRESS NXP_KINETIS_I2C_40066000_BASE_ADDRESS_0
#define CONFIG_I2C_MCUX_0_IRQ NXP_KINETIS_I2C_40066000_IRQ_0
#define CONFIG_I2C_MCUX_0_IRQ_PRI NXP_KINETIS_I2C_40066000_IRQ_0_PRIORITY

View file

@ -9,6 +9,8 @@
aliases {
adc_0 = &adc0;
uart_0 = &uart0;
i2c_0 = &i2c0;
i2c_1 = &i2c1;
};
chosen {
@ -22,6 +24,10 @@
status = "ok";
};
&i2c0 {
status = "ok";
};
&uart0 {
status = "ok";
current-speed = <115200>;

View file

@ -5,3 +5,8 @@
#define CONFIG_ADC_0_IRQ NXP_KINETIS_ADC16_4003B000_IRQ_0
#define CONFIG_ADC_0_IRQ_PRI NXP_KINETIS_ADC16_4003B000_IRQ_0_PRIORITY
#define CONFIG_ADC_0_NAME NXP_KINETIS_ADC16_4003B000_LABEL
#define CONFIG_I2C_0_NAME NXP_KINETIS_I2C_40066000_LABEL
#define CONFIG_I2C_MCUX_0_BASE_ADDRESS NXP_KINETIS_I2C_40066000_BASE_ADDRESS_0
#define CONFIG_I2C_MCUX_0_IRQ NXP_KINETIS_I2C_40066000_IRQ_0
#define CONFIG_I2C_MCUX_0_IRQ_PRI NXP_KINETIS_I2C_40066000_IRQ_0_PRIORITY

View file

@ -15,6 +15,8 @@
gpio_a = &gpioa;
gpio_b = &gpiob;
gpio_c = &gpioc;
i2c_0 = &i2c0;
i2c_1 = &i2c1;
};
chosen {
@ -28,6 +30,10 @@
status = "ok";
};
&i2c1 {
status = "ok";
};
&lpuart0 {
status = "ok";
current-speed = <115200>;

View file

@ -8,3 +8,9 @@
#define CONFIG_ADC_0_IRQ NXP_KINETIS_ADC16_4003B000_IRQ_0
#define CONFIG_ADC_0_IRQ_PRI NXP_KINETIS_ADC16_4003B000_IRQ_0_PRIORITY
#define CONFIG_ADC_0_NAME NXP_KINETIS_ADC16_4003B000_LABEL
#define CONFIG_I2C_1_NAME NXP_KINETIS_I2C_40067000_LABEL
#define CONFIG_FXOS8700_I2C_NAME NXP_KINETIS_I2C_40067000_LABEL
#define CONFIG_I2C_MCUX_1_BASE_ADDRESS NXP_KINETIS_I2C_40067000_BASE_ADDRESS_0
#define CONFIG_I2C_MCUX_1_IRQ NXP_KINETIS_I2C_40067000_IRQ_0
#define CONFIG_I2C_MCUX_1_IRQ_PRI NXP_KINETIS_I2C_40067000_IRQ_0_PRIORITY

View file

@ -21,6 +21,9 @@
gpio_c = &gpioc;
gpio_d = &gpiod;
gpio_e = &gpioe;
i2c_0 = &i2c0;
i2c_1 = &i2c1;
i2c_2 = &i2c2;
};
chosen {
@ -39,6 +42,14 @@
status = "ok";
};
&i2c0 {
status = "ok";
};
&i2c1 {
status = "ok";
};
&uart0 {
status = "ok";
current-speed = <115200>;

View file

@ -33,3 +33,16 @@
#define CONFIG_ADC_1_IRQ NXP_KINETIS_ADC16_400BB000_IRQ_0
#define CONFIG_ADC_1_IRQ_PRI NXP_KINETIS_ADC16_400BB000_IRQ_0_PRIORITY
#define CONFIG_ADC_1_NAME NXP_KINETIS_ADC16_400BB000_LABEL
#define CONFIG_I2C_0_NAME NXP_KINETIS_I2C_40066000_LABEL
#define CONFIG_MAX30101_I2C_NAME NXP_KINETIS_I2C_40066000_LABEL
#define CONFIG_I2C_MCUX_0_BASE_ADDRESS NXP_KINETIS_I2C_40066000_BASE_ADDRESS_0
#define CONFIG_I2C_MCUX_0_IRQ NXP_KINETIS_I2C_40066000_IRQ_0
#define CONFIG_I2C_MCUX_0_IRQ_PRI NXP_KINETIS_I2C_40066000_IRQ_0_PRIORITY
#define CONFIG_I2C_1_NAME NXP_KINETIS_I2C_40067000_LABEL
#define CONFIG_FXOS8700_I2C_NAME NXP_KINETIS_I2C_40067000_LABEL
#define CONFIG_FXAS21002_I2C_NAME NXP_KINETIS_I2C_40067000_LABEL
#define CONFIG_I2C_MCUX_1_BASE_ADDRESS NXP_KINETIS_I2C_40067000_BASE_ADDRESS_0
#define CONFIG_I2C_MCUX_1_IRQ NXP_KINETIS_I2C_40067000_IRQ_0
#define CONFIG_I2C_MCUX_1_IRQ_PRI NXP_KINETIS_I2C_40067000_IRQ_0_PRIORITY

View file

@ -15,6 +15,8 @@
gpio_a = &gpioa;
gpio_b = &gpiob;
gpio_c = &gpioc;
i2c_0 = &i2c0;
i2c_1 = &i2c1;
};
chosen {
@ -27,6 +29,10 @@
status = "ok";
};
&i2c0 {
status = "ok";
};
&lpuart0 {
status = "ok";
current-speed = <115200>;

View file

@ -8,3 +8,8 @@
#define CONFIG_ADC_0_IRQ NXP_KINETIS_ADC16_4003B000_IRQ_0
#define CONFIG_ADC_0_IRQ_PRI NXP_KINETIS_ADC16_4003B000_IRQ_0_PRIORITY
#define CONFIG_ADC_0_NAME NXP_KINETIS_ADC16_4003B000_LABEL
#define CONFIG_I2C_0_NAME NXP_KINETIS_I2C_40066000_LABEL
#define CONFIG_I2C_MCUX_0_BASE_ADDRESS NXP_KINETIS_I2C_40066000_BASE_ADDRESS_0
#define CONFIG_I2C_MCUX_0_IRQ NXP_KINETIS_I2C_40066000_IRQ_0
#define CONFIG_I2C_MCUX_0_IRQ_PRI NXP_KINETIS_I2C_40066000_IRQ_0_PRIORITY

View file

@ -73,6 +73,36 @@
};
};
i2c0: i2c@40066000 {
compatible = "nxp,kinetis-i2c";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40066000 0x1000>;
interrupts = <24 0>;
label = "I2C_0";
status = "disabled";
};
i2c1: i2c@40067000 {
compatible = "nxp,kinetis-i2c";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40067000 0x1000>;
interrupts = <25 0>;
label = "I2C_1";
status = "disabled";
};
i2c2: i2c@400e6000 {
compatible = "nxp,kinetis-i2c";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x400e6000 0x1000>;
interrupts = <74 0>;
label = "I2C_2";
status = "disabled";
};
uart0: uart@4006a000 {
compatible = "nxp,kinetis-uart";
reg = <0x4006a000 0x1000>;

View file

@ -22,6 +22,26 @@
reg = <0 0x20000>;
};
i2c0: i2c@40066000 {
compatible = "nxp,kinetis-i2c";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40066000 0x1000>;
interrupts = <8 0>;
label = "I2C_0";
status = "disabled";
};
i2c1: i2c@40067000 {
compatible = "nxp,kinetis-i2c";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40067000 0x1000>;
interrupts = <9 0>;
label = "I2C_1";
status = "disabled";
};
uart0: uart@4006A000 {
compatible = "nxp,kinetis-lpsci";
reg = <0x4006A000 0xc>;

View file

@ -49,6 +49,26 @@
reg = <0 0x80000>;
};
i2c0: i2c@40066000 {
compatible = "nxp,kinetis-i2c";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40066000 0x1000>;
interrupts = <8 0>;
label = "I2C_0";
status = "disabled";
};
i2c1: i2c@40067000 {
compatible = "nxp,kinetis-i2c";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40067000 0x1000>;
interrupts = <9 0>;
label = "I2C_1";
status = "disabled";
};
lpuart0: lpuart@40054000 {
compatible = "nxp,kinetis-lpuart";
reg = <0x40054000 0x18>;

View file

@ -49,6 +49,26 @@
reg = <0 0x80000>;
};
i2c0: i2c@40066000 {
compatible = "nxp,kinetis-i2c";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40066000 0x1000>;
interrupts = <8 0>;
label = "I2C_0";
status = "disabled";
};
i2c1: i2c@40067000 {
compatible = "nxp,kinetis-i2c";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40067000 0x1000>;
interrupts = <9 0>;
label = "I2C_1";
status = "disabled";
};
lpuart0: lpuart@40054000 {
compatible = "nxp,kinetis-lpuart";
reg = <0x40054000 0x18>;

View file

@ -0,0 +1,28 @@
---
title: Kinetis I2C Controller
version: 0.1
description: >
This is a representation of the Kinetis I2C nodes
inherits:
- !include i2c.yaml
properties:
- compatible:
type: string
category: required
description: compatible strings
constraint: "nxp,kinetis-i2c"
- reg:
type: int
description: mmio register space
generation: define
category: required
- interrupts:
type: compound
category: required
description: required interrupts
generation: define