linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Add at24 functionality to read MAC form different EEPROM offsets
@ 2017-07-06 10:16 Claudiu Beznea
  2017-07-06 10:16 ` [PATCH 1/3] dt-bindings: i2c: eeprom: document all at24 bindings Claudiu Beznea
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Claudiu Beznea @ 2017-07-06 10:16 UTC (permalink / raw)
  To: robh+dt, mark.rutland, nsekhar, david, wsa
  Cc: devicetree, linux-kernel, linux-i2c, nicolas.ferre,
	ludovic.desroches, Claudiu Beznea

Hi all,

Please give feedback on the following approach to extends at24 EEPROM
driver to support reading MAC from different addresses in EEPROM.  This
will allow the at24 driver to be used as a generic driver by different
hardwares.

Thank you,
Claudiu Beznea

Claudiu Beznea (3):
  dt-bindings: i2c: eeprom: document all at24 bindings
  drivers: misc: eeprom: at24: support reading mac eeprom from
    different addresses
  dt-bindings: i2c: eeprom: document "start-offset" binding

 Documentation/devicetree/bindings/eeprom/eeprom.txt | 20 +++++++++++++-------
 drivers/misc/eeprom/at24.c                          |  5 ++++-
 include/linux/platform_data/at24.h                  |  1 +
 3 files changed, 18 insertions(+), 8 deletions(-)

-- 
2.7.4

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

* [PATCH 1/3] dt-bindings: i2c: eeprom: document all at24 bindings
  2017-07-06 10:16 [PATCH 0/3] Add at24 functionality to read MAC form different EEPROM offsets Claudiu Beznea
@ 2017-07-06 10:16 ` Claudiu Beznea
  2017-07-10  3:44   ` Rob Herring
  2017-07-06 10:16 ` [PATCH 2/3] drivers: misc: eeprom: at24: support reading mac eeprom from different addresses Claudiu Beznea
  2017-07-06 10:16 ` [PATCH 3/3] dt-bindings: i2c: eeprom: document "mac-offset" binding Claudiu Beznea
  2 siblings, 1 reply; 8+ messages in thread
From: Claudiu Beznea @ 2017-07-06 10:16 UTC (permalink / raw)
  To: robh+dt, mark.rutland, nsekhar, david, wsa
  Cc: devicetree, linux-kernel, linux-i2c, nicolas.ferre,
	ludovic.desroches, Claudiu Beznea

Document all at24 memories specific bindings.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 Documentation/devicetree/bindings/eeprom/eeprom.txt | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/eeprom/eeprom.txt b/Documentation/devicetree/bindings/eeprom/eeprom.txt
index 5696eb5..a50dc01 100644
--- a/Documentation/devicetree/bindings/eeprom/eeprom.txt
+++ b/Documentation/devicetree/bindings/eeprom/eeprom.txt
@@ -4,9 +4,11 @@ Required properties:
 
   - compatible : should be "<manufacturer>,<type>", like these:
 
-	"atmel,24c00", "atmel,24c01", "atmel,24c02", "atmel,24c04",
-	"atmel,24c08", "atmel,24c16", "atmel,24c32", "atmel,24c64",
-	"atmel,24c128", "atmel,24c256", "atmel,24c512", "atmel,24c1024"
+	"atmel,24c00", "atmel,24c01", "atmel,24cs01", "atmel,24c02", "atmel,24cs02",
+	"atmel,24mac402", "atmel,24mac602", "atmel,spd", "atmel,24c04",
+	"atmel,24cs04", "atmel,24c08", "atmel,24cs08", "atmel,24c16", "atmel,24cs16",
+	"atmel,24c32", "atmel,24cs32", "atmel,24c64", "atmel,24cs64", "atmel,24c128",
+	"atmel,24c256", "atmel,24c512", "atmel,24c1024"
 
 	"catalyst,24c32"
 
@@ -16,10 +18,11 @@ Required properties:
 
 	"renesas,r1ex24002"
 
-	 If there is no specific driver for <manufacturer>, a generic
-	 driver based on <type> is selected. Possible types are:
-	 "24c00", "24c01", "24c02", "24c04", "24c08", "24c16", "24c32", "24c64",
-	 "24c128", "24c256", "24c512", "24c1024", "spd"
+	If there is no specific driver for <manufacturer>, a generic
+	driver based on <type> is selected. Possible types are:
+	"24c00", "24c01", "24cs01", "24c02", "24cs02", "24mac402", "24mac602", "spd",
+	"24c04", "24cs04", "24c08", "24cs08", "24c16", "24cs16", "24c32", "24cs32",
+	"24c64", "24cs64", "24c128", "24c256", "24c512", "24c1024"
 
   - reg : the I2C address of the EEPROM
 
-- 
2.7.4

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

* [PATCH 2/3] drivers: misc: eeprom: at24: support reading mac eeprom from different addresses
  2017-07-06 10:16 [PATCH 0/3] Add at24 functionality to read MAC form different EEPROM offsets Claudiu Beznea
  2017-07-06 10:16 ` [PATCH 1/3] dt-bindings: i2c: eeprom: document all at24 bindings Claudiu Beznea
@ 2017-07-06 10:16 ` Claudiu Beznea
  2017-07-06 10:16 ` [PATCH 3/3] dt-bindings: i2c: eeprom: document "mac-offset" binding Claudiu Beznea
  2 siblings, 0 replies; 8+ messages in thread
From: Claudiu Beznea @ 2017-07-06 10:16 UTC (permalink / raw)
  To: robh+dt, mark.rutland, nsekhar, david, wsa
  Cc: devicetree, linux-kernel, linux-i2c, nicolas.ferre,
	ludovic.desroches, Claudiu Beznea

Add support for reading MAC address from different offsets of EEPROM. The
offset is initialized via device tree. If nothing is given as input the
old value, 0x90, is used. In this way the driver could be used as generic
driver for different vendor memories by only changing the reading offset
via device tree.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/misc/eeprom/at24.c         | 5 ++++-
 include/linux/platform_data/at24.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 764ff5df..53c2b03 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -365,7 +365,7 @@ static ssize_t at24_eeprom_read_mac(struct at24_data *at24, char *buf,
 	memset(msg, 0, sizeof(msg));
 	msg[0].addr = client->addr;
 	msg[0].buf = addrbuf;
-	addrbuf[0] = 0x90 + offset;
+	addrbuf[0] = at24->chip.mac_offset + offset;
 	msg[0].len = 1;
 	msg[1].addr = client->addr;
 	msg[1].flags = I2C_M_RD;
@@ -581,6 +581,9 @@ static void at24_get_pdata(struct device *dev, struct at24_platform_data *chip)
 		 */
 		chip->page_size = 1;
 	}
+	err = device_property_read_u32(dev, "mac-offset", &chip->mac_offset);
+	if (err)
+		chip->mac_offset = 0x90;
 }
 
 static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h
index 271a4e2..4e9523e 100644
--- a/include/linux/platform_data/at24.h
+++ b/include/linux/platform_data/at24.h
@@ -42,6 +42,7 @@
 
 struct at24_platform_data {
 	u32		byte_len;		/* size (sum of all addr) */
+	u32		mac_offset;
 	u16		page_size;		/* for writes */
 	u8		flags;
 #define AT24_FLAG_ADDR16	BIT(7)	/* address pointer is 16 bit */
-- 
2.7.4

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

* [PATCH 3/3] dt-bindings: i2c: eeprom: document "mac-offset" binding
  2017-07-06 10:16 [PATCH 0/3] Add at24 functionality to read MAC form different EEPROM offsets Claudiu Beznea
  2017-07-06 10:16 ` [PATCH 1/3] dt-bindings: i2c: eeprom: document all at24 bindings Claudiu Beznea
  2017-07-06 10:16 ` [PATCH 2/3] drivers: misc: eeprom: at24: support reading mac eeprom from different addresses Claudiu Beznea
@ 2017-07-06 10:16 ` Claudiu Beznea
  2017-07-10  3:46   ` Rob Herring
  2 siblings, 1 reply; 8+ messages in thread
From: Claudiu Beznea @ 2017-07-06 10:16 UTC (permalink / raw)
  To: robh+dt, mark.rutland, nsekhar, david, wsa
  Cc: devicetree, linux-kernel, linux-i2c, nicolas.ferre,
	ludovic.desroches, Claudiu Beznea

Document "mac-offset" binding that will be used by at24 EEPROM driver.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 Documentation/devicetree/bindings/eeprom/eeprom.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/eeprom/eeprom.txt b/Documentation/devicetree/bindings/eeprom/eeprom.txt
index a50dc01..3dd267c 100644
--- a/Documentation/devicetree/bindings/eeprom/eeprom.txt
+++ b/Documentation/devicetree/bindings/eeprom/eeprom.txt
@@ -35,10 +35,13 @@ Optional properties:
 
   - read-only: this parameterless property disables writes to the eeprom
 
+  - mac-offset: offset in EEPROM where MAC address starts
+
 Example:
 
 eeprom@52 {
 	compatible = "atmel,24c32";
 	reg = <0x52>;
 	pagesize = <32>;
+	mac-offset = <0xf8>;
 };
-- 
2.7.4

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

* Re: [PATCH 1/3] dt-bindings: i2c: eeprom: document all at24 bindings
  2017-07-06 10:16 ` [PATCH 1/3] dt-bindings: i2c: eeprom: document all at24 bindings Claudiu Beznea
@ 2017-07-10  3:44   ` Rob Herring
  0 siblings, 0 replies; 8+ messages in thread
From: Rob Herring @ 2017-07-10  3:44 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: mark.rutland, nsekhar, david, wsa, devicetree, linux-kernel,
	linux-i2c, nicolas.ferre, ludovic.desroches

On Thu, Jul 06, 2017 at 01:16:55PM +0300, Claudiu Beznea wrote:
> Document all at24 memories specific bindings.

This will probably conflict with Javier's series "eeprom: at24: Add OF 
device ID table".

Rob

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

* Re: [PATCH 3/3] dt-bindings: i2c: eeprom: document "mac-offset" binding
  2017-07-06 10:16 ` [PATCH 3/3] dt-bindings: i2c: eeprom: document "mac-offset" binding Claudiu Beznea
@ 2017-07-10  3:46   ` Rob Herring
  2017-07-19  9:08     ` m18063
  0 siblings, 1 reply; 8+ messages in thread
From: Rob Herring @ 2017-07-10  3:46 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: mark.rutland, nsekhar, david, wsa, devicetree, linux-kernel,
	linux-i2c, nicolas.ferre, ludovic.desroches

On Thu, Jul 06, 2017 at 01:16:57PM +0300, Claudiu Beznea wrote:
> Document "mac-offset" binding that will be used by at24 EEPROM driver.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> ---
>  Documentation/devicetree/bindings/eeprom/eeprom.txt | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/eeprom/eeprom.txt b/Documentation/devicetree/bindings/eeprom/eeprom.txt
> index a50dc01..3dd267c 100644
> --- a/Documentation/devicetree/bindings/eeprom/eeprom.txt
> +++ b/Documentation/devicetree/bindings/eeprom/eeprom.txt
> @@ -35,10 +35,13 @@ Optional properties:
>  
>    - read-only: this parameterless property disables writes to the eeprom
>  
> +  - mac-offset: offset in EEPROM where MAC address starts
> +

This doesn't scale if you have multiple things you need the offset to, 
and we already have a binding for this. Use the nvmem binding.

Rob

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

* Re: [PATCH 3/3] dt-bindings: i2c: eeprom: document "mac-offset" binding
  2017-07-10  3:46   ` Rob Herring
@ 2017-07-19  9:08     ` m18063
  0 siblings, 0 replies; 8+ messages in thread
From: m18063 @ 2017-07-19  9:08 UTC (permalink / raw)
  To: Rob Herring
  Cc: mark.rutland, nsekhar, david, wsa, devicetree, linux-kernel,
	linux-i2c, nicolas.ferre, ludovic.desroches



On 10.07.2017 06:46, Rob Herring wrote:
> On Thu, Jul 06, 2017 at 01:16:57PM +0300, Claudiu Beznea wrote:
>> Document "mac-offset" binding that will be used by at24 EEPROM driver.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
>> ---
>>  Documentation/devicetree/bindings/eeprom/eeprom.txt | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/eeprom/eeprom.txt b/Documentation/devicetree/bindings/eeprom/eeprom.txt
>> index a50dc01..3dd267c 100644
>> --- a/Documentation/devicetree/bindings/eeprom/eeprom.txt
>> +++ b/Documentation/devicetree/bindings/eeprom/eeprom.txt
>> @@ -35,10 +35,13 @@ Optional properties:
>>  
>>    - read-only: this parameterless property disables writes to the eeprom
>>  
>> +  - mac-offset: offset in EEPROM where MAC address starts
>> +
> 
> This doesn't scale if you have multiple things you need the offset to, 
> and we already have a binding for this. Use the nvmem binding.
Are you talking about nvmem-cells, nvmem-cell-names bindings? Since
at24 is i2c driver, I can only think at it as a nvmem provider. Using these
bindings it will imply, as per my understanding about nvmem subsystem, that
this should also become a nvmem consumer. It looks a little strange to
me but I don't have deep knowledge about subsystem, correct me if I'm wrong.
Please let me know if you are talking about using these bindings and reading
them (just to get the offset passed in "reg" binding) by not passing the nvmem
APIs defined in nvmem core.

Thank you,
Claudiu
> 
> Rob
> 

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

* [PATCH 1/3] dt-bindings: i2c: eeprom: document all at24 bindings
  2017-06-29 11:39 [RFC PATCH 0/3] Add at24 functionality to read form different EEPROM offsets Claudiu Beznea
@ 2017-06-29 11:39 ` Claudiu Beznea
  0 siblings, 0 replies; 8+ messages in thread
From: Claudiu Beznea @ 2017-06-29 11:39 UTC (permalink / raw)
  To: robh+dt, mark.rutland, nsekhar, david, wsa
  Cc: devicetree, linux-kernel, linux-i2c, nicolas.ferre, Claudiu Beznea

Document all at24 memories specific bindings.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 Documentation/devicetree/bindings/eeprom/eeprom.txt | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/eeprom/eeprom.txt b/Documentation/devicetree/bindings/eeprom/eeprom.txt
index 5696eb5..a50dc01 100644
--- a/Documentation/devicetree/bindings/eeprom/eeprom.txt
+++ b/Documentation/devicetree/bindings/eeprom/eeprom.txt
@@ -4,9 +4,11 @@ Required properties:
 
   - compatible : should be "<manufacturer>,<type>", like these:
 
-	"atmel,24c00", "atmel,24c01", "atmel,24c02", "atmel,24c04",
-	"atmel,24c08", "atmel,24c16", "atmel,24c32", "atmel,24c64",
-	"atmel,24c128", "atmel,24c256", "atmel,24c512", "atmel,24c1024"
+	"atmel,24c00", "atmel,24c01", "atmel,24cs01", "atmel,24c02", "atmel,24cs02",
+	"atmel,24mac402", "atmel,24mac602", "atmel,spd", "atmel,24c04",
+	"atmel,24cs04", "atmel,24c08", "atmel,24cs08", "atmel,24c16", "atmel,24cs16",
+	"atmel,24c32", "atmel,24cs32", "atmel,24c64", "atmel,24cs64", "atmel,24c128",
+	"atmel,24c256", "atmel,24c512", "atmel,24c1024"
 
 	"catalyst,24c32"
 
@@ -16,10 +18,11 @@ Required properties:
 
 	"renesas,r1ex24002"
 
-	 If there is no specific driver for <manufacturer>, a generic
-	 driver based on <type> is selected. Possible types are:
-	 "24c00", "24c01", "24c02", "24c04", "24c08", "24c16", "24c32", "24c64",
-	 "24c128", "24c256", "24c512", "24c1024", "spd"
+	If there is no specific driver for <manufacturer>, a generic
+	driver based on <type> is selected. Possible types are:
+	"24c00", "24c01", "24cs01", "24c02", "24cs02", "24mac402", "24mac602", "spd",
+	"24c04", "24cs04", "24c08", "24cs08", "24c16", "24cs16", "24c32", "24cs32",
+	"24c64", "24cs64", "24c128", "24c256", "24c512", "24c1024"
 
   - reg : the I2C address of the EEPROM
 
-- 
2.7.4

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

end of thread, other threads:[~2017-07-19  9:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-06 10:16 [PATCH 0/3] Add at24 functionality to read MAC form different EEPROM offsets Claudiu Beznea
2017-07-06 10:16 ` [PATCH 1/3] dt-bindings: i2c: eeprom: document all at24 bindings Claudiu Beznea
2017-07-10  3:44   ` Rob Herring
2017-07-06 10:16 ` [PATCH 2/3] drivers: misc: eeprom: at24: support reading mac eeprom from different addresses Claudiu Beznea
2017-07-06 10:16 ` [PATCH 3/3] dt-bindings: i2c: eeprom: document "mac-offset" binding Claudiu Beznea
2017-07-10  3:46   ` Rob Herring
2017-07-19  9:08     ` m18063
  -- strict thread matches above, loose matches on Subject: below --
2017-06-29 11:39 [RFC PATCH 0/3] Add at24 functionality to read form different EEPROM offsets Claudiu Beznea
2017-06-29 11:39 ` [PATCH 1/3] dt-bindings: i2c: eeprom: document all at24 bindings Claudiu Beznea

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