Lines Matching +full:spi +full:- +full:flash

2  * SPI flash probing
8 * SPDX-License-Identifier: GPL-2.0+
16 #include <spi.h>
22 * spi_flash_probe_slave() - Probe for a SPI flash device on a bus
24 * @flashp: Pointer to place to put flash info, which may be NULL if the
27 static int spi_flash_probe_slave(struct spi_flash *flash) in spi_flash_probe_slave() argument
29 struct spi_slave *spi = flash->spi; in spi_flash_probe_slave() local
33 if (!spi) { in spi_flash_probe_slave()
35 return -ENODEV; in spi_flash_probe_slave()
38 /* Claim spi bus */ in spi_flash_probe_slave()
39 ret = spi_claim_bus(spi); in spi_flash_probe_slave()
41 debug("SF: Failed to claim SPI bus: %d\n", ret); in spi_flash_probe_slave()
46 flash->mtd.name = (char *)ofnode_read_string(spi->dev->node, "label"); in spi_flash_probe_slave()
49 ret = spi_nor_scan(flash); in spi_flash_probe_slave()
54 ret = spi_flash_mtd_register(flash); in spi_flash_probe_slave()
58 spi_release_bus(spi); in spi_flash_probe_slave()
67 struct spi_flash *flash; in spi_flash_probe() local
73 /* Allocate space if needed (not used by sf-uclass */ in spi_flash_probe()
74 flash = calloc(1, sizeof(*flash)); in spi_flash_probe()
75 if (!flash) { in spi_flash_probe()
80 flash->spi = bus; in spi_flash_probe()
81 if (spi_flash_probe_slave(flash)) { in spi_flash_probe()
83 free(flash); in spi_flash_probe()
87 return flash; in spi_flash_probe()
90 void spi_flash_free(struct spi_flash *flash) in spi_flash_free() argument
95 spi_free_slave(flash->spi); in spi_flash_free()
96 free(flash); in spi_flash_free()
104 struct spi_flash *flash = dev_get_uclass_priv(dev); in spi_flash_std_read() local
105 struct mtd_info *mtd = &flash->mtd; in spi_flash_std_read()
108 return log_ret(mtd->_read(mtd, offset, len, &retlen, buf)); in spi_flash_std_read()
114 struct spi_flash *flash = dev_get_uclass_priv(dev); in spi_flash_std_write() local
115 struct mtd_info *mtd = &flash->mtd; in spi_flash_std_write()
118 return mtd->_write(mtd, offset, len, &retlen, buf); in spi_flash_std_write()
123 struct spi_flash *flash = dev_get_uclass_priv(dev); in spi_flash_std_erase() local
124 struct mtd_info *mtd = &flash->mtd; in spi_flash_std_erase()
127 if (offset % mtd->erasesize || len % mtd->erasesize) { in spi_flash_std_erase()
129 return -EINVAL; in spi_flash_std_erase()
136 return mtd->_erase(mtd, &instr); in spi_flash_std_erase()
141 struct spi_flash *flash = dev_get_uclass_priv(dev); in spi_flash_std_get_sw_write_prot() local
143 return spi_flash_cmd_get_sw_write_prot(flash); in spi_flash_std_get_sw_write_prot()
165 struct spi_flash *flash; in spi_flash_std_probe() local
167 flash = dev_get_uclass_priv(dev); in spi_flash_std_probe()
168 flash->dev = dev; in spi_flash_std_probe()
169 flash->spi = slave; in spi_flash_std_probe()
170 debug("%s: slave=%p, cs=%d\n", __func__, slave, plat->cs); in spi_flash_std_probe()
171 return spi_flash_probe_slave(flash); in spi_flash_std_probe()
190 { .compatible = "jedec,spi-nor" },