mtd: spi-nor: add spi_nor_init() function
authorKamal Dasu <kdasu.kdev@gmail.com>
Tue, 22 Aug 2017 20:45:21 +0000 (16:45 -0400)
committerCyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Tue, 10 Oct 2017 16:19:42 +0000 (18:19 +0200)
commit46dde01f6bab35d99af111fcc02ca3ee1146050f
tree8dab5954c1cc35ab1b4e85ce045e50bac35f97e2
parent90d4fa4540f16df552b4bac480a032552e594fc3
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>
drivers/mtd/spi-nor/spi-nor.c
include/linux/mtd/spi-nor.h