i2c: designware-platdrv: get fast/std speed scl high/low count from DT
Subsystems (4)
PATCH 1/1 i2c: designware-platdrv: get fast/std speed scl high/low count from DT
Sometimes, it's convenient to define the scl's high/low count directly, e.g HW people would do some measurement then directly give out the optimum counts. Previously, we solved the sda falling time and scl falling time by i2c_dw_scl_hcnt() and i2c_dw_scl_lcnt(), then put them into dt, but what we really care isn't the sda/scl falling time.
Quoted 1 line
From another side, the
dw_i2c_acpi_configure()on ACPI platform also
get hcnt/lcnt values rather than the sda/scl falling time from ACPI method, we want similar feature for DT platforms.
--- Documentation/devicetree/bindings/i2c/i2c-designware.txt | 16 ++++++++++++++++ drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++++++ 2 files changed, 24 insertions(+)
Documentation/devicetree/bindings/i2c/i2c-designware.txt +16 -0
@@ -20,6 +20,22 @@ Optional properties : - i2c-sda-falling-time-ns : should contain the SDA falling time in nanoseconds. This value which is by default 300ns is used to compute the tHIGH period. + - i2c-ss-scl-high-count : should contain the standard speed i2c clock SCL high + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + + - i2c-ss-scl-low-count : should contain the standard speed i2c clock SCL low + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + + - i2c-fs-scl-high-count : should contain the fast speed i2c clock SCL high + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + + - i2c-fs-scl-low-count : should contain the fast speed i2c clock SCL low + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + Example : i2c at f0000 {
drivers/i2c/busses/i2c-designware-platdrv.c +8 -0
@@ -188,6 +188,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) &dev->scl_falling_time);device_property_read_u32 (&pdev->dev,"clock-frequency" , &clk_freq); +device_property_read_u16 (&pdev->dev,"i2c-ss-scl-high-count" , + &dev->ss_hcnt); +device_property_read_u16 (&pdev->dev,"i2c-ss-scl-low-count" , + &dev->ss_lcnt); +device_property_read_u16 (&pdev->dev,"i2c-fs-scl-high-count" , + &dev->fs_hcnt); +device_property_read_u16 (&pdev->dev,"i2c-fs-scl-low-count" , + &dev->fs_lcnt); }if (has_acpi_companion (&pdev->dev))
Signature · 1 line
2.8.0.rc3
Rob Herring
maintainerQuoted 5 lines · Jisheng Zhang
Sometimes, it's convenient to define the scl's high/low count directly, e.g HW people would do some measurement then directly give out the optimum counts. Previously, we solved the sda falling time and scl falling time by
i2c_dw_scl_hcnt()andi2c_dw_scl_lcnt(), then put them into dt, but what we really care isn't the sda/scl falling time.
This is just so you can put specific clock count instead of converting from nanoseconds with standard properties or you gain some additional control of the timing. If only the former, then I prefer we stick with the common properties.
Quoted 3 lines
From another side, the
dw_i2c_acpi_configure()on ACPI platform also get hcnt/lcnt values rather than the sda/scl falling time from ACPI method, we want similar feature for DT platforms.
That's nice, but not really a reason IMO.
Quoted 6 lines
Signed-off-by Jisheng Zhang <[email protected]>--- Documentation/devicetree/bindings/i2c/i2c-designware.txt | 16 ++++++++++++++++ drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++++++ 2 files changed, 24 insertions(+)
Dear Rob,
Quoted 11 lines · On Thu, 7 Apr 2016 12:57:59 -0500 Rob Herring wrote:
Quoted 5 lines · Jisheng Zhang
Sometimes, it's convenient to define the scl's high/low count directly, e.g HW people would do some measurement then directly give out the optimum counts. Previously, we solved the sda falling time and scl falling time by
i2c_dw_scl_hcnt()andi2c_dw_scl_lcnt(), then put them into dt, but what we really care isn't the sda/scl falling time.This is just so you can put specific clock count instead of converting from nanoseconds with standard properties or you gain some additional control of the timing. If only the former, then I prefer we stick with the common properties.
To be honest, both. Let me show how I gain additional control of the timing with this patch while I can't do this w/o it.
I want the similar high percent of SCL high for both standard-mode and fast-mode. Before this patch, this is not achievable because the parameters to cal the hcnt/lcnt via i2c_dw_scl_hcnt() and i2c_dw_scl_lcnt() are different for standard-mode and fast-mode.
Thanks,
Jisheng
Quoted 13 lines
Quoted 4 lines
From another side, the
dw_i2c_acpi_configure()on ACPI platform also get hcnt/lcnt values rather than the sda/scl falling time from ACPI method, we want similar feature for DT platforms.That's nice, but not really a reason IMO.
Quoted 6 lines
Signed-off-by Jisheng Zhang <[email protected]>--- Documentation/devicetree/bindings/i2c/i2c-designware.txt | 16 ++++++++++++++++ drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++++++ 2 files changed, 24 insertions(+)
Quoted 16 lines · Jisheng Zhang
Dear Rob,
Quoted 11 lines · On Thu, 7 Apr 2016 12:57:59 -0500 Rob Herring wrote:
Quoted 5 lines · Jisheng Zhang
Sometimes, it's convenient to define the scl's high/low count directly, e.g HW people would do some measurement then directly give out the optimum counts. Previously, we solved the sda falling time and scl falling time by
i2c_dw_scl_hcnt()andi2c_dw_scl_lcnt(), then put them into dt, but what we really care isn't the sda/scl falling time.This is just so you can put specific clock count instead of converting from nanoseconds with standard properties or you gain some additional control of the timing. If only the former, then I prefer we stick with the common properties.
Quoted 7 lines
To be honest, both. Let me show how I gain additional control of the timing with this patch while I can't do this w/o it.
I want the similar high percent of SCL high for both standard-mode and fast-mode. Before this patch, this is not achievable because the parameters to cal the hcnt/lcnt via
i2c_dw_scl_hcnt()andi2c_dw_scl_lcnt()are different for standard-mode and fast-mode.
If there is something you can't describe currently, then we can add additional properties to allow you to do what you want. But they should be generic bindings and not a plain value which is custom to this driver.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160424/e39195df/attachment.sig>
Quoted 10 lines · Jisheng Zhang
Sometimes, it's convenient to define the scl's high/low count directly, e.g HW people would do some measurement then directly give out the optimum counts. Previously, we solved the sda falling time and scl falling time by
i2c_dw_scl_hcnt()andi2c_dw_scl_lcnt(), then put them into dt, but what we really care isn't the sda/scl falling time.From another side, the
dw_i2c_acpi_configure()on ACPI platform also get hcnt/lcnt values rather than the sda/scl falling time from ACPI method, we want similar feature for DT platforms.
Instead of duplicating some words maybe better to explicitly define two groups of parameters and one which supersedes the other.
Quoted 55 lines
Signed-off-by Jisheng Zhang <[email protected]>--- Documentation/devicetree/bindings/i2c/i2c-designware.txt | 16 ++++++++++++++++ drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++++++ 2 files changed, 24 insertions(+)Documentation/devicetree/bindings/i2c/i2c-designware.txt +16
-0@@ -20,6 +20,22 @@ Optional properties : - i2c-sda-falling-time-ns : should contain the SDA falling time in nanoseconds. This value which is by default 300ns is used to compute the tHIGH period. + - i2c-ss-scl-high-count : should contain the standard speed i2c clock SCL high + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + + - i2c-ss-scl-low-count : should contain the standard speed i2c clock SCL low + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + + - i2c-fs-scl-high-count : should contain the fast speed i2c clock SCL high + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + + - i2c-fs-scl-low-count : should contain the fast speed i2c clock SCL low + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + Example : i2c at f0000 {drivers/i2c/busses/i2c-designware-platdrv.c +8
-1@@ -188,6 +188,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) &dev->scl_falling_time);device_property_read_u32 (&pdev->dev,"clock-frequency" , &clk_freq); +device_property_read_u16 (&pdev->dev,"i2c-ss-scl-high-count" , + &dev->ss_hcnt); +device_property_read_u16 (&pdev->dev,"i2c-ss-scl-low-count" , + &dev->ss_lcnt); +device_property_read_u16 (&pdev->dev,"i2c-fs-scl-high-count" , + &dev->fs_hcnt); +device_property_read_u16 (&pdev->dev,"i2c-fs-scl-low-count" , + &dev->fs_lcnt); }if (has_acpi_companion (&pdev->dev)) --2.8.0.rc3
Signature · 2 lines
With Best Regards, Andy Shevchenko
Dear Andy,
Quoted 7 lines · On Thu, 7 Apr 2016 21:05:35 +0300 Andy Shevchenko wrote:
Quoted 6 lines · Jisheng Zhang
Sometimes, it's convenient to define the scl's high/low count directly, e.g HW people would do some measurement then directly give out the optimum counts. Previously, we solved the sda falling time and scl falling time by
i2c_dw_scl_hcnt()andi2c_dw_scl_lcnt(), then put them into dt, but what we really care isn't the sda/scl falling time.
Quoted 7 lines
Quoted 4 lines
From another side, the
dw_i2c_acpi_configure()on ACPI platform also get hcnt/lcnt values rather than the sda/scl falling time from ACPI method, we want similar feature for DT platforms.Instead of duplicating some words maybe better to explicitly define two groups of parameters and one which supersedes the other.
I'm sorry, I can't catch your meaning. Could you please kindly give more details? Or examples of "two groups of parameters"
Thanks,
Jisheng
Quoted 59 lines
Quoted 56 lines
Signed-off-by Jisheng Zhang <[email protected]>--- Documentation/devicetree/bindings/i2c/i2c-designware.txt | 16 ++++++++++++++++ drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++++++ 2 files changed, 24 insertions(+)Documentation/devicetree/bindings/i2c/i2c-designware.txt +16
-0@@ -20,6 +20,22 @@ Optional properties : - i2c-sda-falling-time-ns : should contain the SDA falling time in nanoseconds. This value which is by default 300ns is used to compute the tHIGH period. + - i2c-ss-scl-high-count : should contain the standard speed i2c clock SCL high + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + + - i2c-ss-scl-low-count : should contain the standard speed i2c clock SCL low + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + + - i2c-fs-scl-high-count : should contain the fast speed i2c clock SCL high + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + + - i2c-fs-scl-low-count : should contain the fast speed i2c clock SCL low + count. If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time-ns + will be ignored. + Example : i2c at f0000 {drivers/i2c/busses/i2c-designware-platdrv.c +8
-1@@ -188,6 +188,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) &dev->scl_falling_time);device_property_read_u32 (&pdev->dev,"clock-frequency" , &clk_freq); +device_property_read_u16 (&pdev->dev,"i2c-ss-scl-high-count" , + &dev->ss_hcnt); +device_property_read_u16 (&pdev->dev,"i2c-ss-scl-low-count" , + &dev->ss_lcnt); +device_property_read_u16 (&pdev->dev,"i2c-fs-scl-high-count" , + &dev->fs_hcnt); +device_property_read_u16 (&pdev->dev,"i2c-fs-scl-low-count" , + &dev->fs_lcnt); }if (has_acpi_companion (&pdev->dev)) --2.8.0.rc3
Andy Shevchenko
reviewerQuoted 22 lines · Jisheng Zhang
Dear Andy,
Quoted 18 lines · On Thu, 7 Apr 2016 21:05:35 +0300 Andy Shevchenko wrote:
Quoted 15 lines · Jisheng Zhang
Sometimes, it's convenient to define the scl's high/low count directly,
e.g HW people would do some measurement then directly give out the optimum counts. Previously, we solved the sda falling time and scl falling time byi2c_dw_scl_hcnt()andi2c_dw_scl_lcnt(), then put them
into dt, but what we really care isn't the sda/scl falling time.From another side, the
dw_i2c_acpi_configure()on ACPI platform also
get hcnt/lcnt values rather than the sda/scl falling time from ACPI
method, we want similar feature for DT platforms.
Quoted 15 lines
Quoted 2 lines
Instead of duplicating some words maybe better to explicitly define two groups of parameters and one which supersedes the other.
I'm sorry, I can't catch your meaning. Could you please kindly give more
details? Or examples of "two groups of parameters"--- + - i2c-ss-scl-high-count : should contain the standard speed i2c
Quoted 7 lines
Quoted 7 lines
clock SCL high
+ count.If defined, the i2c-scl-falling-time-ns and i2c-sda-falling-time- ns
+ will be ignored.
I'm referring to the above sentence. Something like
There are two groups of values identifying i2c timings:
1. i2c-scl-falling-time-ns and i2c-sda-falling-time-ns
2. *-[hl]cnt
The second group of parameters supersedes the first one.
Quoted 53 lines
Quoted 53 lines
Quoted 51 lines
+
+ - i2c-ss-scl-low-count : should contain the standard speed i2c clock SCL low
+ count. If defined, the i2c-scl-falling-time-ns and i2c-sda- falling-time-ns
+ will be ignored.
+
+ - i2c-fs-scl-high-count : should contain the fast speed i2c clock SCL high
+ count. If defined, the i2c-scl-falling-time-ns and i2c-sda- falling-time-ns
+ will be ignored.
+
+ - i2c-fs-scl-low-count : should contain the fast speed i2c clock SCL low
+ count. If defined, the i2c-scl-falling-time-ns and i2c-sda- falling-time-ns
+ will be ignored.
+
Example :i2c@f0000 {
drivers/i2c/busses/i2c-designware-platdrv.c +0
-0@@ -188,6 +188,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) &dev->scl_falling_time);device_property_read_u32(&pdev->dev, "clock- frequency",
&clk_freq);
+ device_property_read_u16(&pdev->dev, "i2c-ss-scl- high-count",
+ &dev->ss_hcnt); + device_property_read_u16(&pdev->dev, "i2c-ss-scl- low-count",
+ &dev->ss_lcnt); + device_property_read_u16(&pdev->dev, "i2c-fs-scl- high-count",
+ &dev->fs_hcnt); + device_property_read_u16(&pdev->dev, "i2c-fs-scl- low-count",
+ &dev->fs_lcnt); }if (
has_acpi_companion(&pdev->dev))
--
2.8.0.rc3
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy