aboutsummaryrefslogtreecommitdiff
path: root/linux/3.1.6/0008-n35-Support-for-NAND-Flash-on-Acer-n35.patch
blob: c579e6b3cfdbc80ff3738d01419a04e06b38e857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--- linux-3.1.6/arch/arm/mach-s3c2410/mach-n30.c.orig	2011-12-31 16:29:50.173870254 +0100
+++ linux-3.1.6/arch/arm/mach-s3c2410/mach-n30.c	2011-12-31 16:35:23.089570614 +0100
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 
+#include <linux/delay.h>
 #include <linux/gpio_keys.h>
 #include <linux/init.h>
 #include <linux/gpio.h>
@@ -49,10 +50,67 @@
 #include <plat/cpu.h>
 #include <plat/devs.h>
 #include <plat/mci.h>
+#include <plat/nand.h>
 #include <plat/s3c2410.h>
 #include <plat/ts.h>
 #include <plat/udc.h>
 
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/nand_ecc.h>
+#include <linux/mtd/partitions.h>
+
+struct mtd_partition n35_default_nand_part[] = {
+	/* Original partitioning by manufacturer
+	 *
+	 * 0x0     - 0x3fff  NBoot
+	 * 0x4000  - 0x4fff  TOC
+	 * 0x8000  - 0x27fff Eboot
+	 * 0x28000 - 0x2bfff partition table
+	 * 0x2c000 -         data ...
+	 * FIXME: incomplete
+	 * */
+	{
+		.name   = "bootloader",
+		.offset = 0,
+		.size   = 0x28000,
+		.mask_flags = MTD_WRITEABLE,
+	},
+	{
+		.name   = "partition",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = 0x4000,
+	},
+	{
+		.name   = "kernel",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = 0x180000,
+	},
+	{
+		.name   = "rootfs",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = MTDPART_SIZ_FULL,
+	},
+};
+
+static struct s3c2410_nand_set n35_nand_sets[] = {
+	{
+		.name       = "chip0",
+		.nr_chips   = 1,
+		.nr_partitions  = ARRAY_SIZE(n35_default_nand_part),
+		.partitions = n35_default_nand_part,
+	},
+};
+
+static struct s3c2410_platform_nand n35_nand_info = {
+	.tacls      = 20,
+	.twrph0     = 35,
+	.twrph1     = 20,
+	.nr_sets    = ARRAY_SIZE(n35_nand_sets),
+	.sets       = n35_nand_sets,
+	.ignore_unset_ecc = 1,
+};
+
 static struct map_desc n30_iodesc[] __initdata = {
 	/* nothing here yet */
 };
@@ -476,6 +534,7 @@
 	&s3c_device_rtc,
 	&s3c_device_usbgadget,
 	&s3c_device_sdi,
+	&s3c_device_nand,
 	&s3c_device_adc,
 	&s3c_device_ts,
 	&s3c_device_timer[0],
@@ -665,6 +724,16 @@
 	}
 
 	if (machine_is_n35()) {
+		s3c_nand_set_platdata(&n35_nand_info);
+
+		/* Clear any locks and write protects on the flash. */
+		WARN_ON(gpio_request(S3C2410_GPC(5), "NAND write protection"));
+		gpio_set_value(S3C2410_GPC(5), 1);
+		udelay(1);
+		gpio_set_value(S3C2410_GPC(5), 0);
+		udelay(1);
+		gpio_set_value(S3C2410_GPC(5), 1);
+
 		/* Turn off suspend and switch the selectable USB port
 		 * to USB device mode.  Turn on suspend for the host
 		 * port since it is not connected on the N35.