Skip to content

Commit a2b3bf4

Browse files
Alan Chiangbrgl
authored andcommitted
eeprom: at24: Add support for address-width property
Provide a flexible way to determine the addressing bits of eeprom. Pass the addressing bits to driver through address-width property. Signed-off-by: Alan Chiang <alanx.chiang@intel.com> Signed-off-by: Andy Yeh <andy.yeh@intel.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
1 parent 21d0405 commit a2b3bf4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/misc/eeprom/at24.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,23 @@ static void at24_properties_to_pdata(struct device *dev,
478478
if (device_property_present(dev, "no-read-rollover"))
479479
chip->flags |= AT24_FLAG_NO_RDROL;
480480

481+
err = device_property_read_u32(dev, "address-width", &val);
482+
if (!err) {
483+
switch (val) {
484+
case 8:
485+
if (chip->flags & AT24_FLAG_ADDR16)
486+
dev_warn(dev, "Override address width to be 8, while default is 16\n");
487+
chip->flags &= ~AT24_FLAG_ADDR16;
488+
break;
489+
case 16:
490+
chip->flags |= AT24_FLAG_ADDR16;
491+
break;
492+
default:
493+
dev_warn(dev, "Bad \"address-width\" property: %u\n",
494+
val);
495+
}
496+
}
497+
481498
err = device_property_read_u32(dev, "size", &val);
482499
if (!err)
483500
chip->byte_len = val;

0 commit comments

Comments
 (0)