aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux-2.6.34/ts72xx/0014-ts7200_nor_flash.patch
blob: c76ad361ce6209f42005c1cc824ebf131eeb9060 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
From 116d99d9f45c30d3b1c80b54fed8bf406aa590f7 Mon Sep 17 00:00:00 2001
From: Matthieu Crapet <mcrapet@gmail.com>
Date: Sat, 19 Jun 2010 16:56:48 +0200
Subject: [PATCH 14/18] ts7200_nor_flash

Deal with 8mb or 16mb NOR Flash (TS-7200 only)
---
 drivers/mtd/maps/Kconfig        |   15 +++++
 drivers/mtd/maps/Makefile       |    1 +
 drivers/mtd/maps/ts7200_flash.c |  116 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 132 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/maps/ts7200_flash.c

diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index aa2807d..5d12903 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -422,6 +422,21 @@ config MTD_H720X
 	  This enables access to the flash chips on the Hynix evaluation boards.
 	  If you have such a board, say 'Y'.
 
+config MTD_TS7200_NOR
+	tristate "CFI Flash device mapped on TS-7200"
+	depends on MTD_CFI && MACH_TS72XX
+	help
+	  This provides a map driver for the on-board flash of the Technologic
+	  System's TS-7200 board. The 8MB (or 16MB) flash is splitted into 3 partitions
+	  which are accessed as separate MTD devices.
+
+config MTD_TS7200_NOR_SIZE
+	int "Flash size (8 or 16mb)"
+	depends on MTD_TS7200_NOR
+	default "8"
+	help
+	  Enter the NOR Flash size of your TS-7200 board. Can be 8 or 16.
+
 # This needs CFI or JEDEC, depending on the cards found.
 config MTD_PCI
 	tristate "PCI MTD driver"
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index bb035cd..775c2e7 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_MTD_DMV182)	+= dmv182.o
 obj-$(CONFIG_MTD_PLATRAM)	+= plat-ram.o
 obj-$(CONFIG_MTD_INTEL_VR_NOR)	+= intel_vr_nor.o
 obj-$(CONFIG_MTD_BFIN_ASYNC)	+= bfin-async-flash.o
+obj-$(CONFIG_MTD_TS7200_NOR)	+= ts7200_flash.o
 obj-$(CONFIG_MTD_RBTX4939)	+= rbtx4939-flash.o
 obj-$(CONFIG_MTD_VMU)		+= vmu-flash.o
 obj-$(CONFIG_MTD_GPIO_ADDR)	+= gpio-addr-flash.o
diff --git a/drivers/mtd/maps/ts7200_flash.c b/drivers/mtd/maps/ts7200_flash.c
new file mode 100644
index 0000000..94fb4f4
--- /dev/null
+++ b/drivers/mtd/maps/ts7200_flash.c
@@ -0,0 +1,116 @@
+/*
+ * ts7200_flash.c - mapping for TS-7200 SBCs (8mb NOR flash)
+ * No platform_device resource is used here. All is hardcoded.
+ *
+ * (c) Copyright 2006-2010  Matthieu Crapet <mcrapet@gmail.com>
+ * Based on ts5500_flash.c by Sean Young <sean@mess.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <asm/io.h>
+#include <asm/sizes.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+#include <mach/ep93xx-regs.h>
+
+
+static struct mtd_info *mymtd;
+
+static struct map_info ts7200nor_map = {
+	.name		= "Full TS-7200 NOR flash",
+	.size		= 0,		/* filled in later */
+	.bankwidth	= 2,
+	.phys		= EP93XX_CS6_PHYS_BASE,
+};
+
+/*
+ * MTD partitioning stuff
+ */
+#ifdef CONFIG_MTD_PARTITIONS
+
+#define TS7200_BOOTROM_PART_SIZE	(SZ_128K)
+#define TS7200_REDBOOT_PART_SIZE	(15*SZ_128K)
+
+static struct mtd_partition ts7200_nor_parts[] =
+{
+	{
+		.name		= "TS-BOOTROM",
+		.offset		= 0,
+		.size		= TS7200_BOOTROM_PART_SIZE,
+		.mask_flags	= MTD_WRITEABLE,	/* force read-only */
+	},
+	{
+		.name		= "RootFS",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= 0,			/* filled in later */
+	},
+	{
+		.name		= "Redboot",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= MTDPART_SIZ_FULL,	/* up to the end */
+	}
+};
+#endif
+
+static int __init ts7200_nor_init(void)
+{
+	if (CONFIG_MTD_TS7200_NOR_SIZE <= 8)
+		ts7200nor_map.size = SZ_8M;
+	else
+		ts7200nor_map.size = SZ_16M;
+
+	printk(KERN_NOTICE "TS-7200 flash mapping: %ldmo at 0x%x\n",
+			ts7200nor_map.size / SZ_1M, ts7200nor_map.phys);
+
+	ts7200nor_map.virt = ioremap(ts7200nor_map.phys, ts7200nor_map.size - 1);
+	if (!ts7200nor_map.virt) {
+		printk("ts7200_flash: failed to ioremap\n");
+		return -EIO;
+	}
+
+	simple_map_init(&ts7200nor_map);
+	mymtd = do_map_probe("cfi_probe", &ts7200nor_map);
+	if (mymtd) {
+		mymtd->owner = THIS_MODULE;
+		add_mtd_device(mymtd);
+		#ifdef CONFIG_MTD_PARTITIONS
+		ts7200_nor_parts[1].size = ts7200nor_map.size - TS7200_REDBOOT_PART_SIZE;
+		return add_mtd_partitions(mymtd, ts7200_nor_parts, ARRAY_SIZE(ts7200_nor_parts));
+		#else
+		return 0;
+		#endif
+	}
+
+	iounmap(ts7200nor_map.virt);
+	return -ENXIO;
+}
+
+static void __exit ts7200_nor_exit(void)
+{
+	if (mymtd) {
+		del_mtd_device(mymtd);
+		map_destroy(mymtd);
+		mymtd = NULL;
+	}
+	if (ts7200nor_map.virt) {
+		iounmap(ts7200nor_map.virt);
+		ts7200nor_map.virt = 0;
+	}
+}
+
+module_init(ts7200_nor_init);
+module_exit(ts7200_nor_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>");
+MODULE_DESCRIPTION("MTD map driver for TS-7200 board");
+MODULE_VERSION("0.1");
-- 
1.7.1