x86: add additional companion chip drivers to alix2 and geos
[openwrt.git] / package / uboot-lantiq / patches / 030-cfi-addr-fixup.patch
1 --- a/drivers/mtd/cfi_flash.c
2 +++ b/drivers/mtd/cfi_flash.c
3 @@ -85,6 +85,22 @@ flash_info_t flash_info[CFI_MAX_FLASH_BA
4 #define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_8BIT
5 #endif
6
7 +/*
8 + * Check if address fixup macros are defined, define defaults otherwise
9 + */
10 +#ifndef FLASH_FIXUP_ADDR_8
11 +#define FLASH_FIXUP_ADDR_8(addr) (addr)
12 +#endif
13 +#ifndef FLASH_FIXUP_ADDR_16
14 +#define FLASH_FIXUP_ADDR_16(addr) (addr)
15 +#endif
16 +#ifndef FLASH_FIXUP_ADDR_32
17 +#define FLASH_FIXUP_ADDR_32(addr) (addr)
18 +#endif
19 +#ifndef FLASH_FIXUP_ADDR_64
20 +#define FLASH_FIXUP_ADDR_64(addr) (addr)
21 +#endif
22 +
23 static void __flash_write8(u8 value, void *addr)
24 {
25 __raw_writeb(value, addr);
26 @@ -264,9 +280,9 @@ static inline uchar flash_read_uchar (fl
27
28 cp = flash_map (info, 0, offset);
29 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
30 - retval = flash_read8(cp);
31 + retval = flash_read8(FLASH_FIXUP_ADDR_8(cp));
32 #else
33 - retval = flash_read8(cp + info->portwidth - 1);
34 + retval = flash_read8(FLASH_FIXUP_ADDR_8(cp) + info->portwidth - 1);
35 #endif
36 flash_unmap (info, 0, offset, cp);
37 return retval;
38 @@ -280,7 +296,7 @@ static inline ushort flash_read_word (fl
39 ushort *addr, retval;
40
41 addr = flash_map (info, 0, offset);
42 - retval = flash_read16 (addr);
43 + retval = flash_read16 (FLASH_FIXUP_ADDR_16(addr));
44 flash_unmap (info, 0, offset, addr);
45 return retval;
46 }
47 @@ -305,19 +321,28 @@ static ulong flash_read_long (flash_info
48 debug ("long addr is at %p info->portwidth = %d\n", addr,
49 info->portwidth);
50 for (x = 0; x < 4 * info->portwidth; x++) {
51 - debug ("addr[%x] = 0x%x\n", x, flash_read8(addr + x));
52 + debug ("addr[%x] = 0x%x\n", x,
53 + flash_read8(FLASH_FIXUP_ADDR_32(addr) + x));
54 }
55 #endif
56 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
57 - retval = ((flash_read8(addr) << 16) |
58 - (flash_read8(addr + info->portwidth) << 24) |
59 - (flash_read8(addr + 2 * info->portwidth)) |
60 - (flash_read8(addr + 3 * info->portwidth) << 8));
61 + retval = ((flash_read8(FLASH_FIXUP_ADDR_8
62 + (addr) << 16) |
63 + (flash_read8(FLASH_FIXUP_ADDR_8
64 + (addr + info->portwidth)) << 24) |
65 + (flash_read8(FLASH_FIXUP_ADDR_8
66 + (addr + 2 * info->portwidth))) |
67 + (flash_read8(FLASH_FIXUP_ADDR_8
68 + (addr + 3 * info->portwidth)) << 8));
69 #else
70 - retval = ((flash_read8(addr + 2 * info->portwidth - 1) << 24) |
71 - (flash_read8(addr + info->portwidth - 1) << 16) |
72 - (flash_read8(addr + 4 * info->portwidth - 1) << 8) |
73 - (flash_read8(addr + 3 * info->portwidth - 1)));
74 + retval = ((flash_read8(FLASH_FIXUP_ADDR_8
75 + (addr + 2 * info->portwidth - 1)) << 24) |
76 + (flash_read8(FLASH_FIXUP_ADDR_8
77 + (addr + info->portwidth - 1)) << 16) |
78 + (flash_read8(FLASH_FIXUP_ADDR_8
79 + (addr + 4 * info->portwidth - 1)) << 8) |
80 + (flash_read8(FLASH_FIXUP_ADDR_8
81 + (addr + 3 * info->portwidth - 1))));
82 #endif
83 flash_unmap(info, sect, offset, addr);
84
85 @@ -338,21 +363,22 @@ void flash_write_cmd (flash_info_t * inf
86 flash_make_cmd (info, cmd, &cword);
87 switch (info->portwidth) {
88 case FLASH_CFI_8BIT:
89 - debug ("fwc addr %p cmd %x %x 8bit x %d bit\n", addr, cmd,
90 - cword.c, info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
91 - flash_write8(cword.c, addr);
92 + debug ("fwc addr %p cmd %x %x 8bit x %d bit\n",
93 + FLASH_FIXUP_ADDR_8(addr), cmd, cword.c,
94 + info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
95 + flash_write8(cword.c, FLASH_FIXUP_ADDR_8(addr));
96 break;
97 case FLASH_CFI_16BIT:
98 - debug ("fwc addr %p cmd %x %4.4x 16bit x %d bit\n", addr,
99 - cmd, cword.w,
100 + debug ("fwc addr %p cmd %x %4.4x 16bit x %d bit\n",
101 + FLASH_FIXUP_ADDR_16(addr), cmd, cword.w,
102 info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
103 - flash_write16(cword.w, addr);
104 + flash_write16(cword.w, FLASH_FIXUP_ADDR_16(addr));
105 break;
106 case FLASH_CFI_32BIT:
107 - debug ("fwc addr %p cmd %x %8.8lx 32bit x %d bit\n", addr,
108 - cmd, cword.l,
109 + debug ("fwc addr %p cmd %x %8.8lx 32bit x %d bit\n",
110 + FLASH_FIXUP_ADDR_32(addr), cmd, cword.l,
111 info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
112 - flash_write32(cword.l, addr);
113 + flash_write32(cword.l, FLASH_FIXUP_ADDR_32(addr));
114 break;
115 case FLASH_CFI_64BIT:
116 #ifdef DEBUG
117 @@ -362,11 +388,11 @@ void flash_write_cmd (flash_info_t * inf
118 print_longlong (str, cword.ll);
119
120 debug ("fwrite addr %p cmd %x %s 64 bit x %d bit\n",
121 - addr, cmd, str,
122 + FLASH_FIXUP_ADDR_64(addr), cmd, str,
123 info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
124 }
125 #endif
126 - flash_write64(cword.ll, addr);
127 + flash_write64(cword.ll, FLASH_FIXUP_ADDR_64(addr));
128 break;
129 }
130
131 @@ -397,16 +423,19 @@ static int flash_isequal (flash_info_t *
132 debug ("is= cmd %x(%c) addr %p ", cmd, cmd, addr);
133 switch (info->portwidth) {
134 case FLASH_CFI_8BIT:
135 - debug ("is= %x %x\n", flash_read8(addr), cword.c);
136 - retval = (flash_read8(addr) == cword.c);
137 + debug ("is= %x %x\n",
138 + flash_read8(FLASH_FIXUP_ADDR_8(addr)), cword.c);
139 + retval = (flash_read8(FLASH_FIXUP_ADDR_8(addr)) == cword.c);
140 break;
141 case FLASH_CFI_16BIT:
142 - debug ("is= %4.4x %4.4x\n", flash_read16(addr), cword.w);
143 - retval = (flash_read16(addr) == cword.w);
144 + debug ("is= %4.4x %4.4x\n",
145 + flash_read16(FLASH_FIXUP_ADDR_16(addr)), cword.w);
146 + retval = (flash_read16(FLASH_FIXUP_ADDR_16(addr)) == cword.w);
147 break;
148 case FLASH_CFI_32BIT:
149 - debug ("is= %8.8x %8.8lx\n", flash_read32(addr), cword.l);
150 - retval = (flash_read32(addr) == cword.l);
151 + debug ("is= %8.8x %8.8lx\n",
152 + flash_read32(FLASH_FIXUP_ADDR_32(addr)), cword.l);
153 + retval = (flash_read32(FLASH_FIXUP_ADDR_32(addr)) == cword.l);
154 break;
155 case FLASH_CFI_64BIT:
156 #ifdef DEBUG
157 @@ -414,12 +443,13 @@ static int flash_isequal (flash_info_t *
158 char str1[20];
159 char str2[20];
160
161 - print_longlong (str1, flash_read64(addr));
162 + print_longlong (str1, flash_read64(FLASH_FIXUP_ADDR_64
163 + (addr)));
164 print_longlong (str2, cword.ll);
165 debug ("is= %s %s\n", str1, str2);
166 }
167 #endif
168 - retval = (flash_read64(addr) == cword.ll);
169 + retval = (flash_read64(FLASH_FIXUP_ADDR_64(addr)) == cword.ll);
170 break;
171 default:
172 retval = 0;
173 @@ -443,16 +473,20 @@ static int flash_isset (flash_info_t * i
174 flash_make_cmd (info, cmd, &cword);
175 switch (info->portwidth) {
176 case FLASH_CFI_8BIT:
177 - retval = ((flash_read8(addr) & cword.c) == cword.c);
178 + retval = ((flash_read8(FLASH_FIXUP_ADDR_8(addr))
179 + & cword.c) == cword.c);
180 break;
181 case FLASH_CFI_16BIT:
182 - retval = ((flash_read16(addr) & cword.w) == cword.w);
183 + retval = ((flash_read16(FLASH_FIXUP_ADDR_16(addr))
184 + & cword.w) == cword.w);
185 break;
186 case FLASH_CFI_32BIT:
187 - retval = ((flash_read32(addr) & cword.l) == cword.l);
188 + retval = ((flash_read32(FLASH_FIXUP_ADDR_32(addr))
189 + & cword.l) == cword.l);
190 break;
191 case FLASH_CFI_64BIT:
192 - retval = ((flash_read64(addr) & cword.ll) == cword.ll);
193 + retval = ((flash_read64(FLASH_FIXUP_ADDR_64(addr))
194 + & cword.ll) == cword.ll);
195 break;
196 default:
197 retval = 0;
198 @@ -476,17 +510,22 @@ static int flash_toggle (flash_info_t *
199 flash_make_cmd (info, cmd, &cword);
200 switch (info->portwidth) {
201 case FLASH_CFI_8BIT:
202 - retval = flash_read8(addr) != flash_read8(addr);
203 + retval = flash_read8(FLASH_FIXUP_ADDR_8(addr)) !=
204 + flash_read8(FLASH_FIXUP_ADDR_8(addr));
205 break;
206 case FLASH_CFI_16BIT:
207 - retval = flash_read16(addr) != flash_read16(addr);
208 + retval = flash_read16(FLASH_FIXUP_ADDR_16(addr)) !=
209 + flash_read16(FLASH_FIXUP_ADDR_16(addr));
210 break;
211 case FLASH_CFI_32BIT:
212 - retval = flash_read32(addr) != flash_read32(addr);
213 + retval = flash_read32(FLASH_FIXUP_ADDR_32(addr)) !=
214 + flash_read32(FLASH_FIXUP_ADDR_32(addr));
215 break;
216 case FLASH_CFI_64BIT:
217 - retval = ( (flash_read32( addr ) != flash_read32( addr )) ||
218 - (flash_read32(addr+4) != flash_read32(addr+4)) );
219 + retval = ( (flash_read32(FLASH_FIXUP_ADDR_64( addr )) !=
220 + flash_read32(FLASH_FIXUP_ADDR_64( addr ))) ||
221 + (flash_read32(FLASH_FIXUP_ADDR_64(addr+4)) !=
222 + flash_read32(FLASH_FIXUP_ADDR_64(addr+4))) );
223 break;
224 default:
225 retval = 0;
This page took 0.051896 seconds and 5 git commands to generate.