upgrade to 2.6.17, probably break some stuff temporary
[openwrt.git] / target / linux / aruba-2.6 / patches / 001-flash.patch
1 diff -Nur linux-2.6.15/arch/mips/aruba/flash_lock.c linux-2.6.15-openwrt/arch/mips/aruba/flash_lock.c
2 --- linux-2.6.15/arch/mips/aruba/flash_lock.c   1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.15-openwrt/arch/mips/aruba/flash_lock.c   2006-01-10 00:32:32.000000000 +0100
4 @@ -0,0 +1,27 @@
5 +#include <linux/module.h>
6 +#include <linux/types.h>
7 +#include <asm/bootinfo.h>
8 +
9 +#define AP70_PROT_ADDR 0xb8010008
10 +#define AP70_PROT_DATA 0x8
11 +#define AP60_PROT_ADDR 0xB8400000
12 +#define AP60_PROT_DATA 0x04000000
13 +
14 +void unlock_ap60_70_flash(void)
15 +{
16 +       volatile __u32 val;
17 +       switch (mips_machtype) {
18 +               case MACH_ARUBA_AP70:
19 +                       val = *(volatile __u32 *)AP70_PROT_ADDR;
20 +                       val &= ~(AP70_PROT_DATA);
21 +                       *(volatile __u32 *)AP70_PROT_ADDR = val;
22 +                       break;
23 +               case MACH_ARUBA_AP65:
24 +               case MACH_ARUBA_AP60:
25 +               default:
26 +                       val = *(volatile __u32 *)AP60_PROT_ADDR;
27 +                       val &= ~(AP60_PROT_DATA);
28 +                       *(volatile __u32 *)AP60_PROT_ADDR = val;
29 +                       break;
30 +       }
31 +}
32 diff -Nur linux-2.6.15/drivers/mtd/chips/cfi_probe.c linux-2.6.15-openwrt/drivers/mtd/chips/cfi_probe.c
33 --- linux-2.6.15/drivers/mtd/chips/cfi_probe.c  2006-01-03 04:21:10.000000000 +0100
34 +++ linux-2.6.15-openwrt/drivers/mtd/chips/cfi_probe.c  2006-01-10 00:32:32.000000000 +0100
35 @@ -26,6 +26,74 @@
36  static void print_cfi_ident(struct cfi_ident *);
37  #endif
38  
39 +#if 1
40 +
41 +#define AMD_AUTOSEL_OFF1       0xAAA
42 +#define AMD_AUTOSEL_OFF2       0x555
43 +#define AMD_MANUF_ID           0x1
44 +#define AMD_DEVICE_ID1         0xF6 /* T */
45 +#define AMD_DEVICE_ID2         0xF9 /* B */
46 +/* Foll. are definitions for Macronix Flash Part */
47 +#define MCX_MANUF_ID           0xC2
48 +#define MCX_DEVICE_ID1         0xA7
49 +#define MCX_DEVICE_ID2         0xA8
50 +/* Foll. common to both AMD and Macronix */
51 +#define FACTORY_LOCKED         0x99
52 +#define USER_LOCKED            0x19
53 +
54 +/* NOTE: AP-70/6x use BYTE mode flash access. Therefore the
55 + * lowest Addr. pin in the flash is not A0 but A-1 (A minus 1).
56 + * CPU's A0 is tied to Flash's A-1, A1 to A0 and so on. This
57 + * gives 4MB of byte-addressable mem. In byte mode, all addr
58 + * need to be multiplied by 2 (i.e compared to word mode).
59 + * NOTE: AMD_AUTOSEL_OFF1 and OFF2 are already mult. by 2
60 + * Just blindly use the addr offsets suggested in the manual
61 + * for byte mode and you'll be OK. Offs. in Table 6 need to
62 + * be mult by 2 (for getting autosel params)
63 + */
64 +void
65 +flash_detect(struct map_info *map, __u32 base, struct cfi_private *cfi)
66 +{
67 +       map_word val[3];
68 +       int osf = cfi->interleave * cfi->device_type; // =2 for AP70/6x
69 +       char *manuf, *part, *lock ;
70 +
71 +       if (osf != 1) return ;
72 +
73 +       cfi_send_gen_cmd(0xAA, AMD_AUTOSEL_OFF1, base, map, cfi, cfi->device_type, NULL);
74 +       cfi_send_gen_cmd(0x55, AMD_AUTOSEL_OFF2, base, map, cfi, cfi->device_type, NULL);
75 +       cfi_send_gen_cmd(0x90, AMD_AUTOSEL_OFF1, base, map, cfi, cfi->device_type, NULL);
76 +       val[0] = map_read(map, base) ; // manuf ID
77 +       val[1] = map_read(map, base+2) ; // device ID
78 +       val[2] = map_read(map, base+6) ; // lock indicator
79 +#if 0
80 +printk("v1=0x%x v2=0x%x v3=0x%x\n", val[0], val[1], val[2]) ;
81 +#endif
82 +       if (val[0].x[0] == AMD_MANUF_ID) {
83 +               manuf = "AMD Flash" ;
84 +               if (val[1].x[0] == AMD_DEVICE_ID1)
85 +                       part = "AM29LV320D (Top)" ;
86 +               else if (val[1].x[0] == AMD_DEVICE_ID2)
87 +                       part = "AM29LV320D (Bot)" ;
88 +               else part = "Unknown" ;
89 +       } else if (val[0].x[0] == MCX_MANUF_ID) {
90 +               manuf = "Macronix Flash" ;
91 +               if (val[1].x[0] == MCX_DEVICE_ID1)
92 +                       part = "MX29LV320A (Top)" ;
93 +               else if (val[1].x[0] == MCX_DEVICE_ID2)
94 +                       part = "MX29LV320A (Bot)" ;
95 +               else part = "Unknown" ;
96 +       } else
97 +               return ;
98 +       if (val[2].x[0] == FACTORY_LOCKED)
99 +               lock = "Factory Locked" ;
100 +       else if (val[2].x[0] == USER_LOCKED)
101 +               lock = "User Locked" ;
102 +       else lock = "Unknown locking" ;
103 +       printk("%s %s (%s)\n", manuf, part, lock) ;
104 +}
105 +#endif
106 +
107  static int cfi_probe_chip(struct map_info *map, __u32 base,
108                           unsigned long *chip_map, struct cfi_private *cfi);
109  static int cfi_chip_setup(struct map_info *map, struct cfi_private *cfi);
110 @@ -118,6 +186,10 @@
111         }
112  
113         xip_disable();
114 +#if 1
115 +       //cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
116 +       flash_detect(map, base, cfi) ;
117 +#endif
118         cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
119         cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
120         cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
121 diff -Nur linux-2.6.15/drivers/mtd/maps/physmap.c linux-2.6.15-openwrt/drivers/mtd/maps/physmap.c
122 --- linux-2.6.15/drivers/mtd/maps/physmap.c     2006-01-03 04:21:10.000000000 +0100
123 +++ linux-2.6.15-openwrt/drivers/mtd/maps/physmap.c     2006-01-10 00:32:32.000000000 +0100
124 @@ -34,15 +34,31 @@
125  static struct mtd_partition *mtd_parts;
126  static int                   mtd_parts_nb;
127  
128 -static int num_physmap_partitions;
129 -static struct mtd_partition *physmap_partitions;
130 +static int num_physmap_partitions = 3;
131 +static struct mtd_partition physmap_partitions[] = {
132 +       {
133 +                name:           "zImage",
134 +                size:           0x3f0000-0x80000,
135 +                offset:         0x80000,
136 +        },
137 +       {
138 +                name:           "JFFS2",
139 +                size:           0x3f0000-0x120000,
140 +                offset:         0x120000,
141 +       },
142 +       {
143 +               name:           "NVRAM",
144 +               size:           0x2000,
145 +               offset:         0x3f8000,
146 +       }
147 +};
148  
149  static const char *part_probes[] __initdata = {"cmdlinepart", "RedBoot", NULL};
150  
151  void physmap_set_partitions(struct mtd_partition *parts, int num_parts)
152  {
153 -       physmap_partitions=parts;
154 -       num_physmap_partitions=num_parts;
155 +//     physmap_partitions=parts;
156 +//     num_physmap_partitions=num_parts;
157  }
158  #endif /* CONFIG_MTD_PARTITIONS */
159