diff options
Diffstat (limited to 'arch/powerpc/platforms/44x/warp-nand.c')
-rw-r--r-- | arch/powerpc/platforms/44x/warp-nand.c | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/arch/powerpc/platforms/44x/warp-nand.c b/arch/powerpc/platforms/44x/warp-nand.c index 9150318cfc56..e55746b824b4 100644 --- a/arch/powerpc/platforms/44x/warp-nand.c +++ b/arch/powerpc/platforms/44x/warp-nand.c | |||
@@ -11,8 +11,10 @@ | |||
11 | #include <linux/mtd/partitions.h> | 11 | #include <linux/mtd/partitions.h> |
12 | #include <linux/mtd/nand.h> | 12 | #include <linux/mtd/nand.h> |
13 | #include <linux/mtd/ndfc.h> | 13 | #include <linux/mtd/ndfc.h> |
14 | #include <linux/of.h> | ||
14 | #include <asm/machdep.h> | 15 | #include <asm/machdep.h> |
15 | 16 | ||
17 | |||
16 | #ifdef CONFIG_MTD_NAND_NDFC | 18 | #ifdef CONFIG_MTD_NAND_NDFC |
17 | 19 | ||
18 | #define CS_NAND_0 1 /* use chip select 1 for NAND device 0 */ | 20 | #define CS_NAND_0 1 /* use chip select 1 for NAND device 0 */ |
@@ -35,13 +37,23 @@ static struct mtd_partition nand_parts[] = { | |||
35 | { | 37 | { |
36 | .name = "root", | 38 | .name = "root", |
37 | .offset = 0x0200000, | 39 | .offset = 0x0200000, |
38 | .size = 0x3400000 | 40 | .size = 0x3E00000 |
41 | }, | ||
42 | { | ||
43 | .name = "persistent", | ||
44 | .offset = 0x4000000, | ||
45 | .size = 0x4000000 | ||
39 | }, | 46 | }, |
40 | { | 47 | { |
41 | .name = "user", | 48 | .name = "persistent1", |
42 | .offset = 0x3600000, | 49 | .offset = 0x8000000, |
43 | .size = 0x0A00000 | 50 | .size = 0x4000000 |
44 | }, | 51 | }, |
52 | { | ||
53 | .name = "persistent2", | ||
54 | .offset = 0xC000000, | ||
55 | .size = 0x4000000 | ||
56 | } | ||
45 | }; | 57 | }; |
46 | 58 | ||
47 | struct ndfc_controller_settings warp_ndfc_settings = { | 59 | struct ndfc_controller_settings warp_ndfc_settings = { |
@@ -67,27 +79,22 @@ static struct platform_device warp_ndfc_device = { | |||
67 | .resource = &warp_ndfc, | 79 | .resource = &warp_ndfc, |
68 | }; | 80 | }; |
69 | 81 | ||
70 | static struct nand_ecclayout nand_oob_16 = { | 82 | /* Do NOT set the ecclayout: let it default so it is correct for both |
71 | .eccbytes = 3, | 83 | * 64M and 256M flash chips. |
72 | .eccpos = { 0, 1, 2, 3, 6, 7 }, | 84 | */ |
73 | .oobfree = { {.offset = 8, .length = 16} } | ||
74 | }; | ||
75 | |||
76 | static struct platform_nand_chip warp_nand_chip0 = { | 85 | static struct platform_nand_chip warp_nand_chip0 = { |
77 | .nr_chips = 1, | 86 | .nr_chips = 1, |
78 | .chip_offset = CS_NAND_0, | 87 | .chip_offset = CS_NAND_0, |
79 | .nr_partitions = ARRAY_SIZE(nand_parts), | 88 | .nr_partitions = ARRAY_SIZE(nand_parts), |
80 | .partitions = nand_parts, | 89 | .partitions = nand_parts, |
81 | .chip_delay = 50, | 90 | .chip_delay = 20, |
82 | .ecclayout = &nand_oob_16, | ||
83 | .priv = &warp_chip0_settings, | 91 | .priv = &warp_chip0_settings, |
84 | }; | 92 | }; |
85 | 93 | ||
86 | static struct platform_device warp_nand_device = { | 94 | static struct platform_device warp_nand_device = { |
87 | .name = "ndfc-chip", | 95 | .name = "ndfc-chip", |
88 | .id = 0, | 96 | .id = 0, |
89 | .num_resources = 1, | 97 | .num_resources = 0, |
90 | .resource = &warp_ndfc, | ||
91 | .dev = { | 98 | .dev = { |
92 | .platform_data = &warp_nand_chip0, | 99 | .platform_data = &warp_nand_chip0, |
93 | .parent = &warp_ndfc_device.dev, | 100 | .parent = &warp_ndfc_device.dev, |
@@ -96,6 +103,28 @@ static struct platform_device warp_nand_device = { | |||
96 | 103 | ||
97 | static int warp_setup_nand_flash(void) | 104 | static int warp_setup_nand_flash(void) |
98 | { | 105 | { |
106 | struct device_node *np; | ||
107 | |||
108 | /* Try to detect a rev A based on NOR size. */ | ||
109 | np = of_find_compatible_node(NULL, NULL, "cfi-flash"); | ||
110 | if (np) { | ||
111 | struct property *pp; | ||
112 | |||
113 | pp = of_find_property(np, "reg", NULL); | ||
114 | if (pp && (pp->length == 12)) { | ||
115 | u32 *v = pp->value; | ||
116 | if (v[2] == 0x4000000) { | ||
117 | /* Rev A = 64M NAND */ | ||
118 | warp_nand_chip0.nr_partitions = 3; | ||
119 | |||
120 | nand_parts[1].size = 0x3000000; | ||
121 | nand_parts[2].offset = 0x3200000; | ||
122 | nand_parts[2].size = 0x0e00000; | ||
123 | } | ||
124 | } | ||
125 | of_node_put(np); | ||
126 | } | ||
127 | |||
99 | platform_device_register(&warp_ndfc_device); | 128 | platform_device_register(&warp_ndfc_device); |
100 | platform_device_register(&warp_nand_device); | 129 | platform_device_register(&warp_nand_device); |
101 | 130 | ||