All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] i2c: enable buses to save their clock frequency in adapter
@ 2018-12-10  8:41 ` Tudor.Ambarus
  0 siblings, 0 replies; 11+ messages in thread
From: Tudor.Ambarus @ 2018-12-10  8:41 UTC (permalink / raw)
  To: wsa
  Cc: Nicolas.Ferre, Ludovic.Desroches, alexandre.belloni, linux-i2c,
	linux-arm-kernel, linux-kernel, Tudor.Ambarus

From: Tudor Ambarus <tudor.ambarus@microchip.com>

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in the device tree, the buses __usually__ assume it's 100kHZ
(see altera, at91, axxia, etc.). Broadcom uses a 375kHZ default
clock-frequency, so the default clock frequency varies from bus to bus.

There are i2c clients that need to know the bus clock frequency in order to
compute their wake token (see atecc508a i2c client).

The clock-frequency value has to be propagated to the i2c clients, otherwise,
if they will not find the i2c bus clock frequency in the device tree, they
will have to make their own assumption of the clock frequency.

Spare the i2c clients of making wrong assumptions of the i2c bus clock
frequency and enable the buses to save their clock frequency in adapter.

v2: fix typo in R-b tag
since rfc: reword commit messages

Tudor Ambarus (2):
  i2c: enable buses to save their clock frequency in adapter
  i2c: at91: Save the bus clock frequency in adapter

 drivers/i2c/busses/i2c-at91.c | 1 +
 include/linux/i2c.h           | 1 +
 2 files changed, 2 insertions(+)

-- 
2.9.4


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

* [PATCH v2 0/2] i2c: enable buses to save their clock frequency in adapter
@ 2018-12-10  8:41 ` Tudor.Ambarus
  0 siblings, 0 replies; 11+ messages in thread
From: Tudor.Ambarus @ 2018-12-10  8:41 UTC (permalink / raw)
  To: wsa
  Cc: Nicolas.Ferre, Ludovic.Desroches, alexandre.belloni, linux-i2c,
	linux-arm-kernel, linux-kernel, Tudor.Ambarus

From: Tudor Ambarus <tudor.ambarus@microchip.com>

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in the device tree, the buses __usually__ assume it's 100kHZ
(see altera, at91, axxia, etc.). Broadcom uses a 375kHZ default
clock-frequency, so the default clock frequency varies from bus to bus.

There are i2c clients that need to know the bus clock frequency in order to
compute their wake token (see atecc508a i2c client).

The clock-frequency value has to be propagated to the i2c clients, otherwise,
if they will not find the i2c bus clock frequency in the device tree, they
will have to make their own assumption of the clock frequency.

Spare the i2c clients of making wrong assumptions of the i2c bus clock
frequency and enable the buses to save their clock frequency in adapter.

v2: fix typo in R-b tag
since rfc: reword commit messages

Tudor Ambarus (2):
  i2c: enable buses to save their clock frequency in adapter
  i2c: at91: Save the bus clock frequency in adapter

 drivers/i2c/busses/i2c-at91.c | 1 +
 include/linux/i2c.h           | 1 +
 2 files changed, 2 insertions(+)

-- 
2.9.4

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

* [PATCH v2 0/2] i2c: enable buses to save their clock frequency in adapter
@ 2018-12-10  8:41 ` Tudor.Ambarus
  0 siblings, 0 replies; 11+ messages in thread
From: Tudor.Ambarus @ 2018-12-10  8:41 UTC (permalink / raw)
  To: wsa
  Cc: alexandre.belloni, Tudor.Ambarus, linux-kernel,
	Ludovic.Desroches, linux-i2c, linux-arm-kernel

From: Tudor Ambarus <tudor.ambarus@microchip.com>

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in the device tree, the buses __usually__ assume it's 100kHZ
(see altera, at91, axxia, etc.). Broadcom uses a 375kHZ default
clock-frequency, so the default clock frequency varies from bus to bus.

There are i2c clients that need to know the bus clock frequency in order to
compute their wake token (see atecc508a i2c client).

The clock-frequency value has to be propagated to the i2c clients, otherwise,
if they will not find the i2c bus clock frequency in the device tree, they
will have to make their own assumption of the clock frequency.

Spare the i2c clients of making wrong assumptions of the i2c bus clock
frequency and enable the buses to save their clock frequency in adapter.

v2: fix typo in R-b tag
since rfc: reword commit messages

Tudor Ambarus (2):
  i2c: enable buses to save their clock frequency in adapter
  i2c: at91: Save the bus clock frequency in adapter

 drivers/i2c/busses/i2c-at91.c | 1 +
 include/linux/i2c.h           | 1 +
 2 files changed, 2 insertions(+)

-- 
2.9.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 1/2] i2c: enable buses to save their clock frequency in adapter
  2018-12-10  8:41 ` Tudor.Ambarus
  (?)
@ 2018-12-10  8:41   ` Tudor.Ambarus
  -1 siblings, 0 replies; 11+ messages in thread
From: Tudor.Ambarus @ 2018-12-10  8:41 UTC (permalink / raw)
  To: wsa
  Cc: Nicolas.Ferre, Ludovic.Desroches, alexandre.belloni, linux-i2c,
	linux-arm-kernel, linux-kernel, Tudor.Ambarus

From: Tudor Ambarus <tudor.ambarus@microchip.com>

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in the device tree, the buses __usually__ assume it's 100kHZ
(see altera, at91, axxia, etc.). Broadcom uses a 375kHZ default
clock-frequency, so the default clock frequency varies from bus to bus.

There are i2c clients that need to know the bus clock frequency in order to
compute their wake token (see atecc508a i2c client).

The clock-frequency value has to be propagated to the i2c clients, otherwise,
if they will not find the i2c bus clock frequency in the device tree, they
will have to make their own assumption of the clock frequency.

Spare the i2c clients of making wrong assumptions of the i2c bus clock
frequency and enable the buses to save their clock frequency in adapter.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
v2: fix typo in R-b tag

 include/linux/i2c.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 65b4eaed1d96..f238da204c49 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -677,6 +677,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] 11+ messages in thread

* [PATCH v2 1/2] i2c: enable buses to save their clock frequency in adapter
@ 2018-12-10  8:41   ` Tudor.Ambarus
  0 siblings, 0 replies; 11+ messages in thread
From: Tudor.Ambarus @ 2018-12-10  8:41 UTC (permalink / raw)
  To: wsa
  Cc: Nicolas.Ferre, Ludovic.Desroches, alexandre.belloni, linux-i2c,
	linux-arm-kernel, linux-kernel, Tudor.Ambarus

From: Tudor Ambarus <tudor.ambarus@microchip.com>

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in the device tree, the buses __usually__ assume it's 100kHZ
(see altera, at91, axxia, etc.). Broadcom uses a 375kHZ default
clock-frequency, so the default clock frequency varies from bus to bus.

There are i2c clients that need to know the bus clock frequency in order to
compute their wake token (see atecc508a i2c client).

The clock-frequency value has to be propagated to the i2c clients, otherwise,
if they will not find the i2c bus clock frequency in the device tree, they
will have to make their own assumption of the clock frequency.

Spare the i2c clients of making wrong assumptions of the i2c bus clock
frequency and enable the buses to save their clock frequency in adapter.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
v2: fix typo in R-b tag

 include/linux/i2c.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 65b4eaed1d96..f238da204c49 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -677,6 +677,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] 11+ messages in thread

* [PATCH v2 1/2] i2c: enable buses to save their clock frequency in adapter
@ 2018-12-10  8:41   ` Tudor.Ambarus
  0 siblings, 0 replies; 11+ messages in thread
From: Tudor.Ambarus @ 2018-12-10  8:41 UTC (permalink / raw)
  To: wsa
  Cc: alexandre.belloni, Tudor.Ambarus, linux-kernel,
	Ludovic.Desroches, linux-i2c, linux-arm-kernel

From: Tudor Ambarus <tudor.ambarus@microchip.com>

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in the device tree, the buses __usually__ assume it's 100kHZ
(see altera, at91, axxia, etc.). Broadcom uses a 375kHZ default
clock-frequency, so the default clock frequency varies from bus to bus.

There are i2c clients that need to know the bus clock frequency in order to
compute their wake token (see atecc508a i2c client).

The clock-frequency value has to be propagated to the i2c clients, otherwise,
if they will not find the i2c bus clock frequency in the device tree, they
will have to make their own assumption of the clock frequency.

Spare the i2c clients of making wrong assumptions of the i2c bus clock
frequency and enable the buses to save their clock frequency in adapter.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
v2: fix typo in R-b tag

 include/linux/i2c.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 65b4eaed1d96..f238da204c49 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -677,6 +677,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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 2/2] i2c: at91: Save the bus clock frequency in adapter
  2018-12-10  8:41 ` Tudor.Ambarus
  (?)
@ 2018-12-10  8:41   ` Tudor.Ambarus
  -1 siblings, 0 replies; 11+ messages in thread
From: Tudor.Ambarus @ 2018-12-10  8:41 UTC (permalink / raw)
  To: wsa
  Cc: Nicolas.Ferre, Ludovic.Desroches, alexandre.belloni, linux-i2c,
	linux-arm-kernel, linux-kernel, Tudor.Ambarus

From: Tudor Ambarus <tudor.ambarus@microchip.com>

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in the device tree, the buses __usually__ assume it's 100kHZ
(see altera, at91, axxia, etc.). Broadcom uses a 375kHZ default
clock-frequency, so the default clock frequency varies from bus to bus.

There are i2c clients that need to know the bus clock frequency in order to
compute their wake token (see atecc508a i2c client).

The clock-frequency value has to be propagated to the i2c clients, otherwise,
if they will not find the i2c bus clock frequency in the device tree, they
will have to make their own assumption of the clock frequency.

Spare the i2c clients of making wrong assumptions of the i2c bus clock
frequency and provide the bus clock frequency in adapter.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
v2: no change

 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 3f3e8b3bf5ff..9aa0937817ac 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -1124,6 +1124,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] 11+ messages in thread

* [PATCH v2 2/2] i2c: at91: Save the bus clock frequency in adapter
@ 2018-12-10  8:41   ` Tudor.Ambarus
  0 siblings, 0 replies; 11+ messages in thread
From: Tudor.Ambarus @ 2018-12-10  8:41 UTC (permalink / raw)
  To: wsa
  Cc: Nicolas.Ferre, Ludovic.Desroches, alexandre.belloni, linux-i2c,
	linux-arm-kernel, linux-kernel, Tudor.Ambarus

From: Tudor Ambarus <tudor.ambarus@microchip.com>

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in the device tree, the buses __usually__ assume it's 100kHZ
(see altera, at91, axxia, etc.). Broadcom uses a 375kHZ default
clock-frequency, so the default clock frequency varies from bus to bus.

There are i2c clients that need to know the bus clock frequency in order to
compute their wake token (see atecc508a i2c client).

The clock-frequency value has to be propagated to the i2c clients, otherwise,
if they will not find the i2c bus clock frequency in the device tree, they
will have to make their own assumption of the clock frequency.

Spare the i2c clients of making wrong assumptions of the i2c bus clock
frequency and provide the bus clock frequency in adapter.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
v2: no change

 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 3f3e8b3bf5ff..9aa0937817ac 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -1124,6 +1124,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] 11+ messages in thread

* [PATCH v2 2/2] i2c: at91: Save the bus clock frequency in adapter
@ 2018-12-10  8:41   ` Tudor.Ambarus
  0 siblings, 0 replies; 11+ messages in thread
From: Tudor.Ambarus @ 2018-12-10  8:41 UTC (permalink / raw)
  To: wsa
  Cc: alexandre.belloni, Tudor.Ambarus, linux-kernel,
	Ludovic.Desroches, linux-i2c, linux-arm-kernel

From: Tudor Ambarus <tudor.ambarus@microchip.com>

The clock-frequency property is not mandatory for the i2c buses. If it's
not present in the device tree, the buses __usually__ assume it's 100kHZ
(see altera, at91, axxia, etc.). Broadcom uses a 375kHZ default
clock-frequency, so the default clock frequency varies from bus to bus.

There are i2c clients that need to know the bus clock frequency in order to
compute their wake token (see atecc508a i2c client).

The clock-frequency value has to be propagated to the i2c clients, otherwise,
if they will not find the i2c bus clock frequency in the device tree, they
will have to make their own assumption of the clock frequency.

Spare the i2c clients of making wrong assumptions of the i2c bus clock
frequency and provide the bus clock frequency in adapter.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
v2: no change

 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 3f3e8b3bf5ff..9aa0937817ac 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -1124,6 +1124,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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 1/2] i2c: enable buses to save their clock frequency in adapter
  2018-12-10  8:41   ` Tudor.Ambarus
@ 2019-03-24 22:09     ` Wolfram Sang
  -1 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2019-03-24 22:09 UTC (permalink / raw)
  To: Tudor.Ambarus
  Cc: Nicolas.Ferre, Ludovic.Desroches, alexandre.belloni, linux-i2c,
	linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 846 bytes --]

Hi Tudor,

thanks for your patience! Now that the at91 refactoring for the I2C
slave support is merged, we can keep going forward with your patches. As
I told you personally, I am positive in general about this change.

> +	u32 bus_freq_hz;

Why not unsigned int?

I also think we should have accessor functions for this new member. They
will be very simple currently because we don't really support changing
the bus frequency at runtime. However, I can see that it could be added
somewhen on top of this change, and then we need to extend the accessor
functions with some locking.

For now, I think this can be solved with simple policy: The value has to
be set before calling i2c_add_adapter(). Also, we should define that '0'
means 'value not set'.

So far about my thoughts. Any more comments from the list are welcome!

Thanks,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2 1/2] i2c: enable buses to save their clock frequency in adapter
@ 2019-03-24 22:09     ` Wolfram Sang
  0 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2019-03-24 22:09 UTC (permalink / raw)
  To: Tudor.Ambarus
  Cc: alexandre.belloni, linux-kernel, Ludovic.Desroches, linux-i2c,
	linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 846 bytes --]

Hi Tudor,

thanks for your patience! Now that the at91 refactoring for the I2C
slave support is merged, we can keep going forward with your patches. As
I told you personally, I am positive in general about this change.

> +	u32 bus_freq_hz;

Why not unsigned int?

I also think we should have accessor functions for this new member. They
will be very simple currently because we don't really support changing
the bus frequency at runtime. However, I can see that it could be added
somewhen on top of this change, and then we need to extend the accessor
functions with some locking.

For now, I think this can be solved with simple policy: The value has to
be set before calling i2c_add_adapter(). Also, we should define that '0'
means 'value not set'.

So far about my thoughts. Any more comments from the list are welcome!

Thanks,

   Wolfram


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-03-24 22:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10  8:41 [PATCH v2 0/2] i2c: enable buses to save their clock frequency in adapter Tudor.Ambarus
2018-12-10  8:41 ` Tudor.Ambarus
2018-12-10  8:41 ` Tudor.Ambarus
2018-12-10  8:41 ` [PATCH v2 1/2] " Tudor.Ambarus
2018-12-10  8:41   ` Tudor.Ambarus
2018-12-10  8:41   ` Tudor.Ambarus
2019-03-24 22:09   ` Wolfram Sang
2019-03-24 22:09     ` Wolfram Sang
2018-12-10  8:41 ` [PATCH v2 2/2] i2c: at91: Save the bus " Tudor.Ambarus
2018-12-10  8:41   ` Tudor.Ambarus
2018-12-10  8:41   ` Tudor.Ambarus

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.