Skip to contentSkip to conversation

Add ASPEED AST2600 I2Cv2 controller driver

PATCH Superseded Ryan Chen 7 participants 40 messages Feb 24, 2025 – Sep 12, 2025

Subsystems (4)

v16 of 33 Superseded Latest is v33 →

lore
Share & tools
lore

Ryan Chen

author maintainer
#0 lore raw

v16 cover Add ASPEED AST2600 I2Cv2 controller driver

This series add AST2600 i2cv2 new register set driver. The i2cv2 driver is new register set that have new clock divider option for more flexiable generation. And also have separate i2c controller and target register set for control, patch #2 is i2c controller driver only, patch #3 is add i2c target mode driver.

The legacy register layout is mix controller/target register control together. The following is add more detail description about new register layout. And new feature set add for register.

-Add new clock divider option for more flexible and accurate clock rate generation -Add tCKHighMin timing to guarantee SCL high pulse width. -Add support dual pool buffer mode, split 32 bytes pool buffer of each device into 2 x 16 bytes for Tx and Rx individually. -Increase DMA buffer size to 4096 bytes and support byte alignment. -Re-define the base address of BUS1 ~ BUS16 and Pool buffer. -Re-define registers for separating controller and target mode control. -Support 4 individual DMA buffers for controller Tx and Rx, target Tx and Rx.

And following is new register set for package transfer sequence. -New Master operation mode:
S -> Aw -> P
S -> Aw -> TxD -> P
S -> Ar -> RxD -> P
S -> Aw -> RxD -> Sr -> Ar -> TxD -> P
-Bus SDA lock auto-release capability for new controller DMA command mode. -Bus auto timeout for new controller/target DMA mode.

The following is two versus register layout.
Old:
{I2CD00}: Function Control Register
{I2CD04}: Clock and AC Timing Control Register {I2CD08}: Clock and AC Timing Control Register {I2CD0C}: Interrupt Control Register
{I2CD10}: Interrupt Status Register
{I2CD14}: Command/Status Register
{I2CD18}: Slave Device Address Register
{I2CD1C}: Pool Buffer Control Register
{I2CD20}: Transmit/Receive Byte Buffer Register {I2CD24}: DMA Mode Buffer Address Register
{I2CD28}: DMA Transfer Length Register
{I2CD2C}: Original DMA Mode Buffer Address Setting {I2CD30}: Original DMA Transfer Length Setting and Final Status

New Register mode
{I2CC00}: Master/Slave Function Control Register {I2CC04}: Master/Slave Clock and AC Timing Control Register {I2CC08}: Master/Slave Transmit/Receive Byte Buffer Register {I2CC0C}: Master/Slave Pool Buffer Control Register {I2CM10}: Master Interrupt Control Register {I2CM14}: Master Interrupt Status Register {I2CM18}: Master Command/Status Register
{I2CM1C}: Master DMA Buffer Length Register {I2CS20}: Slave~ Interrupt Control Register {I2CS24}: Slave~ Interrupt Status Register {I2CS28}: Slave~ Command/Status Register
{I2CS2C}: Slave~ DMA Buffer Length Register {I2CM30}: Master DMA Mode Tx Buffer Base Address {I2CM34}: Master DMA Mode Rx Buffer Base Address {I2CS38}: Slave~ DMA Mode Tx Buffer Base Address {I2CS3C}: Slave~ DMA Mode Rx Buffer Base Address {I2CS40}: Slave Device Address Register
{I2CM48}: Master DMA Length Status Register {I2CS4C}: Slave DMA Length Status Register {I2CC50}: Current DMA Operating Address Status {I2CC54}: Current DMA Operating Length Status

aspeed,global-regs:
This global register is needed, global register is setting for new clock divide control, and new register set control.

ASPEED SOC chip is server product, i2c bus may have fingerprint connect to another board. And also support hotplug. The following is board-specific design example.
Board A Board B
------------------------- ------------------------

|i2c bus#1(controller/target)<=fingerprint=>i2c bus#x (controller/target)|
|i2c bus#2(controller)-> tmp i2c device |     |                          |
|i2c bus#3(controller)-> adc i2c device |     |                          |
-------------------------                     ------------------------

i2c-scl-clk-low-timeout-us:
For example I2C controller as slave mode, and suddenly disconnected. Slave state machine will keep waiting for controller clock in for rx/tx transmit. So it need timeout setting to enable timeout unlock controller state. And in another side. In Master side also need avoid suddenly slave miss(un-plug), Master will timeout and release the SDA/SCL.

aspeed,enable-dma:
For example The bus#1 have trunk data needed for transfer, it can enable bus dma mode transfer, it can reduce cpu utilized. Others bus bus#2/3 use defautl buffer mode.

aspeed,enable-byte:
Force i2c controller use byte mode transfer. the byte mode transfer will send i2c data each byte by byte, inlcude address read/write.

v16:
-aspeed,i2c.yaml: add aspeed,enable-byte properties for force byte mode. -i2c-ast2600.c
-change include asm/unaligned.h to linux/unaligned.h.
-add reset timeout councter when slave active timeout. -modify issue i2c_recovery_bus before slave re-enable.
-add aspeed,enable-byte properties.

v15:
-i2c-ast2600.c
-add include unaligned.h
-rename all master -> controller, slave -> target.
-keep multi-master to align property.
-remove no used element in ast2600_i2c_bus.
v14:
-aspeed,i2c.yaml
-v13 change people reviewed-by tag, v14 fixed to original people tag,
modify to Reviewed-by: Krzysztof Kozlowski <[email protected]>
-struct ast2600_i2c_bus layout optimal. -ast2600_select_i2c_clock refine.
-ast2600_i2c_recover_bus overridden fix.
-dma_mapping_error() returned error code shadowed modify. -buffer register in a 4-byte aligned simplified
-remove smbus alert

v13:
-separate i2c master and slave driver to be two patchs. -modify include header list, add bits.h include. remove of*.h -modify (((x) >> 24) & GENMASK(5, 0)) to (((x) & GENMASK(29, 24)) >> 24) -modify ast2600_select_i2c_clock function implement.
-modify ast2600_i2c_recover_bus function u32 claim to
u32 state = readl(i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF);

v12:
-aspeed,i2c.yaml
-add Reviewed-by: Krzysztof Kozlowski <[email protected]>
-i2c-ast2600.c
-update include by alphabetical order
-make just a one TAB and put the last two lines on the single one -remove no used timing_table structre
-remove enum explicit assinment
-rewritten to avoid this and using loop in ast2600_select_i2c_clock -use GENMASK for most 0xffff
-remove too many parentheses
-use str_read_write replace read write string
-remove redundant blank line after ast2600_i2c_bus_of_table -fix wrong multi-line style of the comment
-use macro for i2c standard speeds
-remove useless noise dev_info

v11:
-aspeed,i2c.yaml
-no change, the same with v10.
-i2c-ast2600.c
-modify alert_enable from int -> boolean.
-modify dbg string recovery -> recover.
-remove no need to init 0.
-remove new line after break.
-remove unneeded empty line.
-modify dma_alloc_coherent to dmam_alloc_coherent
-modify probe nomem return dev_err_probe
-modify i2c_add_adapter to devm_i2c_adapter
-modify checkpatch: Alignment should match open parenthesis -modify checkpatch: braces {} should be used on all arms of this statement -modify checkpatch: Unbalanced braces around else statement

v10:
-aspeed,i2c.yaml
-move unevaluatedProperties after allOf.
-remove extra one blank line.
-i2c-ast2600.c
-no change, the same with v8.

v9:
-aspeed,i2c.yaml
-backoff to v7.
-no fix typo in maintainer's name and email. this would be another patch. -no remove address-cells, size-cells, this would be another patch.
-use aspeed,enable-dma property instead of aspeed,xfer-mode selection. -fix allOf and else false properties for aspeed,ast2600-i2cv2.
-i2c-ast2600.c
-no change, the same with v8

v8:
-aspeed,i2c.yaml
-modify commit message.
-Fix typo in maintainer's name and email.
-remove address-cells, size-cells.
-i2c-ast2600.c
-move "i2c timeout counter" comment description before property_read. -remove redundant code "return ret" in probe end.

v7:
-aspeed,i2c.yaml
-Update ASPEED I2C maintainers email.
-use aspeed,enable-dma property instead of aspeed,xfer-mode selection. -fix allOf and else false properties for aspeed,ast2600-i2cv2.
-i2c-ast2600.c
-remove aspeed,xfer-mode instead of aspeed,enable-dma mode. buffer mode
is default.
-remove aspeed,timeout instead of i2c-scl-clk-low-timeout-us for
timeout setting.

v6:
-remove aspeed,i2cv2.yaml, merge to aspeed,i2c.yaml -add support for
i2cv2 properites.
-i2c-ast2600.c
-fix ast2600_i2c_remove ordering.
-remove ast2600_i2c_probe goto labels, and add dev_err_probe -remove
redundant deb_dbg debug message.
-rename gr_regmap -> global_regs

v5:
-remove ast2600-i2c-global.yaml, i2c-ast2600-global.c. -i2c-ast2600.c
-remove legacy clock divide, all go for new clock divide. -remove duplicated read isr.
-remove no used driver match
-fix probe return for each labels return.
-global use mfd driver, driver use phandle to regmap read/write.
-rename aspeed,i2c-ast2600.yaml to aspeed,i2cv2.yaml -remove bus-frequency. -add required aspeed,gr
-add timeout, byte-mode, buff-mode properites.

v4:
-fix i2c-ast2600.c driver buffer mode use single buffer conflit in
master slave mode both enable.
-fix kmemleak issue when use dma mode.
-fix typo aspeed,i2c-ast2600.yaml compatible is "aspeed,ast2600-i2c" -fix typo aspeed,i2c-ast2600.ymal to aspeed,i2c-ast2600.yaml

v3:
-fix i2c global clock divide default value.
-remove i2c slave no used dev_dbg info.

v2:
-add i2c global ymal file commit.
-rename file name from new to ast2600.
aspeed-i2c-new-global.c -> i2c-ast2600-global.c aspeed-i2c-new-global.h -> i2c-ast2600-global.h i2c-new-aspeed.c -> i2c-ast2600.c
-rename all driver function name to ast2600.
Ryan Chen (3):
dt-bindings: i2c: aspeed: support for AST2600-i2cv2
i2c: aspeed: support AST2600 i2c new register mode driver
i2c: aspeed: support AST2600 i2c new register target mode driver

 .../devicetree/bindings/i2c/aspeed,i2c.yaml   |   58 +
 drivers/i2c/busses/Kconfig                    |   11 +
 drivers/i2c/busses/Makefile                   |    1 +
 drivers/i2c/busses/i2c-ast2600.c              | 1565 +++++++++++++++++
 4 files changed, 1635 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ast2600.c
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v16 1/3 dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Add ast2600-i2cv2 compatible and aspeed,global-regs, aspeed,enable-dma and description for ast2600-i2cv2.

---
 .../devicetree/bindings/i2c/aspeed,i2c.yaml   | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +58 -0
index 5b9bd2feda3b..356033d18f90 100644
@@ -44,12 +44,60 @@ properties:
     description: frequency of the bus clock in Hz defaults to 100 kHz when not
       specified
 
+  multi-master:
+    type: boolean
+    description:
+      states that there is another master active on this bus
+
+  aspeed,enable-dma:
+    type: boolean
+    description: |
+      I2C bus enable dma mode transfer.
+
+      ASPEED ast2600 platform equipped with 16 I2C controllers that share a
+      single DMA engine. DTS files can specify the data transfer mode to/from
+      the device, either DMA or programmed I/O. However, hardware limitations
+      may require a DTS to manually allocate which controller can use DMA mode.
+      The "aspeed,enable-dma" property allows control of this.
+
+      In cases where one the hardware design results in a specific
+      controller handling a larger amount of data, a DTS would likely
+      enable DMA mode for that one controller.
+
+  aspeed,enable-byte:
+    type: boolean
+    description: |
+      I2C bus enable byte mode transfer.
+
+  aspeed,global-regs:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of i2c global register node.
+
 required:
   - reg
   - compatible
   - clocks
   - resets
 
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2
+
+    then:
+      properties:
+        reg:
+          minItems: 2
+      required:
+        - aspeed,global-regs
+    else:
+      properties:
+        aspeed,global-regs: false
+        aspeed,enable-dma: false
+
 unevaluatedProperties: false
 
 examples:
@@ -66,3 +114,13 @@ examples:
       interrupts = <0>;
       interrupt-parent = <&i2c_ic>;
     };
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    i2c1: i2c@80 {
+      compatible = "aspeed,ast2600-i2cv2";
+      reg = <0x80 0x80>, <0xc00 0x20>;
+      aspeed,global-regs = <&i2c_global>;
+      clocks = <&syscon ASPEED_CLK_APB>;
+      resets = <&syscon ASPEED_RESET_I2C>;
+      interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
+    };
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 8 lines · Ryan Chen

Add ast2600-i2cv2 compatible and aspeed,global-regs, aspeed,enable-dma and description for ast2600-i2cv2.

---
 .../devicetree/bindings/i2c/aspeed,i2c.yaml   | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:
./Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml:82:1: [error] duplication of key "allOf" in mapping (key-duplicates)

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml: ignoring, error parsing file ./Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml:82:1: found duplicate key "allOf" with value "[]" (original value: "[]") make[2]: *** Deleting file 'Documentation/devicetree/bindings/i2c/aspeed,i2c.example.dts' Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml:82:1: found duplicate key "allOf" with value "[]" (original value: "[]") make[2]: *** [Documentation/devicetree/bindings/Makefile:26: Documentation/devicetree/bindings/i2c/aspeed,i2c.example.dts] Error 1 make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1511: dt_binding_check] Error 2
make: *** [Makefile:251: __sub-make] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#3 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

In reply to Ryan Chen
Quoted 13 lines · Ryan Chen

Add ast2600-i2cv2 compatible and aspeed,global-regs, aspeed,enable-dma and description for ast2600-i2cv2.

---
 .../devicetree/bindings/i2c/aspeed,i2c.yaml   | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +0 -0
index 5b9bd2feda3b..356033d18f90 100644

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 50

Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
@@ -44,12 +44,60 @@ properties:
     description: frequency of the bus clock in Hz defaults to 100 kHz when not
       specified
 
+  multi-master:
+    type: boolean
+    description:
+      states that there is another master active on this bus

Except that this wasn't ever tested...

Don't duplicate properties. i2c-controller schema has it already.

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 59

Quoted 9 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +9 -0
+
+  aspeed,enable-dma:
+    type: boolean
+    description: |
+      I2C bus enable dma mode transfer.
+
+      ASPEED ast2600 platform equipped with 16 I2C controllers that share a
+      single DMA engine. DTS files can specify the data transfer mode to/from
+      the device, either DMA or programmed I/O. However, hardware limitations

so what is byte mode?

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 70

Quoted 11 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +11 -0
+      may require a DTS to manually allocate which controller can use DMA mode.
+      The "aspeed,enable-dma" property allows control of this.
+
+      In cases where one the hardware design results in a specific
+      controller handling a larger amount of data, a DTS would likely
+      enable DMA mode for that one controller.
+
+  aspeed,enable-byte:
+    type: boolean
+    description: |
+      I2C bus enable byte mode transfer.

No, either this is expressed as lack of dma mode property or if you have three modes, then rather some enum (aspeed,transfer-mode ?)

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 74

Quoted 4 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
+
+  aspeed,global-regs:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of i2c global register node.

For what? Same question as usual: do not repeat property name, but say what is this used for and what exactly it points to.

s/i2c/I2C/ but then what is "I2C global register node"? This is how you call your device in datasheet?

Quoted 4 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +1 -0
+
 required:
   - reg
   - compatible

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 88

Quoted 10 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
   - clocks
   - resets
 
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2

NAK, undocumented compatible.

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 93

Quoted 5 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +5 -0
+
+    then:
+      properties:
+        reg:
+          minItems: 2

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 9 lines · Krzysztof Kozlowski
Quoted 9 lines

+
required:
- reg
- compatible
- clocks
- resets

Quoted 9 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 88

Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2

NAK, undocumented compatible.

Heh, and this was in previous versions as well.

You have never tested your DTS. At v16 still no testing. This is not acceptable.

Best regards,
Krzysztof

author maintainer
#5 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

In reply to Krzysztof Kozlowski
Quoted 22 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 14 lines · Ryan Chen

Add ast2600-i2cv2 compatible and aspeed,global-regs, aspeed,enable-dma and description for ast2600-i2cv2.

---
 .../devicetree/bindings/i2c/aspeed,i2c.yaml   | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +0 -0
index 5b9bd2feda3b..356033d18f90 100644

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 44

Quoted 1 line
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +0 -0
@@ -44,12 +44,60 @@ properties:
     description: frequency of the bus clock in Hz defaults to 100 kHz when

not

Quoted 2 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +0 -0
       specified
 
Quoted 8 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 50

Quoted 4 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
+  multi-master:
+    type: boolean
+    description:
+      states that there is another master active on this bus

Except that this wasn't ever tested...

Don't duplicate properties. i2c-controller schema has it already.

I will remove it to avoid duplication.

Quoted 9 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties:

Quoted 8 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
+
+  aspeed,enable-dma:
+    type: boolean
+    description: |
+      I2C bus enable dma mode transfer.
+
+      ASPEED ast2600 platform equipped with 16 I2C controllers that

share a

Quoted 6 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 58

Quoted 1 line
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +1 -0
+      single DMA engine. DTS files can specify the data transfer mode

to/from

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 60

Quoted 2 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +2 -0
+      the device, either DMA or programmed I/O. However, hardware
+ limitations

so what is byte mode?

I explain in cover, I will add here also. aspeed,enable-byte:
Force i2c controller use byte mode transfer. the byte mode transfer will send i2c data each byte by byte, inlcude address read/write.

Quoted 16 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 61

Quoted 2 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +1 -0
+      may require a DTS to manually allocate which controller can use

DMA mode.

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 70

Quoted 10 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +10 -0
+      The "aspeed,enable-dma" property allows control of this.
+
+      In cases where one the hardware design results in a specific
+      controller handling a larger amount of data, a DTS would likely
+      enable DMA mode for that one controller.
+
+  aspeed,enable-byte:
+    type: boolean
+    description: |
+      I2C bus enable byte mode transfer.

No, either this is expressed as lack of dma mode property or if you have three modes, then rather some enum (aspeed,transfer-mode ?)

Thanks suggestion, I will using an enum property like aspeed,transfer-mode instead.

Quoted 8 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 74

Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
+
+  aspeed,global-regs:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of i2c global register node.
Quoted 6 lines

For what? Same question as usual: do not repeat property name, but say what is this used for and what exactly it points to.

s/i2c/I2C/ but then what is "I2C global register node"? This is how you call your device in datasheet?

I do descript in cover, should add into the yaml file ?

aspeed,global-regs:
This global register is needed, global register is setting for new clock divide control, and new register set control.

Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +1 -0
+
 required:
   - reg
   - compatible
   - clocks
   - resets
 
Quoted 9 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 88

Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2

NAK, undocumented compatible.

Sorry, I should add what kind of document about this compatible?

The cover descripts it, should I add into yaml?

This series add AST2600 i2cv2 new register set driver. The i2cv2 driver is new register set that have new clock divider option for more flexiable generation. And also have separate i2c controller and target register set for control, patch #2 is i2c controller driver only, patch #3 is add i2c target mode driver.

The legacy register layout is mix controller/target register control together. The following is add more detail description about new register layout. And new feature set add for register.

Quoted 10 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 93

Quoted 6 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +5 -0
+
+    then:
+      properties:
+        reg:
+          minItems: 2

Best regards,
Krzysztof

#6 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 41 lines · Ryan Chen
Quoted 22 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 14 lines · Ryan Chen

Add ast2600-i2cv2 compatible and aspeed,global-regs, aspeed,enable-dma and description for ast2600-i2cv2.

---
 .../devicetree/bindings/i2c/aspeed,i2c.yaml   | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +0 -0
index 5b9bd2feda3b..356033d18f90 100644

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 44

Quoted 1 line
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +0 -0
@@ -44,12 +44,60 @@ properties:
     description: frequency of the bus clock in Hz defaults to 100 kHz when

not

Quoted 2 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +0 -0
       specified
 
Quoted 8 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 50

Quoted 4 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
+  multi-master:
+    type: boolean
+    description:
+      states that there is another master active on this bus

Except that this wasn't ever tested...

Don't duplicate properties. i2c-controller schema has it already.

I will remove it to avoid duplication.

Quoted 9 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties:

Quoted 8 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
+
+  aspeed,enable-dma:
+    type: boolean
+    description: |
+      I2C bus enable dma mode transfer.
+
+      ASPEED ast2600 platform equipped with 16 I2C controllers that

share a

Quoted 7 lines
Quoted 6 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 58

Quoted 1 line
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +1 -0
+      single DMA engine. DTS files can specify the data transfer mode

to/from

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 60

Quoted 2 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +2 -0
+      the device, either DMA or programmed I/O. However, hardware
+ limitations

so what is byte mode?

I explain in cover, I will add here also.

Cover letters do not get merged and we do not read them, except when looking for dependencies and explanations of process (like RFC). Your hardware description must be fully contained in commits, not cover letter.

Quoted 3 lines

aspeed,enable-byte:
Force i2c controller use byte mode transfer. the byte mode transfer will send i2c data each byte by byte, inlcude address read/write.

Isn't this standard FIFO mode?

Why anyone would need to enable byte mode for given board?

Quoted 27 lines
Quoted 4 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 61

Quoted 3 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +1 -0
+      may require a DTS to manually allocate which controller can use

DMA mode.

Quoted 13 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 70

Quoted 10 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +10 -0
+      The "aspeed,enable-dma" property allows control of this.
+
+      In cases where one the hardware design results in a specific
+      controller handling a larger amount of data, a DTS would likely
+      enable DMA mode for that one controller.
+
+  aspeed,enable-byte:
+    type: boolean
+    description: |
+      I2C bus enable byte mode transfer.

No, either this is expressed as lack of dma mode property or if you have three modes, then rather some enum (aspeed,transfer-mode ?)

Thanks suggestion, I will using an enum property like aspeed,transfer-mode instead.

Quoted 8 lines
Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
+
+  aspeed,global-regs:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of i2c global register node.
Quoted 7 lines
Quoted 6 lines

For what? Same question as usual: do not repeat property name, but say what is this used for and what exactly it points to.

s/i2c/I2C/ but then what is "I2C global register node"? This is how you call your device in datasheet?

I do descript in cover, should add into the yaml file ?

Again, cover letter does not matter. Your hardware must be explained here.

Quoted 4 lines

aspeed,global-regs:
This global register is needed, global register is setting for new clock divide control, and new register set control.

So this means you implement clock controller via syscon?

Quoted 19 lines
Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +1 -0
+
 required:
   - reg
   - compatible
   - clocks
   - resets
 
Quoted 9 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 88

Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2

NAK, undocumented compatible.

Quoted 1 line

Sorry, I should add what kind of document about this compatible?

You cannot add new compatibles without documenting them. Documentation is in the form of DT schema and each compatible must be listed (in some way) in compatible property description.

Best regards,
Krzysztof

author maintainer
#7 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 53 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 10 lines · Ryan Chen
Quoted 10 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 6 lines · Ryan Chen

Add ast2600-i2cv2 compatible and aspeed,global-regs, aspeed,enable-dma and description for ast2600-i2cv2.

---
 .../devicetree/bindings/i2c/aspeed,i2c.yaml   | 58

+++++++++++++++++++

Quoted 38 lines
Quoted 13 lines
Quoted 10 lines
 1 file changed, 58 insertions(+)
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +0 -0
index 5b9bd2feda3b..356033d18f90 100644
@@ -44,12 +44,60 @@ properties:
     description: frequency of the bus clock in Hz defaults to 100

kHz when

not

Quoted 2 lines

specified

Quoted 8 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 50

Quoted 4 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
+  multi-master:
+    type: boolean
+    description:
+      states that there is another master active on this bus

Except that this wasn't ever tested...

Don't duplicate properties. i2c-controller schema has it already.

I will remove it to avoid duplication.

Quoted 15 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties:

Quoted 8 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
+
+  aspeed,enable-dma:
+    type: boolean
+    description: |
+      I2C bus enable dma mode transfer.
+
+      ASPEED ast2600 platform equipped with 16 I2C controllers that

share a

Quoted 2 lines

+ single DMA engine. DTS files can specify the data transfer
+ mode

to/from

Quoted 2 lines

+ the device, either DMA or programmed I/O. However, hardware
+ limitations

Quoted 6 lines
Quoted 2 lines
Quoted 1 line

so what is byte mode?

I explain in cover, I will add here also.

Cover letters do not get merged and we do not read them, except when looking for dependencies and explanations of process (like RFC). Your hardware description must be fully contained in commits, not cover letter.

Got it, I will paste it in commits.

Quoted 7 lines
Quoted 5 lines

aspeed,enable-byte:
Force i2c controller use byte mode transfer. the byte mode transfer will send i2c data each byte by byte, inlcude address read/write.

Isn't this standard FIFO mode?

Yes, it is.

Quoted 2 lines

Why anyone would need to enable byte mode for given board?

By default, it is buffer-mode, for performance, I don't want user enable byte-mode, it will increase CPU utilize. But someone want to be force enable byte-mode, so I add properties.
https://patchwork.ozlabs.org/project/linux-aspeed/patch/[email protected]/

Quoted 33 lines
Quoted 20 lines
Quoted 6 lines
Quoted 5 lines

+ may require a DTS to manually allocate which controller can
+ use

DMA mode.

Quoted 13 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 70

Quoted 10 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +10 -0
+      The "aspeed,enable-dma" property allows control of this.
+
+      In cases where one the hardware design results in a specific
+      controller handling a larger amount of data, a DTS would likely
+      enable DMA mode for that one controller.
+
+  aspeed,enable-byte:
+    type: boolean
+    description: |
+      I2C bus enable byte mode transfer.

No, either this is expressed as lack of dma mode property or if you have three modes, then rather some enum (aspeed,transfer-mode ?)

Quoted 1 line

Thanks suggestion, I will using an enum property like aspeed,transfer-mode

instead.

Quoted 11 lines
Quoted 11 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 74

Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
+
+  aspeed,global-regs:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of i2c global register node.

For what? Same question as usual: do not repeat property name, but say what is this used for and what exactly it points to.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

s/i2c/I2C/ but then what is "I2C global register node"? This is how you call your device in datasheet?

I do descript in cover, should add into the yaml file ?

Again, cover letter does not matter. Your hardware must be explained here.

Will add into commit.

Quoted 7 lines
Quoted 5 lines

aspeed,global-regs:
This global register is needed, global register is setting for new clock divide control, and new register set control.

So this means you implement clock controller via syscon?

No, it is just mode switch. It also explain in cover. I will add it in commit.
The legacy register layout is mix controller/target register control together. The following is add more detail description about new register layout. And new feature set add for register.

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +1 -0
+
 required:
   - reg
   - compatible

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 88

Quoted 10 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
   - clocks
   - resets
 
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2

NAK, undocumented compatible.

Quoted 5 lines
Quoted 1 line

Sorry, I should add what kind of document about this compatible?

You cannot add new compatibles without documenting them. Documentation is in the form of DT schema and each compatible must be listed (in some way) in compatible property description.

Sorry, do you mean, I add following in yaml or commit message?

This series add AST2600 i2cv2 new register set driver. The i2cv2 driver is new register set that have new clock divider option for more flexiable generation. And also have separate i2c controller and target register set for control, patch #2 is i2c controller driver only, patch #3 is add i2c target mode driver.

The legacy register layout is mix controller/target register control together. The following is add more detail description about new register layout. And new feature set add for register.

-Add new clock divider option for more flexible and accurate clock rate generation -Add tCKHighMin timing to guarantee SCL high pulse width. -Add support dual pool buffer mode, split 32 bytes pool buffer of each device into 2 x 16 bytes for Tx and Rx individually. -Increase DMA buffer size to 4096 bytes and support byte alignment.
-Re-define the base address of BUS1 ~ BUS16 and Pool buffer.
-Re-define registers for separating controller and target mode control.
-Support 4 individual DMA buffers for controller Tx and Rx, target Tx and Rx.

Quoted 4 lines

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 6 lines · Ryan Chen
Quoted 6 lines
Quoted 5 lines

aspeed,enable-byte:
Force i2c controller use byte mode transfer. the byte mode transfer will send i2c data each byte by byte, inlcude address read/write.

Quoted 7 lines
Quoted 1 line

Isn't this standard FIFO mode?

Yes, it is.

Quoted 2 lines

Why anyone would need to enable byte mode for given board?

By default, it is buffer-mode, for performance, I don't want user enable byte-mode, it will increase CPU utilize. But someone want to be force enable byte-mode, so I add properties.
https://patchwork.ozlabs.org/project/linux-aspeed/patch/[email protected]/

I don't see the reason why this would be a board property.

I understood need for DMA because it is shared and only some of the controllers can use it. But why choice between buffer and FIFO depending on hardware?

Quoted 70 lines
Quoted 33 lines
Quoted 20 lines
Quoted 6 lines
Quoted 5 lines

+ may require a DTS to manually allocate which controller can
+ use

DMA mode.

Quoted 13 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 70

Quoted 10 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +10 -0
+      The "aspeed,enable-dma" property allows control of this.
+
+      In cases where one the hardware design results in a specific
+      controller handling a larger amount of data, a DTS would likely
+      enable DMA mode for that one controller.
+
+  aspeed,enable-byte:
+    type: boolean
+    description: |
+      I2C bus enable byte mode transfer.

No, either this is expressed as lack of dma mode property or if you have three modes, then rather some enum (aspeed,transfer-mode ?)

Quoted 1 line

Thanks suggestion, I will using an enum property like aspeed,transfer-mode

instead.

Quoted 11 lines
Quoted 11 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 74

Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
+
+  aspeed,global-regs:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of i2c global register node.

For what? Same question as usual: do not repeat property name, but say what is this used for and what exactly it points to.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

s/i2c/I2C/ but then what is "I2C global register node"? This is how you call your device in datasheet?

I do descript in cover, should add into the yaml file ?

Again, cover letter does not matter. Your hardware must be explained here.

Will add into commit.

Quoted 7 lines
Quoted 5 lines

aspeed,global-regs:
This global register is needed, global register is setting for new clock divide control, and new register set control.

So this means you implement clock controller via syscon?

No, it is just mode switch. It also explain in cover. I will add it in commit.
The legacy register layout is mix controller/target register control together. The following is add more detail description about new register layout. And new feature set add for register.

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +1 -0
+
 required:
   - reg
   - compatible

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 88

Quoted 10 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
   - clocks
   - resets
 
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2

NAK, undocumented compatible.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Sorry, I should add what kind of document about this compatible?

You cannot add new compatibles without documenting them. Documentation is in the form of DT schema and each compatible must be listed (in some way) in compatible property description.

Sorry, do you mean, I add following in yaml or commit message?

You need to list this in compatibles first.

Quoted 2 lines

This series add AST2600 i2cv2 new register set driver. The i2cv2 driver is new register set that have new clock divider option for more flexiable generation. And also have separate i2c controller and target register set for control, patch #2 is i2c controller driver only, patch #3 is add i2c target mode driver.

All this describes driver, not hardware.

Review

Quoted 9 lines

The legacy register layout is mix controller/target register control together. The following is add more detail description about new register layout. And new feature set add for register.

(quoted diff) +0 -6
-Add new clock divider option for more flexible and accurate clock rate generation -Add tCKHighMin timing to guarantee SCL high pulse width.
-Add support dual pool buffer mode, split 32 bytes pool buffer of each device into 2 x 16 bytes for Tx and Rx individually.
-Increase DMA buffer size to 4096 bytes and support byte alignment.
-Re-define the base address of BUS1 ~ BUS16 and Pool buffer.
-Re-define registers for separating controller and target mode control.
-Support 4 individual DMA buffers for controller Tx and Rx, target Tx and Rx.

Does it mean hardware changed on AST2600? Or these are different devices than aspeed,ast2600-i2c-bus? If this is not a different device, how one SoC can have two different flavors of same device in the same instance?

Best regards,
Krzysztof

author maintainer
#9 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 21 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 11 lines · Ryan Chen
Quoted 7 lines
Quoted 5 lines

aspeed,enable-byte:
Force i2c controller use byte mode transfer. the byte mode transfer will send i2c data each byte by byte, inlcude address read/write.

Isn't this standard FIFO mode?

Yes, it is.

Quoted 2 lines

Why anyone would need to enable byte mode for given board?

By default, it is buffer-mode, for performance, I don't want user enable

byte-mode, it will increase CPU utilize.

Quoted 3 lines

But someone want to be force enable byte-mode, so I add properties.
https://patchwork.ozlabs.org/project/linux-aspeed/patch/20241007035235
[email protected]/

Quoted 5 lines

I don't see the reason why this would be a board property.

I understood need for DMA because it is shared and only some of the controllers can use it. But why choice between buffer and FIFO depending on hardware?

By default, the I2C controller runs in buffer mode. Each i2c bus have 16bytes buffer to transmit data. Enabling byte mode will increases CPU utilization, so it is not recommended.
However, some user might require forcing byte mode, so I added this property to allow that.

Quoted 77 lines
Quoted 46 lines
Quoted 36 lines
Quoted 22 lines
Quoted 8 lines
Quoted 7 lines

+ may require a DTS to manually allocate which controller can
+ use

DMA mode.

Quoted 13 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 70

Quoted 10 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +10 -0
+      The "aspeed,enable-dma" property allows control of this.
+
+      In cases where one the hardware design results in a specific
+      controller handling a larger amount of data, a DTS would likely
+      enable DMA mode for that one controller.
+
+  aspeed,enable-byte:
+    type: boolean
+    description: |
+      I2C bus enable byte mode transfer.

No, either this is expressed as lack of dma mode property or if you have three modes, then rather some enum (aspeed,transfer-mode ?)

Quoted 2 lines

Thanks suggestion, I will using an enum property like aspeed,transfer-mode

instead.

Quoted 11 lines
Quoted 11 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 74

Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +4 -0
+
+  aspeed,global-regs:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of i2c global register node.

For what? Same question as usual: do not repeat property name, but say what is this used for and what exactly it points to.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

s/i2c/I2C/ but then what is "I2C global register node"? This is how you call your device in datasheet?

I do descript in cover, should add into the yaml file ?

Again, cover letter does not matter. Your hardware must be explained here.

Will add into commit.

Quoted 2 lines
Quoted 2 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

aspeed,global-regs:
This global register is needed, global register is setting for new clock divide control, and new register set control.

So this means you implement clock controller via syscon?

No, it is just mode switch. It also explain in cover. I will add it in commit. The legacy register layout is mix controller/target register control together.

The following is add more detail description about new register layout. And new feature set add for register.

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 10 lines
Quoted 10 lines

+
required:
- reg
- compatible
- clocks
- resets

Quoted 9 lines

Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml properties: · line 88

Quoted 7 lines
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml +7 -0
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2

NAK, undocumented compatible.

Sorry, I should add what kind of document about this compatible?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

You cannot add new compatibles without documenting them. Documentation is in the form of DT schema and each compatible must be listed (in some
way) in compatible property description.

Sorry, do you mean, I add following in yaml or commit message?

You need to list this in compatibles first.

I will add it in compatible in next submit.

	enum:
		-aspeed,ast2600-i2cv2
Quoted 8 lines
Quoted 3 lines

This series add AST2600 i2cv2 new register set driver. The i2cv2 driver is new

register set that have new clock divider option for more flexiable generation. And also have separate i2c controller and target register set for control, patch #2 is i2c controller driver only, patch #3 is add i2c target mode driver.

All this describes driver, not hardware.

Sorry, the cover letter description the register. I will add int in commit message.

-Add new clock divider option for more flexible and accurate clock rate generation -Add tCKHighMin timing to guarantee SCL high pulse width. -Add support dual pool buffer mode, split 32 bytes pool buffer of each device into 2 x 16 bytes for Tx and Rx individually. -Increase DMA buffer size to 4096 bytes and support byte alignment. -Re-define the base address of BUS1 ~ BUS16 and Pool buffer. -Re-define registers for separating controller and target mode control. -Support 4 individual DMA buffers for controller Tx and Rx, target Tx and Rx.

And following is new register set for package transfer sequence. -New Master operation mode:
S -> Aw -> P
S -> Aw -> TxD -> P
S -> Ar -> RxD -> P
S -> Aw -> RxD -> Sr -> Ar -> TxD -> P
-Bus SDA lock auto-release capability for new controller DMA command mode. -Bus auto timeout for new controller/target DMA mode.

The following is two versus register layout.
Old:
{I2CD00}: Function Control Register
{I2CD04}: Clock and AC Timing Control Register {I2CD08}: Clock and AC Timing Control Register {I2CD0C}: Interrupt Control Register
{I2CD10}: Interrupt Status Register
{I2CD14}: Command/Status Register
{I2CD18}: Slave Device Address Register
{I2CD1C}: Pool Buffer Control Register
{I2CD20}: Transmit/Receive Byte Buffer Register {I2CD24}: DMA Mode Buffer Address Register
{I2CD28}: DMA Transfer Length Register
{I2CD2C}: Original DMA Mode Buffer Address Setting {I2CD30}: Original DMA Transfer Length Setting and Final Status

New Register mode
{I2CC00}: Master/Slave Function Control Register {I2CC04}: Master/Slave Clock and AC Timing Control Register {I2CC08}: Master/Slave Transmit/Receive Byte Buffer Register {I2CC0C}: Master/Slave Pool Buffer Control Register {I2CM10}: Master Interrupt Control Register {I2CM14}: Master Interrupt Status Register {I2CM18}: Master Command/Status Register
{I2CM1C}: Master DMA Buffer Length Register {I2CS20}: Slave~ Interrupt Control Register {I2CS24}: Slave~ Interrupt Status Register {I2CS28}: Slave~ Command/Status Register
{I2CS2C}: Slave~ DMA Buffer Length Register {I2CM30}: Master DMA Mode Tx Buffer Base Address {I2CM34}: Master DMA Mode Rx Buffer Base Address {I2CS38}: Slave~ DMA Mode Tx Buffer Base Address {I2CS3C}: Slave~ DMA Mode Rx Buffer Base Address {I2CS40}: Slave Device Address Register
{I2CM48}: Master DMA Length Status Register {I2CS4C}: Slave DMA Length Status Register {I2CC50}: Current DMA Operating Address Status {I2CC54}: Current DMA Operating Length Status

Quoted 8 lines
Quoted 3 lines

The legacy register layout is mix controller/target register control together.

The following is add more detail description about new register layout. And new feature set add for register.

Quoted 2 lines

-Add new clock divider option for more flexible and accurate clock rate

generation -Add tCKHighMin timing to guarantee SCL high pulse width.

Quoted 8 lines
Quoted 1 line

-Add support dual pool buffer mode, split 32 bytes pool buffer of each device

into 2 x 16 bytes for Tx and Rx individually.

Review

Quoted 4 lines
(quoted diff) +0 -4
-Increase DMA buffer size to 4096 bytes and support byte alignment.
-Re-define the base address of BUS1 ~ BUS16 and Pool buffer.
-Re-define registers for separating controller and target mode control.
-Support 4 individual DMA buffers for controller Tx and Rx, target Tx and Rx.

Does it mean hardware changed on AST2600?

No Hw change, it is different mode setting will have another mode register setting. Mode setting is in global register, I will add in next commit message

I2CG00: Device Master Mode Interrupt Status Register (I2CG0C[3]=1)
I2CG00: Device Master/Slave Mode Interrupt Status Register (I2CG0C[3]=0)
I2CG04: Device Slave Mode Interrupt Status Register
I2CG0C: Global Control Register
I2CG10: New Clock Divider Control Register (I2CG0C[1] = 1)

Quoted 3 lines

Or these are different devices
than aspeed,ast2600-i2c-bus? If this is not a different device, how one SoC can have two different flavors of same device in the same instance?

When global setting for new, will new register mapping, no setting will keep old register mapping.

Quoted 6 lines

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 23 lines · Ryan Chen
Quoted 23 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 11 lines · Ryan Chen
Quoted 7 lines
Quoted 5 lines

aspeed,enable-byte:
Force i2c controller use byte mode transfer. the byte mode transfer will send i2c data each byte by byte, inlcude address read/write.

Isn't this standard FIFO mode?

Yes, it is.

Quoted 2 lines

Why anyone would need to enable byte mode for given board?

By default, it is buffer-mode, for performance, I don't want user enable

byte-mode, it will increase CPU utilize.

Quoted 3 lines

But someone want to be force enable byte-mode, so I add properties.
https://patchwork.ozlabs.org/project/linux-aspeed/patch/20241007035235
[email protected]/

I don't see the reason why this would be a board property.

Quoted 7 lines
Quoted 3 lines

I understood need for DMA because it is shared and only some of the controllers can use it. But why choice between buffer and FIFO depending on hardware?

By default, the I2C controller runs in buffer mode. Each i2c bus have 16bytes buffer to transmit data. Enabling byte mode will increases CPU utilization, so it is not recommended.
However, some user might require forcing byte mode, so I added this property to allow that.

You are not answering the question. I asked why the choice depends on hardware and you answer "user might required".

Do you understand that this is about hardware, not user choices?

Quoted 150 lines
Quoted 77 lines
Quoted 46 lines
Quoted 36 lines
Quoted 22 lines
Quoted 8 lines
Quoted 7 lines

+ may require a DTS to manually allocate which controller can
+ use

DMA mode.

Quoted 13 lines

Review

Quoted 10 lines
(quoted diff) +10 -0
+      The "aspeed,enable-dma" property allows control of this.
+
+      In cases where one the hardware design results in a specific
+      controller handling a larger amount of data, a DTS would likely
+      enable DMA mode for that one controller.
+
+  aspeed,enable-byte:
+    type: boolean
+    description: |
+      I2C bus enable byte mode transfer.

No, either this is expressed as lack of dma mode property or if you have three modes, then rather some enum (aspeed,transfer-mode ?)

Quoted 2 lines

Thanks suggestion, I will using an enum property like aspeed,transfer-mode

instead.

Quoted 11 lines
Quoted 11 lines

Review

Quoted 7 lines
(quoted diff) +4 -0
+
+  aspeed,global-regs:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of i2c global register node.

For what? Same question as usual: do not repeat property name, but say what is this used for and what exactly it points to.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

s/i2c/I2C/ but then what is "I2C global register node"? This is how you call your device in datasheet?

I do descript in cover, should add into the yaml file ?

Again, cover letter does not matter. Your hardware must be explained here.

Will add into commit.

Quoted 2 lines
Quoted 2 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

aspeed,global-regs:
This global register is needed, global register is setting for new clock divide control, and new register set control.

So this means you implement clock controller via syscon?

No, it is just mode switch. It also explain in cover. I will add it in commit. The legacy register layout is mix controller/target register control together.

The following is add more detail description about new register layout. And new feature set add for register.

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 10 lines
Quoted 10 lines

+
required:
- reg
- compatible
- clocks
- resets

Quoted 9 lines

Review

Quoted 7 lines
(quoted diff) +7 -0
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2

NAK, undocumented compatible.

Sorry, I should add what kind of document about this compatible?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

You cannot add new compatibles without documenting them. Documentation is in the form of DT schema and each compatible must be listed (in some
way) in compatible property description.

Sorry, do you mean, I add following in yaml or commit message?

You need to list this in compatibles first.

I will add it in compatible in next submit.

	enum:
		-aspeed,ast2600-i2cv2
Quoted 8 lines
Quoted 3 lines

This series add AST2600 i2cv2 new register set driver. The i2cv2 driver is new

register set that have new clock divider option for more flexiable generation. And also have separate i2c controller and target register set for control, patch #2 is i2c controller driver only, patch #3 is add i2c target mode driver.

All this describes driver, not hardware.

Sorry, the cover letter description the register. I will add int in commit message.

-Add new clock divider option for more flexible and accurate clock rate generation -Add tCKHighMin timing to guarantee SCL high pulse width. -Add support dual pool buffer mode, split 32 bytes pool buffer of each device into 2 x 16 bytes for Tx and Rx individually.

(quoted diff) +0 -4
-Increase DMA buffer size to 4096 bytes and support byte alignment.
-Re-define the base address of BUS1 ~ BUS16 and Pool buffer.
-Re-define registers for separating controller and target mode control.
-Support 4 individual DMA buffers for controller Tx and Rx,

target Tx and Rx.

And following is new register set for package transfer sequence.

(quoted diff) +0 -3
-New Master operation mode:
 S -> Aw -> P
 S -> Aw -> TxD -> P
 S -> Ar -> RxD -> P
 S -> Aw -> RxD -> Sr -> Ar -> TxD -> P
-Bus SDA lock auto-release capability for new controller DMA command mode.
-Bus auto timeout for new controller/target DMA mode.

The following is two versus register layout.
Old:
{I2CD00}: Function Control Register
{I2CD04}: Clock and AC Timing Control Register {I2CD08}: Clock and AC Timing Control Register {I2CD0C}: Interrupt Control Register
{I2CD10}: Interrupt Status Register
{I2CD14}: Command/Status Register
{I2CD18}: Slave Device Address Register
{I2CD1C}: Pool Buffer Control Register
{I2CD20}: Transmit/Receive Byte Buffer Register {I2CD24}: DMA Mode Buffer Address Register
{I2CD28}: DMA Transfer Length Register
{I2CD2C}: Original DMA Mode Buffer Address Setting {I2CD30}: Original DMA Transfer Length Setting and Final Status

New Register mode
{I2CC00}: Master/Slave Function Control Register {I2CC04}: Master/Slave Clock and AC Timing Control Register {I2CC08}: Master/Slave Transmit/Receive Byte Buffer Register {I2CC0C}: Master/Slave Pool Buffer Control Register {I2CM10}: Master Interrupt Control Register {I2CM14}: Master Interrupt Status Register {I2CM18}: Master Command/Status Register
{I2CM1C}: Master DMA Buffer Length Register {I2CS20}: Slave~ Interrupt Control Register {I2CS24}: Slave~ Interrupt Status Register {I2CS28}: Slave~ Command/Status Register
{I2CS2C}: Slave~ DMA Buffer Length Register {I2CM30}: Master DMA Mode Tx Buffer Base Address

Quoted 8 lines

{I2CM34}: Master DMA Mode Rx Buffer Base Address
{I2CS38}: Slave~ DMA Mode Tx Buffer Base Address
{I2CS3C}: Slave~ DMA Mode Rx Buffer Base Address
{I2CS40}: Slave Device Address Register
{I2CM48}: Master DMA Length Status Register
{I2CS4C}: Slave DMA Length Status Register
{I2CC50}: Current DMA Operating Address Status
{I2CC54}: Current DMA Operating Length Status

I don't understand anything from that and how is this relevant to our discussion.

Quoted 11 lines
Quoted 11 lines
Quoted 4 lines

The legacy register layout is mix controller/target register control together.

The following is add more detail description about new register layout. And new feature set add for register.

Quoted 2 lines

-Add new clock divider option for more flexible and accurate clock rate

generation -Add tCKHighMin timing to guarantee SCL high pulse width.

Quoted 1 line

-Add support dual pool buffer mode, split 32 bytes pool buffer of each device

into 2 x 16 bytes for Tx and Rx individually.

Quoted 8 lines
Quoted 6 lines

Review

Quoted 4 lines
(quoted diff) +0 -4
-Increase DMA buffer size to 4096 bytes and support byte alignment.
-Re-define the base address of BUS1 ~ BUS16 and Pool buffer.
-Re-define registers for separating controller and target mode control.
-Support 4 individual DMA buffers for controller Tx and Rx, target Tx and Rx.

Does it mean hardware changed on AST2600?

No Hw change, it is different mode setting will have another mode register setting. Mode setting is in global register, I will add in next commit message

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

Quoted 7 lines

I2CG00: Device Master Mode Interrupt Status Register (I2CG0C[3]=1)
I2CG00: Device Master/Slave Mode Interrupt Status Register (I2CG0C[3]=0)
I2CG04: Device Slave Mode Interrupt Status Register
I2CG0C: Global Control Register
I2CG10: New Clock Divider Control Register (I2CG0C[1] = 1)

Quoted 5 lines
Quoted 3 lines

Or these are different devices
than aspeed,ast2600-i2c-bus? If this is not a different device, how one SoC can have two different flavors of same device in the same instance?

When global setting for new, will new register mapping, no setting will keep old register mapping.

I cannot parse this.

Best regards,
Krzysztof

author maintainer
#11 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 37 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 9 lines · Ryan Chen
Quoted 9 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 5 lines · Ryan Chen
Quoted 5 lines
Quoted 5 lines

aspeed,enable-byte:
Force i2c controller use byte mode transfer. the byte mode transfer will send i2c data each byte by byte, inlcude address

read/write.

Quoted 13 lines
Quoted 13 lines
Quoted 7 lines
Quoted 2 lines

Isn't this standard FIFO mode?

Yes, it is.

Quoted 2 lines

Why anyone would need to enable byte mode for given board?

By default, it is buffer-mode, for performance, I don't want user enable

byte-mode, it will increase CPU utilize.

Quoted 3 lines

But someone want to be force enable byte-mode, so I add properties.
https://patchwork.ozlabs.org/project/linux-aspeed/patch/202410070352
35 [email protected]/

Quoted 7 lines
Quoted 5 lines

I don't see the reason why this would be a board property.

I understood need for DMA because it is shared and only some of the controllers can use it. But why choice between buffer and FIFO depending on hardware?

By default, the I2C controller runs in buffer mode. Each i2c bus have 16bytes

buffer to transmit data.

Quoted 2 lines

Enabling byte mode will increases CPU utilization, so it is not recommended. However, some user might require forcing byte mode, so I added this

Quoted 7 lines

property to allow that.

You are not answering the question. I asked why the choice depends on hardware and you answer "user might required".

Do you understand that this is about hardware, not user choices?

The AST2600 I2C controller support 3 modes. 1. Byte mode, 2.buffer mode. 3.dma mode. Which Buffer vs byte mode. is buffer mode have 16 bytes buffer for each i2c transition. Byte mode is 1 by 1 transfer.
So, my original submit patch is only for buffer/dma mode selection in property. But someone in review feedback want to use byte mode, so I add byte mode property now. If not acceptable, I can keep buffer/dma two mode selection in property.

Quoted 162 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

+ may require a DTS to manually allocate which controller
+ can use

DMA mode.

Quoted 4 lines
(quoted diff) +4 -0
+      The "aspeed,enable-dma" property allows control of this.
+
+      In cases where one the hardware design results in a specific
+      controller handling a larger amount of data, a DTS would

likely

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
(quoted diff) +6 -0
+      enable DMA mode for that one controller.
+
+  aspeed,enable-byte:
+    type: boolean
+    description: |
+      I2C bus enable byte mode transfer.
Quoted 6 lines
Quoted 3 lines

No, either this is expressed as lack of dma mode property or if you have three modes, then rather some enum (aspeed,transfer-mode ?)

Thanks suggestion, I will using an enum property like aspeed,transfer-mode

instead.

Quoted 11 lines
Quoted 11 lines

Review

Quoted 7 lines
(quoted diff) +4 -0
+
+  aspeed,global-regs:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of i2c global register node.

For what? Same question as usual: do not repeat property name, but say what is this used for and what exactly it points to.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

s/i2c/I2C/ but then what is "I2C global register node"? This is how you call your device in datasheet?

I do descript in cover, should add into the yaml file ?

Again, cover letter does not matter. Your hardware must be explained

here.

Quoted 39 lines
Quoted 39 lines
Quoted 10 lines

Will add into commit.

Quoted 7 lines
Quoted 5 lines

aspeed,global-regs:
This global register is needed, global register is setting for new clock divide control, and new register set control.

So this means you implement clock controller via syscon?

No, it is just mode switch. It also explain in cover. I will add it in commit. The legacy register layout is mix controller/target register control together.

The following is add more detail description about new register layout. And new feature set add for register.

Quoted 27 lines
Quoted 26 lines
Quoted 20 lines
Quoted 10 lines
Quoted 10 lines

+
required:
- reg
- compatible
- clocks
- resets

Quoted 9 lines

Review

Quoted 7 lines
(quoted diff) +7 -0
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: aspeed,ast2600-i2cv2

NAK, undocumented compatible.

Quoted 1 line

Sorry, I should add what kind of document about this compatible?

You cannot add new compatibles without documenting them. Documentation is in the form of DT schema and each compatible must be listed (in some
way) in compatible property description.

Quoted 13 lines
Quoted 3 lines
Quoted 1 line

Sorry, do you mean, I add following in yaml or commit message?

You need to list this in compatibles first.

I will add it in compatible in next submit.

	enum:
		-aspeed,ast2600-i2cv2
Quoted 5 lines
Quoted 4 lines

This series add AST2600 i2cv2 new register set driver. The i2cv2 driver is new

register set that have new clock divider option for more flexiable

generation.

Quoted 7 lines
Quoted 5 lines

And also have separate i2c controller and target register set for control, patch
#2 is i2c controller driver only, patch #3 is add i2c target mode driver.

All this describes driver, not hardware.

Sorry, the cover letter description the register. I will add int in commit

message.

Quoted 53 lines

-Add new clock divider option for more flexible and accurate clock rate generation -Add tCKHighMin timing to guarantee SCL high pulse width. -Add support dual pool buffer mode, split 32 bytes pool buffer of each device into 2 x 16 bytes for Tx and Rx individually.

(quoted diff) +0 -4
-Increase DMA buffer size to 4096 bytes and support byte alignment.
-Re-define the base address of BUS1 ~ BUS16 and Pool buffer.
-Re-define registers for separating controller and target mode control.
-Support 4 individual DMA buffers for controller Tx and Rx, target Tx

and Rx.

And following is new register set for package transfer sequence. -New Master operation mode:
S -> Aw -> P
S -> Aw -> TxD -> P
S -> Ar -> RxD -> P
S -> Aw -> RxD -> Sr -> Ar -> TxD -> P -Bus SDA lock auto-release
capability for new controller DMA command mode.
-Bus auto timeout for new controller/target DMA mode.

The following is two versus register layout.
Old:
{I2CD00}: Function Control Register
{I2CD04}: Clock and AC Timing Control Register {I2CD08}: Clock and AC Timing Control Register {I2CD0C}: Interrupt Control Register
{I2CD10}: Interrupt Status Register
{I2CD14}: Command/Status Register
{I2CD18}: Slave Device Address Register
{I2CD1C}: Pool Buffer Control Register
{I2CD20}: Transmit/Receive Byte Buffer Register {I2CD24}: DMA Mode Buffer Address Register
{I2CD28}: DMA Transfer Length Register
{I2CD2C}: Original DMA Mode Buffer Address Setting {I2CD30}: Original DMA Transfer Length Setting and Final Status

New Register mode
{I2CC00}: Master/Slave Function Control Register {I2CC04}: Master/Slave Clock and AC Timing Control Register {I2CC08}: Master/Slave Transmit/Receive Byte Buffer Register {I2CC0C}: Master/Slave Pool Buffer Control Register {I2CM10}: Master Interrupt Control Register {I2CM14}: Master Interrupt Status Register {I2CM18}: Master Command/Status Register
{I2CM1C}: Master DMA Buffer Length Register {I2CS20}: Slave~ Interrupt Control Register {I2CS24}: Slave~ Interrupt Status Register {I2CS28}: Slave~ Command/Status Register
{I2CS2C}: Slave~ DMA Buffer Length Register {I2CM30}: Master DMA Mode Tx Buffer Base Address {I2CM34}: Master DMA Mode Rx Buffer Base Address {I2CS38}: Slave~ DMA Mode Tx Buffer Base Address {I2CS3C}: Slave~ DMA Mode Rx Buffer Base Address

Quoted 8 lines
Quoted 5 lines

{I2CS40}: Slave Device Address Register
{I2CM48}: Master DMA Length Status Register
{I2CS4C}: Slave DMA Length Status Register
{I2CC50}: Current DMA Operating Address Status
{I2CC54}: Current DMA Operating Length Status

I don't understand anything from that and how is this relevant to our discussion.

Sorry, I don't catch your wanted.
I assume you want to know new mode register set compare original register set.

Quoted 25 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

The legacy register layout is mix controller/target register control together.

The following is add more detail description about new register layout. And new feature set add for register.

Quoted 3 lines

-Add new clock divider option for more flexible and accurate clock rate

Quoted 8 lines
Quoted 8 lines

generation -Add tCKHighMin timing to guarantee SCL high pulse width.

Quoted 2 lines

-Add support dual pool buffer mode, split 32 bytes pool buffer of each device

into 2 x 16 bytes for Tx and Rx individually.

Review

Quoted 4 lines
(quoted diff) +0 -4
-Increase DMA buffer size to 4096 bytes and support byte alignment.
-Re-define the base address of BUS1 ~ BUS16 and Pool buffer.
-Re-define registers for separating controller and target mode control.
-Support 4 individual DMA buffers for controller Tx and Rx, target Tx and

Rx.

Quoted 3 lines
Quoted 2 lines

Does it mean hardware changed on AST2600?

No Hw change, it is different mode setting will have another mode register

setting.

Quoted 1 line

Mode setting is in global register, I will add in next commit message

Quoted 8 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

OK, for ast2600 i2c controller have two register mode setting.
One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register that can set i2c controller as new mode register set.
That I am going to drive. That I post is all register in new an old register list.

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

Quoted 23 lines
Quoted 10 lines

I2CG00: Device Master Mode Interrupt Status Register (I2CG0C[3]=1)
I2CG00: Device Master/Slave Mode Interrupt Status Register (I2CG0C[3]=0)
I2CG04: Device Slave Mode Interrupt Status Register
I2CG0C: Global Control Register
I2CG10: New Clock Divider Control Register (I2CG0C[1] = 1)

Quoted 5 lines
Quoted 3 lines

Or these are different devices
than aspeed,ast2600-i2c-bus? If this is not a different device, how one SoC can have two different flavors of same device in the same instance?

When global setting for new, will new register mapping, no setting will keep

old register mapping.

I cannot parse this.

Best regards,
Krzysztof

#12 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 9 lines · Ryan Chen
Quoted 8 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

Quoted 8 lines

OK, for ast2600 i2c controller have two register mode setting.
One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register that can set i2c controller as new mode register set.
That I am going to drive. That I post is all register in new an old register list.

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Best regards,
Krzysztof

author maintainer
#13 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 16 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 6 lines · Ryan Chen
Quoted 6 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

Quoted 6 lines
Quoted 2 lines

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

OK, for ast2600 i2c controller have two register mode setting. One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register

Quoted 7 lines

that can set i2c controller as new mode register set.

Quoted 5 lines

That I am going to drive. That I post is all register in new an old register list.

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Sorry, it is different design, and it share the same register space. So that the reason add new compatible "aspeed,ast2600-i2cv2" for this driver. It is different register layout.

Quoted 3 lines

Best regards,
Krzysztof

#14 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 19 lines · Ryan Chen
Quoted 19 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 6 lines · Ryan Chen
Quoted 6 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

Quoted 6 lines
Quoted 2 lines

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

OK, for ast2600 i2c controller have two register mode setting. One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register

that can set i2c controller as new mode register set.

Quoted 2 lines

That I am going to drive. That I post is all register in new an old register list.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Sorry, it is different design, and it share the same register space. So that the reason add new compatible "aspeed,ast2600-i2cv2" for this driver. It is different register layout.

Which device is described by the existing "aspeed,ast2600-i2c-bus" compatible? And which device is described by new compatible?

Best regards,
Krzysztof

author maintainer
#15 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 30 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 13 lines · Ryan Chen
Quoted 13 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 9 lines · Ryan Chen
Quoted 8 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

OK, for ast2600 i2c controller have two register mode setting. One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register

that can set i2c controller as new mode register set.

Quoted 1 line

That I am going to drive. That I post is all register in new an old register

list.

Quoted 6 lines
Quoted 5 lines
Quoted 4 lines

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Quoted 8 lines
Quoted 2 lines

Sorry, it is different design, and it share the same register space. So that the reason add new compatible "aspeed,ast2600-i2cv2" for this

driver.

Quoted 1 line

It is different register layout.

Which device is described by the existing "aspeed,ast2600-i2c-bus" compatible? And which device is described by new compatible?

On the AST2600 SoC, there are up to 16 I2C controller instances (I2C1 ~ I2C16).
Each of these controllers is hardwired at the SoC level to use either the legacy register layout or the new v2 register layout. The mode is selected by a bit in the global register, these represent two different hardware blocks:
"aspeed,ast2600-i2c-bus" describes controllers using the legacy register layout.
"aspeed,ast2600-i2cv2" describes controllers using the new register layout

Quoted 4 lines

Best regards,
Krzysztof

#16 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 32 lines · Ryan Chen
Quoted 32 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 13 lines · Ryan Chen
Quoted 13 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 9 lines · Ryan Chen
Quoted 8 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

OK, for ast2600 i2c controller have two register mode setting. One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register

that can set i2c controller as new mode register set.

Quoted 1 line

That I am going to drive. That I post is all register in new an old register

list.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Sorry, it is different design, and it share the same register space. So that the reason add new compatible "aspeed,ast2600-i2cv2" for this

Quoted 7 lines
Quoted 6 lines

driver.

Quoted 1 line

It is different register layout.

Which device is described by the existing "aspeed,ast2600-i2c-bus" compatible? And which device is described by new compatible?

On the AST2600 SoC, there are up to 16 I2C controller instances (I2C1 ~ I2C16).

So you have 16 same devices.

Quoted 4 lines

Each of these controllers is hardwired at the SoC level to use either the legacy register layout or the new v2 register layout. The mode is selected by a bit in the global register, these represent two different hardware blocks:
"aspeed,ast2600-i2c-bus" describes controllers using the legacy register layout.
"aspeed,ast2600-i2cv2" describes controllers using the new register layout

Which part of "same device" is not clear? You have one device, one compatible. Whatever you do with register layout, is already defined by that compatible. It does not matter that you forgot to implement it in the Linux kernel.

Best regards,
Krzysztof

author maintainer
#17 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 41 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 37 lines · Ryan Chen
Quoted 37 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 13 lines · Ryan Chen
Quoted 13 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 9 lines · Ryan Chen
Quoted 8 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

OK, for ast2600 i2c controller have two register mode setting. One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register

that can set i2c controller as new mode register set.

Quoted 2 lines

That I am going to drive. That I post is all register in new an old register

list.

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Sorry, it is different design, and it share the same register space. So that the reason add new compatible "aspeed,ast2600-i2cv2" for this

driver.

Quoted 1 line

It is different register layout.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

Which device is described by the existing "aspeed,ast2600-i2c-bus" compatible? And which device is described by new compatible?

On the AST2600 SoC, there are up to 16 I2C controller instances (I2C1 ~

I2C16).

So you have 16 same devices.

Yes, one driver instance for 16 i2c device.

Quoted 5 lines
Quoted 2 lines

Each of these controllers is hardwired at the SoC level to use either the

legacy register layout or the new v2 register layout.

Quoted 1 line

The mode is selected by a bit in the global register, these represent two

different hardware blocks:

Quoted 8 lines
Quoted 1 line

"aspeed,ast2600-i2c-bus" describes controllers using the legacy register

layout.

Quoted 2 lines

"aspeed,ast2600-i2cv2" describes controllers using the new register layout

Which part of "same device" is not clear? You have one device, one compatible. Whatever you do with register layout, is already defined by that compatible. It does not matter that you forgot to implement it in the Linux kernel.

Sorry, I still can't catch your point.
I separated the support into two drivers:
i2c-aspeed.c for legacy layout, compatible "aspeed,ast2600-i2c-bus" i2c-ast2600.c for the new register set, compatible compatible "aspeed,ast2600-i2cv2" Do you mean I have integrate into 1 driver at i2c-aspeed.c ? can't be separate two driver?

Quoted 3 lines

Best regards,
Krzysztof

#18 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 56 lines · Ryan Chen
Quoted 41 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 37 lines · Ryan Chen
Quoted 37 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 13 lines · Ryan Chen
Quoted 13 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 9 lines · Ryan Chen
Quoted 8 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

OK, for ast2600 i2c controller have two register mode setting. One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register

that can set i2c controller as new mode register set.

Quoted 2 lines

That I am going to drive. That I post is all register in new an old register

list.

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Sorry, it is different design, and it share the same register space. So that the reason add new compatible "aspeed,ast2600-i2cv2" for this

driver.

Quoted 1 line

It is different register layout.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

Which device is described by the existing "aspeed,ast2600-i2c-bus" compatible? And which device is described by new compatible?

On the AST2600 SoC, there are up to 16 I2C controller instances (I2C1 ~

I2C16).

So you have 16 same devices.

Yes, one driver instance for 16 i2c device.

Quoted 7 lines
Quoted 2 lines

Each of these controllers is hardwired at the SoC level to use either the

legacy register layout or the new v2 register layout.

Quoted 1 line

The mode is selected by a bit in the global register, these represent two

different hardware blocks:

Quoted 1 line

"aspeed,ast2600-i2c-bus" describes controllers using the legacy register

layout.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

"aspeed,ast2600-i2cv2" describes controllers using the new register layout

Which part of "same device" is not clear? You have one device, one compatible. Whatever you do with register layout, is already defined by that compatible. It does not matter that you forgot to implement it in the Linux kernel.

Sorry, I still can't catch your point.

I repeated twice "You have one device, one compatible.", provided few more sentences and if this is still unclear, I don't know what to say more.

Quoted 1 line

I separated the support into two drivers:

I don't care about your drivers, why are you bringing them here?

Quoted 3 lines

i2c-aspeed.c for legacy layout, compatible "aspeed,ast2600-i2c-bus" i2c-ast2600.c for the new register set, compatible compatible "aspeed,ast2600-i2cv2" Do you mean I have integrate into 1 driver at i2c-aspeed.c ? can't be separate two driver?

What is this patch about? Bindings. Not drivers. Look at email month ago:

"All this describes driver, not hardware."

Why are you keep bringing here drivers since a month?

Best regards,
Krzysztof

author maintainer
#19 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 87 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 45 lines · Ryan Chen
Quoted 45 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 41 lines · Ryan Chen
Quoted 41 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 14 lines · Ryan Chen
Quoted 14 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for
AST2600-i2cv2

Quoted 9 lines · Ryan Chen
Quoted 8 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

OK, for ast2600 i2c controller have two register mode setting. One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register

that can set i2c controller as new mode register set.

Quoted 2 lines

That I am going to drive. That I post is all register in new an old register

list.

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Sorry, it is different design, and it share the same register space. So that the reason add new compatible "aspeed,ast2600-i2cv2" for this

driver.

Quoted 1 line

It is different register layout.

Which device is described by the existing "aspeed,ast2600-i2c-bus" compatible? And which device is described by new compatible?

Quoted 20 lines
Quoted 5 lines
Quoted 2 lines

On the AST2600 SoC, there are up to 16 I2C controller instances (I2C1 ~

I2C16).

So you have 16 same devices.

Yes, one driver instance for 16 i2c device.

Quoted 14 lines
Quoted 3 lines

Each of these controllers is hardwired at the SoC level to use either the

legacy register layout or the new v2 register layout.

Quoted 2 lines

The mode is selected by a bit in the global register, these represent two

different hardware blocks:

Quoted 2 lines

"aspeed,ast2600-i2c-bus" describes controllers using the legacy register

layout.

Quoted 2 lines

"aspeed,ast2600-i2cv2" describes controllers using the new register layout

Which part of "same device" is not clear? You have one device, one

compatible.

Quoted 2 lines
Quoted 2 lines

Whatever you do with register layout, is already defined by that compatible. It does not matter that you forgot to implement it in the Linux

kernel.

Quoted 2 lines

Sorry, I still can't catch your point.

I repeated twice "You have one device, one compatible.", provided few more sentences and if this is still unclear, I don't know what to say more.

Quoted 1 line

I separated the support into two drivers:

I don't care about your drivers, why are you bringing them here?

Quoted 2 lines

i2c-aspeed.c for legacy layout, compatible "aspeed,ast2600-i2c-bus" i2c-ast2600.c for the new register set, compatible compatible

"aspeed,ast2600-i2cv2"

Quoted 8 lines
Quoted 1 line

Do you mean I have integrate into 1 driver at i2c-aspeed.c ? can't be

separate two driver?

What is this patch about? Bindings. Not drivers. Look at email month ago:

"All this describes driver, not hardware."

Why are you keep bringing here drivers since a month?

Let me try to rephrase the reasoning from a hardware point of view:

On AST2600, each I2C controller instance is functionally the same type of device (I2C controller),
but it can present two different and incompatible register layouts,
depending on a hardware-controlled configuration (via global register bits that are fixed in production SoCs).
The layouts are not backward-compatible:
Registers are at different offsets. Bit definitions differ.
The programming sequence is not the same.
Because of this incompatibility at the register level, software cannot handle both layouts in a generic way without explicit knowledge of which version is present. That’s why I proposed a new compatible string — to represent a hardware-visible difference in register interface, even though the logical function (I2C controller) is the same.

Quoted 3 lines

Best regards,
Krzysztof

#20 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 14 lines · Ryan Chen
Quoted 4 lines
Quoted 3 lines

i2c-aspeed.c for legacy layout, compatible "aspeed,ast2600-i2c-bus" i2c-ast2600.c for the new register set, compatible compatible

"aspeed,ast2600-i2cv2"

Quoted 8 lines
Quoted 1 line

Do you mean I have integrate into 1 driver at i2c-aspeed.c ? can't be

separate two driver?

What is this patch about? Bindings. Not drivers. Look at email month ago:

"All this describes driver, not hardware."

Why are you keep bringing here drivers since a month?

Let me try to rephrase the reasoning from a hardware point of view:

Quoted 8 lines

On AST2600, each I2C controller instance is functionally the same type of device (I2C controller),
but it can present two different and incompatible register layouts,
depending on a hardware-controlled configuration (via global register bits that are fixed in production SoCs).
The layouts are not backward-compatible:
Registers are at different offsets. Bit definitions differ.
The programming sequence is not the same.
Because of this incompatibility at the register level, software cannot handle both layouts in a generic way without explicit knowledge of which version is present. That’s why I proposed a new compatible string — to represent a hardware-visible difference in register interface, even though the logical function (I2C controller) is the same.

You implied software is set in stone and that's not true. You have a compatible which says to the software - this device has two programming interfaces, choose whatever you wish and work with that.

Different compatible would mean the device is different, it changes or you have compatibility issues.

NONE of these cases are here.

I am done with this topic, because explaining this and other trivialities to Aspeed takes way too much time, so last opinion:

Your compatible already expressed that there are two interfaces, so your drivers can just choose whichever they want. If you need to toggle a bit in system controller, it is fine. If you need different compatible, then that's a NAK.

Best regards,
Krzysztof

#21 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Hi Ryan & Krzysztof,

[my response is intended to make progress on the newer v18 submission, but we still have this item from v16 to resolve, hence picking up this thread]

Quoted 4 lines

Your compatible already expressed that there are two interfaces, so your drivers can just choose whichever they want. If you need to toggle a bit in system controller, it is fine. If you need different compatible, then that's a NAK.

I think the mention of "two register interfaces" is a bit misleading here; it implies that it's just two interfaces to the same hardware.

From reading between the lines on the datasheet, it seems that this is two completely separate IP cores, that:

* are mapped to the same MMIO space; but
* both happen to be I2C controllers.

- where the single "global register" (which you mention above) provides the facility to mux the MMIO mapping between the two. Some versions of the overall SoC have only the old core, some have only the new, and some have both, selectable via this register.

Ryan, can you confirm whether this is the case?

Given there are actual behavioural differences between the two peripherals - beyond just the register set - that would seem to indicate separate binding types (+ a syscon mux control) to me, but I'm keen to hear any other options.

Krzysztof, if that is the case, any thoughts on the representation of separate bindings?

Cheers,

Jeremy

#22 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 10 lines · Jeremy Kerr

Hi Ryan & Krzysztof,

[my response is intended to make progress on the newer v18 submission, but we still have this item from v16 to resolve, hence picking up this thread]

Quoted 4 lines

Your compatible already expressed that there are two interfaces, so your drivers can just choose whichever they want. If you need to toggle a bit in system controller, it is fine. If you need different compatible, then that's a NAK.

You trimmed response and brought some very old thread which does not exist in my inbox.

I have absolutely no clue what this refers to.

Quoted 17 lines

I think the mention of "two register interfaces" is a bit misleading here; it implies that it's just two interfaces to the same hardware.

From reading between the lines on the datasheet, it seems that this is two completely separate IP cores, that:

* are mapped to the same MMIO space; but
* both happen to be I2C controllers.

- where the single "global register" (which you mention above) provides the facility to mux the MMIO mapping between the two. Some versions of the overall SoC have only the old core, some have only the new, and some have both, selectable via this register.

Ryan, can you confirm whether this is the case?

Quoted 7 lines

Given there are actual behavioural differences between the two peripherals - beyond just the register set - that would seem to indicate separate binding types (+ a syscon mux control) to me, but I'm keen to hear any other options.

Krzysztof, if that is the case, any thoughts on the representation of separate bindings?

I have no clue what is this about.

Best regards,
Krzysztof

#23 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Hi Krzysztof,

Quoted 4 lines

You trimmed response and brought some very old thread which does not exist in my inbox.

I have absolutely no clue what this refers to.

OK, reconstructing the relevant parts of that thread - Ryan providing background on the old/new register interfaces (trimmed a little for brevity; original context at [1] if you need):

Quoted 48 lines · Ryan Chen
Quoted 29 lines
Quoted 29 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 25 lines · Ryan Chen
Quoted 24 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 16 lines · Ryan Chen
Quoted 8 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

OK, for ast2600 i2c controller have two register mode setting. One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register that can set i2c controller as new mode register set. That I am going to drive. That I post is all register in new an old register list.

Quoted 3 lines

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Sorry, it is different design, and it share the same register space. So that the reason add new compatible "aspeed,ast2600-i2cv2" for this driver. It is different register layout.

Which device is described by the existing "aspeed,ast2600-i2c-bus" compatible? And which device is described by new compatible?

On the AST2600 SoC, there are up to 16 I2C controller instances (I2C1 ~ I2C16).

So you have 16 same devices.

Quoted 6 lines

Each of these controllers is hardwired at the SoC level to use either the legacy register layout or the new v2 register layout. The mode is selected by a bit in the global register, these represent two different hardware blocks: "aspeed,ast2600-i2c-bus" describes controllers using the legacy register layout. "aspeed,ast2600-i2cv2" describes controllers using the new register layout

Quoted 4 lines

Which part of "same device" is not clear? You have one device, one compatible. Whatever you do with register layout, is already defined by that compatible. It does not matter that you forgot to implement it in the Linux kernel.

So, I'm trying to pick up (from Ryan) on whether we're actually dealing with separate devices here; that was ambiguous in his responses.

To me, it seems like we do have separate IP cores, just multiplexed to the same MMIO space. And if so, what the preference on binding implementation is, particularly with different SoCs having either only the "old", only the "new", or a switchable set of both.

Hence my query:

Quoted 7 lines

Given there are actual behavioural differences between the two peripherals - beyond just the register set - that would seem to indicate separate binding types (+ a syscon mux control) to me, but I'm keen to hear any other options.

Krzysztof, if that is the case, any thoughts on the representation of separate bindings?

- given we may not be dealing with "the same device" in actual hardware, in reference to Ryan's proposed compatible split between the two.

Cheers,

Jeremy

[1]: https://lore.kernel.org/all/[email protected]/t/#u

author maintainer
#24 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 63 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Hi Krzysztof,

Quoted 4 lines

You trimmed response and brought some very old thread which does not exist in my inbox.

I have absolutely no clue what this refers to.

OK, reconstructing the relevant parts of that thread - Ryan providing background on the old/new register interfaces (trimmed a little for brevity; original context at [1] if you need):

Quoted 30 lines · Ryan Chen
Quoted 29 lines
Quoted 29 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 25 lines · Ryan Chen
Quoted 24 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 16 lines · Ryan Chen
Quoted 8 lines

Neither this.

So it seems you describe already existing and documented I2C, but for some reason you want second compatible. The problem is that you do not provide reason from the point of view of bindings.

To summarize: what your users want - don't care. Start properly describing hardware and your SoC.

OK, for ast2600 i2c controller have two register mode setting. One, I call it is old register setting, that is right now i2c-aspeed.c .compatible = "aspeed,ast2600-i2c-bus", And there have a global register that can set i2c controller as new mode register set. That I am going to drive. That I post is all register in new an old register list.

Quoted 3 lines

For example,
Global register [2] = 0 => i2c present as old register set Global register [2] = 1 => i2c present as new register set

It's the same device though, so the same compatible.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Sorry, it is different design, and it share the same register space. So that the reason add new compatible "aspeed,ast2600-i2cv2" for this driver. It is different register layout.

Which device is described by the existing "aspeed,ast2600-i2c-bus" compatible? And which device is described by new compatible?

On the AST2600 SoC, there are up to 16 I2C controller instances (I2C1 ~

I2C16).

Quoted 10 lines

So you have 16 same devices.

Quoted 6 lines

Each of these controllers is hardwired at the SoC level to use either the legacy register layout or the new v2 register layout. The mode is selected by a bit in the global register, these represent two different hardware blocks: "aspeed,ast2600-i2c-bus" describes controllers using the legacy register layout. "aspeed,ast2600-i2cv2" describes controllers using the new register layout

Quoted 7 lines
Quoted 4 lines

Which part of "same device" is not clear? You have one device, one compatible. Whatever you do with register layout, is already defined by that compatible. It does not matter that you forgot to implement it in the Linux kernel.

So, I'm trying to pick up (from Ryan) on whether we're actually dealing with separate devices here; that was ambiguous in his responses.

Hello Jeremy, Krzysztof

Sorry, for ambiguous.
The global register like a mux selection for new/old register layout. Like following example.

						=======================
						Driver : compatible = "aspeed,ast2600-i2c-bus"
						Old register layout : i2c0 ~ 15
						=======================
					0:/

==================
aspeed,global-regs
Global MUX (new/old)
==================

					1:\
						=======================
						Driver: compatible = "aspeed,ast2600-i2cv2-bus "
						New register layout : i2c0 ~ 15
						=======================
Quoted 27 lines

To me, it seems like we do have separate IP cores, just multiplexed to the same MMIO space. And if so, what the preference on binding implementation is, particularly with different SoCs having either only the "old", only the "new", or a switchable set of both.

Hence my query:

Quoted 7 lines

Given there are actual behavioural differences between the two peripherals - beyond just the register set - that would seem to indicate separate binding types (+ a syscon mux control) to me, but I'm keen to hear any other options.

Krzysztof, if that is the case, any thoughts on the representation of separate bindings?

- given we may not be dealing with "the same device" in actual hardware, in reference to Ryan's proposed compatible split between the two.

Cheers,

Jeremy

[1]:
https://lore.kernel.org/all/20250224055936.1804279-2-ryan_chen@aspeedtec
h.com/t/#u

#25 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Hi Ryan,

Quoted 3 lines

Sorry, for ambiguous.
The global register like a mux selection for new/old register layout. Like following example.

That wasn't the ambiguous part - I think we are clear that there is a multiplexer that controls what registers appear at the node's bus address.

The question was more: it sounds like you're switching between *fundamentally different* hardware units with the mux switch - not just a different register interface for the same peripheral hardware. Is that the case?

This is an important distinction in that some SoCs have the old peripheral, some have the new, and some have the mux-switching between both.

Behaviour of those two peripheral options differs beyond just a "register interface", and calling it just a change in register layout is misguiding the conversation somewhat.

If that's the case, then the separate compatible values may make more sense.

Cheers,

Jeremy

#26 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Hi all,

After a bit of a chat with Ryan, some updates on this:

Quoted 4 lines

The question was more: it sounds like you're switching between *fundamentally different* hardware units with the mux switch - not just a different register interface for the same peripheral hardware. Is that the case?

Turns out: no. The controller core is the same, but what gets muxed in/out is more of a compatibility interface. This provides an ast2500-like register set to the ast2600 i2c peripheral.

So, the plan to use the same aspeed,ast2600-i2c-bus binding for the controllers (ie, as in v18) seems mostly sensible to me.

The newly-introduced driver can make use of the non-compat interface to the peripheral (using the existing compatible value), but needs the introduction of support for the global register set to do so. Ideally, this would have been included on the original spec for the aspeed,ast2600-i2c-bus binding (since that's how the hardware is laid out), but that wasn't the case.

We may want to split the aspeed,ast2600-i2c-bus binding out from the existing spec, as we currently have:

compatible:
enum:
- aspeed,ast2400-i2c-bus
- aspeed,ast2500-i2c-bus
- aspeed,ast2600-i2c-bus

- but the former two do not have a global register-set.

We may have better syscon-like options for handling that global register set, but that's more of a conversation for the v18 thread.

Cheers,

Jeremy

#27 lore raw

Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 4 lines · Jeremy Kerr

Hi all,

After a bit of a chat with Ryan, some updates on this:

Quoted 8 lines
Quoted 4 lines

The question was more: it sounds like you're switching between *fundamentally different* hardware units with the mux switch - not just a different register interface for the same peripheral hardware. Is that the case?

Turns out: no. The controller core is the same, but what gets muxed in/out is more of a compatibility interface. This provides an ast2500-like register set to the ast2600 i2c peripheral.

If you had two separate bindings, how would you represent it in DTS? Two device nodes, right? That's confusing, because there is only one device.

If the device can present or change its programming interface, it is still that device, so still one binding for it. And that device driver will handle both (or one) programming models.

I remember now the problem we talk about, but I don't get what exactly you want to solve/discuss. Anyway any discussion should be about newest patch, not something from February, so if you still have concerns please raise them at v18 (or whichever version is now).

Best regards,
Krzysztof

author maintainer
#28 lore raw

RE: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 25 lines

Subject: Re: [PATCH v16 1/3] dt-bindings: i2c: aspeed: support for AST2600-i2cv2

Quoted 4 lines · Jeremy Kerr

Hi all,

After a bit of a chat with Ryan, some updates on this:

Quoted 8 lines
Quoted 4 lines

The question was more: it sounds like you're switching between *fundamentally different* hardware units with the mux switch - not just a different register interface for the same peripheral hardware. Is that the case?

Turns out: no. The controller core is the same, but what gets muxed in/out is more of a compatibility interface. This provides an ast2500-like register set to the ast2600 i2c peripheral.

If you had two separate bindings, how would you represent it in DTS? Two device nodes, right? That's confusing, because there is only one device.

If the device can present or change its programming interface, it is still that device, so still one binding for it. And that device driver will handle both (or one) programming models.

Quoted 7 lines

I remember now the problem we talk about, but I don't get what exactly you want to solve/discuss. Anyway any discussion should be about newest patch, not something from February, so if you still have concerns please raise them at v18 (or whichever version is now).

Best regards,
Krzysztof

Hello Krzysztof,
Thanks a lot.
That I submitted with v18. (that add reason in commit why I add in yaml. So, let's back to v18 give me more feedback, that I can fulfill. Appreciate your help.
v18 https://lore.kernel.org/all/[email protected]/

Ryan

author maintainer
#29 lore raw

PATCH v16 2/3 i2c: aspeed: support AST2600 i2c new register mode driver

In reply to Ryan Chen

Add i2c new register mode driver to support AST2600 i2c new register mode. AST2600 i2c controller have legacy and new register mode. The new register mode have global register support 4 base clock for scl clock selection, and new clock divider mode. The new register mode have separate register set to control i2c controller and target. This patch is for i2c controller mode driver.

---
 drivers/i2c/busses/Kconfig       |   11 +
 drivers/i2c/busses/Makefile      |    1 +
 drivers/i2c/busses/i2c-ast2600.c | 1036 ++++++++++++++++++++++++++++++
 3 files changed, 1048 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ast2600.c
drivers/i2c/busses/Kconfig +11 -0
index fc438f445771..32d96d5c8f5d 100644
@@ -402,6 +402,17 @@ config I2C_ALTERA
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-altera.
 
+config I2C_AST2600
+	tristate "Aspeed I2C v2 Controller"
+	depends on ARCH_ASPEED || COMPILE_TEST
+	select I2C_SMBUS
+	help
+	  If you say yes to this option, support will be included for the
+	  Aspeed I2C controller with new register set.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-ast2600.
+
 config I2C_ASPEED
 	tristate "Aspeed I2C Controller"
 	depends on ARCH_ASPEED || COMPILE_TEST
drivers/i2c/busses/Makefile +1 -0
index 1c2a4510abe4..ebfc377687b1 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_I2C_ALTERA)	+= i2c-altera.o
 obj-$(CONFIG_I2C_AMD_MP2)	+= i2c-amd-mp2-pci.o i2c-amd-mp2-plat.o
 obj-$(CONFIG_I2C_AMD_ASF)	+= i2c-amd-asf-plat.o
 obj-$(CONFIG_I2C_ASPEED)	+= i2c-aspeed.o
+obj-$(CONFIG_I2C_AST2600)	+= i2c-ast2600.o
 obj-$(CONFIG_I2C_AT91)		+= i2c-at91.o
 i2c-at91-y			:= i2c-at91-core.o i2c-at91-master.o
 i2c-at91-$(CONFIG_I2C_AT91_SLAVE_EXPERIMENTAL)	+= i2c-at91-slave.o
drivers/i2c/busses/i2c-ast2600.c new file +1036 -0

1,036 lines not on this page · raw message

Signature · 1 line
2.34.1
#30 lore raw

Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 16 lines · Ryan Chen

Add i2c new register mode driver to support AST2600 i2c new register mode. AST2600 i2c controller have legacy and new register mode. The new register mode have global register support 4 base clock for scl clock selection, and new clock divider mode. The new register mode have separate register set to control i2c controller and target. This patch is for i2c controller mode driver.

---
 drivers/i2c/busses/Kconfig       |   11 +
 drivers/i2c/busses/Makefile      |    1 +
 drivers/i2c/busses/i2c-ast2600.c | 1036 ++++++++++++++++++++++++++++++
 3 files changed, 1048 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ast2600.c

[...]

Quoted 6 lines
drivers/i2c/busses/i2c-ast2600.c new file +0 -0
new file mode 100644
index 000000000000..bfac507693dd
@@ -0,0 +1,1036 @@

[...]

Quoted 11 lines
drivers/i2c/busses/i2c-ast2600.c new file +11 -0
+static int ast2600_i2c_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct ast2600_i2c_bus *i2c_bus;
+	struct resource *res;
+	u32 global_ctrl;
+	int ret;
+
+	i2c_bus = devm_kzalloc(dev, sizeof(*i2c_bus), GFP_KERNEL);
+	if (!i2c_bus)
+		return -ENOMEM;

drivers/i2c/busses/i2c-ast2600.c line 924

Quoted 10 lines
drivers/i2c/busses/i2c-ast2600.c new file +10 -0
+
+	i2c_bus->reg_base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(i2c_bus->reg_base))
+		return PTR_ERR(i2c_bus->reg_base);
+
+	i2c_bus->rst = devm_reset_control_get_shared(dev, NULL);
+	if (IS_ERR(i2c_bus->rst))
+		return dev_err_probe(dev, PTR_ERR(i2c_bus->rst), "Missing reset ctrl\n");
+
+	reset_control_deassert(i2c_bus->rst);

No reset_control_assert() in the error paths below? You could get that and simplify this by using devm_reset_control_get_shared_deasserted().

regards
Philipp

author maintainer
#31 lore raw

RE: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 45 lines

Subject: Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 16 lines · Ryan Chen

Add i2c new register mode driver to support AST2600 i2c new register mode. AST2600 i2c controller have legacy and new register mode. The new register mode have global register support 4 base clock for scl clock selection, and new clock divider mode. The new register mode have separate register set to control i2c controller and target. This patch is for i2c controller mode driver.

---
 drivers/i2c/busses/Kconfig       |   11 +
 drivers/i2c/busses/Makefile      |    1 +
 drivers/i2c/busses/i2c-ast2600.c | 1036
++++++++++++++++++++++++++++++
 3 files changed, 1048 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ast2600.c

[...]

Quoted 7 lines
drivers/i2c/busses/i2c-ast2600.c new file +0 -0
new file mode 100644
index 000000000000..bfac507693dd
@@ -0,0 +1,1036 @@

[...]

Quoted 16 lines
drivers/i2c/busses/i2c-ast2600.c new file +16 -0
+static int ast2600_i2c_probe(struct platform_device *pdev) {
+	struct device *dev = &pdev->dev;
+	struct ast2600_i2c_bus *i2c_bus;
+	struct resource *res;
+	u32 global_ctrl;
+	int ret;
+
+	i2c_bus = devm_kzalloc(dev, sizeof(*i2c_bus), GFP_KERNEL);
+	if (!i2c_bus)
+		return -ENOMEM;
+
+	i2c_bus->reg_base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(i2c_bus->reg_base))
+		return PTR_ERR(i2c_bus->reg_base);
+
+	i2c_bus->rst = devm_reset_control_get_shared(dev, NULL);
Quoted 9 lines

drivers/i2c/busses/i2c-ast2600.c line 924

Quoted 5 lines
drivers/i2c/busses/i2c-ast2600.c new file +5 -0
+	if (IS_ERR(i2c_bus->rst))
+		return dev_err_probe(dev, PTR_ERR(i2c_bus->rst), "Missing reset
+ctrl\n");
+
+	reset_control_deassert(i2c_bus->rst);

No reset_control_assert() in the error paths below? You could get that and simplify this by using devm_reset_control_get_shared_deasserted().

Sorry, devm_reset_control_get_shared_deasserted is new for me. Do you mean modify by following

i2c_bus->rst = devm_reset_control_get_shared_deasserted(dev, NULL); if (IS_ERR(i2c_bus->rst))

    return dev_err_probe(dev, PTR_ERR(i2c_bus->rst), "Missing reset ctrl\n");

- reset_control_deassert(i2c_bus->rst);

Quoted 2 lines

regards
Philipp

#32 lore raw

Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 67 lines · Ryan Chen
Quoted 55 lines

Subject: Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register
mode driver

Quoted 21 lines · Ryan Chen

Add i2c new register mode driver to support AST2600 i2c new register
mode. AST2600 i2c controller have legacy and new register mode. The
new register mode have global register support 4 base clock for scl
clock selection, and new clock divider mode. The new register mode
have separate register set to control i2c controller and target. This
patch is for i2c controller mode driver.

---

 drivers/i2c/busses/Kconfig       |   11 +
 drivers/i2c/busses/Makefile      |    1 +
 drivers/i2c/busses/i2c-ast2600.c | 1036
++++++++++++++++++++++++++++++
 3 files changed, 1048 insertions(+)

 create mode 100644 drivers/i2c/busses/i2c-ast2600.c

[...]

Quoted 7 lines
drivers/i2c/busses/i2c-ast2600.c new file +0 -0
new file mode 100644
index 000000000000..bfac507693dd
@@ -0,0 +1,1036 @@

[...]

Quoted 20 lines
drivers/i2c/busses/i2c-ast2600.c new file +8 -0
+static int ast2600_i2c_probe(struct platform_device *pdev) {
+	struct device *dev = &pdev->dev;
+	struct ast2600_i2c_bus *i2c_bus;
+	struct resource *res;
+	u32 global_ctrl;
+	int ret;
+
+	i2c_bus = devm_kzalloc(dev, sizeof(*i2c_bus),

GFP_KERNEL);

drivers/i2c/busses/i2c-ast2600.c new file +4 -0
+	if (!i2c_bus)
+		return -ENOMEM;
+
+	i2c_bus->reg_base = devm_platform_ioremap_resource(pdev,

0);

drivers/i2c/busses/i2c-ast2600.c new file +6 -0
+	if (IS_ERR(i2c_bus->reg_base))
+		return PTR_ERR(i2c_bus->reg_base);
+
+	i2c_bus->rst = devm_reset_control_get_shared(dev, NULL);
+	if (IS_ERR(i2c_bus->rst))
+		return dev_err_probe(dev, PTR_ERR(i2c_bus->rst),
Quoted 9 lines

drivers/i2c/busses/i2c-ast2600.c line 924

Quoted 4 lines

"Missing reset

drivers/i2c/busses/i2c-ast2600.c new file +3 -0
+ctrl\n");
+
+	reset_control_deassert(i2c_bus->rst);

No reset_control_assert() in the error paths below? You could get that and
simplify this by using devm_reset_control_get_shared_deasserted().

Sorry, devm_reset_control_get_shared_deasserted is new for me. Do you mean modify by following

Quoted 6 lines

i2c_bus->rst = devm_reset_control_get_shared_deasserted(dev, NULL); if (IS_ERR(i2c_bus->rst))
    return dev_err_probe(dev, PTR_ERR(i2c_bus->rst), "Missing reset ctrl\n");

- reset_control_deassert(i2c_bus->rst);

Yes see [1]. Remove the reset_control_assert() in ast2600_i2c_remove() as well.

[1] https://docs.kernel.org/driver-api/reset.html#c.devm_reset_control_get_shared_deasserted

regards
Philipp

#33 lore raw

Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

In reply to Ryan Chen
kernel test robot noticed the following build warnings:

Hi Ryan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on linus/master v6.14-rc4 next-20250227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ryan-Chen/dt-bindings-i2c-aspeed-support-for-AST2600-i2cv2/20250224-140221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link:    https://lore.kernel.org/r/20250224055936.1804279-3-ryan_chen%40aspeedtech.com
patch subject: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20250228/[email protected]/config)
compiler: mips-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250228/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/i2c/busses/i2c-ast2600.c: In function 'ast2600_i2c_recover_bus':

>> drivers/i2c/busses/i2c-ast2600.c:345:32: warning: unsigned conversion from 'int' to 'u8' {aka 'unsigned char'} changes value from '-145' to '111' [-Woverflow]
     345 |                         return -ETIMEDOUT;
         |                                ^

vim +345 drivers/i2c/busses/i2c-ast2600.c

315
316 static u8 ast2600_i2c_recover_bus(struct ast2600_i2c_bus *i2c_bus)
317 {
318 u32 state = readl(i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF);
319 int ret = 0;
320 u32 ctrl;
321 int r;
322
323 dev_dbg(i2c_bus->dev, "%d-bus recovery bus [%x]\n", i2c_bus->adap.nr, state);
324
325 ctrl = readl(i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL);
326
327 /* Disable controller */
328 writel(ctrl & ~(AST2600_I2CC_MASTER_EN | AST2600_I2CC_SLAVE_EN),
329 i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL);
330
331 writel(readl(i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL) | AST2600_I2CC_MASTER_EN,
332 i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL);
333
334 reinit_completion(&i2c_bus->cmd_complete);
335 i2c_bus->cmd_err = 0;
336
337 /* Check 0x14's SDA and SCL status */
338 state = readl(i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF);
339 if (!(state & AST2600_I2CC_SDA_LINE_STS) && (state & AST2600_I2CC_SCL_LINE_STS)) {
340 writel(AST2600_I2CM_RECOVER_CMD_EN, i2c_bus->reg_base + AST2600_I2CM_CMD_STS);
341 r = wait_for_completion_timeout(&i2c_bus->cmd_complete, i2c_bus->adap.timeout);
342 if (r == 0) {
343 dev_dbg(i2c_bus->dev, "recovery timed out\n");
344 writel(ctrl, i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL);

 > 345				return -ETIMEDOUT;

346 } else if (i2c_bus->cmd_err) {
347 dev_dbg(i2c_bus->dev, "recovery error\n");
348 ret = -EPROTO;
349 }
350 }
351
352 /* Recovery done */
353 state = readl(i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF);
354 if (state & AST2600_I2CC_BUS_BUSY_STS) {
355 dev_dbg(i2c_bus->dev, "Can't recover bus [%x]\n", state);
356 ret = -EPROTO;
357 }
358
359 /* restore original controller setting */
360 writel(ctrl, i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL);
361 return ret;
362 }
363

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#34 lore raw

Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 18 lines · kernel test robot

Hi Ryan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on linus/master v6.14-rc4 next-20250227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ryan-Chen/dt-bindings-i2c-aspeed-support-for-AST2600-i2cv2/20250224-140221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link:    https://lore.kernel.org/r/20250224055936.1804279-3-ryan_chen%40aspeedtech.com
patch subject: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20250228/[email protected]/config)
compiler: mips-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250228/[email protected]/reproduce)
Quoted 6 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

My gosh, this is valid report. But it looks like a preexisted issue. Can somebody fix this, please?

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

Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 24 lines · Andy Shevchenko
Quoted 23 lines · kernel test robot

Hi Ryan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on linus/master v6.14-rc4 next-20250227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ryan-Chen/dt-bindings-i2c-aspeed-support-for-AST2600-i2cv2/20250224-140221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link:    https://lore.kernel.org/r/20250224055936.1804279-3-ryan_chen%40aspeedtech.com
patch subject: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20250228/[email protected]/config)
compiler: mips-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250228/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 4 lines
Quoted 1 line

All warnings (new ones prefixed by >>):

My gosh, this is valid report. But it looks like a preexisted issue. Can somebody fix this, please?

That was three weeks ago and still no responses from Aspeed or contributors from here.

I think this tells a lot about aspeedtech.com patchsets on the list.

Best regards,
Krzysztof

#36 lore raw

Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 27 lines · Krzysztof Kozlowski
Quoted 26 lines · Andy Shevchenko
Quoted 24 lines · kernel test robot

Hi Ryan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on linus/master v6.14-rc4 next-20250227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ryan-Chen/dt-bindings-i2c-aspeed-support-for-AST2600-i2cv2/20250224-140221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link:    https://lore.kernel.org/r/20250224055936.1804279-3-ryan_chen%40aspeedtech.com
patch subject: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20250228/[email protected]/config)
compiler: mips-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250228/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

Quoted 8 lines
Quoted 2 lines

My gosh, this is valid report. But it looks like a preexisted issue. Can somebody fix this, please?

That was three weeks ago and still no responses from Aspeed or contributors from here.

I think this tells a lot about aspeedtech.com patchsets on the list.

Yeah...

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#37 lore raw

RE: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 17 lines

Subject: Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · kernel test robot

Hi Ryan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host] [also build test WARNING on linus/master v6.14-rc4 next-20250227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

Quoted 36 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

url:

https://github.com/intel-lab-lkp/linux/commits/Ryan-Chen/dt-bindings-i2c-asp
eed-support-for-AST2600-i2cv2/20250224-140221

Quoted 1 line
Quoted 1 line
Quoted 1 line

base:

https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host

Quoted 1 line
Quoted 1 line
Quoted 1 line

patch link:

https://lore.kernel.org/r/20250224055936.1804279-3-ryan_chen%40aspeedtec
h.com

Quoted 27 lines
Quoted 17 lines
Quoted 17 lines

patch subject: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver
config: mips-allyesconfig
(https://download.01.org/0day-ci/archive/20250228/202502280902.U0gL
[email protected]/config)
compiler: mips-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build):
(https://download.01.org/0day-ci/archive/20250228/202502280902.U0gL
[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Closes:
| https://lore.kernel.org/oe-kbuild-all/202502280902.U0gLDhve-lkp@i
| ntel.com/
Quoted 4 lines
Quoted 1 line

All warnings (new ones prefixed by >>):

My gosh, this is valid report. But it looks like a preexisted issue. Can somebody fix this, please?

That was three weeks ago and still no responses from Aspeed or contributors from here.

I think this tells a lot about aspeedtech.com patchsets on the list.

Sorry, I don't aware this is my patches issue, could you tell me what build instruction can reproduce this?

Quoted 6 lines

Yeah...

--
With Best Regards,
Andy Shevchenko

#38 lore raw

Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 48 lines · Ryan Chen
Quoted 48 lines

Subject: Re: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver

Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · kernel test robot

Hi Ryan,

kernel test robot noticed the following build warnings:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

[auto build test WARNING on andi-shyti/i2c/i2c-host] [also build test WARNING on linus/master v6.14-rc4 next-20250227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:

https://github.com/intel-lab-lkp/linux/commits/Ryan-Chen/dt-bindings-i2c-asp
eed-support-for-AST2600-i2cv2/20250224-140221

Quoted 1 line
Quoted 1 line
Quoted 1 line

base:

https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host

Quoted 1 line
Quoted 1 line
Quoted 1 line

patch link:

https://lore.kernel.org/r/20250224055936.1804279-3-ryan_chen%40aspeedtec
h.com

Quoted 23 lines
Quoted 21 lines
Quoted 10 lines

patch subject: [PATCH v16 2/3] i2c: aspeed: support AST2600 i2c new register mode driver
config: mips-allyesconfig
(https://download.01.org/0day-ci/archive/20250228/202502280902.U0gL
[email protected]/config)
compiler: mips-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build):
(https://download.01.org/0day-ci/archive/20250228/202502280902.U0gL
[email protected]/reproduce)

Quoted 8 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Closes:
| https://lore.kernel.org/oe-kbuild-all/202502280902.U0gLDhve-lkp@i
| ntel.com/

All warnings (new ones prefixed by >>):

My gosh, this is valid report. But it looks like a preexisted issue. Can somebody fix this, please?

Quoted 6 lines
Quoted 5 lines
Quoted 4 lines

That was three weeks ago and still no responses from Aspeed or contributors from here.

I think this tells a lot about aspeedtech.com patchsets on the list.

Sorry, I don't aware this is my patches issue, could you tell me what build instruction can reproduce this?

Everything is explained in the email. You do not need two people explaining the report, just read the report.

Best regards,
Krzysztof

author maintainer
#39 lore raw

PATCH v16 3/3 i2c: aspeed: support AST2600 i2c new register target mode driver

In reply to Ryan Chen

This patch is for i2c new register target mode driver.

---
 drivers/i2c/busses/i2c-ast2600.c | 569 +++++++++++++++++++++++++++++--
 1 file changed, 549 insertions(+), 20 deletions(-)
drivers/i2c/busses/i2c-ast2600.c +549 -20
index bfac507693dd..528575b25f1e 100644
@@ -81,6 +81,7 @@
 #define AST2600_I2CC_THDDAT(x)			(((x) & GENMASK(1, 0)) << 10)
 #define AST2600_I2CC_TOUTBASECLK(x)			(((x) & GENMASK(1, 0)) << 8)
 #define AST2600_I2CC_TBASECLK(x)			((x) & GENMASK(3, 0))
+#define AST2600_I2CC_AC_TIMING_MASK		GENMASK(23, 0)
 
 /* 0x08 : I2CC Controller/Target Transmit/Receive Byte Buffer Register */
 #define AST2600_I2CC_STS_AND_BUFF		0x08
@@ -255,7 +256,7 @@ struct ast2600_i2c_bus {
 	struct i2c_timings	timing_info;
 	struct completion	cmd_complete;
 	struct i2c_msg		*msgs;
-	u8			*controller_dma_safe_buf;
+	u8			*dma_safe_buf;
 	dma_addr_t		controller_dma_addr;
 	u32			apb_clk;
 	u32			timeout;
@@ -271,6 +272,13 @@ struct ast2600_i2c_bus {
 	/* Buffer mode */
 	void __iomem		*buf_base;
 	struct i2c_smbus_alert_setup	alert_data;
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+	/* target structure */
+	int			target_operate;
+	unsigned char	*target_dma_buf;
+	dma_addr_t		target_dma_addr;
+	struct i2c_client	*target;
+#endif
 };
 
 static u32 ast2600_select_i2c_clock(struct ast2600_i2c_bus *i2c_bus)
@@ -361,6 +369,395 @@ static u8 ast2600_i2c_recover_bus(struct ast2600_i2c_bus *i2c_bus)
 	return ret;
 }
 
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+static void ast2600_i2c_target_packet_dma_irq(struct ast2600_i2c_bus *i2c_bus, u32 sts)
+{
+	int target_rx_len = 0;
+	u32 cmd = 0;
+	u8 value;
+	int i;
+
+	sts &= ~(AST2600_I2CS_SLAVE_PENDING);
+	/* Handle i2c target timeout condition */
+	if (AST2600_I2CS_INACTIVE_TO & sts) {
+		cmd = TARGET_TRIGGER_CMD;
+		cmd |= AST2600_I2CS_RX_DMA_EN;
+		writel(AST2600_I2CS_SET_RX_DMA_LEN(I2C_TARGET_MSG_BUF_SIZE),
+		       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+		writel(cmd, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+		writel(AST2600_I2CS_PKT_DONE, i2c_bus->reg_base + AST2600_I2CS_ISR);
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		return;
+	}
+
+	sts &= ~(AST2600_I2CS_PKT_DONE | AST2600_I2CS_PKT_ERROR);
+
+	switch (sts) {
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE | AST2600_I2CS_WAIT_RX_DMA:
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_WAIT_RX_DMA:
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_REQUESTED, &value);
+		target_rx_len = AST2600_I2C_GET_RX_DMA_LEN(readl(i2c_bus->reg_base +
+						      AST2600_I2CS_DMA_LEN_STS));
+		for (i = 0; i < target_rx_len; i++) {
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED,
+					&i2c_bus->target_dma_buf[i]);
+		}
+		writel(AST2600_I2CS_SET_RX_DMA_LEN(I2C_TARGET_MSG_BUF_SIZE),
+		       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_RX_DMA_EN;
+		break;
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_STOP:
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		writel(AST2600_I2CS_SET_RX_DMA_LEN(I2C_TARGET_MSG_BUF_SIZE),
+		       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_RX_DMA_EN;
+		break;
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE_NAK |
+			AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_WAIT_RX_DMA |
+			AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+	case AST2600_I2CS_RX_DONE_NAK | AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+	case AST2600_I2CS_RX_DONE | AST2600_I2CS_WAIT_RX_DMA | AST2600_I2CS_STOP:
+	case AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+	case AST2600_I2CS_RX_DONE | AST2600_I2CS_WAIT_RX_DMA:
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+		if (sts & AST2600_I2CS_SLAVE_MATCH)
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_REQUESTED, &value);
+
+		target_rx_len = AST2600_I2C_GET_RX_DMA_LEN(readl(i2c_bus->reg_base +
+						      AST2600_I2CS_DMA_LEN_STS));
+		for (i = 0; i < target_rx_len; i++) {
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED,
+					&i2c_bus->target_dma_buf[i]);
+		}
+		writel(AST2600_I2CS_SET_RX_DMA_LEN(I2C_TARGET_MSG_BUF_SIZE),
+		       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+		if (sts & AST2600_I2CS_STOP)
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_RX_DMA_EN;
+		break;
+
+	/* it is Mw data Mr coming -> it need send tx */
+	case AST2600_I2CS_RX_DONE | AST2600_I2CS_WAIT_TX_DMA:
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE | AST2600_I2CS_WAIT_TX_DMA:
+		/* it should be repeat start read */
+		if (sts & AST2600_I2CS_SLAVE_MATCH)
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_REQUESTED, &value);
+
+		target_rx_len = AST2600_I2C_GET_RX_DMA_LEN(readl(i2c_bus->reg_base +
+						      AST2600_I2CS_DMA_LEN_STS));
+		for (i = 0; i < target_rx_len; i++) {
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED,
+					&i2c_bus->target_dma_buf[i]);
+		}
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_READ_REQUESTED,
+				&i2c_bus->target_dma_buf[0]);
+		writel(0, i2c_bus->reg_base + AST2600_I2CS_DMA_LEN_STS);
+		writel(AST2600_I2CS_SET_TX_DMA_LEN(1),
+		       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_TX_DMA_EN;
+		break;
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_WAIT_TX_DMA:
+		/* First Start read */
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_READ_REQUESTED,
+				&i2c_bus->target_dma_buf[0]);
+		writel(AST2600_I2CS_SET_TX_DMA_LEN(1),
+		       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_TX_DMA_EN;
+		break;
+	case AST2600_I2CS_WAIT_TX_DMA:
+		/* it should be next start read */
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_READ_PROCESSED,
+				&i2c_bus->target_dma_buf[0]);
+		writel(0, i2c_bus->reg_base + AST2600_I2CS_DMA_LEN_STS);
+		writel(AST2600_I2CS_SET_TX_DMA_LEN(1),
+		       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_TX_DMA_EN;
+		break;
+	case AST2600_I2CS_TX_NAK | AST2600_I2CS_STOP:
+		/* it just tx complete */
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		writel(0, i2c_bus->reg_base + AST2600_I2CS_DMA_LEN_STS);
+		writel(AST2600_I2CS_SET_RX_DMA_LEN(I2C_TARGET_MSG_BUF_SIZE),
+		       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_RX_DMA_EN;
+		break;
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE:
+		cmd = 0;
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_REQUESTED, &value);
+		break;
+	case AST2600_I2CS_STOP:
+		cmd = 0;
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		break;
+	default:
+		dev_dbg(i2c_bus->dev, "unhandled target isr case %x, sts %x\n", sts,
+			readl(i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF));
+		break;
+	}
+
+	if (cmd)
+		writel(cmd, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+	writel(AST2600_I2CS_PKT_DONE, i2c_bus->reg_base + AST2600_I2CS_ISR);
+	readl(i2c_bus->reg_base + AST2600_I2CS_ISR);
+}
+
+static void ast2600_i2c_target_packet_buff_irq(struct ast2600_i2c_bus *i2c_bus, u32 sts)
+{
+	int target_rx_len = 0;
+	u32 cmd = 0;
+	u8 value;
+	int i;
+
+	/* due to controller target is common buffer, need force the master stop not issue */
+	if (readl(i2c_bus->reg_base + AST2600_I2CM_CMD_STS) & GENMASK(15, 0)) {
+		writel(0, i2c_bus->reg_base + AST2600_I2CM_CMD_STS);
+		i2c_bus->cmd_err = -EBUSY;
+		writel(0, i2c_bus->reg_base + AST2600_I2CC_BUFF_CTRL);
+		complete(&i2c_bus->cmd_complete);
+	}
+
+	/* Handle i2c target timeout condition */
+	if (AST2600_I2CS_INACTIVE_TO & sts) {
+		/* Reset timeout counter */
+		u32 ac_timing = readl(i2c_bus->reg_base + AST2600_I2CC_AC_TIMING) &
+				AST2600_I2CC_AC_TIMING_MASK;
+
+		writel(ac_timing, i2c_bus->reg_base + AST2600_I2CC_AC_TIMING);
+		ac_timing |= AST2600_I2CC_TTIMEOUT(i2c_bus->timeout);
+		writel(ac_timing, i2c_bus->reg_base + AST2600_I2CC_AC_TIMING);
+		writel(TARGET_TRIGGER_CMD, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+		writel(AST2600_I2CS_PKT_DONE, i2c_bus->reg_base + AST2600_I2CS_ISR);
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		i2c_bus->target_operate = 0;
+		return;
+	}
+
+	sts &= ~(AST2600_I2CS_PKT_DONE | AST2600_I2CS_PKT_ERROR);
+
+	if (sts & AST2600_I2CS_SLAVE_MATCH)
+		i2c_bus->target_operate = 1;
+
+	switch (sts) {
+	case AST2600_I2CS_SLAVE_PENDING | AST2600_I2CS_WAIT_RX_DMA |
+		 AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+	case AST2600_I2CS_SLAVE_PENDING |
+		 AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+	case AST2600_I2CS_SLAVE_PENDING |
+		 AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_STOP:
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		fallthrough;
+	case AST2600_I2CS_SLAVE_PENDING |
+		 AST2600_I2CS_WAIT_RX_DMA | AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE:
+	case AST2600_I2CS_WAIT_RX_DMA | AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE:
+	case AST2600_I2CS_WAIT_RX_DMA | AST2600_I2CS_SLAVE_MATCH:
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_REQUESTED, &value);
+		cmd = TARGET_TRIGGER_CMD;
+		if (sts & AST2600_I2CS_RX_DONE) {
+			target_rx_len = AST2600_I2CC_GET_RX_BUF_LEN(readl(i2c_bus->reg_base +
+							       AST2600_I2CC_BUFF_CTRL));
+			for (i = 0; i < target_rx_len; i++) {
+				value = readb(i2c_bus->buf_base + 0x10 + i);
+				i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED, &value);
+			}
+		}
+		if (readl(i2c_bus->reg_base + AST2600_I2CS_CMD_STS) & AST2600_I2CS_RX_BUFF_EN)
+			cmd = 0;
+		else
+			cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_RX_BUFF_EN;
+
+		writel(AST2600_I2CC_SET_RX_BUF_LEN(i2c_bus->buf_size),
+		       i2c_bus->reg_base + AST2600_I2CC_BUFF_CTRL);
+		break;
+	case AST2600_I2CS_WAIT_RX_DMA | AST2600_I2CS_RX_DONE:
+		cmd = TARGET_TRIGGER_CMD;
+		target_rx_len = AST2600_I2CC_GET_RX_BUF_LEN(readl(i2c_bus->reg_base +
+						       AST2600_I2CC_BUFF_CTRL));
+		for (i = 0; i < target_rx_len; i++) {
+			value = readb(i2c_bus->buf_base + 0x10 + i);
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED, &value);
+		}
+		cmd |= AST2600_I2CS_RX_BUFF_EN;
+		writel(AST2600_I2CC_SET_RX_BUF_LEN(i2c_bus->buf_size),
+		       i2c_bus->reg_base + AST2600_I2CC_BUFF_CTRL);
+		break;
+	case AST2600_I2CS_SLAVE_PENDING | AST2600_I2CS_WAIT_RX_DMA |
+				AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+		cmd = TARGET_TRIGGER_CMD;
+		target_rx_len = AST2600_I2CC_GET_RX_BUF_LEN(readl(i2c_bus->reg_base +
+								 AST2600_I2CC_BUFF_CTRL));
+		for (i = 0; i < target_rx_len; i++) {
+			value = readb(i2c_bus->buf_base + 0x10 + i);
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED, &value);
+		}
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		cmd |= AST2600_I2CS_RX_BUFF_EN;
+		writel(AST2600_I2CC_SET_RX_BUF_LEN(i2c_bus->buf_size),
+		       i2c_bus->reg_base + AST2600_I2CC_BUFF_CTRL);
+		break;
+	case AST2600_I2CS_SLAVE_PENDING | AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+		cmd = TARGET_TRIGGER_CMD;
+		target_rx_len = AST2600_I2CC_GET_RX_BUF_LEN(readl(i2c_bus->reg_base +
+								 AST2600_I2CC_BUFF_CTRL));
+		for (i = 0; i < target_rx_len; i++) {
+			value = readb(i2c_bus->buf_base + 0x10 + i);
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED, &value);
+		}
+		/* workaround for avoid next start with len != 0 */
+		writel(BIT(0), i2c_bus->reg_base + AST2600_I2CC_BUFF_CTRL);
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		break;
+	case AST2600_I2CS_RX_DONE | AST2600_I2CS_STOP:
+		cmd = TARGET_TRIGGER_CMD;
+		target_rx_len = AST2600_I2CC_GET_RX_BUF_LEN(readl(i2c_bus->reg_base +
+								 AST2600_I2CC_BUFF_CTRL));
+		for (i = 0; i < target_rx_len; i++) {
+			value = readb(i2c_bus->buf_base + 0x10 + i);
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED, &value);
+		}
+		/* workaround for avoid next start with len != 0 */
+		writel(BIT(0), i2c_bus->reg_base + AST2600_I2CC_BUFF_CTRL);
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		break;
+	case AST2600_I2CS_WAIT_TX_DMA | AST2600_I2CS_SLAVE_MATCH:
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_READ_REQUESTED, &value);
+		writeb(value, i2c_bus->buf_base);
+		writel(AST2600_I2CC_SET_TX_BUF_LEN(1),
+		       i2c_bus->reg_base + AST2600_I2CC_BUFF_CTRL);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_TX_BUFF_EN;
+		break;
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_WAIT_TX_DMA | AST2600_I2CS_RX_DONE:
+	case AST2600_I2CS_WAIT_TX_DMA | AST2600_I2CS_RX_DONE:
+	case AST2600_I2CS_WAIT_TX_DMA:
+		if (sts & AST2600_I2CS_SLAVE_MATCH)
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_REQUESTED, &value);
+
+		if (sts & AST2600_I2CS_RX_DONE) {
+			target_rx_len = AST2600_I2CC_GET_RX_BUF_LEN(readl(i2c_bus->reg_base +
+							AST2600_I2CC_BUFF_CTRL));
+			for (i = 0; i < target_rx_len; i++) {
+				value = readb(i2c_bus->buf_base + 0x10 + i);
+				i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED, &value);
+			}
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_READ_REQUESTED, &value);
+		} else {
+			i2c_slave_event(i2c_bus->target, I2C_SLAVE_READ_PROCESSED, &value);
+		}
+		writeb(value, i2c_bus->buf_base);
+		writel(AST2600_I2CC_SET_TX_BUF_LEN(1),
+		       i2c_bus->reg_base + AST2600_I2CC_BUFF_CTRL);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_TX_BUFF_EN;
+		break;
+	/* workaround : trigger the cmd twice to fix next state keep 1000000 */
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE:
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_REQUESTED, &value);
+		cmd = TARGET_TRIGGER_CMD | AST2600_I2CS_RX_BUFF_EN;
+		writel(cmd, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+		break;
+
+	case AST2600_I2CS_TX_NAK | AST2600_I2CS_STOP:
+	case AST2600_I2CS_STOP:
+		cmd = TARGET_TRIGGER_CMD;
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		break;
+	default:
+		dev_dbg(i2c_bus->dev, "unhandled target isr case %x, sts %x\n", sts,
+			readl(i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF));
+		break;
+	}
+
+	if (cmd)
+		writel(cmd, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+	writel(AST2600_I2CS_PKT_DONE, i2c_bus->reg_base + AST2600_I2CS_ISR);
+	readl(i2c_bus->reg_base + AST2600_I2CS_ISR);
+
+	if ((sts & AST2600_I2CS_STOP) && !(sts & AST2600_I2CS_SLAVE_PENDING))
+		i2c_bus->target_operate = 0;
+}
+
+static void ast2600_i2c_target_byte_irq(struct ast2600_i2c_bus *i2c_bus, u32 sts)
+{
+	u32 i2c_buff = readl(i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF);
+	u32 cmd = AST2600_I2CS_ACTIVE_ALL;
+	u8 byte_data;
+	u8 value;
+
+	switch (sts) {
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE | AST2600_I2CS_WAIT_RX_DMA:
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_REQUESTED, &value);
+		/* first address match is address */
+		byte_data = AST2600_I2CC_GET_RX_BUFF(i2c_buff);
+		break;
+	case AST2600_I2CS_RX_DONE | AST2600_I2CS_WAIT_RX_DMA:
+		byte_data = AST2600_I2CC_GET_RX_BUFF(i2c_buff);
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_WRITE_RECEIVED, &byte_data);
+		break;
+	case AST2600_I2CS_SLAVE_MATCH | AST2600_I2CS_RX_DONE | AST2600_I2CS_WAIT_TX_DMA:
+		cmd |= AST2600_I2CS_TX_CMD;
+		byte_data = AST2600_I2CC_GET_RX_BUFF(i2c_buff);
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_READ_REQUESTED, &byte_data);
+		writel(byte_data, i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF);
+		break;
+	case AST2600_I2CS_TX_ACK | AST2600_I2CS_WAIT_TX_DMA:
+		cmd |= AST2600_I2CS_TX_CMD;
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_READ_PROCESSED, &byte_data);
+		writel(byte_data, i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF);
+		break;
+	case AST2600_I2CS_STOP:
+	case AST2600_I2CS_STOP | AST2600_I2CS_TX_NAK:
+		i2c_slave_event(i2c_bus->target, I2C_SLAVE_STOP, &value);
+		break;
+	default:
+		dev_dbg(i2c_bus->dev, "unhandled pkt isr %x\n", sts);
+		break;
+	}
+	writel(cmd, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+	writel(sts, i2c_bus->reg_base + AST2600_I2CS_ISR);
+	readl(i2c_bus->reg_base + AST2600_I2CS_ISR);
+}
+
+static int ast2600_i2c_target_irq(struct ast2600_i2c_bus *i2c_bus)
+{
+	u32 ier = readl(i2c_bus->reg_base + AST2600_I2CS_IER);
+	u32 isr = readl(i2c_bus->reg_base + AST2600_I2CS_ISR);
+
+	if (!(isr & ier))
+		return 0;
+
+	/*
+	 * Target interrupt coming after Master package done
+	 * So need handle master first.
+	 */
+	if (readl(i2c_bus->reg_base + AST2600_I2CM_ISR) & AST2600_I2CM_PKT_DONE)
+		return 0;
+
+	isr &= ~(AST2600_I2CS_ADDR_INDICATE_MASK);
+
+	if (AST2600_I2CS_ADDR1_NAK & isr)
+		isr &= ~AST2600_I2CS_ADDR1_NAK;
+
+	if (AST2600_I2CS_ADDR2_NAK & isr)
+		isr &= ~AST2600_I2CS_ADDR2_NAK;
+
+	if (AST2600_I2CS_ADDR3_NAK & isr)
+		isr &= ~AST2600_I2CS_ADDR3_NAK;
+
+	if (AST2600_I2CS_ADDR_MASK & isr)
+		isr &= ~AST2600_I2CS_ADDR_MASK;
+
+	if (AST2600_I2CS_PKT_DONE & isr) {
+		if (i2c_bus->mode == DMA_MODE)
+			ast2600_i2c_target_packet_dma_irq(i2c_bus, isr);
+		else
+			ast2600_i2c_target_packet_buff_irq(i2c_bus, isr);
+	} else {
+		ast2600_i2c_target_byte_irq(i2c_bus, isr);
+	}
+
+	return 1;
+}
+#endif
+
 static int ast2600_i2c_setup_dma_tx(u32 cmd, struct ast2600_i2c_bus *i2c_bus)
 {
 	struct i2c_msg *msg = &i2c_bus->msgs[i2c_bus->msgs_index];
@@ -376,16 +773,16 @@ static int ast2600_i2c_setup_dma_tx(u32 cmd, struct ast2600_i2c_bus *i2c_bus)
 
 	if (cmd & AST2600_I2CM_START_CMD) {
 		cmd |= AST2600_I2CM_PKT_ADDR(msg->addr);
-		i2c_bus->controller_dma_safe_buf = i2c_get_dma_safe_msg_buf(msg, 1);
-		if (!i2c_bus->controller_dma_safe_buf)
+		i2c_bus->dma_safe_buf = i2c_get_dma_safe_msg_buf(msg, 1);
+		if (!i2c_bus->dma_safe_buf)
 			return -ENOMEM;
 		i2c_bus->controller_dma_addr =
-			dma_map_single(i2c_bus->dev, i2c_bus->controller_dma_safe_buf,
+			dma_map_single(i2c_bus->dev, i2c_bus->dma_safe_buf,
 				       msg->len, DMA_TO_DEVICE);
 		ret = dma_mapping_error(i2c_bus->dev, i2c_bus->controller_dma_addr);
 		if (ret) {
-			i2c_put_dma_safe_msg_buf(i2c_bus->controller_dma_safe_buf, msg, false);
-			i2c_bus->controller_dma_safe_buf = NULL;
+			i2c_put_dma_safe_msg_buf(i2c_bus->dma_safe_buf, msg, false);
+			i2c_bus->dma_safe_buf = NULL;
 			return ret;
 		}
 	}
@@ -502,16 +899,15 @@ static int ast2600_i2c_setup_dma_rx(struct ast2600_i2c_bus *i2c_bus)
 			cmd |= CONTROLLER_TRIGGER_LAST_STOP;
 	}
 	writel(AST2600_I2CM_SET_RX_DMA_LEN(xfer_len - 1), i2c_bus->reg_base + AST2600_I2CM_DMA_LEN);
-	i2c_bus->controller_dma_safe_buf = i2c_get_dma_safe_msg_buf(msg, 1);
-	if (!i2c_bus->controller_dma_safe_buf)
+	i2c_bus->dma_safe_buf = i2c_get_dma_safe_msg_buf(msg, 1);
+	if (!i2c_bus->dma_safe_buf)
 		return -ENOMEM;
 	i2c_bus->controller_dma_addr =
-		dma_map_single(i2c_bus->dev, i2c_bus->controller_dma_safe_buf,
-			       msg->len, DMA_FROM_DEVICE);
+		dma_map_single(i2c_bus->dev, i2c_bus->dma_safe_buf, msg->len, DMA_FROM_DEVICE);
 	ret = dma_mapping_error(i2c_bus->dev, i2c_bus->controller_dma_addr);
 	if (ret) {
-		i2c_put_dma_safe_msg_buf(i2c_bus->controller_dma_safe_buf, msg, false);
-		i2c_bus->controller_dma_safe_buf = NULL;
+		i2c_put_dma_safe_msg_buf(i2c_bus->dma_safe_buf, msg, false);
+		i2c_bus->dma_safe_buf = NULL;
 		return ret;
 	}
 	writel(i2c_bus->controller_dma_addr, i2c_bus->reg_base + AST2600_I2CM_RX_DMA);
@@ -659,9 +1055,8 @@ static void ast2600_i2c_controller_package_irq(struct ast2600_i2c_bus *i2c_bus,
 			if (i2c_bus->mode == DMA_MODE) {
 				dma_unmap_single(i2c_bus->dev, i2c_bus->controller_dma_addr,
 						 msg->len, DMA_TO_DEVICE);
-				i2c_put_dma_safe_msg_buf(i2c_bus->controller_dma_safe_buf,
-							 msg, true);
-				i2c_bus->controller_dma_safe_buf = NULL;
+				i2c_put_dma_safe_msg_buf(i2c_bus->dma_safe_buf, msg, true);
+				i2c_bus->dma_safe_buf = NULL;
 			}
 			i2c_bus->msgs_index++;
 			if (i2c_bus->msgs_index == i2c_bus->msgs_count) {
@@ -683,6 +1078,20 @@ static void ast2600_i2c_controller_package_irq(struct ast2600_i2c_bus *i2c_bus,
 		}
 		break;
 	case AST2600_I2CM_RX_DONE:
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+		/*
+		 * Workaround for controller/target package mode enable rx done stuck issue
+		 * When master go for first read (RX_DONE), target mode will also effect
+		 * Then controller will send nack, not operate anymore.
+		 */
+		if (readl(i2c_bus->reg_base + AST2600_I2CS_CMD_STS) & AST2600_I2CS_PKT_MODE_EN) {
+			u32 target_cmd = readl(i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+
+			writel(0, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+			writel(target_cmd, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+		}
+		fallthrough;
+#endif
 	case AST2600_I2CM_RX_DONE | AST2600_I2CM_NORMAL_STOP:
 		/* do next rx */
 		if (i2c_bus->mode == DMA_MODE) {
@@ -712,9 +1121,8 @@ static void ast2600_i2c_controller_package_irq(struct ast2600_i2c_bus *i2c_bus,
 			if (i2c_bus->mode == DMA_MODE) {
 				dma_unmap_single(i2c_bus->dev, i2c_bus->controller_dma_addr,
 						 msg->len, DMA_FROM_DEVICE);
-				i2c_put_dma_safe_msg_buf(i2c_bus->controller_dma_safe_buf,
-							 msg, true);
-				i2c_bus->controller_dma_safe_buf = NULL;
+				i2c_put_dma_safe_msg_buf(i2c_bus->dma_safe_buf, msg, true);
+				i2c_bus->dma_safe_buf = NULL;
 			}
 
 			i2c_bus->msgs_index++;
@@ -812,6 +1220,12 @@ static irqreturn_t ast2600_i2c_bus_irq(int irq, void *dev_id)
 {
 	struct ast2600_i2c_bus *i2c_bus = dev_id;
 
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+	if (readl(i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL) & AST2600_I2CC_SLAVE_EN) {
+		if (ast2600_i2c_target_irq(i2c_bus))
+			return IRQ_HANDLED;
+	}
+#endif
 	return IRQ_RETVAL(ast2600_i2c_controller_irq(i2c_bus));
 }
 
@@ -828,12 +1242,30 @@ static int ast2600_i2c_controller_xfer(struct i2c_adapter *adap, struct i2c_msg
 			return ret;
 	}
 
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+	if (i2c_bus->mode == BUFF_MODE) {
+		if (i2c_bus->target_operate)
+			return -EBUSY;
+		/* disable target isr */
+		writel(0, i2c_bus->reg_base + AST2600_I2CS_IER);
+		if (readl(i2c_bus->reg_base + AST2600_I2CS_ISR) || i2c_bus->target_operate) {
+			writel(AST2600_I2CS_PKT_DONE, i2c_bus->reg_base + AST2600_I2CS_IER);
+			return -EBUSY;
+		}
+	}
+#endif
+
 	i2c_bus->cmd_err = 0;
 	i2c_bus->msgs = msgs;
 	i2c_bus->msgs_index = 0;
 	i2c_bus->msgs_count = num;
 	reinit_completion(&i2c_bus->cmd_complete);
 	ret = ast2600_i2c_do_start(i2c_bus);
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+	/* avoid race condication target is wait and master wait 1st target operate */
+	if (i2c_bus->mode == BUFF_MODE)
+		writel(AST2600_I2CS_PKT_DONE, i2c_bus->reg_base + AST2600_I2CS_IER);
+#endif
 	if (ret)
 		goto controller_out;
 	timeout = wait_for_completion_timeout(&i2c_bus->cmd_complete, i2c_bus->adap.timeout);
@@ -850,7 +1282,26 @@ static int ast2600_i2c_controller_xfer(struct i2c_adapter *adap, struct i2c_msg
 		    (readl(i2c_bus->reg_base + AST2600_I2CC_STS_AND_BUFF) &
 		    AST2600_I2CC_BUS_BUSY_STS))
 			ast2600_i2c_recover_bus(i2c_bus);
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+		if (ctrl & AST2600_I2CC_SLAVE_EN) {
+			u32 cmd = TARGET_TRIGGER_CMD;
 
+			if (i2c_bus->mode == DMA_MODE) {
+				cmd |= AST2600_I2CS_RX_DMA_EN;
+				writel(i2c_bus->target_dma_addr,
+				       i2c_bus->reg_base + AST2600_I2CS_RX_DMA);
+				writel(i2c_bus->target_dma_addr,
+				       i2c_bus->reg_base + AST2600_I2CS_TX_DMA);
+				writel(AST2600_I2CS_SET_RX_DMA_LEN(I2C_TARGET_MSG_BUF_SIZE),
+				       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+			} else if (i2c_bus->mode == BUFF_MODE) {
+				cmd = TARGET_TRIGGER_CMD;
+			} else {
+				cmd &= ~AST2600_I2CS_PKT_MODE_EN;
+			}
+			writel(cmd, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+		}
+#endif
 		ret = -ETIMEDOUT;
 	} else {
 		ret = i2c_bus->cmd_err;
@@ -860,8 +1311,8 @@ static int ast2600_i2c_controller_xfer(struct i2c_adapter *adap, struct i2c_msg
 
 controller_out:
 	if (i2c_bus->mode == DMA_MODE) {
-		kfree(i2c_bus->controller_dma_safe_buf);
-		i2c_bus->controller_dma_safe_buf = NULL;
+		kfree(i2c_bus->dma_safe_buf);
+		i2c_bus->dma_safe_buf = NULL;
 	}
 
 	return ret;
@@ -889,7 +1340,78 @@ static void ast2600_i2c_init(struct ast2600_i2c_bus *i2c_bus)
 
 	/* Clear Interrupt */
 	writel(GENMASK(27, 0), i2c_bus->reg_base + AST2600_I2CM_ISR);
+
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+	/* for memory buffer initial */
+	if (i2c_bus->mode == DMA_MODE) {
+		i2c_bus->target_dma_buf =
+			dmam_alloc_coherent(i2c_bus->dev, I2C_TARGET_MSG_BUF_SIZE,
+					    &i2c_bus->target_dma_addr, GFP_KERNEL);
+		if (!i2c_bus->target_dma_buf)
+			return;
+	}
+
+	writel(GENMASK(27, 0), i2c_bus->reg_base + AST2600_I2CS_ISR);
+
+	if (i2c_bus->mode == BYTE_MODE)
+		writel(GENMASK(15, 0), i2c_bus->reg_base + AST2600_I2CS_IER);
+	else
+		writel(AST2600_I2CS_PKT_DONE, i2c_bus->reg_base + AST2600_I2CS_IER);
+#endif
+}
+
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+static int ast2600_i2c_reg_target(struct i2c_client *client)
+{
+	struct ast2600_i2c_bus *i2c_bus = i2c_get_adapdata(client->adapter);
+	u32 cmd = TARGET_TRIGGER_CMD;
+
+	if (i2c_bus->target)
+		return -EINVAL;
+
+	dev_dbg(i2c_bus->dev, "target addr %x\n", client->addr);
+
+	writel(0, i2c_bus->reg_base + AST2600_I2CS_ADDR_CTRL);
+	writel(AST2600_I2CC_SLAVE_EN | readl(i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL),
+	       i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL);
+
+	/* trigger rx buffer */
+	if (i2c_bus->mode == DMA_MODE) {
+		cmd |= AST2600_I2CS_RX_DMA_EN;
+		writel(i2c_bus->target_dma_addr, i2c_bus->reg_base + AST2600_I2CS_RX_DMA);
+		writel(i2c_bus->target_dma_addr, i2c_bus->reg_base + AST2600_I2CS_TX_DMA);
+		writel(AST2600_I2CS_SET_RX_DMA_LEN(I2C_TARGET_MSG_BUF_SIZE),
+		       i2c_bus->reg_base + AST2600_I2CS_DMA_LEN);
+	} else if (i2c_bus->mode == BUFF_MODE) {
+		cmd = TARGET_TRIGGER_CMD;
+	} else {
+		cmd &= ~AST2600_I2CS_PKT_MODE_EN;
+	}
+
+	writel(cmd, i2c_bus->reg_base + AST2600_I2CS_CMD_STS);
+	i2c_bus->target = client;
+	/* Set target addr. */
+	writel(client->addr | AST2600_I2CS_ADDR1_ENABLE,
+	       i2c_bus->reg_base + AST2600_I2CS_ADDR_CTRL);
+
+	return 0;
+}
+
+static int ast2600_i2c_unreg_target(struct i2c_client *client)
+{
+	struct ast2600_i2c_bus *i2c_bus = i2c_get_adapdata(client->adapter);
+
+	/* Turn off target mode. */
+	writel(~AST2600_I2CC_SLAVE_EN & readl(i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL),
+	       i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL);
+	writel(readl(i2c_bus->reg_base + AST2600_I2CS_ADDR_CTRL) & ~AST2600_I2CS_ADDR1_MASK,
+	       i2c_bus->reg_base + AST2600_I2CS_ADDR_CTRL);
+
+	i2c_bus->target = NULL;
+
+	return 0;
 }
+#endif
 
 static u32 ast2600_i2c_functionality(struct i2c_adapter *adap)
 {
@@ -899,6 +1421,10 @@ static u32 ast2600_i2c_functionality(struct i2c_adapter *adap)
 static const struct i2c_algorithm i2c_ast2600_algorithm = {
 	.xfer = ast2600_i2c_controller_xfer,
 	.functionality = ast2600_i2c_functionality,
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+	.reg_target = ast2600_i2c_reg_target,
+	.unreg_target = ast2600_i2c_unreg_target,
+#endif
 };
 
 static int ast2600_i2c_probe(struct platform_device *pdev)
@@ -934,6 +1460,9 @@ static int ast2600_i2c_probe(struct platform_device *pdev)
 		regmap_write(i2c_bus->global_regs, AST2600_I2CG_CLK_DIV_CTRL, I2CCG_DIV_CTRL);
 	}
 
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
+	i2c_bus->target_operate = 0;
+#endif
 	i2c_bus->dev = dev;
 	i2c_bus->mode = BUFF_MODE;
 
Signature · 1 line
2.34.1