* [PATCH] eeprom: Support pagesize OF device tree property
@ 2015-11-24 19:53 Trent Piepho
2015-11-26 8:07 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Trent Piepho @ 2015-11-24 19:53 UTC (permalink / raw)
To: barebox
Allows specifying the page size when the eeproms are in the device
tree. Same as the Linux kernel device-tree bindings for at24.
Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---
drivers/eeprom/at24.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c
index 76f30e7..d025db8 100644
--- a/drivers/eeprom/at24.c
+++ b/drivers/eeprom/at24.c
@@ -381,6 +381,7 @@ static int at24_probe(struct device_d *dev)
chip = *(struct at24_platform_data *)dev->platform_data;
} else {
unsigned long magic;
+ u32 page_size;
err = dev_get_drvdata(dev, (const void **)&magic);
if (err)
@@ -389,12 +390,17 @@ static int at24_probe(struct device_d *dev)
chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
magic >>= AT24_SIZE_BYTELEN;
chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
- /*
- * This is slow, but we can't know all eeproms, so we better
- * play safe. Specifying custom eeprom-types via platform_data
- * is recommended anyhow.
- */
- chip.page_size = 1;
+ if (dev->device_node &&
+ !of_property_read_u32(dev->device_node, "pagesize", &page_size))
+ chip.page_size = page_size;
+ else {
+ /*
+ * This is slow, but we can't know all eeproms, so we better
+ * play safe. Specifying custom eeprom-types via platform_data
+ * is recommended anyhow.
+ */
+ chip.page_size = 1;
+ }
}
if (!is_power_of_2(chip.byte_len))
--
1.8.3.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-26 8:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-24 19:53 [PATCH] eeprom: Support pagesize OF device tree property Trent Piepho
2015-11-26 8:07 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox