diff options
| author | Kamal Dasu <kdasu.kdev@gmail.com> | 2017-08-22 16:45:21 -0400 |
|---|---|---|
| committer | Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> | 2017-10-10 12:19:42 -0400 |
| commit | 46dde01f6bab35d99af111fcc02ca3ee1146050f (patch) | |
| tree | 8dab5954c1cc35ab1b4e85ce045e50bac35f97e2 /include/linux/mtd | |
| parent | 90d4fa4540f16df552b4bac480a032552e594fc3 (diff) | |
mtd: spi-nor: add spi_nor_init() function
This patch extracts some chunks from spi_nor_init_params and spi_nor_scan()
and moves them into a new spi_nor_init() function.
Indeed, spi_nor_init() regroups all the required SPI flash commands to be
sent to the SPI flash memory before performing any runtime operations
(Fast Read, Page Program, Sector Erase, ...). Hence spi_nor_init():
1) removes the flash protection if applicable for certain vendors.
2) sets the Quad Enable bit, if needed, before using Quad SPI protocols.
3) makes the memory enter its (stateful) 4-byte address mode, if needed,
for SPI flash memory > 128Mbits not supporting the 4-byte address
instruction set.
spi_nor_scan() now ends by calling spi_nor_init() once the probe phase has
completed. Further patches could also use spi_nor_init() to implement the
mtd->_resume() handler for the spi-nor framework.
Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Diffstat (limited to 'include/linux/mtd')
| -rw-r--r-- | include/linux/mtd/spi-nor.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 1f0a7fc7772f..d0c66a0975cf 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h | |||
| @@ -232,10 +232,17 @@ enum spi_nor_option_flags { | |||
| 232 | }; | 232 | }; |
| 233 | 233 | ||
| 234 | /** | 234 | /** |
| 235 | * struct flash_info - Forward declaration of a structure used internally by | ||
| 236 | * spi_nor_scan() | ||
| 237 | */ | ||
| 238 | struct flash_info; | ||
| 239 | |||
| 240 | /** | ||
| 235 | * struct spi_nor - Structure for defining a the SPI NOR layer | 241 | * struct spi_nor - Structure for defining a the SPI NOR layer |
| 236 | * @mtd: point to a mtd_info structure | 242 | * @mtd: point to a mtd_info structure |
| 237 | * @lock: the lock for the read/write/erase/lock/unlock operations | 243 | * @lock: the lock for the read/write/erase/lock/unlock operations |
| 238 | * @dev: point to a spi device, or a spi nor controller device. | 244 | * @dev: point to a spi device, or a spi nor controller device. |
| 245 | * @info: spi-nor part JDEC MFR id and other info | ||
| 239 | * @page_size: the page size of the SPI NOR | 246 | * @page_size: the page size of the SPI NOR |
| 240 | * @addr_width: number of address bytes | 247 | * @addr_width: number of address bytes |
| 241 | * @erase_opcode: the opcode for erasing a sector | 248 | * @erase_opcode: the opcode for erasing a sector |
| @@ -262,6 +269,7 @@ enum spi_nor_option_flags { | |||
| 262 | * @flash_lock: [FLASH-SPECIFIC] lock a region of the SPI NOR | 269 | * @flash_lock: [FLASH-SPECIFIC] lock a region of the SPI NOR |
| 263 | * @flash_unlock: [FLASH-SPECIFIC] unlock a region of the SPI NOR | 270 | * @flash_unlock: [FLASH-SPECIFIC] unlock a region of the SPI NOR |
| 264 | * @flash_is_locked: [FLASH-SPECIFIC] check if a region of the SPI NOR is | 271 | * @flash_is_locked: [FLASH-SPECIFIC] check if a region of the SPI NOR is |
| 272 | * @quad_enable: [FLASH-SPECIFIC] enables SPI NOR quad mode | ||
| 265 | * completely locked | 273 | * completely locked |
| 266 | * @priv: the private data | 274 | * @priv: the private data |
| 267 | */ | 275 | */ |
| @@ -269,6 +277,7 @@ struct spi_nor { | |||
| 269 | struct mtd_info mtd; | 277 | struct mtd_info mtd; |
| 270 | struct mutex lock; | 278 | struct mutex lock; |
| 271 | struct device *dev; | 279 | struct device *dev; |
| 280 | const struct flash_info *info; | ||
| 272 | u32 page_size; | 281 | u32 page_size; |
| 273 | u8 addr_width; | 282 | u8 addr_width; |
| 274 | u8 erase_opcode; | 283 | u8 erase_opcode; |
| @@ -296,6 +305,7 @@ struct spi_nor { | |||
| 296 | int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len); | 305 | int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len); |
| 297 | int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len); | 306 | int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len); |
| 298 | int (*flash_is_locked)(struct spi_nor *nor, loff_t ofs, uint64_t len); | 307 | int (*flash_is_locked)(struct spi_nor *nor, loff_t ofs, uint64_t len); |
| 308 | int (*quad_enable)(struct spi_nor *nor); | ||
| 299 | 309 | ||
| 300 | void *priv; | 310 | void *priv; |
| 301 | }; | 311 | }; |
