aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-22 16:32:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-22 16:32:53 -0400
commitf6a26ae7699416d86bea8cb68ce413571e9cab3c (patch)
treee91b7a7c7513151fe583721f7435cc9f5cdc4f42 /drivers/mtd/nand
parentcdd3a354a05b0c33fe33ab11a0fb0838396cad19 (diff)
parent48a5765e5104f1afd22c75c5030af3a6cf24b4c3 (diff)
Merge tag 'boards' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull arm-soc board specific changes from Olof Johansson: "While we generally attempt to get rid of board specific files and replace them with device tree based descriptions, a lot of platforms have not come that far: In shmobile, we add two new board files because their recently started effort to add DT support has not proceeded enough to use it for all of the important hardware. In Kirkwood, we are adding support for new boards with a combination of DT and board file contents in multiple cases. pxa/mmp and imx are extending support for existing board files but not adding new ones." Fix up trivial conflicts in arch/arm/mach-{mmp/ttc_dkb.c,shmobile/{Kconfig,Makefile}} * tag 'boards' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (94 commits) ARM: shmobile: fix smp build ARM: kirkwood: Add support for RaidSonic IB-NAS6210/6220 using devicetree kirkwood: Add iconnect support orion/kirkwood: create a generic function for gpio led blinking kirkwood/orion: fix orion_gpio_set_blink ARM: kirkwood: Define DNS-320/DNS-325 NAND in fdt kirkwood: Allow nand to be configured via. devicetree mtd: Add orion_nand devicetree bindings ARM: kirkwood: Basic support for DNS-320 and DNS-325 ARM: mach-shmobile: Use DT_MACHINE for armadillo 800 eva ARM: mach-shmobile: Use DT_MACHINE for KZM9G ARM: pxa: hx4700: Add Synaptics NavPoint touchpad ARM: pxa: Use REGULATOR_SUPPLY macro ARM: mach-shmobile: kzm9g: enable SMP boot ARM: mach-shmobile: kzm9g: defconfig update ARM: mach-shmobile: kzm9g: add PCF8757 gpio-key ARM: mach-shmobile: kzm9g: add SDHI support ARM: mach-shmobile: kzm9g: add MMCIF support ARM: mach-shmobile: kzm9g: correct screen direction ARM: mach-shmobile: sh73a0.h: add GPIO_NR ...
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/orion_nand.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 1d3bfb26080c..0f50ef38b87b 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -13,6 +13,7 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/of.h>
16#include <linux/mtd/mtd.h> 17#include <linux/mtd/mtd.h>
17#include <linux/mtd/nand.h> 18#include <linux/mtd/nand.h>
18#include <linux/mtd/partitions.h> 19#include <linux/mtd/partitions.h>
@@ -74,11 +75,13 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
74static int __init orion_nand_probe(struct platform_device *pdev) 75static int __init orion_nand_probe(struct platform_device *pdev)
75{ 76{
76 struct mtd_info *mtd; 77 struct mtd_info *mtd;
78 struct mtd_part_parser_data ppdata = {};
77 struct nand_chip *nc; 79 struct nand_chip *nc;
78 struct orion_nand_data *board; 80 struct orion_nand_data *board;
79 struct resource *res; 81 struct resource *res;
80 void __iomem *io_base; 82 void __iomem *io_base;
81 int ret = 0; 83 int ret = 0;
84 u32 val = 0;
82 85
83 nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL); 86 nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL);
84 if (!nc) { 87 if (!nc) {
@@ -101,7 +104,32 @@ static int __init orion_nand_probe(struct platform_device *pdev)
101 goto no_res; 104 goto no_res;
102 } 105 }
103 106
104 board = pdev->dev.platform_data; 107 if (pdev->dev.of_node) {
108 board = devm_kzalloc(&pdev->dev, sizeof(struct orion_nand_data),
109 GFP_KERNEL);
110 if (!board) {
111 printk(KERN_ERR "orion_nand: failed to allocate board structure.\n");
112 ret = -ENOMEM;
113 goto no_res;
114 }
115 if (!of_property_read_u32(pdev->dev.of_node, "cle", &val))
116 board->cle = (u8)val;
117 else
118 board->cle = 0;
119 if (!of_property_read_u32(pdev->dev.of_node, "ale", &val))
120 board->ale = (u8)val;
121 else
122 board->ale = 1;
123 if (!of_property_read_u32(pdev->dev.of_node,
124 "bank-width", &val))
125 board->width = (u8)val * 8;
126 else
127 board->width = 8;
128 if (!of_property_read_u32(pdev->dev.of_node,
129 "chip-delay", &val))
130 board->chip_delay = (u8)val;
131 } else
132 board = pdev->dev.platform_data;
105 133
106 mtd->priv = nc; 134 mtd->priv = nc;
107 mtd->owner = THIS_MODULE; 135 mtd->owner = THIS_MODULE;
@@ -115,6 +143,10 @@ static int __init orion_nand_probe(struct platform_device *pdev)
115 if (board->chip_delay) 143 if (board->chip_delay)
116 nc->chip_delay = board->chip_delay; 144 nc->chip_delay = board->chip_delay;
117 145
146 WARN(board->width > 16,
147 "%d bit bus width out of range",
148 board->width);
149
118 if (board->width == 16) 150 if (board->width == 16)
119 nc->options |= NAND_BUSWIDTH_16; 151 nc->options |= NAND_BUSWIDTH_16;
120 152
@@ -129,8 +161,9 @@ static int __init orion_nand_probe(struct platform_device *pdev)
129 } 161 }
130 162
131 mtd->name = "orion_nand"; 163 mtd->name = "orion_nand";
132 ret = mtd_device_parse_register(mtd, NULL, NULL, board->parts, 164 ppdata.of_node = pdev->dev.of_node;
133 board->nr_parts); 165 ret = mtd_device_parse_register(mtd, NULL, &ppdata,
166 board->parts, board->nr_parts);
134 if (ret) { 167 if (ret) {
135 nand_release(mtd); 168 nand_release(mtd);
136 goto no_dev; 169 goto no_dev;
@@ -161,11 +194,19 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
161 return 0; 194 return 0;
162} 195}
163 196
197#ifdef CONFIG_OF
198static struct of_device_id orion_nand_of_match_table[] = {
199 { .compatible = "mrvl,orion-nand", },
200 {},
201};
202#endif
203
164static struct platform_driver orion_nand_driver = { 204static struct platform_driver orion_nand_driver = {
165 .remove = __devexit_p(orion_nand_remove), 205 .remove = __devexit_p(orion_nand_remove),
166 .driver = { 206 .driver = {
167 .name = "orion_nand", 207 .name = "orion_nand",
168 .owner = THIS_MODULE, 208 .owner = THIS_MODULE,
209 .of_match_table = of_match_ptr(orion_nand_of_match_table),
169 }, 210 },
170}; 211};
171 212