mtd: nand: gpio: Add DT property to automatically determine bus width
Subsystems (6)
PATCH v3 1/4 mtd: nand: gpio: Add DT property to automatically determine bus width
This patch adds a property to automatically determine the NAND bus width. This property works if the bus width is not specified explicitly.
--- .../devicetree/bindings/mtd/gpio-control-nand.txt | 2 ++ drivers/mtd/nand/gpio.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/mtd/gpio-control-nand.txt +2 -0
@@ -19,6 +19,8 @@ Optional properties: defaults to 1 byte. - chip-delay : chip dependent delay for transferring data from array to read registers (tR). If not present then a default of 20us is used. +- gpio-control-nand,bank-width-auto : Device bus width is determined + automatically if "bank-width" is omitted (Boolean). - gpio-control-nand,io-sync-reg : A 64-bit physical address for a read location used to guard against bus reordering with regards to accesses to the GPIO's and the NAND flash data bus. If present, then after changing
drivers/mtd/nand/gpio.c +12 -4
@@ -116,6 +116,10 @@ static int gpio_nand_get_config_of(const struct device *dev,dev_err (dev,"invalid bank-width %u\n" , val);return -EINVAL ; } + }else { +if (of_get_property (dev->of_node, +"gpio-control-nand,bank-width-auto" ,NULL )) + plat->options |=NAND_BUSWIDTH_AUTO ; } plat->gpio_rdy =of_get_gpio (dev->of_node,0 );
@@ -223,6 +227,14 @@ static int gpio_nand_probe(struct platform_device *pdev)if (IS_ERR (chip->IO_ADDR_R))return PTR_ERR (chip->IO_ADDR_R); + ret =gpio_nand_get_config (&pdev->dev, &gpiomtd->plat); +if (ret) +return ret; + +if (resource_size (res) <2 ) + gpiomtd->plat.options &= ~(NAND_BUSWIDTH_16 | +NAND_BUSWIDTH_AUTO ); + res =gpio_nand_get_io_sync (pdev);if (res) { gpiomtd->io_sync =devm_ioremap_resource (&pdev->dev, res);
@@ -230,10 +242,6 @@ static int gpio_nand_probe(struct platform_device *pdev)return PTR_ERR (gpiomtd->io_sync); } - ret =gpio_nand_get_config (&pdev->dev, &gpiomtd->plat); -if (ret) -return ret; - ret =devm_gpio_request (&pdev->dev, gpiomtd->plat.gpio_nce,"NAND NCE" );if (ret)return ret;
Signature · 1 line
1.8.1.5
PATCH v3 4/4 mtd: nand: gpio: Add support for multichip devices
This patch adds support for multichip NAND devices controlled through GPIOs. To implement this, the properties of tree have been renamed. All current boards and DTS files converted to use an updated driver. Also driver temporarily keep support for DTS files which use the previous names scheme.
--- .../devicetree/bindings/mtd/gpio-control-nand.txt | 16 +-- arch/arm/boot/dts/picoxcell-pc7302-pc3x2.dts | 10 +- arch/arm/boot/dts/picoxcell-pc7302-pc3x3.dts | 10 +- arch/arm/mach-clps711x/board-autcpu12.c | 4 +- arch/arm/mach-clps711x/board-p720t.c | 4 +- arch/arm/mach-pxa/cm-x255.c | 10 +- drivers/mtd/nand/gpio.c | 108 +++++++++++++++------ include/linux/mtd/nand-gpio.h | 12 ++- 8 files changed, 112 insertions(+), 62 deletions(-)
Documentation/devicetree/bindings/mtd/gpio-control-nand.txt +9 -7
@@ -11,8 +11,11 @@ Required properties: are made in native endianness. - #address-cells, #size-cells : Must be present if the device has sub-nodes representing partitions. -- gpios : specifies the gpio pins to control the NAND device. nwp is an - optional gpio and may be set to 0 if not present. +- ale-gpios : specifies the ALE gpio pin. +- cle-gpios : specifies the CLE gpio pin. +- nwp-gpios : specifies the NWP gpio pin (Optional). +- nce-gpios : specifies the NCE gpio pin or several NCE GPIOs for multichip NAND. +- rdy-gpios : specifies the RDY gpio pin or several RDY GPIOs for multichip NAND. Optional properties: - bank-width : Width (in bytes) of the device. If not present, the width
@@ -37,11 +40,10 @@ gpio-nand@1,0 { reg = <1 0x0000 0x2>; #address-cells = <1>; #size-cells = <1>; - gpios = <&banka 1 0 /* rdy */ - &banka 2 0 /* nce */ - &banka 3 0 /* ale */ - &banka 4 0 /* cle */ - 0 /* nwp */>; + ale-gpios = <&banka 3 0>; + cle-gpios = <&banka 4 0>; + nce-gpios = <&banka 2 0>; + rdy-gpios = <&banka 1 0>; partition@0 { ...
arch/arm/boot/dts/picoxcell-pc7302-pc3x2.dts +4 -6
@@ -44,12 +44,10 @@ bus-clock = <&pclk>, "bus"; gpio-control-nand,io-sync-reg = <0x00000000 0x80220000>; - - gpios = <&banka 1 0 /* rdy */ - &banka 2 0 /* nce */ - &banka 3 0 /* ale */ - &banka 4 0 /* cle */ - 0 /* nwp */>; + ale-gpios = <&banka 3 0>; + cle-gpios = <&banka 4 0>; + nce-gpios = <&banka 2 0>; + rdy-gpios = <&banka 1 0>; boot@100000 { label = "Boot";
arch/arm/boot/dts/picoxcell-pc7302-pc3x3.dts +4 -6
@@ -50,12 +50,10 @@ bus-clock = <&ebi_clk>, "bus"; gpio-control-nand,io-sync-reg = <0x00000000 0x80220000>; - - gpios = <&banka 1 0 /* rdy */ - &banka 2 0 /* nce */ - &banka 3 0 /* ale */ - &banka 4 0 /* cle */ - 0 /* nwp */>; + ale-gpios = <&banka 3 0>; + cle-gpios = <&banka 4 0>; + nce-gpios = <&banka 2 0>; + rdy-gpios = <&banka 1 0>; boot@100000 { label = "Boot";
arch/arm/mach-clps711x/board-autcpu12.c +2 -2
@@ -120,8 +120,8 @@ static void __init autcpu12_adjust_parts(struct gpio_nand_platdata *pdata, }static struct gpio_nand_platdata autcpu12_nand_pdata__initdata = { - .gpio_rdy =AUTCPU12_SMC_RDY , - .gpio_nce =AUTCPU12_SMC_NCE , + .gpio_rdy[0 ] =AUTCPU12_SMC_RDY , + .gpio_nce[0 ] =AUTCPU12_SMC_NCE , .gpio_ale =AUTCPU12_SMC_ALE , .gpio_cle =AUTCPU12_SMC_CLE , .gpio_nwp =-1 ,
arch/arm/mach-clps711x/board-p720t.c +2 -2
@@ -243,8 +243,8 @@ static struct mtd_partition p720t_nand_parts[] __initdata = { };static struct gpio_nand_platdata p720t_nand_pdata__initdata = { - .gpio_rdy =-1 , - .gpio_nce =P720T_NAND_NCE , + .gpio_rdy[0 ] =-1 , + .gpio_nce[0 ] =P720T_NAND_NCE , .gpio_ale =P720T_NAND_ALE , .gpio_cle =P720T_NAND_CLE , .gpio_nwp =-1 ,
arch/arm/mach-pxa/cm-x255.c +5 -5
@@ -198,11 +198,11 @@ static struct mtd_partition cmx255_nand_parts[] = { };static struct gpio_nand_platdata cmx255_nand_platdata = { - .gpio_nce =GPIO_NAND_CS , - .gpio_cle =GPIO_NAND_CLE , - .gpio_ale =GPIO_NAND_ALE , - .gpio_rdy =GPIO_NAND_RB , - .gpio_nwp =-1 , + .gpio_nce[0 ] =GPIO_NAND_CS , + .gpio_cle =GPIO_NAND_CLE , + .gpio_ale =GPIO_NAND_ALE , + .gpio_rdy[0 ] =GPIO_NAND_RB , + .gpio_nwp =-1 , .parts = cmx255_nand_parts, .num_parts =ARRAY_SIZE (cmx255_nand_parts), .chip_delay =25 ,
drivers/mtd/nand/gpio.c +79 -29
193 lines not on this page · raw message
include/linux/mtd/nand-gpio.h +7 -5
@@ -3,12 +3,14 @@#include <linux/mtd/nand.h> +#define MAX_NAND_PER_CHIP 4 +struct gpio_nand_platdata { -int gpio_nce; -int gpio_nwp; -int gpio_cle; -int gpio_ale; -int gpio_rdy; +int gpio_ale;/* ALE */ +int gpio_cle;/* CLE */ +int gpio_nwp;/* NWP (Optional) */ +int gpio_nce[MAX_NAND_PER_CHIP ];/* NCE */ +int gpio_rdy[MAX_NAND_PER_CHIP ];/* RDY (Optional) */ void (*adjust_parts)(struct gpio_nand_platdata *,size_t );struct mtd_partition *parts;unsigned int num_parts;
Signature · 1 line
1.8.1.5
Re: [PATCH v3 4/4] mtd: nand: gpio: Add support for multichip devices
Quoted 10 lines · Alexander Shiyan
This patch adds support for multichip NAND devices controlled through GPIOs. To implement this, the properties of tree have been renamed. All current boards and DTS files converted to use an updated driver. Also driver temporarily keep support for DTS files which use the previous names scheme.
Signed-off-by Alexander Shiyan <[email protected]>--- .../devicetree/bindings/mtd/gpio-control-nand.txt | 16 +-- arch/arm/boot/dts/picoxcell-pc7302-pc3x2.dts | 10 +- arch/arm/boot/dts/picoxcell-pc7302-pc3x3.dts | 10 +-
For the bindings part:
Re: [PATCH v3 4/4] mtd: nand: gpio: Add support for multichip devices
In reply to Alexander ShiyanQuoted 22 lines · Alexander Shiyan
This patch adds support for multichip NAND devices controlled through GPIOs. To implement this, the properties of tree have been renamed. All current boards and DTS files converted to use an updated driver. Also driver temporarily keep support for DTS files which use the previous names scheme.
Signed-off-by Alexander Shiyan <[email protected]>--- .../devicetree/bindings/mtd/gpio-control-nand.txt | 16 +-- arch/arm/boot/dts/picoxcell-pc7302-pc3x2.dts | 10 +- arch/arm/boot/dts/picoxcell-pc7302-pc3x3.dts | 10 +- arch/arm/mach-clps711x/board-autcpu12.c | 4 +- arch/arm/mach-clps711x/board-p720t.c | 4 +- arch/arm/mach-pxa/cm-x255.c | 10 +- drivers/mtd/nand/gpio.c | 108 +++++++++++++++------ include/linux/mtd/nand-gpio.h | 12 ++- 8 files changed, 112 insertions(+), 62 deletions(-)Documentation/devicetree/bindings/mtd/gpio-control-nand.txt +0
-0
Documentation/devicetree/bindings/mtd/gpio-control-nand.txt Required properties: · line 11
Quoted 1 line
Documentation/devicetree/bindings/mtd/gpio-control-nand.txt +0
-0@@ -11,8 +11,11 @@ Required properties: are made in native endianness.
Unrelated, but the above like sounds mighty suspicious and possibly meaningless...
Documentation/devicetree/bindings/mtd/gpio-control-nand.txt Required properties: · line 15
Quoted 4 lines
Documentation/devicetree/bindings/mtd/gpio-control-nand.txt +0
-2- #address-cells, #size-cells : Must be present if the device has sub-nodes representing partitions. -- gpios : specifies the gpio pins to control the NAND device. nwp is an - optional gpio and may be set to 0 if not present.
I'm not against deprecating this property, as the new mechanism is far more flexible, and gets rid of the odd nwp case. However I think the documentation for the old property should be kept (though marked as deprecated). I'd be happy with a "Deprecated properties" section as with the regulator bindings.
I'm not sure about changing the dts immediately as this prevents using them with an old kernel, and creates a lot of churn, given the existing binding will be supported for the transitionary period...
Quoted 11 lines
Documentation/devicetree/bindings/mtd/gpio-control-nand.txt +5
-0+- ale-gpios : specifies the ALE gpio pin. +- cle-gpios : specifies the CLE gpio pin. +- nwp-gpios : specifies the NWP gpio pin (Optional). +- nce-gpios : specifies the NCE gpio pin or several NCE GPIOs for multichip NAND. +- rdy-gpios : specifies the RDY gpio pin or several RDY GPIOs for multichip NAND. Optional properties: - bank-width : Width (in bytes) of the device. If not present, the width@@ -37,11 +40,10 @@ gpio-nand@1,0 { reg = <1 0x0000 0x2>; #address-cells = <1>;
Documentation/devicetree/bindings/mtd/gpio-control-nand.txt gpio-nand@1,0 { · line 46
Quoted 10 lines
Documentation/devicetree/bindings/mtd/gpio-control-nand.txt +4
-5#size-cells = <1>; - gpios = <&banka 1 0 /* rdy */ - &banka 2 0 /* nce */ - &banka 3 0 /* ale */ - &banka 4 0 /* cle */ - 0 /* nwp */>; + ale-gpios = <&banka 3 0>; + cle-gpios = <&banka 4 0>; + nce-gpios = <&banka 2 0>; + rdy-gpios = <&banka 1 0>;
It would be nice to have a multichip NAND example, also.
Thanks,
Mark.