12 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
20 #include <linux/reboot.h>
22 #include <linux/kdev_t.h>
28 #define INTEL_BUSWIDTH 1
29 #define AMD_WINDOW_MAXSIZE 0x00200000
30 #define AMD_BUSWIDTH 1
35 #define SC520_PAR_ADDR_MASK 0x00003fff
36 #define SC520_PAR_ADDR_SHIFT 16
37 #define SC520_PAR_TO_ADDR(par) \
38 (((par)&SC520_PAR_ADDR_MASK) << SC520_PAR_ADDR_SHIFT)
40 #define SC520_PAR_SIZE_MASK 0x01ffc000
41 #define SC520_PAR_SIZE_SHIFT 2
42 #define SC520_PAR_TO_SIZE(par) \
43 ((((par)&SC520_PAR_SIZE_MASK) << SC520_PAR_SIZE_SHIFT) + (64*1024))
45 #define SC520_PAR(cs, addr, size) \
47 ((((size)-(64*1024)) >> SC520_PAR_SIZE_SHIFT) & SC520_PAR_SIZE_MASK) | \
48 (((addr) >> SC520_PAR_ADDR_SHIFT) & SC520_PAR_ADDR_MASK))
50 #define SC520_PAR_BOOTCS 0x8a000000
51 #define SC520_PAR_ROMCS1 0xaa000000
52 #define SC520_PAR_ROMCS2 0xca000000
54 static void *nettel_mmcrp =
NULL;
56 #ifdef CONFIG_MTD_CFI_INTELEXT
65 #ifdef CONFIG_MTD_CFI_INTELEXT
66 static struct map_info nettel_intel_map = {
67 .
name =
"SnapGear Intel",
74 .
name =
"SnapGear kernel",
79 .name =
"SnapGear filesystem",
83 .name =
"SnapGear config",
88 .name =
"SnapGear Intel",
92 .name =
"SnapGear BIOS Config",
97 .name =
"SnapGear BIOS",
104 static struct map_info nettel_amd_map = {
105 .name =
"SnapGear AMD",
112 .name =
"SnapGear BIOS config",
113 .offset = 0x000e0000,
117 .name =
"SnapGear BIOS",
118 .offset = 0x000f0000,
122 .name =
"SnapGear AMD",
126 .name =
"SnapGear high BIOS",
127 .offset = 0x001f0000,
132 #define NUM_AMD_PARTITIONS ARRAY_SIZE(nettel_amd_partitions)
136 #ifdef CONFIG_MTD_CFI_INTELEXT
142 static int nettel_reboot_notifier(
struct notifier_block *nb,
unsigned long val,
void *
v)
148 for (b = 0; (b < nettel_intel_partitions[3].
size); b += 0x100000) {
149 cfi_send_gen_cmd(0xff, 0x55, b, &nettel_intel_map, cfi,
156 nettel_reboot_notifier,
NULL, 0
163 static int __init nettel_init(
void)
165 volatile unsigned long *amdpar;
166 unsigned long amdaddr, maxsize;
167 int num_amd_partitions=0;
168 #ifdef CONFIG_MTD_CFI_INTELEXT
169 volatile unsigned long *intel0par, *intel1par;
170 unsigned long orig_bootcspar, orig_romcs1par;
171 unsigned long intel0addr, intel0size;
172 unsigned long intel1addr, intel1size;
173 int intelboot, intel0cs, intel1cs;
174 int num_intel_partitions;
179 if (nettel_mmcrp ==
NULL) {
180 printk(
"SNAPGEAR: failed to disable MMCR cache??\n");
185 *((
unsigned char *) (nettel_mmcrp + 0xc64)) = 0x01;
187 amdpar = (
volatile unsigned long *) (nettel_mmcrp + 0xc4);
189 #ifdef CONFIG_MTD_CFI_INTELEXT
192 intel0par = (
volatile unsigned long *) (nettel_mmcrp + 0xc0);
194 intel1par = (
volatile unsigned long *) (nettel_mmcrp + 0xbc);
200 orig_bootcspar = *amdpar;
201 orig_romcs1par = *intel0par;
212 amdaddr = 0x20000000;
218 nettel_amd_map.
phys = amdaddr;
220 if (!nettel_amd_map.
virt) {
221 printk(
"SNAPGEAR: failed to ioremap() BOOTCS\n");
227 if ((amd_mtd =
do_map_probe(
"jedec_probe", &nettel_amd_map))) {
229 (
int)(amd_mtd->
size>>10));
236 num_amd_partitions--;
239 #ifdef CONFIG_MTD_CFI_INTELEXT
245 if (maxsize < (32 * 1024 * 1024))
246 maxsize = (32 * 1024 * 1024);
247 intel0addr = amdaddr + maxsize;
250 #ifdef CONFIG_MTD_CFI_INTELEXT
254 if (!orig_romcs1par) {
256 intel0par = (
volatile unsigned long *)
257 (nettel_mmcrp + 0xc4);
259 intel1par = (
volatile unsigned long *)
260 (nettel_mmcrp + 0xc0);
267 intel0par = (
volatile unsigned long *)
268 (nettel_mmcrp + 0xc0);
270 intel1par = (
volatile unsigned long *)
271 (nettel_mmcrp + 0xc4);
288 #ifdef CONFIG_MTD_CFI_INTELEXT
295 if (maxsize < (32 * 1024 * 1024))
296 maxsize = (32 * 1024 * 1024);
297 *intel0par =
SC520_PAR(intel0cs, intel0addr, maxsize);
303 nettel_intel_map.
size = maxsize;
304 nettel_intel_map.
phys = intel0addr;
306 if (!nettel_intel_map.
virt) {
307 printk(
"SNAPGEAR: failed to ioremap() ROMCS1\n");
313 intel_mtd =
do_map_probe(
"cfi_probe", &nettel_intel_map);
320 intel0size = intel_mtd->
size;
321 *intel0par =
SC520_PAR(intel0cs, intel0addr, intel0size);
327 intel1addr = intel0addr + intel0size;
328 *intel1par =
SC520_PAR(intel1cs, intel1addr, maxsize);
331 maxsize += intel0size;
338 nettel_intel_map.
size = maxsize;
340 if (!nettel_intel_map.
virt) {
341 printk(
"SNAPGEAR: failed to ioremap() ROMCS1/2\n");
346 intel_mtd =
do_map_probe(
"cfi_probe", &nettel_intel_map);
352 intel1size = intel_mtd->
size - intel0size;
353 if (intel1size > 0) {
354 *intel1par =
SC520_PAR(intel1cs, intel1addr, intel1size);
361 (
unsigned long long)(intel_mtd->
size >> 10));
365 num_intel_partitions =
ARRAY_SIZE(nettel_intel_partitions);
372 nettel_intel_partitions[1].
size = (intel0size + intel1size) -
374 nettel_intel_partitions[3].
size = intel0size + intel1size;
375 nettel_intel_partitions[4].
offset =
376 (intel0size + intel1size) - intel_mtd->
erasesize;
378 nettel_intel_partitions[5].
offset =
379 nettel_intel_partitions[4].
offset;
380 nettel_intel_partitions[5].
size =
381 nettel_intel_partitions[4].
size;
384 num_intel_partitions -= 2;
387 num_intel_partitions);
395 #ifdef CONFIG_MTD_CFI_INTELEXT
401 #ifdef CONFIG_MTD_CFI_INTELEXT
416 static void __exit nettel_cleanup(
void)
418 #ifdef CONFIG_MTD_CFI_INTELEXT
429 if (nettel_amd_map.
virt) {
433 #ifdef CONFIG_MTD_CFI_INTELEXT
438 if (nettel_intel_map.
virt) {