Lines Matching defs:spi
18 #include <linux/spi/spi.h>
19 #include <linux/spi/flash.h>
94 struct spi_device *spi;
113 static inline int dataflash_status(struct spi_device *spi)
118 return spi_w8r8(spi, OP_READ_STATUS);
125 static int dataflash_waitready(struct spi_device *spi)
130 status = dataflash_status(spi);
132 dev_dbg(&spi->dev, "status %d?\n", status);
151 struct spi_device *spi = priv->spi;
158 dev_dbg(&spi->dev, "erase addr=0x%llx len 0x%llx\n",
192 dev_dbg(&spi->dev, "ERASE %s: (%x) %x %x %x [%i]\n",
197 status = spi_sync(spi, &msg);
198 (void) dataflash_waitready(spi);
201 dev_err(&spi->dev, "erase %x, err %d\n",
239 dev_dbg(&priv->spi->dev, "read 0x%x..0x%x\n",
248 dev_dbg(&priv->spi->dev, "READ: (%x) %x %x %x\n",
273 status = spi_sync(priv->spi, &msg);
280 dev_dbg(&priv->spi->dev, "read %x..%x --> %d\n",
297 struct spi_device *spi = priv->spi;
306 dev_dbg(&spi->dev, "write 0x%x..0x%x\n",
324 dev_dbg(&spi->dev, "write @ %i:%i len=%i\n",
352 dev_dbg(&spi->dev, "TRANSFER: (%x) %x %x %x\n",
355 status = spi_sync(spi, &msg);
357 dev_dbg(&spi->dev, "xfer %u -> %d\n",
360 (void) dataflash_waitready(priv->spi);
370 dev_dbg(&spi->dev, "PROGRAM: (%x) %x %x %x\n",
376 status = spi_sync(spi, &msg);
379 dev_dbg(&spi->dev, "pgm %u/%u -> %d\n",
382 (void) dataflash_waitready(priv->spi);
394 dev_dbg(&spi->dev, "COMPARE: (%x) %x %x %x\n",
397 status = spi_sync(spi, &msg);
399 dev_dbg(&spi->dev, "compare %u -> %d\n",
402 status = dataflash_waitready(priv->spi);
406 dev_err(&spi->dev, "compare page %u, err %d\n",
450 static ssize_t otp_read(struct spi_device *spi, unsigned base,
483 dataflash_waitready(spi);
485 status = spi_sync(spi, &m);
503 status = otp_read(priv->spi, 64, buf, from, len);
520 status = otp_read(priv->spi, 0, buf, from, len);
572 dataflash_waitready(priv->spi);
573 status = spi_sync(priv->spi, &m);
615 static int add_dataflash_otp(struct spi_device *spi, char *name, int nr_pages,
620 struct flash_platform_data *pdata = dev_get_platdata(&spi->dev);
629 priv->spi = spi;
634 sprintf(priv->name, "spi%d.%d-%s",
635 spi->master->bus_num, spi->chip_select,
650 device->dev.parent = &spi->dev;
651 mtd_set_of_node(device, spi->dev.of_node);
656 dev_info(&spi->dev, "%s (%lld KBytes) pagesize %d bytes%s\n",
659 spi_set_drvdata(spi, priv);
672 static inline int add_dataflash(struct spi_device *spi, char *name,
675 return add_dataflash_otp(spi, name, nr_pages, pagesize,
736 static struct flash_info *jedec_lookup(struct spi_device *spi,
749 dev_dbg(&spi->dev, "OTP, sector protect%s\n",
753 status = dataflash_status(spi);
755 dev_dbg(&spi->dev, "status error %d\n",
774 static struct flash_info *jedec_probe(struct spi_device *spi)
792 ret = spi_write_then_read(spi, &code, 1, id, id_size);
794 dev_dbg(&spi->dev, "error %d reading JEDEC ID\n", ret);
807 info = jedec_lookup(spi, jedec >> DATAFLASH_SHIFT_EXTID, true);
814 info = jedec_lookup(spi, jedec >> DATAFLASH_SHIFT_ID, false);
822 dev_warn(&spi->dev, "JEDEC id %016llx not handled\n", jedec);
840 static int dataflash_probe(struct spi_device *spi)
852 info = jedec_probe(spi);
856 return add_dataflash_otp(spi, info->name, info->nr_pages,
864 status = dataflash_status(spi);
866 dev_dbg(&spi->dev, "status error %d\n", status);
873 * board setup should have set spi->max_speed_max to
878 status = add_dataflash(spi, "AT45DB011B", 512, 264, 9);
881 status = add_dataflash(spi, "AT45DB021B", 1024, 264, 9);
884 status = add_dataflash(spi, "AT45DB041x", 2048, 264, 9);
887 status = add_dataflash(spi, "AT45DB081B", 4096, 264, 9);
890 status = add_dataflash(spi, "AT45DB161x", 4096, 528, 10);
893 status = add_dataflash(spi, "AT45DB321x", 8192, 528, 10);
897 status = add_dataflash(spi, "AT45DB642x", 8192, 1056, 11);
901 dev_info(&spi->dev, "unsupported device (%x)\n",
907 dev_dbg(&spi->dev, "add_dataflash --> %d\n", status);
912 static int dataflash_remove(struct spi_device *spi)
914 struct dataflash *flash = spi_get_drvdata(spi);
917 dev_dbg(&spi->dev, "remove\n");
942 MODULE_ALIAS("spi:mtd_dataflash");