Compute HS HCNT and LCNT based on HW parameters
Subsystems (4)
v3 cover Compute HS HCNT and LCNT based on HW parameters
In commit 35eba185fd1a ("i2c: designware: Calculate SCL timing parameters for High Speed Mode") hs_hcnt and hs_lcnt are computed based on fixed tHIGH = 160 and tLOW = 320. However, the set of these fixed values only applies to the combination of hardware parameters "IC_CAP_LOADING = 400pF" and "IC_FREQ_OPTIMIZATION = 1". Outside of this combination, SCL frequency may not reach 3.4 MHz if hs_hcnt and hs_lcnt are both computed using these two fixed values.
Since there are no any registers controlling these two hardware parameters, their values can only be declared through the device tree.
v3:
- add vendor prefix on new property name
- read new properties in i2c_dw_fw_parse_and_configure() directly
- in i2c_dw_set_timings_master() check dev->bus_capacitance_pf and then decide t_high and t_low
v2:
- provide more hardware information in dt-bindings
- rename "bus-loading" to "bus-capacitance-pf"
- call new i2c_dw_fw_parse_hw_params() in i2c_dw_fw_parse_and_configure() to parse hardware parameters from the device tree.
Michael Wu (2):
dt-bindings: i2c: snps,designware-i2c: declare bus capacitance and clk
freq optimized
i2c: dwsignware: determine HS tHIGH and tLOW based on HW parameters
.../bindings/i2c/snps,designware-i2c.yaml | 24 +++++++++++++++++++ drivers/i2c/busses/i2c-designware-common.c | 5 ++++ drivers/i2c/busses/i2c-designware-core.h | 5 ++++ drivers/i2c/busses/i2c-designware-master.c | 23 ++++++++++++++++-- 4 files changed, 55 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/2 dt-bindings: i2c: snps,designware-i2c: declare bus capacitance and clk freq optimized
Since there are no registers controlling the hardware parameters IC_CAP_LOADING and IC_CLK_FREQ_OPTIMIZATION, their values can only be declared in the device tree.
snps,bus-capacitance-pf indicates the bus capacitance in picofarads (pF). It affects the high and low pulse width of SCL line in high speed mode. The legal values for this property are 100 and 400 only, and default value is 100. This property corresponds to IC_CAP_LOADING.
snps,clk-freq-optimized indicates whether the hardware input clock frequency is reduced by reducing the internal latency. This property corresponds to IC_CLK_FREQ_OPTIMIZATION.
The driver can calculate hs_hcnt and hs_lcnt appropriate for the hardware based on these two properties.
--- .../bindings/i2c/snps,designware-i2c.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +24 -0
@@ -97,6 +97,21 @@ properties: - const: tx - const: rx + snps,bus-capacitance-pf: + $ref: /schemas/types.yaml#/definitions/uint32 + description: > + This property indicates the bus capacitance in picofarads (pF). + This value is used to compute the tHIGH and tLOW periods for high speed + mode. + default: 100 + + snps,clk-freq-optimized: + description: > + This property indicates whether the hardware input clock frequency is + reduced by reducing the internal latency. This value is used to compute + the tHIGH and tLOW periods for high speed mode. + type: boolean + unevaluatedProperties: false required:
@@ -146,4 +161,13 @@ examples: interrupts = <8>; clocks = <&ahb_clk>; }; + - | + i2c@c5000000 { + compatible = "snps,designware-i2c"; + reg = <0xc5000000 0x1000>; + interrupts = <37 1>; + clock-frequency = <400000>; + snps,bus-capacitance-pf = <400>; + snps,clk-freq-optimized; + }; ...
Signature · 1 line
2.43.0
Re: [PATCH v3 1/2] dt-bindings: i2c: snps,designware-i2c: declare bus capacitance and clk freq optimized
Quoted 26 lines · Michael Wu
Since there are no registers controlling the hardware parameters
IC_CAP_LOADINGandIC_CLK_FREQ_OPTIMIZATION, their values can only be declared in the device tree.snps,bus-capacitance-pf indicates the bus capacitance in picofarads (pF). It affects the high and low pulse width of SCL line in high speed mode. The legal values for this property are 100 and 400 only, and default value is 100. This property corresponds to
IC_CAP_LOADING.snps,clk-freq-optimized indicates whether the hardware input clock frequency is reduced by reducing the internal latency. This property corresponds to
IC_CLK_FREQ_OPTIMIZATION.The driver can calculate
hs_hcntandhs_lcntappropriate for the hardware based on these two properties.Signed-off-by Michael Wu <[email protected]>--- .../bindings/i2c/snps,designware-i2c.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +0
-0
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml properties: · line 102
Quoted 6 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +3
-0@@ -97,6 +97,21 @@ properties: - const: tx - const: rx + snps,bus-capacitance-pf: + $ref: /schemas/types.yaml#/definitions/uint32 + description: >
I asked to drop |, so you replaced it with something else? So drop >... and then you are going to replace it with another one?
That's not a cat and mouse.
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml properties: · line 106
Quoted 4 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +4
-0+ This property indicates the bus capacitance in picofarads (pF). + This value is used to compute the tHIGH and tLOW periods for high speed + mode. + default: 100
I asked for some constraints here. min/maximum. I think you never replied to this.
Quoted 12 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +8
-0+ + snps,clk-freq-optimized: + description: > + This property indicates whether the hardware input clock frequency is + reduced by reducing the internal latency. This value is used to compute + the tHIGH and tLOW periods for high speed mode. + type: boolean + unevaluatedProperties: false required:
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml examples: · line 166
Quoted 6 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +3
-0@@ -146,4 +161,13 @@ examples: interrupts = <8>; clocks = <&ahb_clk>; }; + - | + i2c@c5000000 { + compatible = "snps,designware-i2c";
Extend EXISTING example. Not add new example.
Best regards,
Krzysztof
Re: [PATCH v3 1/2] dt-bindings: i2c: snps,designware-i2c: declare bus capacitance and clk freq optimized
Quoted 29 lines · Michael Wu
Quoted 13 lines
Since there are no registers controlling the hardware parameters
IC_CAP_LOADINGandIC_CLK_FREQ_OPTIMIZATION, their values can only be declared in the device tree.snps,bus-capacitance-pf indicates the bus capacitance in picofarads (pF). It affects the high and low pulse width of SCL line in high speed mode. The legal values for this property are 100 and 400 only, and default value is 100. This property corresponds to
IC_CAP_LOADING.snps,clk-freq-optimized indicates whether the hardware input clock frequency is reduced by reducing the internal latency. This property corresponds to
IC_CLK_FREQ_OPTIMIZATION.Quoted 6 lines
The driver can calculate
hs_hcntandhs_lcntappropriate for the hardware based on these two properties.Signed-off-by Michael Wu <[email protected]>--- .../bindings/i2c/snps,designware-i2c.yaml | 24+++++++++++++++++++
Quoted 3 lines
1 file changed, 24 insertions(+)diff --git
a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yamlb/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yamlQuoted 3 lines
index
60035a787e5c..c373f3acd34b100644Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +0
-0
...
Quoted 9 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
Quoted 2 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +2
-0+ This property indicates the bus capacitance in picofarads (pF). + This value is used to compute the tHIGH and tLOW periods for highspeed
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml properties: · line 106
Quoted 2 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +2
-0+ mode. + default: 100I asked for some constraints here. min/maximum. I think you never replied to this.
In I2C DesignWare Databook v2.03a the mandatory option is provided to select whether the bus capacitance is 400pF or 100pF. It presents the description like that:
Description:
For high speed mode, the bus loading (pF) affects the high and low pulse width of SCL.
Values: 100, 400
Default Value: 100
Parameter Name: IC_CAP_LOADING
There is no further information describing this option except to the declaration of legal values above, let alone minimum and maximum limits. As a user I don't think I have the right to define a value range for the vendor.
From the information provided in the data sheet, I prefer to list the legal values like the following:
enum: [100, 400]
default: 100
instead of declaring its range. What do you think?
In patches v2 I used if (dev->bus_capacitance_pf == 400) {... } else {...} and other statements in the driver code to indicate that the capacitance can only be 400pf or not. Maybe this is a metaphor. I'm sorry that I wasn't more explicit about the constraints.
Quoted 12 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml properties:
Quoted 4 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +4
-0+ + snps,clk-freq-optimized: + description: > + This property indicates whether the hardware input clock frequencyis
Quoted 1 line
+ reduced by reducing the internal latency. This value is used to
compute
Quoted 5 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +3
-0+ the tHIGH and tLOW periods for high speed mode. + type: boolean + unevaluatedProperties: false
Quoted 10 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml examples: · line 166
Quoted 8 lines
required:
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +3
-0@@ -146,4 +161,13 @@ examples: interrupts = <8>; clocks = <&ahb_clk>; }; + - | + i2c@c5000000 { + compatible = "snps,designware-i2c";Extend EXISTING example. Not add new example.
Should I insert these two properties into one or all existing examples?
Thanks & Regards
Michael
Re: [PATCH v3 1/2] dt-bindings: i2c: snps,designware-i2c: declare bus capacitance and clk freq optimized
Quoted 51 lines · Michael Wu
Quoted 29 lines · Michael Wu
Quoted 13 lines
Since there are no registers controlling the hardware parameters
IC_CAP_LOADINGandIC_CLK_FREQ_OPTIMIZATION, their values can only be declared in the device tree.snps,bus-capacitance-pf indicates the bus capacitance in picofarads (pF). It affects the high and low pulse width of SCL line in high speed mode. The legal values for this property are 100 and 400 only, and default value is 100. This property corresponds to
IC_CAP_LOADING.snps,clk-freq-optimized indicates whether the hardware input clock frequency is reduced by reducing the internal latency. This property corresponds to
IC_CLK_FREQ_OPTIMIZATION.Quoted 6 lines
The driver can calculate
hs_hcntandhs_lcntappropriate for the hardware based on these two properties.Signed-off-by Michael Wu <[email protected]>--- .../bindings/i2c/snps,designware-i2c.yaml | 24+++++++++++++++++++
Quoted 3 lines
1 file changed, 24 insertions(+)diff --git
a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yamlb/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yamlQuoted 3 lines
index
60035a787e5c..c373f3acd34b100644Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +0
-0...
Quoted 9 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
Quoted 2 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +2
-0+ This property indicates the bus capacitance in picofarads (pF). + This value is used to compute the tHIGH and tLOW periods for highspeed
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml properties: · line 106
Quoted 2 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +2
-0+ mode. + default: 100I asked for some constraints here. min/maximum. I think you never replied to this.
In I2C DesignWare Databook v2.03a the mandatory option is provided to select whether the bus capacitance is 400pF or 100pF. It presents the description like that:
Description:
For high speed mode, the bus loading (pF) affects the high and low pulse width of SCL.
Values: 100, 400
Default Value: 100
Parameter Name:IC_CAP_LOADING
Quoted 2 lines
There is no further information describing this option except to the declaration of legal values above, let alone minimum and maximum limits.
So only two values are valid? Then not min/max but enum.
Quoted 39 lines
As a user I don't think I have the right to define a value range for the vendor.
From the information provided in the data sheet, I prefer to list the legal values like the following:
enum: [100, 400]
default: 100instead of declaring its range. What do you think?
In patches v2 I used if (
dev->bus_capacitance_pf== 400) {... } else {...} and other statements in the driver code to indicate that the capacitance can only be 400pf or not. Maybe this is a metaphor. I'm sorry that I wasn't more explicit about the constraints.Quoted 12 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml properties:
Quoted 4 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +4
-0+ + snps,clk-freq-optimized: + description: > + This property indicates whether the hardware input clock frequencyis
Quoted 1 line
+ reduced by reducing the internal latency. This value is used to
compute
Quoted 5 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +3
-0+ the tHIGH and tLOW periods for high speed mode. + type: boolean + unevaluatedProperties: falseQuoted 10 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml examples: · line 166
Quoted 8 lines
required:
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +3
-0@@ -146,4 +161,13 @@ examples: interrupts = <8>; clocks = <&ahb_clk>; }; + - | + i2c@c5000000 { + compatible = "snps,designware-i2c";Extend EXISTING example. Not add new example.
Quoted 1 line
Should I insert these two properties into one or all existing examples?
Into any example, where it looks reasonable.
Best regards,
Krzysztof
Re: [PATCH v3 1/2] dt-bindings: i2c: snps,designware-i2c: declare bus capacitance and clk freq optimized
In reply to Krzysztof KozlowskiQuoted 29 lines · Michael Wu
Quoted 13 lines
Since there are no registers controlling the hardware parameters
IC_CAP_LOADINGandIC_CLK_FREQ_OPTIMIZATION, their values can only be declared in the device tree.snps,bus-capacitance-pf indicates the bus capacitance in picofarads (pF). It affects the high and low pulse width of SCL line in high speed mode. The legal values for this property are 100 and 400 only, and default value is 100. This property corresponds to
IC_CAP_LOADING.snps,clk-freq-optimized indicates whether the hardware input clock frequency is reduced by reducing the internal latency. This property corresponds to
IC_CLK_FREQ_OPTIMIZATION.Quoted 6 lines
The driver can calculate
hs_hcntandhs_lcntappropriate for the hardware based on these two properties.Signed-off-by Michael Wu <[email protected]>--- .../bindings/i2c/snps,designware-i2c.yaml | 24+++++++++++++++++++
Quoted 3 lines
1 file changed, 24 insertions(+)diff --git
a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yamlb/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yamlQuoted 3 lines
index
60035a787e5c..c373f3acd34b100644Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +0
-0
...
Quoted 9 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
Quoted 2 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +2
-0+ This property indicates the bus capacitance in picofarads (pF). + This value is used to compute the tHIGH and tLOW periods for highspeed
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml properties: · line 106
Quoted 2 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +2
-0+ mode. + default: 100I asked for some constraints here. min/maximum. I think you never replied to this.
In I2C DesignWare Databook v2.03a the mandatory option is provided to select whether the bus capacitance is 400pF or 100pF. It presents the description like that:
Description:
For high speed mode, the bus loading (pF) affects the high and low pulse width of SCL.
Values: 100, 400
Default Value: 100
Parameter Name: IC_CAP_LOADING
There is no further information describing this option except to the declaration of legal values above, let alone minimum and maximum limits. As a user I don't think I have the right to define a value range for the vendor.
From the information provided in the data sheet, I prefer to list the legal values like the following:
enum: [100, 400]
default: 100
instead of declaring its range. What do you think?
In patches v2 I used if (dev->bus_capacitance_pf == 400) {... } else {...} and other statements in the driver code to indicate that the capacitance can only be 400pf or not. Maybe this is a metaphor. I'm sorry that I wasn't more explicit about the constraints.
Quoted 12 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml properties:
Quoted 4 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +4
-0+ + snps,clk-freq-optimized: + description: > + This property indicates whether the hardware input clock frequencyis
Quoted 1 line
+ reduced by reducing the internal latency. This value is used to
compute
Quoted 5 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +3
-0+ the tHIGH and tLOW periods for high speed mode. + type: boolean + unevaluatedProperties: false
Quoted 10 lines
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml examples: · line 166
Quoted 8 lines
required:
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +3
-0@@ -146,4 +161,13 @@ examples: interrupts = <8>; clocks = <&ahb_clk>; }; + - | + i2c@c5000000 { + compatible = "snps,designware-i2c";Extend EXISTING example. Not add new example.
Should I insert these two properties into one or all existing examples?
Thanks & Regards
Michael
PATCH v3 2/2 i2c: dwsignware: determine HS tHIGH and tLOW based on HW parameters
In reply to Michael WuIn commit 35eba185fd1a ("i2c: designware: Calculate SCL timing parameter for High Speed Mode") hs_hcnt and hs_lcnt are calculated based on fixed tHIGH = 160 and tLOW = 120. However, the set of these fixed values only applies to the combination of hardware parameters IC_CAP_LOADING = 400pF and IC_CLK_FREQ_OPTIMIZATION = 1. Outside of this combination, if these fixed tHIGH = 160 and tLOW = 120 are still used, the calculated hs_hcnt and hs_lcnt may not be small enough, making it impossible for the SCL frequency to reach 3.4 MHz.
Section 3.15.4.5 in DesignWare DW_apb_i2b Databook v2.03 says that when IC_CLK_FREQ_OPTIMIZATION = 0,
MIN_SCL_HIGHtime = 60 ns for 3.4 Mbps, bus loading = 100pF
= 120 ns for 3.4 Mbps, bus loading = 400pF
MIN_SCL_LOWtime = 160 ns for 3.4 Mbps, bus loading = 100pF
= 320 ns for 3.4 Mbps, bus loading = 400pF
and section 3.15.4.6 says that when IC_CLK_FREQ_OPTIMIZATION = 1,
MIN_SCL_HIGHtime = 60 ns for 3.4 Mbps, bus loading = 100pF
= 160 ns for 3.4 Mbps, bus loading = 400pF
MIN_SCL_LOWtime = 120 ns for 3.4 Mbps, bus loading = 100pF
= 320 ns for 3.4 Mbps, bus loading = 400pF
In order to calculate more accurate hs_hcnt amd hs_lcnt, two hardware parameters IC_CAP_LOADING and IC_CLK_FREQ_OPTIMIZATION must be considered together.
--- drivers/i2c/busses/i2c-designware-common.c | 5 +++++ drivers/i2c/busses/i2c-designware-core.h | 5 +++++ drivers/i2c/busses/i2c-designware-master.c | 23 ++++++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-designware-common.c +5 -0
@@ -380,6 +380,11 @@ int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev)i2c_parse_fw_timings (device, t, false); +if (device_property_read_u32 (device,"snps,bus-capacitance-pf" , &dev->bus_capacitance_pf)) + dev->bus_capacitance_pf =100 ; + + dev->clk_freq_optimized =device_property_read_bool (device,"snps,clk-freq-optimized" ); +i2c_dw_adjust_bus_speed (dev);if (is_of_node (fwnode))
drivers/i2c/busses/i2c-designware-core.h +5 -0
@@ -240,6 +240,9 @@ struct reset_control;* @set_sda_hold_time: callback to retrieve IP specific SDA hold timing * @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE * @rinfo: I²C GPIO recovery information +* @bus_capacitance_pf: bus capacitance in picofarads +* @clk_freq_optimized: indicate whether hardware input clock frequency is +* reduced by reducing the internal latency * * HCNT and LCNT parameters can be used if the platform knows more accurate * values than the one computed based only on the input clock frequency.
@@ -297,6 +300,8 @@ struct dw_i2c_dev {int (*set_sda_hold_time)(struct dw_i2c_dev *dev);int mode;struct i2c_bus_recovery_info rinfo; +u32 bus_capacitance_pf; +bool clk_freq_optimized; };#define ACCESS_INTR_MASK BIT(0)
drivers/i2c/busses/i2c-designware-master.c +21 -2
@@ -154,12 +154,31 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev) dev->hs_hcnt =0 ; dev->hs_lcnt =0 ; }else if (!dev->hs_hcnt || !dev->hs_lcnt) { +u32 t_high, t_low; + +/* +* The legal values stated in the databook for bus +* capacitance are only 100pF and 400pF. +* If dev->bus_capacitance_pf is greater than or equals +* to 400, t_high and t_low are assumed to be +* appropriate values for 400pF, otherwise 100pF. +*/ +if (dev->bus_capacitance_pf >=400 ) { +/* assume bus capacitance is 400pF */ + t_high = dev->clk_freq_optimized ?160 :120 ; + t_low =320 ; + }else { +/* assume bus capacitance is 100pF */ + t_high =60 ; + t_low = dev->clk_freq_optimized ?120 :160 ; + } + ic_clk =i2c_dw_clk_rate (dev); dev->hs_hcnt =i2c_dw_scl_hcnt (dev,DW_IC_HS_SCL_HCNT , ic_clk, -160 ,/* tHIGH = 160 ns */ + t_high, sda_falling_time,0 ,/* DW default */ 0 );/* No offset */
@@ -167,7 +186,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)i2c_dw_scl_lcnt (dev,DW_IC_HS_SCL_LCNT , ic_clk, -320 ,/* tLOW = 320 ns */ + t_low, scl_falling_time,0 );/* No offset */ }
Signature · 1 line
2.43.0
Andi Shyti
maintainerRe: [PATCH v3 2/2] i2c: dwsignware: determine HS tHIGH and tLOW based on HW parameters
Hi Michael,
Quoted 8 lines · Michael Wu
In commit
35eba185fd1a("i2c: designware: Calculate SCL timing parameter for High Speed Mode")hs_hcntandhs_lcntare calculated based on fixed tHIGH = 160 and tLOW = 120. However, the set of these fixed values only applies to the combination of hardware parametersIC_CAP_LOADING= 400pF andIC_CLK_FREQ_OPTIMIZATION= 1. Outside of this combination, if these fixed tHIGH = 160 and tLOW = 120 are still used, the calculatedhs_hcntandhs_lcntmay not be small enough, making it impossible for the SCL frequency to reach 3.4 MHz.
If someone is not familiar with the terms you are using this paragraph is completely meaningless. Can you please describe or at least expandi in parenthesis:
hs_hcnt
hs_lcnt
tHIGH/tLOW (this is easy, but redundancy in commit log is never
enough)
IC_CAP_LOADING
IC_CLK_FREQ_OPTIMIZATION
Quoted 21 lines
Section 3.15.4.5 in DesignWare
DW_apb_i2bDatabook v2.03 says that whenIC_CLK_FREQ_OPTIMIZATION= 0,
MIN_SCL_HIGHtime= 60 ns for 3.4 Mbps, bus loading = 100pF
= 120 ns for 3.4 Mbps, bus loading = 400pF
MIN_SCL_LOWtime= 160 ns for 3.4 Mbps, bus loading = 100pF
= 320 ns for 3.4 Mbps, bus loading = 400pFand section 3.15.4.6 says that when
IC_CLK_FREQ_OPTIMIZATION= 1,
MIN_SCL_HIGHtime= 60 ns for 3.4 Mbps, bus loading = 100pF
= 160 ns for 3.4 Mbps, bus loading = 400pF
MIN_SCL_LOWtime= 120 ns for 3.4 Mbps, bus loading = 100pF
= 320 ns for 3.4 Mbps, bus loading = 400pFIn order to calculate more accurate
hs_hcntamdhs_lcnt, two hardware parametersIC_CAP_LOADINGandIC_CLK_FREQ_OPTIMIZATIONmust be considered together.Signed-off-by Michael Wu <[email protected]>---
...
Quoted 2 lines
+ * @bus_capacitance_pf: bus capacitance in picofarads
+ * @clk_freq_optimized: indicate whether hardware input clock frequency is
/indicate/indicates/
/hardware/the hardware/
Quoted 1 line
+ * reduced by reducing the internal latency
The sentence above is not really meaningful and it's not describing what "clk_freq_optimized" is.
Quoted 3 lines
*
* HCNT and LCNT parameters can be used if the platform knows more accurate
* values than the one computed based only on the input clock frequency.
...
Quoted 30 lines
drivers/i2c/busses/i2c-designware-master.c +20
-1+u32 t_high, t_low; + +/* +* The legal values stated in the databook for bus +* capacitance are only 100pF and 400pF. +* If dev->bus_capacitance_pf is greater than or equals +* to 400, t_high and t_low are assumed to be +* appropriate values for 400pF, otherwise 100pF. +*/ +if (dev->bus_capacitance_pf >=400 ) { +/* assume bus capacitance is 400pF */ + t_high = dev->clk_freq_optimized ?160 :120 ; + t_low =320 ; + }else { +/* assume bus capacitance is 100pF */ + t_high =60 ; + t_low = dev->clk_freq_optimized ?120 :160 ; + } + ic_clk =i2c_dw_clk_rate (dev); dev->hs_hcnt =i2c_dw_scl_hcnt (dev,DW_IC_HS_SCL_HCNT , ic_clk, -160 ,/* tHIGH = 160 ns */ + t_high, sda_falling_time,0 ,/* DW default */ 0 );/* No offset */
drivers/i2c/busses/i2c-designware-master.c static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev) · line 189
Quoted 5 lines
drivers/i2c/busses/i2c-designware-master.c +1
-1@@ -167,7 +186,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev) i2c_dw_scl_lcnt(dev, DW_IC_HS_SCL_LCNT, ic_clk, - 320, /* tLOW = 320 ns */ + t_low,
This looks fine to me.
Thanks,
Andi
Quoted 6 lines
drivers/i2c/busses/i2c-designware-master.c +0
-0scl_falling_time, 0); /* No offset */ }Signature · 1 line
2.43.0
Andy Shevchenko
reviewerRe: [PATCH v3 2/2] i2c: dwsignware: determine HS tHIGH and tLOW based on HW parameters
In reply to Michael WuQuoted 27 lines · Michael Wu
In commit
35eba185fd1a("i2c: designware: Calculate SCL timing parameter for High Speed Mode")hs_hcntandhs_lcntare calculated based on fixed tHIGH = 160 and tLOW = 120. However, the set of these fixed values only applies to the combination of hardware parametersIC_CAP_LOADING= 400pF andIC_CLK_FREQ_OPTIMIZATION= 1. Outside of this combination, if these fixed tHIGH = 160 and tLOW = 120 are still used, the calculatedhs_hcntandhs_lcntmay not be small enough, making it impossible for the SCL frequency to reach 3.4 MHz.Section 3.15.4.5 in DesignWare
DW_apb_i2bDatabook v2.03 says that whenIC_CLK_FREQ_OPTIMIZATION= 0,
MIN_SCL_HIGHtime= 60 ns for 3.4 Mbps, bus loading = 100pF
= 120 ns for 3.4 Mbps, bus loading = 400pF
MIN_SCL_LOWtime= 160 ns for 3.4 Mbps, bus loading = 100pF
= 320 ns for 3.4 Mbps, bus loading = 400pFand section 3.15.4.6 says that when
IC_CLK_FREQ_OPTIMIZATION= 1,
MIN_SCL_HIGHtime= 60 ns for 3.4 Mbps, bus loading = 100pF
= 160 ns for 3.4 Mbps, bus loading = 400pF
MIN_SCL_LOWtime= 120 ns for 3.4 Mbps, bus loading = 100pF
= 320 ns for 3.4 Mbps, bus loading = 400pFIn order to calculate more accurate
hs_hcntamdhs_lcnt, two hardware parametersIC_CAP_LOADINGandIC_CLK_FREQ_OPTIMIZATIONmust be considered together.
...
Quoted 1 line
+ * @bus_capacitance_pf: bus capacitance in picofarads
Since it seems a new version of the series is warranted, and looking into the current kernel source (no other users of this unit were observed), I think we may do correct capitalisation here for the sake of physics and unit system, i.e.
* @bus_capacitance_pF: bus capacitance in picofarads
Signature · 2 lines
With Best Regards, Andy Shevchenko
RE: [PATCH v3 2/2] i2c: dwsignware: determine HS tHIGH and tLOW based on HW parameters
Hi,
Quoted 32 lines · Michael Wu
Quoted 4 lines
In commit
35eba185fd1a("i2c: designware: Calculate SCL timing parameter for High Speed Mode")hs_hcntandhs_lcntare calculated based on fixed tHIGH = 160 and tLOW = 120. However, the set of these fixed values only applies to the combination of hardware parametersIC_CAP_LOADING=400pF
Quoted 23 lines
and
IC_CLK_FREQ_OPTIMIZATION= 1. Outside of this combination, if these fixed tHIGH = 160 and tLOW = 120 are still used, the calculatedhs_hcntandhs_lcntmay not be small enough, making it impossible for the SCL frequency to reach 3.4 MHz.Section 3.15.4.5 in DesignWare
DW_apb_i2bDatabook v2.03 says that whenIC_CLK_FREQ_OPTIMIZATION= 0,
MIN_SCL_HIGHtime= 60 ns for 3.4 Mbps, bus loading = 100pF
= 120 ns for 3.4 Mbps, bus loading = 400pF
MIN_SCL_LOWtime= 160 ns for 3.4 Mbps, bus loading = 100pF
= 320 ns for 3.4 Mbps, bus loading = 400pFand section 3.15.4.6 says that when
IC_CLK_FREQ_OPTIMIZATION= 1,
MIN_SCL_HIGHtime= 60 ns for 3.4 Mbps, bus loading = 100pF
= 160 ns for 3.4 Mbps, bus loading = 400pF
MIN_SCL_LOWtime= 120 ns for 3.4 Mbps, bus loading = 100pF
= 320 ns for 3.4 Mbps, bus loading = 400pFIn order to calculate more accurate
hs_hcntamdhs_lcnt, two hardware parametersIC_CAP_LOADINGandIC_CLK_FREQ_OPTIMIZATIONmust be considered together....
Quoted 8 lines
Quoted 1 line
+ * @bus_capacitance_pf: bus capacitance in picofarads
Since it seems a new version of the series is warranted, and looking into the current kernel source (no other users of this unit were observed), I think we may do correct capitalisation here for the sake of physics and unit system, i.e.
* @bus_capacitance_pF: bus capacitance in picofarads
Are you serious? I have never seen capital letters used to declare a variable name. Although checkpatch.pl does not consider this as an issue, is this against everyone's custom or unspoken rules?
Sincerely,
Michael
Andy Shevchenko
reviewerRe: [PATCH v3 2/2] i2c: dwsignware: determine HS tHIGH and tLOW based on HW parameters
Quoted 1 line · Michael Wu
Quoted 1 line · Michael Wu
...
Quoted 10 lines
Quoted 8 lines
Quoted 1 line
+ * @bus_capacitance_pf: bus capacitance in picofarads
Since it seems a new version of the series is warranted, and looking into the current kernel source (no other users of this unit were observed), I think we may do correct capitalisation here for the sake of physics and unit system, i.e.
* @bus_capacitance_pF: bus capacitance in picofarads
Are you serious?
Are we in the circus?
Quoted 3 lines
I have never seen capital letters used to declare a
variable name. Although checkpatch.pl does not consider this as an issue, is this against everyone's custom or unspoken rules?
I do not really care about checkpatch or any rules as any good rule will have a few exceptions anyway. The rationale here is to follow the science with much longer history than anything related to the computer programming.
Now, since you haven't looked for the existing examples, try this
git grep -n _u[AV]\;
Signature · 2 lines
With Best Regards, Andy Shevchenko