mirror of https://gitee.com/openkylin/linux.git
mtd: rawnand: Add support for manufacturer specific lock/unlock operation
Add nand_lock() & nand_unlock() for manufacturer specific lock & unlock operation while the device supports Block Portection function. Signed-off-by: Mason Yang <masonccyang@mxic.com.tw> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/1583220084-10890-2-git-send-email-masonccyang@mxic.com.tw
This commit is contained in:
parent
e015d72f32
commit
92270086b7
|
@ -4365,6 +4365,38 @@ static void nand_shutdown(struct mtd_info *mtd)
|
|||
nand_suspend(mtd);
|
||||
}
|
||||
|
||||
/**
|
||||
* nand_lock - [MTD Interface] Lock the NAND flash
|
||||
* @mtd: MTD device structure
|
||||
* @ofs: offset byte address
|
||||
* @len: number of bytes to lock (must be a multiple of block/page size)
|
||||
*/
|
||||
static int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
|
||||
if (!chip->lock_area)
|
||||
return -ENOTSUPP;
|
||||
|
||||
return chip->lock_area(chip, ofs, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* nand_unlock - [MTD Interface] Unlock the NAND flash
|
||||
* @mtd: MTD device structure
|
||||
* @ofs: offset byte address
|
||||
* @len: number of bytes to unlock (must be a multiple of block/page size)
|
||||
*/
|
||||
static int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
|
||||
if (!chip->unlock_area)
|
||||
return -ENOTSUPP;
|
||||
|
||||
return chip->unlock_area(chip, ofs, len);
|
||||
}
|
||||
|
||||
/* Set default functions */
|
||||
static void nand_set_defaults(struct nand_chip *chip)
|
||||
{
|
||||
|
@ -5791,8 +5823,8 @@ static int nand_scan_tail(struct nand_chip *chip)
|
|||
mtd->_read_oob = nand_read_oob;
|
||||
mtd->_write_oob = nand_write_oob;
|
||||
mtd->_sync = nand_sync;
|
||||
mtd->_lock = NULL;
|
||||
mtd->_unlock = NULL;
|
||||
mtd->_lock = nand_lock;
|
||||
mtd->_unlock = nand_unlock;
|
||||
mtd->_suspend = nand_suspend;
|
||||
mtd->_resume = nand_resume;
|
||||
mtd->_reboot = nand_shutdown;
|
||||
|
|
|
@ -1077,6 +1077,8 @@ struct nand_legacy {
|
|||
* @manufacturer: [INTERN] Contains manufacturer information
|
||||
* @manufacturer.desc: [INTERN] Contains manufacturer's description
|
||||
* @manufacturer.priv: [INTERN] Contains manufacturer private information
|
||||
* @lock_area: [REPLACEABLE] specific NAND chip lock operation
|
||||
* @unlock_area: [REPLACEABLE] specific NAND chip unlock operation
|
||||
*/
|
||||
|
||||
struct nand_chip {
|
||||
|
@ -1136,6 +1138,9 @@ struct nand_chip {
|
|||
const struct nand_manufacturer *desc;
|
||||
void *priv;
|
||||
} manufacturer;
|
||||
|
||||
int (*lock_area)(struct nand_chip *chip, loff_t ofs, uint64_t len);
|
||||
int (*unlock_area)(struct nand_chip *chip, loff_t ofs, uint64_t len);
|
||||
};
|
||||
|
||||
extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops;
|
||||
|
|
Loading…
Reference in New Issue