Lines Matching +full:spi +full:- +full:flash
2 * Common SPI flash Interface
7 * SPDX-License-Identifier: GPL-2.0
15 #include <linux/mtd/spi-nor.h>
38 * get_sw_write_prot() - Check state of software write-protect feature
40 * SPI flash chips can lock a region of the flash defined by a
44 * @dev: SPI flash device
45 * @return 0 if no region is write-protected, 1 if a region is
46 * write-protected, -ENOSYS if the driver does not implement this,
47 * other -ve value on error
53 #define sf_get_ops(dev) ((struct dm_spi_flash_ops *)(dev)->driver->ops)
57 * spi_flash_read_dm() - Read data from SPI flash
59 * @dev: SPI flash device
63 * @return 0 if OK, -ve on error
68 * spi_flash_write_dm() - Write data to SPI flash
70 * @dev: SPI flash device
74 * @return 0 if OK, -ve on error
80 * spi_flash_erase_dm() - Erase blocks of the SPI flash
82 * Note that @len must be a muiltiple of the flash sector size.
84 * @dev: SPI flash device
87 * @return 0 if OK, -ve on error
92 * spl_flash_get_sw_write_prot() - Check state of software write-protect feature
94 * SPI flash chips can lock a region of the flash defined by a
98 * @dev: SPI flash device
99 * @return 0 if no region is write-protected, 1 if a region is
100 * write-protected, -ENOSYS if the driver does not implement this,
101 * other -ve value on error
109 /* Compatibility function - this is the old U-Boot API */
113 /* Compatibility function - this is the old U-Boot API */
114 void spi_flash_free(struct spi_flash *flash);
116 static inline int spi_flash_read(struct spi_flash *flash, u32 offset, in spi_flash_read() argument
119 return spi_flash_read_dm(flash->dev, offset, len, buf); in spi_flash_read()
122 static inline int spi_flash_write(struct spi_flash *flash, u32 offset, in spi_flash_write() argument
125 return spi_flash_write_dm(flash->dev, offset, len, buf); in spi_flash_write()
128 static inline int spi_flash_erase(struct spi_flash *flash, u32 offset, in spi_flash_erase() argument
131 return spi_flash_erase_dm(flash->dev, offset, len); in spi_flash_erase()
145 void spi_flash_free(struct spi_flash *flash);
147 static inline int spi_flash_read(struct spi_flash *flash, u32 offset, in spi_flash_read() argument
150 struct mtd_info *mtd = &flash->mtd; in spi_flash_read()
153 return mtd->_read(mtd, offset, len, &retlen, buf); in spi_flash_read()
156 static inline int spi_flash_write(struct spi_flash *flash, u32 offset, in spi_flash_write() argument
159 struct mtd_info *mtd = &flash->mtd; in spi_flash_write()
162 return mtd->_write(mtd, offset, len, &retlen, buf); in spi_flash_write()
165 static inline int spi_flash_erase(struct spi_flash *flash, u32 offset, in spi_flash_erase() argument
168 struct mtd_info *mtd = &flash->mtd; in spi_flash_erase()
171 if (offset % mtd->erasesize || len % mtd->erasesize) { in spi_flash_erase()
173 return -EINVAL; in spi_flash_erase()
180 return mtd->_erase(mtd, &instr); in spi_flash_erase()
184 static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len, in spi_flash_protect() argument
187 if (!flash->flash_lock || !flash->flash_unlock) in spi_flash_protect()
188 return -EOPNOTSUPP; in spi_flash_protect()
191 return flash->flash_lock(flash, ofs, len); in spi_flash_protect()
193 return flash->flash_unlock(flash, ofs, len); in spi_flash_protect()