Skip to contentSkip to conversation

Add aproperty in at24.c

PATCH RESEND Applied [email protected] 2 participants 4 messages Jul 25, 2018

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

v4 cover Add aproperty in at24.c

From: Alan Chiang <[email protected]>

The RESEND PATCH modifies the commit message and adds the Reviewed-by.

In at24.c, it uses 8-bit addressing by default. In this patch add a property address-width that provides a flexible method to pass the information to the driver.

Alan Chiang (2):
dt-bindings: at24: Add address-width property
eeprom: at24: Add support for address-width property

 Documentation/devicetree/bindings/eeprom/at24.txt |  2 ++
 drivers/misc/eeprom/at24.c                        | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
Signature · 1 line
2.7.4
#1 lore raw

PATCH RESEND v4 1/2 dt-bindings: at24: Add address-width property

From: Alan Chiang <[email protected]>

Currently the only way to use a variant of a supported model with a different address with a different address width is to define a new compatible string and the corresponding chip data structure.

Provide a flexible way to specify the size of the address pointer by defining a new property: address-width.

---
 Documentation/devicetree/bindings/eeprom/at24.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/eeprom/at24.txt +2 -0
index 61d833a..aededdb 100644
@@ -72,6 +72,8 @@ Optional properties:
 
   - wp-gpios: GPIO to which the write-protect pin of the chip is connected.
 
+  - address-width: number of address bits (one of 8, 16).
+
 Example:
 
 eeprom@52 {
Signature · 1 line
2.7.4
#3 lore raw

PATCH RESEND v4 2/2 eeprom: at24: Add support for address-width property

In reply to [email protected]

From: Alan Chiang <[email protected]>

Provide a flexible way to determine the addressing bits of eeprom. Pass the addressing bits to driver through address-width property.

---
 drivers/misc/eeprom/at24.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/misc/eeprom/at24.c +17 -0
index 0c125f2..7ea640b 100644
@@ -478,6 +478,23 @@ static void at24_properties_to_pdata(struct device *dev,
 	if (device_property_present(dev, "no-read-rollover"))
 		chip->flags |= AT24_FLAG_NO_RDROL;
 
+	err = device_property_read_u32(dev, "address-width", &val);
+	if (!err) {
+		switch (val) {
+		case 8:
+			if (chip->flags & AT24_FLAG_ADDR16)
+				dev_warn(dev, "Override address width to be 8, while default is 16\n");
+			chip->flags &= ~AT24_FLAG_ADDR16;
+			break;
+		case 16:
+			chip->flags |= AT24_FLAG_ADDR16;
+			break;
+		default:
+			dev_warn(dev, "Bad \"address-width\" property: %u\n",
+				 val);
+		}
+	}
+
 	err = device_property_read_u32(dev, "size", &val);
 	if (!err)
 		chip->byte_len = val;
Signature · 1 line
2.7.4
#2 lore raw

Re: [RESEND PATCH v4 1/2] dt-bindings: at24: Add address-width property

In reply to [email protected]

2018-07-25 5:20 GMT+02:00 <[email protected]>:

Quoted 4 lines

From: Alan Chiang <[email protected]>

Currently the only way to use a variant of a supported model with a different address with a different address width is to define a

There's some copy-paste problem here. I fixed it.

Quoted 27 lines

new compatible string and the corresponding chip data structure.

Provide a flexible way to specify the size of the address pointer by defining a new property: address-width.

---
 Documentation/devicetree/bindings/eeprom/at24.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/eeprom/at24.txt +2 -1
index 61d833a..aededdb 100644
@@ -72,6 +72,8 @@ Optional properties:
 
   - wp-gpios: GPIO to which the write-protect pin of the chip is connected.
 
+  - address-width: number of address bits (one of 8, 16).
+
 Example:
 
 eeprom@52 {
--
Quoted 2 lines

2.7.4

Applied both to for-next.

Bart