Commit 14374fbb authored by Emmanuel Gil Peyrot's avatar Emmanuel Gil Peyrot Committed by Greg Kroah-Hartman

misc: eeprom_93xx46: Add new 93c56 and 93c66 compatible strings

These two devices have respectively 2048 and 4096 bits of storage,
compared to 1024 for the 93c46.
Reviewed-by: default avatarJonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: default avatarEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Link: https://lore.kernel.org/r/20210511210727.24895-3-linkmauve@linkmauve.frSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4a5ff99b
...@@ -29,14 +29,29 @@ ...@@ -29,14 +29,29 @@
struct eeprom_93xx46_devtype_data { struct eeprom_93xx46_devtype_data {
unsigned int quirks; unsigned int quirks;
unsigned char flags;
};
static const struct eeprom_93xx46_devtype_data at93c46_data = {
.flags = EE_SIZE1K,
};
static const struct eeprom_93xx46_devtype_data at93c56_data = {
.flags = EE_SIZE2K,
};
static const struct eeprom_93xx46_devtype_data at93c66_data = {
.flags = EE_SIZE4K,
}; };
static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = { static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = {
.flags = EE_SIZE1K,
.quirks = EEPROM_93XX46_QUIRK_SINGLE_WORD_READ | .quirks = EEPROM_93XX46_QUIRK_SINGLE_WORD_READ |
EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH, EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH,
}; };
static const struct eeprom_93xx46_devtype_data microchip_93lc46b_data = { static const struct eeprom_93xx46_devtype_data microchip_93lc46b_data = {
.flags = EE_SIZE1K,
.quirks = EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE, .quirks = EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE,
}; };
...@@ -381,8 +396,11 @@ static void select_deassert(void *context) ...@@ -381,8 +396,11 @@ static void select_deassert(void *context)
} }
static const struct of_device_id eeprom_93xx46_of_table[] = { static const struct of_device_id eeprom_93xx46_of_table[] = {
{ .compatible = "eeprom-93xx46", }, { .compatible = "eeprom-93xx46", .data = &at93c46_data, },
{ .compatible = "atmel,at93c46", .data = &at93c46_data, },
{ .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, }, { .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, },
{ .compatible = "atmel,at93c56", .data = &at93c56_data, },
{ .compatible = "atmel,at93c66", .data = &at93c66_data, },
{ .compatible = "microchip,93lc46b", .data = &microchip_93lc46b_data, }, { .compatible = "microchip,93lc46b", .data = &microchip_93lc46b_data, },
{} {}
}; };
...@@ -432,6 +450,7 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi) ...@@ -432,6 +450,7 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi)
const struct eeprom_93xx46_devtype_data *data = of_id->data; const struct eeprom_93xx46_devtype_data *data = of_id->data;
pd->quirks = data->quirks; pd->quirks = data->quirks;
pd->flags |= data->flags;
} }
spi->dev.platform_data = pd; spi->dev.platform_data = pd;
...@@ -461,7 +480,16 @@ static int eeprom_93xx46_probe(struct spi_device *spi) ...@@ -461,7 +480,16 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
if (!edev) if (!edev)
return -ENOMEM; return -ENOMEM;
edev->size = 128; if (pd->flags & EE_SIZE1K)
edev->size = 128;
else if (pd->flags & EE_SIZE2K)
edev->size = 256;
else if (pd->flags & EE_SIZE4K)
edev->size = 512;
else {
dev_err(&spi->dev, "unspecified size\n");
return -EINVAL;
}
if (pd->flags & EE_ADDR8) if (pd->flags & EE_ADDR8)
edev->addrlen = ilog2(edev->size); edev->addrlen = ilog2(edev->size);
...@@ -496,8 +524,9 @@ static int eeprom_93xx46_probe(struct spi_device *spi) ...@@ -496,8 +524,9 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
if (IS_ERR(edev->nvmem)) if (IS_ERR(edev->nvmem))
return PTR_ERR(edev->nvmem); return PTR_ERR(edev->nvmem);
dev_info(&spi->dev, "%d-bit eeprom %s\n", dev_info(&spi->dev, "%d-bit eeprom containing %d bytes %s\n",
(pd->flags & EE_ADDR8) ? 8 : 16, (pd->flags & EE_ADDR8) ? 8 : 16,
edev->size,
(pd->flags & EE_READONLY) ? "(readonly)" : ""); (pd->flags & EE_READONLY) ? "(readonly)" : "");
if (!(pd->flags & EE_READONLY)) { if (!(pd->flags & EE_READONLY)) {
......
...@@ -10,6 +10,9 @@ struct eeprom_93xx46_platform_data { ...@@ -10,6 +10,9 @@ struct eeprom_93xx46_platform_data {
#define EE_ADDR8 0x01 /* 8 bit addr. cfg */ #define EE_ADDR8 0x01 /* 8 bit addr. cfg */
#define EE_ADDR16 0x02 /* 16 bit addr. cfg */ #define EE_ADDR16 0x02 /* 16 bit addr. cfg */
#define EE_READONLY 0x08 /* forbid writing */ #define EE_READONLY 0x08 /* forbid writing */
#define EE_SIZE1K 0x10 /* 1 kb of data, that is a 93xx46 */
#define EE_SIZE2K 0x20 /* 2 kb of data, that is a 93xx56 */
#define EE_SIZE4K 0x40 /* 4 kb of data, that is a 93xx66 */
unsigned int quirks; unsigned int quirks;
/* Single word read transfers only; no sequential read. */ /* Single word read transfers only; no sequential read. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment