Lines Matching refs:spi
98 struct spi_device *spi; member
117 static inline int dataflash_status(struct spi_device *spi) in dataflash_status() argument
122 return spi_w8r8(spi, OP_READ_STATUS); in dataflash_status()
129 static int dataflash_waitready(struct spi_device *spi) in dataflash_waitready() argument
134 status = dataflash_status(spi); in dataflash_waitready()
136 dev_dbg(&spi->dev, "status %d?\n", status); in dataflash_waitready()
155 struct spi_device *spi = priv->spi; in dataflash_erase() local
162 dev_dbg(&spi->dev, "erase addr=0x%llx len 0x%llx\n", in dataflash_erase()
196 dev_dbg(&spi->dev, "ERASE %s: (%x) %x %x %x [%i]\n", in dataflash_erase()
201 status = spi_sync(spi, &msg); in dataflash_erase()
202 (void) dataflash_waitready(spi); in dataflash_erase()
205 dev_err(&spi->dev, "erase %x, err %d\n", in dataflash_erase()
243 dev_dbg(&priv->spi->dev, "read 0x%x..0x%x\n", in dataflash_read()
252 dev_dbg(&priv->spi->dev, "READ: (%x) %x %x %x\n", in dataflash_read()
277 status = spi_sync(priv->spi, &msg); in dataflash_read()
284 dev_dbg(&priv->spi->dev, "read %x..%x --> %d\n", in dataflash_read()
301 struct spi_device *spi = priv->spi; in dataflash_write() local
310 dev_dbg(&spi->dev, "write 0x%x..0x%x\n", in dataflash_write()
328 dev_dbg(&spi->dev, "write @ %i:%i len=%i\n", in dataflash_write()
356 dev_dbg(&spi->dev, "TRANSFER: (%x) %x %x %x\n", in dataflash_write()
359 status = spi_sync(spi, &msg); in dataflash_write()
361 dev_dbg(&spi->dev, "xfer %u -> %d\n", in dataflash_write()
364 (void) dataflash_waitready(priv->spi); in dataflash_write()
374 dev_dbg(&spi->dev, "PROGRAM: (%x) %x %x %x\n", in dataflash_write()
380 status = spi_sync(spi, &msg); in dataflash_write()
383 dev_dbg(&spi->dev, "pgm %u/%u -> %d\n", in dataflash_write()
386 (void) dataflash_waitready(priv->spi); in dataflash_write()
398 dev_dbg(&spi->dev, "COMPARE: (%x) %x %x %x\n", in dataflash_write()
401 status = spi_sync(spi, &msg); in dataflash_write()
403 dev_dbg(&spi->dev, "compare %u -> %d\n", in dataflash_write()
406 status = dataflash_waitready(priv->spi); in dataflash_write()
410 dev_err(&spi->dev, "compare page %u, err %d\n", in dataflash_write()
454 static ssize_t otp_read(struct spi_device *spi, unsigned base, in otp_read() argument
487 dataflash_waitready(spi); in otp_read()
489 status = spi_sync(spi, &m); in otp_read()
507 status = otp_read(priv->spi, 64, buf, from, len); in dataflash_read_fact_otp()
524 status = otp_read(priv->spi, 0, buf, from, len); in dataflash_read_user_otp()
576 dataflash_waitready(priv->spi); in dataflash_write_user_otp()
577 status = spi_sync(priv->spi, &m); in dataflash_write_user_otp()
619 static int add_dataflash_otp(struct spi_device *spi, char *name, int nr_pages, in add_dataflash_otp() argument
624 struct flash_platform_data *pdata = dev_get_platdata(&spi->dev); in add_dataflash_otp()
633 priv->spi = spi; in add_dataflash_otp()
639 spi->master->bus_num, spi->chip_select, in add_dataflash_otp()
654 device->dev.parent = &spi->dev; in add_dataflash_otp()
655 mtd_set_of_node(device, spi->dev.of_node); in add_dataflash_otp()
660 dev_info(&spi->dev, "%s (%lld KBytes) pagesize %d bytes%s\n", in add_dataflash_otp()
663 spi_set_drvdata(spi, priv); in add_dataflash_otp()
676 static inline int add_dataflash(struct spi_device *spi, char *name, in add_dataflash() argument
679 return add_dataflash_otp(spi, name, nr_pages, pagesize, in add_dataflash()
740 static struct flash_info *jedec_lookup(struct spi_device *spi, in jedec_lookup() argument
753 dev_dbg(&spi->dev, "OTP, sector protect%s\n", in jedec_lookup()
757 status = dataflash_status(spi); in jedec_lookup()
759 dev_dbg(&spi->dev, "status error %d\n", in jedec_lookup()
778 static struct flash_info *jedec_probe(struct spi_device *spi) in jedec_probe() argument
796 ret = spi_write_then_read(spi, &code, 1, id, id_size); in jedec_probe()
798 dev_dbg(&spi->dev, "error %d reading JEDEC ID\n", ret); in jedec_probe()
811 info = jedec_lookup(spi, jedec >> DATAFLASH_SHIFT_EXTID, true); in jedec_probe()
818 info = jedec_lookup(spi, jedec >> DATAFLASH_SHIFT_ID, false); in jedec_probe()
826 dev_warn(&spi->dev, "JEDEC id %016llx not handled\n", jedec); in jedec_probe()
844 static int dataflash_probe(struct spi_device *spi) in dataflash_probe() argument
856 info = jedec_probe(spi); in dataflash_probe()
860 return add_dataflash_otp(spi, info->name, info->nr_pages, in dataflash_probe()
868 status = dataflash_status(spi); in dataflash_probe()
870 dev_dbg(&spi->dev, "status error %d\n", status); in dataflash_probe()
882 status = add_dataflash(spi, "AT45DB011B", 512, 264, 9); in dataflash_probe()
885 status = add_dataflash(spi, "AT45DB021B", 1024, 264, 9); in dataflash_probe()
888 status = add_dataflash(spi, "AT45DB041x", 2048, 264, 9); in dataflash_probe()
891 status = add_dataflash(spi, "AT45DB081B", 4096, 264, 9); in dataflash_probe()
894 status = add_dataflash(spi, "AT45DB161x", 4096, 528, 10); in dataflash_probe()
897 status = add_dataflash(spi, "AT45DB321x", 8192, 528, 10); in dataflash_probe()
901 status = add_dataflash(spi, "AT45DB642x", 8192, 1056, 11); in dataflash_probe()
905 dev_info(&spi->dev, "unsupported device (%x)\n", in dataflash_probe()
911 dev_dbg(&spi->dev, "add_dataflash --> %d\n", status); in dataflash_probe()
916 static int dataflash_remove(struct spi_device *spi) in dataflash_remove() argument
918 struct dataflash *flash = spi_get_drvdata(spi); in dataflash_remove()
921 dev_dbg(&spi->dev, "remove\n"); in dataflash_remove()