[U-Boot] [PATCH 1/2] dm: sf: Make SST flash write op work again

Bin Meng bmeng.cn at gmail.com
Thu Apr 23 11:00:10 CEST 2015


With SPI flash moving to driver model, commit fbb0991 "dm: Convert
spi_flash_probe() and 'sf probe' to use driver model" ignored the
SST flash-specific write op (byte program & word program), which
actually broke the SST flash from wroking.

This commit makes SST flash work again under driver model, by adding
a new SST flash-specific driver to handle the different write op
from the standard one.

Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
---

 drivers/mtd/spi/sf_probe.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index d19138d..47438d2 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -511,4 +511,35 @@ U_BOOT_DRIVER(spi_flash_std) = {
 	.ops		= &spi_flash_std_ops,
 };
 
+int spi_flash_sst_write(struct udevice *dev, u32 offset, size_t len,
+			const void *buf)
+{
+	struct spi_flash *flash = dev_get_uclass_priv(dev);
+
+	if (flash->spi->op_mode_tx & SPI_OPM_TX_BP)
+		return sst_write_bp(flash, offset, len, buf);
+	else
+		return sst_write_wp(flash, offset, len, buf);
+}
+
+static const struct dm_spi_flash_ops spi_flash_sst_ops = {
+	.read = spi_flash_std_read,
+	.write = spi_flash_sst_write,
+	.erase = spi_flash_std_erase,
+};
+
+static const struct udevice_id spi_flash_sst_ids[] = {
+	{ .compatible = "spi-flash-sst" },
+	{ }
+};
+
+U_BOOT_DRIVER(spi_flash_sst) = {
+	.name		= "spi_flash_sst",
+	.id		= UCLASS_SPI_FLASH,
+	.of_match	= spi_flash_sst_ids,
+	.probe		= spi_flash_std_probe,
+	.priv_auto_alloc_size = sizeof(struct spi_flash),
+	.ops		= &spi_flash_sst_ops,
+};
+
 #endif /* CONFIG_DM_SPI_FLASH */
-- 
1.8.2.1



More information about the U-Boot mailing list