* [PATCH 1/6] scripts/dtc: check: Add additional i2c reg flags support
[not found] <20200306131955.12806-1-Sergey.Semin@baikalelectronics.ru>
@ 2020-03-06 13:19 ` Sergey.Semin
2020-03-06 13:19 ` [PATCH 2/6] dt-bindings: i2c: Replace DW I2C legacy bindings with YAML-based one Sergey.Semin
2020-03-06 13:19 ` [PATCH 3/6] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller Sergey.Semin
2 siblings, 0 replies; 7+ messages in thread
From: Sergey.Semin @ 2020-03-06 13:19 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Serge Semin, Serge Semin, Alexey Malahov, Thomas Bogendoerfer,
Paul Burton, Ralf Baechle, devicetree, linux-kernel
From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Recently the I2C-controllers slave interface support was added to the
kernel I2C subsystem. In this case Linux can be used as, for example,
a I2C EEPROM machine. See [1] for details. Other than instantiating
the EEPROM-slave device from user-space there is a way to declare the
device in dts. In this case firstly the I2C bus controller must support
the slave interface. Secondly I2C-slave sub-node of that controller
must have "reg"-property with flag I2C_OWN_SLAVE_ADDRESS set (flag is
declared in [2]). That flag is declared as (1 << 30), which when set
makes dtc unhappy about too big address set for a I2C-slave:
Warning (i2c_bus_reg): /example-2/i2c@1120000/eeprom@64: I2C bus unit address format error, expected "40000064"
Warning (i2c_bus_reg): /example-2/i2c@1120000/eeprom@64:reg: I2C address must be less than 10-bits, got "0x40000064"
Similar problem would have happened if we had set the 10-bit address
flag I2C_TEN_BIT_ADDRESS in the "reg"-property.
In order to fix the problem we suggest to alter the I2C-bus reg-check
algorithm, so one would be aware of the upper bits set. Normally if no
flag specified, the 7-bit address is expected in the "reg"-property.
If I2C_TEN_BIT_ADDRESS is set, then the 10-bit address check will be
performed. The I2C_OWN_SLAVE_ADDRESS flag will be just ignored.
[1] Documentation/i2c/slave-interface.rst
[2] include/dt-bindings/i2c/i2c.h
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
scripts/dtc/checks.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 756f0fa9203f..01c1ad895e6d 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -1025,6 +1025,7 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node
const char *unitname = get_unitname(node);
char unit_addr[17];
uint32_t reg = 0;
+ uint32_t addr;
int len;
cell_t *cells = NULL;
@@ -1041,17 +1042,21 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node
}
reg = fdt32_to_cpu(*cells);
- snprintf(unit_addr, sizeof(unit_addr), "%x", reg);
+ addr = reg & 0x3FFFFFFFU;
+ snprintf(unit_addr, sizeof(unit_addr), "%x", addr);
if (!streq(unitname, unit_addr))
FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"",
unit_addr);
for (len = prop->val.len; len > 0; len -= 4) {
reg = fdt32_to_cpu(*(cells++));
- if (reg > 0x3ff)
+ addr = reg & 0x3FFFFFFFU;
+ if ((reg & (1 << 31)) && addr > 0x3ff)
FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
- reg);
-
+ addr);
+ else if (!(reg & (1 << 31)) && addr > 0x7f)
+ FAIL_PROP(c, dti, node, prop, "I2C address must be less than 7-bits, got \"0x%x\"",
+ addr);
}
}
WARNING(i2c_bus_reg, check_i2c_bus_reg, NULL, ®_format, &i2c_bus_bridge);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] dt-bindings: i2c: Replace DW I2C legacy bindings with YAML-based one
[not found] <20200306131955.12806-1-Sergey.Semin@baikalelectronics.ru>
2020-03-06 13:19 ` [PATCH 1/6] scripts/dtc: check: Add additional i2c reg flags support Sergey.Semin
@ 2020-03-06 13:19 ` Sergey.Semin
2020-03-12 21:43 ` Rob Herring
2020-03-06 13:19 ` [PATCH 3/6] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller Sergey.Semin
2 siblings, 1 reply; 7+ messages in thread
From: Sergey.Semin @ 2020-03-06 13:19 UTC (permalink / raw)
To: Rob Herring, Mark Rutland
Cc: Serge Semin, Serge Semin, Alexey Malahov, Thomas Bogendoerfer,
Paul Burton, Ralf Baechle, linux-i2c, devicetree, linux-kernel
From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Modern device tree bindings are supposed to be created as YAML-files
in accordance with dt-schema. This commit replaces Synopsys DW I2C
legacy bare text bindings with YAML file. As before the bindings file
states that the corresponding dts node is supposed to be compatible
either with generic DW I2C controller or with Microsemi Ocelot SoC I2C
one, to have registers, interrupts and clocks properties. In addition
the node may have clock-frequency, i2c-sda-hold-time-ns,
i2c-scl-falling-time-ns and i2c-sda-falling-time-ns optional properties.
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
.../bindings/i2c/i2c-designware.txt | 73 --------
.../bindings/i2c/snps,designware-i2c.yaml | 156 ++++++++++++++++++
2 files changed, 156 insertions(+), 73 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt
create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
diff --git a/Documentation/devicetree/bindings/i2c/i2c-designware.txt b/Documentation/devicetree/bindings/i2c/i2c-designware.txt
deleted file mode 100644
index 08be4d3846e5..000000000000
--- a/Documentation/devicetree/bindings/i2c/i2c-designware.txt
+++ /dev/null
@@ -1,73 +0,0 @@
-* Synopsys DesignWare I2C
-
-Required properties :
-
- - compatible : should be "snps,designware-i2c"
- or "mscc,ocelot-i2c" with "snps,designware-i2c" for fallback
- - reg : Offset and length of the register set for the device
- - interrupts : <IRQ> where IRQ is the interrupt number.
- - clocks : phandles for the clocks, see the description of clock-names below.
- The phandle for the "ic_clk" clock is required. The phandle for the "pclk"
- clock is optional. If a single clock is specified but no clock-name, it is
- the "ic_clk" clock. If both clocks are listed, the "ic_clk" must be first.
-
-Recommended properties :
-
- - clock-frequency : desired I2C bus clock frequency in Hz.
-
-Optional properties :
-
- - clock-names : Contains the names of the clocks:
- "ic_clk", for the core clock used to generate the external I2C clock.
- "pclk", the interface clock, required for register access.
-
- - reg : for "mscc,ocelot-i2c", a second register set to configure the SDA hold
- time, named ICPU_CFG:TWI_DELAY in the datasheet.
-
- - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds.
- This option is only supported in hardware blocks version 1.11a or newer and
- on Microsemi SoCs ("mscc,ocelot-i2c" compatible).
-
- - i2c-scl-falling-time-ns : should contain the SCL falling time in nanoseconds.
- This value which is by default 300ns is used to compute the tLOW period.
-
- - i2c-sda-falling-time-ns : should contain the SDA falling time in nanoseconds.
- This value which is by default 300ns is used to compute the tHIGH period.
-
-Examples :
-
- i2c@f0000 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "snps,designware-i2c";
- reg = <0xf0000 0x1000>;
- interrupts = <11>;
- clock-frequency = <400000>;
- };
-
- i2c@1120000 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "snps,designware-i2c";
- reg = <0x1120000 0x1000>;
- interrupt-parent = <&ictl>;
- interrupts = <12 1>;
- clock-frequency = <400000>;
- i2c-sda-hold-time-ns = <300>;
- i2c-sda-falling-time-ns = <300>;
- i2c-scl-falling-time-ns = <300>;
- };
-
- i2c@1120000 {
- #address-cells = <1>;
- #size-cells = <0>;
- reg = <0x2000 0x100>;
- clock-frequency = <400000>;
- clocks = <&i2cclk>;
- interrupts = <0>;
-
- eeprom@64 {
- compatible = "linux,slave-24c02";
- reg = <0x40000064>;
- };
- };
diff --git a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
new file mode 100644
index 000000000000..3f348f1ce172
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
@@ -0,0 +1,156 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/snps,designware-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Synopsys DesignWare APB I2C Device Tree Bindings
+
+maintainers:
+ - Jarkko Nikula <jarkko.nikula@linux.intel.com>
+
+allOf:
+ - $ref: /schemas/i2c/i2c-controller.yaml#
+
+if:
+ properties:
+ compatible:
+ contains:
+ const: mscc,ocelot-i2c
+then:
+ properties:
+ reg:
+ minItems: 1
+ items:
+ - description: DW APB I2C controller memory mapped registers.
+ - description: ICPU_CFG:TWI_DELAY registers to setup the SDA hold time.
+
+properties:
+ compatible:
+ oneOf:
+ - description: Generic Synopsys DesignWare I2C controller.
+ const: snps,designware-i2c
+ - description: Microsemi Ocelot SoCs I2C controller.
+ items:
+ - const: mscc,ocelot-i2c
+ - const: snps,designware-i2c
+
+ reg:
+ items:
+ - description: DW APB I2C controller memory mapped registers.
+
+ "#address-cells": true
+
+ "#size-cells": true
+
+ interrupts:
+ maxItems: 1
+
+ clocks:
+ minItems: 1
+ items:
+ - description: I2C controller reference clock source.
+ - description: APB interface clock source.
+
+ clock-names:
+ minItems: 1
+ items:
+ - const: ref
+ - const: pclk
+
+ resets:
+ maxItems: 1
+
+ clock-frequency:
+ description: Desired I2C bus clock frequency in Hz.
+ enum: [100000, 400000, 1000000, 3400000]
+ default: 400000
+
+ i2c-sda-hold-time-ns:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |
+ The property should contain the SDA hold time in nanoseconds. This option
+ is only supported in hardware blocks version 1.11a or newer or on
+ Microsemi SoCs.
+
+ i2c-scl-falling-time-ns:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |
+ The property should contain the SCL falling time in nanoseconds.
+ This value is used to compute the tLOW period.
+ default: 300
+
+ i2c-sda-falling-time-ns:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |
+ The property should contain the SDA falling time in nanoseconds.
+ This value is used to compute the tHIGH period.
+ default: 300
+
+ dmas:
+ items:
+ - description: TX DMA Channel.
+ - description: RX DMA Channel.
+
+ dma-names:
+ items:
+ - const: tx
+ - const: rx
+
+patternProperties:
+ "^.*@[0-9a-f]+$":
+ type: object
+ properties:
+ reg:
+ maxItems: 1
+
+additionalProperties: false
+
+required:
+ - compatible
+ - reg
+ - "#address-cells"
+ - "#size-cells"
+ - interrupts
+
+examples:
+ - |
+ i2c@f0000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "snps,designware-i2c";
+ reg = <0xf0000 0x1000>;
+ interrupts = <11>;
+ clock-frequency = <400000>;
+ };
+
+ - |
+ i2c@1120000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "snps,designware-i2c";
+ reg = <0x1120000 0x1000>;
+ interrupt-parent = <&ictl>;
+ interrupts = <12 1>;
+ clock-frequency = <400000>;
+ i2c-sda-hold-time-ns = <300>;
+ i2c-sda-falling-time-ns = <300>;
+ i2c-scl-falling-time-ns = <300>;
+ };
+
+ - |
+ i2c@1120000 {
+ compatible = "snps,designware-i2c";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x2000 0x100>;
+ clock-frequency = <400000>;
+ clocks = <&i2cclk>;
+ interrupts = <0>;
+
+ eeprom@64 {
+ compatible = "linux,slave-24c02";
+ reg = <0x40000064>;
+ };
+ };
+...
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
[not found] <20200306131955.12806-1-Sergey.Semin@baikalelectronics.ru>
2020-03-06 13:19 ` [PATCH 1/6] scripts/dtc: check: Add additional i2c reg flags support Sergey.Semin
2020-03-06 13:19 ` [PATCH 2/6] dt-bindings: i2c: Replace DW I2C legacy bindings with YAML-based one Sergey.Semin
@ 2020-03-06 13:19 ` Sergey.Semin
2020-03-12 21:43 ` Rob Herring
2 siblings, 1 reply; 7+ messages in thread
From: Sergey.Semin @ 2020-03-06 13:19 UTC (permalink / raw)
To: Rob Herring, Mark Rutland
Cc: Serge Semin, Serge Semin, Alexey Malahov, Thomas Bogendoerfer,
Paul Burton, Ralf Baechle, linux-i2c, devicetree, linux-kernel
From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Just add the "be,bt1-i2c" compatible string to the bindings. The rest of
the DW APB I2C properties can be freely used to describe the Baikal-T1
I2C controller dts-node.
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
index 3f348f1ce172..eab2c9293665 100644
--- a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
+++ b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
@@ -34,6 +34,8 @@ properties:
items:
- const: mscc,ocelot-i2c
- const: snps,designware-i2c
+ - description: Baikal-T1 SoCs I2C controller.
+ const: be,bt1-i2c
reg:
items:
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/6] dt-bindings: i2c: Replace DW I2C legacy bindings with YAML-based one
2020-03-06 13:19 ` [PATCH 2/6] dt-bindings: i2c: Replace DW I2C legacy bindings with YAML-based one Sergey.Semin
@ 2020-03-12 21:43 ` Rob Herring
2020-03-25 20:49 ` Sergey Semin
0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2020-03-12 21:43 UTC (permalink / raw)
To: Sergey.Semin
Cc: Mark Rutland, Serge Semin, Alexey Malahov, Thomas Bogendoerfer,
Paul Burton, Ralf Baechle, linux-i2c, devicetree, linux-kernel
On Fri, Mar 06, 2020 at 04:19:51PM +0300, Sergey.Semin@baikalelectronics.ru wrote:
> From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
>
> Modern device tree bindings are supposed to be created as YAML-files
> in accordance with dt-schema. This commit replaces Synopsys DW I2C
> legacy bare text bindings with YAML file. As before the bindings file
> states that the corresponding dts node is supposed to be compatible
> either with generic DW I2C controller or with Microsemi Ocelot SoC I2C
> one, to have registers, interrupts and clocks properties. In addition
> the node may have clock-frequency, i2c-sda-hold-time-ns,
> i2c-scl-falling-time-ns and i2c-sda-falling-time-ns optional properties.
>
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> ---
> .../bindings/i2c/i2c-designware.txt | 73 --------
> .../bindings/i2c/snps,designware-i2c.yaml | 156 ++++++++++++++++++
> 2 files changed, 156 insertions(+), 73 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt
> create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
>
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-designware.txt b/Documentation/devicetree/bindings/i2c/i2c-designware.txt
> deleted file mode 100644
> index 08be4d3846e5..000000000000
> --- a/Documentation/devicetree/bindings/i2c/i2c-designware.txt
> +++ /dev/null
> @@ -1,73 +0,0 @@
> -* Synopsys DesignWare I2C
> -
> -Required properties :
> -
> - - compatible : should be "snps,designware-i2c"
> - or "mscc,ocelot-i2c" with "snps,designware-i2c" for fallback
> - - reg : Offset and length of the register set for the device
> - - interrupts : <IRQ> where IRQ is the interrupt number.
> - - clocks : phandles for the clocks, see the description of clock-names below.
> - The phandle for the "ic_clk" clock is required. The phandle for the "pclk"
> - clock is optional. If a single clock is specified but no clock-name, it is
> - the "ic_clk" clock. If both clocks are listed, the "ic_clk" must be first.
> -
> -Recommended properties :
> -
> - - clock-frequency : desired I2C bus clock frequency in Hz.
> -
> -Optional properties :
> -
> - - clock-names : Contains the names of the clocks:
> - "ic_clk", for the core clock used to generate the external I2C clock.
> - "pclk", the interface clock, required for register access.
> -
> - - reg : for "mscc,ocelot-i2c", a second register set to configure the SDA hold
> - time, named ICPU_CFG:TWI_DELAY in the datasheet.
> -
> - - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds.
> - This option is only supported in hardware blocks version 1.11a or newer and
> - on Microsemi SoCs ("mscc,ocelot-i2c" compatible).
> -
> - - i2c-scl-falling-time-ns : should contain the SCL falling time in nanoseconds.
> - This value which is by default 300ns is used to compute the tLOW period.
> -
> - - i2c-sda-falling-time-ns : should contain the SDA falling time in nanoseconds.
> - This value which is by default 300ns is used to compute the tHIGH period.
> -
> -Examples :
> -
> - i2c@f0000 {
> - #address-cells = <1>;
> - #size-cells = <0>;
> - compatible = "snps,designware-i2c";
> - reg = <0xf0000 0x1000>;
> - interrupts = <11>;
> - clock-frequency = <400000>;
> - };
> -
> - i2c@1120000 {
> - #address-cells = <1>;
> - #size-cells = <0>;
> - compatible = "snps,designware-i2c";
> - reg = <0x1120000 0x1000>;
> - interrupt-parent = <&ictl>;
> - interrupts = <12 1>;
> - clock-frequency = <400000>;
> - i2c-sda-hold-time-ns = <300>;
> - i2c-sda-falling-time-ns = <300>;
> - i2c-scl-falling-time-ns = <300>;
> - };
> -
> - i2c@1120000 {
> - #address-cells = <1>;
> - #size-cells = <0>;
> - reg = <0x2000 0x100>;
> - clock-frequency = <400000>;
> - clocks = <&i2cclk>;
> - interrupts = <0>;
> -
> - eeprom@64 {
> - compatible = "linux,slave-24c02";
> - reg = <0x40000064>;
> - };
> - };
> diff --git a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
> new file mode 100644
> index 000000000000..3f348f1ce172
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
> @@ -0,0 +1,156 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/i2c/snps,designware-i2c.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Synopsys DesignWare APB I2C Device Tree Bindings
> +
> +maintainers:
> + - Jarkko Nikula <jarkko.nikula@linux.intel.com>
> +
> +allOf:
> + - $ref: /schemas/i2c/i2c-controller.yaml#
> +
> +if:
> + properties:
> + compatible:
> + contains:
> + const: mscc,ocelot-i2c
> +then:
> + properties:
> + reg:
> + minItems: 1
> + items:
> + - description: DW APB I2C controller memory mapped registers.
> + - description: ICPU_CFG:TWI_DELAY registers to setup the SDA hold time.
This won't work (it would be good to have an example that exercises
this). You need to move this definition to the main 'reg' definition
below and then do:
if:
properties:
compatible:
not:
contains:
const: mscc,ocelot-i2c
then:
properties:
reg:
maxItems: 1
> +
> +properties:
> + compatible:
> + oneOf:
> + - description: Generic Synopsys DesignWare I2C controller.
> + const: snps,designware-i2c
> + - description: Microsemi Ocelot SoCs I2C controller.
> + items:
> + - const: mscc,ocelot-i2c
> + - const: snps,designware-i2c
> +
> + reg:
> + items:
> + - description: DW APB I2C controller memory mapped registers.
> +
> + "#address-cells": true
> +
> + "#size-cells": true
> +
> + interrupts:
> + maxItems: 1
> +
> + clocks:
> + minItems: 1
> + items:
> + - description: I2C controller reference clock source.
> + - description: APB interface clock source.
> +
> + clock-names:
> + minItems: 1
> + items:
> + - const: ref
> + - const: pclk
> +
> + resets:
> + maxItems: 1
> +
> + clock-frequency:
> + description: Desired I2C bus clock frequency in Hz.
> + enum: [100000, 400000, 1000000, 3400000]
> + default: 400000
> +
> + i2c-sda-hold-time-ns:
> + $ref: /schemas/types.yaml#/definitions/uint32
Anything with a unit suffix has a type, so you can drop this.
> + description: |
> + The property should contain the SDA hold time in nanoseconds. This option
> + is only supported in hardware blocks version 1.11a or newer or on
> + Microsemi SoCs.
> +
> + i2c-scl-falling-time-ns:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: |
> + The property should contain the SCL falling time in nanoseconds.
> + This value is used to compute the tLOW period.
> + default: 300
> +
> + i2c-sda-falling-time-ns:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: |
> + The property should contain the SDA falling time in nanoseconds.
> + This value is used to compute the tHIGH period.
> + default: 300
> +
> + dmas:
> + items:
> + - description: TX DMA Channel.
> + - description: RX DMA Channel.
> +
> + dma-names:
> + items:
> + - const: tx
> + - const: rx
> +
> +patternProperties:
> + "^.*@[0-9a-f]+$":
> + type: object
> + properties:
> + reg:
> + maxItems: 1
No need for this as i2c-controller.yaml does this.
> +
> +additionalProperties: false
This doesn't work with i2c-controller.yaml. Change it to
'unevaluatedProperties: false' and eventually that will do what we need.
> +
> +required:
> + - compatible
> + - reg
> + - "#address-cells"
> + - "#size-cells"
> + - interrupts
> +
> +examples:
> + - |
> + i2c@f0000 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + compatible = "snps,designware-i2c";
> + reg = <0xf0000 0x1000>;
> + interrupts = <11>;
> + clock-frequency = <400000>;
> + };
> +
> + - |
> + i2c@1120000 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + compatible = "snps,designware-i2c";
> + reg = <0x1120000 0x1000>;
> + interrupt-parent = <&ictl>;
> + interrupts = <12 1>;
> + clock-frequency = <400000>;
> + i2c-sda-hold-time-ns = <300>;
> + i2c-sda-falling-time-ns = <300>;
> + i2c-scl-falling-time-ns = <300>;
> + };
> +
> + - |
> + i2c@1120000 {
> + compatible = "snps,designware-i2c";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <0x2000 0x100>;
> + clock-frequency = <400000>;
> + clocks = <&i2cclk>;
> + interrupts = <0>;
> +
> + eeprom@64 {
> + compatible = "linux,slave-24c02";
> + reg = <0x40000064>;
> + };
> + };
> +...
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/6] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
2020-03-06 13:19 ` [PATCH 3/6] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller Sergey.Semin
@ 2020-03-12 21:43 ` Rob Herring
2020-03-25 21:09 ` Sergey Semin
0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2020-03-12 21:43 UTC (permalink / raw)
To: Sergey.Semin
Cc: Mark Rutland, Serge Semin, Serge Semin, Alexey Malahov,
Thomas Bogendoerfer, Paul Burton, Ralf Baechle, linux-i2c,
devicetree, linux-kernel
On Fri, 6 Mar 2020 16:19:52 +0300, <Sergey.Semin@baikalelectronics.ru> wrote:
> From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
>
> Just add the "be,bt1-i2c" compatible string to the bindings. The rest of
> the DW APB I2C properties can be freely used to describe the Baikal-T1
> I2C controller dts-node.
>
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> ---
> Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml | 2 ++
> 1 file changed, 2 insertions(+)
>
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/6] dt-bindings: i2c: Replace DW I2C legacy bindings with YAML-based one
2020-03-12 21:43 ` Rob Herring
@ 2020-03-25 20:49 ` Sergey Semin
0 siblings, 0 replies; 7+ messages in thread
From: Sergey Semin @ 2020-03-25 20:49 UTC (permalink / raw)
To: Rob Herring
Cc: Mark Rutland, Alexey Malahov, Thomas Bogendoerfer, Paul Burton,
Ralf Baechle, linux-i2c, devicetree, linux-kernel
On Thu, Mar 12, 2020 at 04:43:08PM -0500, Rob Herring wrote:
> On Fri, Mar 06, 2020 at 04:19:51PM +0300, Sergey.Semin@baikalelectronics.ru wrote:
> > From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> >
> > Modern device tree bindings are supposed to be created as YAML-files
> > in accordance with dt-schema. This commit replaces Synopsys DW I2C
> > legacy bare text bindings with YAML file. As before the bindings file
> > states that the corresponding dts node is supposed to be compatible
> > either with generic DW I2C controller or with Microsemi Ocelot SoC I2C
> > one, to have registers, interrupts and clocks properties. In addition
> > the node may have clock-frequency, i2c-sda-hold-time-ns,
> > i2c-scl-falling-time-ns and i2c-sda-falling-time-ns optional properties.
> >
> > Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> > Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
> > Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > Cc: Paul Burton <paulburton@kernel.org>
> > Cc: Ralf Baechle <ralf@linux-mips.org>
> > ---
> > .../bindings/i2c/i2c-designware.txt | 73 --------
> > .../bindings/i2c/snps,designware-i2c.yaml | 156 ++++++++++++++++++
> > 2 files changed, 156 insertions(+), 73 deletions(-)
> > delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt
> > create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/i2c/i2c-designware.txt b/Documentation/devicetree/bindings/i2c/i2c-designware.txt
> > deleted file mode 100644
> > index 08be4d3846e5..000000000000
> > --- a/Documentation/devicetree/bindings/i2c/i2c-designware.txt
> > +++ /dev/null
> > @@ -1,73 +0,0 @@
> > -* Synopsys DesignWare I2C
> > -
> > -Required properties :
> > -
> > - - compatible : should be "snps,designware-i2c"
> > - or "mscc,ocelot-i2c" with "snps,designware-i2c" for fallback
> > - - reg : Offset and length of the register set for the device
> > - - interrupts : <IRQ> where IRQ is the interrupt number.
> > - - clocks : phandles for the clocks, see the description of clock-names below.
> > - The phandle for the "ic_clk" clock is required. The phandle for the "pclk"
> > - clock is optional. If a single clock is specified but no clock-name, it is
> > - the "ic_clk" clock. If both clocks are listed, the "ic_clk" must be first.
> > -
> > -Recommended properties :
> > -
> > - - clock-frequency : desired I2C bus clock frequency in Hz.
> > -
> > -Optional properties :
> > -
> > - - clock-names : Contains the names of the clocks:
> > - "ic_clk", for the core clock used to generate the external I2C clock.
> > - "pclk", the interface clock, required for register access.
> > -
> > - - reg : for "mscc,ocelot-i2c", a second register set to configure the SDA hold
> > - time, named ICPU_CFG:TWI_DELAY in the datasheet.
> > -
> > - - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds.
> > - This option is only supported in hardware blocks version 1.11a or newer and
> > - on Microsemi SoCs ("mscc,ocelot-i2c" compatible).
> > -
> > - - i2c-scl-falling-time-ns : should contain the SCL falling time in nanoseconds.
> > - This value which is by default 300ns is used to compute the tLOW period.
> > -
> > - - i2c-sda-falling-time-ns : should contain the SDA falling time in nanoseconds.
> > - This value which is by default 300ns is used to compute the tHIGH period.
> > -
> > -Examples :
> > -
> > - i2c@f0000 {
> > - #address-cells = <1>;
> > - #size-cells = <0>;
> > - compatible = "snps,designware-i2c";
> > - reg = <0xf0000 0x1000>;
> > - interrupts = <11>;
> > - clock-frequency = <400000>;
> > - };
> > -
> > - i2c@1120000 {
> > - #address-cells = <1>;
> > - #size-cells = <0>;
> > - compatible = "snps,designware-i2c";
> > - reg = <0x1120000 0x1000>;
> > - interrupt-parent = <&ictl>;
> > - interrupts = <12 1>;
> > - clock-frequency = <400000>;
> > - i2c-sda-hold-time-ns = <300>;
> > - i2c-sda-falling-time-ns = <300>;
> > - i2c-scl-falling-time-ns = <300>;
> > - };
> > -
> > - i2c@1120000 {
> > - #address-cells = <1>;
> > - #size-cells = <0>;
> > - reg = <0x2000 0x100>;
> > - clock-frequency = <400000>;
> > - clocks = <&i2cclk>;
> > - interrupts = <0>;
> > -
> > - eeprom@64 {
> > - compatible = "linux,slave-24c02";
> > - reg = <0x40000064>;
> > - };
> > - };
> > diff --git a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
> > new file mode 100644
> > index 000000000000..3f348f1ce172
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
> > @@ -0,0 +1,156 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/i2c/snps,designware-i2c.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Synopsys DesignWare APB I2C Device Tree Bindings
> > +
> > +maintainers:
> > + - Jarkko Nikula <jarkko.nikula@linux.intel.com>
> > +
> > +allOf:
> > + - $ref: /schemas/i2c/i2c-controller.yaml#
> > +
> > +if:
> > + properties:
> > + compatible:
> > + contains:
> > + const: mscc,ocelot-i2c
> > +then:
> > + properties:
> > + reg:
> > + minItems: 1
> > + items:
> > + - description: DW APB I2C controller memory mapped registers.
> > + - description: ICPU_CFG:TWI_DELAY registers to setup the SDA hold time.
>
> This won't work (it would be good to have an example that exercises
> this). You need to move this definition to the main 'reg' definition
> below and then do:
>
> if:
> properties:
> compatible:
> not:
> contains:
> const: mscc,ocelot-i2c
> then:
> properties:
> reg:
> maxItems: 1
>
Hm, I thought I tested this. Apparently I didn't do this well. Thanks for
pointing me out to this problem. I'll add the mscc,ocelot-i2c node to the examples
list to cover the optional two-regs case as well.
> > +
> > +properties:
> > + compatible:
> > + oneOf:
> > + - description: Generic Synopsys DesignWare I2C controller.
> > + const: snps,designware-i2c
> > + - description: Microsemi Ocelot SoCs I2C controller.
> > + items:
> > + - const: mscc,ocelot-i2c
> > + - const: snps,designware-i2c
> > +
> > + reg:
> > + items:
> > + - description: DW APB I2C controller memory mapped registers.
> > +
> > + "#address-cells": true
> > +
> > + "#size-cells": true
> > +
> > + interrupts:
> > + maxItems: 1
> > +
> > + clocks:
> > + minItems: 1
> > + items:
> > + - description: I2C controller reference clock source.
> > + - description: APB interface clock source.
> > +
> > + clock-names:
> > + minItems: 1
> > + items:
> > + - const: ref
> > + - const: pclk
> > +
> > + resets:
> > + maxItems: 1
> > +
> > + clock-frequency:
> > + description: Desired I2C bus clock frequency in Hz.
> > + enum: [100000, 400000, 1000000, 3400000]
> > + default: 400000
> > +
> > + i2c-sda-hold-time-ns:
> > + $ref: /schemas/types.yaml#/definitions/uint32
>
> Anything with a unit suffix has a type, so you can drop this.
>
Yes, but this and the following time-related properties are supposed to be
single numbers (see ./drivers/i2c/i2c-core-base.c for details), while "^.*-ns$"
is defined as uint32-array. So if I removed this $ref, I would have to add a
constraint like:
+ maxItems: 1
+ items:
+ maxItems: 1
which isn't that obvious, than just explicit uint32-type setting.
> > + description: |
> > + The property should contain the SDA hold time in nanoseconds. This option
> > + is only supported in hardware blocks version 1.11a or newer or on
> > + Microsemi SoCs.
> > +
> > + i2c-scl-falling-time-ns:
> > + $ref: /schemas/types.yaml#/definitions/uint32
> > + description: |
> > + The property should contain the SCL falling time in nanoseconds.
> > + This value is used to compute the tLOW period.
> > + default: 300
> > +
> > + i2c-sda-falling-time-ns:
> > + $ref: /schemas/types.yaml#/definitions/uint32
> > + description: |
> > + The property should contain the SDA falling time in nanoseconds.
> > + This value is used to compute the tHIGH period.
> > + default: 300
> > +
> > + dmas:
> > + items:
> > + - description: TX DMA Channel.
> > + - description: RX DMA Channel.
> > +
> > + dma-names:
> > + items:
> > + - const: tx
> > + - const: rx
> > +
>
> > +patternProperties:
> > + "^.*@[0-9a-f]+$":
> > + type: object
> > + properties:
> > + reg:
> > + maxItems: 1
>
> No need for this as i2c-controller.yaml does this.
>
Agreed.
> > +
> > +additionalProperties: false
>
> This doesn't work with i2c-controller.yaml. Change it to
> 'unevaluatedProperties: false' and eventually that will do what we need.
>
Yeah, I tried the "unevaluatedProperties: false" setting and discovered that
it didn't work. That's why I defined all the possible properties in this
DT schema with at least boolean type including the sub-node
pattern-based properties and set the "additionalProperties:
false", so unknown properties would cause the dt_binding_check error.
Since you are saying that unevaluatedProperties: is not implemented,
but it will be in future, and it's ok that currently we may have some
unevaluated properties left declared, then I'll do as you say:
remove all dummy boolean properties and replace "additionalProperties"
property with "unevaluatedProperties" one.
Regards,
-Sergey
> > +
> > +required:
> > + - compatible
> > + - reg
> > + - "#address-cells"
> > + - "#size-cells"
> > + - interrupts
> > +
> > +examples:
> > + - |
> > + i2c@f0000 {
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > + compatible = "snps,designware-i2c";
> > + reg = <0xf0000 0x1000>;
> > + interrupts = <11>;
> > + clock-frequency = <400000>;
> > + };
> > +
> > + - |
> > + i2c@1120000 {
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > + compatible = "snps,designware-i2c";
> > + reg = <0x1120000 0x1000>;
> > + interrupt-parent = <&ictl>;
> > + interrupts = <12 1>;
> > + clock-frequency = <400000>;
> > + i2c-sda-hold-time-ns = <300>;
> > + i2c-sda-falling-time-ns = <300>;
> > + i2c-scl-falling-time-ns = <300>;
> > + };
> > +
> > + - |
> > + i2c@1120000 {
> > + compatible = "snps,designware-i2c";
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > + reg = <0x2000 0x100>;
> > + clock-frequency = <400000>;
> > + clocks = <&i2cclk>;
> > + interrupts = <0>;
> > +
> > + eeprom@64 {
> > + compatible = "linux,slave-24c02";
> > + reg = <0x40000064>;
> > + };
> > + };
> > +...
> > --
> > 2.25.1
> >
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/6] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
2020-03-12 21:43 ` Rob Herring
@ 2020-03-25 21:09 ` Sergey Semin
0 siblings, 0 replies; 7+ messages in thread
From: Sergey Semin @ 2020-03-25 21:09 UTC (permalink / raw)
To: Rob Herring
Cc: Mark Rutland, Alexey Malahov, Thomas Bogendoerfer, Paul Burton,
Ralf Baechle, linux-i2c, devicetree, linux-kernel
On Thu, Mar 12, 2020 at 04:43:40PM -0500, Rob Herring wrote:
> On Fri, 6 Mar 2020 16:19:52 +0300, <Sergey.Semin@baikalelectronics.ru> wrote:
> > From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> >
> > Just add the "be,bt1-i2c" compatible string to the bindings. The rest of
> > the DW APB I2C properties can be freely used to describe the Baikal-T1
> > I2C controller dts-node.
> >
> > Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> > Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
> > Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > Cc: Paul Burton <paulburton@kernel.org>
> > Cc: Ralf Baechle <ralf@linux-mips.org>
> > ---
> > Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml | 2 ++
> > 1 file changed, 2 insertions(+)
> >
>
> Acked-by: Rob Herring <robh@kernel.org>
Seeing you and us having doubts regarding our vendor prefix and the
corresponding patch still hasn't been accepted, in the next patchset release
perhaps I will have to change the compatible string of this driver. It depends
on a result of the discussion: https://lkml.org/lkml/2020/3/13/239
Rob, could you get back to it, so we could come up with a solution?
Currently most of our team members are leaning towards "baikal,t1" = "vendor,chip"
prefixes to all the SoC specific devices. So the Baikal-T1 I2C compatible string
would be renamed to "baikal,t1-i2c". What do you think?
Regards,
-Sergey
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-03-25 21:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20200306131955.12806-1-Sergey.Semin@baikalelectronics.ru>
2020-03-06 13:19 ` [PATCH 1/6] scripts/dtc: check: Add additional i2c reg flags support Sergey.Semin
2020-03-06 13:19 ` [PATCH 2/6] dt-bindings: i2c: Replace DW I2C legacy bindings with YAML-based one Sergey.Semin
2020-03-12 21:43 ` Rob Herring
2020-03-25 20:49 ` Sergey Semin
2020-03-06 13:19 ` [PATCH 3/6] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller Sergey.Semin
2020-03-12 21:43 ` Rob Herring
2020-03-25 21:09 ` Sergey Semin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).