mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] eeprom: Add support for 24c1025 EEPROM
@ 2015-11-23 23:40 Trent Piepho
  2015-11-26  8:06 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Trent Piepho @ 2015-11-23 23:40 UTC (permalink / raw)
  To: barebox

This is the Microchip version of the Atmel 24c1024, which is already
supported.  The key difference between them is that the I2C address
bit used to select between the two banks is bit 2 for the 1025 and not
bit 0 as in the 1024.

Add a flag to describe this difference.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---
 drivers/eeprom/at24.c | 8 ++++++--
 include/i2c/at24.h    | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c
index bb2dd53..9c322a9 100644
--- a/drivers/eeprom/at24.c
+++ b/drivers/eeprom/at24.c
@@ -80,7 +80,9 @@ static unsigned io_limit = 128;
  */
 static unsigned write_timeout = 25;
 
+/* number of bits in driver_data reserved for eeprom byte length */
 #define AT24_SIZE_BYTELEN 5
+/* number of bits in driver_data reserved for flags */
 #define AT24_SIZE_FLAGS 8
 
 #define AT24_BITMASK(x) (BIT(x) - 1)
@@ -109,6 +111,7 @@ static struct platform_device_id at24_ids[] = {
 	{ "24c256", AT24_DEVICE_MAGIC(262144 / 8, AT24_FLAG_ADDR16) },
 	{ "24c512", AT24_DEVICE_MAGIC(524288 / 8, AT24_FLAG_ADDR16) },
 	{ "24c1024", AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16) },
+	{ "24c1025", AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16 | AT24_FLAG_BANK_BIT_2) },
 	{ "at24", 0 },
 	{ /* END OF LIST */ }
 };
@@ -423,11 +426,12 @@ static int at24_probe(struct device_d *dev)
 
 	/* use dummy devices for multiple-address chips */
 	for (i = 1; i < num_addresses; i++) {
+		const int shift = (chip.flags & AT24_FLAG_BANK_BIT_2) ? 2 : 0;
 		at24->client[i] = i2c_new_dummy(client->adapter,
-					client->addr + i);
+					client->addr + (i << shift));
 		if (!at24->client[i]) {
 			dev_err(&client->dev, "address 0x%02x unavailable\n",
-					client->addr + i);
+					client->addr + (i << shift));
 			err = -EADDRINUSE;
 			goto err_clients;
 		}
diff --git a/include/i2c/at24.h b/include/i2c/at24.h
index 1013308..44a64a0 100644
--- a/include/i2c/at24.h
+++ b/include/i2c/at24.h
@@ -30,6 +30,7 @@ struct at24_platform_data {
 #define AT24_FLAG_READONLY	0x40	/* sysfs-entry will be read-only */
 #define AT24_FLAG_IRUGO		0x20	/* sysfs-entry will be world-readable */
 #define AT24_FLAG_TAKE8ADDR	0x10	/* take always 8 addresses (24c00) */
+#define AT24_FLAG_BANK_BIT_2	0x08	/* blank select at bit 2 (vs lsb) */
 };
 
 #endif /* _LINUX_AT24_H */
-- 
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

* Re: [PATCH] eeprom: Add support for 24c1025 EEPROM
  2015-11-23 23:40 [PATCH] eeprom: Add support for 24c1025 EEPROM Trent Piepho
@ 2015-11-26  8:06 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-11-26  8:06 UTC (permalink / raw)
  To: Trent Piepho; +Cc: barebox

On Mon, Nov 23, 2015 at 11:40:53PM +0000, Trent Piepho wrote:
> This is the Microchip version of the Atmel 24c1024, which is already
> supported.  The key difference between them is that the I2C address
> bit used to select between the two banks is bit 2 for the 1025 and not
> bit 0 as in the 1024.
> 
> Add a flag to describe this difference.
> 
> Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
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:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-23 23:40 [PATCH] eeprom: Add support for 24c1025 EEPROM Trent Piepho
2015-11-26  8:06 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox