[PATCH 2/3] mtd: spi-nor: Add and update device_id field in spi_mem structure
Sai Krishna Potthuri
sai.krishna.potthuri at amd.com
Mon Feb 6 22:09:23 PST 2023
Xilinx Versal Octal SPI controller drivers might require the device id
information to perform the Rx tuning operation. Since there is no common
Tuning Data Pattern defined across all vendors, controllers which requires
Rx tuning to find out the optimal sampling point for data lines, this
device id information will be used as a golden data.
spi-nor core updates the device id information in device_id field
while reading the id of the flash device.
Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri at amd.com>
---
drivers/mtd/spi-nor/core.c | 1 +
include/linux/spi/spi-mem.h | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index bee8fc4c9f07..9811e74ef3b6 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1644,6 +1644,7 @@ static const struct flash_info *spi_nor_match_id(struct spi_nor *nor,
if (part->id_len &&
!memcmp(part->id, id, part->id_len)) {
nor->manufacturer = manufacturers[i];
+ memcpy(nor->spimem->device_id, id, SPI_NOR_MAX_ID_LEN);
return part;
}
}
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index 8e984d75f5b6..e9ae5c1b7391 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -181,11 +181,14 @@ struct spi_mem_dirmap_desc {
void *priv;
};
+#define SPI_MEM_DEV_MAX_ID_LEN 6
+
/**
* struct spi_mem - describes a SPI memory device
* @spi: the underlying SPI device
* @drvpriv: spi_mem_driver private data
* @name: name of the SPI memory device
+ * @device_id: device id of the SPI memory device
*
* Extra information that describe the SPI memory device and may be needed by
* the controller to properly handle this device should be placed here.
@@ -197,6 +200,7 @@ struct spi_mem {
struct spi_device *spi;
void *drvpriv;
const char *name;
+ u8 device_id[SPI_MEM_DEV_MAX_ID_LEN];
};
/**
--
2.25.1
More information about the linux-mtd
mailing list