linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 1/2] i2c: add bus_freq_hz in i2c_adapter
@ 2018-03-26 11:19 Tudor Ambarus
  2018-03-26 11:19 ` [RFC PATCH 2/2] i2c: at91: provide bus_freq_hz Tudor Ambarus
  2018-04-18  7:59 ` [RFC PATCH 1/2] i2c: add bus_freq_hz in i2c_adapter Tudor Ambarus
  0 siblings, 2 replies; 4+ messages in thread
From: Tudor Ambarus @ 2018-03-26 11:19 UTC (permalink / raw)
  To: wsa, ludovic.desroches, nicolas.ferre, alexandre.belloni,
	linux-i2c, linux-arm-kernel
  Cc: Tudor Ambarus

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in device tree, the buses usually asume that it is 100kHZ.
There are i2c clients that need to know the i2c bus frequency in order to
compute their wake token. Spare the clients of making (wrong) assumptions
and save the bus frequency in the i2c_adapter structure.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
 include/linux/i2c.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 44ad14e..7a1f26e 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -671,6 +671,7 @@ struct i2c_adapter {
 	struct rt_mutex bus_lock;
 	struct rt_mutex mux_lock;
 
+	u32 bus_freq_hz;
 	int timeout;			/* in jiffies */
 	int retries;
 	struct device dev;		/* the adapter device */
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RFC PATCH 2/2] i2c: at91: provide bus_freq_hz
  2018-03-26 11:19 [RFC PATCH 1/2] i2c: add bus_freq_hz in i2c_adapter Tudor Ambarus
@ 2018-03-26 11:19 ` Tudor Ambarus
  2018-04-04 15:34   ` Ludovic Desroches
  2018-04-18  7:59 ` [RFC PATCH 1/2] i2c: add bus_freq_hz in i2c_adapter Tudor Ambarus
  1 sibling, 1 reply; 4+ messages in thread
From: Tudor Ambarus @ 2018-03-26 11:19 UTC (permalink / raw)
  To: wsa, ludovic.desroches, nicolas.ferre, alexandre.belloni,
	linux-i2c, linux-arm-kernel
  Cc: Tudor Ambarus

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in device tree, the buses usually assume that is 100kHZ.
There are i2c clients that need to know the clock frequency in order to
compute their wake token. Spare the clients of making (wrong) assumptions
and provide the bus frequency in adapter.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
 drivers/i2c/busses/i2c-at91.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index bfd1fdf..d3cd84e 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -1116,6 +1116,7 @@ static int at91_twi_probe(struct platform_device *pdev)
 	dev->adapter.quirks = &at91_twi_quirks;
 	dev->adapter.dev.parent = dev->dev;
 	dev->adapter.nr = pdev->id;
+	dev->adapter.bus_freq_hz = bus_clk_rate;
 	dev->adapter.timeout = AT91_I2C_TIMEOUT;
 	dev->adapter.dev.of_node = pdev->dev.of_node;
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH 2/2] i2c: at91: provide bus_freq_hz
  2018-03-26 11:19 ` [RFC PATCH 2/2] i2c: at91: provide bus_freq_hz Tudor Ambarus
@ 2018-04-04 15:34   ` Ludovic Desroches
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Desroches @ 2018-04-04 15:34 UTC (permalink / raw)
  To: Tudor Ambarus
  Cc: alexandre.belloni, wsa, ludovic.desroches, linux-i2c,
	linux-arm-kernel

On Mon, Mar 26, 2018 at 02:19:27PM +0300, Tudor Ambarus wrote:
> The clock-frequency property is not mandatory for the i2c buses. If it's
> not present in device tree, the buses usually assume that is 100kHZ.
> There are i2c clients that need to know the clock frequency in order to
> compute their wake token. Spare the clients of making (wrong) assumptions
> and provide the bus frequency in adapter.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>

> ---
>  drivers/i2c/busses/i2c-at91.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index bfd1fdf..d3cd84e 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -1116,6 +1116,7 @@ static int at91_twi_probe(struct platform_device *pdev)
>  	dev->adapter.quirks = &at91_twi_quirks;
>  	dev->adapter.dev.parent = dev->dev;
>  	dev->adapter.nr = pdev->id;
> +	dev->adapter.bus_freq_hz = bus_clk_rate;
>  	dev->adapter.timeout = AT91_I2C_TIMEOUT;
>  	dev->adapter.dev.of_node = pdev->dev.of_node;
>  
> -- 
> 2.9.4
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH 1/2] i2c: add bus_freq_hz in i2c_adapter
  2018-03-26 11:19 [RFC PATCH 1/2] i2c: add bus_freq_hz in i2c_adapter Tudor Ambarus
  2018-03-26 11:19 ` [RFC PATCH 2/2] i2c: at91: provide bus_freq_hz Tudor Ambarus
@ 2018-04-18  7:59 ` Tudor Ambarus
  1 sibling, 0 replies; 4+ messages in thread
From: Tudor Ambarus @ 2018-04-18  7:59 UTC (permalink / raw)
  To: wsa, ludovic.desroches, nicolas.ferre, alexandre.belloni,
	linux-i2c, linux-arm-kernel

ping

On 03/26/2018 02:19 PM, Tudor Ambarus wrote:
> The clock-frequency property is not mandatory for the i2c buses. If it's
> not present in device tree, the buses usually asume that it is 100kHZ.
> There are i2c clients that need to know the i2c bus frequency in order to
> compute their wake token. Spare the clients of making (wrong) assumptions
> and save the bus frequency in the i2c_adapter structure.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> ---
>   include/linux/i2c.h | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index 44ad14e..7a1f26e 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -671,6 +671,7 @@ struct i2c_adapter {
>   	struct rt_mutex bus_lock;
>   	struct rt_mutex mux_lock;
>   
> +	u32 bus_freq_hz;
>   	int timeout;			/* in jiffies */
>   	int retries;
>   	struct device dev;		/* the adapter device */
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-18  7:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-26 11:19 [RFC PATCH 1/2] i2c: add bus_freq_hz in i2c_adapter Tudor Ambarus
2018-03-26 11:19 ` [RFC PATCH 2/2] i2c: at91: provide bus_freq_hz Tudor Ambarus
2018-04-04 15:34   ` Ludovic Desroches
2018-04-18  7:59 ` [RFC PATCH 1/2] i2c: add bus_freq_hz in i2c_adapter Tudor Ambarus

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).