* [RFC 0/9] i2c: add generic support for timing parameters
@ 2015-11-26 22:59 Wolfram Sang
2015-11-26 22:59 ` [RFC 1/9] i2c: document generic DT bindings " Wolfram Sang
` (8 more replies)
0 siblings, 9 replies; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
Here is a patch series adding DT support for timing parameters like raise-time
or falling-time. There is a core function for parsing and an implementation for
the RCar driver how to use it.
This series is still RFC because some documentation is missing. It worked fine
on my Lager board this afternoon. However, since then my Lager board refuses to
boot new kernels, even known working branches with known working configs, so I
assume the current failure is unrelated. Anyway, this is to let you know what I
am up to. Please have a look and comment.
Cheers,
Wolfram
Wolfram Sang (9):
i2c: document generic DT bindings for timing parameters
i2c: add generic routine to parse DT timing information
i2c: rcar: refactor probe function a little
i2c: rcar: switch to i2c generic dt parsing
i2c: rcar: honor additional i2c timings from DT
ARM: shmobile: r8a7790: dtsi: add internal delay for i2c IPs
ARM: shmobile: r8a7791: dtsi: add internal delay for i2c IPs
ARM: shmobile: r8a7794: dtsi: add internal delay for i2c IPs
arm64: renesas: r8a7795: add internal delay for i2c IPs
Documentation/devicetree/bindings/i2c/i2c-rcar.txt | 4 ++
Documentation/devicetree/bindings/i2c/i2c.txt | 31 ++++++++--
arch/arm/boot/dts/r8a7790.dtsi | 4 ++
arch/arm/boot/dts/r8a7791.dtsi | 6 ++
arch/arm/boot/dts/r8a7794.dtsi | 6 ++
arch/arm64/boot/dts/renesas/r8a7795.dtsi | 7 +++
drivers/i2c/busses/i2c-rcar.c | 67 +++++++++++-----------
drivers/i2c/i2c-core.c | 34 +++++++++++
include/linux/i2c.h | 15 +++++
9 files changed, 135 insertions(+), 39 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [RFC 1/9] i2c: document generic DT bindings for timing parameters
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
@ 2015-11-26 22:59 ` Wolfram Sang
2015-11-26 22:59 ` [RFC 2/9] i2c: add generic routine to parse DT timing information Wolfram Sang
` (7 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Also, sort the properties alphabetically and make indentation
consistent. Wording largely taken from i2c-rk3x.txt, thanks guys!
Only "i2c-scl-internal-delay-ns" is new, the rest is used by two drivers
already and was documented in their driver binding documentation.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Documentation/devicetree/bindings/i2c/i2c.txt | 31 ++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt b/Documentation/devicetree/bindings/i2c/i2c.txt
index 8a99150ac3a7fd..a00219f5ee0733 100644
--- a/Documentation/devicetree/bindings/i2c/i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c.txt
@@ -29,12 +29,33 @@ Optional properties
These properties may not be supported by all drivers. However, if a driver
wants to support one of the below features, it should adapt the bindings below.
-- clock-frequency - frequency of bus clock in Hz.
-- wakeup-source - device can be used as a wakeup source.
+- clock-frequency
+ frequency of bus clock in Hz.
-- interrupts - interrupts used by the device.
-- interrupt-names - "irq" and "wakeup" names are recognized by I2C core,
- other names are left to individual drivers.
+- i2c-scl-falling-time-ns
+ Number of nanoseconds the SCL signal takes to fall; t(f) in the I2C
+ specification.
+
+- i2c-scl-internal-delay-ns
+ Number of nanoseconds the IP core additionally needs to setup SCL.
+
+- i2c-scl-rising-time-ns
+ Number of nanoseconds the SCL signal takes to rise; t(r) in the I2C
+ specification.
+
+- i2c-sda-falling-time-ns
+ Number of nanoseconds the SDA signal takes to fall; t(f) in the I2C
+ specification.
+
+- interrupts
+ interrupts used by the device.
+
+- interrupt-names
+ "irq" and "wakeup" names are recognized by I2C core, other names are
+ left to individual drivers.
+
+- wakeup-source
+ device can be used as a wakeup source.
Binding may contain optional "interrupts" property, describing interrupts
used by the device. I2C core will assign "irq" interrupt (or the very first
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC 2/9] i2c: add generic routine to parse DT timing information
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
2015-11-26 22:59 ` [RFC 1/9] i2c: document generic DT bindings " Wolfram Sang
@ 2015-11-26 22:59 ` Wolfram Sang
2015-11-26 22:59 ` [RFC 3/9] i2c: rcar: refactor probe function a little Wolfram Sang
` (6 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Inspired from the i2c-rk3x driver, thanks guys!
FIXME: add documentation
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/i2c/i2c-core.c | 34 ++++++++++++++++++++++++++++++++++
include/linux/i2c.h | 15 +++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 040af5cc8143f1..7543fec4f65b61 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1438,6 +1438,40 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
}
}
+void of_i2c_parse_timings(struct device_node *node, struct i2c_timings *t, bool use_defaults)
+{
+ memset(t, 0, sizeof(*t));
+
+ if (of_property_read_u32(node, "clock-frequency", &t->bus_freq) && use_defaults)
+ t->bus_freq = 100000;
+
+ /*
+ * Read rise and fall time from device tree. If not available, use
+ * the default maximum timing from the specification.
+ */
+ if (of_property_read_u32(node, "i2c-scl-rising-time-ns", &t->scl_rise_ns) && use_defaults) {
+ if (t->bus_freq <= 100000)
+ t->scl_rise_ns = 1000;
+ else if (t->bus_freq <= 400000)
+ t->scl_rise_ns = 300;
+ else
+ t->scl_rise_ns = 120;
+ }
+
+ if (of_property_read_u32(node, "i2c-scl-falling-time-ns", &t->scl_fall_ns) && use_defaults) {
+ if (t->bus_freq <= 400000)
+ t->scl_fall_ns = 300;
+ else
+ t->scl_fall_ns = 120;
+ }
+
+ of_property_read_u32(node, "i2c-scl-internal-delay-ns", &t->scl_int_delay_ns);
+
+ if (of_property_read_u32(node, "i2c-sda-falling-time-ns", &t->sda_fall_ns) && use_defaults)
+ t->sda_fall_ns = t->scl_fall_ns;
+}
+EXPORT_SYMBOL_GPL(of_i2c_parse_timings);
+
static int of_dev_node_match(struct device *dev, void *data)
{
return dev->of_node = data;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 768063baafbf5e..ca28c104ac5fb6 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -413,6 +413,15 @@ struct i2c_algorithm {
#endif
};
+/* FIXME: Add docs */
+struct i2c_timings {
+ u32 bus_freq;
+ u32 scl_rise_ns;
+ u32 scl_fall_ns;
+ u32 scl_int_delay_ns;
+ u32 sda_fall_ns;
+};
+
/**
* struct i2c_bus_recovery_info - I2C bus recovery information
* @recover_bus: Recover routine. Either pass driver's recover_bus() routine, or
@@ -644,6 +653,8 @@ extern struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
/* must call i2c_put_adapter() when done with returned i2c_adapter device */
struct i2c_adapter *of_get_i2c_adapter_by_node(struct device_node *node);
+
+void of_i2c_parse_timings(struct device_node *node, struct i2c_timings *t, bool use_defaults);
#else
static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
@@ -660,6 +671,10 @@ static inline struct i2c_adapter *of_get_i2c_adapter_by_node(struct device_node
{
return NULL;
}
+
+static inline void of_i2c_parse_timings(struct device_node *node, struct i2c_timings *t, bool use_defaults)
+{
+}
#endif /* CONFIG_OF */
#endif /* _LINUX_I2C_H */
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC 3/9] i2c: rcar: refactor probe function a little
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
2015-11-26 22:59 ` [RFC 1/9] i2c: document generic DT bindings " Wolfram Sang
2015-11-26 22:59 ` [RFC 2/9] i2c: add generic routine to parse DT timing information Wolfram Sang
@ 2015-11-26 22:59 ` Wolfram Sang
2015-11-26 22:59 ` [RFC 4/9] i2c: rcar: switch to i2c generic dt parsing Wolfram Sang
` (5 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
The probe function is a little bit messy, something here, something
there. Rework it so that there is some order: first init the private
structure, then the adapter, then do HW init. This also allows us to
remove the device argument of the clock calculation function, because it
now can be deduced from the private structure. Also, shorten some lines
where possible. This is a preparation for further refactoring.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/i2c/busses/i2c-rcar.c | 40 +++++++++++++++++-----------------------
1 file changed, 17 insertions(+), 23 deletions(-)
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 3ed1f0aa5eeb16..d4322a9096786f 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -162,15 +162,11 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
return -EBUSY;
}
-static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,
- u32 bus_speed,
- struct device *dev)
+static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, u32 bus_speed)
{
- u32 scgd, cdf;
- u32 round, ick;
- u32 scl;
- u32 cdf_width;
+ u32 scgd, cdf, round, ick, scl, cdf_width;
unsigned long rate;
+ struct device *dev = rcar_i2c_priv_to_dev(priv);
switch (priv->devtype) {
case I2C_RCAR_GEN1:
@@ -610,21 +606,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
if (IS_ERR(priv->io))
return PTR_ERR(priv->io);
- bus_speed = 100000; /* default 100 kHz */
- of_property_read_u32(dev->of_node, "clock-frequency", &bus_speed);
-
priv->devtype = (enum rcar_i2c_type)of_match_device(rcar_i2c_dt_ids, dev)->data;
-
- pm_runtime_enable(dev);
- pm_runtime_get_sync(dev);
- ret = rcar_i2c_clock_calculate(priv, bus_speed, dev);
- if (ret < 0)
- goto out_pm_put;
-
- rcar_i2c_init(priv);
- pm_runtime_put(dev);
-
- irq = platform_get_irq(pdev, 0);
init_waitqueue_head(&priv->wait);
adap = &priv->adap;
@@ -637,8 +619,20 @@ static int rcar_i2c_probe(struct platform_device *pdev)
i2c_set_adapdata(adap, priv);
strlcpy(adap->name, pdev->name, sizeof(adap->name));
- ret = devm_request_irq(dev, irq, rcar_i2c_irq, 0,
- dev_name(dev), priv);
+ bus_speed = 100000; /* default 100 kHz */
+ of_property_read_u32(dev->of_node, "clock-frequency", &bus_speed);
+
+ pm_runtime_enable(dev);
+ pm_runtime_get_sync(dev);
+ ret = rcar_i2c_clock_calculate(priv, bus_speed);
+ if (ret < 0)
+ goto out_pm_put;
+
+ rcar_i2c_init(priv);
+ pm_runtime_put(dev);
+
+ irq = platform_get_irq(pdev, 0);
+ ret = devm_request_irq(dev, irq, rcar_i2c_irq, 0, dev_name(dev), priv);
if (ret < 0) {
dev_err(dev, "cannot get irq %d\n", irq);
goto out_pm_disable;
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC 4/9] i2c: rcar: switch to i2c generic dt parsing
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
` (2 preceding siblings ...)
2015-11-26 22:59 ` [RFC 3/9] i2c: rcar: refactor probe function a little Wolfram Sang
@ 2015-11-26 22:59 ` Wolfram Sang
2015-11-26 22:59 ` [RFC 5/9] i2c: rcar: honor additional i2c timings from DT Wolfram Sang
` (4 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Switch to the new generic functions. Plain convert, no functionality
added yet.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/i2c/busses/i2c-rcar.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index d4322a9096786f..453ce10132025d 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -162,12 +162,15 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
return -EBUSY;
}
-static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, u32 bus_speed)
+static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timings *t)
{
u32 scgd, cdf, round, ick, scl, cdf_width;
unsigned long rate;
struct device *dev = rcar_i2c_priv_to_dev(priv);
+ /* Fall back to previously used values if not supplied */
+ t->bus_freq = t->bus_freq ?: 100000;
+
switch (priv->devtype) {
case I2C_RCAR_GEN1:
cdf_width = 2;
@@ -230,7 +233,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, u32 bus_speed)
*/
for (scgd = 0; scgd < 0x40; scgd++) {
scl = ick / (20 + (scgd * 8) + round);
- if (scl <= bus_speed)
+ if (scl <= t->bus_freq)
goto scgd_find;
}
dev_err(dev, "it is impossible to calculate best SCL\n");
@@ -238,7 +241,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, u32 bus_speed)
scgd_find:
dev_dbg(dev, "clk %d/%d(%lu), round %u, CDF:0x%x, SCGD: 0x%x\n",
- scl, bus_speed, clk_get_rate(priv->clk), round, cdf, scgd);
+ scl, t->bus_freq, clk_get_rate(priv->clk), round, cdf, scgd);
/* keep icccr value */
priv->icccr = scgd << cdf_width | cdf;
@@ -588,7 +591,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
struct i2c_adapter *adap;
struct resource *res;
struct device *dev = &pdev->dev;
- u32 bus_speed;
+ struct i2c_timings i2c_t;
int irq, ret;
priv = devm_kzalloc(dev, sizeof(struct rcar_i2c_priv), GFP_KERNEL);
@@ -619,12 +622,11 @@ static int rcar_i2c_probe(struct platform_device *pdev)
i2c_set_adapdata(adap, priv);
strlcpy(adap->name, pdev->name, sizeof(adap->name));
- bus_speed = 100000; /* default 100 kHz */
- of_property_read_u32(dev->of_node, "clock-frequency", &bus_speed);
+ of_i2c_parse_timings(dev->of_node, &i2c_t, false);
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
- ret = rcar_i2c_clock_calculate(priv, bus_speed);
+ ret = rcar_i2c_clock_calculate(priv, &i2c_t);
if (ret < 0)
goto out_pm_put;
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC 5/9] i2c: rcar: honor additional i2c timings from DT
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
` (3 preceding siblings ...)
2015-11-26 22:59 ` [RFC 4/9] i2c: rcar: switch to i2c generic dt parsing Wolfram Sang
@ 2015-11-26 22:59 ` Wolfram Sang
2015-11-27 8:04 ` Geert Uytterhoeven
2015-11-26 22:59 ` [RFC 6/9] ARM: shmobile: r8a7790: dtsi: add internal delay for i2c IPs Wolfram Sang
` (3 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Documentation/devicetree/bindings/i2c/i2c-rcar.txt | 4 ++++
drivers/i2c/busses/i2c-rcar.c | 21 ++++++++++++---------
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/Documentation/devicetree/bindings/i2c/i2c-rcar.txt b/Documentation/devicetree/bindings/i2c/i2c-rcar.txt
index ea406eb20fa5ad..95e97223a71c83 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-rcar.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-rcar.txt
@@ -20,6 +20,10 @@ Optional properties:
propoerty indicates the default frequency 100 kHz.
- clocks: clock specifier.
+- i2c-scl-falling-time-ns: see i2c.txt
+- i2c-scl-internal-delay-ns: see i2c.txt
+- i2c-scl-rising-time-ns: see i2c.txt
+
Examples :
i2c0: i2c@e6508000 {
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 453ce10132025d..9465a23bcc91a5 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -164,12 +164,15 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timings *t)
{
- u32 scgd, cdf, round, ick, scl, cdf_width;
+ u32 scgd, cdf, round, ick, sum, scl, cdf_width;
unsigned long rate;
struct device *dev = rcar_i2c_priv_to_dev(priv);
/* Fall back to previously used values if not supplied */
t->bus_freq = t->bus_freq ?: 100000;
+ t->scl_fall_ns = t->scl_fall_ns ?: 35;
+ t->scl_rise_ns = t->scl_rise_ns ?: 200;
+ t->scl_int_delay_ns = t->scl_int_delay_ns ?: 50;
switch (priv->devtype) {
case I2C_RCAR_GEN1:
@@ -193,9 +196,9 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timin
* SCL = ick / (20 + SCGD * 8 + F[(ticf + tr + intd) * ick])
*
* ick : I2C internal clock < 20 MHz
- * ticf : I2C SCL falling time = 35 ns here
- * tr : I2C SCL rising time = 200 ns here
- * intd : LSI internal delay = 50 ns here
+ * ticf : I2C SCL falling time
+ * tr : I2C SCL rising time
+ * intd : LSI internal delay
* clkp : peripheral_clk
* F[] : integer up-valuation
*/
@@ -211,12 +214,12 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timin
* it is impossible to calculate large scale
* number on u32. separate it
*
- * F[(ticf + tr + intd) * ick]
- * = F[(35 + 200 + 50)ns * ick]
- * = F[285 * ick / 1000000000]
- * = F[(ick / 1000000) * 285 / 1000]
+ * F[(ticf + tr + intd) * ick] with sum = (ticf + tr + intd)
+ * = F[sum * ick / 1000000000]
+ * = F[(ick / 1000000) * sum / 1000]
*/
- round = (ick + 500000) / 1000000 * 285;
+ sum = t->scl_fall_ns + t->scl_rise_ns + t->scl_int_delay_ns;
+ round = (ick + 500000) / 1000000 * sum;
round = (round + 500) / 1000;
/*
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC 6/9] ARM: shmobile: r8a7790: dtsi: add internal delay for i2c IPs
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
` (4 preceding siblings ...)
2015-11-26 22:59 ` [RFC 5/9] i2c: rcar: honor additional i2c timings from DT Wolfram Sang
@ 2015-11-26 22:59 ` Wolfram Sang
2015-11-26 22:59 ` [RFC 7/9] ARM: shmobile: r8a7791: " Wolfram Sang
` (2 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
arch/arm/boot/dts/r8a7790.dtsi | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 0612502b4a6d67..cdbebc329cff9a 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -418,6 +418,7 @@
clocks = <&mstp9_clks R8A7790_CLK_I2C0>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <110>;
};
i2c1: i2c@e6518000 {
@@ -429,6 +430,7 @@
clocks = <&mstp9_clks R8A7790_CLK_I2C1>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c2: i2c@e6530000 {
@@ -440,6 +442,7 @@
clocks = <&mstp9_clks R8A7790_CLK_I2C2>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c3: i2c@e6540000 {
@@ -451,6 +454,7 @@
clocks = <&mstp9_clks R8A7790_CLK_I2C3>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <110>;
};
iic0: i2c@e6500000 {
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC 7/9] ARM: shmobile: r8a7791: dtsi: add internal delay for i2c IPs
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
` (5 preceding siblings ...)
2015-11-26 22:59 ` [RFC 6/9] ARM: shmobile: r8a7790: dtsi: add internal delay for i2c IPs Wolfram Sang
@ 2015-11-26 22:59 ` Wolfram Sang
2015-11-27 11:58 ` Sergei Shtylyov
2015-11-26 22:59 ` [RFC 8/9] ARM: shmobile: r8a7794: " Wolfram Sang
2015-11-26 22:59 ` [RFC 9/9] arm64: renesas: r8a7795: " Wolfram Sang
8 siblings, 1 reply; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
arch/arm/boot/dts/r8a7791.dtsi | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
index d79102c0e7d346..57b806f8c28fad 100644
--- a/arch/arm/boot/dts/r8a7791.dtsi
+++ b/arch/arm/boot/dts/r8a7791.dtsi
@@ -408,6 +408,7 @@
clocks = <&mstp9_clks R8A7791_CLK_I2C0>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c1: i2c@e6518000 {
@@ -419,6 +420,7 @@
clocks = <&mstp9_clks R8A7791_CLK_I2C1>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c2: i2c@e6530000 {
@@ -430,6 +432,7 @@
clocks = <&mstp9_clks R8A7791_CLK_I2C2>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c3: i2c@e6540000 {
@@ -441,6 +444,7 @@
clocks = <&mstp9_clks R8A7791_CLK_I2C3>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c4: i2c@e6520000 {
@@ -452,6 +456,7 @@
clocks = <&mstp9_clks R8A7791_CLK_I2C4>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c5: i2c@e6528000 {
@@ -464,6 +469,7 @@
clocks = <&mstp9_clks R8A7791_CLK_I2C5>;
power-domains = <&cpg_clocks>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <110>;
};
i2c6: i2c@e60b0000 {
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC 8/9] ARM: shmobile: r8a7794: dtsi: add internal delay for i2c IPs
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
` (6 preceding siblings ...)
2015-11-26 22:59 ` [RFC 7/9] ARM: shmobile: r8a7791: " Wolfram Sang
@ 2015-11-26 22:59 ` Wolfram Sang
2015-11-26 22:59 ` [RFC 9/9] arm64: renesas: r8a7795: " Wolfram Sang
8 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
arch/arm/boot/dts/r8a7794.dtsi | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/boot/dts/r8a7794.dtsi b/arch/arm/boot/dts/r8a7794.dtsi
index 018ff56470b6da..a6a97c2197c814 100644
--- a/arch/arm/boot/dts/r8a7794.dtsi
+++ b/arch/arm/boot/dts/r8a7794.dtsi
@@ -520,6 +520,7 @@
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c1: i2c@e6518000 {
@@ -531,6 +532,7 @@
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c2: i2c@e6530000 {
@@ -542,6 +544,7 @@
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c3: i2c@e6540000 {
@@ -553,6 +556,7 @@
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c4: i2c@e6520000 {
@@ -564,6 +568,7 @@
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c5: i2c@e6528000 {
@@ -575,6 +580,7 @@
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
mmcif0: mmc@ee200000 {
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC 9/9] arm64: renesas: r8a7795: add internal delay for i2c IPs
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
` (7 preceding siblings ...)
2015-11-26 22:59 ` [RFC 8/9] ARM: shmobile: r8a7794: " Wolfram Sang
@ 2015-11-26 22:59 ` Wolfram Sang
8 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2015-11-26 22:59 UTC (permalink / raw)
To: linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Wolfram Sang, Yoshihiro Shimoda
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
arch/arm64/boot/dts/renesas/r8a7795.dtsi | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index e786343d97e709..08262402fe606f 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -429,6 +429,7 @@
clocks = <&cpg CPG_MOD 931>;
power-domains = <&cpg>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <110>;
};
i2c1: i2c@e6508000 {
@@ -440,6 +441,7 @@
clocks = <&cpg CPG_MOD 930>;
power-domains = <&cpg>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c2: i2c@e6510000 {
@@ -451,6 +453,7 @@
clocks = <&cpg CPG_MOD 929>;
power-domains = <&cpg>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
i2c3: i2c@e66d0000 {
@@ -462,6 +465,7 @@
clocks = <&cpg CPG_MOD 928>;
power-domains = <&cpg>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <110>;
};
i2c4: i2c@e66d8000 {
@@ -473,6 +477,7 @@
clocks = <&cpg CPG_MOD 927>;
power-domains = <&cpg>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <110>;
};
i2c5: i2c@e66e0000 {
@@ -484,6 +489,7 @@
clocks = <&cpg CPG_MOD 919>;
power-domains = <&cpg>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <110>;
};
i2c6: i2c@e66e8000 {
@@ -495,6 +501,7 @@
clocks = <&cpg CPG_MOD 918>;
power-domains = <&cpg>;
status = "disabled";
+ i2c-scl-internal-delay-ns = <6>;
};
rcar_sound: sound@ec500000 {
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [RFC 5/9] i2c: rcar: honor additional i2c timings from DT
2015-11-26 22:59 ` [RFC 5/9] i2c: rcar: honor additional i2c timings from DT Wolfram Sang
@ 2015-11-27 8:04 ` Geert Uytterhoeven
2015-12-03 10:59 ` Wolfram Sang
0 siblings, 1 reply; 13+ messages in thread
From: Geert Uytterhoeven @ 2015-11-27 8:04 UTC (permalink / raw)
To: Wolfram Sang
Cc: Linux I2C, Linux-sh list, Magnus Damm, Simon Horman,
Laurent Pinchart, Yoshihiro Shimoda
On Thu, Nov 26, 2015 at 11:59 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c
> @@ -211,12 +214,12 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timin
> * it is impossible to calculate large scale
> * number on u32. separate it
> *
> - * F[(ticf + tr + intd) * ick]
> - * = F[(35 + 200 + 50)ns * ick]
> - * = F[285 * ick / 1000000000]
> - * = F[(ick / 1000000) * 285 / 1000]
> + * F[(ticf + tr + intd) * ick] with sum = (ticf + tr + intd)
> + * = F[sum * ick / 1000000000]
> + * = F[(ick / 1000000) * sum / 1000]
> */
> - round = (ick + 500000) / 1000000 * 285;
> + sum = t->scl_fall_ns + t->scl_rise_ns + t->scl_int_delay_ns;
> + round = (ick + 500000) / 1000000 * sum;
If you're sure it cannot overflow, doing the "* sum" before the division
improves accuracy.
> round = (round + 500) / 1000;
You can use DIV_ROUND_CLOSEST everywhere, e.g.
round = DIV_ROUND_CLOSEST(round, 1000)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC 7/9] ARM: shmobile: r8a7791: dtsi: add internal delay for i2c IPs
2015-11-26 22:59 ` [RFC 7/9] ARM: shmobile: r8a7791: " Wolfram Sang
@ 2015-11-27 11:58 ` Sergei Shtylyov
0 siblings, 0 replies; 13+ messages in thread
From: Sergei Shtylyov @ 2015-11-27 11:58 UTC (permalink / raw)
To: Wolfram Sang, linux-i2c
Cc: linux-sh, Magnus Damm, Simon Horman, Laurent Pinchart,
Geert Uytterhoeven, Yoshihiro Shimoda
Hello.
On 11/27/2015 1:59 AM, Wolfram Sang wrote:
> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> arch/arm/boot/dts/r8a7791.dtsi | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> index d79102c0e7d346..57b806f8c28fad 100644
> --- a/arch/arm/boot/dts/r8a7791.dtsi
> +++ b/arch/arm/boot/dts/r8a7791.dtsi
> @@ -408,6 +408,7 @@
> clocks = <&mstp9_clks R8A7791_CLK_I2C0>;
> power-domains = <&cpg_clocks>;
> status = "disabled";
> + i2c-scl-internal-delay-ns = <6>;
I suggest that you add the new props before "status".
MBR, Sergei
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC 5/9] i2c: rcar: honor additional i2c timings from DT
2015-11-27 8:04 ` Geert Uytterhoeven
@ 2015-12-03 10:59 ` Wolfram Sang
0 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2015-12-03 10:59 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Linux I2C, Linux-sh list, Magnus Damm, Simon Horman,
Laurent Pinchart, Yoshihiro Shimoda
[-- Attachment #1: Type: text/plain, Size: 506 bytes --]
Hi Geert,
> > - round = (ick + 500000) / 1000000 * 285;
> > + sum = t->scl_fall_ns + t->scl_rise_ns + t->scl_int_delay_ns;
> > + round = (ick + 500000) / 1000000 * sum;
>
> If you're sure it cannot overflow, doing the "* sum" before the division
> improves accuracy.
Thanks for the input. In this patch, however, I intentionally did not
change the formula but only replaced the constants with the now user
supplied values. Everything else should be a separate patch IMO.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-12-03 10:59 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-26 22:59 [RFC 0/9] i2c: add generic support for timing parameters Wolfram Sang
2015-11-26 22:59 ` [RFC 1/9] i2c: document generic DT bindings " Wolfram Sang
2015-11-26 22:59 ` [RFC 2/9] i2c: add generic routine to parse DT timing information Wolfram Sang
2015-11-26 22:59 ` [RFC 3/9] i2c: rcar: refactor probe function a little Wolfram Sang
2015-11-26 22:59 ` [RFC 4/9] i2c: rcar: switch to i2c generic dt parsing Wolfram Sang
2015-11-26 22:59 ` [RFC 5/9] i2c: rcar: honor additional i2c timings from DT Wolfram Sang
2015-11-27 8:04 ` Geert Uytterhoeven
2015-12-03 10:59 ` Wolfram Sang
2015-11-26 22:59 ` [RFC 6/9] ARM: shmobile: r8a7790: dtsi: add internal delay for i2c IPs Wolfram Sang
2015-11-26 22:59 ` [RFC 7/9] ARM: shmobile: r8a7791: " Wolfram Sang
2015-11-27 11:58 ` Sergei Shtylyov
2015-11-26 22:59 ` [RFC 8/9] ARM: shmobile: r8a7794: " Wolfram Sang
2015-11-26 22:59 ` [RFC 9/9] arm64: renesas: r8a7795: " Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).