i.MX53 Nand support
Subsystems (6)
Sascha Hauer
maintainerPATCH RESEND 1/1 i.MX53 Nand support
Hi All,
The following patches add i.MX53 and dt support to mxc_nand. This is only a resent based on v3.6-rc3 as it seems this series slipped through the cracks last time I posted it.
So Artem, if there are no objections, please consider applying up to 3/4, I would then take 4/4 through my tree.
Sascha
The following changes since commit fea7a08acb13524b47711625eebea40a0ede69a0:
Linux 3.6-rc3 (2012-08-22 13:29:06 -0700)
are available in the git repository at:
git://git.pengutronix.de/git/imx/linux-2.6.git tags/mtd-imx53-nand
for you to fetch changes up to 587450da74aa7db28fe0e9a9ee2a3816140fa8f4:
ARM i.MX5: Add nand oftree support (2012-08-29 09:33:47 +0200)
----------------------------------------------------------------
Add i.MX53 and dt support to the mxc_nand driver
----------------------------------------------------------------
Sascha Hauer (4):
mtd nand mxc_nand: Use managed resources mtd nand mxc_nand: swap iomem resource order mtd nand mxc_nand: add i.MX53 support ARM i.MX5: Add nand oftree support
arch/arm/boot/dts/imx51.dtsi | 7 ++ arch/arm/boot/dts/imx53.dtsi | 7 ++ arch/arm/mach-imx/clk-imx51-imx53.c | 2 + arch/arm/plat-mxc/devices/platform-mxc_nand.c | 11 +- drivers/mtd/nand/mxc_nand.c | 137 ++++++++++++++----------- 5 files changed, 97 insertions(+), 67 deletions(-)
Sascha Hauer
maintainerPATCH 1/4 mtd nand mxc_nand: Use managed resources
To make the error path simpler and to make subsequent patches easier.
--- drivers/mtd/nand/mxc_nand.c | 70 ++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 47 deletions(-)
drivers/mtd/nand/mxc_nand.c +23 -47
@@ -1344,8 +1344,8 @@ static int __init mxcnd_probe(struct platform_device *pdev)int err =0 ;/* Allocate memory for MTD device structure and private data */ - host =kzalloc (sizeof (struct mxc_nand_host ) +NAND_MAX_PAGESIZE + -NAND_MAX_OOBSIZE ,GFP_KERNEL ); + host =devm_kzalloc (&pdev->dev,sizeof (struct mxc_nand_host ) + +NAND_MAX_PAGESIZE +NAND_MAX_OOBSIZE ,GFP_KERNEL );if (!host)return -ENOMEM ;
@@ -1372,26 +1372,17 @@ static int __init mxcnd_probe(struct platform_device *pdev) this->read_buf = mxc_nand_read_buf; this->verify_buf = mxc_nand_verify_buf; - host->clk =clk_get (&pdev->dev,"nfc" ); -if (IS_ERR (host->clk)) { - err =PTR_ERR (host->clk); - goto eclk; - } - -clk_prepare_enable (host->clk); - host->clk_act =1 ; + host->clk =devm_clk_get (&pdev->dev,"nfc" ); +if (IS_ERR (host->clk)) +return PTR_ERR (host->clk); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { - err = -ENODEV ; - goto eres; - } +if (!res) +return -ENODEV ; - host->base =ioremap (res->start,resource_size (res)); -if (!host->base) { - err = -ENOMEM ; - goto eres; - } + host->base =devm_request_and_ioremap (&pdev->dev, res); +if (!host->base) +return -ENOMEM ; host->main_area0 = host->base;
@@ -1399,7 +1390,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)if (err >0 ) err =mxcnd_probe_pdata (host);if (err <0 ) - goto eirq; +return err;if (host->devtype_data->regs_offset) host->regs = host->base + host->devtype_data->regs_offset;
@@ -1416,15 +1407,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)if (host->devtype_data->needs_ip) { res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (!res) { - err = -ENODEV ; - goto eirq; - } - host->regs_ip =ioremap (res->start,resource_size (res)); -if (!host->regs_ip) { - err = -ENOMEM ; - goto eirq; - } +if (!res) +return -ENODEV ; + host->regs_ip =devm_request_and_ioremap (&pdev->dev, res); +if (!host->regs_ip) +return -ENOMEM ; }if (host->pdata.hw_ecc) {
@@ -1458,9 +1445,13 @@ static int __init mxcnd_probe(struct platform_device *pdev)*/ host->devtype_data->irq_control (host,0 ); - err =request_irq (host->irq, mxc_nfc_irq,IRQF_DISABLED ,DRIVER_NAME , host); + err =devm_request_irq (&pdev->dev, host->irq, mxc_nfc_irq, +IRQF_DISABLED ,DRIVER_NAME , host);if (err) - goto eirq; +return err; + +clk_prepare_enable (host->clk); + host->clk_act =1 ;/* * Now that we "own" the interrupt make sure the interrupt mask bit is
@@ -1512,15 +1503,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)return 0 ; escan: -free_irq (host->irq, host); -eirq: -if (host->regs_ip) -iounmap (host->regs_ip); -iounmap (host->base); -eres: -clk_put (host->clk); -eclk: -kfree (host); +clk_disable_unprepare (host->clk);return err; }
@@ -1529,16 +1512,9 @@ static int __devexit mxcnd_remove(struct platform_device *pdev) {struct mxc_nand_host *host =platform_get_drvdata (pdev); -clk_put (host->clk); -platform_set_drvdata (pdev,NULL );nand_release (&host->mtd); -free_irq (host->irq, host); -if (host->regs_ip) -iounmap (host->regs_ip); -iounmap (host->base); -kfree (host);return 0 ; }
Signature · 1 line
1.7.10.4
Sascha Hauer
maintainerPATCH 2/4 mtd nand mxc_nand: swap iomem resource order
In reply to Sascha HauerThe i.MX v3 nand controller (i.MX5) needs two memory resources. Traditionally we have the AXI resource first. For sorting in this driver into the devicetree it feels much more natural to have the IP resource first. This patch swaps the ordering of these two resources.
--- arch/arm/plat-mxc/devices/platform-mxc_nand.c | 11 ++++---- drivers/mtd/nand/mxc_nand.c | 35 ++++++++++++++----------- 2 files changed, 24 insertions(+), 22 deletions(-)
arch/arm/plat-mxc/devices/platform-mxc_nand.c +5 -6
@@ -63,10 +63,6 @@ struct platform_device *__init imx_add_mxc_nand(/* AXI has to come first, that's how the mxc_nand driver expect it */ struct resource res[] = { { - .start = data->axibase, - .end = data->axibase +SZ_16K -1 , - .flags =IORESOURCE_MEM , - }, { .start = data->iobase, .end = data->iobase + data->iosize -1 , .flags =IORESOURCE_MEM ,
@@ -74,10 +70,13 @@ struct platform_device *__init imx_add_mxc_nand( .start = data->irq, .end = data->irq, .flags = IORESOURCE_IRQ, + }, { + .start = data->axibase, + .end = data->axibase + SZ_16K - 1, + .flags = IORESOURCE_MEM, }, };return imx_add_platform_device ("mxc_nand" , data->id, - res + !data->axibase, -ARRAY_SIZE (res) - !data->axibase, + res,ARRAY_SIZE (res) - !data->axibase, pdata,sizeof (*pdata)); }
drivers/mtd/nand/mxc_nand.c +19 -16
@@ -1376,7 +1376,25 @@ static int __init mxcnd_probe(struct platform_device *pdev)if (IS_ERR (host->clk))return PTR_ERR (host->clk); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + err =mxcnd_probe_dt (host); +if (err >0 ) + err =mxcnd_probe_pdata (host); +if (err <0 ) +return err; + +if (host->devtype_data->needs_ip) { + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -ENODEV ; + host->regs_ip =devm_request_and_ioremap (&pdev->dev, res); +if (!host->regs_ip) +return -ENOMEM ; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); + }else { + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + } +if (!res)return -ENODEV ;
@@ -1386,12 +1404,6 @@ static int __init mxcnd_probe(struct platform_device *pdev) host->main_area0 = host->base; - err =mxcnd_probe_dt (host); -if (err >0 ) - err =mxcnd_probe_pdata (host); -if (err <0 ) -return err; -if (host->devtype_data->regs_offset) host->regs = host->base + host->devtype_data->regs_offset; host->spare0 = host->base + host->devtype_data->spare0_offset;
@@ -1405,15 +1417,6 @@ static int __init mxcnd_probe(struct platform_device *pdev) this->ecc.size =512 ; this->ecc.layout = host->devtype_data->ecclayout_512; -if (host->devtype_data->needs_ip) { - res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (!res) -return -ENODEV ; - host->regs_ip =devm_request_and_ioremap (&pdev->dev, res); -if (!host->regs_ip) -return -ENOMEM ; - } -if (host->pdata.hw_ecc) { this->ecc.calculate = mxc_nand_calculate_ecc; this->ecc.hwctl = mxc_nand_enable_hwecc;
Signature · 1 line
1.7.10.4
Sascha Hauer
maintainerPATCH 3/4 mtd nand mxc_nand: add i.MX53 support
In reply to Sascha HauerThe only relevant change between i.MX51 and i.MX53 is that a bitfield is shifted one bit to the left.
--- drivers/mtd/nand/mxc_nand.c | 48 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-)
drivers/mtd/nand/mxc_nand.c +42 -6
@@ -43,8 +43,8 @@#define nfc_is_v21 () (cpu_is_mx25() || cpu_is_mx35())#define nfc_is_v1 () (cpu_is_mx31() || cpu_is_mx27() || cpu_is_mx21()) -#define nfc_is_v3_2 () (cpu_is_mx51() || cpu_is_mx53()) -#define nfc_is_v3 () nfc_is_v3_2() +#define nfc_is_v3_2a () cpu_is_mx51() +#define nfc_is_v3_2b () cpu_is_mx53()/* Addresses for NFC registers */ #define NFC_V1_V2_BUF_SIZE (host->regs + 0x00)
@@ -122,7 +122,7 @@#define NFC_V3_CONFIG2_2CMD_PHASES (1 << 4)#define NFC_V3_CONFIG2_NUM_ADDR_PHASE0 (1 << 5)#define NFC_V3_CONFIG2_ECC_MODE_8 (1 << 6) -#define NFC_V3_CONFIG2_PPB (x) (((x) & 0x3) << 7) +#define NFC_V3_CONFIG2_PPB (x, shift) (((x) & 0x3) << shift)#define NFC_V3_CONFIG2_NUM_ADDR_PHASE1 (x) (((x) & 0x3) << 12)#define NFC_V3_CONFIG2_INT_MSK (1 << 15)#define NFC_V3_CONFIG2_ST_CMD (x) (((x) & 0xff) << 24)
@@ -174,6 +174,7 @@ struct mxc_nand_devtype_data {int spare_len;int eccbytes;int eccsize; +int ppb_shift; };struct mxc_nand_host {
@@ -1021,7 +1022,9 @@ static void preset_v3(struct mtd_info *mtd) }if (mtd->writesize) { - config2 |=NFC_V3_CONFIG2_PPB (ffs (mtd->erasesize / mtd->writesize) -6 ); + config2 |=NFC_V3_CONFIG2_PPB ( +ffs (mtd->erasesize / mtd->writesize) -6 , + host->devtype_data->ppb_shift); host->eccsize =get_eccsize (mtd);if (host->eccsize ==8 ) config2 |=NFC_V3_CONFIG2_ECC_MODE_8 ;
@@ -1234,7 +1237,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = { .eccsize = 0, }; -/* v3: i.MX51, i.MX53 */ +/* v3.2a: i.MX51 */ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = { .preset = preset_v3, .send_cmd = send_cmd_v3,
@@ -1258,6 +1261,34 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = { .spare_len = 64, .eccbytes = 0, .eccsize = 0, + .ppb_shift = 7, +}; + +/* v3.2b: i.MX53 */ +static const struct mxc_nand_devtype_data imx53_nand_devtype_data = { + .preset = preset_v3, + .send_cmd = send_cmd_v3, + .send_addr = send_addr_v3, + .send_page = send_page_v3, + .send_read_id = send_read_id_v3, + .get_dev_status = get_dev_status_v3, + .check_int = check_int_v3, + .irq_control = irq_control_v3, + .get_ecc_status = get_ecc_status_v3, + .ecclayout_512 = &nandv2_hw_eccoob_smallpage, + .ecclayout_2k = &nandv2_hw_eccoob_largepage, + .ecclayout_4k = &nandv2_hw_eccoob_smallpage,/* XXX: needs fix */ + .select_chip = mxc_nand_select_chip_v1_v3, + .correct_data = mxc_nand_correct_data_v2_v3, + .irqpending_quirk =0 , + .needs_ip =1 , + .regs_offset =0 , + .spare0_offset =0x1000 , + .axi_offset =0x1e00 , + .spare_len =64 , + .eccbytes =0 , + .eccsize =0 , + .ppb_shift =8 , };#ifdef CONFIG_OF_MTD
@@ -1274,6 +1305,9 @@ static const struct of_device_id mxcnd_dt_ids[] = { }, { .compatible = "fsl,imx51-nand", .data = &imx51_nand_devtype_data, + }, { + .compatible = "fsl,imx53-nand", + .data = &imx53_nand_devtype_data, }, {/* sentinel */ } };
@@ -1327,8 +1361,10 @@ static int __init mxcnd_probe_pdata(struct mxc_nand_host *host) host->devtype_data = &imx27_nand_devtype_data; }else if (nfc_is_v21 ()) { host->devtype_data = &imx25_nand_devtype_data; - }else if (nfc_is_v3_2 ()) { + }else if (nfc_is_v3_2a ()) { host->devtype_data = &imx51_nand_devtype_data; + }else if (nfc_is_v3_2b ()) { + host->devtype_data = &imx53_nand_devtype_data; }else BUG ();
Signature · 1 line
1.7.10.4
Sascha Hauer
maintainerPATCH 4/4 ARM i.MX5: Add nand oftree support
In reply to Sascha HauerThis adds snippets to the i.MX51/53 devicetrees for the nand flash controller.
--- arch/arm/boot/dts/imx51.dtsi | 7 +++++++ arch/arm/boot/dts/imx53.dtsi | 7 +++++++ arch/arm/mach-imx/clk-imx51-imx53.c | 2 ++ 3 files changed, 16 insertions(+)
arch/arm/boot/dts/imx51.dtsi +7 -0
@@ -263,6 +263,13 @@ status = "disabled"; }; + nand at 83fdb000 { + compatible = "fsl,imx51-nand"; + reg = <0x83fdb000 0x1000 0xcfff0000 0x10000>; + interrupts = <8>; + status = "disabled"; + }; + ssi3: ssi at 83fe8000 { compatible = "fsl,imx51-ssi", "fsl,imx21-ssi"; reg = <0x83fe8000 0x4000>;
arch/arm/boot/dts/imx53.dtsi +7 -0
@@ -321,6 +321,13 @@ status = "disabled"; }; + nand at 63fdb000 { + compatible = "fsl,imx53-nand"; + reg = <0x63fdb000 0x1000 0xf7ff0000 0x10000>; + interrupts = <8>; + status = "disabled"; + }; + ssi3: ssi at 63fe8000 { compatible = "fsl,imx53-ssi", "fsl,imx21-ssi"; reg = <0x63fe8000 0x4000>;
arch/arm/mach-imx/clk-imx51-imx53.c +2 -0
@@ -367,6 +367,7 @@ int __init mx51_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,clk_register_clkdev (clk[ssi1_ipg_gate],NULL ,"83fcc000.ssi" );clk_register_clkdev (clk[ssi2_ipg_gate],NULL ,"70014000.ssi" );clk_register_clkdev (clk[ssi3_ipg_gate],NULL ,"83fe8000.ssi" ); +clk_register_clkdev (clk[nfc_gate],NULL ,"83fdb000.nand" );/* set the usboh3 parent to pll2_sw */ clk_set_parent (clk[usboh3_sel], clk[pll2_sw]);
@@ -455,6 +456,7 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,clk_register_clkdev (clk[ssi1_ipg_gate],NULL ,"63fcc000.ssi" );clk_register_clkdev (clk[ssi2_ipg_gate],NULL ,"50014000.ssi" );clk_register_clkdev (clk[ssi3_ipg_gate],NULL ,"63fd0000.ssi" ); +clk_register_clkdev (clk[nfc_gate],NULL ,"63fdb000.nand" );/* set SDHC root clock to 200MHZ*/ clk_set_rate (clk[esdhc_a_podf],200000000 );
Signature · 1 line
1.7.10.4
PATCH RESEND 1/1 i.MX53 Nand support
In reply to Sascha HauerQuoted 8 lines · Sascha Hauer
Hi All,
The following patches add i.MX53 and dt support to
mxc_nand. This is only a resent based on v3.6-rc3 as it seems this series slipped through the cracks last time I posted it.So Artem, if there are no objections, please consider applying up to 3/4, I would then take 4/4 through my tree.
Please, take a look at the l2-mtd.git tree, I already have all these patches. Actually, they are already in dwmw2's tree, the and were supposed to be merged already, but unfortunately the merge window was missed because (a) dwmw2 did not send a pull request early enough and
(b) Linus decided to punish late pull-request senders and closed the merge window 2 days earlier than usually.
Signature · 9 lines
Best Regards, Artem Bityutskiy -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120830/63b16be4/attachment.sig>
Sascha Hauer
maintainerPATCH RESEND 1/1 i.MX53 Nand support
Quoted 10 lines · Artem Bityutskiy
Quoted 8 lines · Sascha Hauer
Hi All,
The following patches add i.MX53 and dt support to
mxc_nand. This is only a resent based on v3.6-rc3 as it seems this series slipped through the cracks last time I posted it.So Artem, if there are no objections, please consider applying up to 3/4, I would then take 4/4 through my tree.
Quoted 6 lines
Please, take a look at the l2-mtd.git tree, I already have all these patches. Actually, they are already in dwmw2's tree, the and were supposed to be merged already, but unfortunately the merge window was missed because (a) dwmw2 did not send a pull request early enough and
(b) Linus decided to punish late pull-request senders and closed the merge window 2 days earlier than usually.
Ah, I missed to check the tree. Sorry for the noise then.
Thanks
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |