aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2010-02-01 23:01:25 -0500
committerPaul Mundt <lethal@linux-sh.org>2010-02-01 23:01:25 -0500
commitb79c7adf82e8b8a6d6ad1dadf7e687a4a030cf8c (patch)
tree115e36ec79cc6484303d26a04333617b793b2915
parent9d3f1881abeae0494a27716b08fcf2d3264bb0fa (diff)
mtd: trivial sh_flctl changes
This patch contains a few changes for the sh_flctl driver: - not sh7723-only driver - get rid of kconfig dependency - use dev_err() instead of printk() - use __devinit and __devexit for probe()/remove() - fix probe() return values Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--drivers/mtd/nand/Kconfig4
-rw-r--r--drivers/mtd/nand/sh_flctl.c42
-rw-r--r--include/linux/mtd/sh_flctl.h1
3 files changed, 26 insertions, 21 deletions
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 677cd53f18c3..bb6465604235 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -457,10 +457,10 @@ config MTD_NAND_NOMADIK
457 457
458config MTD_NAND_SH_FLCTL 458config MTD_NAND_SH_FLCTL
459 tristate "Support for NAND on Renesas SuperH FLCTL" 459 tristate "Support for NAND on Renesas SuperH FLCTL"
460 depends on MTD_NAND && SUPERH && CPU_SUBTYPE_SH7723 460 depends on MTD_NAND && SUPERH
461 help 461 help
462 Several Renesas SuperH CPU has FLCTL. This option enables support 462 Several Renesas SuperH CPU has FLCTL. This option enables support
463 for NAND Flash using FLCTL. This driver support SH7723. 463 for NAND Flash using FLCTL.
464 464
465config MTD_NAND_DAVINCI 465config MTD_NAND_DAVINCI
466 tristate "Support NAND on DaVinci SoC" 466 tristate "Support NAND on DaVinci SoC"
diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index 02bef21f2e4b..ab068a503b29 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * SuperH FLCTL nand controller 2 * SuperH FLCTL nand controller
3 * 3 *
4 * Copyright © 2008 Renesas Solutions Corp. 4 * Copyright (c) 2008 Renesas Solutions Corp.
5 * Copyright © 2008 Atom Create Engineering Co., Ltd. 5 * Copyright (c) 2008 Atom Create Engineering Co., Ltd.
6 * 6 *
7 * Based on fsl_elbc_nand.c, Copyright © 2006-2007 Freescale Semiconductor 7 * Based on fsl_elbc_nand.c, Copyright (c) 2006-2007 Freescale Semiconductor
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
@@ -75,6 +75,11 @@ static void start_translation(struct sh_flctl *flctl)
75 writeb(TRSTRT, FLTRCR(flctl)); 75 writeb(TRSTRT, FLTRCR(flctl));
76} 76}
77 77
78static void timeout_error(struct sh_flctl *flctl, const char *str)
79{
80 dev_err(&flctl->pdev->dev, "Timeout occured in %s\n", str);
81}
82
78static void wait_completion(struct sh_flctl *flctl) 83static void wait_completion(struct sh_flctl *flctl)
79{ 84{
80 uint32_t timeout = LOOP_TIMEOUT_MAX; 85 uint32_t timeout = LOOP_TIMEOUT_MAX;
@@ -87,7 +92,7 @@ static void wait_completion(struct sh_flctl *flctl)
87 udelay(1); 92 udelay(1);
88 } 93 }
89 94
90 printk(KERN_ERR "wait_completion(): Timeout occured \n"); 95 timeout_error(flctl, __func__);
91 writeb(0x0, FLTRCR(flctl)); 96 writeb(0x0, FLTRCR(flctl));
92} 97}
93 98
@@ -132,7 +137,7 @@ static void wait_rfifo_ready(struct sh_flctl *flctl)
132 return; 137 return;
133 udelay(1); 138 udelay(1);
134 } 139 }
135 printk(KERN_ERR "wait_rfifo_ready(): Timeout occured \n"); 140 timeout_error(flctl, __func__);
136} 141}
137 142
138static void wait_wfifo_ready(struct sh_flctl *flctl) 143static void wait_wfifo_ready(struct sh_flctl *flctl)
@@ -146,7 +151,7 @@ static void wait_wfifo_ready(struct sh_flctl *flctl)
146 return; 151 return;
147 udelay(1); 152 udelay(1);
148 } 153 }
149 printk(KERN_ERR "wait_wfifo_ready(): Timeout occured \n"); 154 timeout_error(flctl, __func__);
150} 155}
151 156
152static int wait_recfifo_ready(struct sh_flctl *flctl, int sector_number) 157static int wait_recfifo_ready(struct sh_flctl *flctl, int sector_number)
@@ -198,7 +203,7 @@ static int wait_recfifo_ready(struct sh_flctl *flctl, int sector_number)
198 writel(0, FL4ECCCR(flctl)); 203 writel(0, FL4ECCCR(flctl));
199 } 204 }
200 205
201 printk(KERN_ERR "wait_recfifo_ready(): Timeout occured \n"); 206 timeout_error(flctl, __func__);
202 return 1; /* timeout */ 207 return 1; /* timeout */
203} 208}
204 209
@@ -214,7 +219,7 @@ static void wait_wecfifo_ready(struct sh_flctl *flctl)
214 return; 219 return;
215 udelay(1); 220 udelay(1);
216 } 221 }
217 printk(KERN_ERR "wait_wecfifo_ready(): Timeout occured \n"); 222 timeout_error(flctl, __func__);
218} 223}
219 224
220static void read_datareg(struct sh_flctl *flctl, int offset) 225static void read_datareg(struct sh_flctl *flctl, int offset)
@@ -769,38 +774,36 @@ static int flctl_chip_init_tail(struct mtd_info *mtd)
769 return 0; 774 return 0;
770} 775}
771 776
772static int __init flctl_probe(struct platform_device *pdev) 777static int __devinit flctl_probe(struct platform_device *pdev)
773{ 778{
774 struct resource *res; 779 struct resource *res;
775 struct sh_flctl *flctl; 780 struct sh_flctl *flctl;
776 struct mtd_info *flctl_mtd; 781 struct mtd_info *flctl_mtd;
777 struct nand_chip *nand; 782 struct nand_chip *nand;
778 struct sh_flctl_platform_data *pdata; 783 struct sh_flctl_platform_data *pdata;
779 int ret; 784 int ret = -ENXIO;
780 785
781 pdata = pdev->dev.platform_data; 786 pdata = pdev->dev.platform_data;
782 if (pdata == NULL) { 787 if (pdata == NULL) {
783 printk(KERN_ERR "sh_flctl platform_data not found.\n"); 788 dev_err(&pdev->dev, "no platform data defined\n");
784 return -ENODEV; 789 return -EINVAL;
785 } 790 }
786 791
787 flctl = kzalloc(sizeof(struct sh_flctl), GFP_KERNEL); 792 flctl = kzalloc(sizeof(struct sh_flctl), GFP_KERNEL);
788 if (!flctl) { 793 if (!flctl) {
789 printk(KERN_ERR "Unable to allocate NAND MTD dev structure.\n"); 794 dev_err(&pdev->dev, "failed to allocate driver data\n");
790 return -ENOMEM; 795 return -ENOMEM;
791 } 796 }
792 797
793 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 798 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
794 if (!res) { 799 if (!res) {
795 printk(KERN_ERR "%s: resource not found.\n", __func__); 800 dev_err(&pdev->dev, "failed to get I/O memory\n");
796 ret = -ENODEV;
797 goto err; 801 goto err;
798 } 802 }
799 803
800 flctl->reg = ioremap(res->start, res->end - res->start + 1); 804 flctl->reg = ioremap(res->start, resource_size(res));
801 if (flctl->reg == NULL) { 805 if (flctl->reg == NULL) {
802 printk(KERN_ERR "%s: ioremap error.\n", __func__); 806 dev_err(&pdev->dev, "failed to remap I/O memory\n");
803 ret = -ENOMEM;
804 goto err; 807 goto err;
805 } 808 }
806 809
@@ -808,6 +811,7 @@ static int __init flctl_probe(struct platform_device *pdev)
808 flctl_mtd = &flctl->mtd; 811 flctl_mtd = &flctl->mtd;
809 nand = &flctl->chip; 812 nand = &flctl->chip;
810 flctl_mtd->priv = nand; 813 flctl_mtd->priv = nand;
814 flctl->pdev = pdev;
811 flctl->hwecc = pdata->has_hwecc; 815 flctl->hwecc = pdata->has_hwecc;
812 816
813 flctl_register_init(flctl, pdata->flcmncr_val); 817 flctl_register_init(flctl, pdata->flcmncr_val);
@@ -846,7 +850,7 @@ err:
846 return ret; 850 return ret;
847} 851}
848 852
849static int __exit flctl_remove(struct platform_device *pdev) 853static int __devexit flctl_remove(struct platform_device *pdev)
850{ 854{
851 struct sh_flctl *flctl = platform_get_drvdata(pdev); 855 struct sh_flctl *flctl = platform_get_drvdata(pdev);
852 856
diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h
index e77c1cea404d..164c9d4013c0 100644
--- a/include/linux/mtd/sh_flctl.h
+++ b/include/linux/mtd/sh_flctl.h
@@ -96,6 +96,7 @@
96struct sh_flctl { 96struct sh_flctl {
97 struct mtd_info mtd; 97 struct mtd_info mtd;
98 struct nand_chip chip; 98 struct nand_chip chip;
99 struct platform_device *pdev;
99 void __iomem *reg; 100 void __iomem *reg;
100 101
101 uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */ 102 uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */