Skip to content

Commit d08aea2

Browse files
fidomaxbrgl
authored andcommitted
eeprom: at24: Add support for 24c1025 EEPROM
Microchip EEPROM 24xx1025 is like a 24c1024. The only 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. Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
1 parent 151a152 commit d08aea2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/misc/eeprom/at24.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct at24_data {
9191
* Some chips tie up multiple I2C addresses; dummy devices reserve
9292
* them for us.
9393
*/
94+
u8 bank_addr_shift;
9495
struct regmap *client_regmaps[];
9596
};
9697

@@ -118,6 +119,7 @@ MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)");
118119
struct at24_chip_data {
119120
u32 byte_len;
120121
u8 flags;
122+
u8 bank_addr_shift;
121123
void (*read_post)(unsigned int off, char *buf, size_t count);
122124
};
123125

@@ -132,6 +134,12 @@ struct at24_chip_data {
132134
.read_post = _read_post, \
133135
}
134136

137+
#define AT24_CHIP_DATA_BS(_name, _len, _flags, _bank_addr_shift) \
138+
static const struct at24_chip_data _name = { \
139+
.byte_len = _len, .flags = _flags, \
140+
.bank_addr_shift = _bank_addr_shift \
141+
}
142+
135143
static void at24_read_post_vaio(unsigned int off, char *buf, size_t count)
136144
{
137145
int i;
@@ -192,6 +200,7 @@ AT24_CHIP_DATA(at24_data_24c128, 131072 / 8, AT24_FLAG_ADDR16);
192200
AT24_CHIP_DATA(at24_data_24c256, 262144 / 8, AT24_FLAG_ADDR16);
193201
AT24_CHIP_DATA(at24_data_24c512, 524288 / 8, AT24_FLAG_ADDR16);
194202
AT24_CHIP_DATA(at24_data_24c1024, 1048576 / 8, AT24_FLAG_ADDR16);
203+
AT24_CHIP_DATA_BS(at24_data_24c1025, 1048576 / 8, AT24_FLAG_ADDR16, 2);
195204
AT24_CHIP_DATA(at24_data_24c2048, 2097152 / 8, AT24_FLAG_ADDR16);
196205
/* identical to 24c08 ? */
197206
AT24_CHIP_DATA(at24_data_INT3499, 8192 / 8, 0);
@@ -220,6 +229,7 @@ static const struct i2c_device_id at24_ids[] = {
220229
{ "24c256", (kernel_ulong_t)&at24_data_24c256 },
221230
{ "24c512", (kernel_ulong_t)&at24_data_24c512 },
222231
{ "24c1024", (kernel_ulong_t)&at24_data_24c1024 },
232+
{ "24c1025", (kernel_ulong_t)&at24_data_24c1025 },
223233
{ "24c2048", (kernel_ulong_t)&at24_data_24c2048 },
224234
{ "at24", 0 },
225235
{ /* END OF LIST */ }
@@ -249,6 +259,7 @@ static const struct of_device_id at24_of_match[] = {
249259
{ .compatible = "atmel,24c256", .data = &at24_data_24c256 },
250260
{ .compatible = "atmel,24c512", .data = &at24_data_24c512 },
251261
{ .compatible = "atmel,24c1024", .data = &at24_data_24c1024 },
262+
{ .compatible = "atmel,24c1025", .data = &at24_data_24c1025 },
252263
{ .compatible = "atmel,24c2048", .data = &at24_data_24c2048 },
253264
{ /* END OF LIST */ },
254265
};
@@ -533,7 +544,8 @@ static int at24_make_dummy_client(struct at24_data *at24, unsigned int index,
533544

534545
dummy_client = devm_i2c_new_dummy_device(&base_client->dev,
535546
base_client->adapter,
536-
base_client->addr + index);
547+
base_client->addr +
548+
(index << at24->bank_addr_shift));
537549
if (IS_ERR(dummy_client))
538550
return PTR_ERR(dummy_client);
539551

@@ -674,6 +686,7 @@ static int at24_probe(struct i2c_client *client)
674686
at24->page_size = page_size;
675687
at24->flags = flags;
676688
at24->read_post = cdata->read_post;
689+
at24->bank_addr_shift = cdata->bank_addr_shift;
677690
at24->num_addresses = num_addresses;
678691
at24->offset_adj = at24_get_offset_adj(flags, byte_len);
679692
at24->client_regmaps[0] = regmap;

0 commit comments

Comments
 (0)