Lines Matching +full:lock +full:- +full:offset

1 /* SPDX-License-Identifier: GPL-2.0 */
14 #include <linux/mtd/spi-nor.h>
33 int (*read)(struct udevice *dev, u32 offset, size_t len, void *buf);
34 int (*write)(struct udevice *dev, u32 offset, size_t len,
36 int (*erase)(struct udevice *dev, u32 offset, size_t len);
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
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
50 int (*flash_ctrl_wlock)(struct udevice *dev, u32 offset, size_t len);
51 int (*flash_ctrl_wunlock)(struct udevice *dev, u32 offset, size_t len);
55 #define sf_get_ops(dev) ((struct dm_spi_flash_ops *)(dev)->driver->ops)
59 * spi_flash_read_dm() - Read data from SPI flash
62 * @offset: Offset into device in bytes to read from
65 * @return 0 if OK, -ve on error
67 int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf);
70 * spi_flash_write_dm() - Write data to SPI flash
73 * @offset: Offset into device in bytes to write to
76 * @return 0 if OK, -ve on error
78 int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
82 * spi_flash_erase_dm() - Erase blocks of the SPI flash
87 * @offset: Offset into device in bytes to start erasing
89 * @return 0 if OK, -ve on error
91 int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len);
94 * spl_flash_get_sw_write_prot() - Check state of software write-protect feature
96 * SPI flash chips can lock a region of the flash defined by a
101 * @return 0 if no region is write-protected, 1 if a region is
102 * write-protected, -ENOSYS if the driver does not implement this,
103 * other -ve value on error
106 int spi_flash_ctrl_wlock_dm(struct udevice *dev, u32 offset, size_t len);
107 int spi_flash_ctrl_wunlock_dm(struct udevice *dev, u32 offset, size_t len);
113 /* Compatibility function - this is the old U-Boot API */
117 /* Compatibility function - this is the old U-Boot API */
120 static inline int spi_flash_read(struct spi_flash *flash, u32 offset, in spi_flash_read() argument
123 return spi_flash_read_dm(flash->dev, offset, len, buf); in spi_flash_read()
126 static inline int spi_flash_write(struct spi_flash *flash, u32 offset, in spi_flash_write() argument
129 return spi_flash_write_dm(flash->dev, offset, len, buf); in spi_flash_write()
132 static inline int spi_flash_erase(struct spi_flash *flash, u32 offset, in spi_flash_erase() argument
135 return spi_flash_erase_dm(flash->dev, offset, len); in spi_flash_erase()
139 u32 offset, size_t len) in spi_flash_ctrl_wlock() argument
141 return spi_flash_ctrl_wlock_dm(flash->dev, offset, len); in spi_flash_ctrl_wlock()
145 u32 offset, size_t len) in spi_flash_ctrl_wunlock() argument
147 return spi_flash_ctrl_wunlock_dm(flash->dev, offset, len); in spi_flash_ctrl_wunlock()
163 static inline int spi_flash_read(struct spi_flash *flash, u32 offset, in spi_flash_read() argument
166 struct mtd_info *mtd = &flash->mtd; in spi_flash_read()
169 return mtd->_read(mtd, offset, len, &retlen, buf); in spi_flash_read()
172 static inline int spi_flash_write(struct spi_flash *flash, u32 offset, in spi_flash_write() argument
175 struct mtd_info *mtd = &flash->mtd; in spi_flash_write()
178 return mtd->_write(mtd, offset, len, &retlen, buf); in spi_flash_write()
181 static inline int spi_flash_erase(struct spi_flash *flash, u32 offset, in spi_flash_erase() argument
184 struct mtd_info *mtd = &flash->mtd; in spi_flash_erase()
187 if (offset % mtd->erasesize || len % mtd->erasesize) { in spi_flash_erase()
188 printf("SF: Erase offset/length not multiple of erase size\n"); in spi_flash_erase()
189 return -EINVAL; in spi_flash_erase()
193 instr.addr = offset; in spi_flash_erase()
196 return mtd->_erase(mtd, &instr); in spi_flash_erase()
203 if (!flash->flash_lock || !flash->flash_unlock) in spi_flash_protect()
204 return -EOPNOTSUPP; in spi_flash_protect()
207 return flash->flash_lock(flash, ofs, len); in spi_flash_protect()
209 return flash->flash_unlock(flash, ofs, len); in spi_flash_protect()