mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 19:00:25 +00:00
misc: eeprom_93xx46: Add quirk to support Microchip 93LC46B eeprom
[ Upstream commit f6f1f8e6e3
]
A dummy zero bit is sent preceding the data during a read transfer by the
Microchip 93LC46B eeprom (section 2.7 of[1]). This results in right shift
of data during a read. In order to ignore this bit a quirk can be added to
send an extra zero bit after the read address.
Add a quirk to ignore the zero bit sent before data by adding a zero bit
after the read address.
[1] - https://www.mouser.com/datasheet/2/268/20001749K-277859.pdf
Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
Link: https://lore.kernel.org/r/20210105105817.17644-3-a-govindraju@ti.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
2fc01226c2
commit
eece8fe5eb
2 changed files with 17 additions and 0 deletions
|
@ -35,6 +35,10 @@ static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = {
|
||||||
EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH,
|
EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct eeprom_93xx46_devtype_data microchip_93lc46b_data = {
|
||||||
|
.quirks = EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE,
|
||||||
|
};
|
||||||
|
|
||||||
struct eeprom_93xx46_dev {
|
struct eeprom_93xx46_dev {
|
||||||
struct spi_device *spi;
|
struct spi_device *spi;
|
||||||
struct eeprom_93xx46_platform_data *pdata;
|
struct eeprom_93xx46_platform_data *pdata;
|
||||||
|
@ -55,6 +59,11 @@ static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev)
|
||||||
return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH;
|
return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool has_quirk_extra_read_cycle(struct eeprom_93xx46_dev *edev)
|
||||||
|
{
|
||||||
|
return edev->pdata->quirks & EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE;
|
||||||
|
}
|
||||||
|
|
||||||
static int eeprom_93xx46_read(void *priv, unsigned int off,
|
static int eeprom_93xx46_read(void *priv, unsigned int off,
|
||||||
void *val, size_t count)
|
void *val, size_t count)
|
||||||
{
|
{
|
||||||
|
@ -96,6 +105,11 @@ static int eeprom_93xx46_read(void *priv, unsigned int off,
|
||||||
dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n",
|
dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n",
|
||||||
cmd_addr, edev->spi->max_speed_hz);
|
cmd_addr, edev->spi->max_speed_hz);
|
||||||
|
|
||||||
|
if (has_quirk_extra_read_cycle(edev)) {
|
||||||
|
cmd_addr <<= 1;
|
||||||
|
bits += 1;
|
||||||
|
}
|
||||||
|
|
||||||
spi_message_init(&m);
|
spi_message_init(&m);
|
||||||
|
|
||||||
t[0].tx_buf = (char *)&cmd_addr;
|
t[0].tx_buf = (char *)&cmd_addr;
|
||||||
|
@ -363,6 +377,7 @@ 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", },
|
||||||
{ .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, },
|
{ .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, },
|
||||||
|
{ .compatible = "microchip,93lc46b", .data = µchip_93lc46b_data, },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table);
|
MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table);
|
||||||
|
|
|
@ -16,6 +16,8 @@ struct eeprom_93xx46_platform_data {
|
||||||
#define EEPROM_93XX46_QUIRK_SINGLE_WORD_READ (1 << 0)
|
#define EEPROM_93XX46_QUIRK_SINGLE_WORD_READ (1 << 0)
|
||||||
/* Instructions such as EWEN are (addrlen + 2) in length. */
|
/* Instructions such as EWEN are (addrlen + 2) in length. */
|
||||||
#define EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH (1 << 1)
|
#define EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH (1 << 1)
|
||||||
|
/* Add extra cycle after address during a read */
|
||||||
|
#define EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE BIT(2)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* optional hooks to control additional logic
|
* optional hooks to control additional logic
|
||||||
|
|
Loading…
Reference in a new issue