Skip to contentSkip to conversation

i2c: designeware: Add Baikal-T1 System I2C support

PATCH Superseded Serge Semin 4 participants 31 messages May 27, 2020 – Jun 8, 2020

Subsystems (5)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v5 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 i2c/for-next (5.7-rc7):
base-commit: 228f95c14949 ("Merge remote-tracking branch 'spi/for-5.8' into spi-next")

Note new vendor prefix for Baikal-T1 System I2C device is 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.

Changelog v4:
- Rebase on top of the i2c/for-next branch.
- Use PTR_ERR_OR_ZERO() helper in the bt1_i2c_request_regs() and in the dw_i2c_plat_request_regs() methods.
- Discard devm_platform_get_and_ioremap_resource() utilization.
- Discard patch "scripts/dtc: check: Add 10bit/slave i2c reg flags support" since it must be merged in to the dtc upstream repository.

Changelog v5:
- Replace or-assignment with just assignment operator when getting the quirk flags.
- Keep alphabetical order of the include statements.
- Discard explicit u16-type cast in the dw_reg_write_word() method.

Cc Alexey Malahov <[email protected]>
Cc Maxim Kaurkin <[email protected]>
Cc Pavel Parkhomenko <[email protected]>
Cc Ramil Zaripov <[email protected]>
Cc Ekaterina Skachko <[email protected]>
Cc Vadim Vlasov <[email protected]>
Cc Alexey Kolotnikov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Rob Herring <[email protected]>

Serge Semin (11):
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                    |  28 +--
 drivers/i2c/busses/Makefile                   |  18 +-
 drivers/i2c/busses/i2c-designware-common.c    | 178 +++++++++++++-----
 drivers/i2c/busses/i2c-designware-core.h      |  28 +--
 drivers/i2c/busses/i2c-designware-master.c    | 125 ++++++------
 drivers/i2c/busses/i2c-designware-pcidrv.c    |   1 -
 drivers/i2c/busses/i2c-designware-platdrv.c   |  96 +++++++++-
 drivers/i2c/busses/i2c-designware-slave.c     |  77 ++++----
 10 files changed, 520 insertions(+), 260 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
#1 lore raw

PATCH v5 1/11 dt-bindings: i2c: Convert DW I2C binding to DT schema

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.

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 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
deleted file mode 100644
index 08be4d3846e5..000000000000
@@ -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
#2 lore raw

PATCH v5 2/11 dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example

In reply to Serge Semin

dtc 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.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>

---

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
index 4bd430b2b41d..101d78e8f19d 100644
@@ -137,7 +137,7 @@ examples:
 
       eeprom@64 {
         compatible = "linux,slave-24c02";
-        reg = <0x40000064>;
+        reg = <0x64>;
       };
     };
   - |
Signature · 1 line
2.26.2
#3 lore raw

Re: [PATCH v5 02/11] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example

Rob,
Could you pay attention to this patch? The patchset review procedure is nearly over, while the DT part is only partly reviewed by you.

Thanks
-Sergey

Quoted 42 lines · Serge Semin

dtc 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.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>

---

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
index 4bd430b2b41d..101d78e8f19d 100644
@@ -137,7 +137,7 @@ examples:
 
       eeprom@64 {
         compatible = "linux,slave-24c02";
-        reg = <0x40000064>;
+        reg = <0x64>;
       };
     };
   - |
Signature · 1 line
2.26.2
maintainer
#4 lore raw

Re: [PATCH v5 02/11] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example

Quoted 3 lines · Serge Semin

Rob,
Could you pay attention to this patch? The patchset review procedure is nearly over, while the DT part is only partly reviewed by you.

Pretty sure I commented on this. Not sure what version, you're sending new versions too fast. Give people time to review.

Quoted 37 lines

Thanks
-Sergey

Quoted 32 lines · Serge Semin

dtc 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.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>

---

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 +0 -0
index 4bd430b2b41d..101d78e8f19d 100644
@@ -137,7 +137,7 @@ examples:
 
Quoted 4 lines

Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml examples: · line 140

Quoted 4 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +1 -1
       eeprom@64 {
         compatible = "linux,slave-24c02";
-        reg = <0x40000064>;
+        reg = <0x64>;

This is wrong though because "linux,slave-24c02" should have bit 30 set. (And either the unit-address was wrong or we can define the unit-address does not include the high bits.)

Rob

#5 lore raw

Re: [PATCH v5 02/11] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example

Quoted 8 lines · Rob Herring
Quoted 3 lines · Serge Semin

Rob,
Could you pay attention to this patch? The patchset review procedure is nearly over, while the DT part is only partly reviewed by you.

Pretty sure I commented on this. Not sure what version, you're sending new versions too fast. Give people time to review.

Yeah, you did. Sorry for sending the new versions very fast. Normally I prefer to keep up with comments so to past a particular maintainer review as fast as possible without long delays. In my experience the longer you wait, the lesser maintainers remember about your patchset, the harder for one to continue the next versions review.

Regarding this patch the brand new version on is v6:
[PATCH v6 02/11] dt-bindings: i2c: Convert DW I2C slave to the DW I2C master example

Could you please find it in your email log? I've left a note there for you about options what we can do with this case.

-Sergey

Quoted 48 lines
Quoted 38 lines

Thanks
-Sergey

Quoted 32 lines · Serge Semin

dtc 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.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>

---

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 +0 -0
index 4bd430b2b41d..101d78e8f19d 100644
@@ -137,7 +137,7 @@ examples:
 
Quoted 4 lines

Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml examples: · line 140

Quoted 4 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +1 -1
       eeprom@64 {
         compatible = "linux,slave-24c02";
-        reg = <0x40000064>;
+        reg = <0x64>;

This is wrong though because "linux,slave-24c02" should have bit 30 set. (And either the unit-address was wrong or we can define the unit-address does not include the high bits.)

Rob

#6 lore raw

Re: [PATCH v5 02/11] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example

Quoted 11 lines · Serge Semin
Quoted 4 lines · Rob Herring

On Wed, May 27, 2020 at 06:33:51PM +0300, Serge Semin wrote:

you're sending
new versions too fast. Give people time to review.

Yeah, you did. Sorry for sending the new versions very fast. Normally I prefer to keep up with comments so to past a particular maintainer review as fast as possible without long delays. In my experience the longer you wait, the lesser maintainers remember about your patchset, the harder for one to continue the next versions review.

Documentation/process/submitting-patches.rst:

"Wait for a minimum of one week before resubmitting or pinging reviewers - possibly longer during busy times like merge windows."

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

Re: [PATCH v5 02/11] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example

Quoted 14 lines · Andy Shevchenko
Quoted 11 lines · Serge Semin
Quoted 4 lines · Rob Herring

On Wed, May 27, 2020 at 06:33:51PM +0300, Serge Semin wrote:

you're sending
new versions too fast. Give people time to review.

Yeah, you did. Sorry for sending the new versions very fast. Normally I prefer to keep up with comments so to past a particular maintainer review as fast as possible without long delays. In my experience the longer you wait, the lesser maintainers remember about your patchset, the harder for one to continue the next versions review.

Quoted 4 lines

Documentation/process/submitting-patches.rst:

"Wait for a minimum of one week before resubmitting or pinging reviewers - possibly longer during busy times like merge windows."

Good to know what I already know.) How much do you personally wait before resubmitting? In my experience reviewing your DW APB GPIO patches, no longer than a few hours.

-Sergey

Quoted 7 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
#8 lore raw

Re: [PATCH v5 02/11] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example

Quoted 16 lines · Serge Semin
Quoted 13 lines · Andy Shevchenko
Quoted 11 lines · Serge Semin
Quoted 4 lines · Rob Herring

On Wed, May 27, 2020 at 06:33:51PM +0300, Serge Semin wrote:

you're sending
new versions too fast. Give people time to review.

Yeah, you did. Sorry for sending the new versions very fast. Normally I prefer to keep up with comments so to past a particular maintainer review as fast as possible without long delays. In my experience the longer you wait, the lesser maintainers remember about your patchset, the harder for one to continue the next versions review.

Quoted 8 lines
Quoted 4 lines

Documentation/process/submitting-patches.rst:

"Wait for a minimum of one week before resubmitting or pinging reviewers - possibly longer during busy times like merge windows."

Good to know what I already know.) How much do you personally wait before resubmitting? In my experience reviewing your DW APB GPIO patches, no longer than a few hours.

Moreover the statement you cited is about the patches, which doesn't get any attention from the maintainers/reviewers for quite some time. In this case I normally resubmit the patches no sooner than a week. I was talking about the situation when you get the review comments, which need to be addressed.

-Sergey

Quoted 10 lines

-Sergey

Quoted 7 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
maintainer
#9 lore raw

Re: [PATCH v5 02/11] dt-bindings: i2c: Discard i2c-slave flag from the DW I2C example

Quoted 23 lines · Serge Semin
Quoted 21 lines · Serge Semin
Quoted 19 lines · Andy Shevchenko
Quoted 11 lines · Serge Semin
Quoted 4 lines · Rob Herring

On Wed, May 27, 2020 at 06:33:51PM +0300, Serge Semin wrote:

you're sending
new versions too fast. Give people time to review.

Yeah, you did. Sorry for sending the new versions very fast. Normally I prefer to keep up with comments so to past a particular maintainer review as fast as possible without long delays. In my experience the longer you wait, the lesser maintainers remember about your patchset, the harder for one to continue the next versions review.

Documentation/process/submitting-patches.rst:

"Wait for a minimum of one week before resubmitting or pinging reviewers - possibly longer during busy times like merge windows."

Quoted 8 lines
Quoted 3 lines

Good to know what I already know.) How much do you personally wait before resubmitting? In my experience reviewing your DW APB GPIO patches, no longer than a few hours.

Moreover the statement you cited is about the patches, which doesn't get any attention from the maintainers/reviewers for quite some time. In this case I normally resubmit the patches no sooner than a week. I was talking about the situation when you get the review comments, which need to be addressed.

There's not going to be any rule that always works. It takes judgement. I'd say the greater the rework from review comments, the sooner you can resend. But then if it's multiple subsystems/maintainers, you need to give all of them time.

I go in date order mostly. You send a new version, then you go to the back of the queue. So if you want it reviewed the soonest, send it 2 weeks ago. ;) There's also the strategy of reviewing other patches in front of yours. Sometimes I go by version numbers, but send version 50 and I might be suspicious. And that's rewarding folks who are sloppy or keep sending broken stuff. The real solution is I just need more help reviewing things.

Rob

#10 lore raw

PATCH v5 3/11 dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller

In reply to Serge Semin

Add 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.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>

---

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
index 101d78e8f19d..8c9b3db1b1b8 100644
@@ -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
#11 lore raw

Re: [PATCH v5 03/11] dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller

Rob,
Could you please pay attention to this patch? The patchset review procedure is nearly over, while the DT part is only partly reviewed by you.

Thanks
-Sergey

Quoted 41 lines · Serge Semin

Add 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.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>

---

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
index 101d78e8f19d..8c9b3db1b1b8 100644
@@ -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
#12 lore raw

PATCH v5 4/11 i2c: designware: Use `-y` to build multi-object modules

In reply to Serge Semin

Since 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

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Rob Herring <[email protected]>
---
 drivers/i2c/busses/Makefile | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/i2c/busses/Makefile +8 -10
index a33aa107a05d..c6813d7b2780 100644
@@ -48,17 +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-core-objs += 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
#13 lore raw

PATCH v5 5/11 i2c: designware: slave: Set DW I2C core module dependency

In reply to Serge Semin

DW APB I2C slave code in fact depends on the DW I2C driver core, but not on the platform code as it used to be before commit 90bc1ee6de9f ("i2c:
designware: Allow slave mode for PCI enumerated devices"). Yes, the I2C slave interface is currently supported by both the platform and PCI versions of the IP core, but it still depends on the DW I2C core functionality and must be available only if the last one is enabled. So make sure the DW APB I2C slave config is only available if the I2C_DESIGNWARE_CORE config is enabled.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Rob Herring <[email protected]>
---
 drivers/i2c/busses/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/i2c/busses/Kconfig +1 -0
index 1d940810e47e..7f92f6a96042 100644
@@ -529,6 +529,7 @@ config I2C_DESIGNWARE_CORE
 
 config I2C_DESIGNWARE_SLAVE
 	bool "Synopsys DesignWare Slave"
+	depends on I2C_DESIGNWARE_CORE
 	select I2C_SLAVE
 	help
 	  If you say yes to this option, support will be included for the
Signature · 1 line
2.26.2
#14 lore raw

PATCH v5 6/11 i2c: designware: Add Baytrail sem config DW I2C platform dependency

In reply to Serge Semin

Currently 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.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Rob Herring <[email protected]>

---

Changelog v3:
- Replace if-endif clause around the I2C_DESIGNWARE_BAYTRAIL config with "depends on" operator.

---
 drivers/i2c/busses/Kconfig | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/i2c/busses/Kconfig +12 -11
index 7f92f6a96042..7cd279c36898 100644
@@ -549,20 +549,10 @@ 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_PCI
-	tristate "Synopsys DesignWare PCI"
-	depends on PCI
-	select I2C_DESIGNWARE_CORE
-	help
-	  If you say yes to this option, support will be included for the
-	  Synopsys DesignWare I2C adapter. Only master mode is supported.
-
-	  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
 	depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \
 		   (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y)
 	help
@@ -572,6 +562,17 @@ config I2C_DESIGNWARE_BAYTRAIL
 	  the platform firmware controlling it. You should say Y if running on
 	  a BayTrail system using the AXP288.
 
+config I2C_DESIGNWARE_PCI
+	tristate "Synopsys DesignWare PCI"
+	depends on PCI
+	select I2C_DESIGNWARE_CORE
+	help
+	  If you say yes to this option, support will be included for the
+	  Synopsys DesignWare I2C adapter. Only master mode is supported.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-designware-pci.
+
 config I2C_DIGICOLOR
 	tristate "Conexant Digicolor I2C driver"
 	depends on ARCH_DIGICOLOR || COMPILE_TEST
Signature · 1 line
2.26.2
#15 lore raw

Re: [PATCH v5 06/11] i2c: designware: Add Baytrail sem config DW I2C platform dependency

Quoted 7 lines · Serge Semin

Currently 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.

Same comment as per previous version.

drivers/i2c/busses/Kconfig config I2C_DESIGNWARE_PLATFORM · line 557

Quoted 6 lines

config I2C_DESIGNWARE_BAYTRAIL

drivers/i2c/busses/Kconfig +1 -0
 	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)

i.e. this change is not needed.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#16 lore raw

Re: [PATCH v5 06/11] i2c: designware: Add Baytrail sem config DW I2C platform dependency

Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Serge Semin

Currently 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.

Same comment as per previous version.

Quoted 8 lines

drivers/i2c/busses/Kconfig config I2C_DESIGNWARE_PLATFORM · line 557

Quoted 6 lines

config I2C_DESIGNWARE_BAYTRAIL

drivers/i2c/busses/Kconfig +1 -0
 	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)

i.e. this change is not needed.

See my response to you in the previous version.

-Sergey

Quoted 6 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
reviewer Reviewed-by on v5 6/11
#17 lore raw

Re: [PATCH v5 06/11] i2c: designware: Add Baytrail sem config DW I2C platform dependency

In reply to Serge Semin
Quoted 7 lines · Serge Semin

Currently 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.

After clarification Serge gave, it makes sense.

Quoted 65 lines
Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Rob Herring <[email protected]>

---

Changelog v3:
- Replace if-endif clause around the I2C_DESIGNWARE_BAYTRAIL config with "depends on" operator.

---
 drivers/i2c/busses/Kconfig | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/i2c/busses/Kconfig +12 -11
index 7f92f6a96042..7cd279c36898 100644
@@ -549,20 +549,10 @@ 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_PCI
-	tristate "Synopsys DesignWare PCI"
-	depends on PCI
-	select I2C_DESIGNWARE_CORE
-	help
-	  If you say yes to this option, support will be included for the
-	  Synopsys DesignWare I2C adapter. Only master mode is supported.
-
-	  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
 	depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \
 		   (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y)
 	help
@@ -572,6 +562,17 @@ config I2C_DESIGNWARE_BAYTRAIL
 	  the platform firmware controlling it. You should say Y if running on
 	  a BayTrail system using the AXP288.
 
+config I2C_DESIGNWARE_PCI
+	tristate "Synopsys DesignWare PCI"
+	depends on PCI
+	select I2C_DESIGNWARE_CORE
+	help
+	  If you say yes to this option, support will be included for the
+	  Synopsys DesignWare I2C adapter. Only master mode is supported.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-designware-pci.
+
 config I2C_DIGICOLOR
 	tristate "Conexant Digicolor I2C driver"
 	depends on ARCH_DIGICOLOR || COMPILE_TEST
Signature · 1 line
2.26.2
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#18 lore raw

PATCH v5 7/11 i2c: designware: Discard Cherry Trail model flag

In reply to Serge Semin

A 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. Let's remove it. Since MODEL_MSCC_OCELOT is the only model-flag left, redefine it to be 0x100 so setting a very first bit in the MODEL_MASK bits range.

---

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
index 150de5e5c31b..b9ef9b0deef0 100644
@@ -289,8 +289,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		0x00000f00
 
 u32 dw_readl(struct dw_i2c_dev *dev, int offset);
drivers/i2c/busses/i2c-designware-pcidrv.c +0 -1
index 11a5e4751eab..947c096f86e3 100644
@@ -149,7 +149,6 @@ static struct dw_pci_controller dw_pci_controllers[] = {
 	},
 	[cherrytrail] = {
 		.bus_num = -1,
-		.flags = MODEL_CHERRYTRAIL,
 		.scl_sda_cfg = &byt_config,
 	},
 	[elkhartlake] = {
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
index f6d2c96e35ce..ca057aa9eac4 100644
@@ -44,7 +44,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
#19 lore raw

Re: [PATCH v5 07/11] i2c: designware: Discard Cherry Trail model flag

Quoted 4 lines · Serge Semin

A 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. Let's remove it.

Same comment as per previous version.

Quoted 3 lines

Since MODEL_MSCC_OCELOT is
the only model-flag left, redefine it to be 0x100 so setting a very first bit in the MODEL_MASK bits range.

Cool, but why should we care?

drivers/i2c/busses/i2c-designware-core.h struct dw_i2c_dev { · line 292

Quoted 2 lines
drivers/i2c/busses/i2c-designware-core.h +1 -1
-#define MODEL_MSCC_OCELOT	0x00000200
+#define MODEL_MSCC_OCELOT	0x00000100

We have 4 bits for that, and you are going to reuse this anyway.

I consider this unneeded churn.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#20 lore raw

Re: [PATCH v5 07/11] i2c: designware: Discard Cherry Trail model flag

Quoted 12 lines · Andy Shevchenko
Quoted 4 lines · Serge Semin

A 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. Let's remove it.

Same comment as per previous version.

Quoted 3 lines

Since MODEL_MSCC_OCELOT is
the only model-flag left, redefine it to be 0x100 so setting a very first bit in the MODEL_MASK bits range.

Quoted 8 lines

Cool, but why should we care?

drivers/i2c/busses/i2c-designware-core.h struct dw_i2c_dev { · line 292

Quoted 2 lines
drivers/i2c/busses/i2c-designware-core.h +1 -1
-#define MODEL_MSCC_OCELOT	0x00000200
+#define MODEL_MSCC_OCELOT	0x00000100

We have 4 bits for that, and you are going to reuse this anyway.

I consider this unneeded churn.

I'll leave it as is since prefer keeping the bit setting in the historical order. Let's see what Jarkko thinks.

-Sergey

Quoted 6 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
#21 lore raw

PATCH v5 8/11 i2c: designware: Convert driver to using regmap API

In reply to Serge Semin

Seeing 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).

---

Changelog v5:
- Keep alphabetical order of the include statements.
- Discard explicit u16-type cast in the dw_reg_write_word() method.

---
 drivers/i2c/busses/Kconfig                 |   1 +
 drivers/i2c/busses/i2c-designware-common.c | 178 +++++++++++++++------
 drivers/i2c/busses/i2c-designware-core.h   |  22 ++-
 drivers/i2c/busses/i2c-designware-master.c | 125 ++++++++-------
 drivers/i2c/busses/i2c-designware-slave.c  |  77 ++++-----
 5 files changed, 248 insertions(+), 155 deletions(-)
drivers/i2c/busses/Kconfig +1 -0
index 7cd279c36898..259e2325712a 100644
@@ -526,6 +526,7 @@ config I2C_DAVINCI
 
 config I2C_DESIGNWARE_CORE
 	tristate
+	select REGMAP
 
 config I2C_DESIGNWARE_SLAVE
 	bool "Synopsys DesignWare Slave"
drivers/i2c/busses/i2c-designware-common.c +127 -51

291 lines not on this page · raw message

drivers/i2c/busses/i2c-designware-core.h +10 -12
index b9ef9b0deef0..f5bbe3d6bcf8 100644
@@ -15,6 +15,7 @@
 #include <linux/dev_printk.h>
 #include <linux/errno.h>
 #include <linux/i2c.h>
+#include <linux/regmap.h>
 #include <linux/types.h>
 
 #define DW_IC_DEFAULT_FUNCTIONALITY (I2C_FUNC_I2C |			\
@@ -126,8 +127,6 @@
 #define STATUS_WRITE_IN_PROGRESS	0x1
 #define STATUS_READ_IN_PROGRESS		0x2
 
-#define TIMEOUT			20 /* ms */
-
 /*
  * operation modes
  */
@@ -183,7 +182,9 @@ struct reset_control;
 /**
  * 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
@@ -233,6 +234,7 @@ struct reset_control;
  */
 struct dw_i2c_dev {
 	struct device		*dev;
+	struct regmap		*map;
 	void __iomem		*base;
 	void __iomem		*ext;
 	struct completion	cmd_complete;
@@ -284,17 +286,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 ACCESS_INTR_MASK	0x00000001
+#define ACCESS_NO_IRQ_SUSPEND	0x00000002
 
 #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);
@@ -304,19 +302,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
#22 lore raw

Re: [PATCH v5 08/11] i2c: designware: Convert driver to using regmap API

Quoted 19 lines · Serge Semin

Seeing 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/i2c-designware-common.c static char *abort_sources[] = {

Quoted 9 lines
drivers/i2c/busses/i2c-designware-common.c +8 -0
+	struct regmap_config map_cfg = {
+		.reg_bits = 32,
+		.val_bits = 32,
+		.reg_stride = 4,
+		.disable_locking = true,
+		.reg_read = dw_reg_read,
+		.reg_write = dw_reg_write,
 
+		.max_register = DW_IC_COMP_TYPE

Perhaps leave comma here as well.

Quoted 1 line
drivers/i2c/busses/i2c-designware-common.c +1 -0
+	};

...

Quoted 4 lines
drivers/i2c/busses/i2c-designware-common.c +4 -0
+	/*
+	 * Note we'll check the return value of the regmap IO accessors 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

drivers/i2c/busses/i2c-designware-common.c static char *abort_sources[] = {

Quoted 10 lines
drivers/i2c/busses/i2c-designware-common.c +8 -0
+	 * can fail.
+	 */
+	dev->map = devm_regmap_init(dev->dev, NULL, dev, &map_cfg);
+	if (IS_ERR(dev->map)) {
+		dev_err(dev->dev, "Failed to init the registers map\n");
 
+		return PTR_ERR(dev->map);
+	}
+
 	return 0;
	return PTR_ERR_OR_ZERO(dev->map);
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#23 lore raw

Re: [PATCH v5 08/11] i2c: designware: Convert driver to using regmap API

Quoted 31 lines · Andy Shevchenko
Quoted 19 lines · Serge Semin

Seeing 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).

...

Quoted 7 lines
drivers/i2c/busses/i2c-designware-common.c +7 -0
+	struct regmap_config map_cfg = {
+		.reg_bits = 32,
+		.val_bits = 32,
+		.reg_stride = 4,
+		.disable_locking = true,
+		.reg_read = dw_reg_read,
+		.reg_write = dw_reg_write,
Quoted 4 lines

drivers/i2c/busses/i2c-designware-common.c static char *abort_sources[] = { · line 135

Quoted 1 line
drivers/i2c/busses/i2c-designware-common.c +1 -0
+		.max_register = DW_IC_COMP_TYPE

Perhaps leave comma here as well.

If v6 is required, it'll be fixed there.

-Sergey

Quoted 27 lines
Quoted 2 lines
drivers/i2c/busses/i2c-designware-common.c +1 -0
+	};

...

Quoted 4 lines
drivers/i2c/busses/i2c-designware-common.c +4 -0
+	/*
+	 * Note we'll check the return value of the regmap IO accessors 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

drivers/i2c/busses/i2c-designware-common.c static char *abort_sources[] = {

Quoted 10 lines
drivers/i2c/busses/i2c-designware-common.c +8 -0
+	 * can fail.
+	 */
+	dev->map = devm_regmap_init(dev->dev, NULL, dev, &map_cfg);
+	if (IS_ERR(dev->map)) {
+		dev_err(dev->dev, "Failed to init the registers map\n");
 
+		return PTR_ERR(dev->map);
+	}
+
 	return 0;
	return PTR_ERR_OR_ZERO(dev->map);
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#24 lore raw

PATCH v5 9/11 i2c: designware: Retrieve quirk flags as early as possible

In reply to Serge Semin

Some 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. While at it replace the or-assignment with just assignment operator since or-ing is redundant at this stage.

---

Changelog v3:
- This is a new patch, which has been created due to declining the glue-layer approach.

Changelog v5:
- Replace or-assignment with just assignment operator.

---
 drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +2 -2
index ca057aa9eac4..38657d821c72 100644
@@ -124,6 +124,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);
+
 	dev->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(dev->base))
 		return PTR_ERR(dev->base);
@@ -146,8 +148,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 
 	i2c_dw_acpi_adjust_bus_speed(&pdev->dev);
 
-	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
#25 lore raw

PATCH v5 10/11 i2c: designware: Move reg-space remapping into a dedicated function

In reply to Serge Semin

This is a preparation patch before adding a quirk with custom registers map creation required for the Baikal-T1 System I2C support.

---

Changelog v3:
- This is a new patch, which has been created due to declining the glue-layer approach.

Changelog v4:
- Use PTR_ERR_OR_ZERO() helper in the bt1_i2c_request_regs() method.
- Discard devm_platform_get_and_ioremap_resource() utilization.

---
 drivers/i2c/busses/i2c-designware-platdrv.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +13 -5
index 38657d821c72..9d467fa0e163 100644
@@ -108,6 +108,15 @@ static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)
 		pm_runtime_put_noidle(dev->dev);
 }
 
+static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev->dev);
+
+	dev->base = devm_platform_ioremap_resource(pdev, 0);
+
+	return PTR_ERR_OR_ZERO(dev->base);
+}
+
 static int dw_i2c_plat_probe(struct platform_device *pdev)
 {
 	struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -125,15 +134,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	dev->flags = (uintptr_t)device_get_match_data(&pdev->dev);
-
-	dev->base = devm_platform_ioremap_resource(pdev, 0);
-	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
#26 lore raw

PATCH v5 11/11 i2c: designware: Add Baikal-T1 System I2C support

In reply to Serge Semin

Baikal-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.

Changelog v4:
- Use PTR_ERR_OR_ZERO() helper in the bt1_i2c_request_regs() method.

---
 drivers/i2c/busses/Kconfig                  |  3 +-
 drivers/i2c/busses/i2c-designware-core.h    |  3 +
 drivers/i2c/busses/i2c-designware-platdrv.c | 78 ++++++++++++++++++++-
 3 files changed, 81 insertions(+), 3 deletions(-)
drivers/i2c/busses/Kconfig +2 -1
index 259e2325712a..0cf7aea30138 100644
@@ -541,8 +541,9 @@ config I2C_DESIGNWARE_SLAVE
 
 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
index f5bbe3d6bcf8..556673a1f61b 100644
@@ -183,6 +183,7 @@ struct reset_control;
  * 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
@@ -235,6 +236,7 @@ struct reset_control;
 struct dw_i2c_dev {
 	struct device		*dev;
 	struct regmap		*map;
+	struct regmap		*sysmap;
 	void __iomem		*base;
 	void __iomem		*ext;
 	struct completion	cmd_complete;
@@ -290,6 +292,7 @@ struct dw_i2c_dev {
 #define ACCESS_NO_IRQ_SUSPEND	0x00000002
 
 #define MODEL_MSCC_OCELOT	0x00000100
+#define MODEL_BAIKAL_BT1	0x00000200
 #define MODEL_MASK		0x00000f00
 
 int i2c_dw_init_regmap(struct dw_i2c_dev *dev);
drivers/i2c/busses/i2c-designware-platdrv.c +76 -2

114 lines not on this page · raw message

Signature · 1 line
2.26.2
#27 lore raw

Re: [PATCH v5 11/11] i2c: designware: Add Baikal-T1 System I2C support

Quoted 9 lines · Serge Semin

Baikal-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.

...

drivers/i2c/busses/i2c-designware-platdrv.c MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match); · line 107

Quoted 9 lines
drivers/i2c/busses/i2c-designware-platdrv.c +8 -0
+static struct regmap_config bt1_i2c_cfg = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
+	.fast_io = true,
+	.reg_read = bt1_i2c_read,
+	.reg_write = bt1_i2c_write,
 
+	.max_register = DW_IC_COMP_TYPE

Perhaps leave comma here.

Quoted 1 line

+};

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#28 lore raw

Re: [PATCH v5 11/11] i2c: designware: Add Baikal-T1 System I2C support

Quoted 21 lines · Andy Shevchenko
Quoted 9 lines · Serge Semin

Baikal-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.

...

Quoted 7 lines
drivers/i2c/busses/i2c-designware-platdrv.c +7 -0
+static struct regmap_config bt1_i2c_cfg = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
+	.fast_io = true,
+	.reg_read = bt1_i2c_read,
+	.reg_write = bt1_i2c_write,
Quoted 3 lines

drivers/i2c/busses/i2c-designware-platdrv.c MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match); · line 107

Quoted 1 line
drivers/i2c/busses/i2c-designware-platdrv.c +1 -0
+	.max_register = DW_IC_COMP_TYPE

Perhaps leave comma here.

If v6 is required, I'll fix it there.

-Sergey

Quoted 8 lines
Quoted 2 lines

+};

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#29 lore raw
In reply to Serge Semin
Quoted 55 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/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.

Quoted 6 lines

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.

Thank you for an update.

Quoted 1 line

This patchset is rebased and tested on the i2c/for-next (5.7-rc7):

Hmm...

Quoted 1 line

base-commit: 228f95c14949 ("Merge remote-tracking branch 'spi/for-5.8' into spi-next")

...this is strange.

Quoted 5 lines

Changelog v5:
- Replace or-assignment with just assignment operator when getting the quirk flags.
- Keep alphabetical order of the include statements.
- Discard explicit u16-type cast in the dw_reg_write_word() method.

Patches 8 and 11 have been commented solely due to previous comments for patches 6 and 7, which I think should be addressed.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#30 lore raw
Quoted 65 lines · Andy Shevchenko
Quoted 55 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/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.

Quoted 6 lines

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.

Thank you for an update.

Quoted 7 lines
Quoted 1 line

This patchset is rebased and tested on the i2c/for-next (5.7-rc7):

Hmm...

Quoted 1 line

base-commit: 228f95c14949 ("Merge remote-tracking branch 'spi/for-5.8' into spi-next")

...this is strange.

Yeah, my mistake. It should have been:
base-commit: 2a41d0f91443 ("Merge branch 'i2c/for-5.8' into i2c/for-next")

-Sergey

Quoted 15 lines
Quoted 6 lines

Changelog v5:
- Replace or-assignment with just assignment operator when getting the quirk flags.
- Keep alphabetical order of the include statements.
- Discard explicit u16-type cast in the dw_reg_write_word() method.

Patches 8 and 11 have been commented solely due to previous comments for patches 6 and 7, which I think should be addressed.

Signature · 2 lines
With Best Regards,
Andy Shevchenko