dts: Use separate compatibles for Nordic TWI/TWIM/TWIS peripherals

This commit introduces separate "compatible" strings for dts nodes
representing different types of Nordic TWI peripherals. Previously
"nordic,nrf-i2c" was used for both TWI and TWIM, and TWIS was not
supported.

Quite a few files need to be touched by this commit but the changes can
be divided into groups of related or very similar ones, distinguishable
by the initial part of the path to the modified file:

* dts/bindings/i2c/
  new bindings for "nordic,nrf-twim" and "nordic,nrf-twis" are added
  and the one for "nordic,nrf-i2s" is renamed to "nordic,nrf-twi",
  common fields for all these bindings are extracted to a shared file

* dts/arm/nordic/
  "compatible" properties in i2cX nodes are updated (when there is no
  choice as only one type of TWI peripheral is available) or replaced
  with a comment pointing out that the proper type of peripheral needs
  to be picked at some upper layer

* drivers/i2c/
  both flavors of i2c_nrfx drivers are updated with the new names of
  macros generated from dts

* boards/
  all i2cX nodes in dts files for boards equipped with an nRF chip are
  updated with the proper "compatible" property, according to the type
  of TWI peripheral that is currently selected for the board by the
  corresponding Kconfig choice option (I2C_x_NRF_TWI*)

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
Andrzej Głąbek 2019-09-25 09:58:21 +02:00 committed by Carles Cufí
parent 90a2e1f0aa
commit dd4c57d564
38 changed files with 147 additions and 60 deletions

View file

@ -73,6 +73,7 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <20>;
scl-pin = <22>;

View file

@ -89,6 +89,7 @@
};
&i2c2 {
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;

View file

@ -79,6 +79,7 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <26>;
scl-pin = <27>;

View file

@ -103,6 +103,7 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <26>;
scl-pin = <27>;

View file

@ -93,12 +93,14 @@
};
&i2c0 {
compatible = "nordic,nrf-twim";
status = "okay";
sda-pin = <20>;
scl-pin = <22>;
};
&i2c1 {
compatible = "nordic,nrf-twim";
status = "okay";
sda-pin = <41>;
scl-pin = <11>;

View file

@ -101,6 +101,7 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <26>;
scl-pin = <27>;

View file

@ -90,8 +90,8 @@
&uart0 {
compatible = "nordic,nrf-uart";
current-speed = <115200>;
status = "okay";
current-speed = <115200>;
tx-pin = <6>;
rx-pin = <8>;
rts-pin = <5>;
@ -99,8 +99,9 @@
};
&i2c0 {
/* Arduino compatible PINs */
compatible = "nordic,nrf-twi";
status = "okay";
/* Arduino compatible PINs */
sda-pin = <26>;
scl-pin = <27>;
};

View file

@ -80,12 +80,14 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <26>;
scl-pin = <27>;
};
&i2c1 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <30>;
scl-pin = <31>;

View file

@ -85,12 +85,14 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <12>;
scl-pin = <11>;
};
&i2c1 {
compatible = "nordic,nrf-twi";
/* Cannot be used together with spi1. */
/* status = "okay"; */
sda-pin = <2>;

View file

@ -82,12 +82,14 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <26>;
scl-pin = <27>;
};
&i2c1 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <30>;
scl-pin = <31>;

View file

@ -80,6 +80,7 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <5>;
scl-pin = <6>;

View file

@ -121,8 +121,8 @@
&uart0 {
compatible = "nordic,nrf-uart";
current-speed = <115200>;
status = "okay";
current-speed = <115200>;
tx-pin = <6>;
rx-pin = <8>;
rts-pin = <5>;
@ -137,12 +137,14 @@ arduino_serial: &uart1 {
};
arduino_i2c: &i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <26>;
scl-pin = <27>;
};
&i2c1 {
compatible = "nordic,nrf-twi";
/* Cannot be used together with spi1. */
/* status = "okay"; */
sda-pin = <30>;

View file

@ -84,8 +84,8 @@
&uart0 {
compatible = "nordic,nrf-uarte";
current-speed = <115200>;
status = "okay";
current-speed = <115200>;
tx-pin = <20>;
rx-pin = <24>;
rts-pin = <17>;
@ -93,12 +93,14 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <26>;
scl-pin = <27>;
};
&i2c1 {
compatible = "nordic,nrf-twi";
/* Cannot be used together with spi1. */
/* status = "okay"; */
sda-pin = <30>;

View file

@ -70,6 +70,7 @@
};
&i2c0 {
compatible = "nordic,nrf-twi";
sda-pin = <25>;
scl-pin = <26>;
};

View file

@ -55,6 +55,7 @@
};
&i2c0 {
compatible = "nordic,nrf-twim";
status = "okay";
sda-pin = <28>;
scl-pin = <2>;

View file

@ -127,12 +127,14 @@ arduino_serial: &uart0 {
};
arduino_i2c: &i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <26>;
scl-pin = <27>;
};
&i2c1 {
compatible = "nordic,nrf-twi";
/* Cannot be used together with spi1. */
/* status = "okay"; */
sda-pin = <30>;

View file

@ -70,14 +70,15 @@
};
&uart0 {
status = "okay";
compatible = "nordic,nrf-uart";
status = "okay";
current-speed = <115200>;
tx-pin = <3>;
rx-pin = <2>;
};
&i2c0 {
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
sda-pin = <7>;
@ -112,6 +113,7 @@
};
&i2c1 {
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
sda-pin = <14>;

View file

@ -65,6 +65,7 @@
};
&i2c0 {
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
sda-pin = <26>;

View file

@ -104,6 +104,7 @@
};
&i2c2 {
compatible = "nordic,nrf-twim";
status = "okay";
sda-pin = <30>;
scl-pin = <31>;

View file

@ -117,6 +117,7 @@
};
&i2c0 { /* feather I2C */
compatible = "nordic,nrf-twi";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
sda-pin = <26>;

View file

@ -117,6 +117,7 @@
};
&i2c0 { /* feather I2C */
compatible = "nordic,nrf-twi";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
sda-pin = <26>;

View file

@ -25,6 +25,7 @@
};
&i2c1 { /* power monitoring */
compatible = "nordic,nrf-twi";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
sda-pin = <24>;

View file

@ -117,6 +117,7 @@
};
&i2c0 { /* feather I2C */
compatible = "nordic,nrf-twi";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
sda-pin = <26>;

View file

@ -98,6 +98,7 @@ arduino_serial: &uart1 {
};
arduino_i2c: &i2c0 {
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
sda-pin = <26>;

View file

@ -0,0 +1,3 @@
&arduino_i2c {
compatible = "nordic,nrf-twi";
};

View file

@ -0,0 +1,3 @@
&arduino_i2c {
compatible = "nordic,nrf-twi";
};

View file

@ -244,13 +244,13 @@ static int twi_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
#define I2C_NRFX_TWI_DEVICE(idx) \
BUILD_ASSERT_MSG( \
I2C_NRFX_TWI_FREQUENCY( \
DT_NORDIC_NRF_I2C_I2C_##idx##_CLOCK_FREQUENCY) \
DT_NORDIC_NRF_TWI_I2C_##idx##_CLOCK_FREQUENCY) \
!= I2C_NRFX_TWI_INVALID_FREQUENCY, \
"Wrong I2C " #idx " frequency setting in dts"); \
static int twi_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(DT_NORDIC_NRF_I2C_I2C_##idx##_IRQ_0, \
DT_NORDIC_NRF_I2C_I2C_##idx##_IRQ_0_PRIORITY, \
IRQ_CONNECT(DT_NORDIC_NRF_TWI_I2C_##idx##_IRQ_0, \
DT_NORDIC_NRF_TWI_I2C_##idx##_IRQ_0_PRIORITY, \
nrfx_isr, nrfx_twi_##idx##_irq_handler, 0); \
return init_twi(dev); \
} \
@ -263,14 +263,14 @@ static int twi_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
static const struct i2c_nrfx_twi_config twi_##idx##z_config = { \
.twi = NRFX_TWI_INSTANCE(idx), \
.config = { \
.scl = DT_NORDIC_NRF_I2C_I2C_##idx##_SCL_PIN, \
.sda = DT_NORDIC_NRF_I2C_I2C_##idx##_SDA_PIN, \
.scl = DT_NORDIC_NRF_TWI_I2C_##idx##_SCL_PIN, \
.sda = DT_NORDIC_NRF_TWI_I2C_##idx##_SDA_PIN, \
.frequency = I2C_NRFX_TWI_FREQUENCY( \
DT_NORDIC_NRF_I2C_I2C_##idx##_CLOCK_FREQUENCY) \
DT_NORDIC_NRF_TWI_I2C_##idx##_CLOCK_FREQUENCY) \
} \
}; \
DEVICE_DEFINE(twi_##idx, \
DT_NORDIC_NRF_I2C_I2C_##idx##_LABEL, \
DT_NORDIC_NRF_TWI_I2C_##idx##_LABEL, \
twi_##idx##_init, \
twi_nrfx_pm_control, \
&twi_##idx##_data, \
@ -286,4 +286,3 @@ I2C_NRFX_TWI_DEVICE(0);
#ifdef CONFIG_I2C_1_NRF_TWI
I2C_NRFX_TWI_DEVICE(1);
#endif

View file

@ -218,13 +218,13 @@ static int twim_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
#define I2C_NRFX_TWIM_DEVICE(idx) \
BUILD_ASSERT_MSG( \
I2C_NRFX_TWIM_FREQUENCY( \
DT_NORDIC_NRF_I2C_I2C_##idx##_CLOCK_FREQUENCY) \
DT_NORDIC_NRF_TWIM_I2C_##idx##_CLOCK_FREQUENCY) \
!= I2C_NRFX_TWIM_INVALID_FREQUENCY, \
"Wrong I2C " #idx " frequency setting in dts"); \
static int twim_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(DT_NORDIC_NRF_I2C_I2C_##idx##_IRQ_0, \
DT_NORDIC_NRF_I2C_I2C_##idx##_IRQ_0_PRIORITY, \
IRQ_CONNECT(DT_NORDIC_NRF_TWIM_I2C_##idx##_IRQ_0, \
DT_NORDIC_NRF_TWIM_I2C_##idx##_IRQ_0_PRIORITY, \
nrfx_isr, nrfx_twim_##idx##_irq_handler, 0); \
return init_twim(dev); \
} \
@ -237,14 +237,14 @@ static int twim_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
static const struct i2c_nrfx_twim_config twim_##idx##z_config = { \
.twim = NRFX_TWIM_INSTANCE(idx), \
.config = { \
.scl = DT_NORDIC_NRF_I2C_I2C_##idx##_SCL_PIN, \
.sda = DT_NORDIC_NRF_I2C_I2C_##idx##_SDA_PIN, \
.scl = DT_NORDIC_NRF_TWIM_I2C_##idx##_SCL_PIN, \
.sda = DT_NORDIC_NRF_TWIM_I2C_##idx##_SDA_PIN, \
.frequency = I2C_NRFX_TWIM_FREQUENCY( \
DT_NORDIC_NRF_I2C_I2C_##idx##_CLOCK_FREQUENCY) \
DT_NORDIC_NRF_TWIM_I2C_##idx##_CLOCK_FREQUENCY)\
} \
}; \
DEVICE_DEFINE(twim_##idx, \
DT_NORDIC_NRF_I2C_I2C_##idx##_LABEL, \
DT_NORDIC_NRF_TWIM_I2C_##idx##_LABEL, \
twim_##idx##_init, \
twim_nrfx_pm_control, \
&twim_##idx##_data, \

View file

@ -101,7 +101,7 @@
};
i2c0: i2c@40003000 {
compatible = "nordic,nrf-i2c";
compatible = "nordic,nrf-twi";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40003000 0x1000>;
@ -112,7 +112,7 @@
};
i2c1: i2c@40004000 {
compatible = "nordic,nrf-i2c";
compatible = "nordic,nrf-twi";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40004000 0x1000>;

View file

@ -101,7 +101,13 @@
};
i2c0: i2c@40003000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be TWI, TWIM, or TWIS,
* for the user to pick:
* compatible = "nordic,nrf-twi" or
* "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40003000 0x1000>;

View file

@ -108,7 +108,13 @@
};
i2c0: i2c@40003000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be TWI, TWIM, or TWIS,
* for the user to pick:
* compatible = "nordic,nrf-twi" or
* "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40003000 0x1000>;

View file

@ -109,7 +109,13 @@
};
i2c0: i2c@40003000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be TWI, TWIM, or TWIS,
* for the user to pick:
* compatible = "nordic,nrf-twi" or
* "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40003000 0x1000>;
@ -120,7 +126,13 @@
};
i2c1: i2c@40004000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be TWI, TWIM, or TWIS,
* for the user to pick:
* compatible = "nordic,nrf-twi" or
* "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40004000 0x1000>;

View file

@ -135,7 +135,13 @@
};
i2c0: i2c@40003000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be TWI, TWIM, or TWIS,
* for the user to pick:
* compatible = "nordic,nrf-twi" or
* "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40003000 0x1000>;
@ -146,7 +152,13 @@
};
i2c1: i2c@40004000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be TWI, TWIM, or TWIS,
* for the user to pick:
* compatible = "nordic,nrf-twi" or
* "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40004000 0x1000>;

View file

@ -149,7 +149,11 @@ uart3: uart@b000 {
};
i2c0: i2c@8000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be either TWIM or TWIS, for the user to pick:
* compatible = "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0x8000 0x1000>;
@ -160,7 +164,11 @@ i2c0: i2c@8000 {
};
i2c1: i2c@9000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be either TWIM or TWIS, for the user to pick:
* compatible = "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0x9000 0x1000>;
@ -171,7 +179,11 @@ i2c1: i2c@9000 {
};
i2c2: i2c@a000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be either TWIM or TWIS, for the user to pick:
* compatible = "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0xa000 0x1000>;
@ -182,7 +194,11 @@ i2c2: i2c@a000 {
};
i2c3: i2c@b000 {
compatible = "nordic,nrf-i2c";
/*
* This i2c node can be either TWIM or TWIS, for the user to pick:
* compatible = "nordic,nrf-twim" or
* "nordic,nrf-twis".
*/
#address-cells = <1>;
#size-cells = <0>;
reg = <0xb000 0x1000>;

View file

@ -2,12 +2,7 @@
# Copyright (c) 2018 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
title: Nordic nRF Family I2C Master node
description: >
This is a representation of the Nordic nRF I2C node
compatible: "nordic,nrf-i2c"
# Common fields for Nordic nRF family TWI peripherals
include: i2c-controller.yaml
@ -20,10 +15,10 @@ properties:
sda-pin:
type: int
description: SDA pin
required: true
description: SDA pin
scl-pin:
type: int
description: SCL pin
required: true
description: SCL pin

View file

@ -0,0 +1,10 @@
# Copyright (c) 2019 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
title: Nordic nRF family TWI
description: Nordic nRF family TWI (TWI master)
compatible: "nordic,nrf-twi"
include: nordic,nrf-twi-common.yaml

View file

@ -0,0 +1,10 @@
# Copyright (c) 2019 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
title: Nordic nRF family TWIM
description: Nordic nRF family TWIM (TWI master with EasyDMA)
compatible: "nordic,nrf-twim"
include: nordic,nrf-twi-common.yaml

View file

@ -1,32 +1,15 @@
# Copyright (c) 2019 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
title: Nordic TWIS
title: Nordic nRF family TWIS
description: >
Binding for the Nordic TWIS (TWI slave with EasyDMA)
description: Nordic nRF family TWIS (TWI slave with EasyDMA)
compatible: "nordic,nrf-twis"
include: base.yaml
include: nordic,nrf-twi-common.yaml
properties:
reg:
required: true
interrupts:
required: true
sda-pin:
type: int
required: true
description: SDA pin
scl-pin:
type: int
required: true
description: SCL pin
address-0:
type: int
required: false