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