MTD updates for v4.5:
Generic MTD * populate the MTD device 'of_node' field (and get a proper 'of_node' symlink in sysfs) - This yielded some new helper functions, and changes across a variety of drivers * partitioning cleanups, to prepare for better device-tree based partitioning in the future - Eliminate a lot of boilerplate for drivers that want to use OF-based partition parsing - The DT bindings for this didn't settle yet, so most non-cleanup portions are deferred for a future release NAND * embed a struct mtd_info inside struct nand_chip - This is really long overdue; too many drivers have to do the same silly boilerplate to allocate and link up two "independent" structs, when in fact, everyone is assuming there is an exact 1:1 relationship between a NAND chips struct and its underlying MTD. This aids improved helpers and should make certain abstractions easier in the future. - Also causes a lot of churn, helped along by some automated code transformations * add more core support for detecting (and "correcting") bitflips in erased pages; requires opt-in by drivers, but at least we kill a few bad implementations and hopefully stave off future ones * pxa3xx_nand: cleanups, a few fixes, and PM improvements * new JZ4780 NAND driver SPI NOR * provide default erase function, for controllers that just want to send the SECTOR_ERASE command directly * fix some module auto-loading issues with device tree ("jedec,spi-nor") * error handling fixes * new Mediatek QSPI flash driver Other * cfi: force valid geometry Kconfig (finally!) - this one used to trip up randconfigs occasionally, since bots aren't deterred by big scary "advanced configuration" menus More? Probably. See the commit logs. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJWlZSyAAoJEFySrpd9RFgtVkEP/096SsFs+71jPgc6ARHIKt6j b8vnGeMpjYErIjRZXjeLJvD4whYcooM1IDXiy7HPFEF/DrmN+dBjF6gYNHhC9n+X bpIVS+TJknBKqcAClPVArZI77Fugzn1jBuo8t8rH5bpHNvTfucOt0VmQAu/NRxXe qUHNXDdQ+nb7qUy47Us66ygDiUh6tXYD2gp3duE8W49FnoSxcXNTq467RGyVBREl U+5mxsD4y49mktG3xatYdwmvz9UTWOYa+u4NTG282kP6GrqTPTw0ESaxfViP9nyd WSexhylV/PFJjxyMRazy1EZJ3kiQCQvza/VMmZ6fDSzwZ4JephuCDGLd3MhE3/E7 C275DNHC6U0s79gSlihrYHKEkMN8uNUDwNfeZhY05jXL56kFxUlUvvq14bt4gDDK xrPLNKLOpcoAMiRFOM5NdBeyQx9REq1G09I8MBjBN0kW254lIjGm6naCOl0L/Fu1 Y4c7hJCLFUTrki9DeNcP6dtpSCVdOap4C+920FZyrBnUzpt5G/rUGdSQu0iY5i4j BHe/Pr6ybkQ+b7XZbJlbFOy/u6TL/3T9Z4L52RK4j6F3r2EkNiH0+892L4v4qih6 Bt2wsFw8gGHC3dnnh5yfyst/QaG2Mu7V2JJjrrlERjWQJepWqYnUjlH/PgwKj7t0 /pnD40iDmUG2aYe+Jmcv =wFQI -----END PGP SIGNATURE----- Merge tag 'for-linus-20160112' of git://git.infradead.org/linux-mtd Pull MTD updates from Brian Norris: "Generic MTD: - populate the MTD device 'of_node' field (and get a proper 'of_node' symlink in sysfs) This yielded some new helper functions, and changes across a variety of drivers - partitioning cleanups, to prepare for better device-tree based partitioning in the future Eliminate a lot of boilerplate for drivers that want to use OF-based partition parsing The DT bindings for this didn't settle yet, so most non-cleanup portions are deferred for a future release NAND: - embed a struct mtd_info inside struct nand_chip This is really long overdue; too many drivers have to do the same silly boilerplate to allocate and link up two "independent" structs, when in fact, everyone is assuming there is an exact 1:1 relationship between a NAND chips struct and its underlying MTD. This aids improved helpers and should make certain abstractions easier in the future. Also causes a lot of churn, helped along by some automated code transformations - add more core support for detecting (and "correcting") bitflips in erased pages; requires opt-in by drivers, but at least we kill a few bad implementations and hopefully stave off future ones - pxa3xx_nand: cleanups, a few fixes, and PM improvements - new JZ4780 NAND driver SPI NOR: - provide default erase function, for controllers that just want to send the SECTOR_ERASE command directly - fix some module auto-loading issues with device tree ("jedec,spi-nor") - error handling fixes - new Mediatek QSPI flash driver Other: - cfi: force valid geometry Kconfig (finally!) This one used to trip up randconfigs occasionally, since bots aren't deterred by big scary "advanced configuration" menus More? Probably. See the commit logs" * tag 'for-linus-20160112' of git://git.infradead.org/linux-mtd: (168 commits) mtd: jz4780_nand: replace if/else blocks with switch/case mtd: nand: jz4780: Update ecc correction error codes mtd: nandsim: use nand_get_controller_data() mtd: jz4780_nand: remove useless mtd->priv = chip assignment staging: mt29f_spinand: make use of nand_set/get_controller_data() helpers mtd: nand: make use of nand_set/get_controller_data() helpers ARM: make use of nand_set/get_controller_data() helpers mtd: nand: add helpers to access ->priv mtd: nand: jz4780: driver for NAND devices on JZ4780 SoCs mtd: nand: jz4740: remove custom 'erased check' implementation mtd: nand: diskonchip: remove custom 'erased check' implementation mtd: nand: davinci: remove custom 'erased check' implementation mtd: nand: use nand_check_erased_ecc_chunk in default ECC read functions mtd: nand: return consistent error codes in ecc.correct() implementations doc: dt: mtd: new binding for jz4780-{nand,bch} mtd: cfi_cmdset_0001: fixing memory leak and handling failed kmalloc mtd: spi-nor: wait until lock/unlock operations are ready mtd: tests: consolidate kmalloc/memset 0 call to kzalloc jffs2: use to_delayed_work mtd: nand: assign reasonable default name for NAND drivers ...
This commit is contained in:
commit
ac53b2e053
128 changed files with 3472 additions and 1756 deletions
|
@ -162,12 +162,15 @@
|
|||
<sect1 id="Basic_defines">
|
||||
<title>Basic defines</title>
|
||||
<para>
|
||||
At least you have to provide a mtd structure and
|
||||
a storage for the ioremap'ed chip address.
|
||||
You can allocate the mtd structure using kmalloc
|
||||
or you can allocate it statically.
|
||||
In case of static allocation you have to allocate
|
||||
a nand_chip structure too.
|
||||
At least you have to provide a nand_chip structure
|
||||
and a storage for the ioremap'ed chip address.
|
||||
You can allocate the nand_chip structure using
|
||||
kmalloc or you can allocate it statically.
|
||||
The NAND chip structure embeds an mtd structure
|
||||
which will be registered to the MTD subsystem.
|
||||
You can extract a pointer to the mtd structure
|
||||
from a nand_chip pointer using the nand_to_mtd()
|
||||
helper.
|
||||
</para>
|
||||
<para>
|
||||
Kmalloc based example
|
||||
|
@ -180,7 +183,6 @@ static void __iomem *baseaddr;
|
|||
Static example
|
||||
</para>
|
||||
<programlisting>
|
||||
static struct mtd_info board_mtd;
|
||||
static struct nand_chip board_chip;
|
||||
static void __iomem *baseaddr;
|
||||
</programlisting>
|
||||
|
@ -235,7 +237,7 @@ static void board_hwcontrol(struct mtd_info *mtd, int cmd)
|
|||
<programlisting>
|
||||
static void board_hwcontrol(struct mtd_info *mtd, int cmd)
|
||||
{
|
||||
struct nand_chip *this = (struct nand_chip *) mtd->priv;
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
switch(cmd){
|
||||
case NAND_CTL_SETCLE: this->IO_ADDR_W |= CLE_ADRR_BIT; break;
|
||||
case NAND_CTL_CLRCLE: this->IO_ADDR_W &= ~CLE_ADRR_BIT; break;
|
||||
|
@ -274,13 +276,15 @@ static int __init board_init (void)
|
|||
int err = 0;
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
board_mtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!board_mtd) {
|
||||
this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!this) {
|
||||
printk ("Unable to allocate NAND MTD device structure.\n");
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
board_mtd = nand_to_mtd(this);
|
||||
|
||||
/* map physical address */
|
||||
baseaddr = ioremap(CHIP_PHYSICAL_ADDRESS, 1024);
|
||||
if (!baseaddr) {
|
||||
|
@ -289,11 +293,6 @@ static int __init board_init (void)
|
|||
goto out_mtd;
|
||||
}
|
||||
|
||||
/* Get pointer to private data */
|
||||
this = (struct nand_chip *) ();
|
||||
/* Link the private data with the MTD structure */
|
||||
board_mtd->priv = this;
|
||||
|
||||
/* Set address of NAND IO lines */
|
||||
this->IO_ADDR_R = baseaddr;
|
||||
this->IO_ADDR_W = baseaddr;
|
||||
|
@ -317,7 +316,7 @@ static int __init board_init (void)
|
|||
out_ior:
|
||||
iounmap(baseaddr);
|
||||
out_mtd:
|
||||
kfree (board_mtd);
|
||||
kfree (this);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
@ -343,7 +342,7 @@ static void __exit board_cleanup (void)
|
|||
iounmap(baseaddr);
|
||||
|
||||
/* Free the MTD device structure */
|
||||
kfree (board_mtd);
|
||||
kfree (mtd_to_nand(board_mtd));
|
||||
}
|
||||
module_exit(board_cleanup);
|
||||
#endif
|
||||
|
@ -399,7 +398,7 @@ static void board_select_chip (struct mtd_info *mtd, int chip)
|
|||
<programlisting>
|
||||
static void board_select_chip (struct mtd_info *mtd, int chip)
|
||||
{
|
||||
struct nand_chip *this = (struct nand_chip *) mtd->priv;
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
|
||||
/* Deselect all chips */
|
||||
this->IO_ADDR_R &= ~BOARD_NAND_ADDR_MASK;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue