i2c: designeware: Add Baikal-T1 System I2C support
Subsystems (6)
v3 cover i2c: designeware: Add Baikal-T1 System I2C support
Jarkko, Wolfram, the merge window is upon us, please review/merge in/whatever the patchset.
Initially this has been a small patchset which embedded the Baikal-T1 System I2C support into the DW APB I2C driver as is by using a simplest way. After a short discussion with Andy we decided to implement what he suggested (introduce regmap-based accessors and create a glue driver) and even more than that to provide some cleanups of the code. So here is what this patchset consists of.
First of all we've found out that current implementation of scripts/dtc didn't support i2c dt nodes with 10bit and slave flags set in the reg property. You'll see an error if you try to dt_binding_check it. So the very first patch fixes the problem by adding these flags support into the check_i2c_bus_reg() method.
Traditionally we converted the plain text-based DT binding to the DT schema and added Baikal-T1 System I2C device support there. This required to mark the reg property redundant for Baikal-T1 I2C since its reg-space is indirectly accessed by means of the System Controller cmd/read/write registers.
Then as Andy suggested we replaced the Synopsys DW APB I2C common driver registers IO accessors into the regmap API methods. This doesn't change the code logic much, though in two places we managed to replace some bulky peaces of code with a ready-to-use regmap methods.
Additionally before adding the glue layer API we initiated a set of cleanups:
- Define components of the multi-object drivers (like i2c-designware-core.o and i2c-designware-paltform.o) with using -y suffixed makefile variables instead of -objs suffixed one. This is encouraged by Documentation/kbuild/makefiles.rst text since -objs is supposed to be used to build host programs.
- Make DW I2C slave driver depended on the DW I2C core code instead of the platform one, which it really is.
- Move Intel Baytrail semaphore feature to the platform if-clause of the kernel config.
After this we finally can introduce the glue layer API for the DW APB I2C platform driver. So there are three methods exported from the driver:i2c_dw_plat_setup(), i2c_dw_plat_clear(), &i2c_dw_plat_dev_pm_ops to setup, cleanup and add PM operations to the glue driven I2C device. Before setting the platform DW I2C device up the glue probe code is supposed to create an instance of DW I2C device generic object and pre-initialize its struct device pointer together with optional platform-specific flags. In addition to that we converted the MSCC Ocelot SoC I2C specific code into the glue layer seeing it's really too specific and, which is more important, isn't that complicated so we could unpin it without much of worrying to break something.
Meanwhile we discovered that MODEL_CHERRYTRAIL and MODEL_MASK actually were no longer used in the code. MODEL_MSCC flag has been discarded since the MSCC Ocelot I2C code conversion to the glue driver. So now we can get rid of all the MODEL-specific flags.
Finally we introduced a glue driver with Baikal-T1 System I2C device support. The driver probe tries to find a syscon regmap, creates the DW APB I2C regmap based on it and passes it further to the DW I2C device descriptor. Then it does normal DW APB I2C platform setup by calling a generic setup method. Cleanup is straightforward. It's just calling a generic DW APB I2C clean method.
This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
base-commit: 0e698dfa2822 ("Linux 5.7-rc4")
tag: v5.7-rc4
Note new vendor prefix for Baikal-T1 System I2C device will be added in the framework of the next patchset:
https://lkml.org/lkml/2020/5/6/1047
Changelog v2:
- Fix the SoB tags.
- Use a shorter summary describing the bindings convertion patch.
- Patch "i2c: designware: Detect the FIFO size in the common code" has been acked by Jarkko and applied by Wolfram to for-next so drop it from the set.
- Patch "i2c: designware: Discard i2c_dw_read_comp_param() function" has been acked by Jarkko and applied by Wolfram to for-next so drop it from the set.
- Make sure that "mscc,ocelot-i2c" compatible node may have up to two registers space defined in the DT node, while normal DW I2C controller will have only one registers space.
- Add "mscc,ocelot-i2c" DT schema example to test the previous fix.
- Declare "unevaluatedProperties" property instead of "additionalProperties" one in the DT schema.
- Due to the previous fix we can now discard the dummy boolean properties declaration, since the proper type evaluation will be performed by the generic i2c-controller.yaml schema.
- Refactor the DW I2C APB driver related series to address the Andies notes.
- Convert DW APB I2C driver to using regmap instead of handwritten accessors.
- Use -y to build multi-object DW APB drivers.
- Fix DW APB I2C slave code dependency. It should depend on I2C_DESIGNWARE_CORE instead I2C_DESIGNWARE_PLATFORM.
- Move Baytrail semaphore config to the platform if-clause.
- Introduce a glue-layer platform driver API.
- Unpin Microsemi Ocelot I2C code into a glue driver.
- Remove MODEL_CHERRYTRAIL and MODEL_MASK as no longer needed.
- Add support for custom regmap passed from glue driver.
- Add Baikal-T1 System I2C support in a dedicated glue layer driver.
Changelog v3:
- Move fixes and less invasive patches to the head of the series.
- Add patch "dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example" since Rob says the flag can be discarded until dtc is fixed.
- Add patch "i2c: designware: Retrieve quirk flags as early as possible" as a first preparation before adding Baikal-T1 System I2C support.
- Add patch "i2c: designware: Move reg-space remapping into a dedicated function" as a second preparation before adding Baikal-T1 System I2C support.
- Add patch "i2c: designware: Add Baikal-T1 System I2C support", which integrates the Baikal-T1 I2C support into the DW I2C platform driver.
- Get back the reg property being mandatory even if it's Baikal-T1 System I2C DT node. Rob says it has to be in the DT node if there is a dedicated registers range in the System Controller registers space.
- Replace if-endif clause around the I2C_DESIGNWARE_BAYTRAIL config with "depends on" operator.
Serge Semin (12):
scripts/dtc: check: Add 10bit/slave i2c reg flags support
dt-bindings: i2c: Convert DW I2C binding to DT schema
dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example
dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
i2c: designware: Use -y to build multi-object modules
i2c: designware: slave: Set DW I2C core module dependency
i2c: designware: Add Baytrail sem config DW I2C platform dependency
i2c: designware: Discard Cherry Trail model flag
i2c: designware: Convert driver to using regmap API
i2c: designware: Retrieve quirk flags as early as possible
i2c: designware: Move reg-space remapping into a dedicated function
i2c: designware: Add Baikal-T1 System I2C support
.../bindings/i2c/i2c-designware.txt | 73 ------- .../bindings/i2c/snps,designware-i2c.yaml | 156 +++++++++++++++ drivers/i2c/busses/Kconfig | 31 +-- drivers/i2c/busses/Makefile | 17 +- drivers/i2c/busses/i2c-designware-common.c | 178 +++++++++++++----- drivers/i2c/busses/i2c-designware-core.h | 24 +-- drivers/i2c/busses/i2c-designware-master.c | 125 ++++++------ drivers/i2c/busses/i2c-designware-pcidrv.c | 1 - drivers/i2c/busses/i2c-designware-platdrv.c | 102 +++++++++- drivers/i2c/busses/i2c-designware-slave.c | 77 ++++---- scripts/dtc/checks.c | 13 +- 11 files changed, 532 insertions(+), 265 deletions(-) delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
Signature · 1 line
2.26.2
PATCH v3 1/12 scripts/dtc: check: Add 10bit/slave i2c reg flags support
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
--- scripts/dtc/checks.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
scripts/dtc/checks.c +9 -4
@@ -1028,6 +1028,7 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct nodeconst char *unitname =get_unitname (node);char unit_addr[17 ];uint32_t reg =0 ; +uint32_t addr;int len;cell_t *cells =NULL ;
@@ -1044,17 +1045,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);
Signature · 1 line
2.26.2
Rob Herring
maintainerRe: [PATCH v3 01/12] scripts/dtc: check: Add 10bit/slave i2c reg flags support
Quoted 31 lines · Serge Semin
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_ADDRESSset (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_ADDRESSin 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_ADDRESSis set, then the 10-bit address check will be performed. TheI2C_OWN_SLAVE_ADDRESSflag will be just ignored.[1]
Documentation/i2c/slave-interface.rst
[2]include/dt-bindings/i2c/i2c.hSigned-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Mika Westerberg <[email protected]>
Quoted 3 lines
--- scripts/dtc/checks.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
I've lost track of who all I've said this to already for this issue, but patches to dtc should be against upstream and a version of this has been sent there already. But it seems they've lost interest in addressing the review comments. So feel free to send another one. The same comment applies here.
Rob
Re: [PATCH v3 01/12] scripts/dtc: check: Add 10bit/slave i2c reg flags support
Quoted 37 lines · Rob Herring
Quoted 31 lines · Serge Semin
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_ADDRESSset (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_ADDRESSin 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_ADDRESSis set, then the 10-bit address check will be performed. TheI2C_OWN_SLAVE_ADDRESSflag will be just ignored.[1]
Documentation/i2c/slave-interface.rst
[2]include/dt-bindings/i2c/i2c.hSigned-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Mika Westerberg <[email protected]>Quoted 3 lines
--- scripts/dtc/checks.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
Quoted 5 lines
I've lost track of who all I've said this to already for this issue, but patches to dtc should be against upstream and a version of this has been sent there already. But it seems they've lost interest in addressing the review comments. So feel free to send another one. The same comment applies here.
Agreed. Rob, could you also take a look at the patch
[PATCH v3 03/12] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example from this series? You must have missed that. I've created that patch in accordance with your suggestion from v2:
https://lore.kernel.org/linux-i2c/20200511160924.GA9628@bogus/
-Sergey
Quoted 2 lines
Rob
Re: [PATCH v3 01/12] scripts/dtc: check: Add 10bit/slave i2c reg flags support
In reply to Rob HerringQuoted 36 lines · Rob Herring
Quoted 31 lines · Serge Semin
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_ADDRESSset (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_ADDRESSin 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_ADDRESSis set, then the 10-bit address check will be performed. TheI2C_OWN_SLAVE_ADDRESSflag will be just ignored.[1]
Documentation/i2c/slave-interface.rst
[2]include/dt-bindings/i2c/i2c.hSigned-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Mika Westerberg <[email protected]>Quoted 3 lines
--- scripts/dtc/checks.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
Quoted 5 lines
I've lost track of who all I've said this to already for this issue, but patches to dtc should be against upstream and a version of this has been sent there already. But it seems they've lost interest in addressing the review comments. So feel free to send another one. The same comment applies here.
There is another patch in this series:
[PATCH v3 04/12] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller which is also waiting for your review. I've updated it as you requested. Could you take a look at that too?
-Sergey
Quoted 2 lines
Rob
PATCH v3 2/12 dt-bindings: i2c: Convert DW I2C binding to DT schema
In reply to Serge SeminModern 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.
---
Changelog v2:
- Make sure that "mscc,ocelot-i2c" compatible node may have up to two registers space defined, while normal DW I2C controller will have only one registers space.
- Add "mscc,ocelot-i2c" example to test the previous fix.
- Declare "unevaluatedProperties" property instead of "additionalProperties" one.
- Due to the previous fix we can now discard the dummy boolean properties definitions, since the proper type evaluation will be performed by the generic i2c-controller.yaml schema.
Changelog v3:
- Discard $ref from the "-ns" suffixed properties since they've got the uint32-array type by default applied in the common schema. Set "maxItems: 1" there instead to make sure the property will have a single value specified.
--- .../bindings/i2c/i2c-designware.txt | 73 --------- .../bindings/i2c/snps,designware-i2c.yaml | 154 ++++++++++++++++++ 2 files changed, 154 insertions(+), 73 deletions(-) delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
Documentation/devicetree/bindings/i2c/i2c-designware.txt deleted +0 -73
@@ -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>; - }; - };
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [PATCH v3 02/12] dt-bindings: i2c: Convert DW I2C binding to DT schema
Quoted 33 lines · Serge Semin
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 <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>---
Changelog v2:
- Make sure that "mscc,ocelot-i2c" compatible node may have up to two registers space defined, while normal DW I2C controller will have only one registers space.
- Add "mscc,ocelot-i2c" example to test the previous fix.
- Declare "unevaluatedProperties" property instead of "additionalProperties" one.
- Due to the previous fix we can now discard the dummy boolean properties definitions, since the proper type evaluation will be performed by the generici2c-controller.yamlschema.Changelog v3:
- Discard $ref from the "-ns" suffixed properties since they've got the uint32-array type by default applied in the common schema. Set "maxItems: 1" there instead to make sure the property will have a single value specified.
Quoted 7 lines
--- .../bindings/i2c/i2c-designware.txt | 73 --------- .../bindings/i2c/snps,designware-i2c.yaml | 154 ++++++++++++++++++ 2 files changed, 154 insertions(+), 73 deletions(-) delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt create mode 100644 Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
PATCH v3 3/12 dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example
In reply to Serge Semindtc currently doesn't support I2C_OWN_SLAVE_ADDRESS flag set in the i2c "reg" property. If it is the compiler will print a warning:
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"
In order to silence dtc up let's discard the flag from the DW I2C DT binding example for now. Just revert this commit when dtc is fixed.
---
Changelog v3:
- This is a new patch created as a result of the Rob request to remove the EEPROM-slave bit setting in the DT binndings example until the dtc is fixed.
--- Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +1 -1
@@ -137,7 +137,7 @@ examples: eeprom@64 { compatible = "linux,slave-24c02"; - reg = <0x40000064>; + reg = <0x64>; }; }; - |
Signature · 1 line
2.26.2
Re: [PATCH v3 03/12] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example
Quoted 3 lines · Serge Semin
dtc currently doesn't support
I2C_OWN_SLAVE_ADDRESSflag set in the i2c "reg" property. If it is the compiler will print a warning:
Shouldn't be dtc whatever tools fixed?
Quoted 5 lines
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"In order to silence dtc up let's discard the flag from the DW I2C DT binding example for now. Just revert this commit when dtc is fixed.
Doesn't sound like a good idea. If user happens in between of these ping-pong change, how they will know this subtle issue?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 03/12] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example
Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · Serge Semin
dtc currently doesn't support
I2C_OWN_SLAVE_ADDRESSflag set in the i2c "reg" property. If it is the compiler will print a warning:Shouldn't be dtc whatever tools fixed?
See the first patch in the series.
Quoted 9 lines
Quoted 6 lines
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"In order to silence dtc up let's discard the flag from the DW I2C DT binding example for now. Just revert this commit when dtc is fixed.
Doesn't sound like a good idea. If user happens in between of these ping-pong change, how they will know this subtle issue?
As I see it, there are three ways we can follow.
1) Apply the patch and revert when dtc is fixed.
2) Apply the patch, but add a comment above the property, that we need to get the 0x40000064 address back when dtc is dixed.
3) Leave this ugly warning be until dtc is fixed.
In a comment to v2 Rob mentioned a solution like 1). Personally I am ok with either, though I'd like to see a Rob's final comment about this.
-Sergey
Quoted 4 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
Re: [PATCH v3 03/12] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example
Quoted 10 lines · Serge Semin
Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · Serge Semin
dtc currently doesn't support
I2C_OWN_SLAVE_ADDRESSflag set in the i2c "reg" property. If it is the compiler will print a warning:Shouldn't be dtc whatever tools fixed?
See the first patch in the series.
I can't by the reason that I have no such. I also answered to cover letter about it.
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
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"In order to silence dtc up let's discard the flag from the DW I2C DT binding example for now. Just revert this commit when dtc is fixed.
Doesn't sound like a good idea. If user happens in between of these ping-pong change, how they will know this subtle issue?
Quoted 8 lines
As I see it, there are three ways we can follow.
1) Apply the patch and revert when dtc is fixed.
2) Apply the patch, but add a comment above the property, that we need to get the0x40000064address back when dtc is dixed.
3) Leave this ugly warning be until dtc is fixed.In a comment to v2 Rob mentioned a solution like 1). Personally I am ok with either, though I'd like to see a Rob's final comment about this.
Yes, let's follow what Rob proposes.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 4/12 dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
In reply to Serge SeminAdd the "baikal,bt1-sys-i2c" compatible string to the DW I2C binding. Even though the corresponding node is supposed to be a child of the Baikal-T1 System Controller, its reg property is left required for compatibility.
---
Changelog v2:
- Make the reg property being optional if it's Baikal-T1 System I2C DT node.
Changelog v3:
- Get back the reg property being mandatory even if it's Baikal-T1 System I2C DT node. Rob says it has to be in the DT node if there is a dedicated registers range in the System Controller registers space.
--- Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +2 -0
@@ -31,6 +31,8 @@ properties: items: - const: mscc,ocelot-i2c - const: snps,designware-i2c + - description: Baikal-T1 SoC System I2C controller + const: baikal,bt1-sys-i2c reg: minItems: 1
Signature · 1 line
2.26.2
PATCH v3 5/12 i2c: designware: Use `-y` to build multi-object modules
In reply to Serge SeminSince commit 4f8272802739 ("Documentation: update kbuild loadable modules goals & examples") -objs is fitted for building host programs, lets change DW I2C core, platform and PCI driver kbuild directives to using -y, which more straightforward for device drivers. By doing so we can discard the ifeq construction in favor to the more natural and less bulky <module>-$(CONFIG_X) += x.o
--- drivers/i2c/busses/Makefile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/i2c/busses/Makefile +8 -9
@@ -48,16 +48,15 @@ obj-$(CONFIG_I2C_CADENCE) += i2c-cadence.o obj-$(CONFIG_I2C_CBUS_GPIO) += i2c-cbus-gpio.o obj-$(CONFIG_I2C_CPM) += i2c-cpm.o obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o -obj-$(CONFIG_I2C_DESIGNWARE_CORE) += i2c-designware-core.o -i2c-designware-core-objs := i2c-designware-common.o i2c-designware-master.o -ifeq ($(CONFIG_I2C_DESIGNWARE_SLAVE),y) -i2c-designware-core-objs += i2c-designware-slave.o -endif -obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o -i2c-designware-platform-objs := i2c-designware-platdrv.o +obj-$(CONFIG_I2C_DESIGNWARE_CORE) += i2c-designware-core.o +i2c-designware-core-y := i2c-designware-common.o +i2c-designware-core-y += i2c-designware-master.o +i2c-designware-core-$(CONFIG_I2C_DESIGNWARE_SLAVE) += i2c-designware-slave.o +obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o +i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o -obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o -i2c-designware-pci-objs := i2c-designware-pcidrv.o +obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o +i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.o obj-$(CONFIG_I2C_EFM32) += i2c-efm32.o obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
Signature · 1 line
2.26.2
PATCH v3 6/12 i2c: designware: slave: Set DW I2C core module dependency
In reply to Serge SeminDW APB I2C slave code in fact depends on the DW I2C driver core, but not on the platform code. Yes, the I2C slave interface is currently supported by the platform version of the IP core, but it doesn't make it dependent on it. So make sure the DW APB I2C slave config is only available if the I2C_DESIGNWARE_CORE config is enabled.
--- drivers/i2c/busses/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +1 -1
@@ -540,8 +540,8 @@ config I2C_DESIGNWARE_PLATFORM config I2C_DESIGNWARE_SLAVE bool "Synopsys DesignWare Slave" + depends on I2C_DESIGNWARE_CORE select I2C_SLAVE - depends on I2C_DESIGNWARE_PLATFORM help If you say yes to this option, support will be included for the Synopsys DesignWare I2C slave adapter.
Signature · 1 line
2.26.2
PATCH v3 7/12 i2c: designware: Add Baytrail sem config DW I2C platform dependency
In reply to Serge SeminCurrently Intel Baytrail I2C semaphore is a feature of the DW APB I2C platform driver. It's a bit confusing to see it's config in the menu at some separated place with no reference to the platform code. Let's move the config definition to be below the I2C_DESIGNWARE_PLATFORM config and mark it with "depends on I2C_DESIGNWARE_PLATFORM" statement. By doing so the config menu will display the feature right below the DW I2C platform driver item and will indent it to the right so signifying its belonging.
---
Changelog v3:
- Replace if-endif clause around the I2C_DESIGNWARE_BAYTRAIL config with "depends on" operator.
--- drivers/i2c/busses/Kconfig | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/i2c/busses/Kconfig +13 -12
@@ -538,6 +538,19 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +config I2C_DESIGNWARE_BAYTRAIL + bool "Intel Baytrail I2C semaphore support" + depends on ACPI + depends on I2C_DESIGNWARE_PLATFORM + depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \ + (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y) + help + This driver enables managed host access to the PMIC I2C bus on select + Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows + the host to request uninterrupted access to the PMIC's I2C bus from + the platform firmware controlling it. You should say Y if running on + a BayTrail system using the AXP288. + config I2C_DESIGNWARE_SLAVE bool "Synopsys DesignWare Slave" depends on I2C_DESIGNWARE_CORE
@@ -560,18 +573,6 @@ config I2C_DESIGNWARE_PCI This driver can also be built as a module. If so, the module will be called i2c-designware-pci. -config I2C_DESIGNWARE_BAYTRAIL - bool "Intel Baytrail I2C semaphore support" - depends on ACPI - depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \ - (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y) - help - This driver enables managed host access to the PMIC I2C bus on select - Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows - the host to request uninterrupted access to the PMIC's I2C bus from - the platform firmware controlling it. You should say Y if running on - a BayTrail system using the AXP288. - config I2C_DIGICOLOR tristate "Conexant Digicolor I2C driver" depends on ARCH_DIGICOLOR || COMPILE_TEST
Signature · 1 line
2.26.2
PATCH v3 8/12 i2c: designware: Discard Cherry Trail model flag
In reply to Serge SeminA PM workaround activated by the flag MODEL_CHERRYTRAIL has been removed since commit 9cbeeca05049 ("i2c: designware: Remove Cherry Trail PMIC I2C bus pm_disabled workaround"), but the flag most likely by mistake has been left in the Dw I2C drivers. Lets remove it.
---
Changelog v3:
- Since MSCC and Baikal-T1 will be a part of the platform driver code, we have to preserve the MODEL_MASK macro to use it to filter the model flags during the IP-specific quirks activation.
--- drivers/i2c/busses/i2c-designware-core.h | 3 +-- drivers/i2c/busses/i2c-designware-pcidrv.c | 1 - drivers/i2c/busses/i2c-designware-platdrv.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-designware-core.h +1 -2
@@ -281,8 +281,7 @@ struct dw_i2c_dev {#define ACCESS_INTR_MASK 0x00000004#define ACCESS_NO_IRQ_SUSPEND 0x00000008 -#define MODEL_CHERRYTRAIL 0x00000100 -#define MODEL_MSCC_OCELOT 0x00000200 +#define MODEL_MSCC_OCELOT 0x00000100#define MODEL_MASK 0x00000f00u32 dw_readl (struct dw_i2c_dev *dev,int offset);
drivers/i2c/busses/i2c-designware-pcidrv.c +0 -1
@@ -166,7 +166,6 @@ static struct dw_pci_controller dw_pci_controllers[] = { .tx_fifo_depth = 32, .rx_fifo_depth = 32, .functionality = I2C_FUNC_10BIT_ADDR, - .flags = MODEL_CHERRYTRAIL, .scl_sda_cfg = &byt_config, }, [elkhartlake] = {
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
@@ -123,7 +123,7 @@ static const struct acpi_device_id dw_i2c_acpi_match[] = { { "INT3432", 0 }, { "INT3433", 0 }, { "80860F41", ACCESS_NO_IRQ_SUSPEND }, - { "808622C1", ACCESS_NO_IRQ_SUSPEND | MODEL_CHERRYTRAIL }, + { "808622C1", ACCESS_NO_IRQ_SUSPEND }, { "AMD0010", ACCESS_INTR_MASK }, { "AMDI0010", ACCESS_INTR_MASK }, { "AMDI0510", 0 },
Signature · 1 line
2.26.2
PATCH v3 9/12 i2c: designware: Convert driver to using regmap API
In reply to Serge SeminSeeing the DW I2C driver is using flags-based accessors with two conditional clauses it would be better to replace them with the regmap API IO methods and to initialize the regmap object with read/write callbacks specific to the controller registers map implementation. This will be also handy for the drivers with non-standard registers mapping (like an embedded into the Baikal-T1 System Controller DW I2C block, which glue-driver is a part of this series).
As before the driver tries to detect the mapping setup at probe stage and creates a regmap object accordingly, which will be used by the rest of the code to correctly access the controller registers. In two places it was appropriate to convert the hand-written read-modify-write and read-poll-loop design patterns to the corresponding regmap API ready-to-use methods.
Note the regmap IO methods return value is checked only at the probe stage. The rest of the code won't do this because basically we have MMIO-based regmap so non of the read/write methods can fail (this also won't be needed for the Baikal-T1-specific I2C controller).
--- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-designware-common.c | 178 +++++++++++++++------ drivers/i2c/busses/i2c-designware-core.h | 18 +-- drivers/i2c/busses/i2c-designware-master.c | 125 ++++++++------- drivers/i2c/busses/i2c-designware-slave.c | 77 ++++----- 5 files changed, 246 insertions(+), 153 deletions(-)
drivers/i2c/busses/Kconfig +1 -0
@@ -526,6 +526,7 @@ config I2C_DAVINCI config I2C_DESIGNWARE_CORE tristate + select REGMAP config I2C_DESIGNWARE_PLATFORM tristate "Synopsys DesignWare Platform"
drivers/i2c/busses/i2c-designware-common.c +127 -51
291 lines not on this page · raw message
drivers/i2c/busses/i2c-designware-core.h +8 -10
@@ -10,6 +10,7 @@*/ #include <linux/i2c.h> +#include <linux/regmap.h> #define DW_IC_DEFAULT_FUNCTIONALITY (I2C_FUNC_I2C | \ I2C_FUNC_SMBUS_BYTE | \
@@ -120,8 +121,6 @@#define STATUS_WRITE_IN_PROGRESS 0x1#define STATUS_READ_IN_PROGRESS 0x2 -#define TIMEOUT 20/* ms */ -/* * operation modes */
@@ -174,7 +173,9 @@/** * struct dw_i2c_dev - private i2c-designware data * @dev: driver model device node +* @map: IO registers map * @base: IO registers pointer +* @ext: Extended IO registers pointer * @cmd_complete: tx completion indicator * @clk: input reference clock * @pclk: clock required to access the registers
@@ -224,6 +225,7 @@*/ struct dw_i2c_dev {struct device *dev; +struct regmap *map;void __iomem *base;void __iomem *ext;struct completion cmd_complete;
@@ -276,17 +278,13 @@ struct dw_i2c_dev {bool suspended; }; -#define ACCESS_SWAP 0x00000001 -#define ACCESS_16BIT 0x00000002#define ACCESS_INTR_MASK 0x00000004#define ACCESS_NO_IRQ_SUSPEND 0x00000008#define MODEL_MSCC_OCELOT 0x00000100#define MODEL_MASK 0x00000f00 -u32 dw_readl (struct dw_i2c_dev *dev,int offset); -void dw_writel (struct dw_i2c_dev *dev,u32 b,int offset); -int i2c_dw_set_reg_access (struct dw_i2c_dev *dev); +int i2c_dw_init_regmap (struct dw_i2c_dev *dev);u32 i2c_dw_scl_hcnt (u32 ic_clk,u32 tSYMBOL,u32 tf,int cond,int offset);u32 i2c_dw_scl_lcnt (u32 ic_clk,u32 tLOW,u32 tf,int offset);int i2c_dw_set_sda_hold (struct dw_i2c_dev *dev);
@@ -296,19 +294,19 @@ int i2c_dw_acquire_lock(struct dw_i2c_dev *dev);void i2c_dw_release_lock (struct dw_i2c_dev *dev);int i2c_dw_wait_bus_not_busy (struct dw_i2c_dev *dev);int i2c_dw_handle_tx_abort (struct dw_i2c_dev *dev); -void i2c_dw_set_fifo_size (struct dw_i2c_dev *dev); +int i2c_dw_set_fifo_size (struct dw_i2c_dev *dev);u32 i2c_dw_func (struct i2c_adapter *adap);void i2c_dw_disable (struct dw_i2c_dev *dev);void i2c_dw_disable_int (struct dw_i2c_dev *dev);static inline void __i2c_dw_enable (struct dw_i2c_dev *dev) { -dw_writel (dev,1 ,DW_IC_ENABLE ); +regmap_write (dev->map,DW_IC_ENABLE ,1 ); }static inline void __i2c_dw_disable_nowait (struct dw_i2c_dev *dev) { -dw_writel (dev,0 ,DW_IC_ENABLE ); +regmap_write (dev->map,DW_IC_ENABLE ,0 ); }void __i2c_dw_disable (struct dw_i2c_dev *dev);
drivers/i2c/busses/i2c-designware-master.c +69 -56
308 lines not on this page · raw message
drivers/i2c/busses/i2c-designware-slave.c +41 -36
185 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v3 10/12 i2c: designware: Retrieve quirk flags as early as possible
In reply to Serge SeminSome platforms might need to activate the driver quirks at a very early probe stage. For instance, Baikal-T1 System I2C doesn't need to map the registers space as ones belong to the system controller. Instead it will request the syscon regmap from the parental DT node. In order to be able to do so let's retrieve the model flags right after the DW I2C private data is created.
---
Changelog v3:
- This is a new patch, which has been created due to declining the glue-layer approach.
--- drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +2 -2
@@ -252,6 +252,8 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)if (!dev)return -ENOMEM ; + dev->flags |= (uintptr_t )device_get_match_data (&pdev->dev); + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); dev->base =devm_ioremap_resource (&pdev->dev, mem);if (IS_ERR (dev->base))
@@ -295,8 +297,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)else t->bus_freq_hz =I2C_MAX_FAST_MODE_FREQ ; - dev->flags |= (uintptr_t )device_get_match_data (&pdev->dev); -if (pdev->dev.of_node)dw_i2c_of_configure (pdev);
Signature · 1 line
2.26.2
PATCH v3 11/12 i2c: designware: Move reg-space remapping into a dedicated function
In reply to Serge SeminThis is a preparation patch before adding a quirk with custom registers map creation required for the Baikal-T1 System I2C support. Since we've touched this code anyway let's replace platform_get_resource()-devm_ioremap_resource() tuple with ready-to-use helper devm_platform_get_and_ioremap_resource().
---
Changelog v3:
- This is a new patch, which has been created due to declining the glue-layer approach.
--- drivers/i2c/busses/i2c-designware-platdrv.c | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +16 -7
@@ -234,6 +234,18 @@ static const u32 supported_speeds[] = { I2C_MAX_STANDARD_MODE_FREQ, }; +static int dw_i2c_plat_request_regs (struct dw_i2c_dev *dev) +{ +struct platform_device *pdev =to_platform_device (dev->dev); +int ret =0 ; + + dev->base =devm_platform_get_and_ioremap_resource (pdev,0 ,NULL ); +if (IS_ERR (dev->base)) + ret =PTR_ERR (dev->base); + +return ret; +} +static int dw_i2c_plat_probe (struct platform_device *pdev) {struct dw_i2c_platform_data *pdata =dev_get_platdata (&pdev->dev);
@@ -241,7 +253,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)struct dw_i2c_dev *dev;struct i2c_timings *t;u32 acpi_speed; -struct resource *mem;int i, irq, ret; irq =platform_get_irq (pdev,0 );
@@ -253,16 +264,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)return -ENOMEM ; dev->flags |= (uintptr_t )device_get_match_data (&pdev->dev); - - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - dev->base =devm_ioremap_resource (&pdev->dev, mem); -if (IS_ERR (dev->base)) -return PTR_ERR (dev->base); - dev->dev = &pdev->dev; dev->irq = irq;platform_set_drvdata (pdev, dev); + ret =dw_i2c_plat_request_regs (dev); +if (ret) +return ret; + dev->rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );if (IS_ERR (dev->rst))return PTR_ERR (dev->rst);
Signature · 1 line
2.26.2
Re: [PATCH v3 11/12] i2c: designware: Move reg-space remapping into a dedicated function
Quoted 6 lines · Serge Semin
This is a preparation patch before adding a quirk with custom registers map creation required for the Baikal-T1 System I2C support. Since we've touched this code anyway let's replace platform_get_resource()-devm_ioremap_resource() tuple with ready-to-use helper
devm_platform_get_and_ioremap_resource().
...
drivers/i2c/busses/i2c-designware-platdrv.c static const u32 supported_speeds[] = { · line 240
Quoted 5 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4
-0+static int dw_i2c_plat_request_regs (struct dw_i2c_dev *dev) +{ +struct platform_device *pdev =to_platform_device (dev->dev); +int ret =0 ;
Redundant.
Quoted 1 line
+
dev->base=devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
What's the point of this API if you don't use resource parameter?
drivers/i2c/busses/i2c-designware-platdrv.c static const u32 supported_speeds[] = { · line 246
Quoted 4 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4
-0+if (IS_ERR (dev->base)) + ret =PTR_ERR (dev->base); + +return ret;
return PTR_ERR_OR_ZERO(dev->base);
drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_plat_probe(struct platform_device *pdev) · line 260
Quoted 6 lines
drivers/i2c/busses/i2c-designware-platdrv.c +1
-4+} - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - dev->base =devm_ioremap_resource (&pdev->dev, mem); -if (IS_ERR (dev->base)) -return PTR_ERR (dev->base);
Wolfram, did my last series make your tree? I think there was a patch that touched this part...
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 11/12] i2c: designware: Move reg-space remapping into a dedicated function
Quoted 32 lines · Andy Shevchenko
Quoted 6 lines · Serge Semin
This is a preparation patch before adding a quirk with custom registers map creation required for the Baikal-T1 System I2C support. Since we've touched this code anyway let's replace platform_get_resource()-devm_ioremap_resource() tuple with ready-to-use helper
devm_platform_get_and_ioremap_resource()....
drivers/i2c/busses/i2c-designware-platdrv.c static const u32 supported_speeds[] = { · line 240
Quoted 5 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4
-0+static int dw_i2c_plat_request_regs (struct dw_i2c_dev *dev) +{ +struct platform_device *pdev =to_platform_device (dev->dev); +int ret =0 ;Redundant.
Quoted 1 line
+
dev->base=devm_platform_get_and_ioremap_resource(pdev, 0, NULL);What's the point of this API if you don't use resource parameter?
drivers/i2c/busses/i2c-designware-platdrv.c static const u32 supported_speeds[] = { · line 246
Quoted 4 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4
-0+if (IS_ERR (dev->base)) + ret =PTR_ERR (dev->base); + +return ret;return
PTR_ERR_OR_ZERO(dev->base);Quoted 1 line
+}
Quoted 7 lines
drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_plat_probe(struct platform_device *pdev) · line 260
Quoted 4 lines
drivers/i2c/busses/i2c-designware-platdrv.c +0
-4- mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - dev->base =devm_ioremap_resource (&pdev->dev, mem); -if (IS_ERR (dev->base)) -return PTR_ERR (dev->base);Wolfram, did my last series make your tree? I think there was a patch that touched this part...
Right. It is there. I'll rebase the series on top of the i2c/for-next branch.
-Serge
Quoted 4 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
Re: [PATCH v3 11/12] i2c: designware: Move reg-space remapping into a dedicated function
Quoted 3 lines · Serge Semin
Quoted 2 lines · Andy Shevchenko
On Wed, May 27, 2020 at 4:03 AM Serge Semin
<[email protected]> wrote:
...
Quoted 4 lines
Quoted 2 lines
Wolfram, did my last series make your tree? I think there was a patch that touched this part...
Right. It is there. I'll rebase the series on top of the i2c/for-next branch.
Ah, my memory did a trick. Thank you!
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 12/12 i2c: designware: Add Baikal-T1 System I2C support
In reply to Serge SeminBaikal-T1 System Controller is equipped with a dedicated I2C Controller which functionality is based on the DW APB I2C IP-core, the only difference in a way it' registers are accessed. There are three access register provided in the System Controller registers map, which indirectly address the normal DW APB I2C registers space. So in order to have the Baikal-T1 System I2C Controller supported by the common DW APB I2C driver we created a dedicated Dw I2C controller model quirk, which retrieves the syscon regmap from the parental dt node and creates a new regmap based on it.
---
Changelog v3:
- This is a new patch, which has been created due to declining the glue-layer approach.
--- drivers/i2c/busses/Kconfig | 3 +- drivers/i2c/busses/i2c-designware-core.h | 3 + drivers/i2c/busses/i2c-designware-platdrv.c | 81 ++++++++++++++++++++- 3 files changed, 83 insertions(+), 4 deletions(-)
drivers/i2c/busses/Kconfig +2 -1
@@ -530,8 +530,9 @@ config I2C_DESIGNWARE_CORE config I2C_DESIGNWARE_PLATFORM tristate "Synopsys DesignWare Platform" - select I2C_DESIGNWARE_CORE depends on (ACPI && COMMON_CLK) || !ACPI + select I2C_DESIGNWARE_CORE + select MFD_SYSCON if MIPS_BAIKAL_T1 help If you say yes to this option, support will be included for the Synopsys DesignWare I2C adapter.
drivers/i2c/busses/i2c-designware-core.h +3 -0
@@ -174,6 +174,7 @@* struct dw_i2c_dev - private i2c-designware data * @dev: driver model device node * @map: IO registers map +* @sysmap: System controller registers map * @base: IO registers pointer * @ext: Extended IO registers pointer * @cmd_complete: tx completion indicator
@@ -226,6 +227,7 @@struct dw_i2c_dev {struct device *dev;struct regmap *map; +struct regmap *sysmap;void __iomem *base;void __iomem *ext;struct completion cmd_complete;
@@ -282,6 +284,7 @@ struct dw_i2c_dev {#define ACCESS_NO_IRQ_SUSPEND 0x00000008#define MODEL_MSCC_OCELOT 0x00000100 +#define MODEL_BAIKAL_BT1 0x00000200#define MODEL_MASK 0x00000f00int i2c_dw_init_regmap (struct dw_i2c_dev *dev);
drivers/i2c/busses/i2c-designware-platdrv.c +78 -3
115 lines not on this page · raw message
Signature · 1 line
2.26.2
Andy Shevchenko
reviewerQuoted 66 lines · Serge Semin
Jarkko, Wolfram, the merge window is upon us, please review/merge in/whatever the patchset.
Initially this has been a small patchset which embedded the Baikal-T1 System I2C support into the DW APB I2C driver as is by using a simplest way. After a short discussion with Andy we decided to implement what he suggested (introduce regmap-based accessors and create a glue driver) and even more than that to provide some cleanups of the code. So here is what this patchset consists of.
First of all we've found out that current implementation of
scripts/dtcdidn't support i2c dt nodes with 10bit and slave flags set in the reg property. You'll see an error if you try todt_binding_checkit. So the very first patch fixes the problem by adding these flags support into thecheck_i2c_bus_reg()method.Traditionally we converted the plain text-based DT binding to the DT schema and added Baikal-T1 System I2C device support there. This required to mark the reg property redundant for Baikal-T1 I2C since its reg-space is indirectly accessed by means of the System Controller cmd/read/write registers.
Then as Andy suggested we replaced the Synopsys DW APB I2C common driver registers IO accessors into the regmap API methods. This doesn't change the code logic much, though in two places we managed to replace some bulky peaces of code with a ready-to-use regmap methods.
Additionally before adding the glue layer API we initiated a set of cleanups:
- Define components of the multi-object drivers (like i2c-designware-core.o and i2c-designware-paltform.o) with using-ysuffixed makefile variables instead of-objssuffixed one. This is encouraged byDocumentation/kbuild/makefiles.rsttext since-objsis supposed to be used to build host programs.
- Make DW I2C slave driver depended on the DW I2C core code instead of the platform one, which it really is.
- Move Intel Baytrail semaphore feature to the platform if-clause of the kernel config.After this we finally can introduce the glue layer API for the DW APB I2C platform driver. So there are three methods exported from the driver:
i2c_dw_plat_setup(),i2c_dw_plat_clear(),&i2c_dw_plat_dev_pm_opsto setup, cleanup and add PM operations to the glue driven I2C device. Before setting the platform DW I2C device up the glue probe code is supposed to create an instance of DW I2C device generic object and pre-initialize itsstruct devicepointer together with optional platform-specific flags. In addition to that we converted the MSCC Ocelot SoC I2C specific code into the glue layer seeing it's really too specific and, which is more important, isn't that complicated so we could unpin it without much of worrying to break something.Meanwhile we discovered that
MODEL_CHERRYTRAILandMODEL_MASKactually were no longer used in the code.MODEL_MSCCflag has been discarded since the MSCC Ocelot I2C code conversion to the glue driver. So now we can get rid of all the MODEL-specific flags.Finally we introduced a glue driver with Baikal-T1 System I2C device support. The driver probe tries to find a syscon regmap, creates the DW APB I2C regmap based on it and passes it further to the DW I2C device descriptor. Then it does normal DW APB I2C platform setup by calling a generic setup method. Cleanup is straightforward. It's just calling a generic DW APB I2C clean method.
This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
base-commit:0e698dfa2822("Linux 5.7-rc4")
tag: v5.7-rc4
Quoted 5 lines
Note new vendor prefix for Baikal-T1 System I2C device will be added in the framework of the next patchset:
https://lkml.org/lkml/2020/5/6/1047
scripts/dtc: check: Add 10bit/slave i2c reg flags support
Hmm... I don't see this patch.
Signature · 2 lines
With Best Regards, Andy Shevchenko