* [PATCH 1/5] ARM: am335x-bone: Add support for 16-bit NAND cape
2013-10-24 22:12 [PATCH 0/5] Assorted OMAP2 NAND clean-ups Ezequiel Garcia
@ 2013-10-24 22:12 ` Ezequiel Garcia
2013-10-24 22:12 ` [PATCH 2/5] mtd: nand: omap2: Fix device detection path Ezequiel Garcia
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Ezequiel Garcia @ 2013-10-24 22:12 UTC (permalink / raw)
To: linux-mtd, linux-omap
Cc: Brian Norris, Pekon Gupta, Felipe Balbi, Ezequiel Garcia
From: Pekon Gupta <pekon@ti.com>
Add GPMC timing configurations and NAND partitions for the Beaglebone
"NAND cape". Further information and datasheets of this cape can be found at:
- http://beagleboardtoys.info/index.php?title=BeagleBone_Memory_Expansion
- http://beagleboardtoys.info/index.php?title=BeagleBone_4Gb_16-Bit_NAND_Module
Signed-off-by: Pekon Gupta <pekon@ti.com>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
This patch is not really intended for inclusion. I'm just adding it
to the series for reference and in case anyone wants to test.
arch/arm/boot/dts/am335x-bone-common.dtsi | 28 ++++++++++++
arch/arm/boot/dts/am335x-bone.dts | 75 +++++++++++++++++++++++++++++++
arch/arm/boot/dts/am335x-boneblack.dts | 69 ++++++++++++++++++++++++++++
3 files changed, 172 insertions(+)
diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index 2f66ded..73dcc58 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -107,6 +107,34 @@
0x14c (PIN_INPUT_PULLDOWN | MUX_MODE7)
>;
};
+
+ nandflash_pins_s0: nandflash_pins_s0 {
+ pinctrl-single,pins = <
+ 0x0 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad0.gpmc_ad0 */
+ 0x4 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad1.gpmc_ad1 */
+ 0x8 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad2.gpmc_ad2 */
+ 0xc (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad3.gpmc_ad3 */
+ 0x10 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad4.gpmc_ad4 */
+ 0x14 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad5.gpmc_ad5 */
+ 0x18 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad6.gpmc_ad6 */
+ 0x1c (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad7.gpmc_ad7 */
+ 0x20 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad8.gpmc_ad8 */
+ 0x24 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad9.gpmc_ad9 */
+ 0x28 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad10.gpmc_ad10 */
+ 0x2c (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad11.gpmc_ad11 */
+ 0x30 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad12.gpmc_ad12 */
+ 0x34 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad13.gpmc_ad13 */
+ 0x38 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad14.gpmc_ad14 */
+ 0x3c (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad15.gpmc_ad15 */
+ 0x70 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_wait0.gpmc_wait0 */
+ 0x74 (PIN_INPUT_PULLUP | MUX_MODE7) /* gpmc_wpn.gpio0_30 */
+ 0x7c (PIN_OUTPUT | MUX_MODE0) /* gpmc_csn0.gpmc_csn0 */
+ 0x90 (PIN_OUTPUT | MUX_MODE0) /* gpmc_advn_ale.gpmc_advn_ale */
+ 0x94 (PIN_OUTPUT | MUX_MODE0) /* gpmc_oen_ren.gpmc_oen_ren */
+ 0x98 (PIN_OUTPUT | MUX_MODE0) /* gpmc_wen.gpmc_wen */
+ 0x9c (PIN_OUTPUT | MUX_MODE0) /* gpmc_be0n_cle.gpmc_be0n_cle */
+ >;
+ };
};
ocp {
diff --git a/arch/arm/boot/dts/am335x-bone.dts b/arch/arm/boot/dts/am335x-bone.dts
index 7993c48..d9172c7 100644
--- a/arch/arm/boot/dts/am335x-bone.dts
+++ b/arch/arm/boot/dts/am335x-bone.dts
@@ -9,3 +9,78 @@
#include "am33xx.dtsi"
#include "am335x-bone-common.dtsi"
+
+&elm {
+ status = "okay";
+};
+
+&gpmc {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&nandflash_pins_s0>;
+ ranges = <0 0 0x08000000 0x10000000>; /* CS0: NAND */
+ nand@0,0 {
+ reg = <0 0 0>; /* CS0, offset 0 */
+ nand-bus-width = <16>;
+ ti,nand-ecc-opt = "bch8";
+ gpmc,device-width = <2>;
+ gpmc,sync-clk-ps = <0>;
+ gpmc,cs-on-ns = <0>;
+ gpmc,cs-rd-off-ns = <740>;
+ gpmc,cs-wr-off-ns = <740>;
+ gpmc,adv-on-ns = <0>;
+ gpmc,adv-rd-off-ns = <740>;
+ gpmc,adv-wr-off-ns = <740>;
+ gpmc,we-on-ns = <90>;
+ gpmc,we-off-ns = <600>;
+ gpmc,oe-on-ns = <150>;
+ gpmc,oe-off-ns = <650>;
+ gpmc,access-ns = <560>;
+ gpmc,rd-cycle-ns = <740>;
+ gpmc,wr-cycle-ns = <740>;
+ gpmc,wait-on-read = "true";
+ gpmc,wait-on-write = "true";
+ gpmc,bus-turnaround-ns = <0>;
+ gpmc,cycle2cycle-delay-ns = <0>;
+ gpmc,clk-activation-ns = <0>;
+ gpmc,wait-monitoring-ns = <0>;
+ gpmc,wr-access-ns = <40>;
+ gpmc,wr-data-mux-bus-ns = <0>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ti,elm-id = <&elm>;
+ /* MTD partition table */
+ partition@0 {
+ label = "SPL1";
+ reg = <0x00000000 0x000020000>;
+ };
+ partition@1 {
+ label = "SPL2";
+ reg = <0x00020000 0x00020000>;
+ };
+ partition@2 {
+ label = "SPL3";
+ reg = <0x00040000 0x00020000>;
+ };
+ partition@3 {
+ label = "SPL4";
+ reg = <0x00060000 0x00020000>;
+ };
+ partition@4 {
+ label = "U-boot";
+ reg = <0x00080000 0x001e0000>;
+ };
+ partition@5 {
+ label = "environment";
+ reg = <0x00260000 0x00020000>;
+ };
+ partition@6 {
+ label = "Kernel";
+ reg = <0x00280000 0x00500000>;
+ };
+ partition@7 {
+ label = "File-System";
+ reg = <0x00780000 0x0F880000>;
+ };
+ };
+};
diff --git a/arch/arm/boot/dts/am335x-boneblack.dts b/arch/arm/boot/dts/am335x-boneblack.dts
index 197cadf..e30f58a 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts
@@ -15,3 +15,72 @@
regulator-max-microvolt = <1800000>;
regulator-always-on;
};
+
+&elm {
+ status = "okay";
+};
+
+&gpmc {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&nandflash_pins_s0>;
+ ranges = <0 0 0x08000000 0x10000000>; /* CS0: NAND */
+ nand@0,0 {
+ reg = <0 0 0>; /* CS0, offset 0 */
+ nand-bus-width = <16>;
+ ti,nand-ecc-opt = "bch8";
+
+ gpmc,device-width = <2>;
+ gpmc,sync-clk-ps = <0>;
+ gpmc,cs-on-ns = <0>;
+ gpmc,cs-rd-off-ns = <44>;
+ gpmc,cs-wr-off-ns = <44>;
+ gpmc,adv-on-ns = <6>;
+ gpmc,adv-rd-off-ns = <34>;
+ gpmc,adv-wr-off-ns = <44>;
+ gpmc,we-off-ns = <40>;
+ gpmc,oe-off-ns = <54>;
+ gpmc,access-ns = <64>;
+ gpmc,rd-cycle-ns = <82>;
+ gpmc,wr-cycle-ns = <82>;
+ gpmc,wr-access-ns = <40>;
+ gpmc,wr-data-mux-bus-ns = <0>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ti,elm-id = <&elm>;
+ /* MTD partition table */
+ partition@0 {
+ label = "SPL1";
+ reg = <0x00000000 0x000020000>;
+ };
+ partition@1 {
+ label = "SPL2";
+ reg = <0x00020000 0x00020000>;
+ };
+ partition@2 {
+ label = "SPL3";
+ reg = <0x00040000 0x00020000>;
+ };
+ partition@3 {
+ label = "SPL4";
+ reg = <0x00060000 0x00020000>;
+ };
+ partition@4 {
+ label = "U-boot";
+ reg = <0x00080000 0x001e0000>;
+ };
+ partition@5 {
+ label = "environment";
+ reg = <0x00260000 0x00020000>;
+ };
+ partition@6 {
+ label = "Kernel";
+ reg = <0x00280000 0x00500000>;
+ };
+ partition@7 {
+ label = "File-System";
+ reg = <0x00780000 0x0F880000>;
+ };
+ };
+};
--
1.8.1.5
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/5] mtd: nand: omap2: Fix device detection path
2013-10-24 22:12 [PATCH 0/5] Assorted OMAP2 NAND clean-ups Ezequiel Garcia
2013-10-24 22:12 ` [PATCH 1/5] ARM: am335x-bone: Add support for 16-bit NAND cape Ezequiel Garcia
@ 2013-10-24 22:12 ` Ezequiel Garcia
2013-10-24 22:12 ` [PATCH 3/5] mtd: nand: omap2: Fix OMAP_BCH option dependency Ezequiel Garcia
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Ezequiel Garcia @ 2013-10-24 22:12 UTC (permalink / raw)
To: linux-mtd, linux-omap
Cc: Brian Norris, Pekon Gupta, Felipe Balbi, Ezequiel Garcia
From: Pekon Gupta <pekon@ti.com>
Because the device bus can be 8-bit or 16-bit width, yet ONFI detection
cannot work in 16-bit mode, we need to set the NAND_BUSWIDTH_AUTO option
which allows proper initialization configuration.
Once the bus width is detected, nand_scan_ident() updates the nand_chip struct
'option' field to use the appropriate read/write functions and configure
the ECC engine.
Signed-off-by: Pekon Gupta <pekon@ti.com>
[rebased and clean-up a bit pekon's original work]
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/mtd/nand/omap2.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 4ecf0e5..e01a936 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1855,8 +1855,7 @@ static int omap_nand_probe(struct platform_device *pdev)
info->mtd.name = dev_name(&pdev->dev);
info->mtd.owner = THIS_MODULE;
- info->nand.options = pdata->devsize;
- info->nand.options |= NAND_SKIP_BBTSCAN;
+ info->nand.options |= NAND_SKIP_BBTSCAN | NAND_BUSWIDTH_AUTO;
#ifdef CONFIG_MTD_NAND_OMAP_BCH
info->of_node = pdata->of_node;
#endif
@@ -1903,6 +1902,10 @@ static int omap_nand_probe(struct platform_device *pdev)
info->nand.chip_delay = 50;
}
+ err = nand_scan_ident(&info->mtd, 1, NULL);
+ if (err < 0)
+ goto out_release_mem_region;
+
switch (pdata->xfer_type) {
case NAND_OMAP_PREFETCH_POLLED:
info->nand.read_buf = omap_read_buf_pref;
@@ -2013,17 +2016,6 @@ static int omap_nand_probe(struct platform_device *pdev)
}
}
- /* DIP switches on some boards change between 8 and 16 bit
- * bus widths for flash. Try the other width if the first try fails.
- */
- if (nand_scan_ident(&info->mtd, 1, NULL)) {
- info->nand.options ^= NAND_BUSWIDTH_16;
- if (nand_scan_ident(&info->mtd, 1, NULL)) {
- err = -ENXIO;
- goto out_release_mem_region;
- }
- }
-
/* rom code layout */
if (pdata->ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE) {
--
1.8.1.5
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 3/5] mtd: nand: omap2: Fix OMAP_BCH option dependency
2013-10-24 22:12 [PATCH 0/5] Assorted OMAP2 NAND clean-ups Ezequiel Garcia
2013-10-24 22:12 ` [PATCH 1/5] ARM: am335x-bone: Add support for 16-bit NAND cape Ezequiel Garcia
2013-10-24 22:12 ` [PATCH 2/5] mtd: nand: omap2: Fix device detection path Ezequiel Garcia
@ 2013-10-24 22:12 ` Ezequiel Garcia
2013-10-24 22:12 ` [PATCH 4/5] mtd: nand: omap2: Use devm_kzalloc Ezequiel Garcia
2013-10-24 22:12 ` [PATCH 5/5] mtd: nand: omap2: Use devm_ioremap_resource Ezequiel Garcia
4 siblings, 0 replies; 8+ messages in thread
From: Ezequiel Garcia @ 2013-10-24 22:12 UTC (permalink / raw)
To: linux-mtd, linux-omap
Cc: Brian Norris, Pekon Gupta, Felipe Balbi, Ezequiel Garcia
This option does not need to depend in MTD_NAND, for it's enclosed
under it. Also, it's wrong to make it depend in ARCH_OMAP3 only
since the controller is used in a wider range of SoCs.
Instead, just leave the dependency on the OMAP2 driver option.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/mtd/nand/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index d885298..8187466 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -95,7 +95,7 @@ config MTD_NAND_OMAP2
platforms.
config MTD_NAND_OMAP_BCH
- depends on MTD_NAND && MTD_NAND_OMAP2 && ARCH_OMAP3
+ depends on MTD_NAND_OMAP2
tristate "Enable support for hardware BCH error correction"
default n
select BCH
--
1.8.1.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] mtd: nand: omap2: Use devm_kzalloc
2013-10-24 22:12 [PATCH 0/5] Assorted OMAP2 NAND clean-ups Ezequiel Garcia
` (2 preceding siblings ...)
2013-10-24 22:12 ` [PATCH 3/5] mtd: nand: omap2: Fix OMAP_BCH option dependency Ezequiel Garcia
@ 2013-10-24 22:12 ` Ezequiel Garcia
2013-10-24 22:24 ` Belisko Marek
2013-10-24 22:12 ` [PATCH 5/5] mtd: nand: omap2: Use devm_ioremap_resource Ezequiel Garcia
4 siblings, 1 reply; 8+ messages in thread
From: Ezequiel Garcia @ 2013-10-24 22:12 UTC (permalink / raw)
To: linux-mtd, linux-omap
Cc: Brian Norris, Pekon Gupta, Felipe Balbi, Ezequiel Garcia
This simplifies the error path and makes the code less error-prone.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/mtd/nand/omap2.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index e01a936..d4cafb0 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1837,7 +1837,7 @@ static int omap_nand_probe(struct platform_device *pdev)
return -ENODEV;
}
- info = kzalloc(sizeof(struct omap_nand_info), GFP_KERNEL);
+ info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
@@ -2066,9 +2066,6 @@ out_release_mem_region:
if (info->gpmc_irq_fifo > 0)
free_irq(info->gpmc_irq_fifo, info);
release_mem_region(info->phys_base, info->mem_size);
-out_free_info:
- kfree(info);
-
return err;
}
@@ -2091,7 +2088,6 @@ static int omap_nand_remove(struct platform_device *pdev)
nand_release(&info->mtd);
iounmap(info->nand.IO_ADDR_R);
release_mem_region(info->phys_base, info->mem_size);
- kfree(info);
return 0;
}
--
1.8.1.5
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 4/5] mtd: nand: omap2: Use devm_kzalloc
2013-10-24 22:12 ` [PATCH 4/5] mtd: nand: omap2: Use devm_kzalloc Ezequiel Garcia
@ 2013-10-24 22:24 ` Belisko Marek
2013-10-24 22:50 ` Ezequiel Garcia
0 siblings, 1 reply; 8+ messages in thread
From: Belisko Marek @ 2013-10-24 22:24 UTC (permalink / raw)
To: Ezequiel Garcia
Cc: linux-mtd@lists.infradead.org, linux-omap@vger.kernel.org,
Brian Norris, Pekon Gupta, Felipe Balbi
Hi,
On Fri, Oct 25, 2013 at 12:12 AM, Ezequiel Garcia
<ezequiel.garcia@free-electrons.com> wrote:
> This simplifies the error path and makes the code less error-prone.
>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
> drivers/mtd/nand/omap2.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> index e01a936..d4cafb0 100644
> --- a/drivers/mtd/nand/omap2.c
> +++ b/drivers/mtd/nand/omap2.c
> @@ -1837,7 +1837,7 @@ static int omap_nand_probe(struct platform_device *pdev)
> return -ENODEV;
> }
>
> - info = kzalloc(sizeof(struct omap_nand_info), GFP_KERNEL);
> + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
> if (!info)
> return -ENOMEM;
>
> @@ -2066,9 +2066,6 @@ out_release_mem_region:
> if (info->gpmc_irq_fifo > 0)
> free_irq(info->gpmc_irq_fifo, info);
> release_mem_region(info->phys_base, info->mem_size);
> -out_free_info:
You remove ^^^^ statement but it's still used in line ~1868 as return when
cannot get resource.
> - kfree(info);
> -
> return err;
> }
>
> @@ -2091,7 +2088,6 @@ static int omap_nand_remove(struct platform_device *pdev)
> nand_release(&info->mtd);
> iounmap(info->nand.IO_ADDR_R);
> release_mem_region(info->phys_base, info->mem_size);
> - kfree(info);
> return 0;
> }
>
> --
> 1.8.1.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
BR,
marek
--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer
Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] mtd: nand: omap2: Use devm_kzalloc
2013-10-24 22:24 ` Belisko Marek
@ 2013-10-24 22:50 ` Ezequiel Garcia
0 siblings, 0 replies; 8+ messages in thread
From: Ezequiel Garcia @ 2013-10-24 22:50 UTC (permalink / raw)
To: Belisko Marek
Cc: linux-mtd@lists.infradead.org, linux-omap@vger.kernel.org,
Brian Norris, Pekon Gupta, Felipe Balbi
On Fri, Oct 25, 2013 at 12:24:38AM +0200, Belisko Marek wrote:
> Hi,
>
> On Fri, Oct 25, 2013 at 12:12 AM, Ezequiel Garcia
> <ezequiel.garcia@free-electrons.com> wrote:
> > This simplifies the error path and makes the code less error-prone.
> >
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> > drivers/mtd/nand/omap2.c | 6 +-----
> > 1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> > index e01a936..d4cafb0 100644
> > --- a/drivers/mtd/nand/omap2.c
> > +++ b/drivers/mtd/nand/omap2.c
> > @@ -1837,7 +1837,7 @@ static int omap_nand_probe(struct platform_device *pdev)
> > return -ENODEV;
> > }
> >
> > - info = kzalloc(sizeof(struct omap_nand_info), GFP_KERNEL);
> > + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
> > if (!info)
> > return -ENOMEM;
> >
> > @@ -2066,9 +2066,6 @@ out_release_mem_region:
> > if (info->gpmc_irq_fifo > 0)
> > free_irq(info->gpmc_irq_fifo, info);
> > release_mem_region(info->phys_base, info->mem_size);
> > -out_free_info:
> You remove ^^^^ statement but it's still used in line ~1868 as return when
> cannot get resource.
Right, I missed that. This happens when you do two cleanups at once and then
try to commit them separatedly!
Thanks!
--
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/5] mtd: nand: omap2: Use devm_ioremap_resource
2013-10-24 22:12 [PATCH 0/5] Assorted OMAP2 NAND clean-ups Ezequiel Garcia
` (3 preceding siblings ...)
2013-10-24 22:12 ` [PATCH 4/5] mtd: nand: omap2: Use devm_kzalloc Ezequiel Garcia
@ 2013-10-24 22:12 ` Ezequiel Garcia
4 siblings, 0 replies; 8+ messages in thread
From: Ezequiel Garcia @ 2013-10-24 22:12 UTC (permalink / raw)
To: linux-mtd, linux-omap
Cc: Brian Norris, Pekon Gupta, Felipe Balbi, Ezequiel Garcia
This simplifies the code and makes it less error-prone.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/mtd/nand/omap2.c | 30 +++++++-----------------------
1 file changed, 7 insertions(+), 23 deletions(-)
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index d4cafb0..c11e831 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1830,6 +1830,7 @@ static int omap_nand_probe(struct platform_device *pdev)
unsigned sig;
struct resource *res;
struct mtd_part_parser_data ppdata = {};
+ void __iomem *base;
pdata = dev_get_platdata(&pdev->dev);
if (pdata == NULL) {
@@ -1861,29 +1862,15 @@ static int omap_nand_probe(struct platform_device *pdev)
#endif
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (res == NULL) {
- err = -EINVAL;
- dev_err(&pdev->dev, "error getting memory resource\n");
- goto out_free_info;
- }
-
- info->phys_base = res->start;
- info->mem_size = resource_size(res);
-
- if (!request_mem_region(info->phys_base, info->mem_size,
- pdev->dev.driver->name)) {
- err = -EBUSY;
- goto out_free_info;
- }
-
- info->nand.IO_ADDR_R = ioremap(info->phys_base, info->mem_size);
- if (!info->nand.IO_ADDR_R) {
- err = -ENOMEM;
- goto out_release_mem_region;
+ base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(base)) {
+ err = PTR_ERR(base);
+ return err;
}
info->nand.controller = &info->controller;
+ info->nand.IO_ADDR_R = base;
info->nand.IO_ADDR_W = info->nand.IO_ADDR_R;
info->nand.cmd_ctrl = omap_hwcontrol;
@@ -1904,7 +1891,7 @@ static int omap_nand_probe(struct platform_device *pdev)
err = nand_scan_ident(&info->mtd, 1, NULL);
if (err < 0)
- goto out_release_mem_region;
+ return err;
switch (pdata->xfer_type) {
case NAND_OMAP_PREFETCH_POLLED:
@@ -2065,7 +2052,6 @@ out_release_mem_region:
free_irq(info->gpmc_irq_count, info);
if (info->gpmc_irq_fifo > 0)
free_irq(info->gpmc_irq_fifo, info);
- release_mem_region(info->phys_base, info->mem_size);
return err;
}
@@ -2086,8 +2072,6 @@ static int omap_nand_remove(struct platform_device *pdev)
/* Release NAND device, its internal structures and partitions */
nand_release(&info->mtd);
- iounmap(info->nand.IO_ADDR_R);
- release_mem_region(info->phys_base, info->mem_size);
return 0;
}
--
1.8.1.5
^ permalink raw reply related [flat|nested] 8+ messages in thread