mtd: rawnand: Get rid of the cmx270 driver
Subsystems (5)
cover mtd: rawnand: Get rid of the cmx270 driver
Hello,
As part of my attempt to convert all NAND drivers to exec_op() I noticed the cmx270 board didn't really deserve a custom driver since other boards using the same SoC (em-x270 to name one) are using the gen_nand driver. I think the only issue with the CM-X270 is that the chip is connected to D[16:23] (or D[16:31] if it's a 16bit bus). Adjusting the mem resource offset should do the trick.
I hope someone still has a board to test that.
Regards,
Boris
Boris Brezillon (3):
ARM: pxa: cm-x270: Use gen_nand to expose the NAND device
ARM: pxa: Stop selecting CONFIG_MTD_NAND_CM_X270
mtd: rawnand: Remove the cmx270 NAND controller driver
arch/arm/configs/cm_x2xx_defconfig | 1 - arch/arm/configs/pxa_defconfig | 1 - arch/arm/mach-pxa/cm-x270.c | 131 ++++++++++++++++ drivers/mtd/nand/raw/Kconfig | 4 - drivers/mtd/nand/raw/Makefile | 1 - drivers/mtd/nand/raw/cmx270_nand.c | 236 ----------------------------- 6 files changed, 131 insertions(+), 243 deletions(-) delete mode 100644 drivers/mtd/nand/raw/cmx270_nand.c
Signature · 7 lines
2.25.3 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/3 ARM: pxa: cm-x270: Use gen_nand to expose the NAND device
No need to have a dedicated driver for this controller, all we need to do is adjust the memory range offset to account for the fact that the chip is connected to D[16:23] and not D[0:7].
--- arch/arm/mach-pxa/cm-x270.c | 131 ++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+)
arch/arm/mach-pxa/cm-x270.c +131 -0
@@ -23,6 +23,8 @@#include <linux/platform_data/usb-ohci-pxa27x.h> #include <linux/platform_data/mmc-pxamci.h> +#include <linux/mtd/platnand.h> +#include "generic.h" /* physical address if local-bus attached devices */
@@ -36,6 +38,10 @@/* MMC power enable */ #define GPIO105_MMC_POWER (105) +/* NAND GPIOs */ +#define GPIO11_NAND_CS (11) +#define GPIO89_NAND_RB (89) +/* WLAN GPIOS */ #define GPIO19_WLAN_STRAP (19)#define GPIO102_WLAN_RST (102)
@@ -309,6 +315,130 @@ static void __init cmx270_init_mmc(void)static inline void cmx270_init_mmc (void ) {}#endif +/* NAND flash */ +#if IS_ENABLED (CONFIG_MTD_NAND_PLATFORM ) +static inline void nand_cs_on (void ) +{ +gpio_set_value (GPIO11_NAND_CS ,0 ); +} + +static void nand_cs_off (void ) +{ +dsb (); + +gpio_set_value (GPIO11_NAND_CS ,1 ); +} + +/* hardware specific access to control-lines */ +static void cmx270_nand_cmd_ctl (struct nand_chip *this,int dat, +unsigned int ctrl) +{ +unsigned long nandaddr = (unsigned long )this->legacy.IO_ADDR_W; + +dsb (); + +if (ctrl &NAND_CTRL_CHANGE ) { +if (ctrl &NAND_ALE ) + nandaddr |= (1 <<3 ); +else + nandaddr &= ~(1 <<3 ); +if (ctrl &NAND_CLE ) + nandaddr |= (1 <<2 ); +else + nandaddr &= ~(1 <<2 ); +if (ctrl &NAND_NCE ) +nand_cs_on (); +else +nand_cs_off (); + } + +dsb (); + this->legacy.IO_ADDR_W = (void __iomem *)nandaddr; +if (dat !=NAND_CMD_NONE ) +writeb (dat, this->legacy.IO_ADDR_W); + +dsb (); +} + +/* read device ready pin */ +static int cmx270_nand_device_ready (struct nand_chip *this) +{ +dsb (); + +return gpio_get_value (GPIO89_NAND_RB ); +} + +static struct mtd_partition cmx270_partition_info[] = { + [0 ] = { + .name ="cmx270-0" , + .offset =0 , + .size =MTDPART_SIZ_FULL + }, +}; + +struct platform_nand_data cmx270_nand_platdata = { + .chip = { + .nr_chips =1 , + .chip_offset =0 , + .nr_partitions =ARRAY_SIZE (cmx270_partition_info), + .partitions = cmx270_partition_info, + .chip_delay =20 , + }, + .ctrl = { + .dev_ready = cmx270_nand_device_ready, + .cmd_ctrl = cmx270_nand_cmd_ctl, + }, +}; + +static struct resource cmx270_nand_resource[] = { + [0 ] = { +/* +* The NAND is connected to D[16:23], hence the 2 byte offset +* here. +*/ + .start =PXA_CS1_PHYS +2 , + .end =PXA_CS1_PHYS +2 +12 , + .flags =IORESOURCE_MEM , + }, +}; + +static struct platform_device cmx270_nand = { + .name ="gen_nand" , + .num_resources =ARRAY_SIZE (cmx270_nand_resource), + .resource = cmx270_nand_resource, + .id =-1 , + .dev = { + .platform_data = &cmx270_nand_platdata, + } +}; + +static void __init cmx270_init_nand (void ) +{ +int err; + + err =gpio_request (GPIO11_NAND_CS ,"NAND CS" ); +if (err) { +pr_warn ("CMX270: failed to request NAND CS gpio\n" ); +return ; + } + +gpio_direction_output (GPIO11_NAND_CS ,1 ); + + err =gpio_request (GPIO89_NAND_RB ,"NAND R/B" ); +if (err) { +pr_warn ("CMX270: failed to request NAND R/B gpio\n" ); +gpio_free (GPIO11_NAND_CS ); +return ; + } + +gpio_direction_input (GPIO89_NAND_RB ); + +platform_device_register (&cmx270_nand); +} +#else +static inline void cmx270_init_nand (void ) {} +#endif +#if defined(CONFIG_SPI_PXA2XX ) || defined(CONFIG_SPI_PXA2XX_MODULE )static struct pxa2xx_spi_controller cm_x270_spi_info = { .num_chipselect = 1,
@@ -413,6 +543,7 @@ void __init cmx270_init(void)cmx270_init_rtc ();cmx270_init_mmc (); +cmx270_init_nand ();cmx270_init_ohci ();cmx270_init_2700G ();cmx270_init_spi ();
Signature · 7 lines
2.25.3 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/3 ARM: pxa: Stop selecting CONFIG_MTD_NAND_CM_X270
In reply to Boris BrezillonNow that the NAND is handled through the gen_nand driver we can stop selecting CONFIG_MTD_NAND_CM_X270.
--- arch/arm/configs/cm_x2xx_defconfig | 1 - arch/arm/configs/pxa_defconfig | 1 - 2 files changed, 2 deletions(-)
arch/arm/configs/cm_x2xx_defconfig +0 -1
@@ -59,7 +59,6 @@ CONFIG_MTD_PHYSMAP=y CONFIG_MTD_PXA2XX=y CONFIG_MTD_RAW_NAND=y CONFIG_MTD_NAND_GPIO=m -CONFIG_MTD_NAND_CM_X270=y CONFIG_MTD_NAND_PLATFORM=y CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_RAM=y
arch/arm/configs/pxa_defconfig +0 -1
@@ -194,7 +194,6 @@ CONFIG_MTD_NAND_DISKONCHIP_PROBE_HIGH=y CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y CONFIG_MTD_NAND_SHARPSL=m CONFIG_MTD_NAND_MARVELL=m -CONFIG_MTD_NAND_CM_X270=m CONFIG_MTD_NAND_TMIO=m CONFIG_MTD_NAND_BRCMNAND=m CONFIG_MTD_NAND_PLATFORM=m
Signature · 7 lines
2.25.3 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/3 mtd: rawnand: Remove the cmx270 NAND controller driver
In reply to Boris BrezillonThe CM-X270 NAND is now handled through the gen_nand driver, as done for the EM-X270 platform.
--- drivers/mtd/nand/raw/Kconfig | 4 - drivers/mtd/nand/raw/Makefile | 1 - drivers/mtd/nand/raw/cmx270_nand.c | 236 ----------------------------- 3 files changed, 241 deletions(-) delete mode 100644 drivers/mtd/nand/raw/cmx270_nand.c
drivers/mtd/nand/raw/Kconfig +0 -4
@@ -213,10 +213,6 @@ config MTD_NAND_MLC_LPC32XX Please check the actual NAND chip connected and its support by the MLC NAND controller. -config MTD_NAND_CM_X270 - tristate "CM-X270 modules NAND controller" - depends on MACH_ARMCORE - config MTD_NAND_PASEMI tristate "PA Semi PWRficient NAND controller" depends on PPC_PASEMI
drivers/mtd/nand/raw/Makefile +0 -1
@@ -25,7 +25,6 @@ obj-$(CONFIG_MTD_NAND_GPIO) += gpio.o omap2_nand-objs := omap2.o obj-$(CONFIG_MTD_NAND_OMAP2) += omap2_nand.o obj-$(CONFIG_MTD_NAND_OMAP_BCH_BUILD) += omap_elm.o -obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o obj-$(CONFIG_MTD_NAND_MARVELL) += marvell_nand.o obj-$(CONFIG_MTD_NAND_TMIO) += tmio_nand.o obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
drivers/mtd/nand/raw/cmx270_nand.c deleted +0 -236
236 lines not on this page · raw message
Signature · 7 lines
2.25.3 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Miquel Raynal
maintainerHi Robert,
Boris Brezillon <[email protected]> wrote on Thu, 30 Apr 2020 00:31:31 +0200:
Quoted 20 lines
Hello,
As part of my attempt to convert all NAND drivers to
exec_op()I noticed the cmx270 board didn't really deserve a custom driver since other boards using the same SoC (em-x270 to name one) are using thegen_nanddriver. I think the only issue with the CM-X270 is that the chip is connected to D[16:23] (or D[16:31] if it's a 16bit bus). Adjusting the mem resource offset should do the trick.I hope someone still has a board to test that.
Regards,
Boris
Boris Brezillon (3):
ARM: pxa: cm-x270: Usegen_nandto expose the NAND device
ARM: pxa: Stop selectingCONFIG_MTD_NAND_CM_X270
mtd: rawnand: Remove the cmx270 NAND controller driver
Quoted 9 lines
arch/arm/configs/cm_x2xx_defconfig | 1 - arch/arm/configs/pxa_defconfig | 1 - arch/arm/mach-pxa/cm-x270.c | 131 ++++++++++++++++ drivers/mtd/nand/raw/Kconfig | 4 - drivers/mtd/nand/raw/Makefile | 1 - drivers/mtd/nand/raw/cmx270_nand.c | 236 ----------------------------- 6 files changed, 131 insertions(+), 243 deletions(-) delete mode 100644 drivers/mtd/nand/raw/cmx270_nand.c
Any chance you give this series a try? I plan to merge several series like that during this release, but of course if you can test it beforehands it's even better!
Thanks,
Miquèl
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Robert Jarzmik
maintainerQuoted 1 line · Miquel Raynal
Hi Robert,
Mi Miquel,
Quoted 1 line
Quoted 1 line
I hope someone still has a board to test that.
No, unfortunately I don't have this board, nor do I know of anyone having one. It's the second time I see patches on cmx270, and the question to whether we shoud keep this board in kernel is still in my mind ... given that cm-x300 is fully supported and testable, and no one I know has a cm-x2700 ...
Now for your series, I have 2 comments :
- dsb() : can you explain the rationale of each of the 3 instances I saw please.
- the +2 IOMEM offset
I don't like it at all. I don't mind the offset, I disklike the use of readb() or readw() where before there was a readl().. Same thing for writeb() against writel().
The bus semantics are not the same, the alignment is not the same as well (and PXA is very old and doesn't cope well with alignment), and without a proper board to test, I would be very wary to have that change.
Cheers.
Signature · 6 lines
Robert _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Robert,
Quoted 11 lines · On Wed, 13 May 2020 14:55:01 +0200 Robert Jarzmik <[email protected]>…
Quoted 1 line · Miquel Raynal
Hi Robert,
Mi Miquel,
Quoted 1 line
Quoted 1 line
I hope someone still has a board to test that.
No, unfortunately I don't have this board, nor do I know of anyone having one. It's the second time I see patches on cmx270, and the question to whether we shoud keep this board in kernel is still in my mind ... given that cm-x300 is fully supported and testable, and no one I know has a cm-x2700 ...
What's the point of keeping support for a board no one has or no one cares about? I know I don't have my word in this decision, but I would strongly recommend getting rid of it, especially when I see such crappy/unmaintained code lurking around in the drivers/ tree.
Quoted 4 lines
Now for your series, I have 2 comments :
-dsb(): can you explain the rationale of each of the 3 instances I saw please.
I didn't add any dsb(), just copied what was done before.
Quoted 8 lines
- the +2 IOMEM offset
I don't like it at all. I don't mind the offset, I disklike the use ofreadb()orreadw()where before there was areadl().. Same thing forwriteb()againstwritel().The bus semantics are not the same, the alignment is not the same as well (and PXA is very old and doesn't cope well with alignment), and without a proper board to test, I would be very wary to have that change.
Well, given the core uses {read,write}{b,w}() [1] to read/write data and this driver doesn't provide its own ->{read_byte,write_buf,read_buf}() implementation, I'd expect things to work just fine if we use byte/word accessors for the rest. This being said, I'm fine switching back to 32bit accessors if that's a hard requirement.
Thanks,
Boris
[1]https://elixir.bootlin.com/linux/v5.7-rc5/source/drivers/mtd/nand/raw/nand_legacy.c#L28
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Miquel Raynal
maintainerHello,
Boris Brezillon <[email protected]> wrote on Wed, 13 May 2020 15:17:37 +0200:
Quoted 17 lines
Hi Robert,
Quoted 11 lines · On Wed, 13 May 2020 14:55:01 +0200 Robert Jarzmik <[email protected]>…
Quoted 1 line · Miquel Raynal
Hi Robert,
Mi Miquel,
Quoted 1 line
Quoted 1 line
I hope someone still has a board to test that.
No, unfortunately I don't have this board, nor do I know of anyone having one. It's the second time I see patches on cmx270, and the question to whether we shoud keep this board in kernel is still in my mind ... given that cm-x300 is fully supported and testable, and no one I know has a cm-x2700 ...
Quoted 4 lines
What's the point of keeping support for a board no one has or no one cares about? I know I don't have my word in this decision, but I would strongly recommend getting rid of it, especially when I see such crappy/unmaintained code lurking around in the
drivers/tree.
I also agree on the fact that spending time on maintain unused boards is lost time. We have so many drivers to handle, maybe it's time to get rid of these "too" old drivers.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 10 lines · Miquel Raynal
Boris Brezillon <[email protected]> wrote on Wed, 13 May 2020 15:17:37 +0200:
Quoted 9 lines · On Wed, 13 May 2020 14:55:01 +0200 Robert Jarzmik <[email protected]>…
Quoted 7 lines
Quoted 1 line · Miquel Raynal
Quoted 1 line
I hope someone still has a board to test that.
No, unfortunately I don't have this board, nor do I know of anyone having one. It's the second time I see patches on cmx270, and the question to whether we shoud keep this board in kernel is still in my mind ... given that cm-x300 is fully supported and testable, and no one I know has a cm-x2700 ...
Quoted 8 lines
Quoted 4 lines
What's the point of keeping support for a board no one has or no one cares about? I know I don't have my word in this decision, but I would strongly recommend getting rid of it, especially when I see such crappy/unmaintained code lurking around in the
drivers/tree.I also agree on the fact that spending time on maintain unused boards is lost time. We have so many drivers to handle, maybe it's time to get rid of these "too" old drivers.
The cm-x255/cm-x270 came up in another discussion last year because of its unusual PCI_HOST_ITE8152 PCI support that I'd like to kill off.
We did not see a strong reason to keep the board support at that time, but nobody sent any patches. I think it would be reasonable to just kill off MACH_ARMCORE, PCI_HOST_ITE8152 and MTD_NAND_CM_X270 along with anything else that is no longer used after those are gone, such as the pcmcia support.
Arnd
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/