Skip to contentSkip to conversation

eeprom: at24: new property

PATCH In review Bartosz Golaszewski 2 participants 5 messages Feb 5, 2019 – Feb 19, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover eeprom: at24: new property

From: Bartosz Golaszewski <[email protected]>

Microchip 24aa02t EEPROM is compatible with Atmel 24c02 except that it's visible on 8 i2c slave addresses. We already support such a use case with hard-coded config for 'atmel,24c00'. Let's add a more flexible device tree property - 'num-addresses' - to the binding document and support it in the driver.

Bartosz Golaszewski (2):
dt-bindings: at24: add the 'num-addresses' property
eeprom: at24: implement support for 'num-addresses' property

 Documentation/devicetree/bindings/eeprom/at24.txt |  3 +++
 drivers/misc/eeprom/at24.c                        | 13 ++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 dt-bindings: at24: add the 'num-addresses' property

From: Bartosz Golaszewski <[email protected]>

Currently the at24 driver only creates additional i2c dummies for atmel,24c00 and it's hard-coded. Some other chips (like for example Microchip's 24AA02T) also take more slave addresses despite being otherwise compatible with already supported variants.

Add a new property to the device tree binding document that defines the total number of i2c slave addresses taken by the device. The addresses are counted starting from the one in the reg property.

---
 Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/eeprom/at24.txt +3 -0
index f9a7c984274c..0e456bbc1213 100644
@@ -75,6 +75,8 @@ Optional properties:
 
   - address-width: number of address bits (one of 8, 16).
 
+  - num-addresses: total number of i2c slave addresses this device takes
+
 Example:
 
 eeprom@52 {
@@ -82,4 +84,5 @@ eeprom@52 {
 	reg = <0x52>;
 	pagesize = <32>;
 	wp-gpios = <&gpio1 3 0>;
+	num-addresses = <8>;
 };
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 eeprom: at24: implement support for 'num-addresses' property

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

If the device node defines 'num-addresses', let it override the default behavior.

---
 drivers/misc/eeprom/at24.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/misc/eeprom/at24.c +8 -5
index b806a403ca46..63aa541c9608 100644
@@ -641,11 +641,14 @@ static int at24_probe(struct i2c_client *client)
 	if (!is_power_of_2(page_size))
 		dev_warn(dev, "page_size looks suspicious (no power of 2)!\n");
 
-	if (flags & AT24_FLAG_TAKE8ADDR)
-		num_addresses = 8;
-	else
-		num_addresses =	DIV_ROUND_UP(byte_len,
-			(flags & AT24_FLAG_ADDR16) ? 65536 : 256);
+	err = device_property_read_u32(dev, "num-addresses", &num_addresses);
+	if (err) {
+		if (flags & AT24_FLAG_TAKE8ADDR)
+			num_addresses = 8;
+		else
+			num_addresses =	DIV_ROUND_UP(byte_len,
+				(flags & AT24_FLAG_ADDR16) ? 65536 : 256);
+	}
 
 	if ((flags & AT24_FLAG_SERIAL) && (flags & AT24_FLAG_MAC)) {
 		dev_err(dev,
Signature · 1 line
2.20.1
#3 lore raw
In reply to Bartosz Golaszewski

wt., 5 lut 2019 o 15:00 Bartosz Golaszewski <[email protected]> napisał(a):

Quoted 13 lines

From: Bartosz Golaszewski <[email protected]>

Microchip 24aa02t EEPROM is compatible with Atmel 24c02 except that it's visible on 8 i2c slave addresses. We already support such a use case with hard-coded config for 'atmel,24c00'. Let's add a more flexible device tree property - 'num-addresses' - to the binding document and support it in the driver.

Bartosz Golaszewski (2):
dt-bindings: at24: add the 'num-addresses' property
eeprom: at24: implement support for 'num-addresses' property

Quoted 7 lines
 Documentation/devicetree/bindings/eeprom/at24.txt |  3 +++
 drivers/misc/eeprom/at24.c                        | 13 ++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

--
2.20.1

If there are no objections, I will apply these in 2 days and include them in the PR for v5.1.

Bart

maintainer Acked-by
#4 lore raw
Quoted 18 lines · Bartosz Golaszewski

wt., 5 lut 2019 o 15:00 Bartosz Golaszewski <[email protected]> napisał(a):

Quoted 17 lines

From: Bartosz Golaszewski <[email protected]>

Microchip 24aa02t EEPROM is compatible with Atmel 24c02 except that it's visible on 8 i2c slave addresses. We already support such a use case with hard-coded config for 'atmel,24c00'. Let's add a more flexible device tree property - 'num-addresses' - to the binding document and support it in the driver.

Bartosz Golaszewski (2):
dt-bindings: at24: add the 'num-addresses' property
eeprom: at24: implement support for 'num-addresses' property

 Documentation/devicetree/bindings/eeprom/at24.txt |  3 +++
 drivers/misc/eeprom/at24.c                        | 13 ++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
Quoted 6 lines
Quoted 3 lines

--
2.20.1

If there are no objections, I will apply these in 2 days and include them in the PR for v5.1.

No objections from me: