Message ID | 1347481275-995-1-git-send-email-zajec5@gmail.com |
---|---|
State | New, archived |
Headers | show |
On Wed, 2012-09-12 at 22:21 +0200, Rafał Miłecki wrote: > +config MTD_NAND_BCM47XXNFLASH > + tristate "Support for NAND flash on BCMA bus" > + depends on BCMA_NFLASH && BROKEN > + help > + BCMA bus can have various flash memories attached, they are > + registered by bcma as platform devices. This enables driver for > + NAND flash memories. Could we please merge only non-broken stuff upstream. I understand your intentions to merge something non-working first with a promise to make it working later, but I do not think this is an acceptable approach. Why exactly you mark this one as broken? If it is R/O so far, and reading works, and you tested it (how?), we can merge it I guess, just make it clear that it is R/O in Kconfig help text.
2012/9/26 Artem Bityutskiy <dedekind1@gmail.com>: > On Wed, 2012-09-12 at 22:21 +0200, Rafał Miłecki wrote: >> +config MTD_NAND_BCM47XXNFLASH >> + tristate "Support for NAND flash on BCMA bus" >> + depends on BCMA_NFLASH && BROKEN >> + help >> + BCMA bus can have various flash memories attached, they are >> + registered by bcma as platform devices. This enables driver for >> + NAND flash memories. > > Could we please merge only non-broken stuff upstream. I understand your > intentions to merge something non-working first with a promise to make > it working later, but I do not think this is an acceptable approach. > > Why exactly you mark this one as broken? If it is R/O so far, and > reading works, and you tested it (how?), we can merge it I guess, just > make it clear that it is R/O in Kconfig help text. Yes, BROKEN can be dropped from this. I'll resend correct patchset after checking it with verify/aiaiai (i'm almost done! :) )
On Wed, 2012-09-12 at 22:21 +0200, Rafał Miłecki wrote: > BCMA bus can contain NAND flash memory, it's registered in system as > platform device. This adds required hooks and place for controler > specific drivers. > At this point it doesn't work yet, so it's marked as BROKEN. > > Signed-off-by: Rafał Miłecki <zajec5@gmail.com> If you send the next version of this, would you please base it on l2-mtd.git tree, to make my job simpler, because otherwise I have to solve small conflicts.
On Wed, 2012-09-26 at 09:41 +0200, Rafał Miłecki wrote: > 2012/9/26 Artem Bityutskiy <dedekind1@gmail.com>: > > On Wed, 2012-09-12 at 22:21 +0200, Rafał Miłecki wrote: > >> +config MTD_NAND_BCM47XXNFLASH > >> + tristate "Support for NAND flash on BCMA bus" > >> + depends on BCMA_NFLASH && BROKEN > >> + help > >> + BCMA bus can have various flash memories attached, they are > >> + registered by bcma as platform devices. This enables driver for > >> + NAND flash memories. > > > > Could we please merge only non-broken stuff upstream. I understand your > > intentions to merge something non-working first with a promise to make > > it working later, but I do not think this is an acceptable approach. > > > > Why exactly you mark this one as broken? If it is R/O so far, and > > reading works, and you tested it (how?), we can merge it I guess, just > > make it clear that it is R/O in Kconfig help text. > > Yes, BROKEN can be dropped from this. I'll resend correct patchset > after checking it with verify/aiaiai (i'm almost done! :) ) Great, thanks. Do not forget to tell about R/O in the Kconfig text please!
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index 8ca4176..7460ac2 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig @@ -489,6 +489,14 @@ config MTD_NAND_GPMI_NAND block, such as SD card. So pay attention to it when you enable the GPMI. +config MTD_NAND_BCM47XXNFLASH + tristate "Support for NAND flash on BCMA bus" + depends on BCMA_NFLASH && BROKEN + help + BCMA bus can have various flash memories attached, they are + registered by bcma as platform devices. This enables driver for + NAND flash memories. + config MTD_NAND_PLATFORM tristate "Support for generic platform NAND driver" depends on HAS_IOMEM diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index d4b4d87..8aa55d8 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -51,5 +51,6 @@ obj-$(CONFIG_MTD_NAND_MPC5121_NFC) += mpc5121_nfc.o obj-$(CONFIG_MTD_NAND_RICOH) += r852.o obj-$(CONFIG_MTD_NAND_JZ4740) += jz4740_nand.o obj-$(CONFIG_MTD_NAND_GPMI_NAND) += gpmi-nand/ +obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH) += bcm47xxnflash/ nand-objs := nand_base.o nand_bbt.o diff --git a/drivers/mtd/nand/bcm47xxnflash/Makefile b/drivers/mtd/nand/bcm47xxnflash/Makefile new file mode 100644 index 0000000..1d0693a --- /dev/null +++ b/drivers/mtd/nand/bcm47xxnflash/Makefile @@ -0,0 +1,3 @@ +bcm47xxnflash-y += main.o + +obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH) += bcm47xxnflash.o diff --git a/drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h b/drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h new file mode 100644 index 0000000..2e8864a --- /dev/null +++ b/drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h @@ -0,0 +1,14 @@ +#ifndef __BCM47XXNFLASH_H +#define __BCM47XXNFLASH_H + +#include <linux/mtd/mtd.h> +#include <linux/mtd/nand.h> + +struct bcm47xxnflash { + struct bcma_drv_cc *cc; + + struct nand_chip nand_chip; + struct mtd_info mtd; +}; + +#endif /* BCM47XXNFLASH */ diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c new file mode 100644 index 0000000..fc9139d --- /dev/null +++ b/drivers/mtd/nand/bcm47xxnflash/main.c @@ -0,0 +1,108 @@ +/* + * BCM47XX NAND flash driver + * + * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/platform_device.h> +#include <linux/bcma/bcma.h> + +#include "bcm47xxnflash.h" + +MODULE_DESCRIPTION("NAND flash driver for BCMA bus"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Rafał Miłecki"); + +static const char *probes[] = { "bcm47xxpart", NULL }; + +static int bcm47xxnflash_probe(struct platform_device *pdev) +{ + struct bcma_nflash *nflash = dev_get_platdata(&pdev->dev); + struct bcm47xxnflash *b47n; + int err = 0; + + b47n = kzalloc(sizeof(*b47n), GFP_KERNEL); + if (!b47n) { + err = -ENOMEM; + goto out; + } + + b47n->nand_chip.priv = b47n; + b47n->mtd.owner = THIS_MODULE; + b47n->mtd.priv = &b47n->nand_chip; /* Required */ + b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash); + + if (0) { + /* TODO: init device */ + } else { + pr_err("Device not supported\n"); + err = -ENOTSUPP; + } + if (err) { + pr_err("Initialization failed: %d\n", err); + goto err_init; + } + + err = mtd_device_parse_register(&b47n->mtd, probes, NULL, NULL, 0); + if (err) { + pr_err("Failed to register MTD device: %d\n", err); + goto err_dev_reg; + } + + return 0; + +err_dev_reg: +err_init: + kfree(b47n); +out: + return err; +} + +static int __devexit bcm47xxnflash_remove(struct platform_device *pdev) +{ + struct bcma_nflash *nflash = dev_get_platdata(&pdev->dev); + + if (nflash->mtd) + mtd_device_unregister(nflash->mtd); + + return 0; +} + +static struct platform_driver bcm47xxnflash_driver = { + .remove = __devexit_p(bcm47xxnflash_remove), + .driver = { + .name = "bcma_nflash", + .owner = THIS_MODULE, + }, +}; + +static int __init bcm47xxnflash_init(void) +{ + int err; + + /* + * Platform device "bcma_nflash" exists on SoCs and is registered very + * early, it won't be added during runtime (use platform_driver_probe). + */ + err = platform_driver_probe(&bcm47xxnflash_driver, bcm47xxnflash_probe); + if (err) + pr_err("Failed to register serial flash driver: %d\n", err); + + return err; +} + +static void __exit bcm47xxnflash_exit(void) +{ + platform_driver_unregister(&bcm47xxnflash_driver); +} + +module_init(bcm47xxnflash_init); +module_exit(bcm47xxnflash_exit);
BCMA bus can contain NAND flash memory, it's registered in system as platform device. This adds required hooks and place for controler specific drivers. At this point it doesn't work yet, so it's marked as BROKEN. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> --- drivers/mtd/nand/Kconfig | 8 ++ drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/bcm47xxnflash/Makefile | 3 + drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h | 14 +++ drivers/mtd/nand/bcm47xxnflash/main.c | 108 ++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/nand/bcm47xxnflash/Makefile create mode 100644 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h create mode 100644 drivers/mtd/nand/bcm47xxnflash/main.c