* [PATCH] i2c: rcar_i2c: Enable configuring SCL rise and fall times
@ 2021-08-24 14:10 Adam Ford
2021-09-20 12:21 ` Adam Ford
2021-09-28 6:30 ` Heiko Schocher
0 siblings, 2 replies; 5+ messages in thread
From: Adam Ford @ 2021-08-24 14:10 UTC (permalink / raw)
To: u-boot; +Cc: hs, biju.das.jz, Adam Ford
The Linux i2c driver supports i2c-scl-rising-time-ns,
and i2c-scl-falling-time-ns, but U-Boot uses hard-coded values
for these values.
Update the calculation by fetching them from the device tree if
present and use the previous values as the default if they are
missing.
Signed-off-by: Adam Ford <aford173@gmail.com>
diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c
index 14bb6603d5..d9ece5e3a8 100644
--- a/drivers/i2c/rcar_i2c.c
+++ b/drivers/i2c/rcar_i2c.c
@@ -64,6 +64,8 @@ enum rcar_i2c_type {
struct rcar_i2c_priv {
void __iomem *base;
struct clk clk;
+ u32 fall_ns;
+ u32 rise_ns;
u32 intdelay;
u32 icccr;
enum rcar_i2c_type type;
@@ -278,7 +280,7 @@ static int rcar_i2c_set_speed(struct udevice *dev, uint bus_freq_hz)
* = F[sum * ick / 1000000000]
* = F[(ick / 1000000) * sum / 1000]
*/
- sum = 35 + 200 + priv->intdelay;
+ sum = priv->fall_ns + priv->rise_ns + priv->intdelay;
round = (ick + 500000) / 1000000 * sum;
round = (round + 500) / 1000;
@@ -323,6 +325,10 @@ static int rcar_i2c_probe(struct udevice *dev)
int ret;
priv->base = dev_read_addr_ptr(dev);
+ priv->rise_ns = dev_read_u32_default(dev,
+ "i2c-scl-rising-time-ns", 200);
+ priv->fall_ns = dev_read_u32_default(dev,
+ "i2c-scl-falling-time-ns", 35);
priv->intdelay = dev_read_u32_default(dev,
"i2c-scl-internal-delay-ns", 5);
priv->type = dev_get_driver_data(dev);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: rcar_i2c: Enable configuring SCL rise and fall times
2021-08-24 14:10 [PATCH] i2c: rcar_i2c: Enable configuring SCL rise and fall times Adam Ford
@ 2021-09-20 12:21 ` Adam Ford
2021-09-21 4:13 ` Heiko Schocher
2021-09-28 6:30 ` Heiko Schocher
1 sibling, 1 reply; 5+ messages in thread
From: Adam Ford @ 2021-09-20 12:21 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Heiko Schocher, Biju Das
On Tue, Aug 24, 2021 at 9:10 AM Adam Ford <aford173@gmail.com> wrote:
>
> The Linux i2c driver supports i2c-scl-rising-time-ns,
> and i2c-scl-falling-time-ns, but U-Boot uses hard-coded values
> for these values.
>
> Update the calculation by fetching them from the device tree if
> present and use the previous values as the default if they are
> missing.
>
> Signed-off-by: Adam Ford <aford173@gmail.com>
>
Do I have the right people in copy? I was hoping to get some feedback
on this. My boards use the i2c-scl-rising-time-ns to help properly
set the i2c clocking.
thanks
adam
> diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c
> index 14bb6603d5..d9ece5e3a8 100644
> --- a/drivers/i2c/rcar_i2c.c
> +++ b/drivers/i2c/rcar_i2c.c
> @@ -64,6 +64,8 @@ enum rcar_i2c_type {
> struct rcar_i2c_priv {
> void __iomem *base;
> struct clk clk;
> + u32 fall_ns;
> + u32 rise_ns;
> u32 intdelay;
> u32 icccr;
> enum rcar_i2c_type type;
> @@ -278,7 +280,7 @@ static int rcar_i2c_set_speed(struct udevice *dev, uint bus_freq_hz)
> * = F[sum * ick / 1000000000]
> * = F[(ick / 1000000) * sum / 1000]
> */
> - sum = 35 + 200 + priv->intdelay;
> + sum = priv->fall_ns + priv->rise_ns + priv->intdelay;
> round = (ick + 500000) / 1000000 * sum;
> round = (round + 500) / 1000;
>
> @@ -323,6 +325,10 @@ static int rcar_i2c_probe(struct udevice *dev)
> int ret;
>
> priv->base = dev_read_addr_ptr(dev);
> + priv->rise_ns = dev_read_u32_default(dev,
> + "i2c-scl-rising-time-ns", 200);
> + priv->fall_ns = dev_read_u32_default(dev,
> + "i2c-scl-falling-time-ns", 35);
> priv->intdelay = dev_read_u32_default(dev,
> "i2c-scl-internal-delay-ns", 5);
> priv->type = dev_get_driver_data(dev);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: rcar_i2c: Enable configuring SCL rise and fall times
2021-09-20 12:21 ` Adam Ford
@ 2021-09-21 4:13 ` Heiko Schocher
2021-09-21 4:20 ` Marek Vasut
0 siblings, 1 reply; 5+ messages in thread
From: Heiko Schocher @ 2021-09-21 4:13 UTC (permalink / raw)
To: Adam Ford, U-Boot Mailing List; +Cc: Biju Das, Marek Vasut
Hello Adam,
On 20.09.21 14:21, Adam Ford wrote:
> On Tue, Aug 24, 2021 at 9:10 AM Adam Ford <aford173@gmail.com> wrote:
>>
>> The Linux i2c driver supports i2c-scl-rising-time-ns,
>> and i2c-scl-falling-time-ns, but U-Boot uses hard-coded values
>> for these values.
>>
>> Update the calculation by fetching them from the device tree if
>> present and use the previous values as the default if they are
>> missing.
>>
>> Signed-off-by: Adam Ford <aford173@gmail.com>
>>
> Do I have the right people in copy? I was hoping to get some feedback
> on this. My boards use the i2c-scl-rising-time-ns to help properly
> set the i2c clocking.
No, I think all fine, for me the patch is okay, so:
Reviewed-by: Heiko Schocher <hs@denx.de>
Ah, I see, in patchwork the patch is assigned to Marek... added Marek
to cc.
@Marek: Is it okay for you, if I pickup the patch, when new u-boot
version is out? Else you can pick it up.
Thanks!
bye,
Heiko
>
> thanks
> adam
>
>> diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c
>> index 14bb6603d5..d9ece5e3a8 100644
>> --- a/drivers/i2c/rcar_i2c.c
>> +++ b/drivers/i2c/rcar_i2c.c
>> @@ -64,6 +64,8 @@ enum rcar_i2c_type {
>> struct rcar_i2c_priv {
>> void __iomem *base;
>> struct clk clk;
>> + u32 fall_ns;
>> + u32 rise_ns;
>> u32 intdelay;
>> u32 icccr;
>> enum rcar_i2c_type type;
>> @@ -278,7 +280,7 @@ static int rcar_i2c_set_speed(struct udevice *dev, uint bus_freq_hz)
>> * = F[sum * ick / 1000000000]
>> * = F[(ick / 1000000) * sum / 1000]
>> */
>> - sum = 35 + 200 + priv->intdelay;
>> + sum = priv->fall_ns + priv->rise_ns + priv->intdelay;
>> round = (ick + 500000) / 1000000 * sum;
>> round = (round + 500) / 1000;
>>
>> @@ -323,6 +325,10 @@ static int rcar_i2c_probe(struct udevice *dev)
>> int ret;
>>
>> priv->base = dev_read_addr_ptr(dev);
>> + priv->rise_ns = dev_read_u32_default(dev,
>> + "i2c-scl-rising-time-ns", 200);
>> + priv->fall_ns = dev_read_u32_default(dev,
>> + "i2c-scl-falling-time-ns", 35);
>> priv->intdelay = dev_read_u32_default(dev,
>> "i2c-scl-internal-delay-ns", 5);
>> priv->type = dev_get_driver_data(dev);
>> --
>> 2.25.1
>>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs@denx.de
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: rcar_i2c: Enable configuring SCL rise and fall times
2021-09-21 4:13 ` Heiko Schocher
@ 2021-09-21 4:20 ` Marek Vasut
0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2021-09-21 4:20 UTC (permalink / raw)
To: hs, Adam Ford, U-Boot Mailing List; +Cc: Biju Das
On 9/21/21 6:13 AM, Heiko Schocher wrote:
> Hello Adam,
>
> On 20.09.21 14:21, Adam Ford wrote:
>> On Tue, Aug 24, 2021 at 9:10 AM Adam Ford <aford173@gmail.com> wrote:
>>>
>>> The Linux i2c driver supports i2c-scl-rising-time-ns,
>>> and i2c-scl-falling-time-ns, but U-Boot uses hard-coded values
>>> for these values.
>>>
>>> Update the calculation by fetching them from the device tree if
>>> present and use the previous values as the default if they are
>>> missing.
>>>
>>> Signed-off-by: Adam Ford <aford173@gmail.com>
>>>
>> Do I have the right people in copy? I was hoping to get some feedback
>> on this. My boards use the i2c-scl-rising-time-ns to help properly
>> set the i2c clocking.
>
> No, I think all fine, for me the patch is okay, so:
>
> Reviewed-by: Heiko Schocher <hs@denx.de>
>
> Ah, I see, in patchwork the patch is assigned to Marek... added Marek
> to cc.
>
> @Marek: Is it okay for you, if I pickup the patch, when new u-boot
> version is out? Else you can pick it up.
Looks good, pick it for next please.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: rcar_i2c: Enable configuring SCL rise and fall times
2021-08-24 14:10 [PATCH] i2c: rcar_i2c: Enable configuring SCL rise and fall times Adam Ford
2021-09-20 12:21 ` Adam Ford
@ 2021-09-28 6:30 ` Heiko Schocher
1 sibling, 0 replies; 5+ messages in thread
From: Heiko Schocher @ 2021-09-28 6:30 UTC (permalink / raw)
To: Adam Ford, u-boot; +Cc: biju.das.jz
Hello Adam,
On 24.08.21 16:10, Adam Ford wrote:
> The Linux i2c driver supports i2c-scl-rising-time-ns,
> and i2c-scl-falling-time-ns, but U-Boot uses hard-coded values
> for these values.
>
> Update the calculation by fetching them from the device tree if
> present and use the previous values as the default if they are
> missing.
>
> Signed-off-by: Adam Ford <aford173@gmail.com>
Applied to u-boot-i2c next
Thanks!
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs@denx.de
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-28 6:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 14:10 [PATCH] i2c: rcar_i2c: Enable configuring SCL rise and fall times Adam Ford
2021-09-20 12:21 ` Adam Ford
2021-09-21 4:13 ` Heiko Schocher
2021-09-21 4:20 ` Marek Vasut
2021-09-28 6:30 ` Heiko Schocher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.