Lines Matching defs:spi
17 #include <linux/spi/spi.h>
18 #include <linux/spi/flash.h>
93 struct spi_device *spi;
112 MODULE_DEVICE_TABLE(spi, dataflash_spi_ids);
119 static inline int dataflash_status(struct spi_device *spi)
124 return spi_w8r8(spi, OP_READ_STATUS);
131 static int dataflash_waitready(struct spi_device *spi)
136 status = dataflash_status(spi);
138 dev_dbg(&spi->dev, "status %d?\n", status);
157 struct spi_device *spi = priv->spi;
164 dev_dbg(&spi->dev, "erase addr=0x%llx len 0x%llx\n",
198 dev_dbg(&spi->dev, "ERASE %s: (%x) %x %x %x [%i]\n",
203 status = spi_sync(spi, &msg);
204 (void) dataflash_waitready(spi);
207 dev_err(&spi->dev, "erase %x, err %d\n",
245 dev_dbg(&priv->spi->dev, "read 0x%x..0x%x\n",
254 dev_dbg(&priv->spi->dev, "READ: (%x) %x %x %x\n",
279 status = spi_sync(priv->spi, &msg);
286 dev_dbg(&priv->spi->dev, "read %x..%x --> %d\n",
303 struct spi_device *spi = priv->spi;
312 dev_dbg(&spi->dev, "write 0x%x..0x%x\n",
330 dev_dbg(&spi->dev, "write @ %i:%i len=%i\n",
358 dev_dbg(&spi->dev, "TRANSFER: (%x) %x %x %x\n",
361 status = spi_sync(spi, &msg);
363 dev_dbg(&spi->dev, "xfer %u -> %d\n",
366 (void) dataflash_waitready(priv->spi);
376 dev_dbg(&spi->dev, "PROGRAM: (%x) %x %x %x\n",
382 status = spi_sync(spi, &msg);
385 dev_dbg(&spi->dev, "pgm %u/%u -> %d\n",
388 (void) dataflash_waitready(priv->spi);
400 dev_dbg(&spi->dev, "COMPARE: (%x) %x %x %x\n",
403 status = spi_sync(spi, &msg);
405 dev_dbg(&spi->dev, "compare %u -> %d\n",
408 status = dataflash_waitready(priv->spi);
412 dev_err(&spi->dev, "compare page %u, err %d\n",
456 static ssize_t otp_read(struct spi_device *spi, unsigned base,
489 dataflash_waitready(spi);
491 status = spi_sync(spi, &m);
509 status = otp_read(priv->spi, 64, buf, from, len);
526 status = otp_read(priv->spi, 0, buf, from, len);
578 dataflash_waitready(priv->spi);
579 status = spi_sync(priv->spi, &m);
621 static int add_dataflash_otp(struct spi_device *spi, char *name, int nr_pages,
626 struct flash_platform_data *pdata = dev_get_platdata(&spi->dev);
635 priv->spi = spi;
640 sprintf(priv->name, "spi%d.%d-%s",
641 spi->master->bus_num, spi_get_chipselect(spi, 0),
656 device->dev.parent = &spi->dev;
657 mtd_set_of_node(device, spi->dev.of_node);
662 dev_info(&spi->dev, "%s (%lld KBytes) pagesize %d bytes%s\n",
665 spi_set_drvdata(spi, priv);
678 static inline int add_dataflash(struct spi_device *spi, char *name,
681 return add_dataflash_otp(spi, name, nr_pages, pagesize,
742 static struct flash_info *jedec_lookup(struct spi_device *spi,
755 dev_dbg(&spi->dev, "OTP, sector protect%s\n",
759 status = dataflash_status(spi);
761 dev_dbg(&spi->dev, "status error %d\n",
780 static struct flash_info *jedec_probe(struct spi_device *spi)
798 ret = spi_write_then_read(spi, &code, 1, id, id_size);
800 dev_dbg(&spi->dev, "error %d reading JEDEC ID\n", ret);
813 info = jedec_lookup(spi, jedec >> DATAFLASH_SHIFT_EXTID, true);
820 info = jedec_lookup(spi, jedec >> DATAFLASH_SHIFT_ID, false);
828 dev_warn(&spi->dev, "JEDEC id %016llx not handled\n", jedec);
846 static int dataflash_probe(struct spi_device *spi)
858 info = jedec_probe(spi);
862 return add_dataflash_otp(spi, info->name, info->nr_pages,
870 status = dataflash_status(spi);
872 dev_dbg(&spi->dev, "status error %d\n", status);
879 * board setup should have set spi->max_speed_max to
884 status = add_dataflash(spi, "AT45DB011B", 512, 264, 9);
887 status = add_dataflash(spi, "AT45DB021B", 1024, 264, 9);
890 status = add_dataflash(spi, "AT45DB041x", 2048, 264, 9);
893 status = add_dataflash(spi, "AT45DB081B", 4096, 264, 9);
896 status = add_dataflash(spi, "AT45DB161x", 4096, 528, 10);
899 status = add_dataflash(spi, "AT45DB321x", 8192, 528, 10);
903 status = add_dataflash(spi, "AT45DB642x", 8192, 1056, 11);
907 dev_info(&spi->dev, "unsupported device (%x)\n",
913 dev_dbg(&spi->dev, "add_dataflash --> %d\n", status);
918 static void dataflash_remove(struct spi_device *spi)
920 struct dataflash *flash = spi_get_drvdata(spi);
922 dev_dbg(&spi->dev, "remove\n");
946 MODULE_ALIAS("spi:mtd_dataflash");