fix wds in wificonf
[openwrt.git] / openwrt / target / linux / linux-2.4 / patches / brcm / 001-bcm47xx.patch
1 diff -Nur linux-2.4.30/arch/mips/bcm947xx/compressed/Makefile linux-2.4.30-brcm/arch/mips/bcm947xx/compressed/Makefile
2 --- linux-2.4.30/arch/mips/bcm947xx/compressed/Makefile 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/compressed/Makefile 2005-05-26 03:29:22.000000000 +0200
4 @@ -0,0 +1,33 @@
5 +#
6 +# Makefile for Broadcom BCM947XX boards
7 +#
8 +# Copyright 2001-2003, Broadcom Corporation
9 +# All Rights Reserved.
10 +#
11 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
12 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
15 +#
16 +# $Id: Makefile,v 1.2 2005/04/02 12:12:57 wbx Exp $
17 +#
18 +
19 +OBJCOPY_ARGS = -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
20 +SYSTEM ?= $(TOPDIR)/vmlinux
21 +
22 +all: vmlinuz
23 +
24 +# Don't build dependencies, this may die if $(CC) isn't gcc
25 +dep:
26 +
27 +# Create a gzipped version named vmlinuz for compatibility
28 +vmlinuz: piggy
29 + gzip -c9 $< > $@
30 +
31 +piggy: $(SYSTEM)
32 + $(OBJCOPY) $(OBJCOPY_ARGS) $< $@
33 +
34 +mrproper: clean
35 +
36 +clean:
37 + rm -f vmlinuz piggy
38 diff -Nur linux-2.4.30/arch/mips/bcm947xx/generic/int-handler.S linux-2.4.30-brcm/arch/mips/bcm947xx/generic/int-handler.S
39 --- linux-2.4.30/arch/mips/bcm947xx/generic/int-handler.S 1970-01-01 01:00:00.000000000 +0100
40 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/generic/int-handler.S 2005-05-22 22:55:51.000000000 +0200
41 @@ -0,0 +1,51 @@
42 +/*
43 + * Generic interrupt handler for Broadcom MIPS boards
44 + *
45 + * Copyright 2004, Broadcom Corporation
46 + * All Rights Reserved.
47 + *
48 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
49 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
50 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
51 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
52 + *
53 + * $Id: int-handler.S,v 1.1 2005/03/16 13:50:00 wbx Exp $
54 + */
55 +
56 +#include <linux/config.h>
57 +
58 +#include <asm/asm.h>
59 +#include <asm/mipsregs.h>
60 +#include <asm/regdef.h>
61 +#include <asm/stackframe.h>
62 +
63 +/*
64 + * MIPS IRQ Source
65 + * -------- ------
66 + * 0 Software (ignored)
67 + * 1 Software (ignored)
68 + * 2 Combined hardware interrupt (hw0)
69 + * 3 Hardware
70 + * 4 Hardware
71 + * 5 Hardware
72 + * 6 Hardware
73 + * 7 R4k timer
74 + */
75 +
76 + .text
77 + .set noreorder
78 + .set noat
79 + .align 5
80 + NESTED(brcmIRQ, PT_SIZE, sp)
81 + SAVE_ALL
82 + CLI
83 + .set at
84 + .set noreorder
85 +
86 + jal brcm_irq_dispatch
87 + move a0, sp
88 +
89 + j ret_from_irq
90 + nop
91 +
92 + END(brcmIRQ)
93 diff -Nur linux-2.4.30/arch/mips/bcm947xx/generic/irq.c linux-2.4.30-brcm/arch/mips/bcm947xx/generic/irq.c
94 --- linux-2.4.30/arch/mips/bcm947xx/generic/irq.c 1970-01-01 01:00:00.000000000 +0100
95 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/generic/irq.c 2005-05-22 22:55:51.000000000 +0200
96 @@ -0,0 +1,130 @@
97 +/*
98 + * Generic interrupt control functions for Broadcom MIPS boards
99 + *
100 + * Copyright 2004, Broadcom Corporation
101 + * All Rights Reserved.
102 + *
103 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
104 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
105 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
106 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
107 + *
108 + * $Id: irq.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
109 + */
110 +
111 +#include <linux/config.h>
112 +#include <linux/init.h>
113 +#include <linux/kernel.h>
114 +#include <linux/types.h>
115 +#include <linux/interrupt.h>
116 +#include <linux/irq.h>
117 +
118 +#include <asm/irq.h>
119 +#include <asm/mipsregs.h>
120 +#include <asm/gdb-stub.h>
121 +
122 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
123 +
124 +extern asmlinkage void brcmIRQ(void);
125 +extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs);
126 +
127 +void
128 +brcm_irq_dispatch(struct pt_regs *regs)
129 +{
130 + u32 cause;
131 +
132 + cause = read_c0_cause() &
133 + read_c0_status() &
134 + CAUSEF_IP;
135 +
136 +#ifdef CONFIG_KERNPROF
137 + change_c0_status(cause | 1, 1);
138 +#else
139 + clear_c0_status(cause);
140 +#endif
141 +
142 + if (cause & CAUSEF_IP7)
143 + do_IRQ(7, regs);
144 + if (cause & CAUSEF_IP2)
145 + do_IRQ(2, regs);
146 + if (cause & CAUSEF_IP3)
147 + do_IRQ(3, regs);
148 + if (cause & CAUSEF_IP4)
149 + do_IRQ(4, regs);
150 + if (cause & CAUSEF_IP5)
151 + do_IRQ(5, regs);
152 + if (cause & CAUSEF_IP6)
153 + do_IRQ(6, regs);
154 +}
155 +
156 +static void
157 +enable_brcm_irq(unsigned int irq)
158 +{
159 + if (irq < 8)
160 + set_c0_status(1 << (irq + 8));
161 + else
162 + set_c0_status(IE_IRQ0);
163 +}
164 +
165 +static void
166 +disable_brcm_irq(unsigned int irq)
167 +{
168 + if (irq < 8)
169 + clear_c0_status(1 << (irq + 8));
170 + else
171 + clear_c0_status(IE_IRQ0);
172 +}
173 +
174 +static void
175 +ack_brcm_irq(unsigned int irq)
176 +{
177 + /* Already done in brcm_irq_dispatch */
178 +}
179 +
180 +static unsigned int
181 +startup_brcm_irq(unsigned int irq)
182 +{
183 + enable_brcm_irq(irq);
184 +
185 + return 0; /* never anything pending */
186 +}
187 +
188 +static void
189 +end_brcm_irq(unsigned int irq)
190 +{
191 + if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
192 + enable_brcm_irq(irq);
193 +}
194 +
195 +static struct hw_interrupt_type brcm_irq_type = {
196 + typename: "MIPS",
197 + startup: startup_brcm_irq,
198 + shutdown: disable_brcm_irq,
199 + enable: enable_brcm_irq,
200 + disable: disable_brcm_irq,
201 + ack: ack_brcm_irq,
202 + end: end_brcm_irq,
203 + NULL
204 +};
205 +
206 +void __init
207 +init_IRQ(void)
208 +{
209 + int i;
210 +
211 + for (i = 0; i < NR_IRQS; i++) {
212 + irq_desc[i].status = IRQ_DISABLED;
213 + irq_desc[i].action = 0;
214 + irq_desc[i].depth = 1;
215 + irq_desc[i].handler = &brcm_irq_type;
216 + }
217 +
218 + set_except_vector(0, brcmIRQ);
219 + change_c0_status(ST0_IM, ALLINTS);
220 +
221 +#ifdef CONFIG_REMOTE_DEBUG
222 + printk("Breaking into debugger...\n");
223 + set_debug_traps();
224 + breakpoint();
225 +#endif
226 +}
227 diff -Nur linux-2.4.30/arch/mips/bcm947xx/generic/Makefile linux-2.4.30-brcm/arch/mips/bcm947xx/generic/Makefile
228 --- linux-2.4.30/arch/mips/bcm947xx/generic/Makefile 1970-01-01 01:00:00.000000000 +0100
229 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/generic/Makefile 2005-05-25 18:53:41.000000000 +0200
230 @@ -0,0 +1,15 @@
231 +#
232 +# Makefile for the BCM947xx specific kernel interface routines
233 +# under Linux.
234 +#
235 +
236 +.S.s:
237 + $(CPP) $(AFLAGS) $< -o $*.s
238 +.S.o:
239 + $(CC) $(AFLAGS) -c $< -o $*.o
240 +
241 +O_TARGET := brcm.o
242 +
243 +obj-y := int-handler.o irq.o
244 +
245 +include $(TOPDIR)/Rules.make
246 diff -Nur linux-2.4.30/arch/mips/bcm947xx/gpio.c linux-2.4.30-brcm/arch/mips/bcm947xx/gpio.c
247 --- linux-2.4.30/arch/mips/bcm947xx/gpio.c 1970-01-01 01:00:00.000000000 +0100
248 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/gpio.c 2005-05-22 22:55:51.000000000 +0200
249 @@ -0,0 +1,158 @@
250 +/*
251 + * GPIO char driver
252 + *
253 + * Copyright 2004, Broadcom Corporation
254 + * All Rights Reserved.
255 + *
256 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
257 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
258 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
259 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
260 + *
261 + * $Id: gpio.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
262 + */
263 +
264 +#include <linux/module.h>
265 +#include <linux/init.h>
266 +#include <linux/fs.h>
267 +#include <linux/miscdevice.h>
268 +#include <asm/uaccess.h>
269 +
270 +#include <typedefs.h>
271 +#include <bcmutils.h>
272 +#include <sbutils.h>
273 +#include <bcmdevs.h>
274 +
275 +static void *gpio_sbh;
276 +static int gpio_major;
277 +static devfs_handle_t gpio_dir;
278 +static struct {
279 + char *name;
280 + devfs_handle_t handle;
281 +} gpio_file[] = {
282 + { "in", NULL },
283 + { "out", NULL },
284 + { "outen", NULL },
285 + { "control", NULL }
286 +};
287 +
288 +static int
289 +gpio_open(struct inode *inode, struct file * file)
290 +{
291 + if (MINOR(inode->i_rdev) > ARRAYSIZE(gpio_file))
292 + return -ENODEV;
293 +
294 + MOD_INC_USE_COUNT;
295 + return 0;
296 +}
297 +
298 +static int
299 +gpio_release(struct inode *inode, struct file * file)
300 +{
301 + MOD_DEC_USE_COUNT;
302 + return 0;
303 +}
304 +
305 +static ssize_t
306 +gpio_read(struct file *file, char *buf, size_t count, loff_t *ppos)
307 +{
308 + u32 val;
309 +
310 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
311 + case 0:
312 + val = sb_gpioin(gpio_sbh);
313 + break;
314 + case 1:
315 + val = sb_gpioout(gpio_sbh, 0, 0);
316 + break;
317 + case 2:
318 + val = sb_gpioouten(gpio_sbh, 0, 0);
319 + break;
320 + case 3:
321 + val = sb_gpiocontrol(gpio_sbh, 0, 0);
322 + break;
323 + default:
324 + return -ENODEV;
325 + }
326 +
327 + if (put_user(val, (u32 *) buf))
328 + return -EFAULT;
329 +
330 + return sizeof(val);
331 +}
332 +
333 +static ssize_t
334 +gpio_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
335 +{
336 + u32 val;
337 +
338 + if (get_user(val, (u32 *) buf))
339 + return -EFAULT;
340 +
341 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
342 + case 0:
343 + return -EACCES;
344 + case 1:
345 + sb_gpioout(gpio_sbh, ~0, val);
346 + break;
347 + case 2:
348 + sb_gpioouten(gpio_sbh, ~0, val);
349 + break;
350 + case 3:
351 + sb_gpiocontrol(gpio_sbh, ~0, val);
352 + break;
353 + default:
354 + return -ENODEV;
355 + }
356 +
357 + return sizeof(val);
358 +}
359 +
360 +static struct file_operations gpio_fops = {
361 + owner: THIS_MODULE,
362 + open: gpio_open,
363 + release: gpio_release,
364 + read: gpio_read,
365 + write: gpio_write,
366 +};
367 +
368 +static int __init
369 +gpio_init(void)
370 +{
371 + int i;
372 +
373 + if (!(gpio_sbh = sb_kattach()))
374 + return -ENODEV;
375 +
376 + sb_gpiosetcore(gpio_sbh);
377 +
378 + if ((gpio_major = devfs_register_chrdev(0, "gpio", &gpio_fops)) < 0)
379 + return gpio_major;
380 +
381 + gpio_dir = devfs_mk_dir(NULL, "gpio", NULL);
382 +
383 + for (i = 0; i < ARRAYSIZE(gpio_file); i++) {
384 + gpio_file[i].handle = devfs_register(gpio_dir,
385 + gpio_file[i].name,
386 + DEVFS_FL_DEFAULT, gpio_major, i,
387 + S_IFCHR | S_IRUGO | S_IWUGO,
388 + &gpio_fops, NULL);
389 + }
390 +
391 + return 0;
392 +}
393 +
394 +static void __exit
395 +gpio_exit(void)
396 +{
397 + int i;
398 +
399 + for (i = 0; i < ARRAYSIZE(gpio_file); i++)
400 + devfs_unregister(gpio_file[i].handle);
401 + devfs_unregister(gpio_dir);
402 + devfs_unregister_chrdev(gpio_major, "gpio");
403 + sb_detach(gpio_sbh);
404 +}
405 +
406 +module_init(gpio_init);
407 +module_exit(gpio_exit);
408 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmdevs.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmdevs.h
409 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmdevs.h 1970-01-01 01:00:00.000000000 +0100
410 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmdevs.h 2005-05-25 20:30:26.000000000 +0200
411 @@ -0,0 +1,369 @@
412 +/*
413 + * Broadcom device-specific manifest constants.
414 + *
415 + * Copyright 2005, Broadcom Corporation
416 + * All Rights Reserved.
417 + *
418 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
419 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
420 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
421 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
422 + * $Id$
423 + */
424 +
425 +#ifndef _BCMDEVS_H
426 +#define _BCMDEVS_H
427 +
428 +
429 +/* Known PCI vendor Id's */
430 +#define VENDOR_EPIGRAM 0xfeda
431 +#define VENDOR_BROADCOM 0x14e4
432 +#define VENDOR_3COM 0x10b7
433 +#define VENDOR_NETGEAR 0x1385
434 +#define VENDOR_DIAMOND 0x1092
435 +#define VENDOR_DELL 0x1028
436 +#define VENDOR_HP 0x0e11
437 +#define VENDOR_APPLE 0x106b
438 +
439 +/* PCI Device Id's */
440 +#define BCM4210_DEVICE_ID 0x1072 /* never used */
441 +#define BCM4211_DEVICE_ID 0x4211
442 +#define BCM4230_DEVICE_ID 0x1086 /* never used */
443 +#define BCM4231_DEVICE_ID 0x4231
444 +
445 +#define BCM4410_DEVICE_ID 0x4410 /* bcm44xx family pci iline */
446 +#define BCM4430_DEVICE_ID 0x4430 /* bcm44xx family cardbus iline */
447 +#define BCM4412_DEVICE_ID 0x4412 /* bcm44xx family pci enet */
448 +#define BCM4432_DEVICE_ID 0x4432 /* bcm44xx family cardbus enet */
449 +
450 +#define BCM3352_DEVICE_ID 0x3352 /* bcm3352 device id */
451 +#define BCM3360_DEVICE_ID 0x3360 /* bcm3360 device id */
452 +
453 +#define EPI41210_DEVICE_ID 0xa0fa /* bcm4210 */
454 +#define EPI41230_DEVICE_ID 0xa10e /* bcm4230 */
455 +
456 +#define BCM47XX_ILINE_ID 0x4711 /* 47xx iline20 */
457 +#define BCM47XX_V90_ID 0x4712 /* 47xx v90 codec */
458 +#define BCM47XX_ENET_ID 0x4713 /* 47xx enet */
459 +#define BCM47XX_EXT_ID 0x4714 /* 47xx external i/f */
460 +#define BCM47XX_USB_ID 0x4715 /* 47xx usb */
461 +#define BCM47XX_USBH_ID 0x4716 /* 47xx usb host */
462 +#define BCM47XX_USBD_ID 0x4717 /* 47xx usb device */
463 +#define BCM47XX_IPSEC_ID 0x4718 /* 47xx ipsec */
464 +#define BCM47XX_ROBO_ID 0x4719 /* 47xx/53xx roboswitch core */
465 +#define BCM47XX_USB20H_ID 0x471a /* 47xx usb 2.0 host */
466 +#define BCM47XX_USB20D_ID 0x471b /* 47xx usb 2.0 device */
467 +
468 +#define BCM4710_DEVICE_ID 0x4710 /* 4710 primary function 0 */
469 +
470 +#define BCM4610_DEVICE_ID 0x4610 /* 4610 primary function 0 */
471 +#define BCM4610_ILINE_ID 0x4611 /* 4610 iline100 */
472 +#define BCM4610_V90_ID 0x4612 /* 4610 v90 codec */
473 +#define BCM4610_ENET_ID 0x4613 /* 4610 enet */
474 +#define BCM4610_EXT_ID 0x4614 /* 4610 external i/f */
475 +#define BCM4610_USB_ID 0x4615 /* 4610 usb */
476 +
477 +#define BCM4402_DEVICE_ID 0x4402 /* 4402 primary function 0 */
478 +#define BCM4402_ENET_ID 0x4402 /* 4402 enet */
479 +#define BCM4402_V90_ID 0x4403 /* 4402 v90 codec */
480 +#define BCM4401_ENET_ID 0x170c /* 4401b0 production enet cards */
481 +
482 +#define BCM4301_DEVICE_ID 0x4301 /* 4301 primary function 0 */
483 +#define BCM4301_D11B_ID 0x4301 /* 4301 802.11b */
484 +
485 +#define BCM4307_DEVICE_ID 0x4307 /* 4307 primary function 0 */
486 +#define BCM4307_V90_ID 0x4305 /* 4307 v90 codec */
487 +#define BCM4307_ENET_ID 0x4306 /* 4307 enet */
488 +#define BCM4307_D11B_ID 0x4307 /* 4307 802.11b */
489 +
490 +#define BCM4306_DEVICE_ID 0x4306 /* 4306 chipcommon chipid */
491 +#define BCM4306_D11G_ID 0x4320 /* 4306 802.11g */
492 +#define BCM4306_D11G_ID2 0x4325
493 +#define BCM4306_D11A_ID 0x4321 /* 4306 802.11a */
494 +#define BCM4306_UART_ID 0x4322 /* 4306 uart */
495 +#define BCM4306_V90_ID 0x4323 /* 4306 v90 codec */
496 +#define BCM4306_D11DUAL_ID 0x4324 /* 4306 dual A+B */
497 +
498 +#define BCM4309_PKG_ID 1 /* 4309 package id */
499 +
500 +#define BCM4303_D11B_ID 0x4303 /* 4303 802.11b */
501 +#define BCM4303_PKG_ID 2 /* 4303 package id */
502 +
503 +#define BCM4310_DEVICE_ID 0x4310 /* 4310 chipcommon chipid */
504 +#define BCM4310_D11B_ID 0x4311 /* 4310 802.11b */
505 +#define BCM4310_UART_ID 0x4312 /* 4310 uart */
506 +#define BCM4310_ENET_ID 0x4313 /* 4310 enet */
507 +#define BCM4310_USB_ID 0x4315 /* 4310 usb */
508 +
509 +#define BCMGPRS_UART_ID 0x4333 /* Uart id used by 4306/gprs card */
510 +
511 +#define BCM4704_DEVICE_ID 0x4704 /* 4704 chipcommon chipid */
512 +#define BCM4704_ENET_ID 0x4706 /* 4704 enet (Use 47XX_ENET_ID instead!) */
513 +
514 +#define BCM4317_DEVICE_ID 0x4317 /* 4317 chip common chipid */
515 +
516 +#define BCM4318_DEVICE_ID 0x4318 /* 4318 chip common chipid */
517 +#define BCM4318_D11G_ID 0x4318 /* 4318 801.11b/g id */
518 +#define BCM4318_D11DUAL_ID 0x4319 /* 4318 801.11a/b/g id */
519 +#define BCM4318_JTAGM_ID 0x4331 /* 4318 jtagm device id */
520 +
521 +#define FPGA_JTAGM_ID 0x4330 /* ??? */
522 +
523 +/* Address map */
524 +#define BCM4710_SDRAM 0x00000000 /* Physical SDRAM */
525 +#define BCM4710_PCI_MEM 0x08000000 /* Host Mode PCI memory access space (64 MB) */
526 +#define BCM4710_PCI_CFG 0x0c000000 /* Host Mode PCI configuration space (64 MB) */
527 +#define BCM4710_PCI_DMA 0x40000000 /* Client Mode PCI memory access space (1 GB) */
528 +#define BCM4710_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
529 +#define BCM4710_ENUM 0x18000000 /* Beginning of core enumeration space */
530 +
531 +/* Core register space */
532 +#define BCM4710_REG_SDRAM 0x18000000 /* SDRAM core registers */
533 +#define BCM4710_REG_ILINE20 0x18001000 /* InsideLine20 core registers */
534 +#define BCM4710_REG_EMAC0 0x18002000 /* Ethernet MAC 0 core registers */
535 +#define BCM4710_REG_CODEC 0x18003000 /* Codec core registers */
536 +#define BCM4710_REG_USB 0x18004000 /* USB core registers */
537 +#define BCM4710_REG_PCI 0x18005000 /* PCI core registers */
538 +#define BCM4710_REG_MIPS 0x18006000 /* MIPS core registers */
539 +#define BCM4710_REG_EXTIF 0x18007000 /* External Interface core registers */
540 +#define BCM4710_REG_EMAC1 0x18008000 /* Ethernet MAC 1 core registers */
541 +
542 +#define BCM4710_EXTIF 0x1f000000 /* External Interface base address */
543 +#define BCM4710_PCMCIA_MEM 0x1f000000 /* External Interface PCMCIA memory access */
544 +#define BCM4710_PCMCIA_IO 0x1f100000 /* PCMCIA I/O access */
545 +#define BCM4710_PCMCIA_CONF 0x1f200000 /* PCMCIA configuration */
546 +#define BCM4710_PROG 0x1f800000 /* Programable interface */
547 +#define BCM4710_FLASH 0x1fc00000 /* Flash */
548 +
549 +#define BCM4710_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
550 +
551 +#define BCM4710_UART (BCM4710_REG_EXTIF + 0x00000300)
552 +
553 +#define BCM4710_EUART (BCM4710_EXTIF + 0x00800000)
554 +#define BCM4710_LED (BCM4710_EXTIF + 0x00900000)
555 +
556 +#define BCM4712_DEVICE_ID 0x4712 /* 4712 chipcommon chipid */
557 +#define BCM4712_MIPS_ID 0x4720 /* 4712 base devid */
558 +#define BCM4712LARGE_PKG_ID 0 /* 340pin 4712 package id */
559 +#define BCM4712SMALL_PKG_ID 1 /* 200pin 4712 package id */
560 +#define BCM4712MID_PKG_ID 2 /* 225pin 4712 package id */
561 +
562 +#define SDIOH_FPGA_ID 0x4380 /* sdio host fpga */
563 +
564 +#define BCM5365_DEVICE_ID 0x5365 /* 5365 chipcommon chipid */
565 +#define BCM5350_DEVICE_ID 0x5350 /* bcm5350 chipcommon chipid */
566 +#define BCM5352_DEVICE_ID 0x5352 /* bcm5352 chipcommon chipid */
567 +
568 +#define BCM4320_DEVICE_ID 0x4320 /* bcm4320 chipcommon chipid */
569 +
570 +/* PCMCIA vendor Id's */
571 +
572 +#define VENDOR_BROADCOM_PCMCIA 0x02d0
573 +
574 +/* SDIO vendor Id's */
575 +#define VENDOR_BROADCOM_SDIO 0x00BF
576 +
577 +
578 +/* boardflags */
579 +#define BFL_BTCOEXIST 0x0001 /* This board implements Bluetooth coexistance */
580 +#define BFL_PACTRL 0x0002 /* This board has gpio 9 controlling the PA */
581 +#define BFL_AIRLINEMODE 0x0004 /* This board implements gpio13 radio disable indication */
582 +#define BFL_ENETROBO 0x0010 /* This board has robo switch or core */
583 +#define BFL_CCKHIPWR 0x0040 /* Can do high-power CCK transmission */
584 +#define BFL_ENETADM 0x0080 /* This board has ADMtek switch */
585 +#define BFL_ENETVLAN 0x0100 /* This board has vlan capability */
586 +#define BFL_AFTERBURNER 0x0200 /* This board supports Afterburner mode */
587 +#define BFL_NOPCI 0x0400 /* This board leaves PCI floating */
588 +#define BFL_FEM 0x0800 /* This board supports the Front End Module */
589 +#define BFL_EXTLNA 0x1000 /* This board has an external LNA */
590 +#define BFL_HGPA 0x2000 /* This board has a high gain PA */
591 +#define BFL_BTCMOD 0x4000 /* This board' BTCOEXIST is in the alternate gpios */
592 +
593 +/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */
594 +#define BOARD_GPIO_HWRAD_B 0x010 /* bit 4 is HWRAD input on 4301 */
595 +#define BOARD_GPIO_BTCMOD_IN 0x010 /* bit 4 is the alternate BT Coexistance Input */
596 +#define BOARD_GPIO_BTCMOD_OUT 0x020 /* bit 5 is the alternate BT Coexistance Out */
597 +#define BOARD_GPIO_BTC_IN 0x080 /* bit 7 is BT Coexistance Input */
598 +#define BOARD_GPIO_BTC_OUT 0x100 /* bit 8 is BT Coexistance Out */
599 +#define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */
600 +#define PCI_CFG_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */
601 +#define PCI_CFG_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */
602 +#define PCI_CFG_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
603 +#define PCI_CFG_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
604 +
605 +/* Bus types */
606 +#define SB_BUS 0 /* Silicon Backplane */
607 +#define PCI_BUS 1 /* PCI target */
608 +#define PCMCIA_BUS 2 /* PCMCIA target */
609 +#define SDIO_BUS 3 /* SDIO target */
610 +#define JTAG_BUS 4 /* JTAG */
611 +
612 +/* Allows optimization for single-bus support */
613 +#ifdef BCMBUSTYPE
614 +#define BUSTYPE(bus) (BCMBUSTYPE)
615 +#else
616 +#define BUSTYPE(bus) (bus)
617 +#endif
618 +
619 +/* power control defines */
620 +#define PLL_DELAY 150 /* 150us pll on delay */
621 +#define FREF_DELAY 200 /* 200us fref change delay */
622 +#define MIN_SLOW_CLK 32 /* 32us Slow clock period */
623 +
624 +/* Reference Board Types */
625 +
626 +#define BU4710_BOARD 0x0400
627 +#define VSIM4710_BOARD 0x0401
628 +#define QT4710_BOARD 0x0402
629 +
630 +#define BU4610_BOARD 0x0403
631 +#define VSIM4610_BOARD 0x0404
632 +
633 +#define BU4307_BOARD 0x0405
634 +#define BCM94301CB_BOARD 0x0406
635 +#define BCM94301PC_BOARD 0x0406 /* Pcmcia 5v card */
636 +#define BCM94301MP_BOARD 0x0407
637 +#define BCM94307MP_BOARD 0x0408
638 +#define BCMAP4307_BOARD 0x0409
639 +
640 +#define BU4309_BOARD 0x040a
641 +#define BCM94309CB_BOARD 0x040b
642 +#define BCM94309MP_BOARD 0x040c
643 +#define BCM4309AP_BOARD 0x040d
644 +
645 +#define BCM94302MP_BOARD 0x040e
646 +
647 +#define VSIM4310_BOARD 0x040f
648 +#define BU4711_BOARD 0x0410
649 +#define BCM94310U_BOARD 0x0411
650 +#define BCM94310AP_BOARD 0x0412
651 +#define BCM94310MP_BOARD 0x0414
652 +
653 +#define BU4306_BOARD 0x0416
654 +#define BCM94306CB_BOARD 0x0417
655 +#define BCM94306MP_BOARD 0x0418
656 +
657 +#define BCM94710D_BOARD 0x041a
658 +#define BCM94710R1_BOARD 0x041b
659 +#define BCM94710R4_BOARD 0x041c
660 +#define BCM94710AP_BOARD 0x041d
661 +
662 +
663 +#define BU2050_BOARD 0x041f
664 +
665 +
666 +#define BCM94309G_BOARD 0x0421
667 +
668 +#define BCM94301PC3_BOARD 0x0422 /* Pcmcia 3.3v card */
669 +
670 +#define BU4704_BOARD 0x0423
671 +#define BU4702_BOARD 0x0424
672 +
673 +#define BCM94306PC_BOARD 0x0425 /* pcmcia 3.3v 4306 card */
674 +
675 +#define BU4317_BOARD 0x0426
676 +
677 +
678 +#define BCM94702MN_BOARD 0x0428
679 +
680 +/* BCM4702 1U CompactPCI Board */
681 +#define BCM94702CPCI_BOARD 0x0429
682 +
683 +/* BCM4702 with BCM95380 VLAN Router */
684 +#define BCM95380RR_BOARD 0x042a
685 +
686 +/* cb4306 with SiGe PA */
687 +#define BCM94306CBSG_BOARD 0x042b
688 +
689 +/* mp4301 with 2050 radio */
690 +#define BCM94301MPL_BOARD 0x042c
691 +
692 +/* cb4306 with SiGe PA */
693 +#define PCSG94306_BOARD 0x042d
694 +
695 +/* bu4704 with sdram */
696 +#define BU4704SD_BOARD 0x042e
697 +
698 +/* Dual 11a/11g Router */
699 +#define BCM94704AGR_BOARD 0x042f
700 +
701 +/* 11a-only minipci */
702 +#define BCM94308MP_BOARD 0x0430
703 +
704 +
705 +
706 +/* BCM94317 boards */
707 +#define BCM94317CB_BOARD 0x0440
708 +#define BCM94317MP_BOARD 0x0441
709 +#define BCM94317PCMCIA_BOARD 0x0442
710 +#define BCM94317SDIO_BOARD 0x0443
711 +
712 +#define BU4712_BOARD 0x0444
713 +#define BU4712SD_BOARD 0x045d
714 +#define BU4712L_BOARD 0x045f
715 +
716 +/* BCM4712 boards */
717 +#define BCM94712AP_BOARD 0x0445
718 +#define BCM94712P_BOARD 0x0446
719 +
720 +/* BCM4318 boards */
721 +#define BU4318_BOARD 0x0447
722 +#define CB4318_BOARD 0x0448
723 +#define MPG4318_BOARD 0x0449
724 +#define MP4318_BOARD 0x044a
725 +#define SD4318_BOARD 0x044b
726 +
727 +/* Another mp4306 with SiGe */
728 +#define BCM94306P_BOARD 0x044c
729 +
730 +/* CF-like 4317 modules */
731 +#define BCM94317CF_BOARD 0x044d
732 +
733 +/* mp4303 */
734 +#define BCM94303MP_BOARD 0x044e
735 +
736 +/* mpsgh4306 */
737 +#define BCM94306MPSGH_BOARD 0x044f
738 +
739 +/* BRCM 4306 w/ Front End Modules */
740 +#define BCM94306MPM 0x0450
741 +#define BCM94306MPL 0x0453
742 +
743 +/* 4712agr */
744 +#define BCM94712AGR_BOARD 0x0451
745 +
746 +/* The real CF 4317 board */
747 +#define CFI4317_BOARD 0x0452
748 +
749 +/* pcmcia 4303 */
750 +#define PC4303_BOARD 0x0454
751 +
752 +/* 5350K */
753 +#define BCM95350K_BOARD 0x0455
754 +
755 +/* 5350R */
756 +#define BCM95350R_BOARD 0x0456
757 +
758 +/* 4306mplna */
759 +#define BCM94306MPLNA_BOARD 0x0457
760 +
761 +
762 +/* 4306mph */
763 +#define BCM94306MPH_BOARD 0x045b
764 +
765 +/* 4306pciv */
766 +#define BCM94306PCIV_BOARD 0x045c
767 +
768 +#define BU4712SD_BOARD 0x045d
769 +
770 +
771 +#define BU4712L_BOARD 0x045f
772 +#define BCM94712LGR_BOARD 0x0460
773 +
774 +#define BU5352_BOARD 0x0462
775 +#define BCM95352GR_BOARD 0x0467
776 +
777 +/* # of GPIO pins */
778 +#define GPIO_NUMPINS 16
779 +
780 +#endif /* _BCMDEVS_H */
781 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmendian.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmendian.h
782 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmendian.h 1970-01-01 01:00:00.000000000 +0100
783 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmendian.h 2005-02-02 23:16:39.000000000 +0100
784 @@ -0,0 +1,168 @@
785 +/*
786 + * local version of endian.h - byte order defines
787 + *
788 + * Copyright 2005, Broadcom Corporation
789 + * All Rights Reserved.
790 + *
791 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
792 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
793 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
794 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
795 + *
796 + * $Id$
797 +*/
798 +
799 +#ifndef _BCMENDIAN_H_
800 +#define _BCMENDIAN_H_
801 +
802 +#include <typedefs.h>
803 +
804 +/* Byte swap a 16 bit value */
805 +#define BCMSWAP16(val) \
806 + ((uint16)( \
807 + (((uint16)(val) & (uint16)0x00ffU) << 8) | \
808 + (((uint16)(val) & (uint16)0xff00U) >> 8) ))
809 +
810 +/* Byte swap a 32 bit value */
811 +#define BCMSWAP32(val) \
812 + ((uint32)( \
813 + (((uint32)(val) & (uint32)0x000000ffUL) << 24) | \
814 + (((uint32)(val) & (uint32)0x0000ff00UL) << 8) | \
815 + (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) | \
816 + (((uint32)(val) & (uint32)0xff000000UL) >> 24) ))
817 +
818 +static INLINE uint16
819 +bcmswap16(uint16 val)
820 +{
821 + return BCMSWAP16(val);
822 +}
823 +
824 +static INLINE uint32
825 +bcmswap32(uint32 val)
826 +{
827 + return BCMSWAP32(val);
828 +}
829 +
830 +/* buf - start of buffer of shorts to swap */
831 +/* len - byte length of buffer */
832 +static INLINE void
833 +bcmswap16_buf(uint16 *buf, uint len)
834 +{
835 + len = len/2;
836 +
837 + while(len--){
838 + *buf = bcmswap16(*buf);
839 + buf++;
840 + }
841 +}
842 +
843 +#ifndef hton16
844 +#ifndef IL_BIGENDIAN
845 +#define HTON16(i) BCMSWAP16(i)
846 +#define hton16(i) bcmswap16(i)
847 +#define hton32(i) bcmswap32(i)
848 +#define ntoh16(i) bcmswap16(i)
849 +#define ntoh32(i) bcmswap32(i)
850 +#define ltoh16(i) (i)
851 +#define ltoh32(i) (i)
852 +#define htol16(i) (i)
853 +#define htol32(i) (i)
854 +#else
855 +#define HTON16(i) (i)
856 +#define hton16(i) (i)
857 +#define hton32(i) (i)
858 +#define ntoh16(i) (i)
859 +#define ntoh32(i) (i)
860 +#define ltoh16(i) bcmswap16(i)
861 +#define ltoh32(i) bcmswap32(i)
862 +#define htol16(i) bcmswap16(i)
863 +#define htol32(i) bcmswap32(i)
864 +#endif
865 +#endif
866 +
867 +#ifndef IL_BIGENDIAN
868 +#define ltoh16_buf(buf, i)
869 +#define htol16_buf(buf, i)
870 +#else
871 +#define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
872 +#define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
873 +#endif
874 +
875 +/*
876 +* load 16-bit value from unaligned little endian byte array.
877 +*/
878 +static INLINE uint16
879 +ltoh16_ua(uint8 *bytes)
880 +{
881 + return (bytes[1]<<8)+bytes[0];
882 +}
883 +
884 +/*
885 +* load 32-bit value from unaligned little endian byte array.
886 +*/
887 +static INLINE uint32
888 +ltoh32_ua(uint8 *bytes)
889 +{
890 + return (bytes[3]<<24)+(bytes[2]<<16)+(bytes[1]<<8)+bytes[0];
891 +}
892 +
893 +/*
894 +* load 16-bit value from unaligned big(network) endian byte array.
895 +*/
896 +static INLINE uint16
897 +ntoh16_ua(uint8 *bytes)
898 +{
899 + return (bytes[0]<<8)+bytes[1];
900 +}
901 +
902 +/*
903 +* load 32-bit value from unaligned big(network) endian byte array.
904 +*/
905 +static INLINE uint32
906 +ntoh32_ua(uint8 *bytes)
907 +{
908 + return (bytes[0]<<24)+(bytes[1]<<16)+(bytes[2]<<8)+bytes[3];
909 +}
910 +
911 +/* get_ua adapted from Linux asm-mips/unaligned.h */
912 +#ifdef IL_BIGENDIAN
913 +#define get_ua(ptr) \
914 +({ \
915 + __typeof__(*(ptr)) __val; \
916 + \
917 + switch (sizeof(*(ptr))) { \
918 + case 1: \
919 + __val = *(uint8 *)ptr; \
920 + break; \
921 + case 2: \
922 + __val = ntoh16_ua((uint8 *)ptr); \
923 + break; \
924 + case 4: \
925 + __val = ntoh32_ua((uint8 *)ptr); \
926 + break; \
927 + } \
928 + \
929 + __val; \
930 +})
931 +#else
932 +#define get_ua(ptr) \
933 +({ \
934 + __typeof__(*(ptr)) __val; \
935 + \
936 + switch (sizeof(*(ptr))) { \
937 + case 1: \
938 + __val = *(uint8 *)ptr; \
939 + break; \
940 + case 2: \
941 + __val = ltoh16_ua((uint8 *)ptr); \
942 + break; \
943 + case 4: \
944 + __val = ltoh32_ua((uint8 *)ptr); \
945 + break; \
946 + } \
947 + \
948 + __val; \
949 +})
950 +#endif
951 +
952 +#endif /* _BCMENDIAN_H_ */
953 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmenet47xx.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmenet47xx.h
954 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmenet47xx.h 1970-01-01 01:00:00.000000000 +0100
955 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmenet47xx.h 2005-02-02 23:16:39.000000000 +0100
956 @@ -0,0 +1,229 @@
957 +/*
958 + * Hardware-specific definitions for
959 + * Broadcom BCM47XX 10/100 Mbps Ethernet cores.
960 + *
961 + * Copyright 2005, Broadcom Corporation
962 + * All Rights Reserved.
963 + *
964 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
965 + * the contents of this file may not be disclosed to third parties, copied
966 + * or duplicated in any form, in whole or in part, without the prior
967 + * written permission of Broadcom Corporation.
968 + * $Id$
969 + */
970 +
971 +#ifndef _bcmenet_47xx_h_
972 +#define _bcmenet_47xx_h_
973 +
974 +#include <bcmenetmib.h>
975 +#include <bcmenetrxh.h>
976 +#include <bcmenetphy.h>
977 +
978 +#define BCMENET_NFILTERS 64 /* # ethernet address filter entries */
979 +#define BCMENET_MCHASHBASE 0x200 /* multicast hash filter base address */
980 +#define BCMENET_MCHASHSIZE 256 /* multicast hash filter size in bytes */
981 +#define BCMENET_MAX_DMA 4096 /* chip has 12 bits of DMA addressing */
982 +
983 +/* power management event wakeup pattern constants */
984 +#define BCMENET_NPMP 4 /* chip supports 4 wakeup patterns */
985 +#define BCMENET_PMPBASE 0x400 /* wakeup pattern base address */
986 +#define BCMENET_PMPSIZE 0x80 /* 128bytes each pattern */
987 +#define BCMENET_PMMBASE 0x600 /* wakeup mask base address */
988 +#define BCMENET_PMMSIZE 0x10 /* 128bits each mask */
989 +
990 +/* cpp contortions to concatenate w/arg prescan */
991 +#ifndef PAD
992 +#define _PADLINE(line) pad ## line
993 +#define _XSTR(line) _PADLINE(line)
994 +#define PAD _XSTR(__LINE__)
995 +#endif /* PAD */
996 +
997 +/*
998 + * Host Interface Registers
999 + */
1000 +typedef volatile struct _bcmenettregs {
1001 + /* Device and Power Control */
1002 + uint32 devcontrol;
1003 + uint32 PAD[2];
1004 + uint32 biststatus;
1005 + uint32 wakeuplength;
1006 + uint32 PAD[3];
1007 +
1008 + /* Interrupt Control */
1009 + uint32 intstatus;
1010 + uint32 intmask;
1011 + uint32 gptimer;
1012 + uint32 PAD[23];
1013 +
1014 + /* Ethernet MAC Address Filtering Control */
1015 + uint32 PAD[2];
1016 + uint32 enetftaddr;
1017 + uint32 enetftdata;
1018 + uint32 PAD[2];
1019 +
1020 + /* Ethernet MAC Control */
1021 + uint32 emactxmaxburstlen;
1022 + uint32 emacrxmaxburstlen;
1023 + uint32 emaccontrol;
1024 + uint32 emacflowcontrol;
1025 +
1026 + uint32 PAD[20];
1027 +
1028 + /* DMA Lazy Interrupt Control */
1029 + uint32 intrecvlazy;
1030 + uint32 PAD[63];
1031 +
1032 + /* DMA engine */
1033 + dmaregs_t dmaregs;
1034 + dmafifo_t dmafifo;
1035 + uint32 PAD[116];
1036 +
1037 + /* EMAC Registers */
1038 + uint32 rxconfig;
1039 + uint32 rxmaxlength;
1040 + uint32 txmaxlength;
1041 + uint32 PAD;
1042 + uint32 mdiocontrol;
1043 + uint32 mdiodata;
1044 + uint32 emacintmask;
1045 + uint32 emacintstatus;
1046 + uint32 camdatalo;
1047 + uint32 camdatahi;
1048 + uint32 camcontrol;
1049 + uint32 enetcontrol;
1050 + uint32 txcontrol;
1051 + uint32 txwatermark;
1052 + uint32 mibcontrol;
1053 + uint32 PAD[49];
1054 +
1055 + /* EMAC MIB counters */
1056 + bcmenetmib_t mib;
1057 +
1058 + uint32 PAD[585];
1059 +
1060 + /* Sonics SiliconBackplane config registers */
1061 + sbconfig_t sbconfig;
1062 +} bcmenetregs_t;
1063 +
1064 +/* device control */
1065 +#define DC_PM ((uint32)1 << 7) /* pattern filtering enable */
1066 +#define DC_IP ((uint32)1 << 10) /* internal ephy present (rev >= 1) */
1067 +#define DC_ER ((uint32)1 << 15) /* ephy reset */
1068 +#define DC_MP ((uint32)1 << 16) /* mii phy mode enable */
1069 +#define DC_CO ((uint32)1 << 17) /* mii phy mode: enable clocks */
1070 +#define DC_PA_MASK 0x7c0000 /* mii phy mode: mdc/mdio phy address */
1071 +#define DC_PA_SHIFT 18
1072 +#define DC_FS_MASK 0x03800000 /* fifo size (rev >= 8) */
1073 +#define DC_FS_SHIFT 23
1074 +#define DC_FS_4K 0 /* 4Kbytes */
1075 +#define DC_FS_512 1 /* 512bytes */
1076 +
1077 +/* wakeup length */
1078 +#define WL_P0_MASK 0x7f /* pattern 0 */
1079 +#define WL_D0 ((uint32)1 << 7)
1080 +#define WL_P1_MASK 0x7f00 /* pattern 1 */
1081 +#define WL_P1_SHIFT 8
1082 +#define WL_D1 ((uint32)1 << 15)
1083 +#define WL_P2_MASK 0x7f0000 /* pattern 2 */
1084 +#define WL_P2_SHIFT 16
1085 +#define WL_D2 ((uint32)1 << 23)
1086 +#define WL_P3_MASK 0x7f000000 /* pattern 3 */
1087 +#define WL_P3_SHIFT 24
1088 +#define WL_D3 ((uint32)1 << 31)
1089 +
1090 +/* intstatus and intmask */
1091 +#define I_PME ((uint32)1 << 6) /* power management event */
1092 +#define I_TO ((uint32)1 << 7) /* general purpose timeout */
1093 +#define I_PC ((uint32)1 << 10) /* descriptor error */
1094 +#define I_PD ((uint32)1 << 11) /* data error */
1095 +#define I_DE ((uint32)1 << 12) /* descriptor protocol error */
1096 +#define I_RU ((uint32)1 << 13) /* receive descriptor underflow */
1097 +#define I_RO ((uint32)1 << 14) /* receive fifo overflow */
1098 +#define I_XU ((uint32)1 << 15) /* transmit fifo underflow */
1099 +#define I_RI ((uint32)1 << 16) /* receive interrupt */
1100 +#define I_XI ((uint32)1 << 24) /* transmit interrupt */
1101 +#define I_EM ((uint32)1 << 26) /* emac interrupt */
1102 +#define I_MW ((uint32)1 << 27) /* mii write */
1103 +#define I_MR ((uint32)1 << 28) /* mii read */
1104 +
1105 +/* emaccontrol */
1106 +#define EMC_CG ((uint32)1 << 0) /* crc32 generation enable */
1107 +#define EMC_EP ((uint32)1 << 2) /* onchip ephy: powerdown (rev >= 1) */
1108 +#define EMC_ED ((uint32)1 << 3) /* onchip ephy: energy detected (rev >= 1) */
1109 +#define EMC_LC_MASK 0xe0 /* onchip ephy: led control (rev >= 1) */
1110 +#define EMC_LC_SHIFT 5
1111 +
1112 +/* emacflowcontrol */
1113 +#define EMF_RFH_MASK 0xff /* rx fifo hi water mark */
1114 +#define EMF_PG ((uint32)1 << 15) /* enable pause frame generation */
1115 +
1116 +/* interrupt receive lazy */
1117 +#define IRL_TO_MASK 0x00ffffff /* timeout */
1118 +#define IRL_FC_MASK 0xff000000 /* frame count */
1119 +#define IRL_FC_SHIFT 24 /* frame count */
1120 +
1121 +/* emac receive config */
1122 +#define ERC_DB ((uint32)1 << 0) /* disable broadcast */
1123 +#define ERC_AM ((uint32)1 << 1) /* accept all multicast */
1124 +#define ERC_RDT ((uint32)1 << 2) /* receive disable while transmitting */
1125 +#define ERC_PE ((uint32)1 << 3) /* promiscuous enable */
1126 +#define ERC_LE ((uint32)1 << 4) /* loopback enable */
1127 +#define ERC_FE ((uint32)1 << 5) /* enable flow control */
1128 +#define ERC_UF ((uint32)1 << 6) /* accept unicast flow control frame */
1129 +#define ERC_RF ((uint32)1 << 7) /* reject filter */
1130 +#define ERC_CA ((uint32)1 << 8) /* cam absent */
1131 +
1132 +/* emac mdio control */
1133 +#define MC_MF_MASK 0x7f /* mdc frequency */
1134 +#define MC_PE ((uint32)1 << 7) /* mii preamble enable */
1135 +
1136 +/* emac mdio data */
1137 +#define MD_DATA_MASK 0xffff /* r/w data */
1138 +#define MD_TA_MASK 0x30000 /* turnaround value */
1139 +#define MD_TA_SHIFT 16
1140 +#define MD_TA_VALID (2 << MD_TA_SHIFT) /* valid ta */
1141 +#define MD_RA_MASK 0x7c0000 /* register address */
1142 +#define MD_RA_SHIFT 18
1143 +#define MD_PMD_MASK 0xf800000 /* physical media device */
1144 +#define MD_PMD_SHIFT 23
1145 +#define MD_OP_MASK 0x30000000 /* opcode */
1146 +#define MD_OP_SHIFT 28
1147 +#define MD_OP_WRITE (1 << MD_OP_SHIFT) /* write op */
1148 +#define MD_OP_READ (2 << MD_OP_SHIFT) /* read op */
1149 +#define MD_SB_MASK 0xc0000000 /* start bits */
1150 +#define MD_SB_SHIFT 30
1151 +#define MD_SB_START (0x1 << MD_SB_SHIFT) /* start of frame */
1152 +
1153 +/* emac intstatus and intmask */
1154 +#define EI_MII ((uint32)1 << 0) /* mii mdio interrupt */
1155 +#define EI_MIB ((uint32)1 << 1) /* mib interrupt */
1156 +#define EI_FLOW ((uint32)1 << 2) /* flow control interrupt */
1157 +
1158 +/* emac cam data high */
1159 +#define CD_V ((uint32)1 << 16) /* valid bit */
1160 +
1161 +/* emac cam control */
1162 +#define CC_CE ((uint32)1 << 0) /* cam enable */
1163 +#define CC_MS ((uint32)1 << 1) /* mask select */
1164 +#define CC_RD ((uint32)1 << 2) /* read */
1165 +#define CC_WR ((uint32)1 << 3) /* write */
1166 +#define CC_INDEX_MASK 0x3f0000 /* index */
1167 +#define CC_INDEX_SHIFT 16
1168 +#define CC_CB ((uint32)1 << 31) /* cam busy */
1169 +
1170 +/* emac ethernet control */
1171 +#define EC_EE ((uint32)1 << 0) /* emac enable */
1172 +#define EC_ED ((uint32)1 << 1) /* emac disable */
1173 +#define EC_ES ((uint32)1 << 2) /* emac soft reset */
1174 +#define EC_EP ((uint32)1 << 3) /* external phy select */
1175 +
1176 +/* emac transmit control */
1177 +#define EXC_FD ((uint32)1 << 0) /* full duplex */
1178 +#define EXC_FM ((uint32)1 << 1) /* flowmode */
1179 +#define EXC_SB ((uint32)1 << 2) /* single backoff enable */
1180 +#define EXC_SS ((uint32)1 << 3) /* small slottime */
1181 +
1182 +/* emac mib control */
1183 +#define EMC_RZ ((uint32)1 << 0) /* autoclear on read */
1184 +
1185 +#endif /* _bcmenet_47xx_h_ */
1186 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmenetmib.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmenetmib.h
1187 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmenetmib.h 1970-01-01 01:00:00.000000000 +0100
1188 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmenetmib.h 2005-02-02 23:16:39.000000000 +0100
1189 @@ -0,0 +1,81 @@
1190 +/*
1191 + * Hardware-specific MIB definition for
1192 + * Broadcom Home Networking Division
1193 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1194 + *
1195 + * Copyright 2005, Broadcom Corporation
1196 + * All Rights Reserved.
1197 + *
1198 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1199 + * the contents of this file may not be disclosed to third parties, copied
1200 + * or duplicated in any form, in whole or in part, without the prior
1201 + * written permission of Broadcom Corporation.
1202 + * $Id$
1203 + */
1204 +
1205 +#ifndef _bcmenetmib_h_
1206 +#define _bcmenetmib_h_
1207 +
1208 +/* cpp contortions to concatenate w/arg prescan */
1209 +#ifndef PAD
1210 +#define _PADLINE(line) pad ## line
1211 +#define _XSTR(line) _PADLINE(line)
1212 +#define PAD _XSTR(__LINE__)
1213 +#endif /* PAD */
1214 +
1215 +/*
1216 + * EMAC MIB Registers
1217 + */
1218 +typedef volatile struct {
1219 + uint32 tx_good_octets;
1220 + uint32 tx_good_pkts;
1221 + uint32 tx_octets;
1222 + uint32 tx_pkts;
1223 + uint32 tx_broadcast_pkts;
1224 + uint32 tx_multicast_pkts;
1225 + uint32 tx_len_64;
1226 + uint32 tx_len_65_to_127;
1227 + uint32 tx_len_128_to_255;
1228 + uint32 tx_len_256_to_511;
1229 + uint32 tx_len_512_to_1023;
1230 + uint32 tx_len_1024_to_max;
1231 + uint32 tx_jabber_pkts;
1232 + uint32 tx_oversize_pkts;
1233 + uint32 tx_fragment_pkts;
1234 + uint32 tx_underruns;
1235 + uint32 tx_total_cols;
1236 + uint32 tx_single_cols;
1237 + uint32 tx_multiple_cols;
1238 + uint32 tx_excessive_cols;
1239 + uint32 tx_late_cols;
1240 + uint32 tx_defered;
1241 + uint32 tx_carrier_lost;
1242 + uint32 tx_pause_pkts;
1243 + uint32 PAD[8];
1244 +
1245 + uint32 rx_good_octets;
1246 + uint32 rx_good_pkts;
1247 + uint32 rx_octets;
1248 + uint32 rx_pkts;
1249 + uint32 rx_broadcast_pkts;
1250 + uint32 rx_multicast_pkts;
1251 + uint32 rx_len_64;
1252 + uint32 rx_len_65_to_127;
1253 + uint32 rx_len_128_to_255;
1254 + uint32 rx_len_256_to_511;
1255 + uint32 rx_len_512_to_1023;
1256 + uint32 rx_len_1024_to_max;
1257 + uint32 rx_jabber_pkts;
1258 + uint32 rx_oversize_pkts;
1259 + uint32 rx_fragment_pkts;
1260 + uint32 rx_missed_pkts;
1261 + uint32 rx_crc_align_errs;
1262 + uint32 rx_undersize;
1263 + uint32 rx_crc_errs;
1264 + uint32 rx_align_errs;
1265 + uint32 rx_symbol_errs;
1266 + uint32 rx_pause_pkts;
1267 + uint32 rx_nonpause_pkts;
1268 +} bcmenetmib_t;
1269 +
1270 +#endif /* _bcmenetmib_h_ */
1271 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmenetphy.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmenetphy.h
1272 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmenetphy.h 1970-01-01 01:00:00.000000000 +0100
1273 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmenetphy.h 2005-02-02 23:16:39.000000000 +0100
1274 @@ -0,0 +1,58 @@
1275 +/*
1276 + * Misc Broadcom BCM47XX MDC/MDIO enet phy definitions.
1277 + *
1278 + * Copyright 2005, Broadcom Corporation
1279 + * All Rights Reserved.
1280 + *
1281 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1282 + * the contents of this file may not be disclosed to third parties, copied
1283 + * or duplicated in any form, in whole or in part, without the prior
1284 + * written permission of Broadcom Corporation.
1285 + * $Id$
1286 + */
1287 +
1288 +#ifndef _bcmenetphy_h_
1289 +#define _bcmenetphy_h_
1290 +
1291 +/* phy address */
1292 +#define MAXEPHY 32 /* mdio phy addresses are 5bit quantities */
1293 +#define EPHY_MASK 0x1f
1294 +#define EPHY_NONE 31 /* nvram: no phy present at all */
1295 +#define EPHY_NOREG 30 /* nvram: no local phy regs */
1296 +
1297 +/* just a few phy registers */
1298 +#define CTL_RESET (1 << 15) /* reset */
1299 +#define CTL_LOOP (1 << 14) /* loopback */
1300 +#define CTL_SPEED (1 << 13) /* speed selection 0=10, 1=100 */
1301 +#define CTL_ANENAB (1 << 12) /* autonegotiation enable */
1302 +#define CTL_RESTART (1 << 9) /* restart autonegotiation */
1303 +#define CTL_DUPLEX (1 << 8) /* duplex mode 0=half, 1=full */
1304 +
1305 +#define ADV_10FULL (1 << 6) /* autonegotiate advertise 10full */
1306 +#define ADV_10HALF (1 << 5) /* autonegotiate advertise 10half */
1307 +#define ADV_100FULL (1 << 8) /* autonegotiate advertise 100full */
1308 +#define ADV_100HALF (1 << 7) /* autonegotiate advertise 100half */
1309 +
1310 +/* link partner ability register */
1311 +#define LPA_SLCT 0x001f /* same as advertise selector */
1312 +#define LPA_10HALF 0x0020 /* can do 10mbps half-duplex */
1313 +#define LPA_10FULL 0x0040 /* can do 10mbps full-duplex */
1314 +#define LPA_100HALF 0x0080 /* can do 100mbps half-duplex */
1315 +#define LPA_100FULL 0x0100 /* can do 100mbps full-duplex */
1316 +#define LPA_100BASE4 0x0200 /* can do 100mbps 4k packets */
1317 +#define LPA_RESV 0x1c00 /* unused */
1318 +#define LPA_RFAULT 0x2000 /* link partner faulted */
1319 +#define LPA_LPACK 0x4000 /* link partner acked us */
1320 +#define LPA_NPAGE 0x8000 /* next page bit */
1321 +
1322 +#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
1323 +#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
1324 +
1325 +#define STAT_REMFAULT (1 << 4) /* remote fault */
1326 +#define STAT_LINK (1 << 2) /* link status */
1327 +#define STAT_JAB (1 << 1) /* jabber detected */
1328 +#define AUX_FORCED (1 << 2) /* forced 10/100 */
1329 +#define AUX_SPEED (1 << 1) /* speed 0=10mbps 1=100mbps */
1330 +#define AUX_DUPLEX (1 << 0) /* duplex 0=half 1=full */
1331 +
1332 +#endif /* _bcmenetphy_h_ */
1333 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmenetrxh.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmenetrxh.h
1334 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmenetrxh.h 1970-01-01 01:00:00.000000000 +0100
1335 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmenetrxh.h 2005-02-02 23:16:39.000000000 +0100
1336 @@ -0,0 +1,43 @@
1337 +/*
1338 + * Hardware-specific Receive Data Header for the
1339 + * Broadcom Home Networking Division
1340 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1341 + *
1342 + * Copyright 2005, Broadcom Corporation
1343 + * All Rights Reserved.
1344 + *
1345 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1346 + * the contents of this file may not be disclosed to third parties, copied
1347 + * or duplicated in any form, in whole or in part, without the prior
1348 + * written permission of Broadcom Corporation.
1349 + * $Id$
1350 + */
1351 +
1352 +#ifndef _bcmenetrxh_h_
1353 +#define _bcmenetrxh_h_
1354 +
1355 +/*
1356 + * The Ethernet MAC core returns an 8-byte Receive Frame Data Header
1357 + * with every frame consisting of
1358 + * 16bits of frame length, followed by
1359 + * 16bits of EMAC rx descriptor info, followed by 32bits of undefined.
1360 + */
1361 +typedef volatile struct {
1362 + uint16 len;
1363 + uint16 flags;
1364 + uint16 pad[12];
1365 +} bcmenetrxh_t;
1366 +
1367 +#define RXHDR_LEN 28
1368 +
1369 +#define RXF_L ((uint16)1 << 11) /* last buffer in a frame */
1370 +#define RXF_MISS ((uint16)1 << 7) /* received due to promisc mode */
1371 +#define RXF_BRDCAST ((uint16)1 << 6) /* dest is broadcast address */
1372 +#define RXF_MULT ((uint16)1 << 5) /* dest is multicast address */
1373 +#define RXF_LG ((uint16)1 << 4) /* frame length > rxmaxlength */
1374 +#define RXF_NO ((uint16)1 << 3) /* odd number of nibbles */
1375 +#define RXF_RXER ((uint16)1 << 2) /* receive symbol error */
1376 +#define RXF_CRC ((uint16)1 << 1) /* crc error */
1377 +#define RXF_OV ((uint16)1 << 0) /* fifo overflow */
1378 +
1379 +#endif /* _bcmenetrxh_h_ */
1380 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmnvram.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmnvram.h
1381 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmnvram.h 1970-01-01 01:00:00.000000000 +0100
1382 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmnvram.h 2005-02-02 23:16:39.000000000 +0100
1383 @@ -0,0 +1,132 @@
1384 +/*
1385 + * NVRAM variable manipulation
1386 + *
1387 + * Copyright 2005, Broadcom Corporation
1388 + * All Rights Reserved.
1389 + *
1390 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1391 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1392 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1393 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1394 + *
1395 + * $Id$
1396 + */
1397 +
1398 +#ifndef _bcmnvram_h_
1399 +#define _bcmnvram_h_
1400 +
1401 +#ifndef _LANGUAGE_ASSEMBLY
1402 +
1403 +#include <typedefs.h>
1404 +
1405 +struct nvram_header {
1406 + uint32 magic;
1407 + uint32 len;
1408 + uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:27 init, mem. test 28, 29-31 reserved */
1409 + uint32 config_refresh; /* 0:15 config, 16:31 refresh */
1410 + uint32 config_ncdl; /* ncdl values for memc */
1411 +};
1412 +
1413 +struct nvram_tuple {
1414 + char *name;
1415 + char *value;
1416 + struct nvram_tuple *next;
1417 +};
1418 +
1419 +/*
1420 + * Initialize NVRAM access. May be unnecessary or undefined on certain
1421 + * platforms.
1422 + */
1423 +extern int BCMINIT(nvram_init)(void *sbh);
1424 +
1425 +/*
1426 + * Disable NVRAM access. May be unnecessary or undefined on certain
1427 + * platforms.
1428 + */
1429 +extern void BCMINIT(nvram_exit)(void);
1430 +
1431 +/*
1432 + * Get the value of an NVRAM variable. The pointer returned may be
1433 + * invalid after a set.
1434 + * @param name name of variable to get
1435 + * @return value of variable or NULL if undefined
1436 + */
1437 +extern char * BCMINIT(nvram_get)(const char *name);
1438 +
1439 +/*
1440 + * Get the value of an NVRAM variable.
1441 + * @param name name of variable to get
1442 + * @return value of variable or NUL if undefined
1443 + */
1444 +#define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "")
1445 +
1446 +/*
1447 + * Match an NVRAM variable.
1448 + * @param name name of variable to match
1449 + * @param match value to compare against value of variable
1450 + * @return TRUE if variable is defined and its value is string equal
1451 + * to match or FALSE otherwise
1452 + */
1453 +static INLINE int
1454 +nvram_match(char *name, char *match) {
1455 + const char *value = BCMINIT(nvram_get)(name);
1456 + return (value && !strcmp(value, match));
1457 +}
1458 +
1459 +/*
1460 + * Inversely match an NVRAM variable.
1461 + * @param name name of variable to match
1462 + * @param match value to compare against value of variable
1463 + * @return TRUE if variable is defined and its value is not string
1464 + * equal to invmatch or FALSE otherwise
1465 + */
1466 +static INLINE int
1467 +nvram_invmatch(char *name, char *invmatch) {
1468 + const char *value = BCMINIT(nvram_get)(name);
1469 + return (value && strcmp(value, invmatch));
1470 +}
1471 +
1472 +/*
1473 + * Set the value of an NVRAM variable. The name and value strings are
1474 + * copied into private storage. Pointers to previously set values
1475 + * may become invalid. The new value may be immediately
1476 + * retrieved but will not be permanently stored until a commit.
1477 + * @param name name of variable to set
1478 + * @param value value of variable
1479 + * @return 0 on success and errno on failure
1480 + */
1481 +extern int BCMINIT(nvram_set)(const char *name, const char *value);
1482 +
1483 +/*
1484 + * Unset an NVRAM variable. Pointers to previously set values
1485 + * remain valid until a set.
1486 + * @param name name of variable to unset
1487 + * @return 0 on success and errno on failure
1488 + * NOTE: use nvram_commit to commit this change to flash.
1489 + */
1490 +extern int BCMINIT(nvram_unset)(const char *name);
1491 +
1492 +/*
1493 + * Commit NVRAM variables to permanent storage. All pointers to values
1494 + * may be invalid after a commit.
1495 + * NVRAM values are undefined after a commit.
1496 + * @return 0 on success and errno on failure
1497 + */
1498 +extern int BCMINIT(nvram_commit)(void);
1499 +
1500 +/*
1501 + * Get all NVRAM variables (format name=value\0 ... \0\0).
1502 + * @param buf buffer to store variables
1503 + * @param count size of buffer in bytes
1504 + * @return 0 on success and errno on failure
1505 + */
1506 +extern int BCMINIT(nvram_getall)(char *buf, int count);
1507 +
1508 +#endif /* _LANGUAGE_ASSEMBLY */
1509 +
1510 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
1511 +#define NVRAM_VERSION 1
1512 +#define NVRAM_HEADER_SIZE 20
1513 +#define NVRAM_SPACE 0x8000
1514 +
1515 +#endif /* _bcmnvram_h_ */
1516 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmparams.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmparams.h
1517 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmparams.h 1970-01-01 01:00:00.000000000 +0100
1518 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmparams.h 2005-02-02 23:16:39.000000000 +0100
1519 @@ -0,0 +1,23 @@
1520 +/*
1521 + * Misc system wide parameters.
1522 + *
1523 + * Copyright 2005, Broadcom Corporation
1524 + * All Rights Reserved.
1525 + *
1526 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1527 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1528 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1529 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1530 + * $Id$
1531 + */
1532 +
1533 +#ifndef _bcmparams_h_
1534 +#define _bcmparams_h_
1535 +
1536 +#define VLAN_MAXVID 15 /* Max. VLAN ID supported/allowed */
1537 +
1538 +#define VLAN_NUMPRIS 8 /* # of prio, start from 0 */
1539 +
1540 +#define DEV_NUMIFS 16 /* Max. # of devices/interfaces supported */
1541 +
1542 +#endif
1543 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmsrom.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmsrom.h
1544 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmsrom.h 1970-01-01 01:00:00.000000000 +0100
1545 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmsrom.h 2005-02-02 23:16:39.000000000 +0100
1546 @@ -0,0 +1,22 @@
1547 +/*
1548 + * Misc useful routines to access NIC local SROM/OTP .
1549 + *
1550 + * Copyright 2005, Broadcom Corporation
1551 + * All Rights Reserved.
1552 + *
1553 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1554 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1555 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1556 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1557 + *
1558 + * $Id$
1559 + */
1560 +
1561 +#ifndef _bcmsrom_h_
1562 +#define _bcmsrom_h_
1563 +
1564 +extern int srom_var_init(void *sbh, uint bus, void *curmap, void *osh, char **vars, int *count);
1565 +extern int srom_read(uint bus, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf);
1566 +extern int srom_write(uint bus, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf);
1567 +
1568 +#endif /* _bcmsrom_h_ */
1569 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bcmutils.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmutils.h
1570 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmutils.h 1970-01-01 01:00:00.000000000 +0100
1571 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bcmutils.h 2005-02-02 23:16:39.000000000 +0100
1572 @@ -0,0 +1,239 @@
1573 +/*
1574 + * Misc useful os-independent macros and functions.
1575 + *
1576 + * Copyright 2005, Broadcom Corporation
1577 + * All Rights Reserved.
1578 + *
1579 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1580 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1581 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1582 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1583 + * $Id$
1584 + */
1585 +
1586 +#ifndef _bcmutils_h_
1587 +#define _bcmutils_h_
1588 +
1589 +/*** driver-only section ***/
1590 +#ifdef BCMDRIVER
1591 +#include <osl.h>
1592 +
1593 +#define _BCM_U 0x01 /* upper */
1594 +#define _BCM_L 0x02 /* lower */
1595 +#define _BCM_D 0x04 /* digit */
1596 +#define _BCM_C 0x08 /* cntrl */
1597 +#define _BCM_P 0x10 /* punct */
1598 +#define _BCM_S 0x20 /* white space (space/lf/tab) */
1599 +#define _BCM_X 0x40 /* hex digit */
1600 +#define _BCM_SP 0x80 /* hard space (0x20) */
1601 +
1602 +extern unsigned char bcm_ctype[];
1603 +#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
1604 +
1605 +#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
1606 +#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
1607 +#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0)
1608 +#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0)
1609 +#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
1610 +#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0)
1611 +#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
1612 +#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0)
1613 +#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0)
1614 +#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0)
1615 +#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
1616 +
1617 +/*
1618 + * Spin at most 'us' microseconds while 'exp' is true.
1619 + * Caller should explicitly test 'exp' when this completes
1620 + * and take appropriate error action if 'exp' is still true.
1621 + */
1622 +#define SPINWAIT(exp, us) { \
1623 + uint countdown = (us) + 9; \
1624 + while ((exp) && (countdown >= 10)) {\
1625 + OSL_DELAY(10); \
1626 + countdown -= 10; \
1627 + } \
1628 +}
1629 +
1630 +/* generic osl packet queue */
1631 +struct pktq {
1632 + void *head; /* first packet to dequeue */
1633 + void *tail; /* last packet to dequeue */
1634 + uint len; /* number of queued packets */
1635 + uint maxlen; /* maximum number of queued packets */
1636 + bool priority; /* enqueue by packet priority */
1637 + uint8 prio_map[MAXPRIO+1]; /* user priority to packet enqueue policy map */
1638 +};
1639 +#define DEFAULT_QLEN 128
1640 +
1641 +#define pktq_len(q) ((q)->len)
1642 +#define pktq_avail(q) ((q)->maxlen - (q)->len)
1643 +#define pktq_head(q) ((q)->head)
1644 +#define pktq_full(q) ((q)->len >= (q)->maxlen)
1645 +#define _pktq_pri(q, pri) ((q)->prio_map[pri])
1646 +#define pktq_tailpri(q) ((q)->tail ? _pktq_pri(q, PKTPRIO((q)->tail)) : _pktq_pri(q, 0))
1647 +
1648 +/* externs */
1649 +/* packet */
1650 +extern uint pktcopy(void *drv, void *p, uint offset, int len, uchar *buf);
1651 +extern uint pkttotlen(void *drv, void *);
1652 +extern void pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[]);
1653 +extern void pktenq(struct pktq *q, void *p, bool lifo);
1654 +extern void *pktdeq(struct pktq *q);
1655 +extern void *pktdeqtail(struct pktq *q);
1656 +/* string */
1657 +extern uint bcm_atoi(char *s);
1658 +extern uchar bcm_toupper(uchar c);
1659 +extern ulong bcm_strtoul(char *cp, char **endp, uint base);
1660 +extern char *bcmstrstr(char *haystack, char *needle);
1661 +extern char *bcmstrcat(char *dest, const char *src);
1662 +extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen);
1663 +/* ethernet address */
1664 +extern char *bcm_ether_ntoa(char *ea, char *buf);
1665 +extern int bcm_ether_atoe(char *p, char *ea);
1666 +/* delay */
1667 +extern void bcm_mdelay(uint ms);
1668 +/* variable access */
1669 +extern char *getvar(char *vars, char *name);
1670 +extern int getintvar(char *vars, char *name);
1671 +extern uint getgpiopin(char *vars, char *pin_name, uint def_pin);
1672 +#define bcmlog(fmt, a1, a2)
1673 +#define bcmdumplog(buf, size) *buf = '\0'
1674 +#define bcmdumplogent(buf, idx) -1
1675 +#endif /* #ifdef BCMDRIVER */
1676 +
1677 +/*** driver/apps-shared section ***/
1678 +#ifndef MIN
1679 +#define MIN(a, b) (((a)<(b))?(a):(b))
1680 +#endif
1681 +
1682 +#ifndef MAX
1683 +#define MAX(a, b) (((a)>(b))?(a):(b))
1684 +#endif
1685 +
1686 +#define CEIL(x, y) (((x) + ((y)-1)) / (y))
1687 +#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
1688 +#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0)
1689 +#define ISPOWEROF2(x) ((((x)-1)&(x))==0)
1690 +#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member)
1691 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
1692 +
1693 +/* bit map related macros */
1694 +#ifndef setbit
1695 +#define NBBY 8 /* 8 bits per byte */
1696 +#define setbit(a,i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
1697 +#define clrbit(a,i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1698 +#define isset(a,i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY)))
1699 +#define isclr(a,i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1700 +#endif
1701 +
1702 +#define NBITS(type) (sizeof (type) * 8)
1703 +
1704 +/* crc defines */
1705 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
1706 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
1707 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
1708 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
1709 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
1710 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
1711 +
1712 +/* bcm_format_flags() bit description structure */
1713 +typedef struct bcm_bit_desc {
1714 + uint32 bit;
1715 + char* name;
1716 +} bcm_bit_desc_t;
1717 +
1718 +/* tag_ID/length/value_buffer tuple */
1719 +typedef struct bcm_tlv {
1720 + uint8 id;
1721 + uint8 len;
1722 + uint8 data[1];
1723 +} bcm_tlv_t;
1724 +
1725 +/* Check that bcm_tlv_t fits into the given buflen */
1726 +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (buflen) >= 2 + (elt)->len)
1727 +
1728 +/* buffer length for ethernet address from bcm_ether_ntoa() */
1729 +#define ETHER_ADDR_STR_LEN 18
1730 +
1731 +/* unaligned load and store macros */
1732 +#ifdef IL_BIGENDIAN
1733 +static INLINE uint32
1734 +load32_ua(uint8 *a)
1735 +{
1736 + return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
1737 +}
1738 +
1739 +static INLINE void
1740 +store32_ua(uint8 *a, uint32 v)
1741 +{
1742 + a[0] = (v >> 24) & 0xff;
1743 + a[1] = (v >> 16) & 0xff;
1744 + a[2] = (v >> 8) & 0xff;
1745 + a[3] = v & 0xff;
1746 +}
1747 +
1748 +static INLINE uint16
1749 +load16_ua(uint8 *a)
1750 +{
1751 + return ((a[0] << 8) | a[1]);
1752 +}
1753 +
1754 +static INLINE void
1755 +store16_ua(uint8 *a, uint16 v)
1756 +{
1757 + a[0] = (v >> 8) & 0xff;
1758 + a[1] = v & 0xff;
1759 +}
1760 +
1761 +#else
1762 +
1763 +static INLINE uint32
1764 +load32_ua(uint8 *a)
1765 +{
1766 + return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
1767 +}
1768 +
1769 +static INLINE void
1770 +store32_ua(uint8 *a, uint32 v)
1771 +{
1772 + a[3] = (v >> 24) & 0xff;
1773 + a[2] = (v >> 16) & 0xff;
1774 + a[1] = (v >> 8) & 0xff;
1775 + a[0] = v & 0xff;
1776 +}
1777 +
1778 +static INLINE uint16
1779 +load16_ua(uint8 *a)
1780 +{
1781 + return ((a[1] << 8) | a[0]);
1782 +}
1783 +
1784 +static INLINE void
1785 +store16_ua(uint8 *a, uint16 v)
1786 +{
1787 + a[1] = (v >> 8) & 0xff;
1788 + a[0] = v & 0xff;
1789 +}
1790 +
1791 +#endif
1792 +
1793 +/* externs */
1794 +/* crc */
1795 +extern uint8 hndcrc8(uint8 *p, uint nbytes, uint8 crc);
1796 +extern uint16 hndcrc16(uint8 *p, uint nbytes, uint16 crc);
1797 +extern uint32 hndcrc32(uint8 *p, uint nbytes, uint32 crc);
1798 +/* format/print */
1799 +/* IE parsing */
1800 +extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
1801 +extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
1802 +extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
1803 +
1804 +/* multi-bool data type: set of bools, mbool is true if any is set */
1805 +typedef uint32 mbool;
1806 +#define mboolset(mb, bit) (mb |= bit) /* set one bool */
1807 +#define mboolclr(mb, bit) (mb &= ~bit) /* clear one bool */
1808 +#define mboolisset(mb, bit) ((mb & bit) != 0) /* TRUE if one bool is set */
1809 +#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val)))
1810 +
1811 +#endif /* _bcmutils_h_ */
1812 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/bitfuncs.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/bitfuncs.h
1813 --- linux-2.4.30/arch/mips/bcm947xx/include/bitfuncs.h 1970-01-01 01:00:00.000000000 +0100
1814 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/bitfuncs.h 2005-02-02 23:16:39.000000000 +0100
1815 @@ -0,0 +1,85 @@
1816 +/*
1817 + * bit manipulation utility functions
1818 + *
1819 + * Copyright 2005, Broadcom Corporation
1820 + * All Rights Reserved.
1821 + *
1822 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1823 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1824 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1825 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1826 + * $Id$
1827 + */
1828 +
1829 +#ifndef _BITFUNCS_H
1830 +#define _BITFUNCS_H
1831 +
1832 +#include <typedefs.h>
1833 +
1834 +/* local prototypes */
1835 +static INLINE uint32 find_msbit(uint32 x);
1836 +
1837 +
1838 +/*
1839 + * find_msbit: returns index of most significant set bit in x, with index
1840 + * range defined as 0-31. NOTE: returns zero if input is zero.
1841 + */
1842 +
1843 +#if defined(USE_PENTIUM_BSR) && defined(__GNUC__)
1844 +
1845 +/*
1846 + * Implementation for Pentium processors and gcc. Note that this
1847 + * instruction is actually very slow on some processors (e.g., family 5,
1848 + * model 2, stepping 12, "Pentium 75 - 200"), so we use the generic
1849 + * implementation instead.
1850 + */
1851 +static INLINE uint32 find_msbit(uint32 x)
1852 +{
1853 + uint msbit;
1854 + __asm__("bsrl %1,%0"
1855 + :"=r" (msbit)
1856 + :"r" (x));
1857 + return msbit;
1858 +}
1859 +
1860 +#else
1861 +
1862 +/*
1863 + * Generic Implementation
1864 + */
1865 +
1866 +#define DB_POW_MASK16 0xffff0000
1867 +#define DB_POW_MASK8 0x0000ff00
1868 +#define DB_POW_MASK4 0x000000f0
1869 +#define DB_POW_MASK2 0x0000000c
1870 +#define DB_POW_MASK1 0x00000002
1871 +
1872 +static INLINE uint32 find_msbit(uint32 x)
1873 +{
1874 + uint32 temp_x = x;
1875 + uint msbit = 0;
1876 + if (temp_x & DB_POW_MASK16) {
1877 + temp_x >>= 16;
1878 + msbit = 16;
1879 + }
1880 + if (temp_x & DB_POW_MASK8) {
1881 + temp_x >>= 8;
1882 + msbit += 8;
1883 + }
1884 + if (temp_x & DB_POW_MASK4) {
1885 + temp_x >>= 4;
1886 + msbit += 4;
1887 + }
1888 + if (temp_x & DB_POW_MASK2) {
1889 + temp_x >>= 2;
1890 + msbit += 2;
1891 + }
1892 + if (temp_x & DB_POW_MASK1) {
1893 + msbit += 1;
1894 + }
1895 + return(msbit);
1896 +}
1897 +
1898 +#endif
1899 +
1900 +#endif /* _BITFUNCS_H */
1901 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/cfe_osl.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/cfe_osl.h
1902 --- linux-2.4.30/arch/mips/bcm947xx/include/cfe_osl.h 1970-01-01 01:00:00.000000000 +0100
1903 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/cfe_osl.h 2005-02-02 23:16:39.000000000 +0100
1904 @@ -0,0 +1,184 @@
1905 +/*
1906 + * CFE boot loader OS Abstraction Layer.
1907 + *
1908 + * Copyright 2005, Broadcom Corporation
1909 + * All Rights Reserved.
1910 + *
1911 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1912 + * the contents of this file may not be disclosed to third parties, copied
1913 + * or duplicated in any form, in whole or in part, without the prior
1914 + * written permission of Broadcom Corporation.
1915 + *
1916 + * $Id$
1917 + */
1918 +
1919 +#ifndef _cfe_osl_h_
1920 +#define _cfe_osl_h_
1921 +
1922 +#include <lib_types.h>
1923 +#include <lib_string.h>
1924 +#include <lib_printf.h>
1925 +#include <lib_malloc.h>
1926 +#include <cpu_config.h>
1927 +#include <cfe_timer.h>
1928 +#include <cfe_iocb.h>
1929 +#include <cfe_devfuncs.h>
1930 +#include <addrspace.h>
1931 +
1932 +#include <typedefs.h>
1933 +
1934 +/* dump string */
1935 +extern int (*xprinthook)(const char *str);
1936 +#define puts(str) do { if (xprinthook) xprinthook(str); } while (0)
1937 +
1938 +/* assert and panic */
1939 +#define ASSERT(exp) do {} while (0)
1940 +
1941 +/* PCMCIA attribute space access macros */
1942 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
1943 + bzero(buf, size)
1944 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
1945 + do {} while (0)
1946 +
1947 +/* PCI configuration space access macros */
1948 +#define OSL_PCI_READ_CONFIG(loc, offset, size) \
1949 + (offset == 8 ? 0 : 0xffffffff)
1950 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) \
1951 + do {} while (0)
1952 +
1953 +/* register access macros */
1954 +#define wreg32(r, v) (*(volatile uint32*)(r) = (uint32)(v))
1955 +#define rreg32(r) (*(volatile uint32*)(r))
1956 +#ifdef IL_BIGENDIAN
1957 +#define wreg16(r, v) (*(volatile uint16*)((ulong)(r)^2) = (uint16)(v))
1958 +#define rreg16(r) (*(volatile uint16*)((ulong)(r)^2))
1959 +#define wreg8(r, v) (*(volatile uint8*)((ulong)(r)^3) = (uint8)(v))
1960 +#define rreg8(r) (*(volatile uint8*)((ulong)(r)^3))
1961 +#else
1962 +#define wreg16(r, v) (*(volatile uint16*)(r) = (uint16)(v))
1963 +#define rreg16(r) (*(volatile uint16*)(r))
1964 +#define wreg8(r, v) (*(volatile uint8*)(r) = (uint8)(v))
1965 +#define rreg8(r) (*(volatile uint8*)(r))
1966 +#endif
1967 +#define R_REG(r) ({ \
1968 + __typeof(*(r)) __osl_v; \
1969 + switch (sizeof(*(r))) { \
1970 + case sizeof(uint8): __osl_v = rreg8((r)); break; \
1971 + case sizeof(uint16): __osl_v = rreg16((r)); break; \
1972 + case sizeof(uint32): __osl_v = rreg32((r)); break; \
1973 + } \
1974 + __osl_v; \
1975 +})
1976 +#define W_REG(r, v) do { \
1977 + switch (sizeof(*(r))) { \
1978 + case sizeof(uint8): wreg8((r), (v)); break; \
1979 + case sizeof(uint16): wreg16((r), (v)); break; \
1980 + case sizeof(uint32): wreg32((r), (v)); break; \
1981 + } \
1982 +} while (0)
1983 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
1984 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
1985 +
1986 +/* bcopy, bcmp, and bzero */
1987 +#define bcmp(b1, b2, len) lib_memcmp((b1), (b2), (len))
1988 +
1989 +#define osl_attach(pdev) (pdev)
1990 +#define osl_detach(osh)
1991 +
1992 +/* general purpose memory allocation */
1993 +#define MALLOC(osh, size) KMALLOC((size),0)
1994 +#define MFREE(osh, addr, size) KFREE((addr))
1995 +#define MALLOCED(osh) (0)
1996 +#define MALLOC_DUMP(osh, buf, sz)
1997 +#define MALLOC_FAILED(osh) (0)
1998 +
1999 +/* uncached virtual address */
2000 +#define OSL_UNCACHED(va) ((void*)UNCADDR((ulong)(va)))
2001 +
2002 +/* host/bus architecture-specific address byte swap */
2003 +#define BUS_SWAP32(v) (v)
2004 +
2005 +/* get processor cycle count */
2006 +#define OSL_GETCYCLES(x) ((x) = 0)
2007 +
2008 +/* microsecond delay */
2009 +#define OSL_DELAY(usec) cfe_usleep((cfe_cpu_speed/CPUCFG_CYCLESPERCPUTICK/1000000*(usec)))
2010 +
2011 +/* map/unmap physical to virtual I/O */
2012 +#define REG_MAP(pa, size) ((void*)UNCADDR((ulong)(pa)))
2013 +#define REG_UNMAP(va) do {} while (0)
2014 +
2015 +/* dereference an address that may cause a bus exception */
2016 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (uint32)(addr))
2017 +extern int osl_busprobe(uint32 *val, uint32 addr);
2018 +
2019 +/* allocate/free shared (dma-able) consistent (uncached) memory */
2020 +#define DMA_CONSISTENT_ALIGN 4096
2021 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
2022 + osl_dma_alloc_consistent((size), (pap))
2023 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
2024 + osl_dma_free_consistent((void*)(va))
2025 +extern void *osl_dma_alloc_consistent(uint size, ulong *pap);
2026 +extern void osl_dma_free_consistent(void *va);
2027 +
2028 +/* map/unmap direction */
2029 +#define DMA_TX 1
2030 +#define DMA_RX 2
2031 +
2032 +/* map/unmap shared (dma-able) memory */
2033 +#define DMA_MAP(osh, va, size, direction, lb) ({ \
2034 + cfe_flushcache(CFE_CACHE_FLUSH_D); \
2035 + PHYSADDR((ulong)(va)); \
2036 +})
2037 +#define DMA_UNMAP(osh, pa, size, direction, p) \
2038 + do {} while (0)
2039 +
2040 +/* shared (dma-able) memory access macros */
2041 +#define R_SM(r) *(r)
2042 +#define W_SM(r, v) (*(r) = (v))
2043 +#define BZERO_SM(r, len) lib_memset((r), '\0', (len))
2044 +
2045 +/* generic packet structure */
2046 +#define LBUFSZ 4096
2047 +#define LBDATASZ (LBUFSZ - sizeof(struct lbuf))
2048 +struct lbuf {
2049 + struct lbuf *next; /* pointer to next lbuf if in a chain */
2050 + struct lbuf *link; /* pointer to next lbuf if in a list */
2051 + uchar *head; /* start of buffer */
2052 + uchar *end; /* end of buffer */
2053 + uchar *data; /* start of data */
2054 + uchar *tail; /* end of data */
2055 + uint len; /* nbytes of data */
2056 + void *cookie; /* generic cookie */
2057 +};
2058 +
2059 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
2060 +#define PKTBUFSZ 2048
2061 +
2062 +/* packet primitives */
2063 +#define PKTGET(drv, len, send) ((void*)osl_pktget((len)))
2064 +#define PKTFREE(drv, lb, send) osl_pktfree((struct lbuf*)(lb))
2065 +#define PKTDATA(drv, lb) (((struct lbuf*)(lb))->data)
2066 +#define PKTLEN(drv, lb) (((struct lbuf*)(lb))->len)
2067 +#define PKTHEADROOM(drv, lb) (PKTDATA(drv,lb)-(((struct lbuf*)(lb))->head))
2068 +#define PKTTAILROOM(drv, lb) ((((struct lbuf*)(lb))->end)-(((struct lbuf*)(lb))->tail))
2069 +#define PKTNEXT(drv, lb) (((struct lbuf*)(lb))->next)
2070 +#define PKTSETNEXT(lb, x) (((struct lbuf*)(lb))->next = (struct lbuf*)(x))
2071 +#define PKTSETLEN(drv, lb, len) osl_pktsetlen((struct lbuf*)(lb), (len))
2072 +#define PKTPUSH(drv, lb, bytes) osl_pktpush((struct lbuf*)(lb), (bytes))
2073 +#define PKTPULL(drv, lb, bytes) osl_pktpull((struct lbuf*)(lb), (bytes))
2074 +#define PKTDUP(drv, lb) osl_pktdup((struct lbuf*)(lb))
2075 +#define PKTCOOKIE(lb) (((struct lbuf*)(lb))->cookie)
2076 +#define PKTSETCOOKIE(lb, x) (((struct lbuf*)(lb))->cookie = (void*)(x))
2077 +#define PKTLINK(lb) (((struct lbuf*)(lb))->link)
2078 +#define PKTSETLINK(lb, x) (((struct lbuf*)(lb))->link = (struct lbuf*)(x))
2079 +#define PKTPRIO(lb) (0)
2080 +#define PKTSETPRIO(lb, x) do {} while (0)
2081 +extern struct lbuf *osl_pktget(uint len);
2082 +extern void osl_pktfree(struct lbuf *lb);
2083 +extern void osl_pktsetlen(struct lbuf *lb, uint len);
2084 +extern uchar *osl_pktpush(struct lbuf *lb, uint bytes);
2085 +extern uchar *osl_pktpull(struct lbuf *lb, uint bytes);
2086 +extern struct lbuf *osl_pktdup(struct lbuf *lb);
2087 +
2088 +#endif /* _cfe_osl_h_ */
2089 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/epivers.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/epivers.h
2090 --- linux-2.4.30/arch/mips/bcm947xx/include/epivers.h 1970-01-01 01:00:00.000000000 +0100
2091 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/epivers.h 2005-02-02 23:16:39.000000000 +0100
2092 @@ -0,0 +1,69 @@
2093 +/*
2094 + * Copyright 2005, Broadcom Corporation
2095 + * All Rights Reserved.
2096 + *
2097 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2098 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2099 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2100 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2101 + *
2102 + * $Id$
2103 + *
2104 +*/
2105 +
2106 +#ifndef _epivers_h_
2107 +#define _epivers_h_
2108 +
2109 +#ifdef linux
2110 +#include <linux/config.h>
2111 +#endif
2112 +
2113 +/* Vendor Name, ASCII, 32 chars max */
2114 +#ifdef COMPANYNAME
2115 +#define HPNA_VENDOR COMPANYNAME
2116 +#else
2117 +#define HPNA_VENDOR "Broadcom Corporation"
2118 +#endif
2119 +
2120 +/* Driver Date, ASCII, 32 chars max */
2121 +#define HPNA_DRV_BUILD_DATE __DATE__
2122 +
2123 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2124 +#define HPNA_HW_MFG_DATE "Not Specified"
2125 +
2126 +/* See documentation for Device Type values, 32 values max */
2127 +#ifndef HPNA_DEV_TYPE
2128 +
2129 +#if defined(CONFIG_BRCM_VJ)
2130 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2131 +
2132 +#elif defined(CONFIG_BCRM_93725)
2133 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2134 +
2135 +#else
2136 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2137 +
2138 +#endif
2139 +
2140 +#endif /* !HPNA_DEV_TYPE */
2141 +
2142 +
2143 +#define EPI_MAJOR_VERSION 3
2144 +
2145 +#define EPI_MINOR_VERSION 90
2146 +
2147 +#define EPI_RC_NUMBER 23
2148 +
2149 +#define EPI_INCREMENTAL_NUMBER 0
2150 +
2151 +#define EPI_BUILD_NUMBER 0
2152 +
2153 +#define EPI_VERSION 3,90,23,0
2154 +
2155 +#define EPI_VERSION_NUM 0x035a1700
2156 +
2157 +/* Driver Version String, ASCII, 32 chars max */
2158 +#define EPI_VERSION_STR "3.90.23.0"
2159 +#define EPI_ROUTER_VERSION_STR "3.91.23.0"
2160 +
2161 +#endif /* _epivers_h_ */
2162 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/epivers.h.in linux-2.4.30-brcm/arch/mips/bcm947xx/include/epivers.h.in
2163 --- linux-2.4.30/arch/mips/bcm947xx/include/epivers.h.in 1970-01-01 01:00:00.000000000 +0100
2164 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/epivers.h.in 2005-02-02 23:16:39.000000000 +0100
2165 @@ -0,0 +1,69 @@
2166 +/*
2167 + * Copyright 2005, Broadcom Corporation
2168 + * All Rights Reserved.
2169 + *
2170 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2171 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2172 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2173 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2174 + *
2175 + * $Id$
2176 + *
2177 +*/
2178 +
2179 +#ifndef _epivers_h_
2180 +#define _epivers_h_
2181 +
2182 +#ifdef linux
2183 +#include <linux/config.h>
2184 +#endif
2185 +
2186 +/* Vendor Name, ASCII, 32 chars max */
2187 +#ifdef COMPANYNAME
2188 +#define HPNA_VENDOR COMPANYNAME
2189 +#else
2190 +#define HPNA_VENDOR "Broadcom Corporation"
2191 +#endif
2192 +
2193 +/* Driver Date, ASCII, 32 chars max */
2194 +#define HPNA_DRV_BUILD_DATE __DATE__
2195 +
2196 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2197 +#define HPNA_HW_MFG_DATE "Not Specified"
2198 +
2199 +/* See documentation for Device Type values, 32 values max */
2200 +#ifndef HPNA_DEV_TYPE
2201 +
2202 +#if defined(CONFIG_BRCM_VJ)
2203 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2204 +
2205 +#elif defined(CONFIG_BCRM_93725)
2206 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2207 +
2208 +#else
2209 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2210 +
2211 +#endif
2212 +
2213 +#endif /* !HPNA_DEV_TYPE */
2214 +
2215 +
2216 +#define EPI_MAJOR_VERSION @EPI_MAJOR_VERSION@
2217 +
2218 +#define EPI_MINOR_VERSION @EPI_MINOR_VERSION@
2219 +
2220 +#define EPI_RC_NUMBER @EPI_RC_NUMBER@
2221 +
2222 +#define EPI_INCREMENTAL_NUMBER @EPI_INCREMENTAL_NUMBER@
2223 +
2224 +#define EPI_BUILD_NUMBER @EPI_BUILD_NUMBER@
2225 +
2226 +#define EPI_VERSION @EPI_VERSION@
2227 +
2228 +#define EPI_VERSION_NUM @EPI_VERSION_NUM@
2229 +
2230 +/* Driver Version String, ASCII, 32 chars max */
2231 +#define EPI_VERSION_STR "@EPI_VERSION_STR@"
2232 +#define EPI_ROUTER_VERSION_STR "@EPI_ROUTER_VERSION_STR@"
2233 +
2234 +#endif /* _epivers_h_ */
2235 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/etsockio.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/etsockio.h
2236 --- linux-2.4.30/arch/mips/bcm947xx/include/etsockio.h 1970-01-01 01:00:00.000000000 +0100
2237 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/etsockio.h 2005-02-02 23:16:39.000000000 +0100
2238 @@ -0,0 +1,59 @@
2239 +/*
2240 + * Driver-specific socket ioctls
2241 + * used by BSD, Linux, and PSOS
2242 + * Broadcom BCM44XX 10/100Mbps Ethernet Device Driver
2243 + *
2244 + * Copyright 2005, Broadcom Corporation
2245 + * All Rights Reserved.
2246 + *
2247 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2248 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2249 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2250 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2251 + *
2252 + * $Id$
2253 + */
2254 +
2255 +#ifndef _etsockio_h_
2256 +#define _etsockio_h_
2257 +
2258 +/* THESE MUST BE CONTIGUOUS AND CONSISTENT WITH VALUES IN ETC.H */
2259 +
2260 +
2261 +#if defined(linux)
2262 +#define SIOCSETCUP (SIOCDEVPRIVATE + 0)
2263 +#define SIOCSETCDOWN (SIOCDEVPRIVATE + 1)
2264 +#define SIOCSETCLOOP (SIOCDEVPRIVATE + 2)
2265 +#define SIOCGETCDUMP (SIOCDEVPRIVATE + 3)
2266 +#define SIOCSETCSETMSGLEVEL (SIOCDEVPRIVATE + 4)
2267 +#define SIOCSETCPROMISC (SIOCDEVPRIVATE + 5)
2268 +#define SIOCSETCTXDOWN (SIOCDEVPRIVATE + 6) /* obsolete */
2269 +#define SIOCSETCSPEED (SIOCDEVPRIVATE + 7)
2270 +#define SIOCTXGEN (SIOCDEVPRIVATE + 8)
2271 +#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
2272 +#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
2273 +#define SIOCSETCQOS (SIOCDEVPRIVATE + 11)
2274 +
2275 +#else /* !linux */
2276 +
2277 +#define SIOCSETCUP _IOWR('e', 130 + 0, struct ifreq)
2278 +#define SIOCSETCDOWN _IOWR('e', 130 + 1, struct ifreq)
2279 +#define SIOCSETCLOOP _IOWR('e', 130 + 2, struct ifreq)
2280 +#define SIOCGETCDUMP _IOWR('e', 130 + 3, struct ifreq)
2281 +#define SIOCSETCSETMSGLEVEL _IOWR('e', 130 + 4, struct ifreq)
2282 +#define SIOCSETCPROMISC _IOWR('e', 130 + 5, struct ifreq)
2283 +#define SIOCSETCTXDOWN _IOWR('e', 130 + 6, struct ifreq) /* obsolete */
2284 +#define SIOCSETCSPEED _IOWR('e', 130 + 7, struct ifreq)
2285 +#define SIOCTXGEN _IOWR('e', 130 + 8, struct ifreq)
2286 +
2287 +#endif
2288 +
2289 +/* arg to SIOCTXGEN */
2290 +struct txg {
2291 + uint32 num; /* number of frames to send */
2292 + uint32 delay; /* delay in microseconds between sending each */
2293 + uint32 size; /* size of ether frame to send */
2294 + uchar buf[1514]; /* starting ether frame data */
2295 +};
2296 +
2297 +#endif
2298 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/flash.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/flash.h
2299 --- linux-2.4.30/arch/mips/bcm947xx/include/flash.h 1970-01-01 01:00:00.000000000 +0100
2300 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/flash.h 2005-02-02 23:16:39.000000000 +0100
2301 @@ -0,0 +1,188 @@
2302 +/*
2303 + * flash.h: Common definitions for flash access.
2304 + *
2305 + * Copyright 2005, Broadcom Corporation
2306 + * All Rights Reserved.
2307 + *
2308 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2309 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2310 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2311 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2312 + *
2313 + * $Id$
2314 + */
2315 +
2316 +/* Types of flashes we know about */
2317 +typedef enum _flash_type {OLD, BSC, SCS, AMD, SST, SFLASH} flash_type_t;
2318 +
2319 +/* Commands to write/erase the flases */
2320 +typedef struct _flash_cmds{
2321 + flash_type_t type;
2322 + bool need_unlock;
2323 + uint16 pre_erase;
2324 + uint16 erase_block;
2325 + uint16 erase_chip;
2326 + uint16 write_word;
2327 + uint16 write_buf;
2328 + uint16 clear_csr;
2329 + uint16 read_csr;
2330 + uint16 read_id;
2331 + uint16 confirm;
2332 + uint16 read_array;
2333 +} flash_cmds_t;
2334 +
2335 +#define UNLOCK_CMD_WORDS 2
2336 +
2337 +typedef struct _unlock_cmd {
2338 + uint addr[UNLOCK_CMD_WORDS];
2339 + uint16 cmd[UNLOCK_CMD_WORDS];
2340 +} unlock_cmd_t;
2341 +
2342 +/* Flash descriptors */
2343 +typedef struct _flash_desc {
2344 + uint16 mfgid; /* Manufacturer Id */
2345 + uint16 devid; /* Device Id */
2346 + uint size; /* Total size in bytes */
2347 + uint width; /* Device width in bytes */
2348 + flash_type_t type; /* Device type old, S, J */
2349 + uint bsize; /* Block size */
2350 + uint nb; /* Number of blocks */
2351 + uint ff; /* First full block */
2352 + uint lf; /* Last full block */
2353 + uint nsub; /* Number of subblocks */
2354 + uint *subblocks; /* Offsets for subblocks */
2355 + char *desc; /* Description */
2356 +} flash_desc_t;
2357 +
2358 +
2359 +#ifdef DECLARE_FLASHES
2360 +flash_cmds_t sflash_cmd_t =
2361 + { SFLASH, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2362 +
2363 +flash_cmds_t flash_cmds[] = {
2364 +/* type needu preera eraseb erasech write wbuf clcsr rdcsr rdid confrm read */
2365 + { BSC, 0, 0x00, 0x20, 0x00, 0x40, 0x00, 0x50, 0x70, 0x90, 0xd0, 0xff },
2366 + { SCS, 0, 0x00, 0x20, 0x00, 0x40, 0xe8, 0x50, 0x70, 0x90, 0xd0, 0xff },
2367 + { AMD, 1, 0x80, 0x30, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
2368 + { SST, 1, 0x80, 0x50, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
2369 + { 0 }
2370 +};
2371 +
2372 +unlock_cmd_t unlock_cmd_amd = {
2373 +#ifdef MIPSEB
2374 +/* addr: */ { 0x0aa8, 0x0556},
2375 +#else
2376 +/* addr: */ { 0x0aaa, 0x0554},
2377 +#endif
2378 +/* data: */ { 0xaa, 0x55}
2379 +};
2380 +
2381 +unlock_cmd_t unlock_cmd_sst = {
2382 +#ifdef MIPSEB
2383 +/* addr: */ { 0xaaa8, 0x5556},
2384 +#else
2385 +/* addr: */ { 0xaaaa, 0x5554},
2386 +#endif
2387 +/* data: */ { 0xaa, 0x55}
2388 +};
2389 +
2390 +#define AMD_CMD 0xaaa
2391 +#define SST_CMD 0xaaaa
2392 +
2393 +/* intel unlock block cmds */
2394 +#define INTEL_UNLOCK1 0x60
2395 +#define INTEL_UNLOCK2 0xD0
2396 +
2397 +/* Just eight blocks of 8KB byte each */
2398 +
2399 +uint blk8x8k[] = { 0x00000000,
2400 + 0x00002000,
2401 + 0x00004000,
2402 + 0x00006000,
2403 + 0x00008000,
2404 + 0x0000a000,
2405 + 0x0000c000,
2406 + 0x0000e000,
2407 + 0x00010000
2408 +};
2409 +
2410 +/* Funky AMD arrangement for 29xx800's */
2411 +uint amd800[] = { 0x00000000, /* 16KB */
2412 + 0x00004000, /* 32KB */
2413 + 0x0000c000, /* 8KB */
2414 + 0x0000e000, /* 8KB */
2415 + 0x00010000, /* 8KB */
2416 + 0x00012000, /* 8KB */
2417 + 0x00014000, /* 32KB */
2418 + 0x0001c000, /* 16KB */
2419 + 0x00020000
2420 +};
2421 +
2422 +/* AMD arrangement for 29xx160's */
2423 +uint amd4112[] = { 0x00000000, /* 32KB */
2424 + 0x00008000, /* 8KB */
2425 + 0x0000a000, /* 8KB */
2426 + 0x0000c000, /* 16KB */
2427 + 0x00010000
2428 +};
2429 +uint amd2114[] = { 0x00000000, /* 16KB */
2430 + 0x00004000, /* 8KB */
2431 + 0x00006000, /* 8KB */
2432 + 0x00008000, /* 32KB */
2433 + 0x00010000
2434 +};
2435 +
2436 +
2437 +flash_desc_t sflash_desc =
2438 + { 0, 0, 0, 0, SFLASH, 0, 0, 0, 0, 0, NULL, "SFLASH" };
2439 +
2440 +flash_desc_t flashes[] = {
2441 + { 0x00b0, 0x00d0, 0x0200000, 2, SCS, 0x10000, 32, 0, 31, 0, NULL, "Intel 28F160S3/5 1Mx16" },
2442 + { 0x00b0, 0x00d4, 0x0400000, 2, SCS, 0x10000, 64, 0, 63, 0, NULL, "Intel 28F320S3/5 2Mx16" },
2443 + { 0x0089, 0x8890, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160B3 1Mx16 TopB" },
2444 + { 0x0089, 0x8891, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160B3 1Mx16 BotB" },
2445 + { 0x0089, 0x8896, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320B3 2Mx16 TopB" },
2446 + { 0x0089, 0x8897, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320B3 2Mx16 BotB" },
2447 + { 0x0089, 0x8898, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640B3 4Mx16 TopB" },
2448 + { 0x0089, 0x8899, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640B3 4Mx16 BotB" },
2449 + { 0x0089, 0x88C2, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160C3 1Mx16 TopB" },
2450 + { 0x0089, 0x88C3, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160C3 1Mx16 BotB" },
2451 + { 0x0089, 0x88C4, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320C3 2Mx16 TopB" },
2452 + { 0x0089, 0x88C5, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320C3 2Mx16 BotB" },
2453 + { 0x0089, 0x88CC, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640C3 4Mx16 TopB" },
2454 + { 0x0089, 0x88CD, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640C3 4Mx16 BotB" },
2455 + { 0x0089, 0x0014, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J5 2Mx16" },
2456 + { 0x0089, 0x0015, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J5 4Mx16" },
2457 + { 0x0089, 0x0016, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J3 2Mx16" },
2458 + { 0x0089, 0x0017, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J3 4Mx16" },
2459 + { 0x0089, 0x0018, 0x1000000, 2, SCS, 0x20000, 128, 0, 127, 0, NULL, "Intel 28F128J3 8Mx16" },
2460 + { 0x00b0, 0x00e3, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Sharp 28F320BJE 2Mx16 BotB" },
2461 + { 0x0001, 0x224a, 0x0100000, 2, AMD, 0x10000, 16, 0, 13, 8, amd800, "AMD 29DL800BT 512Kx16 TopB" },
2462 + { 0x0001, 0x22cb, 0x0100000, 2, AMD, 0x10000, 16, 2, 15, 8, amd800, "AMD 29DL800BB 512Kx16 BotB" },
2463 + { 0x0001, 0x22c4, 0x0200000, 2, AMD, 0x10000, 32, 0, 30, 4, amd2114, "AMD 29lv160DT 1Mx16 TopB" },
2464 + { 0x0001, 0x2249, 0x0200000, 2, AMD, 0x10000, 32, 1, 31, 4, amd4112, "AMD 29lv160DB 1Mx16 BotB" },
2465 + { 0x0001, 0x22f6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320DT 2Mx16 TopB" },
2466 + { 0x0001, 0x22f9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320DB 2Mx16 BotB" },
2467 + { 0x0001, 0x2201, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320MT 2Mx16 TopB" },
2468 + { 0x0001, 0x2200, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320MB 2Mx16 BotB" },
2469 + { 0x0020, 0x22CA, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "ST 29w320DT 2Mx16 TopB" },
2470 + { 0x0020, 0x22CB, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "ST 29w320DB 2Mx16 BotB" },
2471 + { 0x00C2, 0x00A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
2472 + { 0x00C2, 0x00A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
2473 + { 0x0004, 0x22F6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MBM29LV320TE 2Mx16 TopB" },
2474 + { 0x0004, 0x22F9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MBM29LV320BE 2Mx16 BotB" },
2475 + { 0x0098, 0x009A, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "TC58FVT321 2Mx16 TopB" },
2476 + { 0x0098, 0x009C, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "TC58FVB321 2Mx16 BotB" },
2477 + { 0x00C2, 0x22A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
2478 + { 0x00C2, 0x22A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
2479 + { 0x00BF, 0x2783, 0x0400000, 2, SST, 0x10000, 64, 0, 63, 0, NULL, "SST39VF320 2Mx16" },
2480 + { 0, 0, 0, 0, OLD, 0, 0, 0, 0, 0, NULL, NULL },
2481 +};
2482 +
2483 +#else
2484 +
2485 +extern flash_cmds_t flash_cmds[];
2486 +extern unlock_cmd_t unlock_cmd;
2487 +extern flash_desc_t flashes[];
2488 +
2489 +#endif
2490 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/flashutl.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/flashutl.h
2491 --- linux-2.4.30/arch/mips/bcm947xx/include/flashutl.h 1970-01-01 01:00:00.000000000 +0100
2492 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/flashutl.h 2005-02-02 23:16:39.000000000 +0100
2493 @@ -0,0 +1,27 @@
2494 +/*
2495 + * BCM47XX FLASH driver interface
2496 + *
2497 + * Copyright 2005, Broadcom Corporation
2498 + * All Rights Reserved.
2499 + *
2500 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2501 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2502 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2503 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2504 + * $Id$
2505 + */
2506 +
2507 +#ifndef _flashutl_h_
2508 +#define _flashutl_h_
2509 +
2510 +
2511 +#ifndef _LANGUAGE_ASSEMBLY
2512 +
2513 +int sysFlashInit(char *flash_str);
2514 +int sysFlashRead(uint off, uchar *dst, uint bytes);
2515 +int sysFlashWrite(uint off, uchar *src, uint bytes);
2516 +void nvWrite(unsigned short *data, unsigned int len);
2517 +
2518 +#endif /* _LANGUAGE_ASSEMBLY */
2519 +
2520 +#endif /* _flashutl_h_ */
2521 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/hnddma.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/hnddma.h
2522 --- linux-2.4.30/arch/mips/bcm947xx/include/hnddma.h 1970-01-01 01:00:00.000000000 +0100
2523 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/hnddma.h 2005-02-02 23:16:39.000000000 +0100
2524 @@ -0,0 +1,184 @@
2525 +/*
2526 + * Generic Broadcom Home Networking Division (HND) DMA engine definitions.
2527 + * This supports the following chips: BCM42xx, 44xx, 47xx .
2528 + *
2529 + * Copyright 2005, Broadcom Corporation
2530 + * All Rights Reserved.
2531 + *
2532 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2533 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2534 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2535 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2536 + * $Id$
2537 + */
2538 +
2539 +#ifndef _hnddma_h_
2540 +#define _hnddma_h_
2541 +
2542 +/*
2543 + * Each DMA processor consists of a transmit channel and a receive channel.
2544 + */
2545 +typedef volatile struct {
2546 + /* transmit channel */
2547 + uint32 xmtcontrol; /* enable, et al */
2548 + uint32 xmtaddr; /* descriptor ring base address (4K aligned) */
2549 + uint32 xmtptr; /* last descriptor posted to chip */
2550 + uint32 xmtstatus; /* current active descriptor, et al */
2551 +
2552 + /* receive channel */
2553 + uint32 rcvcontrol; /* enable, et al */
2554 + uint32 rcvaddr; /* descriptor ring base address (4K aligned) */
2555 + uint32 rcvptr; /* last descriptor posted to chip */
2556 + uint32 rcvstatus; /* current active descriptor, et al */
2557 +} dmaregs_t;
2558 +
2559 +typedef volatile struct {
2560 + /* diag access */
2561 + uint32 fifoaddr; /* diag address */
2562 + uint32 fifodatalow; /* low 32bits of data */
2563 + uint32 fifodatahigh; /* high 32bits of data */
2564 + uint32 pad; /* reserved */
2565 +} dmafifo_t;
2566 +
2567 +/* transmit channel control */
2568 +#define XC_XE ((uint32)1 << 0) /* transmit enable */
2569 +#define XC_SE ((uint32)1 << 1) /* transmit suspend request */
2570 +#define XC_LE ((uint32)1 << 2) /* loopback enable */
2571 +#define XC_FL ((uint32)1 << 4) /* flush request */
2572 +
2573 +/* transmit descriptor table pointer */
2574 +#define XP_LD_MASK 0xfff /* last valid descriptor */
2575 +
2576 +/* transmit channel status */
2577 +#define XS_CD_MASK 0x0fff /* current descriptor pointer */
2578 +#define XS_XS_MASK 0xf000 /* transmit state */
2579 +#define XS_XS_SHIFT 12
2580 +#define XS_XS_DISABLED 0x0000 /* disabled */
2581 +#define XS_XS_ACTIVE 0x1000 /* active */
2582 +#define XS_XS_IDLE 0x2000 /* idle wait */
2583 +#define XS_XS_STOPPED 0x3000 /* stopped */
2584 +#define XS_XS_SUSP 0x4000 /* suspend pending */
2585 +#define XS_XE_MASK 0xf0000 /* transmit errors */
2586 +#define XS_XE_SHIFT 16
2587 +#define XS_XE_NOERR 0x00000 /* no error */
2588 +#define XS_XE_DPE 0x10000 /* descriptor protocol error */
2589 +#define XS_XE_DFU 0x20000 /* data fifo underrun */
2590 +#define XS_XE_BEBR 0x30000 /* bus error on buffer read */
2591 +#define XS_XE_BEDA 0x40000 /* bus error on descriptor access */
2592 +#define XS_AD_MASK 0xfff00000 /* active descriptor */
2593 +#define XS_AD_SHIFT 20
2594 +
2595 +/* receive channel control */
2596 +#define RC_RE ((uint32)1 << 0) /* receive enable */
2597 +#define RC_RO_MASK 0xfe /* receive frame offset */
2598 +#define RC_RO_SHIFT 1
2599 +#define RC_FM ((uint32)1 << 8) /* direct fifo receive (pio) mode */
2600 +
2601 +/* receive descriptor table pointer */
2602 +#define RP_LD_MASK 0xfff /* last valid descriptor */
2603 +
2604 +/* receive channel status */
2605 +#define RS_CD_MASK 0x0fff /* current descriptor pointer */
2606 +#define RS_RS_MASK 0xf000 /* receive state */
2607 +#define RS_RS_SHIFT 12
2608 +#define RS_RS_DISABLED 0x0000 /* disabled */
2609 +#define RS_RS_ACTIVE 0x1000 /* active */
2610 +#define RS_RS_IDLE 0x2000 /* idle wait */
2611 +#define RS_RS_STOPPED 0x3000 /* reserved */
2612 +#define RS_RE_MASK 0xf0000 /* receive errors */
2613 +#define RS_RE_SHIFT 16
2614 +#define RS_RE_NOERR 0x00000 /* no error */
2615 +#define RS_RE_DPE 0x10000 /* descriptor protocol error */
2616 +#define RS_RE_DFO 0x20000 /* data fifo overflow */
2617 +#define RS_RE_BEBW 0x30000 /* bus error on buffer write */
2618 +#define RS_RE_BEDA 0x40000 /* bus error on descriptor access */
2619 +#define RS_AD_MASK 0xfff00000 /* active descriptor */
2620 +#define RS_AD_SHIFT 20
2621 +
2622 +/* fifoaddr */
2623 +#define FA_OFF_MASK 0xffff /* offset */
2624 +#define FA_SEL_MASK 0xf0000 /* select */
2625 +#define FA_SEL_SHIFT 16
2626 +#define FA_SEL_XDD 0x00000 /* transmit dma data */
2627 +#define FA_SEL_XDP 0x10000 /* transmit dma pointers */
2628 +#define FA_SEL_RDD 0x40000 /* receive dma data */
2629 +#define FA_SEL_RDP 0x50000 /* receive dma pointers */
2630 +#define FA_SEL_XFD 0x80000 /* transmit fifo data */
2631 +#define FA_SEL_XFP 0x90000 /* transmit fifo pointers */
2632 +#define FA_SEL_RFD 0xc0000 /* receive fifo data */
2633 +#define FA_SEL_RFP 0xd0000 /* receive fifo pointers */
2634 +
2635 +/*
2636 + * DMA Descriptor
2637 + * Descriptors are only read by the hardware, never written back.
2638 + */
2639 +typedef volatile struct {
2640 + uint32 ctrl; /* misc control bits & bufcount */
2641 + uint32 addr; /* data buffer address */
2642 +} dmadd_t;
2643 +
2644 +/*
2645 + * Each descriptor ring must be 4096byte aligned
2646 + * and fit within a single 4096byte page.
2647 + */
2648 +#define DMAMAXRINGSZ 4096
2649 +#define DMARINGALIGN 4096
2650 +
2651 +/* control flags */
2652 +#define CTRL_BC_MASK 0x1fff /* buffer byte count */
2653 +#define CTRL_EOT ((uint32)1 << 28) /* end of descriptor table */
2654 +#define CTRL_IOC ((uint32)1 << 29) /* interrupt on completion */
2655 +#define CTRL_EOF ((uint32)1 << 30) /* end of frame */
2656 +#define CTRL_SOF ((uint32)1 << 31) /* start of frame */
2657 +
2658 +/* control flags in the range [27:20] are core-specific and not defined here */
2659 +#define CTRL_CORE_MASK 0x0ff00000
2660 +
2661 +/* export structure */
2662 +typedef volatile struct {
2663 + /* rx error counters */
2664 + uint rxgiants; /* rx giant frames */
2665 + uint rxnobuf; /* rx out of dma descriptors */
2666 + /* tx error counters */
2667 + uint txnobuf; /* tx out of dma descriptors */
2668 +} hnddma_t;
2669 +
2670 +#ifndef di_t
2671 +#define di_t void
2672 +#endif
2673 +
2674 +/* externs */
2675 +extern void * dma_attach(void *drv, void *dev, char *name, dmaregs_t *dmaregs,
2676 + uint ntxd, uint nrxd, uint rxbufsize, uint nrxpost, uint rxoffset,
2677 + uint ddoffset, uint dataoffset, uint *msg_level);
2678 +extern void dma_detach(di_t *di);
2679 +extern void dma_txreset(di_t *di);
2680 +extern void dma_rxreset(di_t *di);
2681 +extern void dma_txinit(di_t *di);
2682 +extern bool dma_txenabled(di_t *di);
2683 +extern void dma_rxinit(di_t *di);
2684 +extern void dma_rxenable(di_t *di);
2685 +extern bool dma_rxenabled(di_t *di);
2686 +extern void dma_txsuspend(di_t *di);
2687 +extern void dma_txresume(di_t *di);
2688 +extern bool dma_txsuspended(di_t *di);
2689 +extern bool dma_txstopped(di_t *di);
2690 +extern bool dma_rxstopped(di_t *di);
2691 +extern int dma_txfast(di_t *di, void *p, uint32 coreflags);
2692 +extern int dma_tx(di_t *di, void *p, uint32 coreflags);
2693 +extern void dma_fifoloopbackenable(di_t *di);
2694 +extern void *dma_rx(di_t *di);
2695 +extern void dma_rxfill(di_t *di);
2696 +extern void dma_txreclaim(di_t *di, bool forceall);
2697 +extern void dma_rxreclaim(di_t *di);
2698 +extern uintptr dma_getvar(di_t *di, char *name);
2699 +extern void *dma_getnexttxp(di_t *di, bool forceall);
2700 +extern void *dma_peeknexttxp(di_t *di);
2701 +extern void *dma_getnextrxp(di_t *di, bool forceall);
2702 +extern void dma_txblock(di_t *di);
2703 +extern void dma_txunblock(di_t *di);
2704 +extern uint dma_txactive(di_t *di);
2705 +extern void dma_txrotate(di_t *di);
2706 +
2707 +
2708 +#endif /* _hnddma_h_ */
2709 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/hndmips.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/hndmips.h
2710 --- linux-2.4.30/arch/mips/bcm947xx/include/hndmips.h 1970-01-01 01:00:00.000000000 +0100
2711 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/hndmips.h 2005-02-02 23:16:39.000000000 +0100
2712 @@ -0,0 +1,16 @@
2713 +/*
2714 + * Alternate include file for HND sbmips.h since CFE also ships with
2715 + * a sbmips.h.
2716 + *
2717 + * Copyright 2005, Broadcom Corporation
2718 + * All Rights Reserved.
2719 + *
2720 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2721 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2722 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2723 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2724 + *
2725 + * $Id$
2726 + */
2727 +
2728 +#include "sbmips.h"
2729 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/linux_osl.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/linux_osl.h
2730 --- linux-2.4.30/arch/mips/bcm947xx/include/linux_osl.h 1970-01-01 01:00:00.000000000 +0100
2731 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/linux_osl.h 2005-02-02 23:16:39.000000000 +0100
2732 @@ -0,0 +1,341 @@
2733 +/*
2734 + * Linux OS Independent Layer
2735 + *
2736 + * Copyright 2005, Broadcom Corporation
2737 + * All Rights Reserved.
2738 + *
2739 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2740 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2741 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2742 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2743 + *
2744 + * $Id$
2745 + */
2746 +
2747 +#ifndef _linux_osl_h_
2748 +#define _linux_osl_h_
2749 +
2750 +#include <typedefs.h>
2751 +
2752 +/* use current 2.4.x calling conventions */
2753 +#include <linuxver.h>
2754 +
2755 +/* assert and panic */
2756 +#define ASSERT(exp) do {} while (0)
2757 +
2758 +/* PCMCIA attribute space access macros */
2759 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
2760 +struct pcmcia_dev {
2761 + dev_link_t link; /* PCMCIA device pointer */
2762 + dev_node_t node; /* PCMCIA node structure */
2763 + void *base; /* Mapped attribute memory window */
2764 + size_t size; /* Size of window */
2765 + void *drv; /* Driver data */
2766 +};
2767 +#endif
2768 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
2769 + osl_pcmcia_read_attr((osh), (offset), (buf), (size))
2770 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
2771 + osl_pcmcia_write_attr((osh), (offset), (buf), (size))
2772 +extern void osl_pcmcia_read_attr(void *osh, uint offset, void *buf, int size);
2773 +extern void osl_pcmcia_write_attr(void *osh, uint offset, void *buf, int size);
2774 +
2775 +/* PCI configuration space access macros */
2776 +#define OSL_PCI_READ_CONFIG(osh, offset, size) \
2777 + osl_pci_read_config((osh), (offset), (size))
2778 +#define OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
2779 + osl_pci_write_config((osh), (offset), (size), (val))
2780 +extern uint32 osl_pci_read_config(void *osh, uint size, uint offset);
2781 +extern void osl_pci_write_config(void *osh, uint offset, uint size, uint val);
2782 +
2783 +/* OSL initialization */
2784 +extern void *osl_attach(void *pdev);
2785 +extern void osl_detach(void *osh);
2786 +
2787 +/* host/bus architecture-specific byte swap */
2788 +#define BUS_SWAP32(v) (v)
2789 +
2790 +/* general purpose memory allocation */
2791 +
2792 +#if defined(BCMDBG_MEM)
2793 +
2794 +#define MALLOC(osh, size) osl_debug_malloc((osh), (size), __LINE__, __FILE__)
2795 +#define MFREE(osh, addr, size) osl_debug_mfree((osh), (addr), (size), __LINE__, __FILE__)
2796 +#define MALLOCED(osh) osl_malloced((osh))
2797 +#define MALLOC_DUMP(osh, buf, sz) osl_debug_memdump((osh), (buf), (sz))
2798 +extern void *osl_debug_malloc(void *osh, uint size, int line, char* file);
2799 +extern void osl_debug_mfree(void *osh, void *addr, uint size, int line, char* file);
2800 +extern char *osl_debug_memdump(void *osh, char *buf, uint sz);
2801 +
2802 +#else
2803 +
2804 +#define MALLOC(osh, size) osl_malloc((osh), (size))
2805 +#define MFREE(osh, addr, size) osl_mfree((osh), (addr), (size))
2806 +#define MALLOCED(osh) osl_malloced((osh))
2807 +
2808 +#endif /* BCMDBG_MEM */
2809 +
2810 +#define MALLOC_FAILED(osh) osl_malloc_failed((osh))
2811 +
2812 +extern void *osl_malloc(void *osh, uint size);
2813 +extern void osl_mfree(void *osh, void *addr, uint size);
2814 +extern uint osl_malloced(void *osh);
2815 +extern uint osl_malloc_failed(void *osh);
2816 +
2817 +/* allocate/free shared (dma-able) consistent memory */
2818 +#define DMA_CONSISTENT_ALIGN PAGE_SIZE
2819 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
2820 + osl_dma_alloc_consistent((osh), (size), (pap))
2821 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
2822 + osl_dma_free_consistent((osh), (void*)(va), (size), (pa))
2823 +extern void *osl_dma_alloc_consistent(void *osh, uint size, ulong *pap);
2824 +extern void osl_dma_free_consistent(void *osh, void *va, uint size, ulong pa);
2825 +
2826 +/* map/unmap direction */
2827 +#define DMA_TX 1
2828 +#define DMA_RX 2
2829 +
2830 +/* map/unmap shared (dma-able) memory */
2831 +#define DMA_MAP(osh, va, size, direction, p) \
2832 + osl_dma_map((osh), (va), (size), (direction))
2833 +#define DMA_UNMAP(osh, pa, size, direction, p) \
2834 + osl_dma_unmap((osh), (pa), (size), (direction))
2835 +extern uint osl_dma_map(void *osh, void *va, uint size, int direction);
2836 +extern void osl_dma_unmap(void *osh, uint pa, uint size, int direction);
2837 +
2838 +/* register access macros */
2839 +#if defined(BCMJTAG)
2840 +struct bcmjtag_info;
2841 +extern uint32 bcmjtag_read(struct bcmjtag_info *ejh, uint32 addr, uint size);
2842 +extern void bcmjtag_write(struct bcmjtag_info *ejh, uint32 addr, uint32 val, uint size);
2843 +#define R_REG(r) bcmjtag_read(NULL, (uint32)(r), sizeof (*(r)))
2844 +#define W_REG(r, v) bcmjtag_write(NULL, (uint32)(r), (uint32)(v), sizeof (*(r)))
2845 +#endif
2846 +
2847 +/*
2848 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
2849 + * Macros expand to calls to functions defined in linux_osl.c .
2850 + */
2851 +#ifndef BINOSL
2852 +
2853 +/* string library, kernel mode */
2854 +#define printf(fmt, args...) printk(fmt, ## args)
2855 +#include <linux/kernel.h>
2856 +#include <linux/string.h>
2857 +
2858 +/* register access macros */
2859 +#if !defined(BCMJTAG)
2860 +#define R_REG(r) ( \
2861 + sizeof(*(r)) == sizeof(uint8) ? readb((volatile uint8*)(r)) : \
2862 + sizeof(*(r)) == sizeof(uint16) ? readw((volatile uint16*)(r)) : \
2863 + readl((volatile uint32*)(r)) \
2864 +)
2865 +#define W_REG(r, v) do { \
2866 + switch (sizeof(*(r))) { \
2867 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)(r)); break; \
2868 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)(r)); break; \
2869 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
2870 + } \
2871 +} while (0)
2872 +#endif
2873 +
2874 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
2875 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
2876 +
2877 +/* bcopy, bcmp, and bzero */
2878 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
2879 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
2880 +#define bzero(b, len) memset((b), '\0', (len))
2881 +
2882 +/* uncached virtual address */
2883 +#ifdef mips
2884 +#define OSL_UNCACHED(va) KSEG1ADDR((va))
2885 +#include <asm/addrspace.h>
2886 +#else
2887 +#define OSL_UNCACHED(va) (va)
2888 +#endif
2889 +
2890 +/* get processor cycle count */
2891 +#if defined(mips)
2892 +#define OSL_GETCYCLES(x) ((x) = read_c0_count() * 2)
2893 +#elif defined(__i386__)
2894 +#define OSL_GETCYCLES(x) rdtscl((x))
2895 +#else
2896 +#define OSL_GETCYCLES(x) ((x) = 0)
2897 +#endif
2898 +
2899 +/* dereference an address that may cause a bus exception */
2900 +#ifdef mips
2901 +#if defined(MODULE) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17))
2902 +#define BUSPROBE(val, addr) panic("get_dbe() will not fixup a bus exception when compiled into a module")
2903 +#else
2904 +#define BUSPROBE(val, addr) get_dbe((val), (addr))
2905 +#include <asm/paccess.h>
2906 +#endif
2907 +#else
2908 +#define BUSPROBE(val, addr) ({ (val) = R_REG((addr)); 0; })
2909 +#endif
2910 +
2911 +/* map/unmap physical to virtual I/O */
2912 +#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), (unsigned long)(size))
2913 +#define REG_UNMAP(va) iounmap((void *)(va))
2914 +
2915 +/* microsecond delay */
2916 +#define OSL_DELAY(usec) udelay(usec)
2917 +#include <linux/delay.h>
2918 +
2919 +/* shared (dma-able) memory access macros */
2920 +#define R_SM(r) *(r)
2921 +#define W_SM(r, v) (*(r) = (v))
2922 +#define BZERO_SM(r, len) memset((r), '\0', (len))
2923 +
2924 +/* packet primitives */
2925 +#define PKTGET(drv, len, send) osl_pktget((drv), (len), (send))
2926 +#define PKTFREE(drv, skb, send) osl_pktfree((skb))
2927 +#define PKTDATA(drv, skb) (((struct sk_buff*)(skb))->data)
2928 +#define PKTLEN(drv, skb) (((struct sk_buff*)(skb))->len)
2929 +#define PKTHEADROOM(drv, skb) (PKTDATA(drv,skb)-(((struct sk_buff*)(skb))->head))
2930 +#define PKTTAILROOM(drv, skb) ((((struct sk_buff*)(skb))->end)-(((struct sk_buff*)(skb))->tail))
2931 +#define PKTNEXT(drv, skb) (((struct sk_buff*)(skb))->next)
2932 +#define PKTSETNEXT(skb, x) (((struct sk_buff*)(skb))->next = (struct sk_buff*)(x))
2933 +#define PKTSETLEN(drv, skb, len) __skb_trim((struct sk_buff*)(skb), (len))
2934 +#define PKTPUSH(drv, skb, bytes) skb_push((struct sk_buff*)(skb), (bytes))
2935 +#define PKTPULL(drv, skb, bytes) skb_pull((struct sk_buff*)(skb), (bytes))
2936 +#define PKTDUP(drv, skb) skb_clone((struct sk_buff*)(skb), GFP_ATOMIC)
2937 +#define PKTCOOKIE(skb) ((void*)((struct sk_buff*)(skb))->csum)
2938 +#define PKTSETCOOKIE(skb, x) (((struct sk_buff*)(skb))->csum = (uint)(x))
2939 +#define PKTLINK(skb) (((struct sk_buff*)(skb))->prev)
2940 +#define PKTSETLINK(skb, x) (((struct sk_buff*)(skb))->prev = (struct sk_buff*)(x))
2941 +#define PKTPRIO(skb) (((struct sk_buff*)(skb))->priority)
2942 +#define PKTSETPRIO(skb, x) (((struct sk_buff*)(skb))->priority = (x))
2943 +extern void *osl_pktget(void *drv, uint len, bool send);
2944 +extern void osl_pktfree(void *skb);
2945 +
2946 +#else /* BINOSL */
2947 +
2948 +/* string library */
2949 +#ifndef LINUX_OSL
2950 +#undef printf
2951 +#define printf(fmt, args...) osl_printf((fmt), ## args)
2952 +#undef sprintf
2953 +#define sprintf(buf, fmt, args...) osl_sprintf((buf), (fmt), ## args)
2954 +#undef strcmp
2955 +#define strcmp(s1, s2) osl_strcmp((s1), (s2))
2956 +#undef strncmp
2957 +#define strncmp(s1, s2, n) osl_strncmp((s1), (s2), (n))
2958 +#undef strlen
2959 +#define strlen(s) osl_strlen((s))
2960 +#undef strcpy
2961 +#define strcpy(d, s) osl_strcpy((d), (s))
2962 +#undef strncpy
2963 +#define strncpy(d, s, n) osl_strncpy((d), (s), (n))
2964 +#endif
2965 +extern int osl_printf(const char *format, ...);
2966 +extern int osl_sprintf(char *buf, const char *format, ...);
2967 +extern int osl_strcmp(const char *s1, const char *s2);
2968 +extern int osl_strncmp(const char *s1, const char *s2, uint n);
2969 +extern int osl_strlen(char *s);
2970 +extern char* osl_strcpy(char *d, const char *s);
2971 +extern char* osl_strncpy(char *d, const char *s, uint n);
2972 +
2973 +/* register access macros */
2974 +#if !defined(BCMJTAG)
2975 +#define R_REG(r) ( \
2976 + sizeof(*(r)) == sizeof(uint8) ? osl_readb((volatile uint8*)(r)) : \
2977 + sizeof(*(r)) == sizeof(uint16) ? osl_readw((volatile uint16*)(r)) : \
2978 + osl_readl((volatile uint32*)(r)) \
2979 +)
2980 +#define W_REG(r, v) do { \
2981 + switch (sizeof(*(r))) { \
2982 + case sizeof(uint8): osl_writeb((uint8)(v), (volatile uint8*)(r)); break; \
2983 + case sizeof(uint16): osl_writew((uint16)(v), (volatile uint16*)(r)); break; \
2984 + case sizeof(uint32): osl_writel((uint32)(v), (volatile uint32*)(r)); break; \
2985 + } \
2986 +} while (0)
2987 +#endif
2988 +
2989 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
2990 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
2991 +extern uint8 osl_readb(volatile uint8 *r);
2992 +extern uint16 osl_readw(volatile uint16 *r);
2993 +extern uint32 osl_readl(volatile uint32 *r);
2994 +extern void osl_writeb(uint8 v, volatile uint8 *r);
2995 +extern void osl_writew(uint16 v, volatile uint16 *r);
2996 +extern void osl_writel(uint32 v, volatile uint32 *r);
2997 +
2998 +/* bcopy, bcmp, and bzero */
2999 +extern void bcopy(const void *src, void *dst, int len);
3000 +extern int bcmp(const void *b1, const void *b2, int len);
3001 +extern void bzero(void *b, int len);
3002 +
3003 +/* uncached virtual address */
3004 +#define OSL_UNCACHED(va) osl_uncached((va))
3005 +extern void *osl_uncached(void *va);
3006 +
3007 +/* get processor cycle count */
3008 +#define OSL_GETCYCLES(x) ((x) = osl_getcycles())
3009 +extern uint osl_getcycles(void);
3010 +
3011 +/* dereference an address that may target abort */
3012 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (addr))
3013 +extern int osl_busprobe(uint32 *val, uint32 addr);
3014 +
3015 +/* map/unmap physical to virtual */
3016 +#define REG_MAP(pa, size) osl_reg_map((pa), (size))
3017 +#define REG_UNMAP(va) osl_reg_unmap((va))
3018 +extern void *osl_reg_map(uint32 pa, uint size);
3019 +extern void osl_reg_unmap(void *va);
3020 +
3021 +/* microsecond delay */
3022 +#define OSL_DELAY(usec) osl_delay((usec))
3023 +extern void osl_delay(uint usec);
3024 +
3025 +/* shared (dma-able) memory access macros */
3026 +#define R_SM(r) *(r)
3027 +#define W_SM(r, v) (*(r) = (v))
3028 +#define BZERO_SM(r, len) bzero((r), (len))
3029 +
3030 +/* packet primitives */
3031 +#define PKTGET(drv, len, send) osl_pktget((drv), (len), (send))
3032 +#define PKTFREE(drv, skb, send) osl_pktfree((skb))
3033 +#define PKTDATA(drv, skb) osl_pktdata((drv), (skb))
3034 +#define PKTLEN(drv, skb) osl_pktlen((drv), (skb))
3035 +#define PKTHEADROOM(drv, skb) osl_pktheadroom((drv), (skb))
3036 +#define PKTTAILROOM(drv, skb) osl_pkttailroom((drv), (skb))
3037 +#define PKTNEXT(drv, skb) osl_pktnext((drv), (skb))
3038 +#define PKTSETNEXT(skb, x) osl_pktsetnext((skb), (x))
3039 +#define PKTSETLEN(drv, skb, len) osl_pktsetlen((drv), (skb), (len))
3040 +#define PKTPUSH(drv, skb, bytes) osl_pktpush((drv), (skb), (bytes))
3041 +#define PKTPULL(drv, skb, bytes) osl_pktpull((drv), (skb), (bytes))
3042 +#define PKTDUP(drv, skb) osl_pktdup((drv), (skb))
3043 +#define PKTCOOKIE(skb) osl_pktcookie((skb))
3044 +#define PKTSETCOOKIE(skb, x) osl_pktsetcookie((skb), (x))
3045 +#define PKTLINK(skb) osl_pktlink((skb))
3046 +#define PKTSETLINK(skb, x) osl_pktsetlink((skb), (x))
3047 +#define PKTPRIO(skb) osl_pktprio((skb))
3048 +#define PKTSETPRIO(skb, x) osl_pktsetprio((skb), (x))
3049 +extern void *osl_pktget(void *drv, uint len, bool send);
3050 +extern void osl_pktfree(void *skb);
3051 +extern uchar *osl_pktdata(void *drv, void *skb);
3052 +extern uint osl_pktlen(void *drv, void *skb);
3053 +extern uint osl_pktheadroom(void *drv, void *skb);
3054 +extern uint osl_pkttailroom(void *drv, void *skb);
3055 +extern void *osl_pktnext(void *drv, void *skb);
3056 +extern void osl_pktsetnext(void *skb, void *x);
3057 +extern void osl_pktsetlen(void *drv, void *skb, uint len);
3058 +extern uchar *osl_pktpush(void *drv, void *skb, int bytes);
3059 +extern uchar *osl_pktpull(void *drv, void *skb, int bytes);
3060 +extern void *osl_pktdup(void *drv, void *skb);
3061 +extern void *osl_pktcookie(void *skb);
3062 +extern void osl_pktsetcookie(void *skb, void *x);
3063 +extern void *osl_pktlink(void *skb);
3064 +extern void osl_pktsetlink(void *skb, void *x);
3065 +extern uint osl_pktprio(void *skb);
3066 +extern void osl_pktsetprio(void *skb, uint x);
3067 +
3068 +#endif /* BINOSL */
3069 +
3070 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
3071 +#define PKTBUFSZ 2048
3072 +
3073 +#endif /* _linux_osl_h_ */
3074 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/linuxver.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/linuxver.h
3075 --- linux-2.4.30/arch/mips/bcm947xx/include/linuxver.h 1970-01-01 01:00:00.000000000 +0100
3076 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/linuxver.h 2005-02-02 23:16:39.000000000 +0100
3077 @@ -0,0 +1,399 @@
3078 +/*
3079 + * Linux-specific abstractions to gain some independence from linux kernel versions.
3080 + * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
3081 + *
3082 + * Copyright 2005, Broadcom Corporation
3083 + * All Rights Reserved.
3084 + *
3085 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3086 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3087 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3088 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3089 + *
3090 + * $Id$
3091 + */
3092 +
3093 +#ifndef _linuxver_h_
3094 +#define _linuxver_h_
3095 +
3096 +#include <linux/config.h>
3097 +#include <linux/version.h>
3098 +
3099 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
3100 +/* __NO_VERSION__ must be defined for all linkables except one in 2.2 */
3101 +#ifdef __UNDEF_NO_VERSION__
3102 +#undef __NO_VERSION__
3103 +#else
3104 +#define __NO_VERSION__
3105 +#endif
3106 +#endif
3107 +
3108 +#if defined(MODULE) && defined(MODVERSIONS)
3109 +#include <linux/modversions.h>
3110 +#endif
3111 +
3112 +/* linux/malloc.h is deprecated, use linux/slab.h instead. */
3113 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9))
3114 +#include <linux/malloc.h>
3115 +#else
3116 +#include <linux/slab.h>
3117 +#endif
3118 +
3119 +#include <linux/types.h>
3120 +#include <linux/init.h>
3121 +#include <linux/mm.h>
3122 +#include <linux/string.h>
3123 +#include <linux/pci.h>
3124 +#include <linux/interrupt.h>
3125 +#include <linux/netdevice.h>
3126 +#include <asm/io.h>
3127 +
3128 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41))
3129 +#include <linux/workqueue.h>
3130 +#else
3131 +#include <linux/tqueue.h>
3132 +#ifndef work_struct
3133 +#define work_struct tq_struct
3134 +#endif
3135 +#ifndef INIT_WORK
3136 +#define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
3137 +#endif
3138 +#ifndef schedule_work
3139 +#define schedule_work(_work) schedule_task((_work))
3140 +#endif
3141 +#ifndef flush_scheduled_work
3142 +#define flush_scheduled_work() flush_scheduled_tasks()
3143 +#endif
3144 +#endif
3145 +
3146 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
3147 +/* Some distributions have their own 2.6.x compatibility layers */
3148 +#ifndef IRQ_NONE
3149 +typedef void irqreturn_t;
3150 +#define IRQ_NONE
3151 +#define IRQ_HANDLED
3152 +#define IRQ_RETVAL(x)
3153 +#endif
3154 +#endif
3155 +
3156 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
3157 +
3158 +#include <pcmcia/version.h>
3159 +#include <pcmcia/cs_types.h>
3160 +#include <pcmcia/cs.h>
3161 +#include <pcmcia/cistpl.h>
3162 +#include <pcmcia/cisreg.h>
3163 +#include <pcmcia/ds.h>
3164 +
3165 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,69))
3166 +/* In 2.5 (as of 2.5.69 at least) there is a cs_error exported which
3167 + * does this, but it's not in 2.4 so we do our own for now. */
3168 +static inline void
3169 +cs_error(client_handle_t handle, int func, int ret)
3170 +{
3171 + error_info_t err = { func, ret };
3172 + CardServices(ReportError, handle, &err);
3173 +}
3174 +#endif
3175 +
3176 +#endif /* CONFIG_PCMCIA */
3177 +
3178 +#ifndef __exit
3179 +#define __exit
3180 +#endif
3181 +#ifndef __devexit
3182 +#define __devexit
3183 +#endif
3184 +#ifndef __devinit
3185 +#define __devinit __init
3186 +#endif
3187 +#ifndef __devinitdata
3188 +#define __devinitdata
3189 +#endif
3190 +#ifndef __devexit_p
3191 +#define __devexit_p(x) x
3192 +#endif
3193 +
3194 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
3195 +
3196 +#define pci_get_drvdata(dev) (dev)->sysdata
3197 +#define pci_set_drvdata(dev, value) (dev)->sysdata=(value)
3198 +
3199 +/*
3200 + * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
3201 + */
3202 +
3203 +struct pci_device_id {
3204 + unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
3205 + unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
3206 + unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
3207 + unsigned long driver_data; /* Data private to the driver */
3208 +};
3209 +
3210 +struct pci_driver {
3211 + struct list_head node;
3212 + char *name;
3213 + const struct pci_device_id *id_table; /* NULL if wants all devices */
3214 + int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
3215 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
3216 + void (*suspend)(struct pci_dev *dev); /* Device suspended */
3217 + void (*resume)(struct pci_dev *dev); /* Device woken up */
3218 +};
3219 +
3220 +#define MODULE_DEVICE_TABLE(type, name)
3221 +#define PCI_ANY_ID (~0)
3222 +
3223 +/* compatpci.c */
3224 +#define pci_module_init pci_register_driver
3225 +extern int pci_register_driver(struct pci_driver *drv);
3226 +extern void pci_unregister_driver(struct pci_driver *drv);
3227 +
3228 +#endif /* PCI registration */
3229 +
3230 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
3231 +#ifdef MODULE
3232 +#define module_init(x) int init_module(void) { return x(); }
3233 +#define module_exit(x) void cleanup_module(void) { x(); }
3234 +#else
3235 +#define module_init(x) __initcall(x);
3236 +#define module_exit(x) __exitcall(x);
3237 +#endif
3238 +#endif
3239 +
3240 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,48))
3241 +#define list_for_each(pos, head) \
3242 + for (pos = (head)->next; pos != (head); pos = pos->next)
3243 +#endif
3244 +
3245 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,13))
3246 +#define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
3247 +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,44))
3248 +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
3249 +#endif
3250 +
3251 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,23))
3252 +#define pci_enable_device(dev) do { } while (0)
3253 +#endif
3254 +
3255 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,14))
3256 +#define net_device device
3257 +#endif
3258 +
3259 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,42))
3260 +
3261 +/*
3262 + * DMA mapping
3263 + *
3264 + * See linux/Documentation/DMA-mapping.txt
3265 + */
3266 +
3267 +#ifndef PCI_DMA_TODEVICE
3268 +#define PCI_DMA_TODEVICE 1
3269 +#define PCI_DMA_FROMDEVICE 2
3270 +#endif
3271 +
3272 +typedef u32 dma_addr_t;
3273 +
3274 +/* Pure 2^n version of get_order */
3275 +static inline int get_order(unsigned long size)
3276 +{
3277 + int order;
3278 +
3279 + size = (size-1) >> (PAGE_SHIFT-1);
3280 + order = -1;
3281 + do {
3282 + size >>= 1;
3283 + order++;
3284 + } while (size);
3285 + return order;
3286 +}
3287 +
3288 +static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
3289 + dma_addr_t *dma_handle)
3290 +{
3291 + void *ret;
3292 + int gfp = GFP_ATOMIC | GFP_DMA;
3293 +
3294 + ret = (void *)__get_free_pages(gfp, get_order(size));
3295 +
3296 + if (ret != NULL) {
3297 + memset(ret, 0, size);
3298 + *dma_handle = virt_to_bus(ret);
3299 + }
3300 + return ret;
3301 +}
3302 +static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
3303 + void *vaddr, dma_addr_t dma_handle)
3304 +{
3305 + free_pages((unsigned long)vaddr, get_order(size));
3306 +}
3307 +#ifdef ILSIM
3308 +extern uint pci_map_single(void *dev, void *va, uint size, int direction);
3309 +extern void pci_unmap_single(void *dev, uint pa, uint size, int direction);
3310 +#else
3311 +#define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
3312 +#define pci_unmap_single(cookie, address, size, dir)
3313 +#endif
3314 +
3315 +#endif /* DMA mapping */
3316 +
3317 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43))
3318 +
3319 +#define dev_kfree_skb_any(a) dev_kfree_skb(a)
3320 +#define netif_down(dev) do { (dev)->start = 0; } while(0)
3321 +
3322 +/* pcmcia-cs provides its own netdevice compatibility layer */
3323 +#ifndef _COMPAT_NETDEVICE_H
3324 +
3325 +/*
3326 + * SoftNet
3327 + *
3328 + * For pre-softnet kernels we need to tell the upper layer not to
3329 + * re-enter start_xmit() while we are in there. However softnet
3330 + * guarantees not to enter while we are in there so there is no need
3331 + * to do the netif_stop_queue() dance unless the transmit queue really
3332 + * gets stuck. This should also improve performance according to tests
3333 + * done by Aman Singla.
3334 + */
3335 +
3336 +#define dev_kfree_skb_irq(a) dev_kfree_skb(a)
3337 +#define netif_wake_queue(dev) do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while(0)
3338 +#define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy)
3339 +
3340 +static inline void netif_start_queue(struct net_device *dev)
3341 +{
3342 + dev->tbusy = 0;
3343 + dev->interrupt = 0;
3344 + dev->start = 1;
3345 +}
3346 +
3347 +#define netif_queue_stopped(dev) (dev)->tbusy
3348 +#define netif_running(dev) (dev)->start
3349 +
3350 +#endif /* _COMPAT_NETDEVICE_H */
3351 +
3352 +#define netif_device_attach(dev) netif_start_queue(dev)
3353 +#define netif_device_detach(dev) netif_stop_queue(dev)
3354 +
3355 +/* 2.4.x renamed bottom halves to tasklets */
3356 +#define tasklet_struct tq_struct
3357 +static inline void tasklet_schedule(struct tasklet_struct *tasklet)
3358 +{
3359 + queue_task(tasklet, &tq_immediate);
3360 + mark_bh(IMMEDIATE_BH);
3361 +}
3362 +
3363 +static inline void tasklet_init(struct tasklet_struct *tasklet,
3364 + void (*func)(unsigned long),
3365 + unsigned long data)
3366 +{
3367 + tasklet->next = NULL;
3368 + tasklet->sync = 0;
3369 + tasklet->routine = (void (*)(void *))func;
3370 + tasklet->data = (void *)data;
3371 +}
3372 +#define tasklet_kill(tasklet) {do{} while(0);}
3373 +
3374 +/* 2.4.x introduced del_timer_sync() */
3375 +#define del_timer_sync(timer) del_timer(timer)
3376 +
3377 +#else
3378 +
3379 +#define netif_down(dev)
3380 +
3381 +#endif /* SoftNet */
3382 +
3383 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3))
3384 +
3385 +/*
3386 + * Emit code to initialise a tq_struct's routine and data pointers
3387 + */
3388 +#define PREPARE_TQUEUE(_tq, _routine, _data) \
3389 + do { \
3390 + (_tq)->routine = _routine; \
3391 + (_tq)->data = _data; \
3392 + } while (0)
3393 +
3394 +/*
3395 + * Emit code to initialise all of a tq_struct
3396 + */
3397 +#define INIT_TQUEUE(_tq, _routine, _data) \
3398 + do { \
3399 + INIT_LIST_HEAD(&(_tq)->list); \
3400 + (_tq)->sync = 0; \
3401 + PREPARE_TQUEUE((_tq), (_routine), (_data)); \
3402 + } while (0)
3403 +
3404 +#endif
3405 +
3406 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6))
3407 +
3408 +/* Power management related routines */
3409 +
3410 +static inline int
3411 +pci_save_state(struct pci_dev *dev, u32 *buffer)
3412 +{
3413 + int i;
3414 + if (buffer) {
3415 + for (i = 0; i < 16; i++)
3416 + pci_read_config_dword(dev, i * 4,&buffer[i]);
3417 + }
3418 + return 0;
3419 +}
3420 +
3421 +static inline int
3422 +pci_restore_state(struct pci_dev *dev, u32 *buffer)
3423 +{
3424 + int i;
3425 +
3426 + if (buffer) {
3427 + for (i = 0; i < 16; i++)
3428 + pci_write_config_dword(dev,i * 4, buffer[i]);
3429 + }
3430 + /*
3431 + * otherwise, write the context information we know from bootup.
3432 + * This works around a problem where warm-booting from Windows
3433 + * combined with a D3(hot)->D0 transition causes PCI config
3434 + * header data to be forgotten.
3435 + */
3436 + else {
3437 + for (i = 0; i < 6; i ++)
3438 + pci_write_config_dword(dev,
3439 + PCI_BASE_ADDRESS_0 + (i * 4),
3440 + pci_resource_start(dev, i));
3441 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
3442 + }
3443 + return 0;
3444 +}
3445 +
3446 +#endif /* PCI power management */
3447 +
3448 +/* Old cp0 access macros deprecated in 2.4.19 */
3449 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19))
3450 +#define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
3451 +#endif
3452 +
3453 +/* Module refcount handled internally in 2.6.x */
3454 +#ifndef SET_MODULE_OWNER
3455 +#define SET_MODULE_OWNER(dev) do {} while (0)
3456 +#define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
3457 +#define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
3458 +#else
3459 +#define OLD_MOD_INC_USE_COUNT do {} while (0)
3460 +#define OLD_MOD_DEC_USE_COUNT do {} while (0)
3461 +#endif
3462 +
3463 +#ifndef SET_NETDEV_DEV
3464 +#define SET_NETDEV_DEV(net, pdev) do {} while (0)
3465 +#endif
3466 +
3467 +#ifndef HAVE_FREE_NETDEV
3468 +#define free_netdev(dev) kfree(dev)
3469 +#endif
3470 +
3471 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
3472 +/* struct packet_type redefined in 2.6.x */
3473 +#define af_packet_priv data
3474 +#endif
3475 +
3476 +#endif /* _linuxver_h_ */
3477 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/min_osl.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/min_osl.h
3478 --- linux-2.4.30/arch/mips/bcm947xx/include/min_osl.h 1970-01-01 01:00:00.000000000 +0100
3479 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/min_osl.h 2005-05-25 03:31:09.000000000 +0200
3480 @@ -0,0 +1,120 @@
3481 +/*
3482 + * HND Minimal OS Abstraction Layer.
3483 + *
3484 + * Copyright 2005, Broadcom Corporation
3485 + * All Rights Reserved.
3486 + *
3487 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3488 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3489 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3490 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3491 + *
3492 + * $Id$
3493 + */
3494 +
3495 +#ifndef _min_osl_h_
3496 +#define _min_osl_h_
3497 +
3498 +#include <typedefs.h>
3499 +#include <sbconfig.h>
3500 +
3501 +/* Cache support */
3502 +extern void caches_on(void);
3503 +extern void blast_dcache(void);
3504 +extern void blast_icache(void);
3505 +
3506 +/* uart output */
3507 +extern void putc(int c);
3508 +
3509 +/* lib functions */
3510 +extern int printf(const char *fmt, ...);
3511 +extern int sprintf(char *buf, const char *fmt, ...);
3512 +extern int strcmp(const char *s1, const char *s2);
3513 +extern int strncmp(const char *s1, const char *s2, uint n);
3514 +extern char *strcpy(char *dest, const char *src);
3515 +extern char *strncpy(char *dest, const char *src, uint n);
3516 +extern uint strlen(const char *s);
3517 +extern char *strchr(const char *str,int c);
3518 +extern char *strrchr(const char *str, int c);
3519 +extern char *strcat(char *d, const char *s);
3520 +extern void *memset(void *dest, int c, uint n);
3521 +extern void *memcpy(void *dest, const void *src, uint n);
3522 +extern int memcmp(const void *s1, const void *s2, uint n);
3523 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
3524 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
3525 +#define bzero(b, len) memset((b), '\0', (len))
3526 +
3527 +/* assert & debugging */
3528 +#define ASSERT(exp) do {} while (0)
3529 +
3530 +/* PCMCIA attribute space access macros */
3531 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
3532 + ASSERT(0)
3533 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
3534 + ASSERT(0)
3535 +
3536 +/* PCI configuration space access macros */
3537 +#define OSL_PCI_READ_CONFIG(loc, offset, size) \
3538 + (offset == 8 ? 0 : 0xffffffff)
3539 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) \
3540 + do {} while (0)
3541 +
3542 +/* register access macros */
3543 +#define wreg32(r, v) (*(volatile uint32*)(r) = (uint32)(v))
3544 +#define rreg32(r) (*(volatile uint32*)(r))
3545 +#define wreg16(r, v) (*(volatile uint16*)(r) = (uint16)(v))
3546 +#define rreg16(r) (*(volatile uint16*)(r))
3547 +#define wreg8(r, v) (*(volatile uint8*)(r) = (uint8)(v))
3548 +#define rreg8(r) (*(volatile uint8*)(r))
3549 +#define R_REG(r) ({ \
3550 + __typeof(*(r)) __osl_v; \
3551 + switch (sizeof(*(r))) { \
3552 + case sizeof(uint8): __osl_v = rreg8((r)); break; \
3553 + case sizeof(uint16): __osl_v = rreg16((r)); break; \
3554 + case sizeof(uint32): __osl_v = rreg32((r)); break; \
3555 + } \
3556 + __osl_v; \
3557 +})
3558 +#define W_REG(r, v) do { \
3559 + switch (sizeof(*(r))) { \
3560 + case sizeof(uint8): wreg8((r), (v)); break; \
3561 + case sizeof(uint16): wreg16((r), (v)); break; \
3562 + case sizeof(uint32): wreg32((r), (v)); break; \
3563 + } \
3564 +} while (0)
3565 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3566 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3567 +
3568 +/* general purpose memory allocation */
3569 +#define MALLOC(osh, size) malloc(size)
3570 +#define MFREE(osh, addr, size) free(addr)
3571 +#define MALLOCED(osh) 0
3572 +#define MALLOC_FAILED(osh) 0
3573 +#define MALLOC_DUMP(osh, buf, sz)
3574 +extern int free(void *ptr);
3575 +extern void *malloc(uint size);
3576 +
3577 +/* uncached virtual address */
3578 +#define OSL_UNCACHED(va) ((void*)KSEG1ADDR((ulong)(va)))
3579 +
3580 +/* host/bus architecture-specific address byte swap */
3581 +#define BUS_SWAP32(v) (v)
3582 +
3583 +/* microsecond delay */
3584 +#define OSL_DELAY(usec) udelay(usec)
3585 +extern void udelay(uint32 usec);
3586 +
3587 +/* map/unmap physical to virtual I/O */
3588 +#define REG_MAP(pa, size) ((void*)KSEG1ADDR((ulong)(pa)))
3589 +#define REG_UNMAP(va) do {} while (0)
3590 +
3591 +/* dereference an address that may cause a bus exception */
3592 +#define BUSPROBE(val, addr) (uint32 *)(addr) = (val)
3593 +
3594 +/* Misc stubs */
3595 +#define osl_attach(pdev) (pdev)
3596 +#define osl_detach(osh)
3597 +extern void *osl_init(void);
3598 +extern int getintvar(char *vars, char *name);
3599 +
3600 +#endif /* _min_osl_h_ */
3601 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/mipsinc.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/mipsinc.h
3602 --- linux-2.4.30/arch/mips/bcm947xx/include/mipsinc.h 1970-01-01 01:00:00.000000000 +0100
3603 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/mipsinc.h 2005-05-26 02:34:15.000000000 +0200
3604 @@ -0,0 +1,524 @@
3605 +/*
3606 + * HND Run Time Environment for standalone MIPS programs.
3607 + *
3608 + * Copyright 2005, Broadcom Corporation
3609 + * All Rights Reserved.
3610 + *
3611 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3612 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3613 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3614 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3615 + *
3616 + * $Id$
3617 + */
3618 +
3619 +#ifndef _MISPINC_H
3620 +#define _MISPINC_H
3621 +
3622 +
3623 +/* MIPS defines */
3624 +
3625 +#ifdef _LANGUAGE_ASSEMBLY
3626 +
3627 +/*
3628 + * Symbolic register names for 32 bit ABI
3629 + */
3630 +#define zero $0 /* wired zero */
3631 +#define AT $1 /* assembler temp - uppercase because of ".set at" */
3632 +#define v0 $2 /* return value */
3633 +#define v1 $3
3634 +#define a0 $4 /* argument registers */
3635 +#define a1 $5
3636 +#define a2 $6
3637 +#define a3 $7
3638 +#define t0 $8 /* caller saved */
3639 +#define t1 $9
3640 +#define t2 $10
3641 +#define t3 $11
3642 +#define t4 $12
3643 +#define t5 $13
3644 +#define t6 $14
3645 +#define t7 $15
3646 +#define s0 $16 /* callee saved */
3647 +#define s1 $17
3648 +#define s2 $18
3649 +#define s3 $19
3650 +#define s4 $20
3651 +#define s5 $21
3652 +#define s6 $22
3653 +#define s7 $23
3654 +#define t8 $24 /* caller saved */
3655 +#define t9 $25
3656 +#define jp $25 /* PIC jump register */
3657 +#define k0 $26 /* kernel scratch */
3658 +#define k1 $27
3659 +#define gp $28 /* global pointer */
3660 +#define sp $29 /* stack pointer */
3661 +#define fp $30 /* frame pointer */
3662 +#define s8 $30 /* same like fp! */
3663 +#define ra $31 /* return address */
3664 +
3665 +
3666 +/* *********************************************************************
3667 + * CP0 Registers
3668 + ********************************************************************* */
3669 +
3670 +#define C0_INX $0
3671 +#define C0_RAND $1
3672 +#define C0_TLBLO0 $2
3673 +#define C0_TLBLO C0_TLBLO0
3674 +#define C0_TLBLO1 $3
3675 +#define C0_CTEXT $4
3676 +#define C0_PGMASK $5
3677 +#define C0_WIRED $6
3678 +#define C0_BADVADDR $8
3679 +#define C0_COUNT $9
3680 +#define C0_TLBHI $10
3681 +#define C0_COMPARE $11
3682 +#define C0_SR $12
3683 +#define C0_STATUS C0_SR
3684 +#define C0_CAUSE $13
3685 +#define C0_EPC $14
3686 +#define C0_PRID $15
3687 +#define C0_CONFIG $16
3688 +#define C0_LLADDR $17
3689 +#define C0_WATCHLO $18
3690 +#define C0_WATCHHI $19
3691 +#define C0_XCTEXT $20
3692 +#define C0_DIAGNOSTIC $22
3693 +#define C0_BROADCOM C0_DIAGNOSTIC
3694 +#define C0_ECC $26
3695 +#define C0_CACHEERR $27
3696 +#define C0_TAGLO $28
3697 +#define C0_TAGHI $29
3698 +#define C0_ERREPC $30
3699 +#define C0_DESAVE $31
3700 +
3701 +/*
3702 + * LEAF - declare leaf routine
3703 + */
3704 +#define LEAF(symbol) \
3705 + .globl symbol; \
3706 + .align 2; \
3707 + .type symbol,@function; \
3708 + .ent symbol,0; \
3709 +symbol: .frame sp,0,ra
3710 +
3711 +/*
3712 + * END - mark end of function
3713 + */
3714 +#define END(function) \
3715 + .end function; \
3716 + .size function,.-function
3717 +
3718 +#define _ULCAST_
3719 +
3720 +#else
3721 +
3722 +/*
3723 + * The following macros are especially useful for __asm__
3724 + * inline assembler.
3725 + */
3726 +#ifndef __STR
3727 +#define __STR(x) #x
3728 +#endif
3729 +#ifndef STR
3730 +#define STR(x) __STR(x)
3731 +#endif
3732 +
3733 +#define _ULCAST_ (unsigned long)
3734 +
3735 +
3736 +/* *********************************************************************
3737 + * CP0 Registers
3738 + ********************************************************************* */
3739 +
3740 +#define C0_INX 0 /* CP0: TLB Index */
3741 +#define C0_RAND 1 /* CP0: TLB Random */
3742 +#define C0_TLBLO0 2 /* CP0: TLB EntryLo0 */
3743 +#define C0_TLBLO C0_TLBLO0 /* CP0: TLB EntryLo0 */
3744 +#define C0_TLBLO1 3 /* CP0: TLB EntryLo1 */
3745 +#define C0_CTEXT 4 /* CP0: Context */
3746 +#define C0_PGMASK 5 /* CP0: TLB PageMask */
3747 +#define C0_WIRED 6 /* CP0: TLB Wired */
3748 +#define C0_BADVADDR 8 /* CP0: Bad Virtual Address */
3749 +#define C0_COUNT 9 /* CP0: Count */
3750 +#define C0_TLBHI 10 /* CP0: TLB EntryHi */
3751 +#define C0_COMPARE 11 /* CP0: Compare */
3752 +#define C0_SR 12 /* CP0: Processor Status */
3753 +#define C0_STATUS C0_SR /* CP0: Processor Status */
3754 +#define C0_CAUSE 13 /* CP0: Exception Cause */
3755 +#define C0_EPC 14 /* CP0: Exception PC */
3756 +#define C0_PRID 15 /* CP0: Processor Revision Indentifier */
3757 +#define C0_CONFIG 16 /* CP0: Config */
3758 +#define C0_LLADDR 17 /* CP0: LLAddr */
3759 +#define C0_WATCHLO 18 /* CP0: WatchpointLo */
3760 +#define C0_WATCHHI 19 /* CP0: WatchpointHi */
3761 +#define C0_XCTEXT 20 /* CP0: XContext */
3762 +#define C0_DIAGNOSTIC 22 /* CP0: Diagnostic */
3763 +#define C0_BROADCOM C0_DIAGNOSTIC /* CP0: Broadcom Register */
3764 +#define C0_ECC 26 /* CP0: ECC */
3765 +#define C0_CACHEERR 27 /* CP0: CacheErr */
3766 +#define C0_TAGLO 28 /* CP0: TagLo */
3767 +#define C0_TAGHI 29 /* CP0: TagHi */
3768 +#define C0_ERREPC 30 /* CP0: ErrorEPC */
3769 +#define C0_DESAVE 31 /* CP0: DebugSave */
3770 +
3771 +#endif /* _LANGUAGE_ASSEMBLY */
3772 +
3773 +/*
3774 + * Memory segments (32bit kernel mode addresses)
3775 + */
3776 +#undef KUSEG
3777 +#undef KSEG0
3778 +#undef KSEG1
3779 +#undef KSEG2
3780 +#undef KSEG3
3781 +#define KUSEG 0x00000000
3782 +#define KSEG0 0x80000000
3783 +#define KSEG1 0xa0000000
3784 +#define KSEG2 0xc0000000
3785 +#define KSEG3 0xe0000000
3786 +#define PHYSADDR_MASK 0x1fffffff
3787 +
3788 +/*
3789 + * Map an address to a certain kernel segment
3790 + */
3791 +#undef PHYSADDR
3792 +#undef KSEG0ADDR
3793 +#undef KSEG1ADDR
3794 +#undef KSEG2ADDR
3795 +#undef KSEG3ADDR
3796 +
3797 +#define PHYSADDR(a) (_ULCAST_(a) & PHYSADDR_MASK)
3798 +#define KSEG0ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG0)
3799 +#define KSEG1ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG1)
3800 +#define KSEG2ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG2)
3801 +#define KSEG3ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG3)
3802 +
3803 +
3804 +#ifndef Index_Invalidate_I
3805 +/*
3806 + * Cache Operations
3807 + */
3808 +#define Index_Invalidate_I 0x00
3809 +#define Index_Writeback_Inv_D 0x01
3810 +#define Index_Invalidate_SI 0x02
3811 +#define Index_Writeback_Inv_SD 0x03
3812 +#define Index_Load_Tag_I 0x04
3813 +#define Index_Load_Tag_D 0x05
3814 +#define Index_Load_Tag_SI 0x06
3815 +#define Index_Load_Tag_SD 0x07
3816 +#define Index_Store_Tag_I 0x08
3817 +#define Index_Store_Tag_D 0x09
3818 +#define Index_Store_Tag_SI 0x0A
3819 +#define Index_Store_Tag_SD 0x0B
3820 +#define Create_Dirty_Excl_D 0x0d
3821 +#define Create_Dirty_Excl_SD 0x0f
3822 +#define Hit_Invalidate_I 0x10
3823 +#define Hit_Invalidate_D 0x11
3824 +#define Hit_Invalidate_SI 0x12
3825 +#define Hit_Invalidate_SD 0x13
3826 +#define Fill_I 0x14
3827 +#define Hit_Writeback_Inv_D 0x15
3828 + /* 0x16 is unused */
3829 +#define Hit_Writeback_Inv_SD 0x17
3830 +#define R5K_Page_Invalidate_S 0x17
3831 +#define Hit_Writeback_I 0x18
3832 +#define Hit_Writeback_D 0x19
3833 + /* 0x1a is unused */
3834 +#define Hit_Writeback_SD 0x1b
3835 + /* 0x1c is unused */
3836 + /* 0x1e is unused */
3837 +#define Hit_Set_Virtual_SI 0x1e
3838 +#define Hit_Set_Virtual_SD 0x1f
3839 +#endif
3840 +
3841 +#ifndef _LANGUAGE_ASSEMBLY
3842 +
3843 +/*
3844 + * Macros to access the system control coprocessor
3845 + */
3846 +
3847 +#define MFC0(source, sel) \
3848 +({ \
3849 + int __res; \
3850 + __asm__ __volatile__( \
3851 + ".set\tnoreorder\n\t" \
3852 + ".set\tnoat\n\t" \
3853 + ".word\t"STR(0x40010000 | ((source)<<11) | (sel))"\n\t" \
3854 + "move\t%0,$1\n\t" \
3855 + ".set\tat\n\t" \
3856 + ".set\treorder" \
3857 + :"=r" (__res) \
3858 + : \
3859 + :"$1"); \
3860 + __res; \
3861 +})
3862 +
3863 +#define MTC0(source, sel, value) \
3864 +do { \
3865 + __asm__ __volatile__( \
3866 + ".set\tnoreorder\n\t" \
3867 + ".set\tnoat\n\t" \
3868 + "move\t$1,%z0\n\t" \
3869 + ".word\t"STR(0x40810000 | ((source)<<11) | (sel))"\n\t" \
3870 + ".set\tat\n\t" \
3871 + ".set\treorder" \
3872 + : \
3873 + :"jr" (value) \
3874 + :"$1"); \
3875 +} while (0)
3876 +
3877 +#define get_c0_count() \
3878 +({ \
3879 + int __res; \
3880 + __asm__ __volatile__( \
3881 + ".set\tnoreorder\n\t" \
3882 + ".set\tnoat\n\t" \
3883 + "mfc0\t%0,$9\n\t" \
3884 + ".set\tat\n\t" \
3885 + ".set\treorder" \
3886 + :"=r" (__res)); \
3887 + __res; \
3888 +})
3889 +
3890 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize)
3891 +{
3892 + uint lsz, sets, ways;
3893 +
3894 + /* Instruction Cache Size = Associativity * Line Size * Sets Per Way */
3895 + if ((lsz = ((config1 >> 19) & 7)))
3896 + lsz = 2 << lsz;
3897 + sets = 64 << ((config1 >> 22) & 7);
3898 + ways = 1 + ((config1 >> 16) & 7);
3899 + *size = lsz * sets * ways;
3900 + *lsize = lsz;
3901 +}
3902 +
3903 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize)
3904 +{
3905 + uint lsz, sets, ways;
3906 +
3907 + /* Data Cache Size = Associativity * Line Size * Sets Per Way */
3908 + if ((lsz = ((config1 >> 10) & 7)))
3909 + lsz = 2 << lsz;
3910 + sets = 64 << ((config1 >> 13) & 7);
3911 + ways = 1 + ((config1 >> 7) & 7);
3912 + *size = lsz * sets * ways;
3913 + *lsize = lsz;
3914 +}
3915 +
3916 +#define cache_unroll(base,op) \
3917 + __asm__ __volatile__(" \
3918 + .set noreorder; \
3919 + .set mips3; \
3920 + cache %1, (%0); \
3921 + .set mips0; \
3922 + .set reorder" \
3923 + : \
3924 + : "r" (base), \
3925 + "i" (op));
3926 +
3927 +#endif /* !_LANGUAGE_ASSEMBLY */
3928 +
3929 +
3930 +/*
3931 + * R4x00 interrupt enable / cause bits
3932 + */
3933 +#undef IE_SW0
3934 +#undef IE_SW1
3935 +#undef IE_IRQ0
3936 +#undef IE_IRQ1
3937 +#undef IE_IRQ2
3938 +#undef IE_IRQ3
3939 +#undef IE_IRQ4
3940 +#undef IE_IRQ5
3941 +#define IE_SW0 (1<< 8)
3942 +#define IE_SW1 (1<< 9)
3943 +#define IE_IRQ0 (1<<10)
3944 +#define IE_IRQ1 (1<<11)
3945 +#define IE_IRQ2 (1<<12)
3946 +#define IE_IRQ3 (1<<13)
3947 +#define IE_IRQ4 (1<<14)
3948 +#define IE_IRQ5 (1<<15)
3949 +
3950 +/*
3951 + * Bitfields in the mips32 cp0 status register
3952 + */
3953 +#define ST0_IE 0x00000001
3954 +#define ST0_EXL 0x00000002
3955 +#define ST0_ERL 0x00000004
3956 +/* already defined
3957 +#define ST0_UM 0x00000010
3958 +#define ST0_SWINT0 0x00000100
3959 +#define ST0_SWINT1 0x00000200
3960 +*/
3961 +#define ST0_HWINT0 0x00000400
3962 +#define ST0_HWINT1 0x00000800
3963 +#define ST0_HWINT2 0x00001000
3964 +#define ST0_HWINT3 0x00002000
3965 +#define ST0_HWINT4 0x00004000
3966 +#define ST0_HWINT5 0x00008000
3967 +#define ST0_IM 0x0000ff00
3968 +#define ST0_NMI 0x00080000
3969 +#define ST0_SR 0x00100000
3970 +#define ST0_TS 0x00200000
3971 +#define ST0_BEV 0x00400000
3972 +#define ST0_RE 0x02000000
3973 +#define ST0_RP 0x08000000
3974 +#define ST0_CU 0xf0000000
3975 +#define ST0_CU0 0x10000000
3976 +#define ST0_CU1 0x20000000
3977 +#define ST0_CU2 0x40000000
3978 +#define ST0_CU3 0x80000000
3979 +
3980 +
3981 +/*
3982 + * Bitfields in the mips32 cp0 cause register
3983 + */
3984 +#define C_EXC 0x0000007c
3985 +#define C_EXC_SHIFT 2
3986 +#define C_INT 0x0000ff00
3987 +#define C_INT_SHIFT 8
3988 +/* already defined
3989 +#define C_SW0 0x00000100
3990 +#define C_SW1 0x00000200
3991 +#define C_IRQ0 0x00000400
3992 +#define C_IRQ1 0x00000800
3993 +#define C_IRQ2 0x00001000
3994 +#define C_IRQ3 0x00002000
3995 +#define C_IRQ4 0x00004000
3996 +#define C_IRQ5 0x00008000
3997 +*/
3998 +#define C_WP 0x00400000
3999 +#define C_IV 0x00800000
4000 +#define C_CE 0x30000000
4001 +#define C_CE_SHIFT 28
4002 +#define C_BD 0x80000000
4003 +
4004 +/* Values in C_EXC */
4005 +#define EXC_INT 0
4006 +#define EXC_TLBM 1
4007 +#define EXC_TLBL 2
4008 +#define EXC_TLBS 3
4009 +#define EXC_AEL 4
4010 +#define EXC_AES 5
4011 +#define EXC_IBE 6
4012 +#define EXC_DBE 7
4013 +#define EXC_SYS 8
4014 +#define EXC_BPT 9
4015 +#define EXC_RI 10
4016 +#define EXC_CU 11
4017 +#define EXC_OV 12
4018 +#define EXC_TR 13
4019 +#define EXC_WATCH 23
4020 +#define EXC_MCHK 24
4021 +
4022 +
4023 +/*
4024 + * Bits in the cp0 config register.
4025 + */
4026 +#define CONF_CM_CACHABLE_NO_WA 0
4027 +#define CONF_CM_CACHABLE_WA 1
4028 +#define CONF_CM_UNCACHED 2
4029 +#define CONF_CM_CACHABLE_NONCOHERENT 3
4030 +#define CONF_CM_CACHABLE_CE 4
4031 +#define CONF_CM_CACHABLE_COW 5
4032 +#define CONF_CM_CACHABLE_CUW 6
4033 +#define CONF_CM_CACHABLE_ACCELERATED 7
4034 +#define CONF_CM_CMASK 7
4035 +#define CONF_CU (_ULCAST_(1) << 3)
4036 +#define CONF_DB (_ULCAST_(1) << 4)
4037 +#define CONF_IB (_ULCAST_(1) << 5)
4038 +#define CONF_SE (_ULCAST_(1) << 12)
4039 +#define CONF_SC (_ULCAST_(1) << 17)
4040 +#define CONF_AC (_ULCAST_(1) << 23)
4041 +#define CONF_HALT (_ULCAST_(1) << 25)
4042 +
4043 +
4044 +/*
4045 + * Bits in the cp0 config register select 1.
4046 + */
4047 +#define CONF1_FP 0x00000001 /* FPU present */
4048 +#define CONF1_EP 0x00000002 /* EJTAG present */
4049 +#define CONF1_CA 0x00000004 /* mips16 implemented */
4050 +#define CONF1_WR 0x00000008 /* Watch registers present */
4051 +#define CONF1_PC 0x00000010 /* Performance counters present */
4052 +#define CONF1_DA_SHIFT 7 /* D$ associativity */
4053 +#define CONF1_DA_MASK 0x00000380
4054 +#define CONF1_DA_BASE 1
4055 +#define CONF1_DL_SHIFT 10 /* D$ line size */
4056 +#define CONF1_DL_MASK 0x00001c00
4057 +#define CONF1_DL_BASE 2
4058 +#define CONF1_DS_SHIFT 13 /* D$ sets/way */
4059 +#define CONF1_DS_MASK 0x0000e000
4060 +#define CONF1_DS_BASE 64
4061 +#define CONF1_IA_SHIFT 16 /* I$ associativity */
4062 +#define CONF1_IA_MASK 0x00070000
4063 +#define CONF1_IA_BASE 1
4064 +#define CONF1_IL_SHIFT 19 /* I$ line size */
4065 +#define CONF1_IL_MASK 0x00380000
4066 +#define CONF1_IL_BASE 2
4067 +#define CONF1_IS_SHIFT 22 /* Instruction cache sets/way */
4068 +#define CONF1_IS_MASK 0x01c00000
4069 +#define CONF1_IS_BASE 64
4070 +#define CONF1_MS_MASK 0x7e000000 /* Number of tlb entries */
4071 +#define CONF1_MS_SHIFT 25
4072 +
4073 +/* PRID register */
4074 +#define PRID_COPT_MASK 0xff000000
4075 +#define PRID_COMP_MASK 0x00ff0000
4076 +#define PRID_IMP_MASK 0x0000ff00
4077 +#define PRID_REV_MASK 0x000000ff
4078 +
4079 +#define PRID_COMP_LEGACY 0x000000
4080 +#define PRID_COMP_MIPS 0x010000
4081 +#define PRID_COMP_BROADCOM 0x020000
4082 +#define PRID_COMP_ALCHEMY 0x030000
4083 +#define PRID_COMP_SIBYTE 0x040000
4084 +#define PRID_IMP_BCM4710 0x4000
4085 +#define PRID_IMP_BCM3302 0x9000
4086 +#define PRID_IMP_BCM3303 0x9100
4087 +#define PRID_IMP_BCM3303 0x9100
4088 +
4089 +#define PRID_IMP_UNKNOWN 0xff00
4090 +
4091 +#define BCM330X(id) \
4092 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
4093 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
4094 +
4095 +/* Bits in C0_BROADCOM */
4096 +#define BRCM_PFC_AVAIL 0x20000000 /* PFC is available */
4097 +#define BRCM_DC_ENABLE 0x40000000 /* Enable Data $ */
4098 +#define BRCM_IC_ENABLE 0x80000000 /* Enable Instruction $ */
4099 +#define BRCM_PFC_ENABLE 0x00400000 /* Obsolete? Enable PFC (at least on 4310) */
4100 +
4101 +/* PreFetch Cache aka Read Ahead Cache */
4102 +
4103 +#define PFC_CR0 0xff400000 /* control reg 0 */
4104 +#define PFC_CR1 0xff400004 /* control reg 1 */
4105 +
4106 +/*
4107 + * These are the UART port assignments, expressed as offsets from the base
4108 + * register. These assignments should hold for any serial port based on
4109 + * a 8250, 16450, or 16550(A).
4110 + */
4111 +
4112 +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */
4113 +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
4114 +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
4115 +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */
4116 +#define UART_LCR 3 /* Out: Line Control Register */
4117 +#define UART_MCR 4 /* Out: Modem Control Register */
4118 +#define UART_LSR 5 /* In: Line Status Register */
4119 +#define UART_MSR 6 /* In: Modem Status Register */
4120 +#define UART_SCR 7 /* I/O: Scratch Register */
4121 +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
4122 +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
4123 +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
4124 +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
4125 +#define UART_LSR_RXRDY 0x01 /* Receiver ready */
4126 +
4127 +
4128 +#endif /* _MISPINC_H */
4129 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/nvports.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/nvports.h
4130 --- linux-2.4.30/arch/mips/bcm947xx/include/nvports.h 1970-01-01 01:00:00.000000000 +0100
4131 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/nvports.h 2005-02-02 23:41:24.000000000 +0100
4132 @@ -0,0 +1,55 @@
4133 +/*
4134 + * BCM53xx RoboSwitch utility functions
4135 + *
4136 + * Copyright (C) 2002 Broadcom Corporation
4137 + * $Id$
4138 + */
4139 +
4140 +#ifndef _nvports_h_
4141 +#define _nvports_h_
4142 +
4143 +#define uint32 unsigned long
4144 +#define uint16 unsigned short
4145 +#define uint unsigned int
4146 +#define uint8 unsigned char
4147 +#define uint64 unsigned long long
4148 +
4149 +enum FORCE_PORT {
4150 + FORCE_OFF,
4151 + FORCE_10H,
4152 + FORCE_10F,
4153 + FORCE_100H,
4154 + FORCE_100F,
4155 + FORCE_DOWN,
4156 + POWER_OFF
4157 +};
4158 +
4159 +typedef struct _PORT_ATTRIBS
4160 +{
4161 + uint autoneg;
4162 + uint force;
4163 + uint native;
4164 +} PORT_ATTRIBS;
4165 +
4166 +extern uint
4167 +nvExistsPortAttrib(char *attrib, uint portno);
4168 +
4169 +extern int
4170 +nvExistsAnyForcePortAttrib(uint portno);
4171 +
4172 +extern void
4173 +nvSetPortAttrib(char *attrib, uint portno);
4174 +
4175 +extern void
4176 +nvUnsetPortAttrib(char *attrib, uint portno);
4177 +
4178 +extern void
4179 +nvUnsetAllForcePortAttrib(uint portno);
4180 +
4181 +extern PORT_ATTRIBS
4182 +nvGetSwitchPortAttribs(uint portno);
4183 +
4184 +#endif /* _nvports_h_ */
4185 +
4186 +
4187 +
4188 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/osl.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/osl.h
4189 --- linux-2.4.30/arch/mips/bcm947xx/include/osl.h 1970-01-01 01:00:00.000000000 +0100
4190 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/osl.h 2005-02-02 23:16:39.000000000 +0100
4191 @@ -0,0 +1,39 @@
4192 +/*
4193 + * OS Independent Layer
4194 + *
4195 + * Copyright 2005, Broadcom Corporation
4196 + * All Rights Reserved.
4197 + *
4198 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4199 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4200 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4201 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4202 + * $Id$
4203 + */
4204 +
4205 +#ifndef _osl_h_
4206 +#define _osl_h_
4207 +
4208 +#if defined(linux)
4209 +#include <linux_osl.h>
4210 +#elif defined(NDIS)
4211 +#include <ndis_osl.h>
4212 +#elif defined(_CFE_)
4213 +#include <cfe_osl.h>
4214 +#elif defined(_HNDRTE_)
4215 +#include <hndrte_osl.h>
4216 +#elif defined(_MINOSL_)
4217 +#include <min_osl.h>
4218 +#elif PMON
4219 +#include <pmon_osl.h>
4220 +#elif defined(MACOSX)
4221 +#include <macosx_osl.h>
4222 +#else
4223 +#error "Unsupported OSL requested"
4224 +#endif
4225 +
4226 +/* handy */
4227 +#define SET_REG(r, mask, val) W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
4228 +#define MAXPRIO 7 /* 0-7 */
4229 +
4230 +#endif /* _osl_h_ */
4231 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/pcicfg.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/pcicfg.h
4232 --- linux-2.4.30/arch/mips/bcm947xx/include/pcicfg.h 1970-01-01 01:00:00.000000000 +0100
4233 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/pcicfg.h 2005-02-02 23:16:39.000000000 +0100
4234 @@ -0,0 +1,369 @@
4235 +/*
4236 + * pcicfg.h: PCI configuration constants and structures.
4237 + *
4238 + * Copyright 2005, Broadcom Corporation
4239 + * All Rights Reserved.
4240 + *
4241 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4242 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4243 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4244 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4245 + *
4246 + * $Id$
4247 + */
4248 +
4249 +#ifndef _h_pci_
4250 +#define _h_pci_
4251 +
4252 +/* The following inside ifndef's so we don't collide with NTDDK.H */
4253 +#ifndef PCI_MAX_BUS
4254 +#define PCI_MAX_BUS 0x100
4255 +#endif
4256 +#ifndef PCI_MAX_DEVICES
4257 +#define PCI_MAX_DEVICES 0x20
4258 +#endif
4259 +#ifndef PCI_MAX_FUNCTION
4260 +#define PCI_MAX_FUNCTION 0x8
4261 +#endif
4262 +
4263 +#ifndef PCI_INVALID_VENDORID
4264 +#define PCI_INVALID_VENDORID 0xffff
4265 +#endif
4266 +#ifndef PCI_INVALID_DEVICEID
4267 +#define PCI_INVALID_DEVICEID 0xffff
4268 +#endif
4269 +
4270 +
4271 +/* Convert between bus-slot-function-register and config addresses */
4272 +
4273 +#define PCICFG_BUS_SHIFT 16 /* Bus shift */
4274 +#define PCICFG_SLOT_SHIFT 11 /* Slot shift */
4275 +#define PCICFG_FUN_SHIFT 8 /* Function shift */
4276 +#define PCICFG_OFF_SHIFT 0 /* Bus shift */
4277 +
4278 +#define PCICFG_BUS_MASK 0xff /* Bus mask */
4279 +#define PCICFG_SLOT_MASK 0x1f /* Slot mask */
4280 +#define PCICFG_FUN_MASK 7 /* Function mask */
4281 +#define PCICFG_OFF_MASK 0xff /* Bus mask */
4282 +
4283 +#define PCI_CONFIG_ADDR(b, s, f, o) \
4284 + ((((b) & PCICFG_BUS_MASK) << PCICFG_BUS_SHIFT) \
4285 + | (((s) & PCICFG_SLOT_MASK) << PCICFG_SLOT_SHIFT) \
4286 + | (((f) & PCICFG_FUN_MASK) << PCICFG_FUN_SHIFT) \
4287 + | (((o) & PCICFG_OFF_MASK) << PCICFG_OFF_SHIFT))
4288 +
4289 +#define PCI_CONFIG_BUS(a) (((a) >> PCICFG_BUS_SHIFT) & PCICFG_BUS_MASK)
4290 +#define PCI_CONFIG_SLOT(a) (((a) >> PCICFG_SLOT_SHIFT) & PCICFG_SLOT_MASK)
4291 +#define PCI_CONFIG_FUN(a) (((a) >> PCICFG_FUN_SHIFT) & PCICFG_FUN_MASK)
4292 +#define PCI_CONFIG_OFF(a) (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK)
4293 +
4294 +
4295 +/* The actual config space */
4296 +
4297 +#define PCI_BAR_MAX 6
4298 +
4299 +#define PCI_ROM_BAR 8
4300 +
4301 +#define PCR_RSVDA_MAX 2
4302 +
4303 +typedef struct _pci_config_regs {
4304 + unsigned short vendor;
4305 + unsigned short device;
4306 + unsigned short command;
4307 + unsigned short status;
4308 + unsigned char rev_id;
4309 + unsigned char prog_if;
4310 + unsigned char sub_class;
4311 + unsigned char base_class;
4312 + unsigned char cache_line_size;
4313 + unsigned char latency_timer;
4314 + unsigned char header_type;
4315 + unsigned char bist;
4316 + unsigned long base[PCI_BAR_MAX];
4317 + unsigned long cardbus_cis;
4318 + unsigned short subsys_vendor;
4319 + unsigned short subsys_id;
4320 + unsigned long baserom;
4321 + unsigned long rsvd_a[PCR_RSVDA_MAX];
4322 + unsigned char int_line;
4323 + unsigned char int_pin;
4324 + unsigned char min_gnt;
4325 + unsigned char max_lat;
4326 + unsigned char dev_dep[192];
4327 +} pci_config_regs;
4328 +
4329 +#define SZPCR (sizeof (pci_config_regs))
4330 +#define MINSZPCR 64 /* offsetof (dev_dep[0] */
4331 +
4332 +/* A structure for the config registers is nice, but in most
4333 + * systems the config space is not memory mapped, so we need
4334 + * filed offsetts. :-(
4335 + */
4336 +#define PCI_CFG_VID 0
4337 +#define PCI_CFG_DID 2
4338 +#define PCI_CFG_CMD 4
4339 +#define PCI_CFG_STAT 6
4340 +#define PCI_CFG_REV 8
4341 +#define PCI_CFG_PROGIF 9
4342 +#define PCI_CFG_SUBCL 0xa
4343 +#define PCI_CFG_BASECL 0xb
4344 +#define PCI_CFG_CLSZ 0xc
4345 +#define PCI_CFG_LATTIM 0xd
4346 +#define PCI_CFG_HDR 0xe
4347 +#define PCI_CFG_BIST 0xf
4348 +#define PCI_CFG_BAR0 0x10
4349 +#define PCI_CFG_BAR1 0x14
4350 +#define PCI_CFG_BAR2 0x18
4351 +#define PCI_CFG_BAR3 0x1c
4352 +#define PCI_CFG_BAR4 0x20
4353 +#define PCI_CFG_BAR5 0x24
4354 +#define PCI_CFG_CIS 0x28
4355 +#define PCI_CFG_SVID 0x2c
4356 +#define PCI_CFG_SSID 0x2e
4357 +#define PCI_CFG_ROMBAR 0x30
4358 +#define PCI_CFG_INT 0x3c
4359 +#define PCI_CFG_PIN 0x3d
4360 +#define PCI_CFG_MINGNT 0x3e
4361 +#define PCI_CFG_MAXLAT 0x3f
4362 +
4363 +/* Classes and subclasses */
4364 +
4365 +typedef enum {
4366 + PCI_CLASS_OLD = 0,
4367 + PCI_CLASS_DASDI,
4368 + PCI_CLASS_NET,
4369 + PCI_CLASS_DISPLAY,
4370 + PCI_CLASS_MMEDIA,
4371 + PCI_CLASS_MEMORY,
4372 + PCI_CLASS_BRIDGE,
4373 + PCI_CLASS_COMM,
4374 + PCI_CLASS_BASE,
4375 + PCI_CLASS_INPUT,
4376 + PCI_CLASS_DOCK,
4377 + PCI_CLASS_CPU,
4378 + PCI_CLASS_SERIAL,
4379 + PCI_CLASS_INTELLIGENT = 0xe,
4380 + PCI_CLASS_SATELLITE,
4381 + PCI_CLASS_CRYPT,
4382 + PCI_CLASS_DSP,
4383 + PCI_CLASS_MAX
4384 +} pci_classes;
4385 +
4386 +typedef enum {
4387 + PCI_DASDI_SCSI,
4388 + PCI_DASDI_IDE,
4389 + PCI_DASDI_FLOPPY,
4390 + PCI_DASDI_IPI,
4391 + PCI_DASDI_RAID,
4392 + PCI_DASDI_OTHER = 0x80
4393 +} pci_dasdi_subclasses;
4394 +
4395 +typedef enum {
4396 + PCI_NET_ETHER,
4397 + PCI_NET_TOKEN,
4398 + PCI_NET_FDDI,
4399 + PCI_NET_ATM,
4400 + PCI_NET_OTHER = 0x80
4401 +} pci_net_subclasses;
4402 +
4403 +typedef enum {
4404 + PCI_DISPLAY_VGA,
4405 + PCI_DISPLAY_XGA,
4406 + PCI_DISPLAY_3D,
4407 + PCI_DISPLAY_OTHER = 0x80
4408 +} pci_display_subclasses;
4409 +
4410 +typedef enum {
4411 + PCI_MMEDIA_VIDEO,
4412 + PCI_MMEDIA_AUDIO,
4413 + PCI_MMEDIA_PHONE,
4414 + PCI_MEDIA_OTHER = 0x80
4415 +} pci_mmedia_subclasses;
4416 +
4417 +typedef enum {
4418 + PCI_MEMORY_RAM,
4419 + PCI_MEMORY_FLASH,
4420 + PCI_MEMORY_OTHER = 0x80
4421 +} pci_memory_subclasses;
4422 +
4423 +typedef enum {
4424 + PCI_BRIDGE_HOST,
4425 + PCI_BRIDGE_ISA,
4426 + PCI_BRIDGE_EISA,
4427 + PCI_BRIDGE_MC,
4428 + PCI_BRIDGE_PCI,
4429 + PCI_BRIDGE_PCMCIA,
4430 + PCI_BRIDGE_NUBUS,
4431 + PCI_BRIDGE_CARDBUS,
4432 + PCI_BRIDGE_RACEWAY,
4433 + PCI_BRIDGE_OTHER = 0x80
4434 +} pci_bridge_subclasses;
4435 +
4436 +typedef enum {
4437 + PCI_COMM_UART,
4438 + PCI_COMM_PARALLEL,
4439 + PCI_COMM_MULTIUART,
4440 + PCI_COMM_MODEM,
4441 + PCI_COMM_OTHER = 0x80
4442 +} pci_comm_subclasses;
4443 +
4444 +typedef enum {
4445 + PCI_BASE_PIC,
4446 + PCI_BASE_DMA,
4447 + PCI_BASE_TIMER,
4448 + PCI_BASE_RTC,
4449 + PCI_BASE_PCI_HOTPLUG,
4450 + PCI_BASE_OTHER = 0x80
4451 +} pci_base_subclasses;
4452 +
4453 +typedef enum {
4454 + PCI_INPUT_KBD,
4455 + PCI_INPUT_PEN,
4456 + PCI_INPUT_MOUSE,
4457 + PCI_INPUT_SCANNER,
4458 + PCI_INPUT_GAMEPORT,
4459 + PCI_INPUT_OTHER = 0x80
4460 +} pci_input_subclasses;
4461 +
4462 +typedef enum {
4463 + PCI_DOCK_GENERIC,
4464 + PCI_DOCK_OTHER = 0x80
4465 +} pci_dock_subclasses;
4466 +
4467 +typedef enum {
4468 + PCI_CPU_386,
4469 + PCI_CPU_486,
4470 + PCI_CPU_PENTIUM,
4471 + PCI_CPU_ALPHA = 0x10,
4472 + PCI_CPU_POWERPC = 0x20,
4473 + PCI_CPU_MIPS = 0x30,
4474 + PCI_CPU_COPROC = 0x40,
4475 + PCI_CPU_OTHER = 0x80
4476 +} pci_cpu_subclasses;
4477 +
4478 +typedef enum {
4479 + PCI_SERIAL_IEEE1394,
4480 + PCI_SERIAL_ACCESS,
4481 + PCI_SERIAL_SSA,
4482 + PCI_SERIAL_USB,
4483 + PCI_SERIAL_FIBER,
4484 + PCI_SERIAL_SMBUS,
4485 + PCI_SERIAL_OTHER = 0x80
4486 +} pci_serial_subclasses;
4487 +
4488 +typedef enum {
4489 + PCI_INTELLIGENT_I2O,
4490 +} pci_intelligent_subclasses;
4491 +
4492 +typedef enum {
4493 + PCI_SATELLITE_TV,
4494 + PCI_SATELLITE_AUDIO,
4495 + PCI_SATELLITE_VOICE,
4496 + PCI_SATELLITE_DATA,
4497 + PCI_SATELLITE_OTHER = 0x80
4498 +} pci_satellite_subclasses;
4499 +
4500 +typedef enum {
4501 + PCI_CRYPT_NETWORK,
4502 + PCI_CRYPT_ENTERTAINMENT,
4503 + PCI_CRYPT_OTHER = 0x80
4504 +} pci_crypt_subclasses;
4505 +
4506 +typedef enum {
4507 + PCI_DSP_DPIO,
4508 + PCI_DSP_OTHER = 0x80
4509 +} pci_dsp_subclasses;
4510 +
4511 +/* Header types */
4512 +typedef enum {
4513 + PCI_HEADER_NORMAL,
4514 + PCI_HEADER_BRIDGE,
4515 + PCI_HEADER_CARDBUS
4516 +} pci_header_types;
4517 +
4518 +
4519 +/* Overlay for a PCI-to-PCI bridge */
4520 +
4521 +#define PPB_RSVDA_MAX 2
4522 +#define PPB_RSVDD_MAX 8
4523 +
4524 +typedef struct _ppb_config_regs {
4525 + unsigned short vendor;
4526 + unsigned short device;
4527 + unsigned short command;
4528 + unsigned short status;
4529 + unsigned char rev_id;
4530 + unsigned char prog_if;
4531 + unsigned char sub_class;
4532 + unsigned char base_class;
4533 + unsigned char cache_line_size;
4534 + unsigned char latency_timer;
4535 + unsigned char header_type;
4536 + unsigned char bist;
4537 + unsigned long rsvd_a[PPB_RSVDA_MAX];
4538 + unsigned char prim_bus;
4539 + unsigned char sec_bus;
4540 + unsigned char sub_bus;
4541 + unsigned char sec_lat;
4542 + unsigned char io_base;
4543 + unsigned char io_lim;
4544 + unsigned short sec_status;
4545 + unsigned short mem_base;
4546 + unsigned short mem_lim;
4547 + unsigned short pf_mem_base;
4548 + unsigned short pf_mem_lim;
4549 + unsigned long pf_mem_base_hi;
4550 + unsigned long pf_mem_lim_hi;
4551 + unsigned short io_base_hi;
4552 + unsigned short io_lim_hi;
4553 + unsigned short subsys_vendor;
4554 + unsigned short subsys_id;
4555 + unsigned long rsvd_b;
4556 + unsigned char rsvd_c;
4557 + unsigned char int_pin;
4558 + unsigned short bridge_ctrl;
4559 + unsigned char chip_ctrl;
4560 + unsigned char diag_ctrl;
4561 + unsigned short arb_ctrl;
4562 + unsigned long rsvd_d[PPB_RSVDD_MAX];
4563 + unsigned char dev_dep[192];
4564 +} ppb_config_regs;
4565 +
4566 +/* Eveything below is BRCM HND proprietary */
4567 +
4568 +#define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */
4569 +#define PCI_BAR1_WIN 0x84 /* backplane addres space accessed by BAR1 */
4570 +#define PCI_SPROM_CONTROL 0x88 /* sprom property control */
4571 +#define PCI_BAR1_CONTROL 0x8c /* BAR1 region burst control */
4572 +#define PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */
4573 +#define PCI_INT_MASK 0x94 /* mask of PCI and other cores interrupts */
4574 +#define PCI_TO_SB_MB 0x98 /* signal backplane interrupts */
4575 +#define PCI_BACKPLANE_ADDR 0xA0 /* address an arbitrary location on the system backplane */
4576 +#define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address register */
4577 +#define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */
4578 +#define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */
4579 +#define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */
4580 +
4581 +#define PCI_BAR0_SPROM_OFFSET (4 * 1024) /* bar0 + 4K accesses external sprom */
4582 +#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) /* bar0 + 6K accesses pci core registers */
4583 +
4584 +/* PCI_INT_STATUS */
4585 +#define PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */
4586 +
4587 +/* PCI_INT_MASK */
4588 +#define PCI_SBIM_SHIFT 8 /* backplane core interrupt mask bits offset */
4589 +#define PCI_SBIM_MASK 0xff00 /* backplane core interrupt mask */
4590 +#define PCI_SBIM_MASK_SERR 0x4 /* backplane SBErr interrupt mask */
4591 +
4592 +/* PCI_SPROM_CONTROL */
4593 +#define SPROM_BLANK 0x04 /* indicating a blank sprom */
4594 +#define SPROM_WRITEEN 0x10 /* sprom write enable */
4595 +#define SPROM_BOOTROM_WE 0x20 /* external bootrom write enable */
4596 +
4597 +#define SPROM_SIZE 256 /* sprom size in 16-bit */
4598 +#define SPROM_CRC_RANGE 64 /* crc cover range in 16-bit */
4599 +
4600 +/* PCI_CFG_CMD_STAT */
4601 +#define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */
4602 +
4603 +#endif
4604 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/pmon_osl.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/pmon_osl.h
4605 --- linux-2.4.30/arch/mips/bcm947xx/include/pmon_osl.h 1970-01-01 01:00:00.000000000 +0100
4606 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/pmon_osl.h 2005-02-02 23:16:39.000000000 +0100
4607 @@ -0,0 +1,126 @@
4608 +/*
4609 + * MIPS PMON boot loader OS Abstraction Layer.
4610 + *
4611 + * Copyright 2005, Broadcom Corporation
4612 + * All Rights Reserved.
4613 + *
4614 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
4615 + * the contents of this file may not be disclosed to third parties, copied
4616 + * or duplicated in any form, in whole or in part, without the prior
4617 + * written permission of Broadcom Corporation.
4618 + * $Id$
4619 + */
4620 +
4621 +#ifndef _pmon_osl_h_
4622 +#define _pmon_osl_h_
4623 +
4624 +#include <typedefs.h>
4625 +#include <mips.h>
4626 +#include <string.h>
4627 +#include <utypes.h>
4628 +
4629 +extern int printf(char *fmt,...);
4630 +extern int sprintf(char *dst,char *fmt,...);
4631 +
4632 +#define OSL_UNCACHED(va) phy2k1(log2phy((va)))
4633 +#define REG_MAP(pa, size) phy2k1((pa))
4634 +#define REG_UNMAP(va) /* nop */
4635 +
4636 +/* Common macros */
4637 +
4638 +#define BUSPROBE(val, addr) ((val) = *(addr))
4639 +
4640 +#define ASSERT(exp)
4641 +
4642 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) bzero(buf, size)
4643 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size)
4644 +
4645 +/* kludge */
4646 +#define OSL_PCI_READ_CONFIG(loc, offset, size) ((offset == 8)? 0: 0xffffffff)
4647 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) ASSERT(0)
4648 +
4649 +#define wreg32(r,v) (*(volatile uint32 *)(r) = (v))
4650 +#define rreg32(r) (*(volatile uint32 *)(r))
4651 +#ifdef IL_BIGENDIAN
4652 +#define wreg16(r,v) (*(volatile uint16 *)((uint32)r^2) = (v))
4653 +#define rreg16(r) (*(volatile uint16 *)((uint32)r^2))
4654 +#else
4655 +#define wreg16(r,v) (*(volatile uint16 *)(r) = (v))
4656 +#define rreg16(r) (*(volatile uint16 *)(r))
4657 +#endif
4658 +
4659 +#include <memory.h>
4660 +#define bcopy(src, dst, len) memcpy(dst, src, len)
4661 +#define bcmp(b1, b2, len) memcmp(b1, b2, len)
4662 +#define bzero(b, len) memset(b, '\0', len)
4663 +
4664 +/* register access macros */
4665 +#define R_REG(r) ((sizeof *(r) == sizeof (uint32))? rreg32(r): rreg16(r))
4666 +#define W_REG(r,v) ((sizeof *(r) == sizeof (uint32))? wreg32(r,(uint32)v): wreg16(r,(uint16)v))
4667 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
4668 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
4669 +
4670 +#define R_SM(r) *(r)
4671 +#define W_SM(r, v) (*(r) = (v))
4672 +#define BZERO_SM(r, len) memset(r, '\0', len)
4673 +
4674 +/* Host/Bus architecture specific swap. Noop for little endian systems, possible swap on big endian */
4675 +#define BUS_SWAP32(v) (v)
4676 +
4677 +#define OSL_DELAY(usec) delay_us(usec)
4678 +extern void delay_us(uint usec);
4679 +
4680 +#define OSL_GETCYCLES(x) ((x) = 0)
4681 +
4682 +#define osl_attach(pdev) (pdev)
4683 +#define osl_detach(osh)
4684 +
4685 +#define MALLOC(osh, size) malloc(size)
4686 +#define MFREE(osh, addr, size) free(addr)
4687 +#define MALLOCED(osh) (0)
4688 +#define MALLOC_DUMP(osh, buf, sz)
4689 +#define MALLOC_FAILED(osh)
4690 +extern void *malloc();
4691 +extern void free(void *addr);
4692 +
4693 +#define DMA_CONSISTENT_ALIGN sizeof (int)
4694 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) et_dma_alloc_consistent(osh, size, pap)
4695 +#define DMA_FREE_CONSISTENT(osh, va, size, pa)
4696 +extern void* et_dma_alloc_consistent(void *osh, uint size, ulong *pap);
4697 +#define DMA_TX 0
4698 +#define DMA_RX 1
4699 +
4700 +#define DMA_MAP(osh, va, size, direction, p) osl_dma_map(osh, (void*)va, size, direction)
4701 +#define DMA_UNMAP(osh, pa, size, direction, p) /* nop */
4702 +extern void* osl_dma_map(void *osh, void *va, uint size, uint direction);
4703 +
4704 +struct lbuf {
4705 + struct lbuf *next; /* pointer to next lbuf on freelist */
4706 + uchar *buf; /* pointer to buffer */
4707 + uint len; /* nbytes of data */
4708 +};
4709 +
4710 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
4711 +#define PKTBUFSZ 2048
4712 +
4713 +/* packet primitives */
4714 +#define PKTGET(drv, len, send) et_pktget(drv, len, send)
4715 +#define PKTFREE(drv, lb, send) et_pktfree(drv, (struct lbuf*)lb, send)
4716 +#define PKTDATA(drv, lb) ((uchar*)OSL_UNCACHED(((struct lbuf*)lb)->buf))
4717 +#define PKTLEN(drv, lb) ((struct lbuf*)lb)->len
4718 +#define PKTHEADROOM(drv, lb) (0)
4719 +#define PKTTAILROOM(drv, lb) (0)
4720 +#define PKTNEXT(drv, lb) NULL
4721 +#define PKTSETNEXT(lb, x) ASSERT(0)
4722 +#define PKTSETLEN(drv, lb, bytes) ((struct lbuf*)lb)->len = bytes
4723 +#define PKTPUSH(drv, lb, bytes) ASSERT(0)
4724 +#define PKTPULL(drv, lb, bytes) ASSERT(0)
4725 +#define PKTDUP(drv, lb) ASSERT(0)
4726 +#define PKTLINK(lb) ((struct lbuf*)lb)->next
4727 +#define PKTSETLINK(lb, x) ((struct lbuf*)lb)->next = (struct lbuf*)x
4728 +#define PKTPRIO(lb) (0)
4729 +#define PKTSETPRIO(lb, x) do {} while (0)
4730 +extern void *et_pktget(void *drv, uint len, bool send);
4731 +extern void et_pktfree(void *drv, struct lbuf *lb, bool send);
4732 +
4733 +#endif /* _pmon_osl_h_ */
4734 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/proto/802.11.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/802.11.h
4735 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/802.11.h 1970-01-01 01:00:00.000000000 +0100
4736 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/802.11.h 2005-02-02 23:16:40.000000000 +0100
4737 @@ -0,0 +1,897 @@
4738 +/*
4739 + * Copyright 2005, Broadcom Corporation
4740 + * All Rights Reserved.
4741 + *
4742 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4743 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4744 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4745 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4746 + *
4747 + * Fundamental types and constants relating to 802.11
4748 + *
4749 + * $Id$
4750 + */
4751 +
4752 +#ifndef _802_11_H_
4753 +#define _802_11_H_
4754 +
4755 +#ifndef _TYPEDEFS_H_
4756 +#include <typedefs.h>
4757 +#endif
4758 +
4759 +#ifndef _NET_ETHERNET_H_
4760 +#include <proto/ethernet.h>
4761 +#endif
4762 +
4763 +#include <proto/wpa.h>
4764 +
4765 +
4766 +/* enable structure packing */
4767 +#if defined(__GNUC__)
4768 +#define PACKED __attribute__((packed))
4769 +#else
4770 +#pragma pack(1)
4771 +#define PACKED
4772 +#endif
4773 +
4774 +#define DOT11_TU_TO_US 1024 /* 802.11 Time Unit is 1024 microseconds */
4775 +
4776 +/* Generic 802.11 frame constants */
4777 +#define DOT11_A3_HDR_LEN 24
4778 +#define DOT11_A4_HDR_LEN 30
4779 +#define DOT11_MAC_HDR_LEN DOT11_A3_HDR_LEN
4780 +#define DOT11_FCS_LEN 4
4781 +#define DOT11_ICV_LEN 4
4782 +#define DOT11_ICV_AES_LEN 8
4783 +#define DOT11_QOS_LEN 2
4784 +
4785 +#define DOT11_KEY_INDEX_SHIFT 6
4786 +#define DOT11_IV_LEN 4
4787 +#define DOT11_IV_TKIP_LEN 8
4788 +#define DOT11_IV_AES_OCB_LEN 4
4789 +#define DOT11_IV_AES_CCM_LEN 8
4790 +
4791 +/* Includes MIC */
4792 +#define DOT11_MAX_MPDU_BODY_LEN 2304
4793 +/* A4 header + QoS + CCMP + PDU + ICV + FCS = 2352 */
4794 +#define DOT11_MAX_MPDU_LEN (DOT11_A4_HDR_LEN + \
4795 + DOT11_QOS_LEN + \
4796 + DOT11_IV_AES_CCM_LEN + \
4797 + DOT11_MAX_MPDU_BODY_LEN + \
4798 + DOT11_ICV_LEN + \
4799 + DOT11_FCS_LEN)
4800 +
4801 +#define DOT11_MAX_SSID_LEN 32
4802 +
4803 +/* dot11RTSThreshold */
4804 +#define DOT11_DEFAULT_RTS_LEN 2347
4805 +#define DOT11_MAX_RTS_LEN 2347
4806 +
4807 +/* dot11FragmentationThreshold */
4808 +#define DOT11_MIN_FRAG_LEN 256
4809 +#define DOT11_MAX_FRAG_LEN 2346 /* Max frag is also limited by aMPDUMaxLength of the attached PHY */
4810 +#define DOT11_DEFAULT_FRAG_LEN 2346
4811 +
4812 +/* dot11BeaconPeriod */
4813 +#define DOT11_MIN_BEACON_PERIOD 1
4814 +#define DOT11_MAX_BEACON_PERIOD 0xFFFF
4815 +
4816 +/* dot11DTIMPeriod */
4817 +#define DOT11_MIN_DTIM_PERIOD 1
4818 +#define DOT11_MAX_DTIM_PERIOD 0xFF
4819 +
4820 +/* 802.2 LLC/SNAP header used by 802.11 per 802.1H */
4821 +#define DOT11_LLC_SNAP_HDR_LEN 8
4822 +#define DOT11_OUI_LEN 3
4823 +struct dot11_llc_snap_header {
4824 + uint8 dsap; /* always 0xAA */
4825 + uint8 ssap; /* always 0xAA */
4826 + uint8 ctl; /* always 0x03 */
4827 + uint8 oui[DOT11_OUI_LEN]; /* RFC1042: 0x00 0x00 0x00
4828 + Bridge-Tunnel: 0x00 0x00 0xF8 */
4829 + uint16 type; /* ethertype */
4830 +} PACKED;
4831 +
4832 +/* RFC1042 header used by 802.11 per 802.1H */
4833 +#define RFC1042_HDR_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN)
4834 +
4835 +/* Generic 802.11 MAC header */
4836 +/*
4837 + * N.B.: This struct reflects the full 4 address 802.11 MAC header.
4838 + * The fields are defined such that the shorter 1, 2, and 3
4839 + * address headers just use the first k fields.
4840 + */
4841 +struct dot11_header {
4842 + uint16 fc; /* frame control */
4843 + uint16 durid; /* duration/ID */
4844 + struct ether_addr a1; /* address 1 */
4845 + struct ether_addr a2; /* address 2 */
4846 + struct ether_addr a3; /* address 3 */
4847 + uint16 seq; /* sequence control */
4848 + struct ether_addr a4; /* address 4 */
4849 +} PACKED;
4850 +
4851 +/* Control frames */
4852 +
4853 +struct dot11_rts_frame {
4854 + uint16 fc; /* frame control */
4855 + uint16 durid; /* duration/ID */
4856 + struct ether_addr ra; /* receiver address */
4857 + struct ether_addr ta; /* transmitter address */
4858 +} PACKED;
4859 +#define DOT11_RTS_LEN 16
4860 +
4861 +struct dot11_cts_frame {
4862 + uint16 fc; /* frame control */
4863 + uint16 durid; /* duration/ID */
4864 + struct ether_addr ra; /* receiver address */
4865 +} PACKED;
4866 +#define DOT11_CTS_LEN 10
4867 +
4868 +struct dot11_ack_frame {
4869 + uint16 fc; /* frame control */
4870 + uint16 durid; /* duration/ID */
4871 + struct ether_addr ra; /* receiver address */
4872 +} PACKED;
4873 +#define DOT11_ACK_LEN 10
4874 +
4875 +struct dot11_ps_poll_frame {
4876 + uint16 fc; /* frame control */
4877 + uint16 durid; /* AID */
4878 + struct ether_addr bssid; /* receiver address, STA in AP */
4879 + struct ether_addr ta; /* transmitter address */
4880 +} PACKED;
4881 +#define DOT11_PS_POLL_LEN 16
4882 +
4883 +struct dot11_cf_end_frame {
4884 + uint16 fc; /* frame control */
4885 + uint16 durid; /* duration/ID */
4886 + struct ether_addr ra; /* receiver address */
4887 + struct ether_addr bssid; /* transmitter address, STA in AP */
4888 +} PACKED;
4889 +#define DOT11_CS_END_LEN 16
4890 +
4891 +/* Management frame header */
4892 +struct dot11_management_header {
4893 + uint16 fc; /* frame control */
4894 + uint16 durid; /* duration/ID */
4895 + struct ether_addr da; /* receiver address */
4896 + struct ether_addr sa; /* transmitter address */
4897 + struct ether_addr bssid; /* BSS ID */
4898 + uint16 seq; /* sequence control */
4899 +} PACKED;
4900 +#define DOT11_MGMT_HDR_LEN 24
4901 +
4902 +/* Management frame payloads */
4903 +
4904 +struct dot11_bcn_prb {
4905 + uint32 timestamp[2];
4906 + uint16 beacon_interval;
4907 + uint16 capability;
4908 +} PACKED;
4909 +#define DOT11_BCN_PRB_LEN 12
4910 +
4911 +struct dot11_auth {
4912 + uint16 alg; /* algorithm */
4913 + uint16 seq; /* sequence control */
4914 + uint16 status; /* status code */
4915 +} PACKED;
4916 +#define DOT11_AUTH_FIXED_LEN 6 /* length of auth frame without challenge info elt */
4917 +
4918 +struct dot11_assoc_req {
4919 + uint16 capability; /* capability information */
4920 + uint16 listen; /* listen interval */
4921 +} PACKED;
4922 +
4923 +struct dot11_assoc_resp {
4924 + uint16 capability; /* capability information */
4925 + uint16 status; /* status code */
4926 + uint16 aid; /* association ID */
4927 +} PACKED;
4928 +
4929 +struct dot11_action_measure {
4930 + uint8 category;
4931 + uint8 action;
4932 + uint8 token;
4933 + uint8 data[1];
4934 +} PACKED;
4935 +#define DOT11_ACTION_MEASURE_LEN 3
4936 +
4937 +/**************
4938 + 802.11h related definitions.
4939 +**************/
4940 +typedef struct {
4941 + uint8 id;
4942 + uint8 len;
4943 + uint8 power;
4944 +} dot11_power_cnst_t;
4945 +
4946 +typedef struct {
4947 + uint8 min;
4948 + uint8 max;
4949 +} dot11_power_cap_t;
4950 +
4951 +typedef struct {
4952 + uint8 id;
4953 + uint8 len;
4954 + uint8 tx_pwr;
4955 + uint8 margin;
4956 +} dot11_tpc_rep_t;
4957 +#define DOT11_MNG_IE_TPC_REPORT_LEN 2 /* length of IE data, not including 2 byte header */
4958 +
4959 +typedef struct {
4960 + uint8 id;
4961 + uint8 len;
4962 + uint8 first_channel;
4963 + uint8 num_channels;
4964 +} dot11_supp_channels_t;
4965 +
4966 +struct dot11_channel_switch {
4967 + uint8 id;
4968 + uint8 len;
4969 + uint8 mode;
4970 + uint8 channel;
4971 + uint8 count;
4972 +} PACKED;
4973 +typedef struct dot11_channel_switch dot11_channel_switch_t;
4974 +
4975 +/* 802.11h Measurement Request/Report IEs */
4976 +/* Measurement Type field */
4977 +#define DOT11_MEASURE_TYPE_BASIC 0
4978 +#define DOT11_MEASURE_TYPE_CCA 1
4979 +#define DOT11_MEASURE_TYPE_RPI 2
4980 +
4981 +/* Measurement Mode field */
4982 +
4983 +/* Measurement Request Modes */
4984 +#define DOT11_MEASURE_MODE_ENABLE (1<<1)
4985 +#define DOT11_MEASURE_MODE_REQUEST (1<<2)
4986 +#define DOT11_MEASURE_MODE_REPORT (1<<3)
4987 +/* Measurement Report Modes */
4988 +#define DOT11_MEASURE_MODE_LATE (1<<0)
4989 +#define DOT11_MEASURE_MODE_INCAPABLE (1<<1)
4990 +#define DOT11_MEASURE_MODE_REFUSED (1<<2)
4991 +/* Basic Measurement Map bits */
4992 +#define DOT11_MEASURE_BASIC_MAP_BSS ((uint8)(1<<0))
4993 +#define DOT11_MEASURE_BASIC_MAP_OFDM ((uint8)(1<<1))
4994 +#define DOT11_MEASURE_BASIC_MAP_UKNOWN ((uint8)(1<<2))
4995 +#define DOT11_MEASURE_BASIC_MAP_RADAR ((uint8)(1<<3))
4996 +#define DOT11_MEASURE_BASIC_MAP_UNMEAS ((uint8)(1<<4))
4997 +
4998 +typedef struct {
4999 + uint8 id;
5000 + uint8 len;
5001 + uint8 token;
5002 + uint8 mode;
5003 + uint8 type;
5004 + uint8 channel;
5005 + uint8 start_time[8];
5006 + uint16 duration;
5007 +} dot11_meas_req_t;
5008 +#define DOT11_MNG_IE_MREQ_LEN 14
5009 +/* length of Measure Request IE data not including variable len */
5010 +#define DOT11_MNG_IE_MREQ_FIXED_LEN 3
5011 +
5012 +struct dot11_meas_rep {
5013 + uint8 id;
5014 + uint8 len;
5015 + uint8 token;
5016 + uint8 mode;
5017 + uint8 type;
5018 + union
5019 + {
5020 + struct {
5021 + uint8 channel;
5022 + uint8 start_time[8];
5023 + uint16 duration;
5024 + uint8 map;
5025 + } PACKED basic;
5026 + uint8 data[1];
5027 + } PACKED rep;
5028 +} PACKED;
5029 +typedef struct dot11_meas_rep dot11_meas_rep_t;
5030 +
5031 +/* length of Measure Report IE data not including variable len */
5032 +#define DOT11_MNG_IE_MREP_FIXED_LEN 3
5033 +
5034 +struct dot11_meas_rep_basic {
5035 + uint8 channel;
5036 + uint8 start_time[8];
5037 + uint16 duration;
5038 + uint8 map;
5039 +} PACKED;
5040 +typedef struct dot11_meas_rep_basic dot11_meas_rep_basic_t;
5041 +#define DOT11_MEASURE_BASIC_REP_LEN 12
5042 +
5043 +struct dot11_quiet {
5044 + uint8 id;
5045 + uint8 len;
5046 + uint8 count; /* TBTTs until beacon interval in quiet starts */
5047 + uint8 period; /* Beacon intervals between periodic quiet periods ? */
5048 + uint16 duration;/* Length of quiet period, in TU's */
5049 + uint16 offset; /* TU's offset from TBTT in Count field */
5050 +} PACKED;
5051 +typedef struct dot11_quiet dot11_quiet_t;
5052 +
5053 +typedef struct {
5054 + uint8 channel;
5055 + uint8 map;
5056 +} chan_map_tuple_t;
5057 +
5058 +typedef struct {
5059 + uint8 id;
5060 + uint8 len;
5061 + uint8 eaddr[ETHER_ADDR_LEN];
5062 + uint8 interval;
5063 + chan_map_tuple_t map[1];
5064 +} dot11_ibss_dfs_t;
5065 +
5066 +/* WME Elements */
5067 +#define WME_OUI "\x00\x50\xf2"
5068 +#define WME_VER 1
5069 +#define WME_TYPE 2
5070 +#define WME_SUBTYPE_IE 0 /* Information Element */
5071 +#define WME_SUBTYPE_PARAM_IE 1 /* Parameter Element */
5072 +#define WME_SUBTYPE_TSPEC 2 /* Traffic Specification */
5073 +
5074 +/* WME Access Category Indices (ACIs) */
5075 +#define AC_BE 0 /* Best Effort */
5076 +#define AC_BK 1 /* Background */
5077 +#define AC_VI 2 /* Video */
5078 +#define AC_VO 3 /* Voice */
5079 +#define AC_MAX 4
5080 +
5081 +/* WME Information Element (IE) */
5082 +struct wme_ie {
5083 + uint8 oui[3];
5084 + uint8 type;
5085 + uint8 subtype;
5086 + uint8 version;
5087 + uint8 acinfo;
5088 +} PACKED;
5089 +typedef struct wme_ie wme_ie_t;
5090 +#define WME_IE_LEN 7
5091 +
5092 +struct wme_acparam {
5093 + uint8 ACI;
5094 + uint8 ECW;
5095 + uint16 TXOP; /* stored in network order (ls octet first) */
5096 +} PACKED;
5097 +typedef struct wme_acparam wme_acparam_t;
5098 +
5099 +/* WME Parameter Element (PE) */
5100 +struct wme_params {
5101 + uint8 oui[3];
5102 + uint8 type;
5103 + uint8 subtype;
5104 + uint8 version;
5105 + uint8 acinfo;
5106 + uint8 rsvd;
5107 + wme_acparam_t acparam[4];
5108 +} PACKED;
5109 +typedef struct wme_params wme_params_t;
5110 +#define WME_PARAMS_IE_LEN 24
5111 +
5112 +/* acinfo */
5113 +#define WME_COUNT_MASK 0x0f
5114 +/* ACI */
5115 +#define WME_AIFS_MASK 0x0f
5116 +#define WME_ACM_MASK 0x10
5117 +#define WME_ACI_MASK 0x60
5118 +#define WME_ACI_SHIFT 5
5119 +/* ECW */
5120 +#define WME_CWMIN_MASK 0x0f
5121 +#define WME_CWMAX_MASK 0xf0
5122 +#define WME_CWMAX_SHIFT 4
5123 +
5124 +#define WME_TXOP_UNITS 32
5125 +
5126 +/* AP: default params to be announced in the Beacon Frames/Probe Responses Table 12 WME Draft*/
5127 +/* AP: default params to be Used in the AP Side Table 14 WME Draft January 2004 802.11-03-504r5 */
5128 +#define WME_AC_BK_ACI_STA 0x27
5129 +#define WME_AC_BK_ECW_STA 0xA4
5130 +#define WME_AC_BK_TXOP_STA 0x0000
5131 +#define WME_AC_BE_ACI_STA 0x03
5132 +#define WME_AC_BE_ECW_STA 0xA4
5133 +#define WME_AC_BE_TXOP_STA 0x0000
5134 +#define WME_AC_VI_ACI_STA 0x42
5135 +#define WME_AC_VI_ECW_STA 0x43
5136 +#define WME_AC_VI_TXOP_STA 0x005e
5137 +#define WME_AC_VO_ACI_STA 0x62
5138 +#define WME_AC_VO_ECW_STA 0x32
5139 +#define WME_AC_VO_TXOP_STA 0x002f
5140 +
5141 +#define WME_AC_BK_ACI_AP 0x27
5142 +#define WME_AC_BK_ECW_AP 0xA4
5143 +#define WME_AC_BK_TXOP_AP 0x0000
5144 +#define WME_AC_BE_ACI_AP 0x03
5145 +#define WME_AC_BE_ECW_AP 0x64
5146 +#define WME_AC_BE_TXOP_AP 0x0000
5147 +#define WME_AC_VI_ACI_AP 0x41
5148 +#define WME_AC_VI_ECW_AP 0x43
5149 +#define WME_AC_VI_TXOP_AP 0x005e
5150 +#define WME_AC_VO_ACI_AP 0x61
5151 +#define WME_AC_VO_ECW_AP 0x32
5152 +#define WME_AC_VO_TXOP_AP 0x002f
5153 +
5154 +/* WME Traffic Specification (TSPEC) element */
5155 +#define WME_SUBTYPE_TSPEC 2
5156 +#define WME_TSPEC_HDR_LEN 2
5157 +#define WME_TSPEC_BODY_OFF 2
5158 +struct wme_tspec {
5159 + uint8 oui[DOT11_OUI_LEN]; /* WME_OUI */
5160 + uint8 type; /* WME_TYPE */
5161 + uint8 subtype; /* WME_SUBTYPE_TSPEC */
5162 + uint8 version; /* WME_VERSION */
5163 + uint16 ts_info; /* TS Info */
5164 + uint16 nom_msdu_size; /* (Nominal or fixed) MSDU Size (bytes) */
5165 + uint16 max_msdu_size; /* Maximum MSDU Size (bytes) */
5166 + uint32 min_service_interval; /* Minimum Service Interval (us) */
5167 + uint32 max_service_interval; /* Maximum Service Interval (us) */
5168 + uint32 inactivity_interval; /* Inactivity Interval (us) */
5169 + uint32 service_start; /* Service Start Time (us) */
5170 + uint32 min_rate; /* Minimum Data Rate (bps) */
5171 + uint32 mean_rate; /* Mean Data Rate (bps) */
5172 + uint32 max_burst_size; /* Maximum Burst Size (bytes) */
5173 + uint32 min_phy_rate; /* Minimum PHY Rate (bps) */
5174 + uint32 peak_rate; /* Peak Data Rate (bps) */
5175 + uint32 delay_bound; /* Delay Bound (us) */
5176 + uint16 surplus_bandwidth; /* Surplus Bandwidth Allowance Factor */
5177 + uint16 medium_time; /* Medium Time (32 us/s periods) */
5178 +} PACKED;
5179 +typedef struct wme_tspec wme_tspec_t;
5180 +#define WME_TSPEC_LEN 56 /* not including 2-byte header */
5181 +
5182 +/* ts_info */
5183 +/* 802.1D priority is duplicated - bits 13-11 AND bits 3-1 */
5184 +#define TS_INFO_PRIO_SHIFT_HI 11
5185 +#define TS_INFO_PRIO_MASK_HI (0x7 << TS_INFO_PRIO_SHIFT_HI)
5186 +#define TS_INFO_PRIO_SHIFT_LO 1
5187 +#define TS_INFO_PRIO_MASK_LO (0x7 << TS_INFO_PRIO_SHIFT_LO)
5188 +#define TS_INFO_CONTENTION_SHIFT 7
5189 +#define TS_INFO_CONTENTION_MASK (0x1 << TS_INFO_CONTENTION_SHIFT)
5190 +#define TS_INFO_DIRECTION_SHIFT 5
5191 +#define TS_INFO_DIRECTION_MASK (0x3 << TS_INFO_DIRECTION_SHIFT)
5192 +#define TS_INFO_UPLINK (0 << TS_INFO_DIRECTION_SHIFT)
5193 +#define TS_INFO_DOWNLINK (1 << TS_INFO_DIRECTION_SHIFT)
5194 +#define TS_INFO_BIDIRECTIONAL (3 << TS_INFO_DIRECTION_SHIFT)
5195 +
5196 +/* nom_msdu_size */
5197 +#define FIXED_MSDU_SIZE 0x8000 /* MSDU size is fixed */
5198 +#define MSDU_SIZE_MASK 0x7fff /* (Nominal or fixed) MSDU size */
5199 +
5200 +/* surplus_bandwidth */
5201 +/* Represented as 3 bits of integer, binary point, 13 bits fraction */
5202 +#define INTEGER_SHIFT 13
5203 +#define FRACTION_MASK 0x1FFF
5204 +
5205 +/* Management Notification Frame */
5206 +struct dot11_management_notification {
5207 + uint8 category; /* DOT11_ACTION_NOTIFICATION */
5208 + uint8 action;
5209 + uint8 token;
5210 + uint8 status;
5211 + uint8 data[1]; /* Elements */
5212 +} PACKED;
5213 +#define DOT11_MGMT_NOTIFICATION_LEN 4 /* Fixed length */
5214 +
5215 +/* WME Action Codes */
5216 +#define WME_SETUP_REQUEST 0
5217 +#define WME_SETUP_RESPONSE 1
5218 +#define WME_TEARDOWN 2
5219 +
5220 +/* WME Setup Response Status Codes */
5221 +#define WME_ADMISSION_ACCEPTED 0
5222 +#define WME_INVALID_PARAMETERS 1
5223 +#define WME_ADMISSION_REFUSED 3
5224 +
5225 +/* Macro to take a pointer to a beacon or probe response
5226 + * header and return the char* pointer to the SSID info element
5227 + */
5228 +#define BCN_PRB_SSID(hdr) ((char*)(hdr) + DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_LEN)
5229 +
5230 +/* Authentication frame payload constants */
5231 +#define DOT11_OPEN_SYSTEM 0
5232 +#define DOT11_SHARED_KEY 1
5233 +#define DOT11_CHALLENGE_LEN 128
5234 +
5235 +/* Frame control macros */
5236 +#define FC_PVER_MASK 0x3
5237 +#define FC_PVER_SHIFT 0
5238 +#define FC_TYPE_MASK 0xC
5239 +#define FC_TYPE_SHIFT 2
5240 +#define FC_SUBTYPE_MASK 0xF0
5241 +#define FC_SUBTYPE_SHIFT 4
5242 +#define FC_TODS 0x100
5243 +#define FC_TODS_SHIFT 8
5244 +#define FC_FROMDS 0x200
5245 +#define FC_FROMDS_SHIFT 9
5246 +#define FC_MOREFRAG 0x400
5247 +#define FC_MOREFRAG_SHIFT 10
5248 +#define FC_RETRY 0x800
5249 +#define FC_RETRY_SHIFT 11
5250 +#define FC_PM 0x1000
5251 +#define FC_PM_SHIFT 12
5252 +#define FC_MOREDATA 0x2000
5253 +#define FC_MOREDATA_SHIFT 13
5254 +#define FC_WEP 0x4000
5255 +#define FC_WEP_SHIFT 14
5256 +#define FC_ORDER 0x8000
5257 +#define FC_ORDER_SHIFT 15
5258 +
5259 +/* sequence control macros */
5260 +#define SEQNUM_SHIFT 4
5261 +#define FRAGNUM_MASK 0xF
5262 +
5263 +/* Frame Control type/subtype defs */
5264 +
5265 +/* FC Types */
5266 +#define FC_TYPE_MNG 0
5267 +#define FC_TYPE_CTL 1
5268 +#define FC_TYPE_DATA 2
5269 +
5270 +/* Management Subtypes */
5271 +#define FC_SUBTYPE_ASSOC_REQ 0
5272 +#define FC_SUBTYPE_ASSOC_RESP 1
5273 +#define FC_SUBTYPE_REASSOC_REQ 2
5274 +#define FC_SUBTYPE_REASSOC_RESP 3
5275 +#define FC_SUBTYPE_PROBE_REQ 4
5276 +#define FC_SUBTYPE_PROBE_RESP 5
5277 +#define FC_SUBTYPE_BEACON 8
5278 +#define FC_SUBTYPE_ATIM 9
5279 +#define FC_SUBTYPE_DISASSOC 10
5280 +#define FC_SUBTYPE_AUTH 11
5281 +#define FC_SUBTYPE_DEAUTH 12
5282 +#define FC_SUBTYPE_ACTION 13
5283 +
5284 +/* Control Subtypes */
5285 +#define FC_SUBTYPE_PS_POLL 10
5286 +#define FC_SUBTYPE_RTS 11
5287 +#define FC_SUBTYPE_CTS 12
5288 +#define FC_SUBTYPE_ACK 13
5289 +#define FC_SUBTYPE_CF_END 14
5290 +#define FC_SUBTYPE_CF_END_ACK 15
5291 +
5292 +/* Data Subtypes */
5293 +#define FC_SUBTYPE_DATA 0
5294 +#define FC_SUBTYPE_DATA_CF_ACK 1
5295 +#define FC_SUBTYPE_DATA_CF_POLL 2
5296 +#define FC_SUBTYPE_DATA_CF_ACK_POLL 3
5297 +#define FC_SUBTYPE_NULL 4
5298 +#define FC_SUBTYPE_CF_ACK 5
5299 +#define FC_SUBTYPE_CF_POLL 6
5300 +#define FC_SUBTYPE_CF_ACK_POLL 7
5301 +#define FC_SUBTYPE_QOS_DATA 8
5302 +#define FC_SUBTYPE_QOS_NULL 12
5303 +
5304 +/* type-subtype combos */
5305 +#define FC_KIND_MASK (FC_TYPE_MASK | FC_SUBTYPE_MASK)
5306 +
5307 +#define FC_KIND(t, s) (((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT))
5308 +
5309 +#define FC_ASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_REQ)
5310 +#define FC_ASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_RESP)
5311 +#define FC_REASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_REQ)
5312 +#define FC_REASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_RESP)
5313 +#define FC_PROBE_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_REQ)
5314 +#define FC_PROBE_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_RESP)
5315 +#define FC_BEACON FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_BEACON)
5316 +#define FC_DISASSOC FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DISASSOC)
5317 +#define FC_AUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_AUTH)
5318 +#define FC_DEAUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DEAUTH)
5319 +#define FC_ACTION FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ACTION)
5320 +
5321 +#define FC_PS_POLL FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_PS_POLL)
5322 +#define FC_RTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_RTS)
5323 +#define FC_CTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTS)
5324 +#define FC_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_ACK)
5325 +#define FC_CF_END FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END)
5326 +#define FC_CF_END_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END_ACK)
5327 +
5328 +#define FC_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA)
5329 +#define FC_NULL_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_NULL)
5330 +#define FC_DATA_CF_ACK FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA_CF_ACK)
5331 +#define FC_QOS_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_DATA)
5332 +#define FC_QOS_NULL FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_NULL)
5333 +
5334 +/* QoS Control Field */
5335 +
5336 +/* 802.1D Tag */
5337 +#define QOS_PRIO_SHIFT 0
5338 +#define QOS_PRIO_MASK 0x0007
5339 +#define QOS_PRIO(qos) (((qos) & QOS_PRIO_MASK) >> QOS_PRIO_SHIFT)
5340 +
5341 +/* Ack Policy (0 means Acknowledge) */
5342 +#define QOS_ACK_SHIFT 5
5343 +#define QOS_ACK_MASK 0x0060
5344 +#define QOS_ACK(qos) (((qos) & QOS_ACK_MASK) >> QOS_ACK_SHIFT)
5345 +
5346 +/* Management Frames */
5347 +
5348 +/* Management Frame Constants */
5349 +
5350 +/* Fixed fields */
5351 +#define DOT11_MNG_AUTH_ALGO_LEN 2
5352 +#define DOT11_MNG_AUTH_SEQ_LEN 2
5353 +#define DOT11_MNG_BEACON_INT_LEN 2
5354 +#define DOT11_MNG_CAP_LEN 2
5355 +#define DOT11_MNG_AP_ADDR_LEN 6
5356 +#define DOT11_MNG_LISTEN_INT_LEN 2
5357 +#define DOT11_MNG_REASON_LEN 2
5358 +#define DOT11_MNG_AID_LEN 2
5359 +#define DOT11_MNG_STATUS_LEN 2
5360 +#define DOT11_MNG_TIMESTAMP_LEN 8
5361 +
5362 +/* DUR/ID field in assoc resp is 0xc000 | AID */
5363 +#define DOT11_AID_MASK 0x3fff
5364 +
5365 +/* Reason Codes */
5366 +#define DOT11_RC_RESERVED 0
5367 +#define DOT11_RC_UNSPECIFIED 1 /* Unspecified reason */
5368 +#define DOT11_RC_AUTH_INVAL 2 /* Previous authentication no longer valid */
5369 +#define DOT11_RC_DEAUTH_LEAVING 3 /* Deauthenticated because sending station is
5370 + leaving (or has left) IBSS or ESS */
5371 +#define DOT11_RC_INACTIVITY 4 /* Disassociated due to inactivity */
5372 +#define DOT11_RC_BUSY 5 /* Disassociated because AP is unable to handle
5373 + all currently associated stations */
5374 +#define DOT11_RC_INVAL_CLASS_2 6 /* Class 2 frame received from
5375 + nonauthenticated station */
5376 +#define DOT11_RC_INVAL_CLASS_3 7 /* Class 3 frame received from
5377 + nonassociated station */
5378 +#define DOT11_RC_DISASSOC_LEAVING 8 /* Disassociated because sending station is
5379 + leaving (or has left) BSS */
5380 +#define DOT11_RC_NOT_AUTH 9 /* Station requesting (re)association is
5381 + not authenticated with responding station */
5382 +#define DOT11_RC_MAX 23 /* Reason codes > 23 are reserved */
5383 +
5384 +/* Status Codes */
5385 +#define DOT11_STATUS_SUCCESS 0 /* Successful */
5386 +#define DOT11_STATUS_FAILURE 1 /* Unspecified failure */
5387 +#define DOT11_STATUS_CAP_MISMATCH 10 /* Cannot support all requested capabilities
5388 + in the Capability Information field */
5389 +#define DOT11_STATUS_REASSOC_FAIL 11 /* Reassociation denied due to inability to
5390 + confirm that association exists */
5391 +#define DOT11_STATUS_ASSOC_FAIL 12 /* Association denied due to reason outside
5392 + the scope of this standard */
5393 +#define DOT11_STATUS_AUTH_MISMATCH 13 /* Responding station does not support the
5394 + specified authentication algorithm */
5395 +#define DOT11_STATUS_AUTH_SEQ 14 /* Received an Authentication frame with
5396 + authentication transaction sequence number
5397 + out of expected sequence */
5398 +#define DOT11_STATUS_AUTH_CHALLENGE_FAIL 15 /* Authentication rejected because of challenge failure */
5399 +#define DOT11_STATUS_AUTH_TIMEOUT 16 /* Authentication rejected due to timeout waiting
5400 + for next frame in sequence */
5401 +#define DOT11_STATUS_ASSOC_BUSY_FAIL 17 /* Association denied because AP is unable to
5402 + handle additional associated stations */
5403 +#define DOT11_STATUS_ASSOC_RATE_MISMATCH 18 /* Association denied due to requesting station
5404 + not supporting all of the data rates in the
5405 + BSSBasicRateSet parameter */
5406 +#define DOT11_STATUS_ASSOC_SHORT_REQUIRED 19 /* Association denied due to requesting station
5407 + not supporting the Short Preamble option */
5408 +#define DOT11_STATUS_ASSOC_PBCC_REQUIRED 20 /* Association denied due to requesting station
5409 + not supporting the PBCC Modulation option */
5410 +#define DOT11_STATUS_ASSOC_AGILITY_REQUIRED 21 /* Association denied due to requesting station
5411 + not supporting the Channel Agility option */
5412 +#define DOT11_STATUS_ASSOC_SPECTRUM_REQUIRED 22 /* Association denied because Spectrum Management
5413 + capability is required. */
5414 +#define DOT11_STATUS_ASSOC_BAD_POWER_CAP 23 /* Association denied because the info in the
5415 + Power Cap element is unacceptable. */
5416 +#define DOT11_STATUS_ASSOC_BAD_SUP_CHANNELS 24 /* Association denied because the info in the
5417 + Supported Channel element is unacceptable */
5418 +#define DOT11_STATUS_ASSOC_SHORTSLOT_REQUIRED 25 /* Association denied due to requesting station
5419 + not supporting the Short Slot Time option */
5420 +#define DOT11_STATUS_ASSOC_ERPBCC_REQUIRED 26 /* Association denied due to requesting station
5421 + not supporting the ER-PBCC Modulation option */
5422 +#define DOT11_STATUS_ASSOC_DSSOFDM_REQUIRED 27 /* Association denied due to requesting station
5423 + not supporting the DSS-OFDM option */
5424 +
5425 +/* Info Elts, length of INFORMATION portion of Info Elts */
5426 +#define DOT11_MNG_DS_PARAM_LEN 1
5427 +#define DOT11_MNG_IBSS_PARAM_LEN 2
5428 +
5429 +/* TIM Info element has 3 bytes fixed info in INFORMATION field,
5430 + * followed by 1 to 251 bytes of Partial Virtual Bitmap */
5431 +#define DOT11_MNG_TIM_FIXED_LEN 3
5432 +#define DOT11_MNG_TIM_DTIM_COUNT 0
5433 +#define DOT11_MNG_TIM_DTIM_PERIOD 1
5434 +#define DOT11_MNG_TIM_BITMAP_CTL 2
5435 +#define DOT11_MNG_TIM_PVB 3
5436 +
5437 +/* TLV defines */
5438 +#define TLV_TAG_OFF 0
5439 +#define TLV_LEN_OFF 1
5440 +#define TLV_HDR_LEN 2
5441 +#define TLV_BODY_OFF 2
5442 +
5443 +/* Management Frame Information Element IDs */
5444 +#define DOT11_MNG_SSID_ID 0
5445 +#define DOT11_MNG_RATES_ID 1
5446 +#define DOT11_MNG_FH_PARMS_ID 2
5447 +#define DOT11_MNG_DS_PARMS_ID 3
5448 +#define DOT11_MNG_CF_PARMS_ID 4
5449 +#define DOT11_MNG_TIM_ID 5
5450 +#define DOT11_MNG_IBSS_PARMS_ID 6
5451 +#define DOT11_MNG_COUNTRY_ID 7
5452 +#define DOT11_MNG_HOPPING_PARMS_ID 8
5453 +#define DOT11_MNG_HOPPING_TABLE_ID 9
5454 +#define DOT11_MNG_REQUEST_ID 10
5455 +#define DOT11_MNG_CHALLENGE_ID 16
5456 +#define DOT11_MNG_PWR_CONSTRAINT_ID 32 /* 11H PowerConstraint */
5457 +#define DOT11_MNG_PWR_CAP_ID 33 /* 11H PowerCapability */
5458 +#define DOT11_MNG_TPC_REQUEST_ID 34 /* 11H TPC Request */
5459 +#define DOT11_MNG_TPC_REPORT_ID 35 /* 11H TPC Report */
5460 +#define DOT11_MNG_SUPP_CHANNELS_ID 36 /* 11H Supported Channels */
5461 +#define DOT11_MNG_CHANNEL_SWITCH_ID 37 /* 11H ChannelSwitch Announcement*/
5462 +#define DOT11_MNG_MEASURE_REQUEST_ID 38 /* 11H MeasurementRequest */
5463 +#define DOT11_MNG_MEASURE_REPORT_ID 39 /* 11H MeasurementReport */
5464 +#define DOT11_MNG_QUIET_ID 40 /* 11H Quiet */
5465 +#define DOT11_MNG_IBSS_DFS_ID 41 /* 11H IBSS_DFS */
5466 +#define DOT11_MNG_ERP_ID 42
5467 +#define DOT11_MNG_NONERP_ID 47
5468 +#define DOT11_MNG_RSN_ID 48
5469 +#define DOT11_MNG_EXT_RATES_ID 50
5470 +#define DOT11_MNG_WPA_ID 221
5471 +#define DOT11_MNG_PROPR_ID 221
5472 +
5473 +/* ERP info element bit values */
5474 +#define DOT11_MNG_ERP_LEN 1 /* ERP is currently 1 byte long */
5475 +#define DOT11_MNG_NONERP_PRESENT 0x01 /* NonERP (802.11b) STAs are present in the BSS */
5476 +#define DOT11_MNG_USE_PROTECTION 0x02 /* Use protection mechanisms for ERP-OFDM frames */
5477 +#define DOT11_MNG_BARKER_PREAMBLE 0x04 /* Short Preambles: 0 == allowed, 1 == not allowed */
5478 +
5479 +/* Capability Information Field */
5480 +#define DOT11_CAP_ESS 0x0001
5481 +#define DOT11_CAP_IBSS 0x0002
5482 +#define DOT11_CAP_POLLABLE 0x0004
5483 +#define DOT11_CAP_POLL_RQ 0x0008
5484 +#define DOT11_CAP_PRIVACY 0x0010
5485 +#define DOT11_CAP_SHORT 0x0020
5486 +#define DOT11_CAP_PBCC 0x0040
5487 +#define DOT11_CAP_AGILITY 0x0080
5488 +#define DOT11_CAP_SPECTRUM 0x0100
5489 +#define DOT11_CAP_SHORTSLOT 0x0400
5490 +#define DOT11_CAP_CCK_OFDM 0x2000
5491 +
5492 +/* Action Frame Constants */
5493 +#define DOT11_ACTION_CAT_ERR_MASK 0x80
5494 +#define DOT11_ACTION_CAT_SPECT_MNG 0x00
5495 +#define DOT11_ACTION_NOTIFICATION 0x11 /* 17 */
5496 +
5497 +#define DOT11_ACTION_ID_M_REQ 0
5498 +#define DOT11_ACTION_ID_M_REP 1
5499 +#define DOT11_ACTION_ID_TPC_REQ 2
5500 +#define DOT11_ACTION_ID_TPC_REP 3
5501 +#define DOT11_ACTION_ID_CHANNEL_SWITCH 4
5502 +
5503 +/* MLME Enumerations */
5504 +#define DOT11_BSSTYPE_INFRASTRUCTURE 0
5505 +#define DOT11_BSSTYPE_INDEPENDENT 1
5506 +#define DOT11_BSSTYPE_ANY 2
5507 +#define DOT11_SCANTYPE_ACTIVE 0
5508 +#define DOT11_SCANTYPE_PASSIVE 1
5509 +
5510 +/* 802.11 A PHY constants */
5511 +#define APHY_SLOT_TIME 9
5512 +#define APHY_SIFS_TIME 16
5513 +#define APHY_DIFS_TIME (APHY_SIFS_TIME + (2 * APHY_SLOT_TIME))
5514 +#define APHY_PREAMBLE_TIME 16
5515 +#define APHY_SIGNAL_TIME 4
5516 +#define APHY_SYMBOL_TIME 4
5517 +#define APHY_SERVICE_NBITS 16
5518 +#define APHY_TAIL_NBITS 6
5519 +#define APHY_CWMIN 15
5520 +
5521 +/* 802.11 B PHY constants */
5522 +#define BPHY_SLOT_TIME 20
5523 +#define BPHY_SIFS_TIME 10
5524 +#define BPHY_DIFS_TIME 50
5525 +#define BPHY_PLCP_TIME 192
5526 +#define BPHY_PLCP_SHORT_TIME 96
5527 +#define BPHY_CWMIN 31
5528 +
5529 +/* 802.11 G constants */
5530 +#define DOT11_OFDM_SIGNAL_EXTENSION 6
5531 +
5532 +#define PHY_CWMAX 1023
5533 +
5534 +#define DOT11_MAXNUMFRAGS 16 /* max # fragments per MSDU */
5535 +
5536 +/* dot11Counters Table - 802.11 spec., Annex D */
5537 +typedef struct d11cnt {
5538 + uint32 txfrag; /* dot11TransmittedFragmentCount */
5539 + uint32 txmulti; /* dot11MulticastTransmittedFrameCount */
5540 + uint32 txfail; /* dot11FailedCount */
5541 + uint32 txretry; /* dot11RetryCount */
5542 + uint32 txretrie; /* dot11MultipleRetryCount */
5543 + uint32 rxdup; /* dot11FrameduplicateCount */
5544 + uint32 txrts; /* dot11RTSSuccessCount */
5545 + uint32 txnocts; /* dot11RTSFailureCount */
5546 + uint32 txnoack; /* dot11ACKFailureCount */
5547 + uint32 rxfrag; /* dot11ReceivedFragmentCount */
5548 + uint32 rxmulti; /* dot11MulticastReceivedFrameCount */
5549 + uint32 rxcrc; /* dot11FCSErrorCount */
5550 + uint32 txfrmsnt; /* dot11TransmittedFrameCount */
5551 + uint32 rxundec; /* dot11WEPUndecryptableCount */
5552 +} d11cnt_t;
5553 +
5554 +/* BRCM OUI */
5555 +#define BRCM_OUI "\x00\x10\x18"
5556 +
5557 +/* BRCM info element */
5558 +struct brcm_ie {
5559 + uchar id; /* 221, DOT11_MNG_PROPR_ID */
5560 + uchar len;
5561 + uchar oui[3];
5562 + uchar ver;
5563 + uchar assoc; /* # of assoc STAs */
5564 + uchar flags; /* misc flags */
5565 +} PACKED;
5566 +#define BRCM_IE_LEN 8
5567 +typedef struct brcm_ie brcm_ie_t;
5568 +#define BRCM_IE_VER 2
5569 +#define BRCM_IE_LEGACY_AES_VER 1
5570 +
5571 +/* brcm_ie flags */
5572 +#define BRF_ABCAP 0x1 /* afterburner capable */
5573 +#define BRF_ABRQRD 0x2 /* afterburner requested */
5574 +#define BRF_LZWDS 0x4 /* lazy wds enabled */
5575 +
5576 +
5577 +/* OUI for BRCM proprietary IE */
5578 +#define BRCM_PROP_OUI "\x00\x90\x4C"
5579 +
5580 +/* Vendor IE structure */
5581 +struct vndr_ie {
5582 + uchar id;
5583 + uchar len;
5584 + uchar oui [3];
5585 + uchar data [1]; /* Variable size data */
5586 +}PACKED;
5587 +typedef struct vndr_ie vndr_ie_t;
5588 +
5589 +#define VNDR_IE_HDR_LEN 2 /* id + len field */
5590 +#define VNDR_IE_MIN_LEN 3 /* size of the oui field */
5591 +#define VNDR_IE_MAX_LEN 256
5592 +
5593 +/* WPA definitions */
5594 +#define WPA_VERSION 1
5595 +#define WPA_OUI "\x00\x50\xF2"
5596 +
5597 +#define WPA2_VERSION 1
5598 +#define WPA2_VERSION_LEN 2
5599 +#define WPA2_OUI "\x00\x0F\xAC"
5600 +
5601 +#define WPA_OUI_LEN 3
5602 +
5603 +/* RSN authenticated key managment suite */
5604 +#define RSN_AKM_NONE 0 /* None (IBSS) */
5605 +#define RSN_AKM_UNSPECIFIED 1 /* Over 802.1x */
5606 +#define RSN_AKM_PSK 2 /* Pre-shared Key */
5607 +
5608 +
5609 +/* Key related defines */
5610 +#define DOT11_MAX_DEFAULT_KEYS 4 /* number of default keys */
5611 +#define DOT11_MAX_KEY_SIZE 32 /* max size of any key */
5612 +#define DOT11_MAX_IV_SIZE 16 /* max size of any IV */
5613 +#define DOT11_EXT_IV_FLAG (1<<5) /* flag to indicate IV is > 4 bytes */
5614 +
5615 +#define WEP1_KEY_SIZE 5 /* max size of any WEP key */
5616 +#define WEP1_KEY_HEX_SIZE 10 /* size of WEP key in hex. */
5617 +#define WEP128_KEY_SIZE 13 /* max size of any WEP key */
5618 +#define WEP128_KEY_HEX_SIZE 26 /* size of WEP key in hex. */
5619 +#define TKIP_MIC_SIZE 8 /* size of TKIP MIC */
5620 +#define TKIP_EOM_SIZE 7 /* max size of TKIP EOM */
5621 +#define TKIP_EOM_FLAG 0x5a /* TKIP EOM flag byte */
5622 +#define TKIP_KEY_SIZE 32 /* size of any TKIP key */
5623 +#define TKIP_MIC_AUTH_TX 16 /* offset to Authenticator MIC TX key */
5624 +#define TKIP_MIC_AUTH_RX 24 /* offset to Authenticator MIC RX key */
5625 +#define TKIP_MIC_SUP_RX 16 /* offset to Supplicant MIC RX key */
5626 +#define TKIP_MIC_SUP_TX 24 /* offset to Supplicant MIC TX key */
5627 +#define AES_KEY_SIZE 16 /* size of AES key */
5628 +
5629 +#undef PACKED
5630 +#if !defined(__GNUC__)
5631 +#pragma pack()
5632 +#endif
5633 +
5634 +#endif /* _802_11_H_ */
5635 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/proto/bcmeth.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/bcmeth.h
5636 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/bcmeth.h 1970-01-01 01:00:00.000000000 +0100
5637 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/bcmeth.h 2005-02-02 23:16:40.000000000 +0100
5638 @@ -0,0 +1,97 @@
5639 +/*
5640 + * Broadcom Ethernettype protocol definitions
5641 + *
5642 + * Copyright 2005, Broadcom Corporation
5643 + * All Rights Reserved.
5644 + *
5645 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5646 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5647 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5648 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5649 + *
5650 + */
5651 +
5652 +/*
5653 + * Broadcom Ethernet protocol defines
5654 + *
5655 + */
5656 +
5657 +#ifndef _BCMETH_H_
5658 +#define _BCMETH_H_
5659 +
5660 +/* enable structure packing */
5661 +#if defined(__GNUC__)
5662 +#define PACKED __attribute__((packed))
5663 +#else
5664 +#pragma pack(1)
5665 +#define PACKED
5666 +#endif
5667 +
5668 +/* ETHER_TYPE_BRCM is defined in ethernet.h */
5669 +
5670 +/*
5671 + * Following the 2byte BRCM ether_type is a 16bit BRCM subtype field
5672 + * in one of two formats: (only subtypes 32768-65535 are in use now)
5673 + *
5674 + * subtypes 0-32767:
5675 + * 8 bit subtype (0-127)
5676 + * 8 bit length in bytes (0-255)
5677 + *
5678 + * subtypes 32768-65535:
5679 + * 16 bit big-endian subtype
5680 + * 16 bit big-endian length in bytes (0-65535)
5681 + *
5682 + * length is the number of additional bytes beyond the 4 or 6 byte header
5683 + *
5684 + * Reserved values:
5685 + * 0 reserved
5686 + * 5-15 reserved for iLine protocol assignments
5687 + * 17-126 reserved, assignable
5688 + * 127 reserved
5689 + * 32768 reserved
5690 + * 32769-65534 reserved, assignable
5691 + * 65535 reserved
5692 + */
5693 +
5694 +/*
5695 + * While adding the subtypes and their specific processing code make sure
5696 + * bcmeth_bcm_hdr_t is the first data structure in the user specific data structure definition
5697 + */
5698 +
5699 +#define BCMILCP_SUBTYPE_RATE 1
5700 +#define BCMILCP_SUBTYPE_LINK 2
5701 +#define BCMILCP_SUBTYPE_CSA 3
5702 +#define BCMILCP_SUBTYPE_LARQ 4
5703 +#define BCMILCP_SUBTYPE_VENDOR 5
5704 +#define BCMILCP_SUBTYPE_FLH 17
5705 +
5706 +#define BCMILCP_SUBTYPE_VENDOR_LONG 32769
5707 +#define BCMILCP_SUBTYPE_CERT 32770
5708 +#define BCMILCP_SUBTYPE_SES 32771
5709 +
5710 +
5711 +#define BCMILCP_BCM_SUBTYPE_RESERVED 0
5712 +#define BCMILCP_BCM_SUBTYPE_WPA 1
5713 +#define BCMILCP_BCM_SUBTYPE_EAPOL 2
5714 +#define BCMILCP_BCM_SUBTYPE_SES 3
5715 +
5716 +#define BCMILCP_BCM_SUBTYPEHDR_MINLENGTH 8
5717 +#define BCMILCP_BCM_SUBTYPEHDR_VERSION 0
5718 +
5719 +typedef struct bcmeth_bcm_hdr
5720 +{
5721 + uint16 subtype; /* Vendor specific..32769*/
5722 + uint16 length;
5723 + uint8 version; /* Version is 0*/
5724 + uint8 oui[3]; /* Broadcom OUI*/
5725 + /* user specific Data */
5726 + uint16 usr_subtype;
5727 +} PACKED bcmeth_bcm_hdr_t;
5728 +
5729 +
5730 +#undef PACKED
5731 +#if !defined(__GNUC__)
5732 +#pragma pack()
5733 +#endif
5734 +
5735 +#endif
5736 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/proto/ethernet.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/ethernet.h
5737 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/ethernet.h 1970-01-01 01:00:00.000000000 +0100
5738 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/ethernet.h 2005-02-02 23:16:40.000000000 +0100
5739 @@ -0,0 +1,161 @@
5740 +/*******************************************************************************
5741 + * $Id$
5742 + * Copyright 2005, Broadcom Corporation
5743 + * All Rights Reserved.
5744 + *
5745 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5746 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5747 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5748 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5749 + * From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
5750 + ******************************************************************************/
5751 +
5752 +#ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
5753 +#define _NET_ETHERNET_H_
5754 +
5755 +#ifndef _TYPEDEFS_H_
5756 +#include "typedefs.h"
5757 +#endif
5758 +
5759 +/* enable structure packing */
5760 +#if defined(__GNUC__)
5761 +#define PACKED __attribute__((packed))
5762 +#else
5763 +#pragma pack(1)
5764 +#define PACKED
5765 +#endif
5766 +
5767 +/*
5768 + * The number of bytes in an ethernet (MAC) address.
5769 + */
5770 +#define ETHER_ADDR_LEN 6
5771 +
5772 +/*
5773 + * The number of bytes in the type field.
5774 + */
5775 +#define ETHER_TYPE_LEN 2
5776 +
5777 +/*
5778 + * The number of bytes in the trailing CRC field.
5779 + */
5780 +#define ETHER_CRC_LEN 4
5781 +
5782 +/*
5783 + * The length of the combined header.
5784 + */
5785 +#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
5786 +
5787 +/*
5788 + * The minimum packet length.
5789 + */
5790 +#define ETHER_MIN_LEN 64
5791 +
5792 +/*
5793 + * The minimum packet user data length.
5794 + */
5795 +#define ETHER_MIN_DATA 46
5796 +
5797 +/*
5798 + * The maximum packet length.
5799 + */
5800 +#define ETHER_MAX_LEN 1518
5801 +
5802 +/*
5803 + * The maximum packet user data length.
5804 + */
5805 +#define ETHER_MAX_DATA 1500
5806 +
5807 +/* ether types */
5808 +#define ETHER_TYPE_IP 0x0800 /* IP */
5809 +#define ETHER_TYPE_ARP 0x0806 /* ARP */
5810 +#define ETHER_TYPE_8021Q 0x8100 /* 802.1Q */
5811 +#define ETHER_TYPE_BRCM 0x886c /* Broadcom Corp. */
5812 +#define ETHER_TYPE_802_1X 0x888e /* 802.1x */
5813 +#define ETHER_TYPE_802_1X_PREAUTH 0x88c7 /* 802.1x preauthentication*/
5814 +
5815 +/* Broadcom subtype follows ethertype; First 2 bytes are reserved; Next 2 are subtype; */
5816 +#define ETHER_BRCM_SUBTYPE_LEN 4 /* Broadcom 4 byte subtype */
5817 +#define ETHER_BRCM_CRAM 0x1 /* Broadcom subtype cram protocol */
5818 +
5819 +/* ether header */
5820 +#define ETHER_DEST_OFFSET 0 /* dest address offset */
5821 +#define ETHER_SRC_OFFSET 6 /* src address offset */
5822 +#define ETHER_TYPE_OFFSET 12 /* ether type offset */
5823 +
5824 +/*
5825 + * A macro to validate a length with
5826 + */
5827 +#define ETHER_IS_VALID_LEN(foo) \
5828 + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
5829 +
5830 +
5831 +#ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
5832 +/*
5833 + * Structure of a 10Mb/s Ethernet header.
5834 + */
5835 +struct ether_header {
5836 + uint8 ether_dhost[ETHER_ADDR_LEN];
5837 + uint8 ether_shost[ETHER_ADDR_LEN];
5838 + uint16 ether_type;
5839 +} PACKED;
5840 +
5841 +/*
5842 + * Structure of a 48-bit Ethernet address.
5843 + */
5844 +struct ether_addr {
5845 + uint8 octet[ETHER_ADDR_LEN];
5846 +} PACKED;
5847 +#endif
5848 +
5849 +/*
5850 + * Takes a pointer, returns true if a 48-bit multicast address
5851 + * (including broadcast, since it is all ones)
5852 + */
5853 +#define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
5854 +
5855 +/* compare two ethernet addresses - assumes the pointers can be referenced as shorts */
5856 +#define ether_cmp(a, b) ( \
5857 + !(((short*)a)[0] == ((short*)b)[0]) | \
5858 + !(((short*)a)[1] == ((short*)b)[1]) | \
5859 + !(((short*)a)[2] == ((short*)b)[2]))
5860 +
5861 +/* copy an ethernet address - assumes the pointers can be referenced as shorts */
5862 +#define ether_copy(s, d) { \
5863 + ((short*)d)[0] = ((short*)s)[0]; \
5864 + ((short*)d)[1] = ((short*)s)[1]; \
5865 + ((short*)d)[2] = ((short*)s)[2]; }
5866 +
5867 +/*
5868 + * Takes a pointer, returns true if a 48-bit broadcast (all ones)
5869 + */
5870 +#define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \
5871 + ((uint8 *)(ea))[1] & \
5872 + ((uint8 *)(ea))[2] & \
5873 + ((uint8 *)(ea))[3] & \
5874 + ((uint8 *)(ea))[4] & \
5875 + ((uint8 *)(ea))[5]) == 0xff)
5876 +
5877 +static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
5878 +
5879 +/*
5880 + * Takes a pointer, returns true if a 48-bit null address (all zeros)
5881 + */
5882 +#define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \
5883 + ((uint8 *)(ea))[1] | \
5884 + ((uint8 *)(ea))[2] | \
5885 + ((uint8 *)(ea))[3] | \
5886 + ((uint8 *)(ea))[4] | \
5887 + ((uint8 *)(ea))[5]) == 0)
5888 +
5889 +/* Differentiated Services Codepoint - upper 6 bits of tos in iphdr */
5890 +#define DSCP_MASK 0xFC /* upper 6 bits */
5891 +#define DSCP_SHIFT 2
5892 +#define DSCP_WME_PRI_MASK 0xE0 /* upper 3 bits */
5893 +#define DSCP_WME_PRI_SHIFT 5
5894 +
5895 +#undef PACKED
5896 +#if !defined(__GNUC__)
5897 +#pragma pack()
5898 +#endif
5899 +
5900 +#endif /* _NET_ETHERNET_H_ */
5901 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/proto/vlan.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/vlan.h
5902 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/vlan.h 1970-01-01 01:00:00.000000000 +0100
5903 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/vlan.h 2005-02-02 23:16:40.000000000 +0100
5904 @@ -0,0 +1,50 @@
5905 +/*
5906 + * 802.1Q VLAN protocol definitions
5907 + *
5908 + * Copyright 2005, Broadcom Corporation
5909 + * All Rights Reserved.
5910 + *
5911 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5912 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5913 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5914 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5915 + *
5916 + * $Id$
5917 + */
5918 +
5919 +#ifndef _vlan_h_
5920 +#define _vlan_h_
5921 +
5922 +/* enable structure packing */
5923 +#if defined(__GNUC__)
5924 +#define PACKED __attribute__((packed))
5925 +#else
5926 +#pragma pack(1)
5927 +#define PACKED
5928 +#endif
5929 +
5930 +#define VLAN_VID_MASK 0xfff /* low 12 bits are vlan id */
5931 +#define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */
5932 +#define VLAN_PRI_SHIFT 13 /* user priority */
5933 +
5934 +#define VLAN_PRI_MASK 7 /* 3 bits of priority */
5935 +
5936 +#define VLAN_TAG_LEN 4
5937 +#define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN)
5938 +
5939 +struct ethervlan_header {
5940 + uint8 ether_dhost[ETHER_ADDR_LEN];
5941 + uint8 ether_shost[ETHER_ADDR_LEN];
5942 + uint16 vlan_type; /* 0x8100 */
5943 + uint16 vlan_tag; /* priority, cfi and vid */
5944 + uint16 ether_type;
5945 +};
5946 +
5947 +#define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN)
5948 +
5949 +#undef PACKED
5950 +#if !defined(__GNUC__)
5951 +#pragma pack()
5952 +#endif
5953 +
5954 +#endif /* _vlan_h_ */
5955 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/proto/wpa.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/wpa.h
5956 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/wpa.h 1970-01-01 01:00:00.000000000 +0100
5957 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/proto/wpa.h 2005-02-02 23:16:40.000000000 +0100
5958 @@ -0,0 +1,140 @@
5959 +/*
5960 + * Fundamental types and constants relating to WPA
5961 + *
5962 + * Copyright 2005, Broadcom Corporation
5963 + * All Rights Reserved.
5964 + *
5965 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5966 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5967 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5968 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5969 + *
5970 + * $Id$
5971 + */
5972 +
5973 +#ifndef _proto_wpa_h_
5974 +#define _proto_wpa_h_
5975 +
5976 +#include <typedefs.h>
5977 +#include <proto/ethernet.h>
5978 +
5979 +/* enable structure packing */
5980 +#if defined(__GNUC__)
5981 +#define PACKED __attribute__((packed))
5982 +#else
5983 +#pragma pack(1)
5984 +#define PACKED
5985 +#endif
5986 +
5987 +/* Reason Codes */
5988 +
5989 +/* 10 and 11 are from TGh. */
5990 +#define DOT11_RC_BAD_PC 10 /* Unacceptable power capability element */
5991 +#define DOT11_RC_BAD_CHANNELS 11 /* Unacceptable supported channels element */
5992 +/* 12 is unused */
5993 +/* 13 through 23 taken from P802.11i/D3.0, November 2002 */
5994 +#define DOT11_RC_INVALID_WPA_IE 13 /* Invalid info. element */
5995 +#define DOT11_RC_MIC_FAILURE 14 /* Michael failure */
5996 +#define DOT11_RC_4WH_TIMEOUT 15 /* 4-way handshake timeout */
5997 +#define DOT11_RC_GTK_UPDATE_TIMEOUT 16 /* Group key update timeout */
5998 +#define DOT11_RC_WPA_IE_MISMATCH 17 /* WPA IE in 4-way handshake differs from (re-)assoc. request/probe response */
5999 +#define DOT11_RC_INVALID_MC_CIPHER 18 /* Invalid multicast cipher */
6000 +#define DOT11_RC_INVALID_UC_CIPHER 19 /* Invalid unicast cipher */
6001 +#define DOT11_RC_INVALID_AKMP 20 /* Invalid authenticated key management protocol */
6002 +#define DOT11_RC_BAD_WPA_VERSION 21 /* Unsupported WPA version */
6003 +#define DOT11_RC_INVALID_WPA_CAP 22 /* Invalid WPA IE capabilities */
6004 +#define DOT11_RC_8021X_AUTH_FAIL 23 /* 802.1X authentication failure */
6005 +
6006 +#define WPA2_PMKID_LEN 16
6007 +
6008 +/* WPA IE fixed portion */
6009 +typedef struct
6010 +{
6011 + uint8 tag; /* TAG */
6012 + uint8 length; /* TAG length */
6013 + uint8 oui[3]; /* IE OUI */
6014 + uint8 oui_type; /* OUI type */
6015 + struct {
6016 + uint8 low;
6017 + uint8 high;
6018 + } PACKED version; /* IE version */
6019 +} PACKED wpa_ie_fixed_t;
6020 +#define WPA_IE_OUITYPE_LEN 4
6021 +#define WPA_IE_FIXED_LEN 8
6022 +#define WPA_IE_TAG_FIXED_LEN 6
6023 +
6024 +typedef struct {
6025 + uint8 tag; /* TAG */
6026 + uint8 length; /* TAG length */
6027 + struct {
6028 + uint8 low;
6029 + uint8 high;
6030 + } PACKED version; /* IE version */
6031 +} PACKED wpa_rsn_ie_fixed_t;
6032 +#define WPA_RSN_IE_FIXED_LEN 4
6033 +#define WPA_RSN_IE_TAG_FIXED_LEN 2
6034 +typedef uint8 wpa_pmkid_t[WPA2_PMKID_LEN];
6035 +
6036 +/* WPA suite/multicast suite */
6037 +typedef struct
6038 +{
6039 + uint8 oui[3];
6040 + uint8 type;
6041 +} PACKED wpa_suite_t, wpa_suite_mcast_t;
6042 +#define WPA_SUITE_LEN 4
6043 +
6044 +/* WPA unicast suite list/key management suite list */
6045 +typedef struct
6046 +{
6047 + struct {
6048 + uint8 low;
6049 + uint8 high;
6050 + } PACKED count;
6051 + wpa_suite_t list[1];
6052 +} PACKED wpa_suite_ucast_t, wpa_suite_auth_key_mgmt_t;
6053 +#define WPA_IE_SUITE_COUNT_LEN 2
6054 +typedef struct
6055 +{
6056 + struct {
6057 + uint8 low;
6058 + uint8 high;
6059 + } PACKED count;
6060 + wpa_pmkid_t list[1];
6061 +} PACKED wpa_pmkid_list_t;
6062 +
6063 +/* WPA cipher suites */
6064 +#define WPA_CIPHER_NONE 0 /* None */
6065 +#define WPA_CIPHER_WEP_40 1 /* WEP (40-bit) */
6066 +#define WPA_CIPHER_TKIP 2 /* TKIP: default for WPA */
6067 +#define WPA_CIPHER_AES_OCB 3 /* AES (OCB) */
6068 +#define WPA_CIPHER_AES_CCM 4 /* AES (CCM) */
6069 +#define WPA_CIPHER_WEP_104 5 /* WEP (104-bit) */
6070 +
6071 +#define IS_WPA_CIPHER(cipher) ((cipher) == WPA_CIPHER_NONE || \
6072 + (cipher) == WPA_CIPHER_WEP_40 || \
6073 + (cipher) == WPA_CIPHER_WEP_104 || \
6074 + (cipher) == WPA_CIPHER_TKIP || \
6075 + (cipher) == WPA_CIPHER_AES_OCB || \
6076 + (cipher) == WPA_CIPHER_AES_CCM)
6077 +
6078 +/* WPA TKIP countermeasures parameters */
6079 +#define WPA_TKIP_CM_DETECT 60 /* multiple MIC failure window (seconds) */
6080 +#define WPA_TKIP_CM_BLOCK 60 /* countermeasures active window (seconds) */
6081 +
6082 +/* WPA capabilities defined in 802.11i */
6083 +#define WPA_CAP_4_REPLAY_CNTRS 2
6084 +#define WPA_CAP_16_REPLAY_CNTRS 3
6085 +#define WPA_CAP_REPLAY_CNTR_SHIFT 2
6086 +#define WPA_CAP_REPLAY_CNTR_MASK 0x000c
6087 +
6088 +/* WPA Specific defines */
6089 +#define WPA_CAP_LEN 2
6090 +
6091 +#define WPA_CAP_WPA2_PREAUTH 1
6092 +
6093 +#undef PACKED
6094 +#if !defined(__GNUC__)
6095 +#pragma pack()
6096 +#endif
6097 +
6098 +#endif /* _proto_wpa_h_ */
6099 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/rts/crc.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/rts/crc.h
6100 --- linux-2.4.30/arch/mips/bcm947xx/include/rts/crc.h 1970-01-01 01:00:00.000000000 +0100
6101 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/rts/crc.h 2005-02-02 23:16:40.000000000 +0100
6102 @@ -0,0 +1,69 @@
6103 +/*******************************************************************************
6104 + * $Id$
6105 + * Copyright 2005, Broadcom Corporation
6106 + * All Rights Reserved.
6107 + *
6108 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6109 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6110 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6111 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6112 + * crc.h - a function to compute crc for iLine10 headers
6113 + ******************************************************************************/
6114 +
6115 +#ifndef _RTS_CRC_H_
6116 +#define _RTS_CRC_H_ 1
6117 +
6118 +#include "typedefs.h"
6119 +
6120 +#ifdef __cplusplus
6121 +extern "C" {
6122 +#endif
6123 +
6124 +
6125 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
6126 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
6127 +#define HCS_GOOD_VALUE 0x39 /* Good final header checksum value */
6128 +
6129 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
6130 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
6131 +
6132 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
6133 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
6134 +
6135 +void hcs(uint8 *, uint);
6136 +uint8 crc8(uint8 *, uint, uint8);
6137 +uint16 crc16(uint8 *, uint, uint16);
6138 +uint32 crc32(uint8 *, uint, uint32);
6139 +
6140 +/* macros for common usage */
6141 +
6142 +#define APPEND_CRC8(pbytes, nbytes) \
6143 +do { \
6144 + uint8 tmp = crc8(pbytes, nbytes, CRC8_INIT_VALUE) ^ 0xff; \
6145 + (pbytes)[(nbytes)] = tmp; \
6146 + (nbytes) += 1; \
6147 +} while (0)
6148 +
6149 +#define APPEND_CRC16(pbytes, nbytes) \
6150 +do { \
6151 + uint16 tmp = crc16(pbytes, nbytes, CRC16_INIT_VALUE) ^ 0xffff; \
6152 + (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
6153 + (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
6154 + (nbytes) += 2; \
6155 +} while (0)
6156 +
6157 +#define APPEND_CRC32(pbytes, nbytes) \
6158 +do { \
6159 + uint32 tmp = crc32(pbytes, nbytes, CRC32_INIT_VALUE) ^ 0xffffffff; \
6160 + (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
6161 + (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
6162 + (pbytes)[(nbytes) + 2] = (tmp >> 16) & 0xff; \
6163 + (pbytes)[(nbytes) + 3] = (tmp >> 24) & 0xff; \
6164 + (nbytes) += 4; \
6165 +} while (0)
6166 +
6167 +#ifdef __cplusplus
6168 +}
6169 +#endif
6170 +
6171 +#endif /* _RTS_CRC_H_ */
6172 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbchipc.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbchipc.h
6173 --- linux-2.4.30/arch/mips/bcm947xx/include/sbchipc.h 1970-01-01 01:00:00.000000000 +0100
6174 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbchipc.h 2005-02-02 23:16:40.000000000 +0100
6175 @@ -0,0 +1,394 @@
6176 +/*
6177 + * SiliconBackplane Chipcommon core hardware definitions.
6178 + *
6179 + * The chipcommon core provides chip identification, SB control,
6180 + * jtag, 0/1/2 uarts, clock frequency control, a watchdog interrupt timer,
6181 + * gpio interface, extbus, and support for serial and parallel flashes.
6182 + *
6183 + * $Id$
6184 + * Copyright 2005, Broadcom Corporation
6185 + * All Rights Reserved.
6186 + *
6187 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6188 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6189 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6190 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6191 + *
6192 + */
6193 +
6194 +#ifndef _SBCHIPC_H
6195 +#define _SBCHIPC_H
6196 +
6197 +
6198 +#ifndef _LANGUAGE_ASSEMBLY
6199 +
6200 +/* cpp contortions to concatenate w/arg prescan */
6201 +#ifndef PAD
6202 +#define _PADLINE(line) pad ## line
6203 +#define _XSTR(line) _PADLINE(line)
6204 +#define PAD _XSTR(__LINE__)
6205 +#endif /* PAD */
6206 +
6207 +typedef volatile struct {
6208 + uint32 chipid; /* 0x0 */
6209 + uint32 capabilities;
6210 + uint32 corecontrol; /* corerev >= 1 */
6211 + uint32 bist;
6212 +
6213 + /* OTP */
6214 + uint32 otpstatus; /* 0x10, corerev >= 10 */
6215 + uint32 otpcontrol;
6216 + uint32 otpprog;
6217 + uint32 PAD;
6218 +
6219 + /* Interrupt control */
6220 + uint32 intstatus; /* 0x20 */
6221 + uint32 intmask;
6222 + uint32 chipcontrol; /* 0x28, rev >= 11 */
6223 + uint32 chipstatus; /* 0x2c, rev >= 11 */
6224 +
6225 + /* Jtag Master */
6226 + uint32 jtagcmd; /* 0x30, rev >= 10 */
6227 + uint32 jtagir;
6228 + uint32 jtagdr;
6229 + uint32 jtagctrl;
6230 +
6231 + /* serial flash interface registers */
6232 + uint32 flashcontrol; /* 0x40 */
6233 + uint32 flashaddress;
6234 + uint32 flashdata;
6235 + uint32 PAD[1];
6236 +
6237 + /* Silicon backplane configuration broadcast control */
6238 + uint32 broadcastaddress; /* 0x50 */
6239 + uint32 broadcastdata;
6240 + uint32 PAD[2];
6241 +
6242 + /* gpio - cleared only by power-on-reset */
6243 + uint32 gpioin; /* 0x60 */
6244 + uint32 gpioout;
6245 + uint32 gpioouten;
6246 + uint32 gpiocontrol;
6247 + uint32 gpiointpolarity;
6248 + uint32 gpiointmask;
6249 + uint32 PAD[2];
6250 +
6251 + /* Watchdog timer */
6252 + uint32 watchdog; /* 0x80 */
6253 + uint32 PAD[3];
6254 +
6255 + /* clock control */
6256 + uint32 clockcontrol_n; /* 0x90 */
6257 + uint32 clockcontrol_sb; /* aka m0 */
6258 + uint32 clockcontrol_pci; /* aka m1 */
6259 + uint32 clockcontrol_m2; /* mii/uart/mipsref */
6260 + uint32 clockcontrol_mips; /* aka m3 */
6261 + uint32 clkdiv; /* corerev >= 3 */
6262 + uint32 PAD[2];
6263 +
6264 + /* pll delay registers (corerev >= 4) */
6265 + uint32 pll_on_delay; /* 0xb0 */
6266 + uint32 fref_sel_delay;
6267 + uint32 slow_clk_ctl; /* 5 < corerev < 10 */
6268 + uint32 PAD[1];
6269 +
6270 + /* Instaclock registers (corerev >= 10) */
6271 + uint32 system_clk_ctl; /* 0xc0 */
6272 + uint32 clkstatestretch;
6273 + uint32 PAD[14];
6274 +
6275 + /* ExtBus control registers (corerev >= 3) */
6276 + uint32 pcmcia_config; /* 0x100 */
6277 + uint32 pcmcia_memwait;
6278 + uint32 pcmcia_attrwait;
6279 + uint32 pcmcia_iowait;
6280 + uint32 ide_config;
6281 + uint32 ide_memwait;
6282 + uint32 ide_attrwait;
6283 + uint32 ide_iowait;
6284 + uint32 prog_config;
6285 + uint32 prog_waitcount;
6286 + uint32 flash_config;
6287 + uint32 flash_waitcount;
6288 + uint32 PAD[116];
6289 +
6290 + /* uarts */
6291 + uint8 uart0data; /* 0x300 */
6292 + uint8 uart0imr;
6293 + uint8 uart0fcr;
6294 + uint8 uart0lcr;
6295 + uint8 uart0mcr;
6296 + uint8 uart0lsr;
6297 + uint8 uart0msr;
6298 + uint8 uart0scratch;
6299 + uint8 PAD[248]; /* corerev >= 1 */
6300 +
6301 + uint8 uart1data; /* 0x400 */
6302 + uint8 uart1imr;
6303 + uint8 uart1fcr;
6304 + uint8 uart1lcr;
6305 + uint8 uart1mcr;
6306 + uint8 uart1lsr;
6307 + uint8 uart1msr;
6308 + uint8 uart1scratch;
6309 +} chipcregs_t;
6310 +
6311 +#endif /* _LANGUAGE_ASSEMBLY */
6312 +
6313 +#define CC_CHIPID 0
6314 +#define CC_CAPABILITIES 4
6315 +#define CC_JTAGCMD 0x30
6316 +#define CC_JTAGIR 0x34
6317 +#define CC_JTAGDR 0x38
6318 +#define CC_JTAGCTRL 0x3c
6319 +#define CC_CLKDIV 0xa4
6320 +#define CC_OTP 0x800
6321 +
6322 +/* chipid */
6323 +#define CID_ID_MASK 0x0000ffff /* Chip Id mask */
6324 +#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */
6325 +#define CID_REV_SHIFT 16 /* Chip Revision shift */
6326 +#define CID_PKG_MASK 0x00f00000 /* Package Option mask */
6327 +#define CID_PKG_SHIFT 20 /* Package Option shift */
6328 +#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */
6329 +#define CID_CC_SHIFT 24
6330 +
6331 +/* capabilities */
6332 +#define CAP_UARTS_MASK 0x00000003 /* Number of uarts */
6333 +#define CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */
6334 +#define CAP_UCLKSEL 0x00000018 /* UARTs clock select */
6335 +#define CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */
6336 +#define CAP_UARTGPIO 0x00000020 /* UARTs own Gpio's 15:12 */
6337 +#define CAP_EXTBUS 0x00000040 /* External bus present */
6338 +#define CAP_FLASH_MASK 0x00000700 /* Type of flash */
6339 +#define CAP_PLL_MASK 0x00038000 /* Type of PLL */
6340 +#define CAP_PWR_CTL 0x00040000 /* Power control */
6341 +#define CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */
6342 +#define CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */
6343 +#define CAP_JTAGP 0x00400000 /* JTAG Master Present */
6344 +#define CAP_ROM 0x00800000 /* Internal boot rom active */
6345 +
6346 +/* PLL type */
6347 +#define PLL_NONE 0x00000000
6348 +#define PLL_TYPE1 0x00010000 /* 48Mhz base, 3 dividers */
6349 +#define PLL_TYPE2 0x00020000 /* 48Mhz, 4 dividers */
6350 +#define PLL_TYPE3 0x00030000 /* 25Mhz, 2 dividers */
6351 +#define PLL_TYPE4 0x00008000 /* 48Mhz, 4 dividers */
6352 +#define PLL_TYPE5 0x00018000 /* 25Mhz, 4 dividers */
6353 +#define PLL_TYPE6 0x00028000 /* 100/200 or 120/240 only */
6354 +#define PLL_TYPE7 0x00038000 /* 25Mhz, 4 dividers */
6355 +
6356 +/* corecontrol */
6357 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */
6358 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
6359 +
6360 +/* jtagcmd */
6361 +#define JCMD_START 0x80000000
6362 +#define JCMD_BUSY 0x80000000
6363 +#define JCMD_PAUSE 0x40000000
6364 +#define JCMD0_ACC_MASK 0x0000f000
6365 +#define JCMD0_ACC_IRDR 0x00000000
6366 +#define JCMD0_ACC_DR 0x00001000
6367 +#define JCMD0_ACC_IR 0x00002000
6368 +#define JCMD0_ACC_RESET 0x00003000
6369 +#define JCMD0_ACC_IRPDR 0x00004000
6370 +#define JCMD0_ACC_PDR 0x00005000
6371 +#define JCMD0_IRW_MASK 0x00000f00
6372 +#define JCMD_ACC_MASK 0x000f0000 /* Changes for corerev 11 */
6373 +#define JCMD_ACC_IRDR 0x00000000
6374 +#define JCMD_ACC_DR 0x00010000
6375 +#define JCMD_ACC_IR 0x00020000
6376 +#define JCMD_ACC_RESET 0x00030000
6377 +#define JCMD_ACC_IRPDR 0x00040000
6378 +#define JCMD_ACC_PDR 0x00050000
6379 +#define JCMD_IRW_MASK 0x00001f00
6380 +#define JCMD_IRW_SHIFT 8
6381 +#define JCMD_DRW_MASK 0x0000003f
6382 +
6383 +/* jtagctrl */
6384 +#define JCTRL_FORCE_CLK 4 /* Force clock */
6385 +#define JCTRL_EXT_EN 2 /* Enable external targets */
6386 +#define JCTRL_EN 1 /* Enable Jtag master */
6387 +
6388 +/* Fields in clkdiv */
6389 +#define CLKD_SFLASH 0x0f000000
6390 +#define CLKD_SFLASH_SHIFT 24
6391 +#define CLKD_OTP 0x000f0000
6392 +#define CLKD_OTP_SHIFT 16
6393 +#define CLKD_JTAG 0x00000f00
6394 +#define CLKD_JTAG_SHIFT 8
6395 +#define CLKD_UART 0x000000ff
6396 +
6397 +/* intstatus/intmask */
6398 +#define CI_GPIO 0x00000001 /* gpio intr */
6399 +#define CI_EI 0x00000002 /* ro: ext intr pin (corerev >= 3) */
6400 +#define CI_WDRESET 0x80000000 /* watchdog reset occurred */
6401 +
6402 +/* slow_clk_ctl */
6403 +#define SCC_SS_MASK 0x00000007 /* slow clock source mask */
6404 +#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */
6405 +#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */
6406 +#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */
6407 +#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */
6408 +#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */
6409 +#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */
6410 +#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */
6411 +#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */
6412 +#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */
6413 +#define SCC_CD_MASK 0xffff0000 /* ClockDivider mask, SlowClk = 1/(4+divisor) * crystal/PCI clock */
6414 +#define SCC_CD_SHF 16 /* CLockDivider shift */
6415 +
6416 +/* sys_clk_ctl */
6417 +#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */
6418 +#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */
6419 +#define SYCC_FP 0x00000004 /* ForcePLLOn */
6420 +#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */
6421 +#define SYCC_HR 0x00000010 /* Force HT */
6422 +#define SYCC_CD_MASK 0xffff0000 /* ClockDivider mask, SlowClk = 1/(4+divisor) * crystal/PCI clock */
6423 +#define SYCC_CD_SHF 16 /* CLockDivider shift */
6424 +
6425 +/* clockcontrol_n */
6426 +#define CN_N1_MASK 0x3f /* n1 control */
6427 +#define CN_N2_MASK 0x3f00 /* n2 control */
6428 +#define CN_N2_SHIFT 8
6429 +#define CN_PLLC_MASK 0xf0000 /* pll control */
6430 +#define CN_PLLC_SHIFT 16
6431 +
6432 +/* clockcontrol_sb/pci/uart */
6433 +#define CC_M1_MASK 0x3f /* m1 control */
6434 +#define CC_M2_MASK 0x3f00 /* m2 control */
6435 +#define CC_M2_SHIFT 8
6436 +#define CC_M3_MASK 0x3f0000 /* m3 control */
6437 +#define CC_M3_SHIFT 16
6438 +#define CC_MC_MASK 0x1f000000 /* mux control */
6439 +#define CC_MC_SHIFT 24
6440 +
6441 +/* N3M Clock control values for 125Mhz */
6442 +#define CC_125_N 0x0802 /* Default values for bcm4310 */
6443 +#define CC_125_M 0x04020009
6444 +#define CC_125_M25 0x11090009
6445 +#define CC_125_M33 0x11090005
6446 +
6447 +/* N3M Clock control magic field values */
6448 +#define CC_F6_2 0x02 /* A factor of 2 in */
6449 +#define CC_F6_3 0x03 /* 6-bit fields like */
6450 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
6451 +#define CC_F6_5 0x09
6452 +#define CC_F6_6 0x11
6453 +#define CC_F6_7 0x21
6454 +
6455 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
6456 +
6457 +#define CC_MC_BYPASS 0x08
6458 +#define CC_MC_M1 0x04
6459 +#define CC_MC_M1M2 0x02
6460 +#define CC_MC_M1M2M3 0x01
6461 +#define CC_MC_M1M3 0x11
6462 +
6463 +/* Type 2 Clock control magic field values */
6464 +#define CC_T2_BIAS 2 /* n1, n2, m1 & m3 bias */
6465 +#define CC_T2M2_BIAS 3 /* m2 bias */
6466 +
6467 +#define CC_T2MC_M1BYP 1
6468 +#define CC_T2MC_M2BYP 2
6469 +#define CC_T2MC_M3BYP 4
6470 +
6471 +/* Type 6 Clock control magic field values */
6472 +#define CC_T6_MMASK 1 /* bits of interest in m */
6473 +#define CC_T6_M0 120000000 /* sb clock for m = 0 */
6474 +#define CC_T6_M1 100000000 /* sb clock for m = 1 */
6475 +#define SB2MIPS_T6(sb) (2 * (sb))
6476 +
6477 +/* Common clock base */
6478 +#define CC_CLOCK_BASE1 24000000 /* Half the clock freq */
6479 +#define CC_CLOCK_BASE2 12500000 /* Alternate crystal on some PLL's */
6480 +
6481 +/* Flash types in the chipcommon capabilities register */
6482 +#define FLASH_NONE 0x000 /* No flash */
6483 +#define SFLASH_ST 0x100 /* ST serial flash */
6484 +#define SFLASH_AT 0x200 /* Atmel serial flash */
6485 +#define PFLASH 0x700 /* Parallel flash */
6486 +
6487 +/* Bits in the config registers */
6488 +#define CC_CFG_EN 0x0001 /* Enable */
6489 +#define CC_CFG_EM_MASK 0x000e /* Extif Mode */
6490 +#define CC_CFG_EM_ASYNC 0x0002 /* Async/Parallel flash */
6491 +#define CC_CFG_EM_SYNC 0x0004 /* Synchronous */
6492 +#define CC_CFG_EM_PCMCIA 0x0008 /* PCMCIA */
6493 +#define CC_CFG_EM_IDE 0x000a /* IDE */
6494 +#define CC_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
6495 +#define CC_CFG_CD_MASK 0x0060 /* Sync: Clock divisor */
6496 +#define CC_CFG_CE 0x0080 /* Sync: Clock enable */
6497 +#define CC_CFG_SB 0x0100 /* Sync: Size/Bytestrobe */
6498 +
6499 +/* Start/busy bit in flashcontrol */
6500 +#define SFLASH_START 0x80000000
6501 +#define SFLASH_BUSY SFLASH_START
6502 +
6503 +/* flashcontrol opcodes for ST flashes */
6504 +#define SFLASH_ST_WREN 0x0006 /* Write Enable */
6505 +#define SFLASH_ST_WRDIS 0x0004 /* Write Disable */
6506 +#define SFLASH_ST_RDSR 0x0105 /* Read Status Register */
6507 +#define SFLASH_ST_WRSR 0x0101 /* Write Status Register */
6508 +#define SFLASH_ST_READ 0x0303 /* Read Data Bytes */
6509 +#define SFLASH_ST_PP 0x0302 /* Page Program */
6510 +#define SFLASH_ST_SE 0x02d8 /* Sector Erase */
6511 +#define SFLASH_ST_BE 0x00c7 /* Bulk Erase */
6512 +#define SFLASH_ST_DP 0x00b9 /* Deep Power-down */
6513 +#define SFLASH_ST_RES 0x03ab /* Read Electronic Signature */
6514 +
6515 +/* Status register bits for ST flashes */
6516 +#define SFLASH_ST_WIP 0x01 /* Write In Progress */
6517 +#define SFLASH_ST_WEL 0x02 /* Write Enable Latch */
6518 +#define SFLASH_ST_BP_MASK 0x1c /* Block Protect */
6519 +#define SFLASH_ST_BP_SHIFT 2
6520 +#define SFLASH_ST_SRWD 0x80 /* Status Register Write Disable */
6521 +
6522 +/* flashcontrol opcodes for Atmel flashes */
6523 +#define SFLASH_AT_READ 0x07e8
6524 +#define SFLASH_AT_PAGE_READ 0x07d2
6525 +#define SFLASH_AT_BUF1_READ
6526 +#define SFLASH_AT_BUF2_READ
6527 +#define SFLASH_AT_STATUS 0x01d7
6528 +#define SFLASH_AT_BUF1_WRITE 0x0384
6529 +#define SFLASH_AT_BUF2_WRITE 0x0387
6530 +#define SFLASH_AT_BUF1_ERASE_PROGRAM 0x0283
6531 +#define SFLASH_AT_BUF2_ERASE_PROGRAM 0x0286
6532 +#define SFLASH_AT_BUF1_PROGRAM 0x0288
6533 +#define SFLASH_AT_BUF2_PROGRAM 0x0289
6534 +#define SFLASH_AT_PAGE_ERASE 0x0281
6535 +#define SFLASH_AT_BLOCK_ERASE 0x0250
6536 +#define SFLASH_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382
6537 +#define SFLASH_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385
6538 +#define SFLASH_AT_BUF1_LOAD 0x0253
6539 +#define SFLASH_AT_BUF2_LOAD 0x0255
6540 +#define SFLASH_AT_BUF1_COMPARE 0x0260
6541 +#define SFLASH_AT_BUF2_COMPARE 0x0261
6542 +#define SFLASH_AT_BUF1_REPROGRAM 0x0258
6543 +#define SFLASH_AT_BUF2_REPROGRAM 0x0259
6544 +
6545 +/* Status register bits for Atmel flashes */
6546 +#define SFLASH_AT_READY 0x80
6547 +#define SFLASH_AT_MISMATCH 0x40
6548 +#define SFLASH_AT_ID_MASK 0x38
6549 +#define SFLASH_AT_ID_SHIFT 3
6550 +
6551 +/* OTP conventions */
6552 +#define OTP_HWBASE 0
6553 +#define OTP_SWLIM 256
6554 +#define OTP_CIDBASE 256
6555 +#define OTP_CIDLIM 260
6556 +
6557 +#define OTP_BOUNDARY 252
6558 +#define OTP_HWSIGN 253
6559 +#define OTP_SWSIGN 254
6560 +#define OTP_CIDSIGN 255
6561 +
6562 +#define OTP_CID 256
6563 +#define OTP_PKG 257
6564 +#define OTP_FID 258
6565 +
6566 +#define OTP_SIGNATURE 0x578a
6567 +#define OTP_MAGIC 0x4e56
6568 +
6569 +#endif /* _SBCHIPC_H */
6570 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbconfig.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbconfig.h
6571 --- linux-2.4.30/arch/mips/bcm947xx/include/sbconfig.h 1970-01-01 01:00:00.000000000 +0100
6572 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbconfig.h 2005-02-02 23:16:40.000000000 +0100
6573 @@ -0,0 +1,324 @@
6574 +/*
6575 + * Broadcom SiliconBackplane hardware register definitions.
6576 + *
6577 + * Copyright 2005, Broadcom Corporation
6578 + * All Rights Reserved.
6579 + *
6580 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6581 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6582 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6583 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6584 + * $Id$
6585 + */
6586 +
6587 +#ifndef _SBCONFIG_H
6588 +#define _SBCONFIG_H
6589 +
6590 +/* cpp contortions to concatenate w/arg prescan */
6591 +#ifndef PAD
6592 +#define _PADLINE(line) pad ## line
6593 +#define _XSTR(line) _PADLINE(line)
6594 +#define PAD _XSTR(__LINE__)
6595 +#endif
6596 +
6597 +/*
6598 + * SiliconBackplane Address Map.
6599 + * All regions may not exist on all chips.
6600 + */
6601 +#define SB_SDRAM_BASE 0x00000000 /* Physical SDRAM */
6602 +#define SB_PCI_MEM 0x08000000 /* Host Mode sb2pcitranslation0 (64 MB) */
6603 +#define SB_PCI_CFG 0x0c000000 /* Host Mode sb2pcitranslation1 (64 MB) */
6604 +#define SB_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
6605 +#define SB_ENUM_BASE 0x18000000 /* Enumeration space base */
6606 +#define SB_ENUM_LIM 0x18010000 /* Enumeration space limit */
6607 +
6608 +#define SB_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
6609 +#define SB_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
6610 +
6611 +#define SB_EXTIF_BASE 0x1f000000 /* External Interface region base address */
6612 +#define SB_FLASH1 0x1fc00000 /* Flash Region 1 */
6613 +#define SB_FLASH1_SZ 0x00400000 /* Size of Flash Region 1 */
6614 +
6615 +#define SB_PCI_DMA 0x40000000 /* Client Mode sb2pcitranslation2 (1 GB) */
6616 +#define SB_PCI_DMA_SZ 0x40000000 /* Client Mode sb2pcitranslation2 size in bytes */
6617 +#define SB_EUART (SB_EXTIF_BASE + 0x00800000)
6618 +#define SB_LED (SB_EXTIF_BASE + 0x00900000)
6619 +
6620 +/* enumeration space related defs */
6621 +#define SB_CORE_SIZE 0x1000 /* each core gets 4Kbytes for registers */
6622 +#define SB_MAXCORES ((SB_ENUM_LIM - SB_ENUM_BASE)/SB_CORE_SIZE)
6623 +#define SBCONFIGOFF 0xf00 /* core sbconfig regs are top 256bytes of regs */
6624 +#define SBCONFIGSIZE 256 /* sizeof (sbconfig_t) */
6625 +
6626 +/* mips address */
6627 +#define SB_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
6628 +
6629 +/*
6630 + * Sonics Configuration Space Registers.
6631 + */
6632 +#define SBIPSFLAG 0x08
6633 +#define SBTPSFLAG 0x18
6634 +#define SBTMERRLOGA 0x48 /* sonics >= 2.3 */
6635 +#define SBTMERRLOG 0x50 /* sonics >= 2.3 */
6636 +#define SBADMATCH3 0x60
6637 +#define SBADMATCH2 0x68
6638 +#define SBADMATCH1 0x70
6639 +#define SBIMSTATE 0x90
6640 +#define SBINTVEC 0x94
6641 +#define SBTMSTATELOW 0x98
6642 +#define SBTMSTATEHIGH 0x9c
6643 +#define SBBWA0 0xa0
6644 +#define SBIMCONFIGLOW 0xa8
6645 +#define SBIMCONFIGHIGH 0xac
6646 +#define SBADMATCH0 0xb0
6647 +#define SBTMCONFIGLOW 0xb8
6648 +#define SBTMCONFIGHIGH 0xbc
6649 +#define SBBCONFIG 0xc0
6650 +#define SBBSTATE 0xc8
6651 +#define SBACTCNFG 0xd8
6652 +#define SBFLAGST 0xe8
6653 +#define SBIDLOW 0xf8
6654 +#define SBIDHIGH 0xfc
6655 +
6656 +#ifndef _LANGUAGE_ASSEMBLY
6657 +
6658 +typedef volatile struct _sbconfig {
6659 + uint32 PAD[2];
6660 + uint32 sbipsflag; /* initiator port ocp slave flag */
6661 + uint32 PAD[3];
6662 + uint32 sbtpsflag; /* target port ocp slave flag */
6663 + uint32 PAD[11];
6664 + uint32 sbtmerrloga; /* (sonics >= 2.3) */
6665 + uint32 PAD;
6666 + uint32 sbtmerrlog; /* (sonics >= 2.3) */
6667 + uint32 PAD[3];
6668 + uint32 sbadmatch3; /* address match3 */
6669 + uint32 PAD;
6670 + uint32 sbadmatch2; /* address match2 */
6671 + uint32 PAD;
6672 + uint32 sbadmatch1; /* address match1 */
6673 + uint32 PAD[7];
6674 + uint32 sbimstate; /* initiator agent state */
6675 + uint32 sbintvec; /* interrupt mask */
6676 + uint32 sbtmstatelow; /* target state */
6677 + uint32 sbtmstatehigh; /* target state */
6678 + uint32 sbbwa0; /* bandwidth allocation table0 */
6679 + uint32 PAD;
6680 + uint32 sbimconfiglow; /* initiator configuration */
6681 + uint32 sbimconfighigh; /* initiator configuration */
6682 + uint32 sbadmatch0; /* address match0 */
6683 + uint32 PAD;
6684 + uint32 sbtmconfiglow; /* target configuration */
6685 + uint32 sbtmconfighigh; /* target configuration */
6686 + uint32 sbbconfig; /* broadcast configuration */
6687 + uint32 PAD;
6688 + uint32 sbbstate; /* broadcast state */
6689 + uint32 PAD[3];
6690 + uint32 sbactcnfg; /* activate configuration */
6691 + uint32 PAD[3];
6692 + uint32 sbflagst; /* current sbflags */
6693 + uint32 PAD[3];
6694 + uint32 sbidlow; /* identification */
6695 + uint32 sbidhigh; /* identification */
6696 +} sbconfig_t;
6697 +
6698 +#endif /* _LANGUAGE_ASSEMBLY */
6699 +
6700 +/* sbipsflag */
6701 +#define SBIPS_INT1_MASK 0x3f /* which sbflags get routed to mips interrupt 1 */
6702 +#define SBIPS_INT1_SHIFT 0
6703 +#define SBIPS_INT2_MASK 0x3f00 /* which sbflags get routed to mips interrupt 2 */
6704 +#define SBIPS_INT2_SHIFT 8
6705 +#define SBIPS_INT3_MASK 0x3f0000 /* which sbflags get routed to mips interrupt 3 */
6706 +#define SBIPS_INT3_SHIFT 16
6707 +#define SBIPS_INT4_MASK 0x3f000000 /* which sbflags get routed to mips interrupt 4 */
6708 +#define SBIPS_INT4_SHIFT 24
6709 +
6710 +/* sbtpsflag */
6711 +#define SBTPS_NUM0_MASK 0x3f /* interrupt sbFlag # generated by this core */
6712 +#define SBTPS_F0EN0 0x40 /* interrupt is always sent on the backplane */
6713 +
6714 +/* sbtmerrlog */
6715 +#define SBTMEL_CM 0x00000007 /* command */
6716 +#define SBTMEL_CI 0x0000ff00 /* connection id */
6717 +#define SBTMEL_EC 0x0f000000 /* error code */
6718 +#define SBTMEL_ME 0x80000000 /* multiple error */
6719 +
6720 +/* sbimstate */
6721 +#define SBIM_PC 0xf /* pipecount */
6722 +#define SBIM_AP_MASK 0x30 /* arbitration policy */
6723 +#define SBIM_AP_BOTH 0x00 /* use both timeslaces and token */
6724 +#define SBIM_AP_TS 0x10 /* use timesliaces only */
6725 +#define SBIM_AP_TK 0x20 /* use token only */
6726 +#define SBIM_AP_RSV 0x30 /* reserved */
6727 +#define SBIM_IBE 0x20000 /* inbanderror */
6728 +#define SBIM_TO 0x40000 /* timeout */
6729 +#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */
6730 +#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */
6731 +
6732 +/* sbtmstatelow */
6733 +#define SBTML_RESET 0x1 /* reset */
6734 +#define SBTML_REJ 0x2 /* reject */
6735 +#define SBTML_CLK 0x10000 /* clock enable */
6736 +#define SBTML_FGC 0x20000 /* force gated clocks on */
6737 +#define SBTML_FL_MASK 0x3ffc0000 /* core-specific flags */
6738 +#define SBTML_PE 0x40000000 /* pme enable */
6739 +#define SBTML_BE 0x80000000 /* bist enable */
6740 +
6741 +/* sbtmstatehigh */
6742 +#define SBTMH_SERR 0x1 /* serror */
6743 +#define SBTMH_INT 0x2 /* interrupt */
6744 +#define SBTMH_BUSY 0x4 /* busy */
6745 +#define SBTMH_TO 0x00000020 /* timeout (sonics >= 2.3) */
6746 +#define SBTMH_FL_MASK 0x1fff0000 /* core-specific flags */
6747 +#define SBTMH_GCR 0x20000000 /* gated clock request */
6748 +#define SBTMH_BISTF 0x40000000 /* bist failed */
6749 +#define SBTMH_BISTD 0x80000000 /* bist done */
6750 +
6751 +/* sbbwa0 */
6752 +#define SBBWA_TAB0_MASK 0xffff /* lookup table 0 */
6753 +#define SBBWA_TAB1_MASK 0xffff /* lookup table 1 */
6754 +#define SBBWA_TAB1_SHIFT 16
6755 +
6756 +/* sbimconfiglow */
6757 +#define SBIMCL_STO_MASK 0x7 /* service timeout */
6758 +#define SBIMCL_RTO_MASK 0x70 /* request timeout */
6759 +#define SBIMCL_RTO_SHIFT 4
6760 +#define SBIMCL_CID_MASK 0xff0000 /* connection id */
6761 +#define SBIMCL_CID_SHIFT 16
6762 +
6763 +/* sbimconfighigh */
6764 +#define SBIMCH_IEM_MASK 0xc /* inband error mode */
6765 +#define SBIMCH_TEM_MASK 0x30 /* timeout error mode */
6766 +#define SBIMCH_TEM_SHIFT 4
6767 +#define SBIMCH_BEM_MASK 0xc0 /* bus error mode */
6768 +#define SBIMCH_BEM_SHIFT 6
6769 +
6770 +/* sbadmatch0 */
6771 +#define SBAM_TYPE_MASK 0x3 /* address type */
6772 +#define SBAM_AD64 0x4 /* reserved */
6773 +#define SBAM_ADINT0_MASK 0xf8 /* type0 size */
6774 +#define SBAM_ADINT0_SHIFT 3
6775 +#define SBAM_ADINT1_MASK 0x1f8 /* type1 size */
6776 +#define SBAM_ADINT1_SHIFT 3
6777 +#define SBAM_ADINT2_MASK 0x1f8 /* type2 size */
6778 +#define SBAM_ADINT2_SHIFT 3
6779 +#define SBAM_ADEN 0x400 /* enable */
6780 +#define SBAM_ADNEG 0x800 /* negative decode */
6781 +#define SBAM_BASE0_MASK 0xffffff00 /* type0 base address */
6782 +#define SBAM_BASE0_SHIFT 8
6783 +#define SBAM_BASE1_MASK 0xfffff000 /* type1 base address for the core */
6784 +#define SBAM_BASE1_SHIFT 12
6785 +#define SBAM_BASE2_MASK 0xffff0000 /* type2 base address for the core */
6786 +#define SBAM_BASE2_SHIFT 16
6787 +
6788 +/* sbtmconfiglow */
6789 +#define SBTMCL_CD_MASK 0xff /* clock divide */
6790 +#define SBTMCL_CO_MASK 0xf800 /* clock offset */
6791 +#define SBTMCL_CO_SHIFT 11
6792 +#define SBTMCL_IF_MASK 0xfc0000 /* interrupt flags */
6793 +#define SBTMCL_IF_SHIFT 18
6794 +#define SBTMCL_IM_MASK 0x3000000 /* interrupt mode */
6795 +#define SBTMCL_IM_SHIFT 24
6796 +
6797 +/* sbtmconfighigh */
6798 +#define SBTMCH_BM_MASK 0x3 /* busy mode */
6799 +#define SBTMCH_RM_MASK 0x3 /* retry mode */
6800 +#define SBTMCH_RM_SHIFT 2
6801 +#define SBTMCH_SM_MASK 0x30 /* stop mode */
6802 +#define SBTMCH_SM_SHIFT 4
6803 +#define SBTMCH_EM_MASK 0x300 /* sb error mode */
6804 +#define SBTMCH_EM_SHIFT 8
6805 +#define SBTMCH_IM_MASK 0xc00 /* int mode */
6806 +#define SBTMCH_IM_SHIFT 10
6807 +
6808 +/* sbbconfig */
6809 +#define SBBC_LAT_MASK 0x3 /* sb latency */
6810 +#define SBBC_MAX0_MASK 0xf0000 /* maxccntr0 */
6811 +#define SBBC_MAX0_SHIFT 16
6812 +#define SBBC_MAX1_MASK 0xf00000 /* maxccntr1 */
6813 +#define SBBC_MAX1_SHIFT 20
6814 +
6815 +/* sbbstate */
6816 +#define SBBS_SRD 0x1 /* st reg disable */
6817 +#define SBBS_HRD 0x2 /* hold reg disable */
6818 +
6819 +/* sbidlow */
6820 +#define SBIDL_CS_MASK 0x3 /* config space */
6821 +#define SBIDL_AR_MASK 0x38 /* # address ranges supported */
6822 +#define SBIDL_AR_SHIFT 3
6823 +#define SBIDL_SYNCH 0x40 /* sync */
6824 +#define SBIDL_INIT 0x80 /* initiator */
6825 +#define SBIDL_MINLAT_MASK 0xf00 /* minimum backplane latency */
6826 +#define SBIDL_MINLAT_SHIFT 8
6827 +#define SBIDL_MAXLAT 0xf000 /* maximum backplane latency */
6828 +#define SBIDL_MAXLAT_SHIFT 12
6829 +#define SBIDL_FIRST 0x10000 /* this initiator is first */
6830 +#define SBIDL_CW_MASK 0xc0000 /* cycle counter width */
6831 +#define SBIDL_CW_SHIFT 18
6832 +#define SBIDL_TP_MASK 0xf00000 /* target ports */
6833 +#define SBIDL_TP_SHIFT 20
6834 +#define SBIDL_IP_MASK 0xf000000 /* initiator ports */
6835 +#define SBIDL_IP_SHIFT 24
6836 +#define SBIDL_RV_MASK 0xf0000000 /* sonics backplane revision code */
6837 +#define SBIDL_RV_SHIFT 28
6838 +
6839 +/* sbidhigh */
6840 +#define SBIDH_RC_MASK 0xf /* revision code*/
6841 +#define SBIDH_CC_MASK 0xfff0 /* core code */
6842 +#define SBIDH_CC_SHIFT 4
6843 +#define SBIDH_VC_MASK 0xffff0000 /* vendor code */
6844 +#define SBIDH_VC_SHIFT 16
6845 +
6846 +#define SB_COMMIT 0xfd8 /* update buffered registers value */
6847 +
6848 +/* vendor codes */
6849 +#define SB_VEND_BCM 0x4243 /* Broadcom's SB vendor code */
6850 +
6851 +/* core codes */
6852 +#define SB_CC 0x800 /* chipcommon core */
6853 +#define SB_ILINE20 0x801 /* iline20 core */
6854 +#define SB_SDRAM 0x803 /* sdram core */
6855 +#define SB_PCI 0x804 /* pci core */
6856 +#define SB_MIPS 0x805 /* mips core */
6857 +#define SB_ENET 0x806 /* enet mac core */
6858 +#define SB_CODEC 0x807 /* v90 codec core */
6859 +#define SB_USB 0x808 /* usb 1.1 host/device core */
6860 +#define SB_ADSL 0x809 /* ADSL core */
6861 +#define SB_ILINE100 0x80a /* iline100 core */
6862 +#define SB_IPSEC 0x80b /* ipsec core */
6863 +#define SB_PCMCIA 0x80d /* pcmcia core */
6864 +#define SB_SOCRAM 0x80e /* internal memory core */
6865 +#define SB_MEMC 0x80f /* memc sdram core */
6866 +#define SB_EXTIF 0x811 /* external interface core */
6867 +#define SB_D11 0x812 /* 802.11 MAC core */
6868 +#define SB_MIPS33 0x816 /* mips3302 core */
6869 +#define SB_USB11H 0x817 /* usb 1.1 host core */
6870 +#define SB_USB11D 0x818 /* usb 1.1 device core */
6871 +#define SB_USB20H 0x819 /* usb 2.0 host core */
6872 +#define SB_USB20D 0x81a /* usb 2.0 device core */
6873 +#define SB_SDIOH 0x81b /* sdio host core */
6874 +#define SB_ROBO 0x81c /* roboswitch core */
6875 +#define SB_ATA100 0x81d /* parallel ATA core */
6876 +#define SB_SATAXOR 0x81e /* serial ATA & XOR DMA core */
6877 +#define SB_GIGETH 0x81f /* gigabit ethernet core */
6878 +
6879 +/* Not really related to Silicon Backplane, but a couple of software
6880 + * conventions for the use the flash space:
6881 + */
6882 +
6883 +/* Minumum amount of flash we support */
6884 +#define FLASH_MIN 0x00020000 /* Minimum flash size */
6885 +
6886 +/* A boot/binary may have an embedded block that describes its size */
6887 +#define BISZ_OFFSET 0x3e0 /* At this offset into the binary */
6888 +#define BISZ_MAGIC 0x4249535a /* Marked with this value: 'BISZ' */
6889 +#define BISZ_MAGIC_IDX 0 /* Word 0: magic */
6890 +#define BISZ_TXTST_IDX 1 /* 1: text start */
6891 +#define BISZ_TXTEND_IDX 2 /* 2: text start */
6892 +#define BISZ_DATAST_IDX 3 /* 3: text start */
6893 +#define BISZ_DATAEND_IDX 4 /* 4: text start */
6894 +#define BISZ_BSSST_IDX 5 /* 5: text start */
6895 +#define BISZ_BSSEND_IDX 6 /* 6: text start */
6896 +
6897 +#endif /* _SBCONFIG_H */
6898 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbextif.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbextif.h
6899 --- linux-2.4.30/arch/mips/bcm947xx/include/sbextif.h 1970-01-01 01:00:00.000000000 +0100
6900 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbextif.h 2005-02-02 23:16:40.000000000 +0100
6901 @@ -0,0 +1,242 @@
6902 +/*
6903 + * Hardware-specific External Interface I/O core definitions
6904 + * for the BCM47xx family of SiliconBackplane-based chips.
6905 + *
6906 + * The External Interface core supports a total of three external chip selects
6907 + * supporting external interfaces. One of the external chip selects is
6908 + * used for Flash, one is used for PCMCIA, and the other may be
6909 + * programmed to support either a synchronous interface or an
6910 + * asynchronous interface. The asynchronous interface can be used to
6911 + * support external devices such as UARTs and the BCM2019 Bluetooth
6912 + * baseband processor.
6913 + * The external interface core also contains 2 on-chip 16550 UARTs, clock
6914 + * frequency control, a watchdog interrupt timer, and a GPIO interface.
6915 + *
6916 + * Copyright 2005, Broadcom Corporation
6917 + * All Rights Reserved.
6918 + *
6919 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6920 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6921 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6922 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6923 + * $Id$
6924 + */
6925 +
6926 +#ifndef _SBEXTIF_H
6927 +#define _SBEXTIF_H
6928 +
6929 +/* external interface address space */
6930 +#define EXTIF_PCMCIA_MEMBASE(x) (x)
6931 +#define EXTIF_PCMCIA_IOBASE(x) ((x) + 0x100000)
6932 +#define EXTIF_PCMCIA_CFGBASE(x) ((x) + 0x200000)
6933 +#define EXTIF_CFGIF_BASE(x) ((x) + 0x800000)
6934 +#define EXTIF_FLASH_BASE(x) ((x) + 0xc00000)
6935 +
6936 +/* cpp contortions to concatenate w/arg prescan */
6937 +#ifndef PAD
6938 +#define _PADLINE(line) pad ## line
6939 +#define _XSTR(line) _PADLINE(line)
6940 +#define PAD _XSTR(__LINE__)
6941 +#endif /* PAD */
6942 +
6943 +/*
6944 + * The multiple instances of output and output enable registers
6945 + * are present to allow driver software for multiple cores to control
6946 + * gpio outputs without needing to share a single register pair.
6947 + */
6948 +struct gpiouser {
6949 + uint32 out;
6950 + uint32 outen;
6951 +};
6952 +#define NGPIOUSER 5
6953 +
6954 +typedef volatile struct {
6955 + uint32 corecontrol;
6956 + uint32 extstatus;
6957 + uint32 PAD[2];
6958 +
6959 + /* pcmcia control registers */
6960 + uint32 pcmcia_config;
6961 + uint32 pcmcia_memwait;
6962 + uint32 pcmcia_attrwait;
6963 + uint32 pcmcia_iowait;
6964 +
6965 + /* programmable interface control registers */
6966 + uint32 prog_config;
6967 + uint32 prog_waitcount;
6968 +
6969 + /* flash control registers */
6970 + uint32 flash_config;
6971 + uint32 flash_waitcount;
6972 + uint32 PAD[4];
6973 +
6974 + uint32 watchdog;
6975 +
6976 + /* clock control */
6977 + uint32 clockcontrol_n;
6978 + uint32 clockcontrol_sb;
6979 + uint32 clockcontrol_pci;
6980 + uint32 clockcontrol_mii;
6981 + uint32 PAD[3];
6982 +
6983 + /* gpio */
6984 + uint32 gpioin;
6985 + struct gpiouser gpio[NGPIOUSER];
6986 + uint32 PAD;
6987 + uint32 ejtagouten;
6988 + uint32 gpiointpolarity;
6989 + uint32 gpiointmask;
6990 + uint32 PAD[153];
6991 +
6992 + uint8 uartdata;
6993 + uint8 PAD[3];
6994 + uint8 uartimer;
6995 + uint8 PAD[3];
6996 + uint8 uartfcr;
6997 + uint8 PAD[3];
6998 + uint8 uartlcr;
6999 + uint8 PAD[3];
7000 + uint8 uartmcr;
7001 + uint8 PAD[3];
7002 + uint8 uartlsr;
7003 + uint8 PAD[3];
7004 + uint8 uartmsr;
7005 + uint8 PAD[3];
7006 + uint8 uartscratch;
7007 + uint8 PAD[3];
7008 +} extifregs_t;
7009 +
7010 +/* corecontrol */
7011 +#define CC_UE (1 << 0) /* uart enable */
7012 +
7013 +/* extstatus */
7014 +#define ES_EM (1 << 0) /* endian mode (ro) */
7015 +#define ES_EI (1 << 1) /* external interrupt pin (ro) */
7016 +#define ES_GI (1 << 2) /* gpio interrupt pin (ro) */
7017 +
7018 +/* gpio bit mask */
7019 +#define GPIO_BIT0 (1 << 0)
7020 +#define GPIO_BIT1 (1 << 1)
7021 +#define GPIO_BIT2 (1 << 2)
7022 +#define GPIO_BIT3 (1 << 3)
7023 +#define GPIO_BIT4 (1 << 4)
7024 +#define GPIO_BIT5 (1 << 5)
7025 +#define GPIO_BIT6 (1 << 6)
7026 +#define GPIO_BIT7 (1 << 7)
7027 +
7028 +
7029 +/* pcmcia/prog/flash_config */
7030 +#define CF_EN (1 << 0) /* enable */
7031 +#define CF_EM_MASK 0xe /* mode */
7032 +#define CF_EM_SHIFT 1
7033 +#define CF_EM_FLASH 0x0 /* flash/asynchronous mode */
7034 +#define CF_EM_SYNC 0x2 /* synchronous mode */
7035 +#define CF_EM_PCMCIA 0x4 /* pcmcia mode */
7036 +#define CF_DS (1 << 4) /* destsize: 0=8bit, 1=16bit */
7037 +#define CF_BS (1 << 5) /* byteswap */
7038 +#define CF_CD_MASK 0xc0 /* clock divider */
7039 +#define CF_CD_SHIFT 6
7040 +#define CF_CD_DIV2 0x0 /* backplane/2 */
7041 +#define CF_CD_DIV3 0x40 /* backplane/3 */
7042 +#define CF_CD_DIV4 0x80 /* backplane/4 */
7043 +#define CF_CE (1 << 8) /* clock enable */
7044 +#define CF_SB (1 << 9) /* size/bytestrobe (synch only) */
7045 +
7046 +/* pcmcia_memwait */
7047 +#define PM_W0_MASK 0x3f /* waitcount0 */
7048 +#define PM_W1_MASK 0x1f00 /* waitcount1 */
7049 +#define PM_W1_SHIFT 8
7050 +#define PM_W2_MASK 0x1f0000 /* waitcount2 */
7051 +#define PM_W2_SHIFT 16
7052 +#define PM_W3_MASK 0x1f000000 /* waitcount3 */
7053 +#define PM_W3_SHIFT 24
7054 +
7055 +/* pcmcia_attrwait */
7056 +#define PA_W0_MASK 0x3f /* waitcount0 */
7057 +#define PA_W1_MASK 0x1f00 /* waitcount1 */
7058 +#define PA_W1_SHIFT 8
7059 +#define PA_W2_MASK 0x1f0000 /* waitcount2 */
7060 +#define PA_W2_SHIFT 16
7061 +#define PA_W3_MASK 0x1f000000 /* waitcount3 */
7062 +#define PA_W3_SHIFT 24
7063 +
7064 +/* pcmcia_iowait */
7065 +#define PI_W0_MASK 0x3f /* waitcount0 */
7066 +#define PI_W1_MASK 0x1f00 /* waitcount1 */
7067 +#define PI_W1_SHIFT 8
7068 +#define PI_W2_MASK 0x1f0000 /* waitcount2 */
7069 +#define PI_W2_SHIFT 16
7070 +#define PI_W3_MASK 0x1f000000 /* waitcount3 */
7071 +#define PI_W3_SHIFT 24
7072 +
7073 +/* prog_waitcount */
7074 +#define PW_W0_MASK 0x0000001f /* waitcount0 */
7075 +#define PW_W1_MASK 0x00001f00 /* waitcount1 */
7076 +#define PW_W1_SHIFT 8
7077 +#define PW_W2_MASK 0x001f0000 /* waitcount2 */
7078 +#define PW_W2_SHIFT 16
7079 +#define PW_W3_MASK 0x1f000000 /* waitcount3 */
7080 +#define PW_W3_SHIFT 24
7081 +
7082 +#define PW_W0 0x0000000c
7083 +#define PW_W1 0x00000a00
7084 +#define PW_W2 0x00020000
7085 +#define PW_W3 0x01000000
7086 +
7087 +/* flash_waitcount */
7088 +#define FW_W0_MASK 0x1f /* waitcount0 */
7089 +#define FW_W1_MASK 0x1f00 /* waitcount1 */
7090 +#define FW_W1_SHIFT 8
7091 +#define FW_W2_MASK 0x1f0000 /* waitcount2 */
7092 +#define FW_W2_SHIFT 16
7093 +#define FW_W3_MASK 0x1f000000 /* waitcount3 */
7094 +#define FW_W3_SHIFT 24
7095 +
7096 +/* watchdog */
7097 +#define WATCHDOG_CLOCK 48000000 /* Hz */
7098 +
7099 +/* clockcontrol_n */
7100 +#define CN_N1_MASK 0x3f /* n1 control */
7101 +#define CN_N2_MASK 0x3f00 /* n2 control */
7102 +#define CN_N2_SHIFT 8
7103 +
7104 +/* clockcontrol_sb/pci/mii */
7105 +#define CC_M1_MASK 0x3f /* m1 control */
7106 +#define CC_M2_MASK 0x3f00 /* m2 control */
7107 +#define CC_M2_SHIFT 8
7108 +#define CC_M3_MASK 0x3f0000 /* m3 control */
7109 +#define CC_M3_SHIFT 16
7110 +#define CC_MC_MASK 0x1f000000 /* mux control */
7111 +#define CC_MC_SHIFT 24
7112 +
7113 +/* Clock control default values */
7114 +#define CC_DEF_N 0x0009 /* Default values for bcm4710 */
7115 +#define CC_DEF_100 0x04020011
7116 +#define CC_DEF_33 0x11030011
7117 +#define CC_DEF_25 0x11050011
7118 +
7119 +/* Clock control values for 125Mhz */
7120 +#define CC_125_N 0x0802
7121 +#define CC_125_M 0x04020009
7122 +#define CC_125_M25 0x11090009
7123 +#define CC_125_M33 0x11090005
7124 +
7125 +/* Clock control magic field values */
7126 +#define CC_F6_2 0x02 /* A factor of 2 in */
7127 +#define CC_F6_3 0x03 /* 6-bit fields like */
7128 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
7129 +#define CC_F6_5 0x09
7130 +#define CC_F6_6 0x11
7131 +#define CC_F6_7 0x21
7132 +
7133 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
7134 +
7135 +#define CC_MC_BYPASS 0x08
7136 +#define CC_MC_M1 0x04
7137 +#define CC_MC_M1M2 0x02
7138 +#define CC_MC_M1M2M3 0x01
7139 +#define CC_MC_M1M3 0x11
7140 +
7141 +#define CC_CLOCK_BASE 24000000 /* Half the clock freq. in the 4710 */
7142 +
7143 +#endif /* _SBEXTIF_H */
7144 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbmemc.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbmemc.h
7145 --- linux-2.4.30/arch/mips/bcm947xx/include/sbmemc.h 1970-01-01 01:00:00.000000000 +0100
7146 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbmemc.h 2005-02-02 23:16:40.000000000 +0100
7147 @@ -0,0 +1,147 @@
7148 +/*
7149 + * BCM47XX Sonics SiliconBackplane DDR/SDRAM controller core hardware definitions.
7150 + *
7151 + * Copyright 2005, Broadcom Corporation
7152 + * All Rights Reserved.
7153 + *
7154 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7155 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7156 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7157 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7158 + *
7159 + * $Id$
7160 + */
7161 +
7162 +#ifndef _SBMEMC_H
7163 +#define _SBMEMC_H
7164 +
7165 +#ifdef _LANGUAGE_ASSEMBLY
7166 +
7167 +#define MEMC_CONTROL 0x00
7168 +#define MEMC_CONFIG 0x04
7169 +#define MEMC_REFRESH 0x08
7170 +#define MEMC_BISTSTAT 0x0c
7171 +#define MEMC_MODEBUF 0x10
7172 +#define MEMC_BKCLS 0x14
7173 +#define MEMC_PRIORINV 0x18
7174 +#define MEMC_DRAMTIM 0x1c
7175 +#define MEMC_INTSTAT 0x20
7176 +#define MEMC_INTMASK 0x24
7177 +#define MEMC_INTINFO 0x28
7178 +#define MEMC_NCDLCTL 0x30
7179 +#define MEMC_RDNCDLCOR 0x34
7180 +#define MEMC_WRNCDLCOR 0x38
7181 +#define MEMC_MISCDLYCTL 0x3c
7182 +#define MEMC_DQSGATENCDL 0x40
7183 +#define MEMC_SPARE 0x44
7184 +#define MEMC_TPADDR 0x48
7185 +#define MEMC_TPDATA 0x4c
7186 +#define MEMC_BARRIER 0x50
7187 +#define MEMC_CORE 0x54
7188 +
7189 +
7190 +#else
7191 +
7192 +/* Sonics side: MEMC core registers */
7193 +typedef volatile struct sbmemcregs {
7194 + uint32 control;
7195 + uint32 config;
7196 + uint32 refresh;
7197 + uint32 biststat;
7198 + uint32 modebuf;
7199 + uint32 bkcls;
7200 + uint32 priorinv;
7201 + uint32 dramtim;
7202 + uint32 intstat;
7203 + uint32 intmask;
7204 + uint32 intinfo;
7205 + uint32 reserved1;
7206 + uint32 ncdlctl;
7207 + uint32 rdncdlcor;
7208 + uint32 wrncdlcor;
7209 + uint32 miscdlyctl;
7210 + uint32 dqsgatencdl;
7211 + uint32 spare;
7212 + uint32 tpaddr;
7213 + uint32 tpdata;
7214 + uint32 barrier;
7215 + uint32 core;
7216 +} sbmemcregs_t;
7217 +
7218 +#endif
7219 +
7220 +/* MEMC Core Init values (OCP ID 0x80f) */
7221 +
7222 +/* For sdr: */
7223 +#define MEMC_SD_CONFIG_INIT 0x00048000
7224 +#define MEMC_SD_DRAMTIM2_INIT 0x000754d8
7225 +#define MEMC_SD_DRAMTIM3_INIT 0x000754da
7226 +#define MEMC_SD_RDNCDLCOR_INIT 0x00000000
7227 +#define MEMC_SD_WRNCDLCOR_INIT 0x49351200
7228 +#define MEMC_SD1_WRNCDLCOR_INIT 0x14500200 /* For corerev 1 (4712) */
7229 +#define MEMC_SD_MISCDLYCTL_INIT 0x00061c1b
7230 +#define MEMC_SD1_MISCDLYCTL_INIT 0x00021416 /* For corerev 1 (4712) */
7231 +#define MEMC_SD_CONTROL_INIT0 0x00000002
7232 +#define MEMC_SD_CONTROL_INIT1 0x00000008
7233 +#define MEMC_SD_CONTROL_INIT2 0x00000004
7234 +#define MEMC_SD_CONTROL_INIT3 0x00000010
7235 +#define MEMC_SD_CONTROL_INIT4 0x00000001
7236 +#define MEMC_SD_MODEBUF_INIT 0x00000000
7237 +#define MEMC_SD_REFRESH_INIT 0x0000840f
7238 +
7239 +
7240 +/* This is for SDRM8X8X4 */
7241 +#define MEMC_SDR_INIT 0x0008
7242 +#define MEMC_SDR_MODE 0x32
7243 +#define MEMC_SDR_NCDL 0x00020032
7244 +#define MEMC_SDR1_NCDL 0x0002020f /* For corerev 1 (4712) */
7245 +
7246 +/* For ddr: */
7247 +#define MEMC_CONFIG_INIT 0x00048000
7248 +#define MEMC_DRAMTIM2_INIT 0x000754d8
7249 +#define MEMC_DRAMTIM25_INIT 0x000754d9
7250 +#define MEMC_RDNCDLCOR_INIT 0x00000000
7251 +#define MEMC_WRNCDLCOR_INIT 0x49351200
7252 +#define MEMC_1_WRNCDLCOR_INIT 0x14500200
7253 +#define MEMC_DQSGATENCDL_INIT 0x00030000
7254 +#define MEMC_MISCDLYCTL_INIT 0x21061c1b
7255 +#define MEMC_1_MISCDLYCTL_INIT 0x21021400
7256 +#define MEMC_NCDLCTL_INIT 0x00002001
7257 +#define MEMC_CONTROL_INIT0 0x00000002
7258 +#define MEMC_CONTROL_INIT1 0x00000008
7259 +#define MEMC_MODEBUF_INIT0 0x00004000
7260 +#define MEMC_CONTROL_INIT2 0x00000010
7261 +#define MEMC_MODEBUF_INIT1 0x00000100
7262 +#define MEMC_CONTROL_INIT3 0x00000010
7263 +#define MEMC_CONTROL_INIT4 0x00000008
7264 +#define MEMC_REFRESH_INIT 0x0000840f
7265 +#define MEMC_CONTROL_INIT5 0x00000004
7266 +#define MEMC_MODEBUF_INIT2 0x00000000
7267 +#define MEMC_CONTROL_INIT6 0x00000010
7268 +#define MEMC_CONTROL_INIT7 0x00000001
7269 +
7270 +
7271 +/* This is for DDRM16X16X2 */
7272 +#define MEMC_DDR_INIT 0x0009
7273 +#define MEMC_DDR_MODE 0x62
7274 +#define MEMC_DDR_NCDL 0x0005050a
7275 +#define MEMC_DDR1_NCDL 0x00000a0a /* For corerev 1 (4712) */
7276 +
7277 +/* mask for sdr/ddr calibration registers */
7278 +#define MEMC_RDNCDLCOR_RD_MASK 0x000000ff
7279 +#define MEMC_WRNCDLCOR_WR_MASK 0x000000ff
7280 +#define MEMC_DQSGATENCDL_G_MASK 0x000000ff
7281 +
7282 +/* masks for miscdlyctl registers */
7283 +#define MEMC_MISC_SM_MASK 0x30000000
7284 +#define MEMC_MISC_SM_SHIFT 28
7285 +#define MEMC_MISC_SD_MASK 0x0f000000
7286 +#define MEMC_MISC_SD_SHIFT 24
7287 +
7288 +/* hw threshhold for calculating wr/rd for sdr memc */
7289 +#define MEMC_CD_THRESHOLD 128
7290 +
7291 +/* Low bit of init register says if memc is ddr or sdr */
7292 +#define MEMC_CONFIG_DDR 0x00000001
7293 +
7294 +#endif /* _SBMEMC_H */
7295 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbmips.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbmips.h
7296 --- linux-2.4.30/arch/mips/bcm947xx/include/sbmips.h 1970-01-01 01:00:00.000000000 +0100
7297 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbmips.h 2005-02-02 23:16:40.000000000 +0100
7298 @@ -0,0 +1,60 @@
7299 +/*
7300 + * Broadcom SiliconBackplane MIPS definitions
7301 + *
7302 + * SB MIPS cores are custom MIPS32 processors with SiliconBackplane
7303 + * OCP interfaces. The CP0 processor ID is 0x00024000, where bits
7304 + * 23:16 mean Broadcom and bits 15:8 mean a MIPS core with an OCP
7305 + * interface. The core revision is stored in the SB ID register in SB
7306 + * configuration space.
7307 + *
7308 + * Copyright 2005, Broadcom Corporation
7309 + * All Rights Reserved.
7310 + *
7311 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7312 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7313 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7314 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7315 + *
7316 + * $Id$
7317 + */
7318 +
7319 +#ifndef _SBMIPS_H
7320 +#define _SBMIPS_H
7321 +
7322 +#ifndef _LANGUAGE_ASSEMBLY
7323 +
7324 +/* cpp contortions to concatenate w/arg prescan */
7325 +#ifndef PAD
7326 +#define _PADLINE(line) pad ## line
7327 +#define _XSTR(line) _PADLINE(line)
7328 +#define PAD _XSTR(__LINE__)
7329 +#endif /* PAD */
7330 +
7331 +typedef volatile struct {
7332 + uint32 corecontrol;
7333 + uint32 PAD[2];
7334 + uint32 biststatus;
7335 + uint32 PAD[4];
7336 + uint32 intstatus;
7337 + uint32 intmask;
7338 + uint32 timer;
7339 +} mipsregs_t;
7340 +
7341 +extern uint32 sb_flag(void *sbh);
7342 +extern uint sb_irq(void *sbh);
7343 +
7344 +extern void BCMINIT(sb_serial_init)(void *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift));
7345 +
7346 +extern void *sb_jtagm_init(void *sbh, uint clkd, bool exttap);
7347 +extern void sb_jtagm_disable(void *h);
7348 +extern uint32 jtag_rwreg(void *h, uint32 ir, uint32 dr);
7349 +extern void BCMINIT(sb_mips_init)(void *sbh);
7350 +extern uint32 BCMINIT(sb_mips_clock)(void *sbh);
7351 +extern bool BCMINIT(sb_mips_setclock)(void *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock);
7352 +
7353 +extern uint32 BCMINIT(sb_memc_get_ncdl)(void *sbh);
7354 +extern uint32 BCMINIT(sb_mips_get_pfc)(void *sbh);
7355 +
7356 +#endif /* _LANGUAGE_ASSEMBLY */
7357 +
7358 +#endif /* _SBMIPS_H */
7359 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbpci.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbpci.h
7360 --- linux-2.4.30/arch/mips/bcm947xx/include/sbpci.h 1970-01-01 01:00:00.000000000 +0100
7361 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbpci.h 2005-02-02 23:16:40.000000000 +0100
7362 @@ -0,0 +1,117 @@
7363 +/*
7364 + * BCM47XX Sonics SiliconBackplane PCI core hardware definitions.
7365 + *
7366 + * $Id$
7367 + * Copyright 2005, Broadcom Corporation
7368 + * All Rights Reserved.
7369 + *
7370 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7371 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7372 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7373 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7374 + */
7375 +
7376 +#ifndef _SBPCI_H
7377 +#define _SBPCI_H
7378 +
7379 +/* cpp contortions to concatenate w/arg prescan */
7380 +#ifndef PAD
7381 +#define _PADLINE(line) pad ## line
7382 +#define _XSTR(line) _PADLINE(line)
7383 +#define PAD _XSTR(__LINE__)
7384 +#endif
7385 +
7386 +/* Sonics side: PCI core and host control registers */
7387 +typedef struct sbpciregs {
7388 + uint32 control; /* PCI control */
7389 + uint32 PAD[3];
7390 + uint32 arbcontrol; /* PCI arbiter control */
7391 + uint32 PAD[3];
7392 + uint32 intstatus; /* Interrupt status */
7393 + uint32 intmask; /* Interrupt mask */
7394 + uint32 sbtopcimailbox; /* Sonics to PCI mailbox */
7395 + uint32 PAD[9];
7396 + uint32 bcastaddr; /* Sonics broadcast address */
7397 + uint32 bcastdata; /* Sonics broadcast data */
7398 + uint32 PAD[2];
7399 + uint32 gpioin; /* ro: gpio input (>=rev2) */
7400 + uint32 gpioout; /* rw: gpio output (>=rev2) */
7401 + uint32 gpioouten; /* rw: gpio output enable (>= rev2) */
7402 + uint32 gpiocontrol; /* rw: gpio control (>= rev2) */
7403 + uint32 PAD[36];
7404 + uint32 sbtopci0; /* Sonics to PCI translation 0 */
7405 + uint32 sbtopci1; /* Sonics to PCI translation 1 */
7406 + uint32 sbtopci2; /* Sonics to PCI translation 2 */
7407 + uint32 PAD[445];
7408 + uint16 sprom[36]; /* SPROM shadow Area */
7409 + uint32 PAD[46];
7410 +} sbpciregs_t;
7411 +
7412 +/* PCI control */
7413 +#define PCI_RST_OE 0x01 /* When set, drives PCI_RESET out to pin */
7414 +#define PCI_RST 0x02 /* Value driven out to pin */
7415 +#define PCI_CLK_OE 0x04 /* When set, drives clock as gated by PCI_CLK out to pin */
7416 +#define PCI_CLK 0x08 /* Gate for clock driven out to pin */
7417 +
7418 +/* PCI arbiter control */
7419 +#define PCI_INT_ARB 0x01 /* When set, use an internal arbiter */
7420 +#define PCI_EXT_ARB 0x02 /* When set, use an external arbiter */
7421 +#define PCI_PARKID_MASK 0x06 /* Selects which agent is parked on an idle bus */
7422 +#define PCI_PARKID_SHIFT 1
7423 +#define PCI_PARKID_LAST 0 /* Last requestor */
7424 +#define PCI_PARKID_4710 1 /* 4710 */
7425 +#define PCI_PARKID_EXTREQ0 2 /* External requestor 0 */
7426 +#define PCI_PARKID_EXTREQ1 3 /* External requestor 1 */
7427 +
7428 +/* Interrupt status/mask */
7429 +#define PCI_INTA 0x01 /* PCI INTA# is asserted */
7430 +#define PCI_INTB 0x02 /* PCI INTB# is asserted */
7431 +#define PCI_SERR 0x04 /* PCI SERR# has been asserted (write one to clear) */
7432 +#define PCI_PERR 0x08 /* PCI PERR# has been asserted (write one to clear) */
7433 +#define PCI_PME 0x10 /* PCI PME# is asserted */
7434 +
7435 +/* (General) PCI/SB mailbox interrupts, two bits per pci function */
7436 +#define MAILBOX_F0_0 0x100 /* function 0, int 0 */
7437 +#define MAILBOX_F0_1 0x200 /* function 0, int 1 */
7438 +#define MAILBOX_F1_0 0x400 /* function 1, int 0 */
7439 +#define MAILBOX_F1_1 0x800 /* function 1, int 1 */
7440 +#define MAILBOX_F2_0 0x1000 /* function 2, int 0 */
7441 +#define MAILBOX_F2_1 0x2000 /* function 2, int 1 */
7442 +#define MAILBOX_F3_0 0x4000 /* function 3, int 0 */
7443 +#define MAILBOX_F3_1 0x8000 /* function 3, int 1 */
7444 +
7445 +/* Sonics broadcast address */
7446 +#define BCAST_ADDR_MASK 0xff /* Broadcast register address */
7447 +
7448 +/* Sonics to PCI translation types */
7449 +#define SBTOPCI0_MASK 0xfc000000
7450 +#define SBTOPCI1_MASK 0xfc000000
7451 +#define SBTOPCI2_MASK 0xc0000000
7452 +#define SBTOPCI_MEM 0
7453 +#define SBTOPCI_IO 1
7454 +#define SBTOPCI_CFG0 2
7455 +#define SBTOPCI_CFG1 3
7456 +#define SBTOPCI_PREF 0x4 /* prefetch enable */
7457 +#define SBTOPCI_BURST 0x8 /* burst enable */
7458 +#define SBTOPCI_RC_MASK 0x30 /* read command (>= rev11) */
7459 +#define SBTOPCI_RC_READ 0x00 /* memory read */
7460 +#define SBTOPCI_RC_READLINE 0x10 /* memory read line */
7461 +#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */
7462 +
7463 +/* PCI side: Reserved PCI configuration registers (see pcicfg.h) */
7464 +#define cap_list rsvd_a[0]
7465 +#define bar0_window dev_dep[0x80 - 0x40]
7466 +#define bar1_window dev_dep[0x84 - 0x40]
7467 +#define sprom_control dev_dep[0x88 - 0x40]
7468 +
7469 +#ifndef _LANGUAGE_ASSEMBLY
7470 +
7471 +extern int sbpci_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
7472 +extern int sbpci_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
7473 +extern void sbpci_ban(uint16 core);
7474 +extern int sbpci_init(void *sbh);
7475 +extern void sbpci_check(void *sbh);
7476 +
7477 +#endif /* !_LANGUAGE_ASSEMBLY */
7478 +
7479 +#endif /* _SBPCI_H */
7480 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbpcmcia.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbpcmcia.h
7481 --- linux-2.4.30/arch/mips/bcm947xx/include/sbpcmcia.h 1970-01-01 01:00:00.000000000 +0100
7482 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbpcmcia.h 2005-02-02 23:16:40.000000000 +0100
7483 @@ -0,0 +1,139 @@
7484 +/*
7485 + * BCM43XX Sonics SiliconBackplane PCMCIA core hardware definitions.
7486 + *
7487 + * $Id$
7488 + * Copyright 2005, Broadcom Corporation
7489 + * All Rights Reserved.
7490 + *
7491 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7492 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7493 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7494 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7495 + */
7496 +
7497 +#ifndef _SBPCMCIA_H
7498 +#define _SBPCMCIA_H
7499 +
7500 +
7501 +/* All the addresses that are offsets in attribute space are divided
7502 + * by two to account for the fact that odd bytes are invalid in
7503 + * attribute space and our read/write routines make the space appear
7504 + * as if they didn't exist. Still we want to show the original numbers
7505 + * as documented in the hnd_pcmcia core manual.
7506 + */
7507 +
7508 +/* PCMCIA Function Configuration Registers */
7509 +#define PCMCIA_FCR (0x700 / 2)
7510 +
7511 +#define FCR0_OFF 0
7512 +#define FCR1_OFF (0x40 / 2)
7513 +#define FCR2_OFF (0x80 / 2)
7514 +#define FCR3_OFF (0xc0 / 2)
7515 +
7516 +#define PCMCIA_FCR0 (0x700 / 2)
7517 +#define PCMCIA_FCR1 (0x740 / 2)
7518 +#define PCMCIA_FCR2 (0x780 / 2)
7519 +#define PCMCIA_FCR3 (0x7c0 / 2)
7520 +
7521 +/* Standard PCMCIA FCR registers */
7522 +
7523 +#define PCMCIA_COR 0
7524 +
7525 +#define COR_RST 0x80
7526 +#define COR_LEV 0x40
7527 +#define COR_IRQEN 0x04
7528 +#define COR_BLREN 0x01
7529 +#define COR_FUNEN 0x01
7530 +
7531 +
7532 +#define PCICIA_FCSR (2 / 2)
7533 +#define PCICIA_PRR (4 / 2)
7534 +#define PCICIA_SCR (6 / 2)
7535 +#define PCICIA_ESR (8 / 2)
7536 +
7537 +
7538 +#define PCM_MEMOFF 0x0000
7539 +#define F0_MEMOFF 0x1000
7540 +#define F1_MEMOFF 0x2000
7541 +#define F2_MEMOFF 0x3000
7542 +#define F3_MEMOFF 0x4000
7543 +
7544 +/* Memory base in the function fcr's */
7545 +#define MEM_ADDR0 (0x728 / 2)
7546 +#define MEM_ADDR1 (0x72a / 2)
7547 +#define MEM_ADDR2 (0x72c / 2)
7548 +
7549 +/* PCMCIA base plus Srom access in fcr0: */
7550 +#define PCMCIA_ADDR0 (0x072e / 2)
7551 +#define PCMCIA_ADDR1 (0x0730 / 2)
7552 +#define PCMCIA_ADDR2 (0x0732 / 2)
7553 +
7554 +#define MEM_SEG (0x0734 / 2)
7555 +#define SROM_CS (0x0736 / 2)
7556 +#define SROM_DATAL (0x0738 / 2)
7557 +#define SROM_DATAH (0x073a / 2)
7558 +#define SROM_ADDRL (0x073c / 2)
7559 +#define SROM_ADDRH (0x073e / 2)
7560 +
7561 +/* Values for srom_cs: */
7562 +#define SROM_IDLE 0
7563 +#define SROM_WRITE 1
7564 +#define SROM_READ 2
7565 +#define SROM_WEN 4
7566 +#define SROM_WDS 7
7567 +#define SROM_DONE 8
7568 +
7569 +/* CIS stuff */
7570 +
7571 +/* The CIS stops where the FCRs start */
7572 +#define CIS_SIZE PCMCIA_FCR
7573 +
7574 +/* Standard tuples we know about */
7575 +
7576 +#define CISTPL_MANFID 0x20 /* Manufacturer and device id */
7577 +#define CISTPL_FUNCE 0x22 /* Function extensions */
7578 +#define CISTPL_CFTABLE 0x1b /* Config table entry */
7579 +
7580 +/* Function extensions for LANs */
7581 +
7582 +#define LAN_TECH 1 /* Technology type */
7583 +#define LAN_SPEED 2 /* Raw bit rate */
7584 +#define LAN_MEDIA 3 /* Transmission media */
7585 +#define LAN_NID 4 /* Node identification (aka MAC addr) */
7586 +#define LAN_CONN 5 /* Connector standard */
7587 +
7588 +
7589 +/* CFTable */
7590 +#define CFTABLE_REGWIN_2K 0x08 /* 2k reg windows size */
7591 +#define CFTABLE_REGWIN_4K 0x10 /* 4k reg windows size */
7592 +#define CFTABLE_REGWIN_8K 0x20 /* 8k reg windows size */
7593 +
7594 +/* Vendor unique tuples are 0x80-0x8f. Within Broadcom we'll
7595 + * take one for HNBU, and use "extensions" (a la FUNCE) within it.
7596 + */
7597 +
7598 +#define CISTPL_BRCM_HNBU 0x80
7599 +
7600 +/* Subtypes of BRCM_HNBU: */
7601 +
7602 +#define HNBU_CHIPID 0x01 /* Six bytes with PCI vendor &
7603 + * device id and chiprev
7604 + */
7605 +#define HNBU_BOARDREV 0x02 /* Two bytes board revision */
7606 +#define HNBU_PAPARMS 0x03 /* Eleven bytes PA parameters */
7607 +#define HNBU_OEM 0x04 /* Eight bytes OEM data */
7608 +#define HNBU_CC 0x05 /* Default country code */
7609 +#define HNBU_AA 0x06 /* Antennas available */
7610 +#define HNBU_AG 0x07 /* Antenna gain */
7611 +#define HNBU_BOARDFLAGS 0x08 /* board flags */
7612 +#define HNBU_LED 0x09 /* LED set */
7613 +
7614 +
7615 +/* sbtmstatelow */
7616 +#define SBTML_INT_ACK 0x40000 /* ack the sb interrupt */
7617 +#define SBTML_INT_EN 0x20000 /* enable sb interrupt */
7618 +
7619 +/* sbtmstatehigh */
7620 +#define SBTMH_INT_STATUS 0x40000 /* sb interrupt status */
7621 +
7622 +#endif /* _SBPCMCIA_H */
7623 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbsdram.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbsdram.h
7624 --- linux-2.4.30/arch/mips/bcm947xx/include/sbsdram.h 1970-01-01 01:00:00.000000000 +0100
7625 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbsdram.h 2005-02-02 23:16:40.000000000 +0100
7626 @@ -0,0 +1,75 @@
7627 +/*
7628 + * BCM47XX Sonics SiliconBackplane SDRAM controller core hardware definitions.
7629 + *
7630 + * Copyright 2005, Broadcom Corporation
7631 + * All Rights Reserved.
7632 + *
7633 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7634 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7635 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7636 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7637 + * $Id$
7638 + */
7639 +
7640 +#ifndef _SBSDRAM_H
7641 +#define _SBSDRAM_H
7642 +
7643 +#ifndef _LANGUAGE_ASSEMBLY
7644 +
7645 +/* Sonics side: SDRAM core registers */
7646 +typedef volatile struct sbsdramregs {
7647 + uint32 initcontrol; /* Generates external SDRAM initialization sequence */
7648 + uint32 config; /* Initializes external SDRAM mode register */
7649 + uint32 refresh; /* Controls external SDRAM refresh rate */
7650 + uint32 pad1;
7651 + uint32 pad2;
7652 +} sbsdramregs_t;
7653 +
7654 +#endif
7655 +
7656 +/* SDRAM initialization control (initcontrol) register bits */
7657 +#define SDRAM_CBR 0x0001 /* Writing 1 generates refresh cycle and toggles bit */
7658 +#define SDRAM_PRE 0x0002 /* Writing 1 generates precharge cycle and toggles bit */
7659 +#define SDRAM_MRS 0x0004 /* Writing 1 generates mode register select cycle and toggles bit */
7660 +#define SDRAM_EN 0x0008 /* When set, enables access to SDRAM */
7661 +#define SDRAM_16Mb 0x0000 /* Use 16 Megabit SDRAM */
7662 +#define SDRAM_64Mb 0x0010 /* Use 64 Megabit SDRAM */
7663 +#define SDRAM_128Mb 0x0020 /* Use 128 Megabit SDRAM */
7664 +#define SDRAM_RSVMb 0x0030 /* Use special SDRAM */
7665 +#define SDRAM_RST 0x0080 /* Writing 1 causes soft reset of controller */
7666 +#define SDRAM_SELFREF 0x0100 /* Writing 1 enables self refresh mode */
7667 +#define SDRAM_PWRDOWN 0x0200 /* Writing 1 causes controller to power down */
7668 +#define SDRAM_32BIT 0x0400 /* When set, indicates 32 bit SDRAM interface */
7669 +#define SDRAM_9BITCOL 0x0800 /* When set, indicates 9 bit column */
7670 +
7671 +/* SDRAM configuration (config) register bits */
7672 +#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
7673 +#define SDRAM_BURST8 0x0001 /* Use burst of 8 */
7674 +#define SDRAM_BURST4 0x0002 /* Use burst of 4 */
7675 +#define SDRAM_BURST2 0x0003 /* Use burst of 2 */
7676 +#define SDRAM_CAS3 0x0000 /* Use CAS latency of 3 */
7677 +#define SDRAM_CAS2 0x0004 /* Use CAS latency of 2 */
7678 +
7679 +/* SDRAM refresh control (refresh) register bits */
7680 +#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
7681 +#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
7682 +
7683 +/* SDRAM Core default Init values (OCP ID 0x803) */
7684 +#define SDRAM_INIT MEM4MX16X2
7685 +#define SDRAM_CONFIG SDRAM_BURSTFULL
7686 +#define SDRAM_REFRESH SDRAM_REF(0x40)
7687 +
7688 +#define MEM1MX16 0x009 /* 2 MB */
7689 +#define MEM1MX16X2 0x409 /* 4 MB */
7690 +#define MEM2MX8X2 0x809 /* 4 MB */
7691 +#define MEM2MX8X4 0xc09 /* 8 MB */
7692 +#define MEM2MX32 0x439 /* 8 MB */
7693 +#define MEM4MX16 0x019 /* 8 MB */
7694 +#define MEM4MX16X2 0x419 /* 16 MB */
7695 +#define MEM8MX8X2 0x819 /* 16 MB */
7696 +#define MEM8MX16 0x829 /* 16 MB */
7697 +#define MEM4MX32 0x429 /* 16 MB */
7698 +#define MEM8MX8X4 0xc19 /* 32 MB */
7699 +#define MEM8MX16X2 0xc29 /* 32 MB */
7700 +
7701 +#endif /* _SBSDRAM_H */
7702 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbsocram.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbsocram.h
7703 --- linux-2.4.30/arch/mips/bcm947xx/include/sbsocram.h 1970-01-01 01:00:00.000000000 +0100
7704 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbsocram.h 2005-02-02 23:16:40.000000000 +0100
7705 @@ -0,0 +1,37 @@
7706 +/*
7707 + * BCM47XX Sonics SiliconBackplane embedded ram core
7708 + *
7709 + * Copyright 2005, Broadcom Corporation
7710 + * All Rights Reserved.
7711 + *
7712 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7713 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7714 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7715 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7716 + *
7717 + * $Id$
7718 + */
7719 +
7720 +#ifndef _SBSOCRAM_H
7721 +#define _SBSOCRAM_H
7722 +
7723 +#define SOCRAM_MEMSIZE 0x00
7724 +#define SOCRAM_BISTSTAT 0x0c
7725 +
7726 +
7727 +#ifndef _LANGUAGE_ASSEMBLY
7728 +
7729 +/* Memcsocram core registers */
7730 +typedef volatile struct sbsocramregs {
7731 + uint32 memsize;
7732 + uint32 biststat;
7733 +} sbsocramregs_t;
7734 +
7735 +#endif
7736 +
7737 +/* Them memory size is 2 to the power of the following
7738 + * base added to the contents of the memsize register.
7739 + */
7740 +#define SOCRAM_MEMSIZE_BASESHIFT 16
7741 +
7742 +#endif /* _SBSOCRAM_H */
7743 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sbutils.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbutils.h
7744 --- linux-2.4.30/arch/mips/bcm947xx/include/sbutils.h 1970-01-01 01:00:00.000000000 +0100
7745 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sbutils.h 2005-02-02 23:16:40.000000000 +0100
7746 @@ -0,0 +1,87 @@
7747 +/*
7748 + * Misc utility routines for accessing chip-specific features
7749 + * of Broadcom HNBU SiliconBackplane-based chips.
7750 + *
7751 + * Copyright 2005, Broadcom Corporation
7752 + * All Rights Reserved.
7753 + *
7754 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7755 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7756 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7757 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7758 + *
7759 + * $Id$
7760 + */
7761 +
7762 +#ifndef _sbutils_h_
7763 +#define _sbutils_h_
7764 +
7765 +/*
7766 + * Many of the routines below take an 'sbh' handle as their first arg.
7767 + * Allocate this by calling sb_attach(). Free it by calling sb_detach().
7768 + * At any one time, the sbh is logically focused on one particular sb core
7769 + * (the "current core").
7770 + * Use sb_setcore() or sb_setcoreidx() to change the association to another core.
7771 + */
7772 +
7773 +/* exported externs */
7774 +extern void * BCMINIT(sb_attach)(uint pcidev, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz);
7775 +extern void * BCMINIT(sb_kattach)(void);
7776 +extern void sb_detach(void *sbh);
7777 +extern uint BCMINIT(sb_chip)(void *sbh);
7778 +extern uint BCMINIT(sb_chiprev)(void *sbh);
7779 +extern uint BCMINIT(sb_chipcrev)(void *sbh);
7780 +extern uint BCMINIT(sb_chippkg)(void *sbh);
7781 +extern uint BCMINIT(sb_pcirev)(void *sbh);
7782 +extern uint BCMINIT(sb_pcmciarev)(void *sbh);
7783 +extern uint BCMINIT(sb_boardvendor)(void *sbh);
7784 +extern uint BCMINIT(sb_boardtype)(void *sbh);
7785 +extern uint sb_bus(void *sbh);
7786 +extern uint sb_corelist(void *sbh, uint coreid[]);
7787 +extern uint sb_coreid(void *sbh);
7788 +extern uint sb_coreidx(void *sbh);
7789 +extern uint sb_coreunit(void *sbh);
7790 +extern uint sb_corevendor(void *sbh);
7791 +extern uint sb_corerev(void *sbh);
7792 +extern void *sb_osh(void *sbh);
7793 +extern void *sb_coreregs(void *sbh);
7794 +extern uint32 sb_coreflags(void *sbh, uint32 mask, uint32 val);
7795 +extern uint32 sb_coreflagshi(void *sbh, uint32 mask, uint32 val);
7796 +extern bool sb_iscoreup(void *sbh);
7797 +extern void *sb_setcoreidx(void *sbh, uint coreidx);
7798 +extern void *sb_setcore(void *sbh, uint coreid, uint coreunit);
7799 +extern void sb_commit(void *sbh);
7800 +extern uint32 sb_base(uint32 admatch);
7801 +extern uint32 sb_size(uint32 admatch);
7802 +extern void sb_core_reset(void *sbh, uint32 bits);
7803 +extern void sb_core_tofixup(void *sbh);
7804 +extern void sb_core_disable(void *sbh, uint32 bits);
7805 +extern uint32 sb_clock_rate(uint32 pll_type, uint32 n, uint32 m);
7806 +extern uint32 sb_clock(void *sbh);
7807 +extern void sb_pci_setup(void *sbh, uint32 *dmaoffset, uint coremask);
7808 +extern void sb_pcmcia_init(void *sbh);
7809 +extern void sb_watchdog(void *sbh, uint ticks);
7810 +extern void *sb_gpiosetcore(void *sbh);
7811 +extern uint32 sb_gpiocontrol(void *sbh, uint32 mask, uint32 val);
7812 +extern uint32 sb_gpioouten(void *sbh, uint32 mask, uint32 val);
7813 +extern uint32 sb_gpioout(void *sbh, uint32 mask, uint32 val);
7814 +extern uint32 sb_gpioin(void *sbh);
7815 +extern uint32 sb_gpiointpolarity(void *sbh, uint32 mask, uint32 val);
7816 +extern uint32 sb_gpiointmask(void *sbh, uint32 mask, uint32 val);
7817 +extern void sb_pwrctl_init(void *sbh);
7818 +extern uint16 sb_pwrctl_fast_pwrup_delay(void *sbh);
7819 +extern bool sb_pwrctl_clk(void *sbh, uint mode);
7820 +extern int sb_pwrctl_xtal(void *sbh, uint what, bool on);
7821 +extern int sb_pwrctl_slowclk(void *sbh, bool set, uint *div);
7822 +extern void sb_register_intr_callback(void *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg);
7823 +
7824 +/* pwrctl xtal what flags */
7825 +#define XTAL 0x1 /* primary crystal oscillator (2050) */
7826 +#define PLL 0x2 /* main chip pll */
7827 +
7828 +/* pwrctl clk mode */
7829 +#define CLK_FAST 0 /* force fast (pll) clock */
7830 +#define CLK_SLOW 1 /* force slow clock */
7831 +#define CLK_DYNAMIC 2 /* enable dynamic power control */
7832 +
7833 +#endif /* _sbutils_h_ */
7834 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/sflash.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/sflash.h
7835 --- linux-2.4.30/arch/mips/bcm947xx/include/sflash.h 1970-01-01 01:00:00.000000000 +0100
7836 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/sflash.h 2005-02-02 23:16:40.000000000 +0100
7837 @@ -0,0 +1,36 @@
7838 +/*
7839 + * Broadcom SiliconBackplane chipcommon serial flash interface
7840 + *
7841 + * Copyright 2005, Broadcom Corporation
7842 + * All Rights Reserved.
7843 + *
7844 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7845 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7846 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7847 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7848 + *
7849 + * $Id$
7850 + */
7851 +
7852 +#ifndef _sflash_h_
7853 +#define _sflash_h_
7854 +
7855 +#include <typedefs.h>
7856 +#include <sbchipc.h>
7857 +
7858 +struct sflash {
7859 + uint blocksize; /* Block size */
7860 + uint numblocks; /* Number of blocks */
7861 + uint32 type; /* Type */
7862 + uint size; /* Total size in bytes */
7863 +};
7864 +
7865 +/* Utility functions */
7866 +extern int sflash_poll(chipcregs_t *cc, uint offset);
7867 +extern int sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf);
7868 +extern int sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
7869 +extern int sflash_erase(chipcregs_t *cc, uint offset);
7870 +extern int sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
7871 +extern struct sflash * sflash_init(chipcregs_t *cc);
7872 +
7873 +#endif /* _sflash_h_ */
7874 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/trxhdr.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/trxhdr.h
7875 --- linux-2.4.30/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +0100
7876 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/trxhdr.h 2005-02-02 23:16:40.000000000 +0100
7877 @@ -0,0 +1,33 @@
7878 +/*
7879 + * TRX image file header format.
7880 + *
7881 + * Copyright 2005, Broadcom Corporation
7882 + * All Rights Reserved.
7883 + *
7884 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7885 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7886 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7887 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7888 + *
7889 + * $Id$
7890 + */
7891 +
7892 +#include <typedefs.h>
7893 +
7894 +#define TRX_MAGIC 0x30524448 /* "HDR0" */
7895 +#define TRX_VERSION 1
7896 +#define TRX_MAX_LEN 0x3A0000
7897 +#define TRX_NO_HEADER 1 /* Do not write TRX header */
7898 +#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
7899 +#define TRX_MAX_OFFSET 3
7900 +
7901 +struct trx_header {
7902 + uint32 magic; /* "HDR0" */
7903 + uint32 len; /* Length of file including header */
7904 + uint32 crc32; /* 32-bit CRC from flag_version to end of file */
7905 + uint32 flag_version; /* 0:15 flags, 16:31 version */
7906 + uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
7907 +};
7908 +
7909 +/* Compatibility */
7910 +typedef struct trx_header TRXHDR, *PTRXHDR;
7911 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/typedefs.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/typedefs.h
7912 --- linux-2.4.30/arch/mips/bcm947xx/include/typedefs.h 1970-01-01 01:00:00.000000000 +0100
7913 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/typedefs.h 2005-02-02 23:16:40.000000000 +0100
7914 @@ -0,0 +1,322 @@
7915 +/*
7916 + * Copyright 2005, Broadcom Corporation
7917 + * All Rights Reserved.
7918 + *
7919 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7920 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7921 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7922 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7923 + * $Id$
7924 + */
7925 +
7926 +#ifndef _TYPEDEFS_H_
7927 +#define _TYPEDEFS_H_
7928 +
7929 +
7930 +/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
7931 + * typedef file "site_typedefs.h".
7932 + *
7933 + * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
7934 + * section of this file makes inferences about the compile environment
7935 + * based on defined symbols and possibly compiler pragmas.
7936 + *
7937 + * Following these two sections is the "Default Typedefs"
7938 + * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
7939 + * defined. This section has a default set of typedefs and a few
7940 + * proprocessor symbols (TRUE, FALSE, NULL, ...).
7941 + */
7942 +
7943 +#ifdef SITE_TYPEDEFS
7944 +
7945 +/*******************************************************************************
7946 + * Site Specific Typedefs
7947 + *******************************************************************************/
7948 +
7949 +#include "site_typedefs.h"
7950 +
7951 +#else
7952 +
7953 +/*******************************************************************************
7954 + * Inferred Typedefs
7955 + *******************************************************************************/
7956 +
7957 +/* Infer the compile environment based on preprocessor symbols and pramas.
7958 + * Override type definitions as needed, and include configuration dependent
7959 + * header files to define types.
7960 + */
7961 +
7962 +#ifdef __cplusplus
7963 +
7964 +#define TYPEDEF_BOOL
7965 +#ifndef FALSE
7966 +#define FALSE false
7967 +#endif
7968 +#ifndef TRUE
7969 +#define TRUE true
7970 +#endif
7971 +
7972 +#else /* ! __cplusplus */
7973 +
7974 +#if defined(_WIN32)
7975 +
7976 +#define TYPEDEF_BOOL
7977 +typedef unsigned char bool; /* consistent w/BOOL */
7978 +
7979 +#endif /* _WIN32 */
7980 +
7981 +#endif /* ! __cplusplus */
7982 +
7983 +/* use the Windows ULONG_PTR type when compiling for 64 bit */
7984 +#if defined(_WIN64)
7985 +#include <basetsd.h>
7986 +#define TYPEDEF_UINTPTR
7987 +typedef ULONG_PTR uintptr;
7988 +#endif
7989 +
7990 +#ifdef _MSC_VER /* Microsoft C */
7991 +#define TYPEDEF_INT64
7992 +#define TYPEDEF_UINT64
7993 +typedef signed __int64 int64;
7994 +typedef unsigned __int64 uint64;
7995 +#endif
7996 +
7997 +#if defined(MACOSX) && defined(KERNEL)
7998 +#define TYPEDEF_BOOL
7999 +#endif
8000 +
8001 +
8002 +#if defined(linux)
8003 +#define TYPEDEF_UINT
8004 +#define TYPEDEF_USHORT
8005 +#define TYPEDEF_ULONG
8006 +#endif
8007 +
8008 +#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
8009 +#define TYPEDEF_UINT
8010 +#define TYPEDEF_USHORT
8011 +#endif
8012 +
8013 +
8014 +/* Do not support the (u)int64 types with strict ansi for GNU C */
8015 +#if defined(__GNUC__) && defined(__STRICT_ANSI__)
8016 +#define TYPEDEF_INT64
8017 +#define TYPEDEF_UINT64
8018 +#endif
8019 +
8020 +/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
8021 + * for singned or unsigned */
8022 +#if defined(__ICL)
8023 +
8024 +#define TYPEDEF_INT64
8025 +
8026 +#if defined(__STDC__)
8027 +#define TYPEDEF_UINT64
8028 +#endif
8029 +
8030 +#endif /* __ICL */
8031 +
8032 +
8033 +#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
8034 +
8035 +/* pick up ushort & uint from standard types.h */
8036 +#if defined(linux) && defined(__KERNEL__)
8037 +
8038 +#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
8039 +
8040 +#else
8041 +
8042 +#include <sys/types.h>
8043 +
8044 +#endif
8045 +
8046 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */
8047 +
8048 +#if defined(MACOSX) && defined(KERNEL)
8049 +#include <IOKit/IOTypes.h>
8050 +#endif
8051 +
8052 +
8053 +/* use the default typedefs in the next section of this file */
8054 +#define USE_TYPEDEF_DEFAULTS
8055 +
8056 +#endif /* SITE_TYPEDEFS */
8057 +
8058 +
8059 +/*******************************************************************************
8060 + * Default Typedefs
8061 + *******************************************************************************/
8062 +
8063 +#ifdef USE_TYPEDEF_DEFAULTS
8064 +#undef USE_TYPEDEF_DEFAULTS
8065 +
8066 +#ifndef TYPEDEF_BOOL
8067 +typedef /*@abstract@*/ unsigned char bool;
8068 +#endif
8069 +
8070 +/*----------------------- define uchar, ushort, uint, ulong ------------------*/
8071 +
8072 +#ifndef TYPEDEF_UCHAR
8073 +typedef unsigned char uchar;
8074 +#endif
8075 +
8076 +#ifndef TYPEDEF_USHORT
8077 +typedef unsigned short ushort;
8078 +#endif
8079 +
8080 +#ifndef TYPEDEF_UINT
8081 +typedef unsigned int uint;
8082 +#endif
8083 +
8084 +#ifndef TYPEDEF_ULONG
8085 +typedef unsigned long ulong;
8086 +#endif
8087 +
8088 +/*----------------------- define [u]int8/16/32/64, uintptr --------------------*/
8089 +
8090 +#ifndef TYPEDEF_UINT8
8091 +typedef unsigned char uint8;
8092 +#endif
8093 +
8094 +#ifndef TYPEDEF_UINT16
8095 +typedef unsigned short uint16;
8096 +#endif
8097 +
8098 +#ifndef TYPEDEF_UINT32
8099 +typedef unsigned int uint32;
8100 +#endif
8101 +
8102 +#ifndef TYPEDEF_UINT64
8103 +typedef unsigned long long uint64;
8104 +#endif
8105 +
8106 +#ifndef TYPEDEF_UINTPTR
8107 +typedef unsigned int uintptr;
8108 +#endif
8109 +
8110 +#ifndef TYPEDEF_INT8
8111 +typedef signed char int8;
8112 +#endif
8113 +
8114 +#ifndef TYPEDEF_INT16
8115 +typedef signed short int16;
8116 +#endif
8117 +
8118 +#ifndef TYPEDEF_INT32
8119 +typedef signed int int32;
8120 +#endif
8121 +
8122 +#ifndef TYPEDEF_INT64
8123 +typedef signed long long int64;
8124 +#endif
8125 +
8126 +/*----------------------- define float32/64, float_t -----------------------*/
8127 +
8128 +#ifndef TYPEDEF_FLOAT32
8129 +typedef float float32;
8130 +#endif
8131 +
8132 +#ifndef TYPEDEF_FLOAT64
8133 +typedef double float64;
8134 +#endif
8135 +
8136 +/*
8137 + * abstracted floating point type allows for compile time selection of
8138 + * single or double precision arithmetic. Compiling with -DFLOAT32
8139 + * selects single precision; the default is double precision.
8140 + */
8141 +
8142 +#ifndef TYPEDEF_FLOAT_T
8143 +
8144 +#if defined(FLOAT32)
8145 +typedef float32 float_t;
8146 +#else /* default to double precision floating point */
8147 +typedef float64 float_t;
8148 +#endif
8149 +
8150 +#endif /* TYPEDEF_FLOAT_T */
8151 +
8152 +/*----------------------- define macro values -----------------------------*/
8153 +
8154 +#ifndef FALSE
8155 +#define FALSE 0
8156 +#endif
8157 +
8158 +#ifndef TRUE
8159 +#define TRUE 1
8160 +#endif
8161 +
8162 +#ifndef NULL
8163 +#define NULL 0
8164 +#endif
8165 +
8166 +#ifndef OFF
8167 +#define OFF 0
8168 +#endif
8169 +
8170 +#ifndef ON
8171 +#define ON 1
8172 +#endif
8173 +
8174 +#define AUTO (-1)
8175 +
8176 +/* Reclaiming text and data :
8177 + The following macros specify special linker sections that can be reclaimed
8178 + after a system is considered 'up'.
8179 + */
8180 +#if defined(__GNUC__) && defined(BCMRECLAIM)
8181 +extern bool bcmreclaimed;
8182 +#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data##_ini
8183 +#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn##_ini
8184 +#define BCMINIT(_id) _id##_ini
8185 +#else
8186 +#define BCMINITDATA(_data) _data
8187 +#define BCMINITFN(_fn) _fn
8188 +#define BCMINIT(_id) _id
8189 +#define bcmreclaimed 0
8190 +#endif
8191 +
8192 +/*----------------------- define PTRSZ, INLINE ----------------------------*/
8193 +
8194 +#ifndef PTRSZ
8195 +#define PTRSZ sizeof (char*)
8196 +#endif
8197 +
8198 +#ifndef INLINE
8199 +
8200 +#ifdef _MSC_VER
8201 +
8202 +#define INLINE __inline
8203 +
8204 +#elif __GNUC__
8205 +
8206 +#define INLINE __inline__
8207 +
8208 +#else
8209 +
8210 +#define INLINE
8211 +
8212 +#endif /* _MSC_VER */
8213 +
8214 +#endif /* INLINE */
8215 +
8216 +#undef TYPEDEF_BOOL
8217 +#undef TYPEDEF_UCHAR
8218 +#undef TYPEDEF_USHORT
8219 +#undef TYPEDEF_UINT
8220 +#undef TYPEDEF_ULONG
8221 +#undef TYPEDEF_UINT8
8222 +#undef TYPEDEF_UINT16
8223 +#undef TYPEDEF_UINT32
8224 +#undef TYPEDEF_UINT64
8225 +#undef TYPEDEF_UINTPTR
8226 +#undef TYPEDEF_INT8
8227 +#undef TYPEDEF_INT16
8228 +#undef TYPEDEF_INT32
8229 +#undef TYPEDEF_INT64
8230 +#undef TYPEDEF_FLOAT32
8231 +#undef TYPEDEF_FLOAT64
8232 +#undef TYPEDEF_FLOAT_T
8233 +
8234 +#endif /* USE_TYPEDEF_DEFAULTS */
8235 +
8236 +#endif /* _TYPEDEFS_H_ */
8237 diff -Nur linux-2.4.30/arch/mips/bcm947xx/include/wlioctl.h linux-2.4.30-brcm/arch/mips/bcm947xx/include/wlioctl.h
8238 --- linux-2.4.30/arch/mips/bcm947xx/include/wlioctl.h 1970-01-01 01:00:00.000000000 +0100
8239 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/include/wlioctl.h 2005-02-02 23:16:40.000000000 +0100
8240 @@ -0,0 +1,825 @@
8241 +/*
8242 + * Custom OID/ioctl definitions for
8243 + * Broadcom 802.11abg Networking Device Driver
8244 + *
8245 + * Definitions subject to change without notice.
8246 + *
8247 + * Copyright 2005, Broadcom Corporation
8248 + * All Rights Reserved.
8249 + *
8250 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8251 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8252 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8253 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8254 + *
8255 + * $Id$
8256 + */
8257 +
8258 +#ifndef _wlioctl_h_
8259 +#define _wlioctl_h_
8260 +
8261 +#include <typedefs.h>
8262 +#include <proto/ethernet.h>
8263 +#include <proto/802.11.h>
8264 +
8265 +/* require default structure packing */
8266 +#if !defined(__GNUC__)
8267 +#pragma pack(push,8)
8268 +#endif
8269 +
8270 +#define WL_NUMRATES 255 /* max # of rates in a rateset */
8271 +
8272 +typedef struct wl_rateset {
8273 + uint32 count; /* # rates in this set */
8274 + uint8 rates[WL_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */
8275 +} wl_rateset_t;
8276 +
8277 +#define WL_CHANSPEC_CHAN_MASK 0x0fff
8278 +#define WL_CHANSPEC_BAND_MASK 0xf000
8279 +#define WL_CHANSPEC_BAND_SHIFT 12
8280 +#define WL_CHANSPEC_BAND_A 0x1000
8281 +#define WL_CHANSPEC_BAND_B 0x2000
8282 +
8283 +/*
8284 + * Per-bss information structure.
8285 + */
8286 +
8287 +#define WL_BSS_INFO_VERSION 107 /* current version of wl_bss_info struct */
8288 +
8289 +typedef struct wl_bss_info {
8290 + uint32 version; /* version field */
8291 + uint32 length; /* byte length of data in this record, starting at version and including IEs */
8292 + struct ether_addr BSSID;
8293 + uint16 beacon_period; /* units are Kusec */
8294 + uint16 capability; /* Capability information */
8295 + uint8 SSID_len;
8296 + uint8 SSID[32];
8297 + struct {
8298 + uint count; /* # rates in this set */
8299 + uint8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */
8300 + } rateset; /* supported rates */
8301 + uint8 channel; /* Channel no. */
8302 + uint16 atim_window; /* units are Kusec */
8303 + uint8 dtim_period; /* DTIM period */
8304 + int16 RSSI; /* receive signal strength (in dBm) */
8305 + int8 phy_noise; /* noise (in dBm) */
8306 + uint32 ie_length; /* byte length of Information Elements */
8307 + /* variable length Information Elements */
8308 +} wl_bss_info_t;
8309 +
8310 +typedef struct wlc_ssid {
8311 + uint32 SSID_len;
8312 + uchar SSID[32];
8313 +} wlc_ssid_t;
8314 +
8315 +typedef struct wl_scan_params {
8316 + wlc_ssid_t ssid; /* default is {0, ""} */
8317 + struct ether_addr bssid;/* default is bcast */
8318 + int8 bss_type; /* default is any, DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT */
8319 + int8 scan_type; /* -1 use default, DOT11_SCANTYPE_ACTIVE/PASSIVE */
8320 + int32 nprobes; /* -1 use default, number of probes per channel */
8321 + int32 active_time; /* -1 use default, dwell time per channel for active scanning */
8322 + int32 passive_time; /* -1 use default, dwell time per channel for passive scanning */
8323 + int32 home_time; /* -1 use default, dwell time for the home channel between channel scans */
8324 + int32 channel_num; /* 0 use default (all available channels), count of channels in channel_list */
8325 + uint16 channel_list[1]; /* list of chanspecs */
8326 +} wl_scan_params_t;
8327 +/* size of wl_scan_params not including variable length array */
8328 +#define WL_SCAN_PARAMS_FIXED_SIZE 64
8329 +
8330 +typedef struct wl_scan_results {
8331 + uint32 buflen;
8332 + uint32 version;
8333 + uint32 count;
8334 + wl_bss_info_t bss_info[1];
8335 +} wl_scan_results_t;
8336 +/* size of wl_scan_results not including variable length array */
8337 +#define WL_SCAN_RESULTS_FIXED_SIZE 12
8338 +
8339 +/* uint32 list */
8340 +typedef struct wl_uint32_list {
8341 + /* in - # of elements, out - # of entries */
8342 + uint32 count;
8343 + /* variable length uint32 list */
8344 + uint32 element[1];
8345 +} wl_uint32_list_t;
8346 +
8347 +#define WLC_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NULL */
8348 +
8349 +typedef struct wl_channels_in_country {
8350 + uint32 buflen;
8351 + uint32 band;
8352 + char country_abbrev[WLC_CNTRY_BUF_SZ];
8353 + uint32 count;
8354 + uint32 channel[1];
8355 +} wl_channels_in_country_t;
8356 +
8357 +typedef struct wl_country_list {
8358 + uint32 buflen;
8359 + uint32 band_set;
8360 + uint32 band;
8361 + uint32 count;
8362 + char country_abbrev[1];
8363 +} wl_country_list_t;
8364 +
8365 +#define WL_RM_TYPE_BASIC 1
8366 +#define WL_RM_TYPE_CCA 2
8367 +#define WL_RM_TYPE_RPI 3
8368 +
8369 +#define WL_RM_FLAG_PARALLEL (1<<0)
8370 +
8371 +#define WL_RM_FLAG_LATE (1<<1)
8372 +#define WL_RM_FLAG_INCAPABLE (1<<2)
8373 +#define WL_RM_FLAG_REFUSED (1<<3)
8374 +
8375 +typedef struct wl_rm_req_elt {
8376 + int8 type;
8377 + int8 flags;
8378 + uint16 chanspec;
8379 + uint32 token; /* token for this measurement */
8380 + uint32 tsf_h; /* TSF high 32-bits of Measurement start time */
8381 + uint32 tsf_l; /* TSF low 32-bits */
8382 + uint32 dur; /* TUs */
8383 +} wl_rm_req_elt_t;
8384 +
8385 +typedef struct wl_rm_req {
8386 + uint32 token; /* overall measurement set token */
8387 + uint32 count; /* number of measurement reqests */
8388 + wl_rm_req_elt_t req[1]; /* variable length block of requests */
8389 +} wl_rm_req_t;
8390 +#define WL_RM_REQ_FIXED_LEN 8
8391 +
8392 +typedef struct wl_rm_rep_elt {
8393 + int8 type;
8394 + int8 flags;
8395 + uint16 chanspec;
8396 + uint32 token; /* token for this measurement */
8397 + uint32 tsf_h; /* TSF high 32-bits of Measurement start time */
8398 + uint32 tsf_l; /* TSF low 32-bits */
8399 + uint32 dur; /* TUs */
8400 + uint32 len; /* byte length of data block */
8401 + uint8 data[1]; /* variable length data block */
8402 +} wl_rm_rep_elt_t;
8403 +#define WL_RM_REP_ELT_FIXED_LEN 24 /* length excluding data block */
8404 +
8405 +#define WL_RPI_REP_BIN_NUM 8
8406 +typedef struct wl_rm_rpi_rep {
8407 + uint8 rpi[WL_RPI_REP_BIN_NUM];
8408 + int8 rpi_max[WL_RPI_REP_BIN_NUM];
8409 +} wl_rm_rpi_rep_t;
8410 +
8411 +typedef struct wl_rm_rep {
8412 + uint32 token; /* overall measurement set token */
8413 + uint32 len; /* length of measurement report block */
8414 + wl_rm_rep_elt_t rep[1]; /* variable length block of reports */
8415 +} wl_rm_rep_t;
8416 +#define WL_RM_REP_FIXED_LEN 8
8417 +
8418 +
8419 +#if defined(BCMSUP_PSK)
8420 +typedef enum sup_auth_status {
8421 + WLC_SUP_DISCONNECTED = 0,
8422 + WLC_SUP_CONNECTING,
8423 + WLC_SUP_IDREQUIRED,
8424 + WLC_SUP_AUTHENTICATING,
8425 + WLC_SUP_AUTHENTICATED,
8426 + WLC_SUP_KEYXCHANGE,
8427 + WLC_SUP_KEYED
8428 +} sup_auth_status_t;
8429 +#endif /* BCMCCX | BCMSUP_PSK */
8430 +
8431 +/* Enumerate crypto algorithms */
8432 +#define CRYPTO_ALGO_OFF 0
8433 +#define CRYPTO_ALGO_WEP1 1
8434 +#define CRYPTO_ALGO_TKIP 2
8435 +#define CRYPTO_ALGO_WEP128 3
8436 +#define CRYPTO_ALGO_AES_CCM 4
8437 +#define CRYPTO_ALGO_AES_OCB_MSDU 5
8438 +#define CRYPTO_ALGO_AES_OCB_MPDU 6
8439 +#define CRYPTO_ALGO_NALG 7
8440 +
8441 +#define WSEC_GEN_MIC_ERROR 0x0001
8442 +#define WSEC_GEN_REPLAY 0x0002
8443 +
8444 +#define WL_SOFT_KEY (1 << 0) /* Indicates this key is using soft encrypt */
8445 +#define WL_PRIMARY_KEY (1 << 1) /* Indicates this key is the primary (ie tx) key */
8446 +#define WL_KF_RES_4 (1 << 4) /* Reserved for backward compat */
8447 +#define WL_KF_RES_5 (1 << 5) /* Reserved for backward compat */
8448 +
8449 +typedef struct wl_wsec_key {
8450 + uint32 index; /* key index */
8451 + uint32 len; /* key length */
8452 + uint8 data[DOT11_MAX_KEY_SIZE]; /* key data */
8453 + uint32 pad_1[18];
8454 + uint32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
8455 + uint32 flags; /* misc flags */
8456 + uint32 pad_2[2];
8457 + int pad_3;
8458 + int iv_initialized; /* has IV been initialized already? */
8459 + int pad_4;
8460 + /* Rx IV */
8461 + struct {
8462 + uint32 hi; /* upper 32 bits of IV */
8463 + uint16 lo; /* lower 16 bits of IV */
8464 + } rxiv;
8465 + uint32 pad_5[2];
8466 + struct ether_addr ea; /* per station */
8467 +} wl_wsec_key_t;
8468 +
8469 +
8470 +#define WSEC_MIN_PSK_LEN 8
8471 +#define WSEC_MAX_PSK_LEN 64
8472 +
8473 +/* Flag for key material needing passhash'ing */
8474 +#define WSEC_PASSPHRASE (1<<0)
8475 +
8476 +/* recepticle for WLC_SET_WSEC_PMK parameter */
8477 +typedef struct {
8478 + ushort key_len; /* octets in key material */
8479 + ushort flags; /* key handling qualification */
8480 + uint8 key[WSEC_MAX_PSK_LEN]; /* PMK material */
8481 +} wsec_pmk_t;
8482 +
8483 +/* wireless security bitvec */
8484 +#define WEP_ENABLED 1
8485 +#define TKIP_ENABLED 2
8486 +#define AES_ENABLED 4
8487 +#define WSEC_SWFLAG 8
8488 +
8489 +/* WPA authentication mode bitvec */
8490 +#define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */
8491 +#define WPA_AUTH_NONE 0x0001 /* none (IBSS) */
8492 +#define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */
8493 +#define WPA_AUTH_PSK 0x0004 /* Pre-shared key */
8494 +/*#define WPA_AUTH_8021X 0x0020*/ /* 802.1x, reserved */
8495 +#define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
8496 +#define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
8497 +
8498 +typedef struct wl_led_info {
8499 + uint32 index; /* led index */
8500 + uint32 behavior;
8501 + bool activehi;
8502 +} wl_led_info_t;
8503 +
8504 +/*
8505 + * definitions for driver messages passed from WL to NAS.
8506 + */
8507 +/* Use this to recognize wpa and 802.1x driver messages. */
8508 +static const uint8 wl_wpa_snap_template[] =
8509 + { 0xaa, 0xaa, 0x03, 0x00, 0x90, 0x4c };
8510 +
8511 +#define WL_WPA_MSG_IFNAME_MAX 16
8512 +
8513 +/* WPA driver message */
8514 +typedef struct wl_wpa_header {
8515 + struct ether_header eth;
8516 + struct dot11_llc_snap_header snap;
8517 + uint8 version;
8518 + uint8 type;
8519 + /* version 2 additions */
8520 + char ifname[WL_WPA_MSG_IFNAME_MAX];
8521 + /* version specific data */
8522 + /* uint8 data[1]; */
8523 +} wl_wpa_header_t;
8524 +
8525 +#define WL_WPA_HEADER_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN + 2 + WL_WPA_MSG_IFNAME_MAX)
8526 +
8527 +/* WPA driver message ethertype - private between wlc and nas */
8528 +#define WL_WPA_ETHER_TYPE 0x9999
8529 +
8530 +/* WPA driver message current version */
8531 +#define WL_WPA_MSG_VERSION 2
8532 +
8533 +/* Type field values for the 802.2 driver messages for WPA. */
8534 +#define WLC_ASSOC_MSG 1
8535 +#define WLC_DISASSOC_MSG 2
8536 +#define WLC_PTK_MIC_MSG 3
8537 +#define WLC_GTK_MIC_MSG 4
8538 +
8539 +/* 802.1x driver message */
8540 +typedef struct wl_eapol_header {
8541 + struct ether_header eth;
8542 + struct dot11_llc_snap_header snap;
8543 + uint8 version;
8544 + uint8 reserved;
8545 + char ifname[WL_WPA_MSG_IFNAME_MAX];
8546 + /* version specific data */
8547 + /* uint8 802_1x_msg[1]; */
8548 +} wl_eapol_header_t;
8549 +
8550 +#define WL_EAPOL_HEADER_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN + 2 + WL_WPA_MSG_IFNAME_MAX)
8551 +
8552 +/* 802.1x driver message ethertype - private between wlc and nas */
8553 +#define WL_EAPOL_ETHER_TYPE 0x999A
8554 +
8555 +/* 802.1x driver message current version */
8556 +#define WL_EAPOL_MSG_VERSION 1
8557 +
8558 +#define WL_SECPVT_DATA_LEN (ETHER_HDR_LEN + 4 + WL_WPA_MSG_IFNAME_MAX)
8559 +
8560 +/* message header for the private data exchange between nas and wl*/
8561 +typedef struct wl_secpvt_data {
8562 + struct ether_header eth; /* use the Type field in the eth header with the private type*/
8563 + uint8 version;
8564 + uint8 sub_type;
8565 + uint16 data_len;
8566 + char ifname[WL_WPA_MSG_IFNAME_MAX];
8567 + /* version specific data */
8568 + /* uint8 802_1x_msg[1]; */
8569 +}wl_secpvt_data_t;
8570 +
8571 +
8572 +/* srom read/write struct passed through ioctl */
8573 +typedef struct {
8574 + uint byteoff; /* byte offset */
8575 + uint nbytes; /* number of bytes */
8576 + uint16 buf[1];
8577 +} srom_rw_t;
8578 +
8579 +/* R_REG and W_REG struct passed through ioctl */
8580 +typedef struct {
8581 + uint32 byteoff; /* byte offset of the field in d11regs_t */
8582 + uint32 val; /* read/write value of the field */
8583 + uint32 size; /* sizeof the field */
8584 +} rw_reg_t;
8585 +
8586 +/* Structure used by GET/SET_ATTEN ioctls */
8587 +typedef struct {
8588 + uint16 auto_ctrl; /* 1: Automatic control, 0: overriden */
8589 + uint16 bb; /* Baseband attenuation */
8590 + uint16 radio; /* Radio attenuation */
8591 + uint16 txctl1; /* Radio TX_CTL1 value */
8592 +} atten_t;
8593 +
8594 +/* Used to get specific STA parameters */
8595 +typedef struct {
8596 + uint32 val;
8597 + struct ether_addr ea;
8598 +} scb_val_t;
8599 +
8600 +/* Event data type */
8601 +typedef struct {
8602 + uint msg; /* Message (see below) */
8603 + struct ether_addr *addr; /* Station address (if applicable) */
8604 + uint status; /* Status code (see below) */
8605 + uint reason; /* Reason code (if applicable) */
8606 + uint auth_type; /* WLC_E_AUTH */
8607 + bool link; /* WLC_E_LINK */
8608 + bool group; /* WLC_E_MIC_ERROR */
8609 + bool flush_txq; /* WLC_E_MIC_ERROR */
8610 +} wlc_event_t;
8611 +
8612 +typedef struct {
8613 + uint16 ver; /* version of this struct */
8614 + uint16 len; /* length in bytes of this structure */
8615 + uint16 cap; /* sta's advertized capabilities */
8616 + uint32 flags; /* flags defined below */
8617 + uint32 idle; /* time since data pkt rx'd from sta */
8618 + struct ether_addr ea; /* Station address */
8619 + wl_rateset_t rateset; /* rateset in use */
8620 + uint32 in; /* seconds elapsed since associated */
8621 + uint32 listen_interval_inms; /* Min Listen interval in ms for this STA*/
8622 +} sta_info_t;
8623 +
8624 +#define WL_STA_VER 2
8625 +
8626 +/* flags fields */
8627 +#define WL_STA_BRCM 0x01
8628 +#define WL_STA_WME 0x02
8629 +#define WL_STA_ABCAP 0x04
8630 +#define WL_STA_AUTHE 0x08
8631 +#define WL_STA_ASSOC 0x10
8632 +#define WL_STA_AUTHO 0x20
8633 +#define WL_STA_WDS 0x40
8634 +#define WL_WDS_LINKUP 0x80
8635 +
8636 +/* Event messages */
8637 +#define WLC_E_SET_SSID 1
8638 +#define WLC_E_JOIN 2
8639 +#define WLC_E_START 3
8640 +#define WLC_E_AUTH 4
8641 +#define WLC_E_AUTH_IND 5
8642 +#define WLC_E_DEAUTH 6
8643 +#define WLC_E_DEAUTH_IND 7
8644 +#define WLC_E_ASSOC 8
8645 +#define WLC_E_ASSOC_IND 9
8646 +#define WLC_E_REASSOC 10
8647 +#define WLC_E_REASSOC_IND 11
8648 +#define WLC_E_DISASSOC 12
8649 +#define WLC_E_DISASSOC_IND 13
8650 +#define WLC_E_QUIET_START 14 /* 802.11h Quiet period started */
8651 +#define WLC_E_QUIET_END 15 /* 802.11h Quiet period ended */
8652 +#define WLC_E_GOT_BEACONS 16
8653 +#define WLC_E_LINK 17 /* Link indication */
8654 +#define WLC_E_MIC_ERROR 18 /* TKIP MIC error occurred */
8655 +#define WLC_E_NDIS_LINK 19 /* NDIS style link indication */
8656 +#define WLC_E_ROAM 20
8657 +#define WLC_E_TXFAIL 21 /* dot11FailedCount (txfail) */
8658 +#define WLC_E_LAST 22
8659 +
8660 +/* Event status codes */
8661 +#define WLC_E_STATUS_SUCCESS 0
8662 +#define WLC_E_STATUS_FAIL 1
8663 +#define WLC_E_STATUS_TIMEOUT 2
8664 +#define WLC_E_STATUS_NO_NETWORKS 3
8665 +#define WLC_E_STATUS_ABORT 4
8666 +
8667 +typedef struct wlc_event_cb {
8668 + uint msg; /* Event message or 0 for all */
8669 + void (*fn)(void *, wlc_event_t *); /* Callback function */
8670 + void *context; /* Passed to callback function */
8671 + struct wlc_event_cb *next; /* Next in the chain */
8672 +} wlc_event_cb_t;
8673 +
8674 +/*
8675 + * Country locale determines which channels are available to us.
8676 + */
8677 +typedef enum _wlc_locale {
8678 + WLC_WW = 0, /* Worldwide */
8679 + WLC_THA, /* Thailand */
8680 + WLC_ISR, /* Israel */
8681 + WLC_JDN, /* Jordan */
8682 + WLC_PRC, /* China */
8683 + WLC_JPN, /* Japan */
8684 + WLC_FCC, /* USA */
8685 + WLC_EUR, /* Europe */
8686 + WLC_USL, /* US Low Band only */
8687 + WLC_JPH, /* Japan High Band only */
8688 + WLC_ALL, /* All the channels in this band */
8689 + WLC_11D, /* Represents locale recieved by 11d beacons */
8690 + WLC_LAST_LOCALE,
8691 + WLC_UNDEFINED_LOCALE = 0xf
8692 +} wlc_locale_t;
8693 +
8694 +/* channel encoding */
8695 +typedef struct channel_info {
8696 + int hw_channel;
8697 + int target_channel;
8698 + int scan_channel;
8699 +} channel_info_t;
8700 +
8701 +/* For ioctls that take a list of MAC addresses */
8702 +struct maclist {
8703 + uint count; /* number of MAC addresses */
8704 + struct ether_addr ea[1]; /* variable length array of MAC addresses */
8705 +};
8706 +
8707 +/* get pkt count struct passed through ioctl */
8708 +typedef struct get_pktcnt {
8709 + uint rx_good_pkt;
8710 + uint rx_bad_pkt;
8711 + uint tx_good_pkt;
8712 + uint tx_bad_pkt;
8713 +} get_pktcnt_t;
8714 +
8715 +/* Linux network driver ioctl encoding */
8716 +typedef struct wl_ioctl {
8717 + uint cmd; /* common ioctl definition */
8718 + void *buf; /* pointer to user buffer */
8719 + uint len; /* length of user buffer */
8720 + bool set; /* get or set request (optional) */
8721 + uint used; /* bytes read or written (optional) */
8722 + uint needed; /* bytes needed (optional) */
8723 +} wl_ioctl_t;
8724 +
8725 +/*
8726 + * Structure for passing hardware and software
8727 + * revision info up from the driver.
8728 + */
8729 +typedef struct wlc_rev_info {
8730 + uint vendorid; /* PCI vendor id */
8731 + uint deviceid; /* device id of chip */
8732 + uint radiorev; /* radio revision */
8733 + uint chiprev; /* chip revision */
8734 + uint corerev; /* core revision */
8735 + uint boardid; /* board identifier (usu. PCI sub-device id) */
8736 + uint boardvendor; /* board vendor (usu. PCI sub-vendor id) */
8737 + uint boardrev; /* board revision */
8738 + uint driverrev; /* driver version */
8739 + uint ucoderev; /* microcode version */
8740 + uint bus; /* bus type */
8741 + uint chipnum; /* chip number */
8742 +} wlc_rev_info_t;
8743 +
8744 +/* check this magic number */
8745 +#define WLC_IOCTL_MAGIC 0x14e46c77
8746 +
8747 +/* bump this number if you change the ioctl interface */
8748 +#define WLC_IOCTL_VERSION 1
8749 +
8750 +#define WLC_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */
8751 +#define WLC_IOCTL_SMLEN 256 /* "small" length ioctl buffer required */
8752 +
8753 +/* common ioctl definitions */
8754 +#define WLC_GET_MAGIC 0
8755 +#define WLC_GET_VERSION 1
8756 +#define WLC_UP 2
8757 +#define WLC_DOWN 3
8758 +#define WLC_DUMP 6
8759 +#define WLC_GET_MSGLEVEL 7
8760 +#define WLC_SET_MSGLEVEL 8
8761 +#define WLC_GET_PROMISC 9
8762 +#define WLC_SET_PROMISC 10
8763 +#define WLC_GET_RATE 12
8764 +#define WLC_SET_RATE 13
8765 +#define WLC_GET_INSTANCE 14
8766 +#define WLC_GET_FRAG 15
8767 +#define WLC_SET_FRAG 16
8768 +#define WLC_GET_RTS 17
8769 +#define WLC_SET_RTS 18
8770 +#define WLC_GET_INFRA 19
8771 +#define WLC_SET_INFRA 20
8772 +#define WLC_GET_AUTH 21
8773 +#define WLC_SET_AUTH 22
8774 +#define WLC_GET_BSSID 23
8775 +#define WLC_SET_BSSID 24
8776 +#define WLC_GET_SSID 25
8777 +#define WLC_SET_SSID 26
8778 +#define WLC_RESTART 27
8779 +#define WLC_GET_CHANNEL 29
8780 +#define WLC_SET_CHANNEL 30
8781 +#define WLC_GET_SRL 31
8782 +#define WLC_SET_SRL 32
8783 +#define WLC_GET_LRL 33
8784 +#define WLC_SET_LRL 34
8785 +#define WLC_GET_PLCPHDR 35
8786 +#define WLC_SET_PLCPHDR 36
8787 +#define WLC_GET_RADIO 37
8788 +#define WLC_SET_RADIO 38
8789 +#define WLC_GET_PHYTYPE 39
8790 +#define WLC_GET_WEP 42
8791 +#define WLC_SET_WEP 43
8792 +#define WLC_GET_KEY 44
8793 +#define WLC_SET_KEY 45
8794 +#define WLC_SCAN 50
8795 +#define WLC_SCAN_RESULTS 51
8796 +#define WLC_DISASSOC 52
8797 +#define WLC_REASSOC 53
8798 +#define WLC_GET_ROAM_TRIGGER 54
8799 +#define WLC_SET_ROAM_TRIGGER 55
8800 +#define WLC_GET_TXANT 61
8801 +#define WLC_SET_TXANT 62
8802 +#define WLC_GET_ANTDIV 63
8803 +#define WLC_SET_ANTDIV 64
8804 +#define WLC_GET_TXPWR 65
8805 +#define WLC_SET_TXPWR 66
8806 +#define WLC_GET_CLOSED 67
8807 +#define WLC_SET_CLOSED 68
8808 +#define WLC_GET_MACLIST 69
8809 +#define WLC_SET_MACLIST 70
8810 +#define WLC_GET_RATESET 71
8811 +#define WLC_SET_RATESET 72
8812 +#define WLC_GET_LOCALE 73
8813 +#define WLC_SET_LOCALE 74
8814 +#define WLC_GET_BCNPRD 75
8815 +#define WLC_SET_BCNPRD 76
8816 +#define WLC_GET_DTIMPRD 77
8817 +#define WLC_SET_DTIMPRD 78
8818 +#define WLC_GET_SROM 79
8819 +#define WLC_SET_SROM 80
8820 +#define WLC_GET_WEP_RESTRICT 81
8821 +#define WLC_SET_WEP_RESTRICT 82
8822 +#define WLC_GET_COUNTRY 83
8823 +#define WLC_SET_COUNTRY 84
8824 +#define WLC_GET_REVINFO 98
8825 +#define WLC_GET_MACMODE 105
8826 +#define WLC_SET_MACMODE 106
8827 +#define WLC_GET_GMODE 109
8828 +#define WLC_SET_GMODE 110
8829 +#define WLC_GET_CURR_RATESET 114 /* current rateset */
8830 +#define WLC_GET_SCANSUPPRESS 115
8831 +#define WLC_SET_SCANSUPPRESS 116
8832 +#define WLC_GET_AP 117
8833 +#define WLC_SET_AP 118
8834 +#define WLC_GET_EAP_RESTRICT 119
8835 +#define WLC_SET_EAP_RESTRICT 120
8836 +#define WLC_GET_WDSLIST 123
8837 +#define WLC_SET_WDSLIST 124
8838 +#define WLC_GET_RSSI 127
8839 +#define WLC_GET_WSEC 133
8840 +#define WLC_SET_WSEC 134
8841 +#define WLC_GET_BSS_INFO 136
8842 +#define WLC_GET_LAZYWDS 138
8843 +#define WLC_SET_LAZYWDS 139
8844 +#define WLC_GET_BANDLIST 140
8845 +#define WLC_GET_BAND 141
8846 +#define WLC_SET_BAND 142
8847 +#define WLC_GET_SHORTSLOT 144
8848 +#define WLC_GET_SHORTSLOT_OVERRIDE 145
8849 +#define WLC_SET_SHORTSLOT_OVERRIDE 146
8850 +#define WLC_GET_SHORTSLOT_RESTRICT 147
8851 +#define WLC_SET_SHORTSLOT_RESTRICT 148
8852 +#define WLC_GET_GMODE_PROTECTION 149
8853 +#define WLC_GET_GMODE_PROTECTION_OVERRIDE 150
8854 +#define WLC_SET_GMODE_PROTECTION_OVERRIDE 151
8855 +#define WLC_UPGRADE 152
8856 +#define WLC_GET_MRATE 153
8857 +#define WLC_SET_MRATE 154
8858 +#define WLC_GET_ASSOCLIST 159
8859 +#define WLC_GET_CLK 160
8860 +#define WLC_SET_CLK 161
8861 +#define WLC_GET_UP 162
8862 +#define WLC_OUT 163
8863 +#define WLC_GET_WPA_AUTH 164
8864 +#define WLC_SET_WPA_AUTH 165
8865 +#define WLC_GET_GMODE_PROTECTION_CONTROL 178
8866 +#define WLC_SET_GMODE_PROTECTION_CONTROL 179
8867 +#define WLC_GET_PHYLIST 180
8868 +#define WLC_GET_KEY_SEQ 183
8869 +#define WLC_GET_GMODE_PROTECTION_CTS 198
8870 +#define WLC_SET_GMODE_PROTECTION_CTS 199
8871 +#define WLC_GET_PIOMODE 203
8872 +#define WLC_SET_PIOMODE 204
8873 +#define WLC_SET_LED 209
8874 +#define WLC_GET_LED 210
8875 +#define WLC_GET_CHANNEL_SEL 215
8876 +#define WLC_START_CHANNEL_SEL 216
8877 +#define WLC_GET_VALID_CHANNELS 217
8878 +#define WLC_GET_FAKEFRAG 218
8879 +#define WLC_SET_FAKEFRAG 219
8880 +#define WLC_GET_WET 230
8881 +#define WLC_SET_WET 231
8882 +#define WLC_GET_KEY_PRIMARY 235
8883 +#define WLC_SET_KEY_PRIMARY 236
8884 +#define WLC_WDS_GET_REMOTE_HWADDR 246 /* currently handled in wl_linux.c/wl_vx.c */
8885 +#define WLC_SET_CS_SCAN_TIMER 248
8886 +#define WLC_GET_CS_SCAN_TIMER 249
8887 +#define WLC_CURRENT_PWR 256
8888 +#define WLC_GET_CHANNELS_IN_COUNTRY 260
8889 +#define WLC_GET_COUNTRY_LIST 261
8890 +#define WLC_GET_VAR 262 /* get value of named variable */
8891 +#define WLC_SET_VAR 263 /* set named variable to value */
8892 +#define WLC_NVRAM_GET 264
8893 +#define WLC_NVRAM_SET 265
8894 +#define WLC_SET_WSEC_PMK 268
8895 +#define WLC_GET_AUTH_MODE 269
8896 +#define WLC_SET_AUTH_MODE 270
8897 +#define WLC_LAST 273 /* do not change - use get_var/set_var */
8898 +
8899 +/*
8900 + * Minor kludge alert:
8901 + * Duplicate a few definitions that irelay requires from epiioctl.h here
8902 + * so caller doesn't have to include this file and epiioctl.h .
8903 + * If this grows any more, it would be time to move these irelay-specific
8904 + * definitions out of the epiioctl.h and into a separate driver common file.
8905 + */
8906 +#ifndef EPICTRL_COOKIE
8907 +#define EPICTRL_COOKIE 0xABADCEDE
8908 +#endif
8909 +
8910 +/* vx wlc ioctl's offset */
8911 +#define CMN_IOCTL_OFF 0x180
8912 +
8913 +/*
8914 + * custom OID support
8915 + *
8916 + * 0xFF - implementation specific OID
8917 + * 0xE4 - first byte of Broadcom PCI vendor ID
8918 + * 0x14 - second byte of Broadcom PCI vendor ID
8919 + * 0xXX - the custom OID number
8920 + */
8921 +
8922 +/* begin 0x1f values beyond the start of the ET driver range. */
8923 +#define WL_OID_BASE 0xFFE41420
8924 +
8925 +/* NDIS overrides */
8926 +#define OID_WL_GETINSTANCE (WL_OID_BASE + WLC_GET_INSTANCE)
8927 +
8928 +#define WL_DECRYPT_STATUS_SUCCESS 1
8929 +#define WL_DECRYPT_STATUS_FAILURE 2
8930 +#define WL_DECRYPT_STATUS_UNKNOWN 3
8931 +
8932 +/* allows user-mode app to poll the status of USB image upgrade */
8933 +#define WLC_UPGRADE_SUCCESS 0
8934 +#define WLC_UPGRADE_PENDING 1
8935 +
8936 +/* Bit masks for radio disabled status - returned by WL_GET_RADIO */
8937 +#define WL_RADIO_SW_DISABLE (1<<0)
8938 +#define WL_RADIO_HW_DISABLE (1<<1)
8939 +#define WL_RADIO_UNASSOC_DISABLE (1<<2)
8940 +
8941 +/* Override bit for WLC_SET_TXPWR. if set, ignore other level limits */
8942 +#define WL_TXPWR_OVERRIDE (1<<31)
8943 +
8944 +
8945 +/* Bus types */
8946 +#define WL_SB_BUS 0 /* Silicon Backplane */
8947 +#define WL_PCI_BUS 1 /* PCI target */
8948 +#define WL_PCMCIA_BUS 2 /* PCMCIA target */
8949 +
8950 +/* band types */
8951 +#define WLC_BAND_AUTO 0 /* auto-select */
8952 +#define WLC_BAND_A 1 /* "a" band (5 Ghz) */
8953 +#define WLC_BAND_B 2 /* "b" band (2.4 Ghz) */
8954 +
8955 +/* MAC list modes */
8956 +#define WLC_MACMODE_DISABLED 0 /* MAC list disabled */
8957 +#define WLC_MACMODE_DENY 1 /* Deny specified (i.e. allow unspecified) */
8958 +#define WLC_MACMODE_ALLOW 2 /* Allow specified (i.e. deny unspecified) */
8959 +
8960 +/*
8961 + *
8962 + */
8963 +#define GMODE_LEGACY_B 0
8964 +#define GMODE_AUTO 1
8965 +#define GMODE_ONLY 2
8966 +#define GMODE_B_DEFERRED 3
8967 +#define GMODE_PERFORMANCE 4
8968 +#define GMODE_LRS 5
8969 +#define GMODE_MAX 6
8970 +
8971 +/* values for PLCPHdr_override */
8972 +#define WLC_PLCP_AUTO -1
8973 +#define WLC_PLCP_SHORT 0
8974 +#define WLC_PLCP_LONG 1
8975 +
8976 +/* values for g_protection_override */
8977 +#define WLC_G_PROTECTION_AUTO -1
8978 +#define WLC_G_PROTECTION_OFF 0
8979 +#define WLC_G_PROTECTION_ON 1
8980 +
8981 +/* values for g_protection_control */
8982 +#define WLC_G_PROTECTION_CTL_OFF 0
8983 +#define WLC_G_PROTECTION_CTL_LOCAL 1
8984 +#define WLC_G_PROTECTION_CTL_OVERLAP 2
8985 +
8986 +/* Values for PM */
8987 +#define PM_OFF 0
8988 +#define PM_MAX 1
8989 +#define PM_FAST 2
8990 +
8991 +
8992 +
8993 +
8994 +
8995 +/* 802.11h enforcement levels */
8996 +#define SPECT_MNGMT_OFF 0 /* 11h disabled */
8997 +#define SPECT_MNGMT_LOOSE 1 /* qllow scan lists to contain non-11h AP */
8998 +#define SPECT_MNGMT_STRICT 2 /* prune out non-11h APs from scan list */
8999 +
9000 +
9001 +#define WL_CHAN_VALID_HW (1 << 0) /* valid with current HW */
9002 +#define WL_CHAN_VALID_SW (1 << 1) /* valid with current country setting */
9003 +#define WL_CHAN_BAND_A (1 << 2) /* A-band channel */
9004 +#define WL_CHAN_RADAR (1 << 3) /* radar sensitive channel */
9005 +#define WL_CHAN_INACTIVE (1 << 4) /* temporarily out of service due to radar */
9006 +#define WL_CHAN_RADAR_PASSIVE (1 << 5) /* radar channel is in passive mode */
9007 +
9008 +
9009 +/* max # of leds supported by GPIO (gpio pin# == led index#) */
9010 +#define WL_LED_NUMGPIO 16 /* gpio 0-15 */
9011 +
9012 +/* led per-pin behaviors */
9013 +#define WL_LED_OFF 0 /* always off */
9014 +#define WL_LED_ON 1 /* always on */
9015 +#define WL_LED_ACTIVITY 2 /* activity */
9016 +#define WL_LED_RADIO 3 /* radio enabled */
9017 +#define WL_LED_ARADIO 4 /* 5 Ghz radio enabled */
9018 +#define WL_LED_BRADIO 5 /* 2.4Ghz radio enabled */
9019 +#define WL_LED_BGMODE 6 /* on if gmode, off if bmode */
9020 +#define WL_LED_WI1 7
9021 +#define WL_LED_WI2 8
9022 +#define WL_LED_WI3 9
9023 +#define WL_LED_ASSOC 10 /* associated state indicator */
9024 +#define WL_LED_INACTIVE 11 /* null behavior (clears default behavior) */
9025 +#define WL_LED_NUMBEHAVIOR 12
9026 +
9027 +/* led behavior numeric value format */
9028 +#define WL_LED_BEH_MASK 0x7f /* behavior mask */
9029 +#define WL_LED_AL_MASK 0x80 /* activelow (polarity) bit */
9030 +
9031 +
9032 +/* WDS link local endpoint WPA role */
9033 +#define WL_WDS_WPA_ROLE_AUTH 0 /* authenticator */
9034 +#define WL_WDS_WPA_ROLE_SUP 1 /* supplicant */
9035 +#define WL_WDS_WPA_ROLE_AUTO 255 /* auto, based on mac addr value */
9036 +
9037 +/* Structures and constants used for "vndr_ie" IOVar interface */
9038 +#define VNDR_IE_CMD_LEN 4 /* length of the set command string: "add", "del" (+ NULL) */
9039 +
9040 +/* 802.11 Mgmt Packet flags */
9041 +#define VNDR_IE_BEACON_FLAG 0x1
9042 +#define VNDR_IE_PRBRSP_FLAG 0x2
9043 +#define VNDR_IE_ASSOCRSP_FLAG 0x4
9044 +#define VNDR_IE_AUTHRSP_FLAG 0x8
9045 +
9046 +typedef struct vndr_ie_info {
9047 + uint32 pktflag; /* bitmask indicating which packet(s) contain this IE */
9048 + vndr_ie_t vndr_ie_data; /* vendor IE data */
9049 +} vndr_ie_info_t;
9050 +
9051 +typedef struct vndr_ie_buf {
9052 + int iecount; /* number of entries in the vndr_ie_list[] array */
9053 + vndr_ie_info_t vndr_ie_list[1]; /* variable size list of vndr_ie_info_t structs */
9054 +} vndr_ie_buf_t;
9055 +
9056 +typedef struct vndr_ie_setbuf {
9057 + char cmd[VNDR_IE_CMD_LEN]; /* vndr_ie IOVar set command : "add", "del" + NULL */
9058 + vndr_ie_buf_t vndr_ie_buffer; /* buffer containing Vendor IE list information */
9059 +} vndr_ie_setbuf_t;
9060 +
9061 +#if !defined(__GNUC__)
9062 +#pragma pack(pop)
9063 +#endif
9064 +
9065 +#endif /* _wlioctl_h_ */
9066 diff -Nur linux-2.4.30/arch/mips/bcm947xx/Makefile linux-2.4.30-brcm/arch/mips/bcm947xx/Makefile
9067 --- linux-2.4.30/arch/mips/bcm947xx/Makefile 1970-01-01 01:00:00.000000000 +0100
9068 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/Makefile 2005-05-26 15:07:37.000000000 +0200
9069 @@ -0,0 +1,15 @@
9070 +#
9071 +# Makefile for the BCM947xx specific kernel interface routines
9072 +# under Linux.
9073 +#
9074 +
9075 +EXTRA_CFLAGS+=-I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
9076 +
9077 +O_TARGET := bcm947xx.o
9078 +
9079 +export-objs := nvram_linux.o setup.o
9080 +obj-y := prom.o setup.o time.o sbmips.o gpio.o
9081 +obj-y += nvram.o nvram_linux.o
9082 +obj-$(CONFIG_PCI) += sbpci.o pcibios.o
9083 +
9084 +include $(TOPDIR)/Rules.make
9085 diff -Nur linux-2.4.30/arch/mips/bcm947xx/nvram.c linux-2.4.30-brcm/arch/mips/bcm947xx/nvram.c
9086 --- linux-2.4.30/arch/mips/bcm947xx/nvram.c 1970-01-01 01:00:00.000000000 +0100
9087 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/nvram.c 2005-05-24 17:58:29.000000000 +0200
9088 @@ -0,0 +1,321 @@
9089 +/*
9090 + * NVRAM variable manipulation (common)
9091 + *
9092 + * Copyright 2004, Broadcom Corporation
9093 + * All Rights Reserved.
9094 + *
9095 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9096 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9097 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9098 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9099 + *
9100 + * $Id$
9101 + */
9102 +
9103 +#include <typedefs.h>
9104 +#include <osl.h>
9105 +#include <bcmendian.h>
9106 +#include <bcmnvram.h>
9107 +#include <bcmutils.h>
9108 +#include <sbsdram.h>
9109 +
9110 +extern struct nvram_tuple * BCMINIT(_nvram_realloc)(struct nvram_tuple *t, const char *name, const char *value);
9111 +extern void BCMINIT(_nvram_free)(struct nvram_tuple *t);
9112 +extern int BCMINIT(_nvram_read)(void *buf);
9113 +
9114 +char * BCMINIT(_nvram_get)(const char *name);
9115 +int BCMINIT(_nvram_set)(const char *name, const char *value);
9116 +int BCMINIT(_nvram_unset)(const char *name);
9117 +int BCMINIT(_nvram_getall)(char *buf, int count);
9118 +int BCMINIT(_nvram_commit)(struct nvram_header *header);
9119 +int BCMINIT(_nvram_init)(void);
9120 +void BCMINIT(_nvram_exit)(void);
9121 +
9122 +static struct nvram_tuple * BCMINITDATA(nvram_hash)[257];
9123 +static struct nvram_tuple * nvram_dead;
9124 +
9125 +/* Free all tuples. Should be locked. */
9126 +static void
9127 +BCMINITFN(nvram_free)(void)
9128 +{
9129 + uint i;
9130 + struct nvram_tuple *t, *next;
9131 +
9132 + /* Free hash table */
9133 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
9134 + for (t = BCMINIT(nvram_hash)[i]; t; t = next) {
9135 + next = t->next;
9136 + BCMINIT(_nvram_free)(t);
9137 + }
9138 + BCMINIT(nvram_hash)[i] = NULL;
9139 + }
9140 +
9141 + /* Free dead table */
9142 + for (t = nvram_dead; t; t = next) {
9143 + next = t->next;
9144 + BCMINIT(_nvram_free)(t);
9145 + }
9146 + nvram_dead = NULL;
9147 +
9148 + /* Indicate to per-port code that all tuples have been freed */
9149 + BCMINIT(_nvram_free)(NULL);
9150 +}
9151 +
9152 +/* String hash */
9153 +static INLINE uint
9154 +hash(const char *s)
9155 +{
9156 + uint hash = 0;
9157 +
9158 + while (*s)
9159 + hash = 31 * hash + *s++;
9160 +
9161 + return hash;
9162 +}
9163 +
9164 +/* (Re)initialize the hash table. Should be locked. */
9165 +static int
9166 +BCMINITFN(nvram_rehash)(struct nvram_header *header)
9167 +{
9168 + char buf[] = "0xXXXXXXXX", *name, *value, *end, *eq;
9169 +
9170 + /* (Re)initialize hash table */
9171 + BCMINIT(nvram_free)();
9172 +
9173 + /* Parse and set "name=value\0 ... \0\0" */
9174 + name = (char *) &header[1];
9175 + end = (char *) header + NVRAM_SPACE - 2;
9176 + end[0] = end[1] = '\0';
9177 + for (; *name; name = value + strlen(value) + 1) {
9178 + if (!(eq = strchr(name, '=')))
9179 + break;
9180 + *eq = '\0';
9181 + value = eq + 1;
9182 + BCMINIT(_nvram_set)(name, value);
9183 + *eq = '=';
9184 + }
9185 +
9186 + /* Set special SDRAM parameters */
9187 + if (!BCMINIT(_nvram_get)("sdram_init")) {
9188 + sprintf(buf, "0x%04X", (uint16)(header->crc_ver_init >> 16));
9189 + BCMINIT(_nvram_set)("sdram_init", buf);
9190 + }
9191 + if (!BCMINIT(_nvram_get)("sdram_config")) {
9192 + sprintf(buf, "0x%04X", (uint16)(header->config_refresh & 0xffff));
9193 + BCMINIT(_nvram_set)("sdram_config", buf);
9194 + }
9195 + if (!BCMINIT(_nvram_get)("sdram_refresh")) {
9196 + sprintf(buf, "0x%04X", (uint16)((header->config_refresh >> 16) & 0xffff));
9197 + BCMINIT(_nvram_set)("sdram_refresh", buf);
9198 + }
9199 + if (!BCMINIT(_nvram_get)("sdram_ncdl")) {
9200 + sprintf(buf, "0x%08X", header->config_ncdl);
9201 + BCMINIT(_nvram_set)("sdram_ncdl", buf);
9202 + }
9203 +
9204 + return 0;
9205 +}
9206 +
9207 +/* Get the value of an NVRAM variable. Should be locked. */
9208 +char *
9209 +BCMINITFN(_nvram_get)(const char *name)
9210 +{
9211 + uint i;
9212 + struct nvram_tuple *t;
9213 + char *value;
9214 +
9215 + if (!name)
9216 + return NULL;
9217 +
9218 + /* Hash the name */
9219 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
9220 +
9221 + /* Find the associated tuple in the hash table */
9222 + for (t = BCMINIT(nvram_hash)[i]; t && strcmp(t->name, name); t = t->next);
9223 +
9224 + value = t ? t->value : NULL;
9225 +
9226 + return value;
9227 +}
9228 +
9229 +/* Get the value of an NVRAM variable. Should be locked. */
9230 +int
9231 +BCMINITFN(_nvram_set)(const char *name, const char *value)
9232 +{
9233 + uint i;
9234 + struct nvram_tuple *t, *u, **prev;
9235 +
9236 + /* Hash the name */
9237 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
9238 +
9239 + /* Find the associated tuple in the hash table */
9240 + for (prev = &BCMINIT(nvram_hash)[i], t = *prev; t && strcmp(t->name, name); prev = &t->next, t = *prev);
9241 +
9242 + /* (Re)allocate tuple */
9243 + if (!(u = BCMINIT(_nvram_realloc)(t, name, value)))
9244 + return -12; /* -ENOMEM */
9245 +
9246 + /* Value reallocated */
9247 + if (t && t == u)
9248 + return 0;
9249 +
9250 + /* Move old tuple to the dead table */
9251 + if (t) {
9252 + *prev = t->next;
9253 + t->next = nvram_dead;
9254 + nvram_dead = t;
9255 + }
9256 +
9257 + /* Add new tuple to the hash table */
9258 + u->next = BCMINIT(nvram_hash)[i];
9259 + BCMINIT(nvram_hash)[i] = u;
9260 +
9261 + return 0;
9262 +}
9263 +
9264 +/* Unset the value of an NVRAM variable. Should be locked. */
9265 +int
9266 +BCMINITFN(_nvram_unset)(const char *name)
9267 +{
9268 + uint i;
9269 + struct nvram_tuple *t, **prev;
9270 +
9271 + if (!name)
9272 + return 0;
9273 +
9274 + /* Hash the name */
9275 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
9276 +
9277 + /* Find the associated tuple in the hash table */
9278 + for (prev = &BCMINIT(nvram_hash)[i], t = *prev; t && strcmp(t->name, name); prev = &t->next, t = *prev);
9279 +
9280 + /* Move it to the dead table */
9281 + if (t) {
9282 + *prev = t->next;
9283 + t->next = nvram_dead;
9284 + nvram_dead = t;
9285 + }
9286 +
9287 + return 0;
9288 +}
9289 +
9290 +/* Get all NVRAM variables. Should be locked. */
9291 +int
9292 +BCMINITFN(_nvram_getall)(char *buf, int count)
9293 +{
9294 + uint i;
9295 + struct nvram_tuple *t;
9296 + int len = 0;
9297 +
9298 + bzero(buf, count);
9299 +
9300 + /* Write name=value\0 ... \0\0 */
9301 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
9302 + for (t = BCMINIT(nvram_hash)[i]; t; t = t->next) {
9303 + if ((count - len) > (strlen(t->name) + 1 + strlen(t->value) + 1))
9304 + len += sprintf(buf + len, "%s=%s", t->name, t->value) + 1;
9305 + else
9306 + break;
9307 + }
9308 + }
9309 +
9310 + return 0;
9311 +}
9312 +
9313 +/* Regenerate NVRAM. Should be locked. */
9314 +int
9315 +BCMINITFN(_nvram_commit)(struct nvram_header *header)
9316 +{
9317 + char *init, *config, *refresh, *ncdl;
9318 + char *ptr, *end;
9319 + int i;
9320 + struct nvram_tuple *t;
9321 + struct nvram_header tmp;
9322 + uint8 crc;
9323 +
9324 + /* Regenerate header */
9325 + header->magic = NVRAM_MAGIC;
9326 + header->crc_ver_init = (NVRAM_VERSION << 8);
9327 + if (!(init = BCMINIT(_nvram_get)("sdram_init")) ||
9328 + !(config = BCMINIT(_nvram_get)("sdram_config")) ||
9329 + !(refresh = BCMINIT(_nvram_get)("sdram_refresh")) ||
9330 + !(ncdl = BCMINIT(_nvram_get)("sdram_ncdl"))) {
9331 + header->crc_ver_init |= SDRAM_INIT << 16;
9332 + header->config_refresh = SDRAM_CONFIG;
9333 + header->config_refresh |= SDRAM_REFRESH << 16;
9334 + header->config_ncdl = 0;
9335 + } else {
9336 + header->crc_ver_init |= (bcm_strtoul(init, NULL, 0) & 0xffff) << 16;
9337 + header->config_refresh = bcm_strtoul(config, NULL, 0) & 0xffff;
9338 + header->config_refresh |= (bcm_strtoul(refresh, NULL, 0) & 0xffff) << 16;
9339 + header->config_ncdl = bcm_strtoul(ncdl, NULL, 0);
9340 + }
9341 +
9342 + /* Clear data area */
9343 + ptr = (char *) header + sizeof(struct nvram_header);
9344 + bzero(ptr, NVRAM_SPACE - sizeof(struct nvram_header));
9345 +
9346 + /* Leave space for a double NUL at the end */
9347 + end = (char *) header + NVRAM_SPACE - 2;
9348 +
9349 + /* Write out all tuples */
9350 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
9351 + for (t = BCMINIT(nvram_hash)[i]; t; t = t->next) {
9352 + if ((ptr + strlen(t->name) + 1 + strlen(t->value) + 1) > end)
9353 + break;
9354 + ptr += sprintf(ptr, "%s=%s", t->name, t->value) + 1;
9355 + }
9356 + }
9357 +
9358 + /* End with a double NUL */
9359 + ptr += 2;
9360 +
9361 + /* Set new length */
9362 + header->len = ROUNDUP(ptr - (char *) header, 4);
9363 +
9364 + /* Little-endian CRC8 over the last 11 bytes of the header */
9365 + tmp.crc_ver_init = htol32(header->crc_ver_init);
9366 + tmp.config_refresh = htol32(header->config_refresh);
9367 + tmp.config_ncdl = htol32(header->config_ncdl);
9368 + crc = hndcrc8((char *) &tmp + 9, sizeof(struct nvram_header) - 9, CRC8_INIT_VALUE);
9369 +
9370 + /* Continue CRC8 over data bytes */
9371 + crc = hndcrc8((char *) &header[1], header->len - sizeof(struct nvram_header), crc);
9372 +
9373 + /* Set new CRC8 */
9374 + header->crc_ver_init |= crc;
9375 +
9376 + /* Reinitialize hash table */
9377 + return BCMINIT(nvram_rehash)(header);
9378 +}
9379 +
9380 +/* Initialize hash table. Should be locked. */
9381 +int
9382 +BCMINITFN(_nvram_init)(void)
9383 +{
9384 + struct nvram_header *header;
9385 + int ret;
9386 + void *osh;
9387 +
9388 + /* get kernel osl handler */
9389 + osh = osl_attach(NULL);
9390 +
9391 + if (!(header = (struct nvram_header *) MALLOC(osh, NVRAM_SPACE))) {
9392 + printf("nvram_init: out of memory, malloced %d bytes\n", MALLOCED(osh));
9393 + return -12; /* -ENOMEM */
9394 + }
9395 +
9396 + if ((ret = BCMINIT(_nvram_read)(header)) == 0 &&
9397 + header->magic == NVRAM_MAGIC)
9398 + BCMINIT(nvram_rehash)(header);
9399 +
9400 + MFREE(osh, header, NVRAM_SPACE);
9401 + return ret;
9402 +}
9403 +
9404 +/* Free hash table. Should be locked. */
9405 +void
9406 +BCMINITFN(_nvram_exit)(void)
9407 +{
9408 + BCMINIT(nvram_free)();
9409 +}
9410 diff -Nur linux-2.4.30/arch/mips/bcm947xx/nvram_linux.c linux-2.4.30-brcm/arch/mips/bcm947xx/nvram_linux.c
9411 --- linux-2.4.30/arch/mips/bcm947xx/nvram_linux.c 1970-01-01 01:00:00.000000000 +0100
9412 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/nvram_linux.c 2005-05-25 20:02:50.000000000 +0200
9413 @@ -0,0 +1,617 @@
9414 +/*
9415 + * NVRAM variable manipulation (Linux kernel half)
9416 + *
9417 + * Copyright 2004, Broadcom Corporation
9418 + * All Rights Reserved.
9419 + *
9420 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9421 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9422 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9423 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9424 + *
9425 + * $Id$
9426 + */
9427 +
9428 +#include <linux/config.h>
9429 +#include <linux/init.h>
9430 +#include <linux/module.h>
9431 +#include <linux/kernel.h>
9432 +#include <linux/string.h>
9433 +#include <linux/interrupt.h>
9434 +#include <linux/spinlock.h>
9435 +#include <linux/slab.h>
9436 +#include <linux/bootmem.h>
9437 +#include <linux/wrapper.h>
9438 +#include <linux/fs.h>
9439 +#include <linux/miscdevice.h>
9440 +#include <linux/mtd/mtd.h>
9441 +#include <asm/addrspace.h>
9442 +#include <asm/io.h>
9443 +#include <asm/uaccess.h>
9444 +
9445 +#include <typedefs.h>
9446 +#include <bcmendian.h>
9447 +#include <bcmnvram.h>
9448 +#include <bcmutils.h>
9449 +#include <sbconfig.h>
9450 +#include <sbchipc.h>
9451 +#include <sbutils.h>
9452 +#include <sbmips.h>
9453 +
9454 +/* In BSS to minimize text size and page aligned so it can be mmap()-ed */
9455 +static char nvram_buf[NVRAM_SPACE] __attribute__((aligned(PAGE_SIZE)));
9456 +
9457 +#ifdef MODULE
9458 +
9459 +#define early_nvram_get(name) nvram_get(name)
9460 +
9461 +#else /* !MODULE */
9462 +
9463 +/* Global SB handle */
9464 +extern void *bcm947xx_sbh;
9465 +extern spinlock_t bcm947xx_sbh_lock;
9466 +
9467 +/* Convenience */
9468 +#define sbh bcm947xx_sbh
9469 +#define sbh_lock bcm947xx_sbh_lock
9470 +#define KB * 1024
9471 +#define MB * 1024 * 1024
9472 +
9473 +/* Probe for NVRAM header */
9474 +static void __init
9475 +early_nvram_init(void)
9476 +{
9477 + struct nvram_header *header;
9478 + chipcregs_t *cc;
9479 + int i;
9480 + uint32 base, off, lim;
9481 +
9482 + if ((cc = sb_setcore(sbh, SB_CC, 0)) != NULL) {
9483 + base = KSEG1ADDR(SB_FLASH2);
9484 + switch (readl(&cc->capabilities) & CAP_FLASH_MASK) {
9485 + case PFLASH:
9486 + lim = SB_FLASH2_SZ;
9487 + break;
9488 +
9489 + case SFLASH_ST:
9490 + case SFLASH_AT:
9491 + case FLASH_NONE:
9492 + default:
9493 + return;
9494 + }
9495 + } else {
9496 + /* extif assumed, Stop at 4 MB */
9497 + base = KSEG1ADDR(SB_FLASH1);
9498 + lim = SB_FLASH1_SZ;
9499 + }
9500 +
9501 + off = FLASH_MIN;
9502 + while (off <= lim) {
9503 + /* Windowed flash access */
9504 + header = (struct nvram_header *) KSEG1ADDR(base + off - NVRAM_SPACE);
9505 + if (header->magic == NVRAM_MAGIC) {
9506 + u32 *src = (u32 *) header;
9507 + u32 *dst = (u32 *) nvram_buf;
9508 + for (i = 0; i < sizeof(struct nvram_header); i += 4)
9509 + *dst++ = *src++;
9510 + for (; i < header->len && i < NVRAM_SPACE; i += 4)
9511 + *dst++ = ltoh32(*src++);
9512 + return;
9513 + }
9514 +
9515 + /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
9516 + if (off == 1 KB)
9517 + break;
9518 + else if (off == 4 KB)
9519 + off = 1 KB;
9520 + else if (off == lim)
9521 + off = 4 KB;
9522 + else
9523 + off <<= 1;
9524 + }
9525 +}
9526 +
9527 +/* Early (before mm or mtd) read-only access to NVRAM */
9528 +static char * __init
9529 +early_nvram_get(const char *name)
9530 +{
9531 + char *var, *value, *end, *eq;
9532 +
9533 + if (!name)
9534 + return NULL;
9535 +
9536 + if (!nvram_buf[0])
9537 + early_nvram_init();
9538 +
9539 + /* Look for name=value and return value */
9540 + var = &nvram_buf[sizeof(struct nvram_header)];
9541 + end = nvram_buf + sizeof(nvram_buf) - 2;
9542 + end[0] = end[1] = '\0';
9543 + for (; *var; var = value + strlen(value) + 1) {
9544 + if (!(eq = strchr(var, '=')))
9545 + break;
9546 + value = eq + 1;
9547 + if ((eq - var) == strlen(name) && strncmp(var, name, (eq - var)) == 0)
9548 + return value;
9549 + }
9550 +
9551 + return NULL;
9552 +}
9553 +
9554 +#endif /* !MODULE */
9555 +
9556 +extern char * _nvram_get(const char *name);
9557 +extern int _nvram_set(const char *name, const char *value);
9558 +extern int _nvram_unset(const char *name);
9559 +extern int _nvram_getall(char *buf, int count);
9560 +extern int _nvram_commit(struct nvram_header *header);
9561 +extern int _nvram_init(void);
9562 +extern void _nvram_exit(void);
9563 +
9564 +/* Globals */
9565 +static spinlock_t nvram_lock = SPIN_LOCK_UNLOCKED;
9566 +static struct semaphore nvram_sem;
9567 +static unsigned long nvram_offset = 0;
9568 +static int nvram_major = -1;
9569 +static devfs_handle_t nvram_handle = NULL;
9570 +static struct mtd_info *nvram_mtd = NULL;
9571 +
9572 +int
9573 +_nvram_read(char *buf)
9574 +{
9575 + struct nvram_header *header = (struct nvram_header *) buf;
9576 + size_t len;
9577 +
9578 + if (!nvram_mtd ||
9579 + MTD_READ(nvram_mtd, nvram_mtd->size - NVRAM_SPACE, NVRAM_SPACE, &len, buf) ||
9580 + len != NVRAM_SPACE ||
9581 + header->magic != NVRAM_MAGIC) {
9582 + /* Maybe we can recover some data from early initialization */
9583 + memcpy(buf, nvram_buf, NVRAM_SPACE);
9584 + }
9585 +
9586 + return 0;
9587 +}
9588 +
9589 +struct nvram_tuple *
9590 +_nvram_realloc(struct nvram_tuple *t, const char *name, const char *value)
9591 +{
9592 + if ((nvram_offset + strlen(value) + 1) > NVRAM_SPACE)
9593 + return NULL;
9594 +
9595 + if (!t) {
9596 + if (!(t = kmalloc(sizeof(struct nvram_tuple) + strlen(name) + 1, GFP_ATOMIC)))
9597 + return NULL;
9598 +
9599 + /* Copy name */
9600 + t->name = (char *) &t[1];
9601 + strcpy(t->name, name);
9602 +
9603 + t->value = NULL;
9604 + }
9605 +
9606 + /* Copy value */
9607 + if (!t->value || strcmp(t->value, value)) {
9608 + t->value = &nvram_buf[nvram_offset];
9609 + strcpy(t->value, value);
9610 + nvram_offset += strlen(value) + 1;
9611 + }
9612 +
9613 + return t;
9614 +}
9615 +
9616 +void
9617 +_nvram_free(struct nvram_tuple *t)
9618 +{
9619 + if (!t)
9620 + nvram_offset = 0;
9621 + else
9622 + kfree(t);
9623 +}
9624 +
9625 +int
9626 +nvram_set(const char *name, const char *value)
9627 +{
9628 + unsigned long flags;
9629 + int ret;
9630 + struct nvram_header *header;
9631 +
9632 + spin_lock_irqsave(&nvram_lock, flags);
9633 + if ((ret = _nvram_set(name, value))) {
9634 + /* Consolidate space and try again */
9635 + if ((header = kmalloc(NVRAM_SPACE, GFP_ATOMIC))) {
9636 + if (_nvram_commit(header) == 0)
9637 + ret = _nvram_set(name, value);
9638 + kfree(header);
9639 + }
9640 + }
9641 + spin_unlock_irqrestore(&nvram_lock, flags);
9642 +
9643 + return ret;
9644 +}
9645 +
9646 +char *
9647 +real_nvram_get(const char *name)
9648 +{
9649 + unsigned long flags;
9650 + char *value;
9651 +
9652 + spin_lock_irqsave(&nvram_lock, flags);
9653 + value = _nvram_get(name);
9654 + spin_unlock_irqrestore(&nvram_lock, flags);
9655 +
9656 + return value;
9657 +}
9658 +
9659 +char *
9660 +nvram_get(const char *name)
9661 +{
9662 + if (nvram_major >= 0)
9663 + return real_nvram_get(name);
9664 + else
9665 + return early_nvram_get(name);
9666 +}
9667 +
9668 +int
9669 +nvram_unset(const char *name)
9670 +{
9671 + unsigned long flags;
9672 + int ret;
9673 +
9674 + spin_lock_irqsave(&nvram_lock, flags);
9675 + ret = _nvram_unset(name);
9676 + spin_unlock_irqrestore(&nvram_lock, flags);
9677 +
9678 + return ret;
9679 +}
9680 +
9681 +static void
9682 +erase_callback(struct erase_info *done)
9683 +{
9684 + wait_queue_head_t *wait_q = (wait_queue_head_t *) done->priv;
9685 + wake_up(wait_q);
9686 +}
9687 +
9688 +int
9689 +nvram_commit(void)
9690 +{
9691 + char *buf;
9692 + size_t erasesize, len;
9693 + unsigned int i;
9694 + int ret;
9695 + struct nvram_header *header;
9696 + unsigned long flags;
9697 + u_int32_t offset;
9698 + DECLARE_WAITQUEUE(wait, current);
9699 + wait_queue_head_t wait_q;
9700 + struct erase_info erase;
9701 +
9702 + if (!nvram_mtd) {
9703 + printk("nvram_commit: NVRAM not found\n");
9704 + return -ENODEV;
9705 + }
9706 +
9707 + if (in_interrupt()) {
9708 + printk("nvram_commit: not committing in interrupt\n");
9709 + return -EINVAL;
9710 + }
9711 +
9712 + /* Backup sector blocks to be erased */
9713 + erasesize = ROUNDUP(NVRAM_SPACE, nvram_mtd->erasesize);
9714 + if (!(buf = kmalloc(erasesize, GFP_KERNEL))) {
9715 + printk("nvram_commit: out of memory\n");
9716 + return -ENOMEM;
9717 + }
9718 +
9719 + down(&nvram_sem);
9720 +
9721 + if ((i = erasesize - NVRAM_SPACE) > 0) {
9722 + offset = nvram_mtd->size - erasesize;
9723 + len = 0;
9724 + ret = MTD_READ(nvram_mtd, offset, i, &len, buf);
9725 + if (ret || len != i) {
9726 + printk("nvram_commit: read error ret = %d, len = %d/%d\n", ret, len, i);
9727 + ret = -EIO;
9728 + goto done;
9729 + }
9730 + header = (struct nvram_header *)(buf + i);
9731 + } else {
9732 + offset = nvram_mtd->size - NVRAM_SPACE;
9733 + header = (struct nvram_header *)buf;
9734 + }
9735 +
9736 + /* Regenerate NVRAM */
9737 + spin_lock_irqsave(&nvram_lock, flags);
9738 + ret = _nvram_commit(header);
9739 + spin_unlock_irqrestore(&nvram_lock, flags);
9740 + if (ret)
9741 + goto done;
9742 +
9743 + /* Erase sector blocks */
9744 + init_waitqueue_head(&wait_q);
9745 + for (; offset < nvram_mtd->size - NVRAM_SPACE + header->len; offset += nvram_mtd->erasesize) {
9746 + erase.mtd = nvram_mtd;
9747 + erase.addr = offset;
9748 + erase.len = nvram_mtd->erasesize;
9749 + erase.callback = erase_callback;
9750 + erase.priv = (u_long) &wait_q;
9751 +
9752 + set_current_state(TASK_INTERRUPTIBLE);
9753 + add_wait_queue(&wait_q, &wait);
9754 +
9755 + /* Unlock sector blocks */
9756 + if (nvram_mtd->unlock)
9757 + nvram_mtd->unlock(nvram_mtd, offset, nvram_mtd->erasesize);
9758 +
9759 + if ((ret = MTD_ERASE(nvram_mtd, &erase))) {
9760 + set_current_state(TASK_RUNNING);
9761 + remove_wait_queue(&wait_q, &wait);
9762 + printk("nvram_commit: erase error\n");
9763 + goto done;
9764 + }
9765 +
9766 + /* Wait for erase to finish */
9767 + schedule();
9768 + remove_wait_queue(&wait_q, &wait);
9769 + }
9770 +
9771 + /* Write partition up to end of data area */
9772 + offset = nvram_mtd->size - erasesize;
9773 + i = erasesize - NVRAM_SPACE + header->len;
9774 + ret = MTD_WRITE(nvram_mtd, offset, i, &len, buf);
9775 + if (ret || len != i) {
9776 + printk("nvram_commit: write error\n");
9777 + ret = -EIO;
9778 + goto done;
9779 + }
9780 +
9781 + offset = nvram_mtd->size - erasesize;
9782 + ret = MTD_READ(nvram_mtd, offset, 4, &len, buf);
9783 +
9784 + done:
9785 + up(&nvram_sem);
9786 + kfree(buf);
9787 + return ret;
9788 +}
9789 +
9790 +int
9791 +nvram_getall(char *buf, int count)
9792 +{
9793 + unsigned long flags;
9794 + int ret;
9795 +
9796 + spin_lock_irqsave(&nvram_lock, flags);
9797 + ret = _nvram_getall(buf, count);
9798 + spin_unlock_irqrestore(&nvram_lock, flags);
9799 +
9800 + return ret;
9801 +}
9802 +
9803 +EXPORT_SYMBOL(nvram_get);
9804 +EXPORT_SYMBOL(nvram_getall);
9805 +EXPORT_SYMBOL(nvram_set);
9806 +EXPORT_SYMBOL(nvram_unset);
9807 +EXPORT_SYMBOL(nvram_commit);
9808 +
9809 +/* User mode interface below */
9810 +
9811 +static ssize_t
9812 +dev_nvram_read(struct file *file, char *buf, size_t count, loff_t *ppos)
9813 +{
9814 + char tmp[100], *name = tmp, *value;
9815 + ssize_t ret;
9816 + unsigned long off;
9817 +
9818 + if (count > sizeof(tmp)) {
9819 + if (!(name = kmalloc(count, GFP_KERNEL)))
9820 + return -ENOMEM;
9821 + }
9822 +
9823 + if (copy_from_user(name, buf, count)) {
9824 + ret = -EFAULT;
9825 + goto done;
9826 + }
9827 +
9828 + if (*name == '\0') {
9829 + /* Get all variables */
9830 + ret = nvram_getall(name, count);
9831 + if (ret == 0) {
9832 + if (copy_to_user(buf, name, count)) {
9833 + ret = -EFAULT;
9834 + goto done;
9835 + }
9836 + ret = count;
9837 + }
9838 + } else {
9839 + if (!(value = nvram_get(name))) {
9840 + ret = 0;
9841 + goto done;
9842 + }
9843 +
9844 + /* Provide the offset into mmap() space */
9845 + off = (unsigned long) value - (unsigned long) nvram_buf;
9846 +
9847 + if (put_user(off, (unsigned long *) buf)) {
9848 + ret = -EFAULT;
9849 + goto done;
9850 + }
9851 +
9852 + ret = sizeof(unsigned long);
9853 + }
9854 +
9855 + flush_cache_all();
9856 +
9857 +done:
9858 + if (name != tmp)
9859 + kfree(name);
9860 +
9861 + return ret;
9862 +}
9863 +
9864 +static ssize_t
9865 +dev_nvram_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
9866 +{
9867 + char tmp[100], *name = tmp, *value;
9868 + ssize_t ret;
9869 +
9870 + if (count > sizeof(tmp)) {
9871 + if (!(name = kmalloc(count, GFP_KERNEL)))
9872 + return -ENOMEM;
9873 + }
9874 +
9875 + if (copy_from_user(name, buf, count)) {
9876 + ret = -EFAULT;
9877 + goto done;
9878 + }
9879 +
9880 + value = name;
9881 + name = strsep(&value, "=");
9882 + if (value)
9883 + ret = nvram_set(name, value) ? : count;
9884 + else
9885 + ret = nvram_unset(name) ? : count;
9886 +
9887 + done:
9888 + if (name != tmp)
9889 + kfree(name);
9890 +
9891 + return ret;
9892 +}
9893 +
9894 +static int
9895 +dev_nvram_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
9896 +{
9897 + if (cmd != NVRAM_MAGIC)
9898 + return -EINVAL;
9899 + return nvram_commit();
9900 +}
9901 +
9902 +static int
9903 +dev_nvram_mmap(struct file *file, struct vm_area_struct *vma)
9904 +{
9905 + unsigned long offset = virt_to_phys(nvram_buf);
9906 +
9907 + if (remap_page_range(vma->vm_start, offset, vma->vm_end-vma->vm_start,
9908 + vma->vm_page_prot))
9909 + return -EAGAIN;
9910 +
9911 + return 0;
9912 +}
9913 +
9914 +static int
9915 +dev_nvram_open(struct inode *inode, struct file * file)
9916 +{
9917 + MOD_INC_USE_COUNT;
9918 + return 0;
9919 +}
9920 +
9921 +static int
9922 +dev_nvram_release(struct inode *inode, struct file * file)
9923 +{
9924 + MOD_DEC_USE_COUNT;
9925 + return 0;
9926 +}
9927 +
9928 +static struct file_operations dev_nvram_fops = {
9929 + owner: THIS_MODULE,
9930 + open: dev_nvram_open,
9931 + release: dev_nvram_release,
9932 + read: dev_nvram_read,
9933 + write: dev_nvram_write,
9934 + ioctl: dev_nvram_ioctl,
9935 + mmap: dev_nvram_mmap,
9936 +};
9937 +
9938 +static void
9939 +dev_nvram_exit(void)
9940 +{
9941 + int order = 0;
9942 + struct page *page, *end;
9943 +
9944 + if (nvram_handle)
9945 + devfs_unregister(nvram_handle);
9946 +
9947 + if (nvram_major >= 0)
9948 + devfs_unregister_chrdev(nvram_major, "nvram");
9949 +
9950 + if (nvram_mtd)
9951 + put_mtd_device(nvram_mtd);
9952 +
9953 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
9954 + order++;
9955 + end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
9956 + for (page = virt_to_page(nvram_buf); page <= end; page++)
9957 + mem_map_unreserve(page);
9958 +
9959 + _nvram_exit();
9960 +}
9961 +
9962 +static int __init
9963 +dev_nvram_init(void)
9964 +{
9965 + int order = 0, ret = 0;
9966 + struct page *page, *end;
9967 + unsigned int i;
9968 +
9969 + /* Allocate and reserve memory to mmap() */
9970 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
9971 + order++;
9972 + end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
9973 + for (page = virt_to_page(nvram_buf); page <= end; page++)
9974 + mem_map_reserve(page);
9975 +
9976 +#ifdef CONFIG_MTD
9977 + /* Find associated MTD device */
9978 + for (i = 0; i < MAX_MTD_DEVICES; i++) {
9979 + nvram_mtd = get_mtd_device(NULL, i);
9980 + if (nvram_mtd) {
9981 + if (!strcmp(nvram_mtd->name, "nvram") &&
9982 + nvram_mtd->size >= NVRAM_SPACE)
9983 + break;
9984 + put_mtd_device(nvram_mtd);
9985 + }
9986 + }
9987 + if (i >= MAX_MTD_DEVICES)
9988 + nvram_mtd = NULL;
9989 +#endif
9990 +
9991 + /* Initialize hash table lock */
9992 + spin_lock_init(&nvram_lock);
9993 +
9994 + /* Initialize commit semaphore */
9995 + init_MUTEX(&nvram_sem);
9996 +
9997 + /* Register char device */
9998 + if ((nvram_major = devfs_register_chrdev(0, "nvram", &dev_nvram_fops)) < 0) {
9999 + ret = nvram_major;
10000 + goto err;
10001 + }
10002 +
10003 + /* Initialize hash table */
10004 + _nvram_init();
10005 +
10006 + /* Create /dev/nvram handle */
10007 + nvram_handle = devfs_register(NULL, "nvram", DEVFS_FL_NONE, nvram_major, 0,
10008 + S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, &dev_nvram_fops, NULL);
10009 +
10010 + /* Set the SDRAM NCDL value into NVRAM if not already done */
10011 + if (getintvar(NULL, "sdram_ncdl") == 0) {
10012 + unsigned int ncdl;
10013 + char buf[] = "0x00000000";
10014 +
10015 + if ((ncdl = sb_memc_get_ncdl(sbh))) {
10016 + sprintf(buf, "0x%08x", ncdl);
10017 + nvram_set("sdram_ncdl", buf);
10018 + nvram_commit();
10019 + }
10020 + }
10021 +
10022 + return 0;
10023 +
10024 + err:
10025 + dev_nvram_exit();
10026 + return ret;
10027 +}
10028 +
10029 +module_init(dev_nvram_init);
10030 +module_exit(dev_nvram_exit);
10031 diff -Nur linux-2.4.30/arch/mips/bcm947xx/pcibios.c linux-2.4.30-brcm/arch/mips/bcm947xx/pcibios.c
10032 --- linux-2.4.30/arch/mips/bcm947xx/pcibios.c 1970-01-01 01:00:00.000000000 +0100
10033 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/pcibios.c 2005-05-26 01:15:53.000000000 +0200
10034 @@ -0,0 +1,355 @@
10035 +/*
10036 + * Low-Level PCI and SB support for BCM47xx (Linux support code)
10037 + *
10038 + * Copyright 2004, Broadcom Corporation
10039 + * All Rights Reserved.
10040 + *
10041 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10042 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10043 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10044 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10045 + *
10046 + * $Id$
10047 + */
10048 +
10049 +#include <linux/config.h>
10050 +#include <linux/types.h>
10051 +#include <linux/kernel.h>
10052 +#include <linux/sched.h>
10053 +#include <linux/pci.h>
10054 +#include <linux/init.h>
10055 +#include <linux/delay.h>
10056 +#include <asm/io.h>
10057 +#include <asm/irq.h>
10058 +#include <asm/paccess.h>
10059 +
10060 +#include <typedefs.h>
10061 +#include <bcmutils.h>
10062 +#include <sbconfig.h>
10063 +#include <sbpci.h>
10064 +#include <pcicfg.h>
10065 +#include <sbutils.h>
10066 +#include <bcmdevs.h>
10067 +#include <bcmnvram.h>
10068 +
10069 +/* Global SB handle */
10070 +extern void *bcm947xx_sbh;
10071 +extern spinlock_t bcm947xx_sbh_lock;
10072 +
10073 +/* Convenience */
10074 +#define sbh bcm947xx_sbh
10075 +#define sbh_lock bcm947xx_sbh_lock
10076 +
10077 +static int
10078 +sbpci_read_config_byte(struct pci_dev *dev, int where, u8 *value)
10079 +{
10080 + unsigned long flags;
10081 + int ret;
10082 +
10083 + spin_lock_irqsave(&sbh_lock, flags);
10084 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
10085 + spin_unlock_irqrestore(&sbh_lock, flags);
10086 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10087 +}
10088 +
10089 +static int
10090 +sbpci_read_config_word(struct pci_dev *dev, int where, u16 *value)
10091 +{
10092 + unsigned long flags;
10093 + int ret;
10094 +
10095 + spin_lock_irqsave(&sbh_lock, flags);
10096 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
10097 + spin_unlock_irqrestore(&sbh_lock, flags);
10098 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10099 +}
10100 +
10101 +static int
10102 +sbpci_read_config_dword(struct pci_dev *dev, int where, u32 *value)
10103 +{
10104 + unsigned long flags;
10105 + int ret;
10106 +
10107 + spin_lock_irqsave(&sbh_lock, flags);
10108 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
10109 + spin_unlock_irqrestore(&sbh_lock, flags);
10110 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10111 +}
10112 +
10113 +static int
10114 +sbpci_write_config_byte(struct pci_dev *dev, int where, u8 value)
10115 +{
10116 + unsigned long flags;
10117 + int ret;
10118 +
10119 + spin_lock_irqsave(&sbh_lock, flags);
10120 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
10121 + spin_unlock_irqrestore(&sbh_lock, flags);
10122 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10123 +}
10124 +
10125 +static int
10126 +sbpci_write_config_word(struct pci_dev *dev, int where, u16 value)
10127 +{
10128 + unsigned long flags;
10129 + int ret;
10130 +
10131 + spin_lock_irqsave(&sbh_lock, flags);
10132 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
10133 + spin_unlock_irqrestore(&sbh_lock, flags);
10134 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10135 +}
10136 +
10137 +static int
10138 +sbpci_write_config_dword(struct pci_dev *dev, int where, u32 value)
10139 +{
10140 + unsigned long flags;
10141 + int ret;
10142 +
10143 + spin_lock_irqsave(&sbh_lock, flags);
10144 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
10145 + spin_unlock_irqrestore(&sbh_lock, flags);
10146 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10147 +}
10148 +
10149 +static struct pci_ops pcibios_ops = {
10150 + sbpci_read_config_byte,
10151 + sbpci_read_config_word,
10152 + sbpci_read_config_dword,
10153 + sbpci_write_config_byte,
10154 + sbpci_write_config_word,
10155 + sbpci_write_config_dword
10156 +};
10157 +
10158 +
10159 +void __init
10160 +pcibios_init(void)
10161 +{
10162 + ulong flags;
10163 +
10164 + if (!(sbh = sb_kattach()))
10165 + panic("sb_kattach failed");
10166 + spin_lock_init(&sbh_lock);
10167 +
10168 + spin_lock_irqsave(&sbh_lock, flags);
10169 + sbpci_init(sbh);
10170 + spin_unlock_irqrestore(&sbh_lock, flags);
10171 +
10172 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
10173 +
10174 + mdelay(300); //By Joey for Atheros Card
10175 +
10176 + /* Scan the SB bus */
10177 + pci_scan_bus(0, &pcibios_ops, NULL);
10178 +
10179 +}
10180 +
10181 +char * __init
10182 +pcibios_setup(char *str)
10183 +{
10184 + if (!strncmp(str, "ban=", 4)) {
10185 + sbpci_ban(simple_strtoul(str + 4, NULL, 0));
10186 + return NULL;
10187 + }
10188 +
10189 + return (str);
10190 +}
10191 +
10192 +static u32 pci_iobase = 0x100;
10193 +static u32 pci_membase = SB_PCI_DMA;
10194 +
10195 +void __init
10196 +pcibios_fixup_bus(struct pci_bus *b)
10197 +{
10198 + struct list_head *ln;
10199 + struct pci_dev *d;
10200 + struct resource *res;
10201 + int pos, size;
10202 + u32 *base;
10203 + u8 irq;
10204 +
10205 + printk("PCI: Fixing up bus %d\n", b->number);
10206 +
10207 + /* Fix up SB */
10208 + if (b->number == 0) {
10209 + for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
10210 + d = pci_dev_b(ln);
10211 + /* Fix up interrupt lines */
10212 + pci_read_config_byte(d, PCI_INTERRUPT_LINE, &irq);
10213 + d->irq = irq + 2;
10214 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
10215 + }
10216 + }
10217 +
10218 + /* Fix up external PCI */
10219 + else {
10220 + for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
10221 + d = pci_dev_b(ln);
10222 + /* Fix up resource bases */
10223 + for (pos = 0; pos < 6; pos++) {
10224 + res = &d->resource[pos];
10225 + base = (res->flags & IORESOURCE_IO) ? &pci_iobase : &pci_membase;
10226 + if (res->end) {
10227 + size = res->end - res->start + 1;
10228 + if (*base & (size - 1))
10229 + *base = (*base + size) & ~(size - 1);
10230 + res->start = *base;
10231 + res->end = res->start + size - 1;
10232 + *base += size;
10233 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
10234 + }
10235 + /* Fix up PCI bridge BAR0 only */
10236 + if (b->number == 1 && PCI_SLOT(d->devfn) == 0)
10237 + break;
10238 + }
10239 + /* Fix up interrupt lines */
10240 + if (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))
10241 + d->irq = (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))->irq;
10242 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
10243 + }
10244 + }
10245 +}
10246 +
10247 +unsigned int
10248 +pcibios_assign_all_busses(void)
10249 +{
10250 + return 1;
10251 +}
10252 +
10253 +void
10254 +pcibios_align_resource(void *data, struct resource *res,
10255 + unsigned long size, unsigned long align)
10256 +{
10257 +}
10258 +
10259 +int
10260 +pcibios_enable_resources(struct pci_dev *dev)
10261 +{
10262 + u16 cmd, old_cmd;
10263 + int idx;
10264 + struct resource *r;
10265 +
10266 + /* External PCI only */
10267 + if (dev->bus->number == 0)
10268 + return 0;
10269 +
10270 + pci_read_config_word(dev, PCI_COMMAND, &cmd);
10271 + old_cmd = cmd;
10272 + for(idx=0; idx<6; idx++) {
10273 + r = &dev->resource[idx];
10274 + if (r->flags & IORESOURCE_IO)
10275 + cmd |= PCI_COMMAND_IO;
10276 + if (r->flags & IORESOURCE_MEM)
10277 + cmd |= PCI_COMMAND_MEMORY;
10278 + }
10279 + if (dev->resource[PCI_ROM_RESOURCE].start)
10280 + cmd |= PCI_COMMAND_MEMORY;
10281 + if (cmd != old_cmd) {
10282 + printk("PCI: Enabling device %s (%04x -> %04x)\n", dev->slot_name, old_cmd, cmd);
10283 + pci_write_config_word(dev, PCI_COMMAND, cmd);
10284 + }
10285 + return 0;
10286 +}
10287 +
10288 +int
10289 +pcibios_enable_device(struct pci_dev *dev, int mask)
10290 +{
10291 + ulong flags;
10292 + uint coreidx;
10293 +
10294 + /* External PCI device enable */
10295 + if (dev->bus->number != 0)
10296 + return pcibios_enable_resources(dev);
10297 +
10298 + /* These cores come out of reset enabled */
10299 + if (dev->device == SB_MIPS ||
10300 + dev->device == SB_MIPS33 ||
10301 + dev->device == SB_EXTIF ||
10302 + dev->device == SB_CC)
10303 + return 0;
10304 +
10305 + spin_lock_irqsave(&sbh_lock, flags);
10306 + coreidx = sb_coreidx(sbh);
10307 + if (!sb_setcoreidx(sbh, PCI_SLOT(dev->devfn)))
10308 + return PCIBIOS_DEVICE_NOT_FOUND;
10309 +
10310 + /*
10311 + * The USB core requires a special bit to be set during core
10312 + * reset to enable host (OHCI) mode. Resetting the SB core in
10313 + * pcibios_enable_device() is a hack for compatibility with
10314 + * vanilla usb-ohci so that it does not have to know about
10315 + * SB. A driver that wants to use the USB core in device mode
10316 + * should know about SB and should reset the bit back to 0
10317 + * after calling pcibios_enable_device().
10318 + */
10319 + if (sb_coreid(sbh) == SB_USB) {
10320 + sb_core_disable(sbh, sb_coreflags(sbh, 0, 0));
10321 + sb_core_reset(sbh, 1 << 29);
10322 + } else
10323 + sb_core_reset(sbh, 0);
10324 +
10325 + sb_setcoreidx(sbh, coreidx);
10326 + spin_unlock_irqrestore(&sbh_lock, flags);
10327 +
10328 + return 0;
10329 +}
10330 +
10331 +void
10332 +pcibios_update_resource(struct pci_dev *dev, struct resource *root,
10333 + struct resource *res, int resource)
10334 +{
10335 + unsigned long where, size;
10336 + u32 reg;
10337 +
10338 + /* External PCI only */
10339 + if (dev->bus->number == 0)
10340 + return;
10341 +
10342 + where = PCI_BASE_ADDRESS_0 + (resource * 4);
10343 + size = res->end - res->start;
10344 + pci_read_config_dword(dev, where, &reg);
10345 + reg = (reg & size) | (((u32)(res->start - root->start)) & ~size);
10346 + pci_write_config_dword(dev, where, reg);
10347 +}
10348 +
10349 +static void __init
10350 +quirk_sbpci_bridge(struct pci_dev *dev)
10351 +{
10352 + if (dev->bus->number != 1 || PCI_SLOT(dev->devfn) != 0)
10353 + return;
10354 +
10355 + printk("PCI: Fixing up bridge\n");
10356 +
10357 + /* Enable PCI bridge bus mastering and memory space */
10358 + pci_set_master(dev);
10359 + pcibios_enable_resources(dev);
10360 +
10361 + /* Enable PCI bridge BAR1 prefetch and burst */
10362 + pci_write_config_dword(dev, PCI_BAR1_CONTROL, 3);
10363 +}
10364 +
10365 +struct pci_fixup pcibios_fixups[] = {
10366 + { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, quirk_sbpci_bridge },
10367 + { 0 }
10368 +};
10369 +
10370 +/*
10371 + * If we set up a device for bus mastering, we need to check the latency
10372 + * timer as certain crappy BIOSes forget to set it properly.
10373 + */
10374 +unsigned int pcibios_max_latency = 255;
10375 +
10376 +void pcibios_set_master(struct pci_dev *dev)
10377 +{
10378 + u8 lat;
10379 + pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
10380 + if (lat < 16)
10381 + lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
10382 + else if (lat > pcibios_max_latency)
10383 + lat = pcibios_max_latency;
10384 + else
10385 + return;
10386 + printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", dev->slot_name, lat);
10387 + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
10388 +}
10389 +
10390 diff -Nur linux-2.4.30/arch/mips/bcm947xx/prom.c linux-2.4.30-brcm/arch/mips/bcm947xx/prom.c
10391 --- linux-2.4.30/arch/mips/bcm947xx/prom.c 1970-01-01 01:00:00.000000000 +0100
10392 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/prom.c 2005-05-22 22:55:51.000000000 +0200
10393 @@ -0,0 +1,41 @@
10394 +/*
10395 + * Early initialization code for BCM94710 boards
10396 + *
10397 + * Copyright 2004, Broadcom Corporation
10398 + * All Rights Reserved.
10399 + *
10400 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10401 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10402 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10403 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10404 + *
10405 + * $Id: prom.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
10406 + */
10407 +
10408 +#include <linux/config.h>
10409 +#include <linux/init.h>
10410 +#include <linux/kernel.h>
10411 +#include <linux/types.h>
10412 +#include <asm/bootinfo.h>
10413 +
10414 +void __init
10415 +prom_init(int argc, const char **argv)
10416 +{
10417 + unsigned long mem;
10418 +
10419 + mips_machgroup = MACH_GROUP_BRCM;
10420 + mips_machtype = MACH_BCM947XX;
10421 +
10422 + /* Figure out memory size by finding aliases */
10423 + for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
10424 + if (*(unsigned long *)((unsigned long)(prom_init) + mem) ==
10425 + *(unsigned long *)(prom_init))
10426 + break;
10427 + }
10428 + add_memory_region(0, mem, BOOT_MEM_RAM);
10429 +}
10430 +
10431 +void __init
10432 +prom_free_prom_memory(void)
10433 +{
10434 +}
10435 diff -Nur linux-2.4.30/arch/mips/bcm947xx/sbmips.c linux-2.4.30-brcm/arch/mips/bcm947xx/sbmips.c
10436 --- linux-2.4.30/arch/mips/bcm947xx/sbmips.c 1970-01-01 01:00:00.000000000 +0100
10437 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/sbmips.c 2005-05-25 05:06:08.000000000 +0200
10438 @@ -0,0 +1,982 @@
10439 +/*
10440 + * BCM47XX Sonics SiliconBackplane MIPS core routines
10441 + *
10442 + * Copyright 2004, Broadcom Corporation
10443 + * All Rights Reserved.
10444 + *
10445 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10446 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10447 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10448 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10449 + *
10450 + * $Id$
10451 + */
10452 +
10453 +#include <typedefs.h>
10454 +#include <osl.h>
10455 +#include <sbutils.h>
10456 +#include <bcmdevs.h>
10457 +#include <bcmnvram.h>
10458 +#include <bcmutils.h>
10459 +#include <hndmips.h>
10460 +#include <sbconfig.h>
10461 +#include <sbextif.h>
10462 +#include <sbchipc.h>
10463 +#include <sbmemc.h>
10464 +#include <mipsinc.h>
10465 +
10466 +/*
10467 + * Returns TRUE if an external UART exists at the given base
10468 + * register.
10469 + */
10470 +static bool
10471 +BCMINITFN(serial_exists)(uint8 *regs)
10472 +{
10473 + uint8 save_mcr, status1;
10474 +
10475 + save_mcr = R_REG(&regs[UART_MCR]);
10476 + W_REG(&regs[UART_MCR], UART_MCR_LOOP | 0x0a);
10477 + status1 = R_REG(&regs[UART_MSR]) & 0xf0;
10478 + W_REG(&regs[UART_MCR], save_mcr);
10479 +
10480 + return (status1 == 0x90);
10481 +}
10482 +
10483 +/*
10484 + * Initializes UART access. The callback function will be called once
10485 + * per found UART.
10486 + */
10487 +void
10488 +BCMINITFN(sb_serial_init)(void *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift))
10489 +{
10490 + void *regs;
10491 + ulong base;
10492 + uint irq;
10493 + int i, n;
10494 +
10495 + if ((regs = sb_setcore(sbh, SB_EXTIF, 0))) {
10496 + extifregs_t *eir = (extifregs_t *) regs;
10497 + sbconfig_t *sb;
10498 +
10499 + /* Determine external UART register base */
10500 + sb = (sbconfig_t *)((ulong) eir + SBCONFIGOFF);
10501 + base = EXTIF_CFGIF_BASE(sb_base(R_REG(&sb->sbadmatch1)));
10502 +
10503 + /* Determine IRQ */
10504 + irq = sb_irq(sbh);
10505 +
10506 + /* Disable GPIO interrupt initially */
10507 + W_REG(&eir->gpiointpolarity, 0);
10508 + W_REG(&eir->gpiointmask, 0);
10509 +
10510 + /* Search for external UARTs */
10511 + n = 2;
10512 + for (i = 0; i < 2; i++) {
10513 + regs = (void *) REG_MAP(base + (i * 8), 8);
10514 + if (BCMINIT(serial_exists)(regs)) {
10515 + /* Set GPIO 1 to be the external UART IRQ */
10516 + W_REG(&eir->gpiointmask, 2);
10517 + if (add)
10518 + add(regs, irq, 13500000, 0);
10519 + }
10520 + }
10521 +
10522 + /* Add internal UART if enabled */
10523 + if (R_REG(&eir->corecontrol) & CC_UE)
10524 + if (add)
10525 + add((void *) &eir->uartdata, irq, sb_clock(sbh), 2);
10526 + } else if ((regs = sb_setcore(sbh, SB_CC, 0))) {
10527 + chipcregs_t *cc = (chipcregs_t *) regs;
10528 + uint32 rev, cap, pll, baud_base, div;
10529 +
10530 + /* Determine core revision and capabilities */
10531 + rev = sb_corerev(sbh);
10532 + cap = R_REG(&cc->capabilities);
10533 + pll = cap & CAP_PLL_MASK;
10534 +
10535 + /* Determine IRQ */
10536 + irq = sb_irq(sbh);
10537 +
10538 + if (pll == PLL_TYPE1) {
10539 + /* PLL clock */
10540 + baud_base = sb_clock_rate(pll,
10541 + R_REG(&cc->clockcontrol_n),
10542 + R_REG(&cc->clockcontrol_m2));
10543 + div = 1;
10544 + } else if (rev >= 3) {
10545 + if (pll == PLL_TYPE6) {
10546 + /* Fixed ALP clock on 4320 */
10547 + baud_base = 20000000;
10548 + /* Set the override bit so we don't divide it */
10549 + W_REG(&cc->corecontrol, CC_UARTCLKO);
10550 + } else {
10551 + /* Internal backplane clock */
10552 + baud_base = sb_clock(sbh);
10553 + }
10554 + div = 2; /* Minimum divisor */
10555 + W_REG(&cc->clkdiv, ((R_REG(&cc->clkdiv) & ~CLKD_UART) | div));
10556 + } else {
10557 + /* Fixed internal backplane clock */
10558 + baud_base = 88000000;
10559 + div = 48;
10560 + }
10561 +
10562 + /* Clock source depends on strapping if UartClkOverride is unset */
10563 + if ((rev > 0) && ((R_REG(&cc->corecontrol) & CC_UARTCLKO) == 0)) {
10564 + if ((cap & CAP_UCLKSEL) == CAP_UINTCLK) {
10565 + /* Internal divided backplane clock */
10566 + baud_base /= div;
10567 + } else {
10568 + /* Assume external clock of 1.8432 MHz */
10569 + baud_base = 1843200;
10570 + }
10571 + }
10572 +
10573 + /* Add internal UARTs */
10574 + n = cap & CAP_UARTS_MASK;
10575 + for (i = 0; i < n; i++) {
10576 + /* Register offset changed after revision 0 */
10577 + if (rev)
10578 + regs = (void *)((ulong) &cc->uart0data + (i * 256));
10579 + else
10580 + regs = (void *)((ulong) &cc->uart0data + (i * 8));
10581 +
10582 + if (add)
10583 + add(regs, irq, baud_base, 0);
10584 + }
10585 + }
10586 +}
10587 +
10588 +/*
10589 + * Initialize jtag master and return handle for
10590 + * jtag_rwreg. Returns NULL on failure.
10591 + */
10592 +void *
10593 +sb_jtagm_init(void *sbh, uint clkd, bool exttap)
10594 +{
10595 + void *regs;
10596 +
10597 + if ((regs = sb_setcore(sbh, SB_CC, 0)) != NULL) {
10598 + chipcregs_t *cc = (chipcregs_t *) regs;
10599 + uint32 tmp;
10600 +
10601 + /*
10602 + * Determine jtagm availability from
10603 + * core revision and capabilities.
10604 + */
10605 + tmp = sb_corerev(sbh);
10606 + /*
10607 + * Corerev 10 has jtagm, but the only chip
10608 + * with it does not have a mips, and
10609 + * the layout of the jtagcmd register is
10610 + * different. We'll only accept >= 11.
10611 + */
10612 + if (tmp < 11)
10613 + return (NULL);
10614 +
10615 + tmp = R_REG(&cc->capabilities);
10616 + if ((tmp & CAP_JTAGP) == 0)
10617 + return (NULL);
10618 +
10619 + /* Set clock divider if requested */
10620 + if (clkd != 0) {
10621 + tmp = R_REG(&cc->clkdiv);
10622 + tmp = (tmp & ~CLKD_JTAG) |
10623 + ((clkd << CLKD_JTAG_SHIFT) & CLKD_JTAG);
10624 + W_REG(&cc->clkdiv, tmp);
10625 + }
10626 +
10627 + /* Enable jtagm */
10628 + tmp = JCTRL_EN | (exttap ? JCTRL_EXT_EN : 0);
10629 + W_REG(&cc->jtagctrl, tmp);
10630 + }
10631 +
10632 + return (regs);
10633 +}
10634 +
10635 +void
10636 +sb_jtagm_disable(void *h)
10637 +{
10638 + chipcregs_t *cc = (chipcregs_t *)h;
10639 +
10640 + W_REG(&cc->jtagctrl, R_REG(&cc->jtagctrl) & ~JCTRL_EN);
10641 +}
10642 +
10643 +/*
10644 + * Read/write a jtag register. Assumes a target with
10645 + * 8 bit IR and 32 bit DR.
10646 + */
10647 +#define IRWIDTH 8
10648 +#define DRWIDTH 32
10649 +uint32
10650 +jtag_rwreg(void *h, uint32 ir, uint32 dr)
10651 +{
10652 + chipcregs_t *cc = (chipcregs_t *) h;
10653 + uint32 tmp;
10654 +
10655 + W_REG(&cc->jtagir, ir);
10656 + W_REG(&cc->jtagdr, dr);
10657 + tmp = JCMD_START | JCMD_ACC_IRDR |
10658 + ((IRWIDTH - 1) << JCMD_IRW_SHIFT) |
10659 + (DRWIDTH - 1);
10660 + W_REG(&cc->jtagcmd, tmp);
10661 + while (((tmp = R_REG(&cc->jtagcmd)) & JCMD_BUSY) == JCMD_BUSY) {
10662 + /* OSL_DELAY(1); */
10663 + }
10664 +
10665 + tmp = R_REG(&cc->jtagdr);
10666 + return (tmp);
10667 +}
10668 +
10669 +/* Returns the SB interrupt flag of the current core. */
10670 +uint32
10671 +sb_flag(void *sbh)
10672 +{
10673 + void *regs;
10674 + sbconfig_t *sb;
10675 +
10676 + regs = sb_coreregs(sbh);
10677 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
10678 +
10679 + return (R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK);
10680 +}
10681 +
10682 +static const uint32 sbips_int_mask[] = {
10683 + 0,
10684 + SBIPS_INT1_MASK,
10685 + SBIPS_INT2_MASK,
10686 + SBIPS_INT3_MASK,
10687 + SBIPS_INT4_MASK
10688 +};
10689 +
10690 +static const uint32 sbips_int_shift[] = {
10691 + 0,
10692 + 0,
10693 + SBIPS_INT2_SHIFT,
10694 + SBIPS_INT3_SHIFT,
10695 + SBIPS_INT4_SHIFT
10696 +};
10697 +
10698 +/*
10699 + * Returns the MIPS IRQ assignment of the current core. If unassigned,
10700 + * 0 is returned.
10701 + */
10702 +uint
10703 +sb_irq(void *sbh)
10704 +{
10705 + uint idx;
10706 + void *regs;
10707 + sbconfig_t *sb;
10708 + uint32 flag, sbipsflag;
10709 + uint irq = 0;
10710 +
10711 + flag = sb_flag(sbh);
10712 +
10713 + idx = sb_coreidx(sbh);
10714 +
10715 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
10716 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
10717 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
10718 +
10719 + /* sbipsflag specifies which core is routed to interrupts 1 to 4 */
10720 + sbipsflag = R_REG(&sb->sbipsflag);
10721 + for (irq = 1; irq <= 4; irq++) {
10722 + if (((sbipsflag & sbips_int_mask[irq]) >> sbips_int_shift[irq]) == flag)
10723 + break;
10724 + }
10725 + if (irq == 5)
10726 + irq = 0;
10727 + }
10728 +
10729 + sb_setcoreidx(sbh, idx);
10730 +
10731 + return irq;
10732 +}
10733 +
10734 +/* Clears the specified MIPS IRQ. */
10735 +static void
10736 +BCMINITFN(sb_clearirq)(void *sbh, uint irq)
10737 +{
10738 + void *regs;
10739 + sbconfig_t *sb;
10740 +
10741 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
10742 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
10743 + ASSERT(regs);
10744 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
10745 +
10746 + if (irq == 0)
10747 + W_REG(&sb->sbintvec, 0);
10748 + else
10749 + OR_REG(&sb->sbipsflag, sbips_int_mask[irq]);
10750 +}
10751 +
10752 +/*
10753 + * Assigns the specified MIPS IRQ to the specified core. Shared MIPS
10754 + * IRQ 0 may be assigned more than once.
10755 + */
10756 +static void
10757 +BCMINITFN(sb_setirq)(void *sbh, uint irq, uint coreid, uint coreunit)
10758 +{
10759 + void *regs;
10760 + sbconfig_t *sb;
10761 + uint32 flag;
10762 +
10763 + regs = sb_setcore(sbh, coreid, coreunit);
10764 + ASSERT(regs);
10765 + flag = sb_flag(sbh);
10766 +
10767 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
10768 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
10769 + ASSERT(regs);
10770 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
10771 +
10772 + if (irq == 0)
10773 + OR_REG(&sb->sbintvec, 1 << flag);
10774 + else {
10775 + flag <<= sbips_int_shift[irq];
10776 + ASSERT(!(flag & ~sbips_int_mask[irq]));
10777 + flag |= R_REG(&sb->sbipsflag) & ~sbips_int_mask[irq];
10778 + W_REG(&sb->sbipsflag, flag);
10779 + }
10780 +}
10781 +
10782 +/*
10783 + * Initializes clocks and interrupts. SB and NVRAM access must be
10784 + * initialized prior to calling.
10785 + */
10786 +void
10787 +BCMINITFN(sb_mips_init)(void *sbh)
10788 +{
10789 + ulong hz, ns, tmp;
10790 + extifregs_t *eir;
10791 + chipcregs_t *cc;
10792 + char *value;
10793 + uint irq;
10794 +
10795 + /* Figure out current SB clock speed */
10796 + if ((hz = sb_clock(sbh)) == 0)
10797 + hz = 100000000;
10798 + ns = 1000000000 / hz;
10799 +
10800 + /* Setup external interface timing */
10801 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
10802 + /* Initialize extif so we can get to the LEDs and external UART */
10803 + W_REG(&eir->prog_config, CF_EN);
10804 +
10805 + /* Set timing for the flash */
10806 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
10807 + tmp = tmp | (CEIL(40, ns) << FW_W1_SHIFT); /* W1 = 40nS */
10808 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
10809 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
10810 +
10811 + /* Set programmable interface timing for external uart */
10812 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
10813 + tmp = tmp | (CEIL(20, ns) << FW_W2_SHIFT); /* W2 = 20nS */
10814 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */
10815 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
10816 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
10817 + } else if ((cc = sb_setcore(sbh, SB_CC, 0))) {
10818 + /* Set timing for the flash */
10819 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
10820 + tmp |= CEIL(10, ns) << FW_W1_SHIFT; /* W1 = 10nS */
10821 + tmp |= CEIL(120, ns); /* W0 = 120nS */
10822 +
10823 + // Added by Chen-I for 5365
10824 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
10825 + {
10826 + W_REG(&cc->flash_waitcount, tmp);
10827 + W_REG(&cc->pcmcia_memwait, tmp);
10828 + }
10829 + else
10830 + {
10831 + if (sb_corerev(sbh) < 9)
10832 + W_REG(&cc->flash_waitcount, tmp);
10833 +
10834 + if ( (sb_corerev(sbh) < 9) ||
10835 + ((BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID) && BCMINIT(sb_chiprev)(sbh) == 0) ) {
10836 + W_REG(&cc->pcmcia_memwait, tmp);
10837 + }
10838 + }
10839 +
10840 + // Added by Chen-I & Yen for enabling 5350 EXTIF
10841 + if (BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID)
10842 + {
10843 + /* Set programmable interface timing for external uart */
10844 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
10845 + tmp = tmp | (CEIL(20, ns) << FW_W2_SHIFT); /* W2 = 20nS */
10846 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */
10847 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
10848 + W_REG(&cc->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
10849 + //printf("===========config_REG=%d\n", R_REG(&cc->prog_config));
10850 + //printf("-----------config_REG_addr=%x\n", &cc->prog_config);
10851 + //printf("===========waitcount_REG=%d\n", R_REG(&cc->prog_waitcount));
10852 + //printf("-----------waitcount_REG=%x\n", &cc->prog_waitcount);
10853 + }
10854 + }
10855 +
10856 + /* Chip specific initialization */
10857 + switch (BCMINIT(sb_chip)(sbh)) {
10858 + case BCM4710_DEVICE_ID:
10859 + /* Clear interrupt map */
10860 + for (irq = 0; irq <= 4; irq++)
10861 + BCMINIT(sb_clearirq)(sbh, irq);
10862 + BCMINIT(sb_setirq)(sbh, 0, SB_CODEC, 0);
10863 + BCMINIT(sb_setirq)(sbh, 0, SB_EXTIF, 0);
10864 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 1);
10865 + BCMINIT(sb_setirq)(sbh, 3, SB_ILINE20, 0);
10866 + BCMINIT(sb_setirq)(sbh, 4, SB_PCI, 0);
10867 + ASSERT(eir);
10868 + value = BCMINIT(nvram_get)("et0phyaddr");
10869 + if (value && !strcmp(value, "31")) {
10870 + /* Enable internal UART */
10871 + W_REG(&eir->corecontrol, CC_UE);
10872 + /* Give USB its own interrupt */
10873 + BCMINIT(sb_setirq)(sbh, 1, SB_USB, 0);
10874 + } else {
10875 + /* Disable internal UART */
10876 + W_REG(&eir->corecontrol, 0);
10877 + /* Give Ethernet its own interrupt */
10878 + BCMINIT(sb_setirq)(sbh, 1, SB_ENET, 0);
10879 + BCMINIT(sb_setirq)(sbh, 0, SB_USB, 0);
10880 + }
10881 + break;
10882 + case BCM4310_DEVICE_ID:
10883 + MTC0(C0_BROADCOM, 0, MFC0(C0_BROADCOM, 0) & ~(1 << 22));
10884 + break;
10885 + case BCM5350_DEVICE_ID:
10886 + /* Clear interrupt map */
10887 + for (irq = 0; irq <= 4; irq++)
10888 + BCMINIT(sb_clearirq)(sbh, irq);
10889 + BCMINIT(sb_setirq)(sbh, 0, SB_CC, 0);
10890 + BCMINIT(sb_setirq)(sbh, 1, SB_D11, 0);
10891 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 0);
10892 + BCMINIT(sb_setirq)(sbh, 3, SB_IPSEC, 0);
10893 + BCMINIT(sb_setirq)(sbh, 4, SB_USB, 0);
10894 + break;
10895 + }
10896 +}
10897 +
10898 +uint32
10899 +BCMINITFN(sb_mips_clock)(void *sbh)
10900 +{
10901 + extifregs_t *eir;
10902 + chipcregs_t *cc;
10903 + uint32 n, m;
10904 + uint idx;
10905 + uint32 pll_type, rate = 0;
10906 +
10907 + /* get index of the current core */
10908 + idx = sb_coreidx(sbh);
10909 + pll_type = PLL_TYPE1;
10910 +
10911 + /* switch to extif or chipc core */
10912 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
10913 + n = R_REG(&eir->clockcontrol_n);
10914 + m = R_REG(&eir->clockcontrol_sb);
10915 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
10916 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
10917 + n = R_REG(&cc->clockcontrol_n);
10918 + if ((pll_type == PLL_TYPE2) ||
10919 + (pll_type == PLL_TYPE4) ||
10920 + (pll_type == PLL_TYPE6))
10921 + m = R_REG(&cc->clockcontrol_mips);
10922 + else if (pll_type == PLL_TYPE5) {
10923 + rate = 200000000;
10924 + goto out;
10925 + }
10926 + else if (pll_type == PLL_TYPE3) {
10927 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) { /* 5365 is also type3 */
10928 + rate = 200000000;
10929 + goto out;
10930 + } else
10931 + m = R_REG(&cc->clockcontrol_m2); /* 5350 uses m2 to control mips */
10932 + } else
10933 + m = R_REG(&cc->clockcontrol_sb);
10934 + } else
10935 + goto out;
10936 +
10937 + // Added by Chen-I for 5365
10938 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
10939 + rate = 100000000;
10940 + else
10941 + /* calculate rate */
10942 + rate = sb_clock_rate(pll_type, n, m);
10943 +
10944 + if (pll_type == PLL_TYPE6)
10945 + rate = SB2MIPS_T6(rate);
10946 +
10947 +out:
10948 + /* switch back to previous core */
10949 + sb_setcoreidx(sbh, idx);
10950 +
10951 + return rate;
10952 +}
10953 +
10954 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
10955 +
10956 +static void
10957 +BCMINITFN(handler)(void)
10958 +{
10959 + /* Step 11 */
10960 + __asm__ (
10961 + ".set\tmips32\n\t"
10962 + "ssnop\n\t"
10963 + "ssnop\n\t"
10964 + /* Disable interrupts */
10965 + /* MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~(ALLINTS | STO_IE)); */
10966 + "mfc0 $15, $12\n\t"
10967 + /* Just a Hack to not to use reg 'at' which was causing problems on 4704 A2 */
10968 + "li $14, -31746\n\t"
10969 + "and $15, $15, $14\n\t"
10970 + "mtc0 $15, $12\n\t"
10971 + "eret\n\t"
10972 + "nop\n\t"
10973 + "nop\n\t"
10974 + ".set\tmips0"
10975 + );
10976 +}
10977 +
10978 +/* The following MUST come right after handler() */
10979 +static void
10980 +BCMINITFN(afterhandler)(void)
10981 +{
10982 +}
10983 +
10984 +/*
10985 + * Set the MIPS, backplane and PCI clocks as closely as possible.
10986 + */
10987 +bool
10988 +BCMINITFN(sb_mips_setclock)(void *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock)
10989 +{
10990 + extifregs_t *eir = NULL;
10991 + chipcregs_t *cc = NULL;
10992 + mipsregs_t *mipsr = NULL;
10993 + volatile uint32 *clockcontrol_n, *clockcontrol_sb, *clockcontrol_pci, *clockcontrol_m2;
10994 + uint32 orig_n, orig_sb, orig_pci, orig_m2, orig_mips, orig_ratio_parm, new_ratio;
10995 + uint32 pll_type, sync_mode;
10996 + uint ic_size, ic_lsize;
10997 + uint idx, i;
10998 + typedef struct {
10999 + uint32 mipsclock;
11000 + uint16 n;
11001 + uint32 sb;
11002 + uint32 pci33;
11003 + uint32 pci25;
11004 + } n3m_table_t;
11005 + static n3m_table_t BCMINITDATA(type1_table)[] = {
11006 + { 96000000, 0x0303, 0x04020011, 0x11030011, 0x11050011 }, /* 96.000 32.000 24.000 */
11007 + { 100000000, 0x0009, 0x04020011, 0x11030011, 0x11050011 }, /* 100.000 33.333 25.000 */
11008 + { 104000000, 0x0802, 0x04020011, 0x11050009, 0x11090009 }, /* 104.000 31.200 24.960 */
11009 + { 108000000, 0x0403, 0x04020011, 0x11050009, 0x02000802 }, /* 108.000 32.400 24.923 */
11010 + { 112000000, 0x0205, 0x04020011, 0x11030021, 0x02000403 }, /* 112.000 32.000 24.889 */
11011 + { 115200000, 0x0303, 0x04020009, 0x11030011, 0x11050011 }, /* 115.200 32.000 24.000 */
11012 + { 120000000, 0x0011, 0x04020011, 0x11050011, 0x11090011 }, /* 120.000 30.000 24.000 */
11013 + { 124800000, 0x0802, 0x04020009, 0x11050009, 0x11090009 }, /* 124.800 31.200 24.960 */
11014 + { 128000000, 0x0305, 0x04020011, 0x11050011, 0x02000305 }, /* 128.000 32.000 24.000 */
11015 + { 132000000, 0x0603, 0x04020011, 0x11050011, 0x02000305 }, /* 132.000 33.000 24.750 */
11016 + { 136000000, 0x0c02, 0x04020011, 0x11090009, 0x02000603 }, /* 136.000 32.640 24.727 */
11017 + { 140000000, 0x0021, 0x04020011, 0x11050021, 0x02000c02 }, /* 140.000 30.000 24.706 */
11018 + { 144000000, 0x0405, 0x04020011, 0x01020202, 0x11090021 }, /* 144.000 30.857 24.686 */
11019 + { 150857142, 0x0605, 0x04020021, 0x02000305, 0x02000605 }, /* 150.857 33.000 24.000 */
11020 + { 152000000, 0x0e02, 0x04020011, 0x11050021, 0x02000e02 }, /* 152.000 32.571 24.000 */
11021 + { 156000000, 0x0802, 0x04020005, 0x11050009, 0x11090009 }, /* 156.000 31.200 24.960 */
11022 + { 160000000, 0x0309, 0x04020011, 0x11090011, 0x02000309 }, /* 160.000 32.000 24.000 */
11023 + { 163200000, 0x0c02, 0x04020009, 0x11090009, 0x02000603 }, /* 163.200 32.640 24.727 */
11024 + { 168000000, 0x0205, 0x04020005, 0x11030021, 0x02000403 }, /* 168.000 32.000 24.889 */
11025 + { 176000000, 0x0602, 0x04020003, 0x11050005, 0x02000602 }, /* 176.000 33.000 24.000 */
11026 + };
11027 + typedef struct {
11028 + uint32 mipsclock;
11029 + uint16 n;
11030 + uint32 m2; /* that is the clockcontrol_m2 */
11031 + } type3_table_t;
11032 + static type3_table_t type3_table[] = { /* for 5350, mips clock is always double sb clock */
11033 + { 150000000, 0x311, 0x4020005 },
11034 +// { 180000000, 0x, 0x }, /* later we may want this frequency */
11035 + { 200000000, 0x311, 0x4020003 },
11036 + };
11037 + typedef struct {
11038 + uint32 mipsclock;
11039 + uint32 sbclock;
11040 + uint16 n;
11041 + uint32 sb;
11042 + uint32 pci33;
11043 + uint32 m2;
11044 + uint32 m3;
11045 + uint32 ratio;
11046 + uint32 ratio_parm;
11047 + } n4m_table_t;
11048 +
11049 + static n4m_table_t BCMINITDATA(type2_table)[] = {
11050 + { 180000000, 80000000, 0x0403, 0x01010000, 0x01020300, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11051 + { 180000000, 90000000, 0x0403, 0x01000100, 0x01020300, 0x01000100, 0x05000100, 0x21, 0x0aaa0555 },
11052 + { 200000000, 100000000, 0x0303, 0x01000000, 0x01000600, 0x01000000, 0x05000000, 0x21, 0x0aaa0555 },
11053 + { 211200000, 105600000, 0x0902, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11054 + { 220800000, 110400000, 0x1500, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11055 + { 230400000, 115200000, 0x0604, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11056 + { 234000000, 104000000, 0x0b01, 0x01010000, 0x01010700, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11057 + { 240000000, 120000000, 0x0803, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11058 + { 252000000, 126000000, 0x0504, 0x01000100, 0x01020500, 0x01000100, 0x05000100, 0x21, 0x0aaa0555 },
11059 + { 264000000, 132000000, 0x0903, 0x01000200, 0x01020700, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11060 + { 270000000, 120000000, 0x0703, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11061 + { 276000000, 122666666, 0x1500, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11062 + { 280000000, 140000000, 0x0503, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 0x21, 0x0aaa0555 },
11063 + { 288000000, 128000000, 0x0604, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11064 + { 288000000, 144000000, 0x0404, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 0x21, 0x0aaa0555 },
11065 + { 300000000, 133333333, 0x0803, 0x01010000, 0x01020600, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11066 + { 300000000, 150000000, 0x0803, 0x01000100, 0x01020600, 0x01000100, 0x05000100, 0x21, 0x0aaa0555 }
11067 + };
11068 +
11069 + static n4m_table_t BCMINITDATA(type4_table)[] = {
11070 + { 192000000, 96000000, 0x0702, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 0x21, 0x0aaa0555 },
11071 + { 200000000, 100000000, 0x0009, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 0x21, 0x0aaa0555 },
11072 + { 216000000, 108000000, 0x0111, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 0x21, 0x0aaa0555 },
11073 + { 228000000, 101333333, 0x0e02, 0x11030003, 0x11210005, 0x11030305, 0x04000005, 0x94, 0x012a00a9 },
11074 + { 228000000, 114000000, 0x0e02, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 0x21, 0x0aaa0555 },
11075 + { 240000000, 120000000, 0x0109, 0x11030002, 0x01050203, 0x11030002, 0x04000003, 0x21, 0x0aaa0555 },
11076 + { 252000000, 126000000, 0x0203, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 0x21, 0x0aaa0555 },
11077 + { 264000000, 132000000, 0x0602, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 0x21, 0x0aaa0555 },
11078 + { 272000000, 116571428, 0x0c02, 0x04000021, 0x02000909, 0x02000221, 0x04000003, 0x73, 0x254a14a9 },
11079 + { 280000000, 120000000, 0x0209, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 0x73, 0x254a14a9 },
11080 + { 288000000, 123428571, 0x0111, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 0x73, 0x254a14a9 },
11081 + { 300000000, 120000000, 0x0009, 0x04000009, 0x01030203, 0x02000902, 0x04000002, 0x52, 0x02520129 }
11082 + };
11083 + ulong start, end, dst;
11084 + bool ret = FALSE;
11085 +
11086 + /* get index of the current core */
11087 + idx = sb_coreidx(sbh);
11088 + clockcontrol_m2 = NULL;
11089 +
11090 + /* switch to extif or chipc core */
11091 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
11092 + pll_type = PLL_TYPE1;
11093 + clockcontrol_n = &eir->clockcontrol_n;
11094 + clockcontrol_sb = &eir->clockcontrol_sb;
11095 + clockcontrol_pci = &eir->clockcontrol_pci;
11096 + clockcontrol_m2 = &cc->clockcontrol_m2;
11097 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
11098 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
11099 + if (pll_type == PLL_TYPE6) {
11100 + clockcontrol_n = NULL;
11101 + clockcontrol_sb = NULL;
11102 + clockcontrol_pci = NULL;
11103 + } else {
11104 + clockcontrol_n = &cc->clockcontrol_n;
11105 + clockcontrol_sb = &cc->clockcontrol_sb;
11106 + clockcontrol_pci = &cc->clockcontrol_pci;
11107 + clockcontrol_m2 = &cc->clockcontrol_m2;
11108 + }
11109 + } else
11110 + goto done;
11111 +
11112 + if (pll_type == PLL_TYPE6) {
11113 + /* Silence compilers */
11114 + orig_n = orig_sb = orig_pci = 0;
11115 + } else {
11116 + /* Store the current clock register values */
11117 + orig_n = R_REG(clockcontrol_n);
11118 + orig_sb = R_REG(clockcontrol_sb);
11119 + orig_pci = R_REG(clockcontrol_pci);
11120 + }
11121 +
11122 + if (pll_type == PLL_TYPE1) {
11123 + /* Keep the current PCI clock if not specified */
11124 + if (pciclock == 0) {
11125 + pciclock = sb_clock_rate(pll_type, R_REG(clockcontrol_n), R_REG(clockcontrol_pci));
11126 + pciclock = (pciclock <= 25000000) ? 25000000 : 33000000;
11127 + }
11128 +
11129 + /* Search for the closest MIPS clock less than or equal to a preferred value */
11130 + for (i = 0; i < ARRAYSIZE(BCMINIT(type1_table)); i++) {
11131 + ASSERT(BCMINIT(type1_table)[i].mipsclock ==
11132 + sb_clock_rate(pll_type, BCMINIT(type1_table)[i].n, BCMINIT(type1_table)[i].sb));
11133 + if (BCMINIT(type1_table)[i].mipsclock > mipsclock)
11134 + break;
11135 + }
11136 + if (i == 0) {
11137 + ret = FALSE;
11138 + goto done;
11139 + } else {
11140 + ret = TRUE;
11141 + i--;
11142 + }
11143 + ASSERT(BCMINIT(type1_table)[i].mipsclock <= mipsclock);
11144 +
11145 + /* No PLL change */
11146 + if ((orig_n == BCMINIT(type1_table)[i].n) &&
11147 + (orig_sb == BCMINIT(type1_table)[i].sb) &&
11148 + (orig_pci == BCMINIT(type1_table)[i].pci33))
11149 + goto done;
11150 +
11151 + /* Set the PLL controls */
11152 + W_REG(clockcontrol_n, BCMINIT(type1_table)[i].n);
11153 + W_REG(clockcontrol_sb, BCMINIT(type1_table)[i].sb);
11154 + if (pciclock == 25000000)
11155 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci25);
11156 + else
11157 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci33);
11158 +
11159 + /* Reset */
11160 + sb_watchdog(sbh, 1);
11161 +
11162 + while (1);
11163 + } else if ((pll_type == PLL_TYPE3) &&
11164 + (BCMINIT(sb_chip)(sbh) != BCM5365_DEVICE_ID)) {
11165 + /* 5350 */
11166 + /* Search for the closest MIPS clock less than or equal to a preferred value */
11167 +
11168 + for (i = 0; i < ARRAYSIZE(type3_table); i++) {
11169 + if (type3_table[i].mipsclock > mipsclock)
11170 + break;
11171 + }
11172 + if (i == 0) {
11173 + ret = FALSE;
11174 + goto done;
11175 + } else {
11176 + ret = TRUE;
11177 + i--;
11178 + }
11179 + ASSERT(type3_table[i].mipsclock <= mipsclock);
11180 +
11181 + /* No PLL change */
11182 + orig_m2 = R_REG(&cc->clockcontrol_m2);
11183 + if ((orig_n == type3_table[i].n) &&
11184 + (orig_m2 == type3_table[i].m2)) {
11185 + goto done;
11186 + }
11187 +
11188 + /* Set the PLL controls */
11189 + W_REG(clockcontrol_n, type3_table[i].n);
11190 + W_REG(clockcontrol_m2, type3_table[i].m2);
11191 +
11192 + /* Reset */
11193 + sb_watchdog(sbh, 1);
11194 + while (1);
11195 + } else if ((pll_type == PLL_TYPE2) ||
11196 + (pll_type == PLL_TYPE4) ||
11197 + (pll_type == PLL_TYPE6)) {
11198 + n4m_table_t *table = NULL;
11199 + uint tabsz = 0;
11200 +
11201 + ASSERT(cc);
11202 +
11203 + orig_mips = R_REG(&cc->clockcontrol_mips);
11204 +
11205 + if (pll_type == PLL_TYPE6) {
11206 + uint32 new_mips = 0;
11207 +
11208 + ret = TRUE;
11209 + if (mipsclock <= SB2MIPS_T6(CC_T6_M1))
11210 + new_mips = CC_T6_MMASK;
11211 +
11212 + if (orig_mips == new_mips)
11213 + goto done;
11214 +
11215 + W_REG(&cc->clockcontrol_mips, new_mips);
11216 + goto end_fill;
11217 + }
11218 +
11219 + table = (pll_type == PLL_TYPE2) ? BCMINIT(type2_table) : BCMINIT(type4_table);
11220 + tabsz = (pll_type == PLL_TYPE2) ? ARRAYSIZE(BCMINIT(type2_table)) :
11221 + ARRAYSIZE(BCMINIT(type4_table));
11222 +
11223 + /* Store the current clock register values */
11224 + orig_m2 = R_REG(&cc->clockcontrol_m2);
11225 + orig_ratio_parm = 0;
11226 +
11227 + /* Look up current ratio */
11228 + for (i = 0; i < tabsz; i++) {
11229 + if ((orig_n == table[i].n) &&
11230 + (orig_sb == table[i].sb) &&
11231 + (orig_pci == table[i].pci33) &&
11232 + (orig_m2 == table[i].m2) &&
11233 + (orig_mips == table[i].m3)) {
11234 + orig_ratio_parm = table[i].ratio_parm;
11235 + break;
11236 + }
11237 + }
11238 +
11239 + /* Search for the closest MIPS clock greater or equal to a preferred value */
11240 + for (i = 0; i < tabsz; i++) {
11241 + ASSERT(table[i].mipsclock ==
11242 + sb_clock_rate(pll_type, table[i].n, table[i].m3));
11243 + if ((mipsclock <= table[i].mipsclock) &&
11244 + ((sbclock == 0) || (sbclock <= table[i].sbclock)))
11245 + break;
11246 + }
11247 + if (i == tabsz) {
11248 + ret = FALSE;
11249 + goto done;
11250 + } else {
11251 + ret = TRUE;
11252 + }
11253 +
11254 + /* No PLL change */
11255 + if ((orig_n == table[i].n) &&
11256 + (orig_sb == table[i].sb) &&
11257 + (orig_pci == table[i].pci33) &&
11258 + (orig_m2 == table[i].m2) &&
11259 + (orig_mips == table[i].m3))
11260 + goto done;
11261 +
11262 + /* Set the PLL controls */
11263 + W_REG(clockcontrol_n, table[i].n);
11264 + W_REG(clockcontrol_sb, table[i].sb);
11265 + W_REG(clockcontrol_pci, table[i].pci33);
11266 + W_REG(&cc->clockcontrol_m2, table[i].m2);
11267 + W_REG(&cc->clockcontrol_mips, table[i].m3);
11268 +
11269 + /* No ratio change */
11270 + if (orig_ratio_parm == table[i].ratio_parm)
11271 + goto end_fill;
11272 +
11273 + new_ratio = table[i].ratio_parm;
11274 +
11275 + icache_probe(MFC0(C0_CONFIG, 1), &ic_size, &ic_lsize);
11276 +
11277 + /* Preload the code into the cache */
11278 + start = ((ulong) &&start_fill) & ~(ic_lsize - 1);
11279 + end = ((ulong) &&end_fill + (ic_lsize - 1)) & ~(ic_lsize - 1);
11280 + while (start < end) {
11281 + cache_unroll(start, Fill_I);
11282 + start += ic_lsize;
11283 + }
11284 +
11285 + /* Copy the handler */
11286 + start = (ulong) &BCMINIT(handler);
11287 + end = (ulong) &BCMINIT(afterhandler);
11288 + dst = KSEG1ADDR(0x180);
11289 + for (i = 0; i < (end - start); i += 4)
11290 + *((ulong *)(dst + i)) = *((ulong *)(start + i));
11291 +
11292 + /* Preload handler into the cache one line at a time */
11293 + for (i = 0; i < (end - start); i += 4)
11294 + cache_unroll(dst + i, Fill_I);
11295 +
11296 + /* Clear BEV bit */
11297 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~ST0_BEV);
11298 +
11299 + /* Enable interrupts */
11300 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) | (ALLINTS | ST0_IE));
11301 +
11302 + /* Enable MIPS timer interrupt */
11303 + if (!(mipsr = sb_setcore(sbh, SB_MIPS, 0)) &&
11304 + !(mipsr = sb_setcore(sbh, SB_MIPS33, 0)))
11305 + ASSERT(mipsr);
11306 + W_REG(&mipsr->intmask, 1);
11307 +
11308 + start_fill:
11309 + /* step 1, set clock ratios */
11310 + MTC0(C0_BROADCOM, 3, new_ratio);
11311 + MTC0(C0_BROADCOM, 1, 8);
11312 +
11313 + /* step 2: program timer intr */
11314 + W_REG(&mipsr->timer, 100);
11315 + (void) R_REG(&mipsr->timer);
11316 +
11317 + /* step 3, switch to async */
11318 + sync_mode = MFC0(C0_BROADCOM, 4);
11319 + MTC0(C0_BROADCOM, 4, 1 << 22);
11320 +
11321 + /* step 4, set cfg active */
11322 + MTC0(C0_BROADCOM, 2, 0x9);
11323 +
11324 +
11325 + /* steps 5 & 6 */
11326 + __asm__ __volatile__ (
11327 + ".set\tmips3\n\t"
11328 + "wait\n\t"
11329 + ".set\tmips0"
11330 + );
11331 +
11332 + /* step 7, clear cfg_active */
11333 + MTC0(C0_BROADCOM, 2, 0);
11334 +
11335 + /* Additional Step: set back to orig sync mode */
11336 + MTC0(C0_BROADCOM, 4, sync_mode);
11337 +
11338 + /* step 8, fake soft reset */
11339 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | 4);
11340 +
11341 + end_fill:
11342 + /* step 9 set watchdog timer */
11343 + sb_watchdog(sbh, 20);
11344 + (void) R_REG(&cc->chipid);
11345 +
11346 + /* step 11 */
11347 + __asm__ __volatile__ (
11348 + ".set\tmips3\n\t"
11349 + "sync\n\t"
11350 + "wait\n\t"
11351 + ".set\tmips0"
11352 + );
11353 + while (1);
11354 + }
11355 +
11356 +done:
11357 + /* switch back to previous core */
11358 + sb_setcoreidx(sbh, idx);
11359 +
11360 + return ret;
11361 +}
11362 +
11363 +
11364 +/* returns the ncdl value to be programmed into sdram_ncdl for calibration */
11365 +uint32
11366 +BCMINITFN(sb_memc_get_ncdl)(void *sbh)
11367 +{
11368 + sbmemcregs_t *memc;
11369 + uint32 ret = 0;
11370 + uint32 config, rd, wr, misc, dqsg, cd, sm, sd;
11371 + uint idx, rev;
11372 +
11373 + idx = sb_coreidx(sbh);
11374 +
11375 + memc = (sbmemcregs_t *)sb_setcore(sbh, SB_MEMC, 0);
11376 + if (memc == 0)
11377 + goto out;
11378 +
11379 + rev = sb_corerev(sbh);
11380 +
11381 + config = R_REG(&memc->config);
11382 + wr = R_REG(&memc->wrncdlcor);
11383 + rd = R_REG(&memc->rdncdlcor);
11384 + misc = R_REG(&memc->miscdlyctl);
11385 + dqsg = R_REG(&memc->dqsgatencdl);
11386 +
11387 + rd &= MEMC_RDNCDLCOR_RD_MASK;
11388 + wr &= MEMC_WRNCDLCOR_WR_MASK;
11389 + dqsg &= MEMC_DQSGATENCDL_G_MASK;
11390 +
11391 + if (config & MEMC_CONFIG_DDR) {
11392 + ret = (wr << 16) | (rd << 8) | dqsg;
11393 + } else {
11394 + if ( (rev > 0) || (sb_chip(sbh) == BCM5365_DEVICE_ID))
11395 +
11396 + cd = rd;
11397 + else
11398 + cd = (rd == MEMC_CD_THRESHOLD) ? rd : (wr + MEMC_CD_THRESHOLD);
11399 + sm = (misc & MEMC_MISC_SM_MASK) >> MEMC_MISC_SM_SHIFT;
11400 + sd = (misc & MEMC_MISC_SD_MASK) >> MEMC_MISC_SD_SHIFT;
11401 + ret = (sm << 16) | (sd << 8) | cd;
11402 + }
11403 +
11404 +out:
11405 + /* switch back to previous core */
11406 + sb_setcoreidx(sbh, idx);
11407 +
11408 + return ret;
11409 +}
11410 +
11411 +/* returns the PFC values to be used based on the chip ID*/
11412 +
11413 +uint32
11414 +BCMINITFN(sb_mips_get_pfc)(void *sbh)
11415 +{
11416 + if (BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID)
11417 + return 0x11;
11418 + else
11419 + return 0x15;
11420 +}
11421 diff -Nur linux-2.4.30/arch/mips/bcm947xx/sbpci.c linux-2.4.30-brcm/arch/mips/bcm947xx/sbpci.c
11422 --- linux-2.4.30/arch/mips/bcm947xx/sbpci.c 1970-01-01 01:00:00.000000000 +0100
11423 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/sbpci.c 2005-05-26 21:56:08.000000000 +0200
11424 @@ -0,0 +1,569 @@
11425 +/*
11426 + * Low-Level PCI and SB support for BCM47xx
11427 + *
11428 + * Copyright 2004, Broadcom Corporation
11429 + * All Rights Reserved.
11430 + *
11431 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
11432 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11433 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11434 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11435 + *
11436 + * $Id$
11437 + */
11438 +
11439 +#include <typedefs.h>
11440 +#include <pcicfg.h>
11441 +#include <bcmdevs.h>
11442 +#include <sbconfig.h>
11443 +#include <sbpci.h>
11444 +#include <osl.h>
11445 +#include <bcmendian.h>
11446 +#include <bcmutils.h>
11447 +#include <sbutils.h>
11448 +#include <bcmnvram.h>
11449 +#include <hndmips.h>
11450 +
11451 +/* Can free sbpci_init() memory after boot */
11452 +#ifndef linux
11453 +#define __init
11454 +#endif
11455 +
11456 +/* Emulated configuration space */
11457 +static pci_config_regs sb_config_regs[SB_MAXCORES];
11458 +
11459 +/* Banned cores */
11460 +static uint16 pci_ban[32] = { 0 };
11461 +static uint pci_banned = 0;
11462 +
11463 +/* CardBus mode */
11464 +static bool cardbus = FALSE;
11465 +
11466 +/* Disable PCI host core */
11467 +static bool pci_disabled = FALSE;
11468 +
11469 +/*
11470 + * Functions for accessing external PCI configuration space
11471 + */
11472 +
11473 +/* Assume one-hot slot wiring */
11474 +#define PCI_SLOT_MAX 16
11475 +
11476 +static uint32
11477 +config_cmd(void *sbh, uint bus, uint dev, uint func, uint off)
11478 +{
11479 + uint coreidx;
11480 + sbpciregs_t *regs;
11481 + uint32 addr = 0;
11482 +
11483 + /* CardBusMode supports only one device */
11484 + if (cardbus && dev > 1)
11485 + return 0;
11486 +
11487 + coreidx = sb_coreidx(sbh);
11488 + regs = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
11489 +
11490 + /* Type 0 transaction */
11491 + if (bus == 1) {
11492 + /* Skip unwired slots */
11493 + if (dev < PCI_SLOT_MAX) {
11494 + /* Slide the PCI window to the appropriate slot */
11495 + W_REG(&regs->sbtopci1, SBTOPCI_CFG0 | ((1 << (dev + 16)) & SBTOPCI1_MASK));
11496 + addr = SB_PCI_CFG | ((1 << (dev + 16)) & ~SBTOPCI1_MASK) |
11497 + (func << 8) | (off & ~3);
11498 + }
11499 + }
11500 +
11501 + /* Type 1 transaction */
11502 + else {
11503 + W_REG(&regs->sbtopci1, SBTOPCI_CFG1);
11504 + addr = SB_PCI_CFG | (bus << 16) | (dev << 11) | (func << 8) | (off & ~3);
11505 + }
11506 +
11507 + sb_setcoreidx(sbh, coreidx);
11508 +
11509 + return addr;
11510 +}
11511 +
11512 +static int
11513 +extpci_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11514 +{
11515 + uint32 addr, *reg = NULL, val;
11516 + int ret = 0;
11517 +
11518 + if (pci_disabled ||
11519 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
11520 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
11521 + BUSPROBE(val, reg))
11522 + val = 0xffffffff;
11523 +
11524 + val >>= 8 * (off & 3);
11525 + if (len == 4)
11526 + *((uint32 *) buf) = val;
11527 + else if (len == 2)
11528 + *((uint16 *) buf) = (uint16) val;
11529 + else if (len == 1)
11530 + *((uint8 *) buf) = (uint8) val;
11531 + else
11532 + ret = -1;
11533 +
11534 + if (reg)
11535 + REG_UNMAP(reg);
11536 +
11537 + return ret;
11538 +}
11539 +
11540 +static int
11541 +extpci_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11542 +{
11543 + uint32 addr, *reg = NULL, val;
11544 + int ret = 0;
11545 +
11546 + if (pci_disabled ||
11547 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
11548 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
11549 + BUSPROBE(val, reg))
11550 + goto done;
11551 +
11552 + if (len == 4)
11553 + val = *((uint32 *) buf);
11554 + else if (len == 2) {
11555 + val &= ~(0xffff << (8 * (off & 3)));
11556 + val |= *((uint16 *) buf) << (8 * (off & 3));
11557 + } else if (len == 1) {
11558 + val &= ~(0xff << (8 * (off & 3)));
11559 + val |= *((uint8 *) buf) << (8 * (off & 3));
11560 + } else
11561 + ret = -1;
11562 +
11563 + W_REG(reg, val);
11564 +
11565 + done:
11566 + if (reg)
11567 + REG_UNMAP(reg);
11568 +
11569 + return ret;
11570 +}
11571 +
11572 +/*
11573 + * Functions for accessing translated SB configuration space
11574 + */
11575 +
11576 +static int
11577 +sb_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11578 +{
11579 + pci_config_regs *cfg;
11580 +
11581 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
11582 + return -1;
11583 + cfg = &sb_config_regs[dev];
11584 +
11585 + ASSERT(ISALIGNED(off, len));
11586 + ASSERT(ISALIGNED((uintptr)buf, len));
11587 +
11588 + if (len == 4)
11589 + *((uint32 *) buf) = ltoh32(*((uint32 *)((ulong) cfg + off)));
11590 + else if (len == 2)
11591 + *((uint16 *) buf) = ltoh16(*((uint16 *)((ulong) cfg + off)));
11592 + else if (len == 1)
11593 + *((uint8 *) buf) = *((uint8 *)((ulong) cfg + off));
11594 + else
11595 + return -1;
11596 +
11597 + return 0;
11598 +}
11599 +
11600 +static int
11601 +sb_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11602 +{
11603 + uint coreidx, n;
11604 + void *regs;
11605 + sbconfig_t *sb;
11606 + pci_config_regs *cfg;
11607 +
11608 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
11609 + return -1;
11610 + cfg = &sb_config_regs[dev];
11611 +
11612 + ASSERT(ISALIGNED(off, len));
11613 + ASSERT(ISALIGNED((uintptr)buf, len));
11614 +
11615 + /* Emulate BAR sizing */
11616 + if (off >= OFFSETOF(pci_config_regs, base[0]) && off <= OFFSETOF(pci_config_regs, base[3]) &&
11617 + len == 4 && *((uint32 *) buf) == ~0) {
11618 + coreidx = sb_coreidx(sbh);
11619 + if ((regs = sb_setcoreidx(sbh, dev))) {
11620 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
11621 + /* Highest numbered address match register */
11622 + n = (R_REG(&sb->sbidlow) & SBIDL_AR_MASK) >> SBIDL_AR_SHIFT;
11623 + if (off == OFFSETOF(pci_config_regs, base[0]))
11624 + cfg->base[0] = ~(sb_size(R_REG(&sb->sbadmatch0)) - 1);
11625 + else if (off == OFFSETOF(pci_config_regs, base[1]) && n >= 1)
11626 + cfg->base[1] = ~(sb_size(R_REG(&sb->sbadmatch1)) - 1);
11627 + else if (off == OFFSETOF(pci_config_regs, base[2]) && n >= 2)
11628 + cfg->base[2] = ~(sb_size(R_REG(&sb->sbadmatch2)) - 1);
11629 + else if (off == OFFSETOF(pci_config_regs, base[3]) && n >= 3)
11630 + cfg->base[3] = ~(sb_size(R_REG(&sb->sbadmatch3)) - 1);
11631 + }
11632 + sb_setcoreidx(sbh, coreidx);
11633 + return 0;
11634 + }
11635 +
11636 + if (len == 4)
11637 + *((uint32 *)((ulong) cfg + off)) = htol32(*((uint32 *) buf));
11638 + else if (len == 2)
11639 + *((uint16 *)((ulong) cfg + off)) = htol16(*((uint16 *) buf));
11640 + else if (len == 1)
11641 + *((uint8 *)((ulong) cfg + off)) = *((uint8 *) buf);
11642 + else
11643 + return -1;
11644 +
11645 + return 0;
11646 +}
11647 +
11648 +int
11649 +sbpci_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11650 +{
11651 + if (bus == 0)
11652 + return sb_read_config(sbh, bus, dev, func, off, buf, len);
11653 + else
11654 + return extpci_read_config(sbh, bus, dev, func, off, buf, len);
11655 +}
11656 +
11657 +int
11658 +sbpci_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11659 +{
11660 + if (bus == 0)
11661 + return sb_write_config(sbh, bus, dev, func, off, buf, len);
11662 + else
11663 + return extpci_write_config(sbh, bus, dev, func, off, buf, len);
11664 +}
11665 +
11666 +void
11667 +sbpci_ban(uint16 core)
11668 +{
11669 + if (pci_banned < ARRAYSIZE(pci_ban))
11670 + pci_ban[pci_banned++] = core;
11671 +}
11672 +
11673 +int __init
11674 +sbpci_init(void *sbh)
11675 +{
11676 + uint chip, chiprev, chippkg, coreidx, host, i;
11677 + uint32 boardflags;
11678 + sbpciregs_t *pci;
11679 + sbconfig_t *sb;
11680 + pci_config_regs *cfg;
11681 + void *regs;
11682 + char varname[8];
11683 + int CT4712_WR;
11684 + uint wlidx = 0;
11685 + uint16 vendor, core;
11686 + uint8 class, subclass, progif;
11687 + uint32 val;
11688 + uint32 sbips_int_mask[] = { 0, SBIPS_INT1_MASK, SBIPS_INT2_MASK, SBIPS_INT3_MASK, SBIPS_INT4_MASK };
11689 + uint32 sbips_int_shift[] = { 0, 0, SBIPS_INT2_SHIFT, SBIPS_INT3_SHIFT, SBIPS_INT4_SHIFT };
11690 +
11691 + chip = sb_chip(sbh);
11692 + chiprev = sb_chiprev(sbh);
11693 + chippkg = sb_chippkg(sbh);
11694 + coreidx = sb_coreidx(sbh);
11695 +
11696 + if (!(pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0)))
11697 + return -1;
11698 + sb_core_reset(sbh, 0);
11699 +
11700 + /* In some board,
11701 + if(nvram_match("boardtype", "bcm94710dev"))
11702 + CT4712_WR = 0;
11703 + else
11704 + CT4712_WR = 1;
11705 + */
11706 +
11707 + boardflags = (uint32) getintvar(NULL, "boardflags");
11708 +
11709 + if ((chip == BCM4310_DEVICE_ID) && (chiprev == 0))
11710 + pci_disabled = TRUE;
11711 +
11712 + /*
11713 + * The 200-pin BCM4712 package does not bond out PCI. Even when
11714 + * PCI is bonded out, some boards may leave the pins
11715 + * floating.
11716 + */
11717 + if (((chip == BCM4712_DEVICE_ID) &&
11718 + ((chippkg == BCM4712SMALL_PKG_ID) ||
11719 + (chippkg == BCM4712MID_PKG_ID))) )
11720 + pci_disabled = TRUE;
11721 +
11722 + /*
11723 + * If the PCI core should not be touched (disabled, not bonded
11724 + * out, or pins floating), do not even attempt to access core
11725 + * registers. Otherwise, try to determine if it is in host
11726 + * mode.
11727 + */
11728 + if (pci_disabled)
11729 + host = 0;
11730 + else
11731 + host = !BUSPROBE(val, &pci->control);
11732 +
11733 + if (!host) {
11734 + /* Disable PCI interrupts in client mode */
11735 + sb = (sbconfig_t *)((ulong) pci + SBCONFIGOFF);
11736 + W_REG(&sb->sbintvec, 0);
11737 +
11738 + /* Disable the PCI bridge in client mode */
11739 + sbpci_ban(SB_PCI);
11740 + printf("PCI: Disabled\n");
11741 + } else {
11742 + /* Reset the external PCI bus and enable the clock */
11743 + W_REG(&pci->control, 0x5); /* enable the tristate drivers */
11744 + W_REG(&pci->control, 0xd); /* enable the PCI clock */
11745 + OSL_DELAY(150); /* delay > 100 us */
11746 + W_REG(&pci->control, 0xf); /* deassert PCI reset */
11747 + W_REG(&pci->arbcontrol, PCI_INT_ARB); /* use internal arbiter */
11748 + OSL_DELAY(1); /* delay 1 us */
11749 +
11750 + /* Enable CardBusMode */
11751 + cardbus = nvram_match("cardbus", "1");
11752 + if (cardbus) {
11753 + printf("PCI: Enabling CardBus\n");
11754 + /* GPIO 1 resets the CardBus device on bcm94710ap */
11755 + sb_gpioout(sbh, 1, 1);
11756 + sb_gpioouten(sbh, 1, 1);
11757 + W_REG(&pci->sprom[0], R_REG(&pci->sprom[0]) | 0x400);
11758 + }
11759 +
11760 + /* 64 MB I/O access window */
11761 + W_REG(&pci->sbtopci0, SBTOPCI_IO);
11762 + /* 64 MB configuration access window */
11763 + W_REG(&pci->sbtopci1, SBTOPCI_CFG0);
11764 + /* 1 GB memory access window */
11765 + W_REG(&pci->sbtopci2, SBTOPCI_MEM | SB_PCI_DMA);
11766 +
11767 + /* Enable PCI bridge BAR0 prefetch and burst */
11768 + val = 6;
11769 + sbpci_write_config(sbh, 1, 0, 0, PCI_CFG_CMD, &val, sizeof(val));
11770 +
11771 + /* Enable PCI interrupts */
11772 + W_REG(&pci->intmask, PCI_INTA);
11773 + }
11774 +
11775 + /* Scan the SB bus */
11776 + bzero(sb_config_regs, sizeof(sb_config_regs));
11777 + for (cfg = sb_config_regs; cfg < &sb_config_regs[SB_MAXCORES]; cfg++) {
11778 + cfg->vendor = 0xffff;
11779 + if (!(regs = sb_setcoreidx(sbh, cfg - sb_config_regs)))
11780 + continue;
11781 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
11782 +
11783 + /* Read ID register and parse vendor and core */
11784 + val = R_REG(&sb->sbidhigh);
11785 + vendor = (val & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT;
11786 + core = (val & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;
11787 + progif = 0;
11788 +
11789 + /* Check if this core is banned */
11790 + for (i = 0; i < pci_banned; i++)
11791 + if (core == pci_ban[i])
11792 + break;
11793 + if (i < pci_banned)
11794 + continue;
11795 +
11796 + /* Known vendor translations */
11797 + switch (vendor) {
11798 + case SB_VEND_BCM:
11799 + vendor = VENDOR_BROADCOM;
11800 + break;
11801 + }
11802 +
11803 + /* Determine class based on known core codes */
11804 + switch (core) {
11805 + case SB_ILINE20:
11806 + class = PCI_CLASS_NET;
11807 + subclass = PCI_NET_ETHER;
11808 + core = BCM47XX_ILINE_ID;
11809 + break;
11810 + case SB_ILINE100:
11811 + class = PCI_CLASS_NET;
11812 + subclass = PCI_NET_ETHER;
11813 + core = BCM4610_ILINE_ID;
11814 + break;
11815 + case SB_ENET:
11816 + class = PCI_CLASS_NET;
11817 + subclass = PCI_NET_ETHER;
11818 + core = BCM47XX_ENET_ID;
11819 + break;
11820 + case SB_SDRAM:
11821 + case SB_MEMC:
11822 + class = PCI_CLASS_MEMORY;
11823 + subclass = PCI_MEMORY_RAM;
11824 + break;
11825 + case SB_PCI:
11826 + class = PCI_CLASS_BRIDGE;
11827 + subclass = PCI_BRIDGE_PCI;
11828 + break;
11829 + case SB_MIPS:
11830 + case SB_MIPS33:
11831 + class = PCI_CLASS_CPU;
11832 + subclass = PCI_CPU_MIPS;
11833 + break;
11834 + case SB_CODEC:
11835 + class = PCI_CLASS_COMM;
11836 + subclass = PCI_COMM_MODEM;
11837 + core = BCM47XX_V90_ID;
11838 + break;
11839 + case SB_USB:
11840 + class = PCI_CLASS_SERIAL;
11841 + subclass = PCI_SERIAL_USB;
11842 + progif = 0x10; /* OHCI */
11843 + core = BCM47XX_USB_ID;
11844 + break;
11845 + case SB_USB11H:
11846 + class = PCI_CLASS_SERIAL;
11847 + subclass = PCI_SERIAL_USB;
11848 + progif = 0x10; /* OHCI */
11849 + core = BCM47XX_USBH_ID;
11850 + break;
11851 + case SB_USB11D:
11852 + class = PCI_CLASS_SERIAL;
11853 + subclass = PCI_SERIAL_USB;
11854 + core = BCM47XX_USBD_ID;
11855 + break;
11856 + case SB_IPSEC:
11857 + class = PCI_CLASS_CRYPT;
11858 + subclass = PCI_CRYPT_NETWORK;
11859 + core = BCM47XX_IPSEC_ID;
11860 + break;
11861 + case SB_ROBO:
11862 + class = PCI_CLASS_NET;
11863 + subclass = PCI_NET_OTHER;
11864 + core = BCM47XX_ROBO_ID;
11865 + break;
11866 + case SB_EXTIF:
11867 + case SB_CC:
11868 + class = PCI_CLASS_MEMORY;
11869 + subclass = PCI_MEMORY_FLASH;
11870 + break;
11871 + case SB_D11:
11872 + class = PCI_CLASS_NET;
11873 + subclass = PCI_NET_OTHER;
11874 + /* Let an nvram variable override this */
11875 + sprintf(varname, "wl%did", wlidx);
11876 + wlidx++;
11877 + if ((core = getintvar(NULL, varname)) == 0) {
11878 + if (chip == BCM4712_DEVICE_ID) {
11879 + if (chippkg == BCM4712SMALL_PKG_ID)
11880 + core = BCM4306_D11G_ID;
11881 + else
11882 + core = BCM4306_D11DUAL_ID;
11883 + } else {
11884 + /* 4310 */
11885 + core = BCM4310_D11B_ID;
11886 + }
11887 + }
11888 + break;
11889 +
11890 + default:
11891 + class = subclass = progif = 0xff;
11892 + break;
11893 + }
11894 +
11895 + /* Supported translations */
11896 + cfg->vendor = htol16(vendor);
11897 + cfg->device = htol16(core);
11898 + cfg->rev_id = chiprev;
11899 + cfg->prog_if = progif;
11900 + cfg->sub_class = subclass;
11901 + cfg->base_class = class;
11902 + cfg->base[0] = htol32(sb_base(R_REG(&sb->sbadmatch0)));
11903 + cfg->base[1] = htol32(sb_base(R_REG(&sb->sbadmatch1)));
11904 + cfg->base[2] = htol32(sb_base(R_REG(&sb->sbadmatch2)));
11905 + cfg->base[3] = htol32(sb_base(R_REG(&sb->sbadmatch3)));
11906 + cfg->base[4] = 0;
11907 + cfg->base[5] = 0;
11908 + if (class == PCI_CLASS_BRIDGE && subclass == PCI_BRIDGE_PCI)
11909 + cfg->header_type = PCI_HEADER_BRIDGE;
11910 + else
11911 + cfg->header_type = PCI_HEADER_NORMAL;
11912 + /* Save core interrupt flag */
11913 + cfg->int_pin = R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK;
11914 + /* Default to MIPS shared interrupt 0 */
11915 + cfg->int_line = 0;
11916 + /* MIPS sbipsflag maps core interrupt flags to interrupts 1 through 4 */
11917 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
11918 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
11919 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
11920 + val = R_REG(&sb->sbipsflag);
11921 + for (cfg->int_line = 1; cfg->int_line <= 4; cfg->int_line++) {
11922 + if (((val & sbips_int_mask[cfg->int_line]) >> sbips_int_shift[cfg->int_line]) == cfg->int_pin)
11923 + break;
11924 + }
11925 + if (cfg->int_line > 4)
11926 + cfg->int_line = 0;
11927 + }
11928 + /* Emulated core */
11929 + *((uint32 *) &cfg->sprom_control) = 0xffffffff;
11930 + }
11931 +
11932 + sb_setcoreidx(sbh, coreidx);
11933 + return 0;
11934 +}
11935 +
11936 +void
11937 +sbpci_check(void *sbh)
11938 +{
11939 + uint coreidx;
11940 + sbpciregs_t *pci;
11941 + uint32 sbtopci1;
11942 + uint32 buf[64], *ptr, i;
11943 + ulong pa;
11944 + volatile uint j;
11945 +
11946 + coreidx = sb_coreidx(sbh);
11947 + pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
11948 +
11949 + /* Clear the test array */
11950 + pa = (ulong) DMA_MAP(NULL, buf, sizeof(buf), DMA_RX, NULL);
11951 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]);
11952 + memset(ptr, 0, sizeof(buf));
11953 +
11954 + /* Point PCI window 1 to memory */
11955 + sbtopci1 = R_REG(&pci->sbtopci1);
11956 + W_REG(&pci->sbtopci1, SBTOPCI_MEM | (pa & SBTOPCI1_MASK));
11957 +
11958 + /* Fill the test array via PCI window 1 */
11959 + ptr = (uint32 *) REG_MAP(SB_PCI_CFG + (pa & ~SBTOPCI1_MASK), sizeof(buf));
11960 + for (i = 0; i < ARRAYSIZE(buf); i++) {
11961 + for (j = 0; j < 2; j++);
11962 + W_REG(&ptr[i], i);
11963 + }
11964 + REG_UNMAP(ptr);
11965 +
11966 + /* Restore PCI window 1 */
11967 + W_REG(&pci->sbtopci1, sbtopci1);
11968 +
11969 + /* Check the test array */
11970 + DMA_UNMAP(NULL, pa, sizeof(buf), DMA_RX, NULL);
11971 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]);
11972 + for (i = 0; i < ARRAYSIZE(buf); i++) {
11973 + if (ptr[i] != i)
11974 + break;
11975 + }
11976 +
11977 + /* Change the clock if the test fails */
11978 + if (i < ARRAYSIZE(buf)) {
11979 + uint32 req, cur;
11980 +
11981 + cur = sb_clock(sbh);
11982 + printf("PCI: Test failed at %d MHz\n", (cur + 500000) / 1000000);
11983 + for (req = 104000000; req < 176000000; req += 4000000) {
11984 + printf("PCI: Resetting to %d MHz\n", (req + 500000) / 1000000);
11985 + /* This will only reset if the clocks are valid and have changed */
11986 + sb_mips_setclock(sbh, req, 0, 0);
11987 + }
11988 + /* Should not reach here */
11989 + ASSERT(0);
11990 + }
11991 +
11992 + sb_setcoreidx(sbh, coreidx);
11993 +}
11994 diff -Nur linux-2.4.30/arch/mips/bcm947xx/setup.c linux-2.4.30-brcm/arch/mips/bcm947xx/setup.c
11995 --- linux-2.4.30/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100
11996 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/setup.c 2005-05-25 17:50:08.000000000 +0200
11997 @@ -0,0 +1,261 @@
11998 +/*
11999 + * Generic setup routines for Broadcom MIPS boards
12000 + *
12001 + * Copyright 2004, Broadcom Corporation
12002 + * All Rights Reserved.
12003 + *
12004 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
12005 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
12006 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
12007 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
12008 + *
12009 + * $Id: setup.c,v 1.2 2005/04/02 12:12:57 wbx Exp $
12010 + */
12011 +
12012 +#include <linux/config.h>
12013 +#include <linux/init.h>
12014 +#include <linux/kernel.h>
12015 +#include <linux/serialP.h>
12016 +#include <linux/ide.h>
12017 +#include <asm/bootinfo.h>
12018 +#include <asm/time.h>
12019 +#include <asm/reboot.h>
12020 +
12021 +#ifdef CONFIG_MTD_PARTITIONS
12022 +#include <linux/mtd/mtd.h>
12023 +#include <linux/mtd/partitions.h>
12024 +#endif
12025 +
12026 +#include <typedefs.h>
12027 +#include <bcmutils.h>
12028 +#include <bcmnvram.h>
12029 +#include <sbmips.h>
12030 +#include <sbutils.h>
12031 +#include <trxhdr.h>
12032 +
12033 +extern void bcm947xx_time_init(void);
12034 +extern void bcm947xx_timer_setup(struct irqaction *irq);
12035 +extern void check_enable_mips_pfc(int val);
12036 +
12037 +#ifdef CONFIG_REMOTE_DEBUG
12038 +extern void set_debug_traps(void);
12039 +extern void rs_kgdb_hook(struct serial_state *);
12040 +extern void breakpoint(void);
12041 +#endif
12042 +
12043 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
12044 +extern struct ide_ops std_ide_ops;
12045 +#endif
12046 +
12047 +/* Global SB handle */
12048 +void *bcm947xx_sbh = NULL;
12049 +spinlock_t bcm947xx_sbh_lock = SPIN_LOCK_UNLOCKED;
12050 +EXPORT_SYMBOL(bcm947xx_sbh);
12051 +EXPORT_SYMBOL(bcm947xx_sbh_lock);
12052 +
12053 +/* Convenience */
12054 +#define sbh bcm947xx_sbh
12055 +#define sbh_lock bcm947xx_sbh_lock
12056 +
12057 +/* Kernel command line */
12058 +char arcs_cmdline[CL_SIZE] __initdata = CONFIG_CMDLINE;
12059 +
12060 +void
12061 +bcm947xx_machine_restart(char *command)
12062 +{
12063 + printk("Please stand by while rebooting the system...\n");
12064 +
12065 + /* Set the watchdog timer to reset immediately */
12066 + __cli();
12067 + sb_watchdog(sbh, 1);
12068 + while (1);
12069 +}
12070 +
12071 +void
12072 +bcm947xx_machine_halt(void)
12073 +{
12074 + printk("System halted\n");
12075 +
12076 + /* Disable interrupts and watchdog and spin forever */
12077 + __cli();
12078 + sb_watchdog(sbh, 0);
12079 + while (1);
12080 +}
12081 +
12082 +#ifdef CONFIG_SERIAL
12083 +
12084 +static struct serial_struct rs = {
12085 + line: 0,
12086 + flags: ASYNC_BOOT_AUTOCONF,
12087 + io_type: SERIAL_IO_MEM,
12088 +};
12089 +
12090 +static void __init
12091 +serial_add(void *regs, uint irq, uint baud_base, uint reg_shift)
12092 +{
12093 + rs.iomem_base = regs;
12094 + rs.irq = irq + 2;
12095 + rs.baud_base = baud_base / 16;
12096 + rs.iomem_reg_shift = reg_shift;
12097 +
12098 + early_serial_setup(&rs);
12099 +
12100 + rs.line++;
12101 +}
12102 +
12103 +static void __init
12104 +serial_setup(void *sbh)
12105 +{
12106 + sb_serial_init(sbh, serial_add);
12107 +
12108 +#ifdef CONFIG_REMOTE_DEBUG
12109 + /* Use the last port for kernel debugging */
12110 + if (rs.iomem_base)
12111 + rs_kgdb_hook(&rs);
12112 +#endif
12113 +}
12114 +
12115 +#endif /* CONFIG_SERIAL */
12116 +
12117 +void __init
12118 +brcm_setup(void)
12119 +{
12120 + char *value;
12121 + uint pfc_val;
12122 +
12123 + /* Get global SB handle */
12124 + sbh = sb_kattach();
12125 +
12126 + /* Initialize clocks and interrupts */
12127 + sb_mips_init(sbh);
12128 +
12129 + /*
12130 + * Now that the sbh is inited set the proper PFC value
12131 + */
12132 + pfc_val = sb_mips_get_pfc(sbh);
12133 + printk("Setting the PFC value as 0x%x\n", pfc_val);
12134 + check_enable_mips_pfc(pfc_val);
12135 +
12136 +#ifdef CONFIG_SERIAL
12137 + /* Initialize UARTs */
12138 + serial_setup(sbh);
12139 +#endif
12140 +
12141 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
12142 + ide_ops = &std_ide_ops;
12143 +#endif
12144 +
12145 + /* Override default command line arguments */
12146 + value = nvram_get("kernel_args");
12147 + if (value && strlen(value) && strncmp(value, "empty", 5))
12148 + strncpy(arcs_cmdline, value, sizeof(arcs_cmdline));
12149 +
12150 +
12151 + /* Generic setup */
12152 + _machine_restart = bcm947xx_machine_restart;
12153 + _machine_halt = bcm947xx_machine_halt;
12154 + _machine_power_off = bcm947xx_machine_halt;
12155 +
12156 + board_time_init = bcm947xx_time_init;
12157 + board_timer_setup = bcm947xx_timer_setup;
12158 +}
12159 +
12160 +const char *
12161 +get_system_type(void)
12162 +{
12163 + return "Broadcom BCM947XX";
12164 +}
12165 +
12166 +void __init
12167 +bus_error_init(void)
12168 +{
12169 +}
12170 +
12171 +#ifdef CONFIG_MTD_PARTITIONS
12172 +
12173 +static struct mtd_partition bcm947xx_parts[] = {
12174 + { name: "pmon", offset: 0, size: 0, mask_flags: MTD_WRITEABLE, },
12175 + { name: "linux", offset: 0, size: 0, },
12176 + { name: "rootfs", offset: 0, size: 0, },
12177 + { name: "nvram", offset: 0, size: 0, },
12178 + { name: "OpenWrt", offset: 0, size: 0, },
12179 + { name: NULL, },
12180 +};
12181 +
12182 +static int __init
12183 +find_root(struct mtd_info *mtd, size_t size, struct mtd_partition *part)
12184 +{
12185 + struct trx_header *trx;
12186 + unsigned char buf[512];
12187 + int off;
12188 + size_t len;
12189 +
12190 + trx = (struct trx_header *) buf;
12191 +
12192 + for (off = (256*1024); off < size; off += mtd->erasesize) {
12193 + memset(buf, 0xe5, sizeof(buf));
12194 +
12195 + /*
12196 + * Read into buffer
12197 + */
12198 + if (MTD_READ(mtd, off, sizeof(buf), &len, buf) ||
12199 + len != sizeof(buf))
12200 + continue;
12201 +
12202 + /* found a TRX header */
12203 + if (le32_to_cpu(trx->magic) == TRX_MAGIC) {
12204 + part->offset = le32_to_cpu(trx->offsets[2]) ? :
12205 + le32_to_cpu(trx->offsets[1]);
12206 + part->size = le32_to_cpu(trx->len);
12207 +
12208 + part->size -= part->offset;
12209 + part->offset += off;
12210 +
12211 + goto done;
12212 + }
12213 + }
12214 +
12215 + printk(KERN_NOTICE
12216 + "%s: Couldn't find root filesystem\n",
12217 + mtd->name);
12218 + return -1;
12219 +
12220 + done:
12221 + return part->size;
12222 +}
12223 +
12224 +struct mtd_partition * __init
12225 +init_mtd_partitions(struct mtd_info *mtd, size_t size)
12226 +{
12227 +
12228 + /* boot loader */
12229 + bcm947xx_parts[0].offset=0;
12230 + bcm947xx_parts[0].size=256*1024;
12231 +
12232 + /* nvram */
12233 + bcm947xx_parts[3].offset = size - ROUNDUP(NVRAM_SPACE, mtd->erasesize);
12234 + bcm947xx_parts[3].size = size - bcm947xx_parts[3].offset;
12235 +
12236 + /* Size linux (kernel and rootfs) */
12237 + bcm947xx_parts[1].offset = bcm947xx_parts[0].size;
12238 + bcm947xx_parts[1].size = bcm947xx_parts[3].offset - bcm947xx_parts[1].offset;
12239 +
12240 + /* Find and size rootfs */
12241 + if (find_root(mtd,size,&bcm947xx_parts[2])==0) {
12242 + /* entirely jffs2 */
12243 + bcm947xx_parts[2].size = bcm947xx_parts[3].offset - bcm947xx_parts[2].offset;
12244 + bcm947xx_parts[4].name = NULL;
12245 + } else {
12246 + /* legacy setup */
12247 + /* calculate leftover flash, and assign it to the jffs2 partition */
12248 + bcm947xx_parts[4].offset = bcm947xx_parts[2].offset + bcm947xx_parts[2].size;
12249 + bcm947xx_parts[4].offset = ROUNDUP(bcm947xx_parts[4].offset, mtd->erasesize);
12250 + bcm947xx_parts[4].size = bcm947xx_parts[3].offset - bcm947xx_parts[4].offset;
12251 + }
12252 +
12253 + return bcm947xx_parts;
12254 +}
12255 +
12256 +EXPORT_SYMBOL(init_mtd_partitions);
12257 +
12258 +#endif
12259 diff -Nur linux-2.4.30/arch/mips/bcm947xx/time.c linux-2.4.30-brcm/arch/mips/bcm947xx/time.c
12260 --- linux-2.4.30/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +0100
12261 +++ linux-2.4.30-brcm/arch/mips/bcm947xx/time.c 2005-05-22 22:55:51.000000000 +0200
12262 @@ -0,0 +1,117 @@
12263 +/*
12264 + * Copyright 2004, Broadcom Corporation
12265 + * All Rights Reserved.
12266 + *
12267 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
12268 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
12269 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
12270 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
12271 + *
12272 + * $Id: time.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
12273 + */
12274 +#include <linux/config.h>
12275 +#include <linux/init.h>
12276 +#include <linux/kernel.h>
12277 +#include <linux/sched.h>
12278 +#include <linux/serial_reg.h>
12279 +#include <linux/interrupt.h>
12280 +#include <asm/addrspace.h>
12281 +#include <asm/io.h>
12282 +#include <asm/time.h>
12283 +
12284 +#include <typedefs.h>
12285 +#include <bcmnvram.h>
12286 +#include <sbconfig.h>
12287 +#include <sbextif.h>
12288 +#include <sbutils.h>
12289 +#include <sbmips.h>
12290 +
12291 +/* Global SB handle */
12292 +extern void *bcm947xx_sbh;
12293 +extern spinlock_t bcm947xx_sbh_lock;
12294 +
12295 +/* Convenience */
12296 +#define sbh bcm947xx_sbh
12297 +#define sbh_lock bcm947xx_sbh_lock
12298 +
12299 +extern int panic_timeout;
12300 +static int watchdog = 0;
12301 +static u8 *mcr = NULL;
12302 +
12303 +void __init
12304 +bcm947xx_time_init(void)
12305 +{
12306 + unsigned int hz;
12307 + extifregs_t *eir;
12308 +
12309 + /*
12310 + * Use deterministic values for initial counter interrupt
12311 + * so that calibrate delay avoids encountering a counter wrap.
12312 + */
12313 + write_c0_count(0);
12314 + write_c0_compare(0xffff);
12315 +
12316 + if (!(hz = sb_mips_clock(sbh)))
12317 + hz = 100000000;
12318 +
12319 + printk("CPU: BCM%04x rev %d at %d MHz\n", sb_chip(sbh), sb_chiprev(sbh),
12320 + (hz + 500000) / 1000000);
12321 +
12322 + /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
12323 + mips_hpt_frequency = hz / 2;
12324 +
12325 + /* Set watchdog interval in ms */
12326 + watchdog = simple_strtoul(nvram_safe_get("watchdog"), NULL, 0);
12327 +
12328 + /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */
12329 + if (watchdog > 0) {
12330 + if (watchdog < 3000)
12331 + watchdog = 3000;
12332 + }
12333 +
12334 +
12335 + /* Set panic timeout in seconds */
12336 + panic_timeout = watchdog / 1000;
12337 +
12338 + /* Setup blink */
12339 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
12340 + sbconfig_t *sb = (sbconfig_t *)((unsigned int) eir + SBCONFIGOFF);
12341 + unsigned long base = EXTIF_CFGIF_BASE(sb_base(readl(&sb->sbadmatch1)));
12342 + mcr = (u8 *) ioremap_nocache(base + UART_MCR, 1);
12343 + }
12344 +}
12345 +
12346 +static void
12347 +bcm947xx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
12348 +{
12349 + /* Generic MIPS timer code */
12350 + timer_interrupt(irq, dev_id, regs);
12351 +
12352 + /* Set the watchdog timer to reset after the specified number of ms */
12353 + if (watchdog > 0)
12354 + sb_watchdog(sbh, WATCHDOG_CLOCK / 1000 * watchdog);
12355 +
12356 +#ifdef CONFIG_HWSIM
12357 + (*((int *)0xa0000f1c))++;
12358 +#else
12359 + /* Blink one of the LEDs in the external UART */
12360 + if (mcr && !(jiffies % (HZ/2)))
12361 + writeb(readb(mcr) ^ UART_MCR_OUT2, mcr);
12362 +#endif
12363 +}
12364 +
12365 +static struct irqaction bcm947xx_timer_irqaction = {
12366 + bcm947xx_timer_interrupt,
12367 + SA_INTERRUPT,
12368 + 0,
12369 + "timer",
12370 + NULL,
12371 + NULL
12372 +};
12373 +
12374 +void __init
12375 +bcm947xx_timer_setup(struct irqaction *irq)
12376 +{
12377 + /* Enable the timer interrupt */
12378 + setup_irq(7, &bcm947xx_timer_irqaction);
12379 +}
12380 diff -Nur linux-2.4.30/arch/mips/config-shared.in linux-2.4.30-brcm/arch/mips/config-shared.in
12381 --- linux-2.4.30/arch/mips/config-shared.in 2005-01-19 15:09:27.000000000 +0100
12382 +++ linux-2.4.30-brcm/arch/mips/config-shared.in 2005-05-26 16:34:10.000000000 +0200
12383 @@ -205,6 +205,14 @@
12384 fi
12385 define_bool CONFIG_MIPS_RTC y
12386 fi
12387 +dep_bool 'Support for Broadcom MIPS-based boards' CONFIG_MIPS_BRCM $CONFIG_EXPERIMENTAL
12388 +dep_bool 'Support for Broadcom BCM947XX' CONFIG_BCM947XX $CONFIG_MIPS_BRCM
12389 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
12390 + bool ' Support for Broadcom BCM4710' CONFIG_BCM4710
12391 + bool ' Support for Broadcom BCM4310' CONFIG_BCM4310
12392 + bool ' Support for Broadcom BCM4704' CONFIG_BCM4704
12393 + bool ' Support for Broadcom BCM5365' CONFIG_BCM5365
12394 +fi
12395 bool 'Support for SNI RM200 PCI' CONFIG_SNI_RM200_PCI
12396 bool 'Support for TANBAC TB0226 (Mbase)' CONFIG_TANBAC_TB0226
12397 bool 'Support for TANBAC TB0229 (VR4131DIMM)' CONFIG_TANBAC_TB0229
12398 @@ -226,6 +234,11 @@
12399 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
12400
12401 #
12402 +# Provide an option for a default kernel command line
12403 +#
12404 +string 'Default kernel command string' CONFIG_CMDLINE ""
12405 +
12406 +#
12407 # Select some configuration options automatically based on user selections.
12408 #
12409 if [ "$CONFIG_ACER_PICA_61" = "y" ]; then
12410 @@ -533,6 +546,13 @@
12411 define_bool CONFIG_SWAP_IO_SPACE_L y
12412 define_bool CONFIG_BOOT_ELF32 y
12413 fi
12414 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
12415 + define_bool CONFIG_PCI y
12416 + define_bool CONFIG_NONCOHERENT_IO y
12417 + define_bool CONFIG_NEW_TIME_C y
12418 + define_bool CONFIG_NEW_IRQ y
12419 + define_bool CONFIG_HND y
12420 +fi
12421 if [ "$CONFIG_SNI_RM200_PCI" = "y" ]; then
12422 define_bool CONFIG_ARC32 y
12423 define_bool CONFIG_ARC_MEMORY y
12424 @@ -1011,7 +1031,11 @@
12425
12426 bool 'Are you using a crosscompiler' CONFIG_CROSSCOMPILE
12427 bool 'Enable run-time debugging' CONFIG_RUNTIME_DEBUG
12428 -bool 'Remote GDB kernel debugging' CONFIG_KGDB
12429 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
12430 + bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG
12431 +else
12432 + bool 'Remote GDB kernel debugging' CONFIG_KGDB
12433 +fi
12434 dep_bool ' Console output to GDB' CONFIG_GDB_CONSOLE $CONFIG_KGDB
12435 if [ "$CONFIG_KGDB" = "y" ]; then
12436 define_bool CONFIG_DEBUG_INFO y
12437 diff -Nur linux-2.4.30/arch/mips/kernel/cpu-probe.c linux-2.4.30-brcm/arch/mips/kernel/cpu-probe.c
12438 --- linux-2.4.30/arch/mips/kernel/cpu-probe.c 2005-01-19 15:09:29.000000000 +0100
12439 +++ linux-2.4.30-brcm/arch/mips/kernel/cpu-probe.c 2005-05-22 22:55:51.000000000 +0200
12440 @@ -174,7 +174,7 @@
12441
12442 static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
12443 {
12444 - switch (c->processor_id & 0xff00) {
12445 + switch (c->processor_id & PRID_IMP_MASK) {
12446 case PRID_IMP_R2000:
12447 c->cputype = CPU_R2000;
12448 c->isa_level = MIPS_CPU_ISA_I;
12449 @@ -184,7 +184,7 @@
12450 c->tlbsize = 64;
12451 break;
12452 case PRID_IMP_R3000:
12453 - if ((c->processor_id & 0xff) == PRID_REV_R3000A)
12454 + if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A)
12455 if (cpu_has_confreg())
12456 c->cputype = CPU_R3081E;
12457 else
12458 @@ -199,12 +199,12 @@
12459 break;
12460 case PRID_IMP_R4000:
12461 if (read_c0_config() & CONF_SC) {
12462 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
12463 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
12464 c->cputype = CPU_R4400PC;
12465 else
12466 c->cputype = CPU_R4000PC;
12467 } else {
12468 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
12469 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
12470 c->cputype = CPU_R4400SC;
12471 else
12472 c->cputype = CPU_R4000SC;
12473 @@ -450,7 +450,7 @@
12474 static inline void cpu_probe_mips(struct cpuinfo_mips *c)
12475 {
12476 decode_config1(c);
12477 - switch (c->processor_id & 0xff00) {
12478 + switch (c->processor_id & PRID_IMP_MASK) {
12479 case PRID_IMP_4KC:
12480 c->cputype = CPU_4KC;
12481 c->isa_level = MIPS_CPU_ISA_M32;
12482 @@ -491,10 +491,10 @@
12483 {
12484 decode_config1(c);
12485 c->options |= MIPS_CPU_PREFETCH;
12486 - switch (c->processor_id & 0xff00) {
12487 + switch (c->processor_id & PRID_IMP_MASK) {
12488 case PRID_IMP_AU1_REV1:
12489 case PRID_IMP_AU1_REV2:
12490 - switch ((c->processor_id >> 24) & 0xff) {
12491 + switch ((c->processor_id >> 24) & PRID_REV_MASK) {
12492 case 0:
12493 c->cputype = CPU_AU1000;
12494 break;
12495 @@ -522,10 +522,34 @@
12496 }
12497 }
12498
12499 +static inline void cpu_probe_broadcom(struct cpuinfo_mips *c)
12500 +{
12501 + decode_config1(c);
12502 + c->options |= MIPS_CPU_PREFETCH;
12503 + switch (c->processor_id & PRID_IMP_MASK) {
12504 + case PRID_IMP_BCM4710:
12505 + c->cputype = CPU_BCM4710;
12506 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
12507 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
12508 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
12509 + break;
12510 + case PRID_IMP_4KC:
12511 + case PRID_IMP_BCM3302:
12512 + c->cputype = CPU_BCM3302;
12513 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
12514 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
12515 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
12516 + break;
12517 + default:
12518 + c->cputype = CPU_UNKNOWN;
12519 + break;
12520 + }
12521 +}
12522 +
12523 static inline void cpu_probe_sibyte(struct cpuinfo_mips *c)
12524 {
12525 decode_config1(c);
12526 - switch (c->processor_id & 0xff00) {
12527 + switch (c->processor_id & PRID_IMP_MASK) {
12528 case PRID_IMP_SB1:
12529 c->cputype = CPU_SB1;
12530 c->isa_level = MIPS_CPU_ISA_M64;
12531 @@ -547,7 +571,7 @@
12532 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c)
12533 {
12534 decode_config1(c);
12535 - switch (c->processor_id & 0xff00) {
12536 + switch (c->processor_id & PRID_IMP_MASK) {
12537 case PRID_IMP_SR71000:
12538 c->cputype = CPU_SR71000;
12539 c->isa_level = MIPS_CPU_ISA_M64;
12540 @@ -572,7 +596,7 @@
12541 c->cputype = CPU_UNKNOWN;
12542
12543 c->processor_id = read_c0_prid();
12544 - switch (c->processor_id & 0xff0000) {
12545 + switch (c->processor_id & PRID_COMP_MASK) {
12546
12547 case PRID_COMP_LEGACY:
12548 cpu_probe_legacy(c);
12549 @@ -583,6 +607,9 @@
12550 case PRID_COMP_ALCHEMY:
12551 cpu_probe_alchemy(c);
12552 break;
12553 + case PRID_COMP_BROADCOM:
12554 + cpu_probe_broadcom(c);
12555 + break;
12556 case PRID_COMP_SIBYTE:
12557 cpu_probe_sibyte(c);
12558 break;
12559 diff -Nur linux-2.4.30/arch/mips/kernel/head.S linux-2.4.30-brcm/arch/mips/kernel/head.S
12560 --- linux-2.4.30/arch/mips/kernel/head.S 2005-01-19 15:09:29.000000000 +0100
12561 +++ linux-2.4.30-brcm/arch/mips/kernel/head.S 2005-05-22 22:55:51.000000000 +0200
12562 @@ -28,12 +28,20 @@
12563 #include <asm/mipsregs.h>
12564 #include <asm/stackframe.h>
12565
12566 +#ifdef CONFIG_BCM4710
12567 +#undef eret
12568 +#define eret nop; nop; eret
12569 +#endif
12570 +
12571 .text
12572 + j kernel_entry
12573 + nop
12574 +
12575 /*
12576 * Reserved space for exception handlers.
12577 * Necessary for machines which link their kernels at KSEG0.
12578 */
12579 - .fill 0x400
12580 + .fill 0x3f4
12581
12582 /* The following two symbols are used for kernel profiling. */
12583 EXPORT(stext)
12584 diff -Nur linux-2.4.30/arch/mips/kernel/proc.c linux-2.4.30-brcm/arch/mips/kernel/proc.c
12585 --- linux-2.4.30/arch/mips/kernel/proc.c 2005-01-19 15:09:29.000000000 +0100
12586 +++ linux-2.4.30-brcm/arch/mips/kernel/proc.c 2005-05-22 22:55:51.000000000 +0200
12587 @@ -78,9 +78,10 @@
12588 [CPU_AU1550] "Au1550",
12589 [CPU_24K] "MIPS 24K",
12590 [CPU_AU1200] "Au1200",
12591 + [CPU_BCM4710] "BCM4710",
12592 + [CPU_BCM3302] "BCM3302",
12593 };
12594
12595 -
12596 static int show_cpuinfo(struct seq_file *m, void *v)
12597 {
12598 unsigned int version = current_cpu_data.processor_id;
12599 diff -Nur linux-2.4.30/arch/mips/kernel/setup.c linux-2.4.30-brcm/arch/mips/kernel/setup.c
12600 --- linux-2.4.30/arch/mips/kernel/setup.c 2005-01-19 15:09:29.000000000 +0100
12601 +++ linux-2.4.30-brcm/arch/mips/kernel/setup.c 2005-05-25 19:00:43.000000000 +0200
12602 @@ -495,6 +495,7 @@
12603 void swarm_setup(void);
12604 void hp_setup(void);
12605 void au1x00_setup(void);
12606 + void brcm_setup(void);
12607 void frame_info_init(void);
12608
12609 frame_info_init();
12610 @@ -693,6 +694,11 @@
12611 pmc_yosemite_setup();
12612 break;
12613 #endif
12614 +#if defined(CONFIG_BCM4710) || defined(CONFIG_BCM4310)
12615 + case MACH_GROUP_BRCM:
12616 + brcm_setup();
12617 + break;
12618 +#endif
12619 default:
12620 panic("Unsupported architecture");
12621 }
12622 diff -Nur linux-2.4.30/arch/mips/kernel/traps.c linux-2.4.30-brcm/arch/mips/kernel/traps.c
12623 --- linux-2.4.30/arch/mips/kernel/traps.c 2005-01-19 15:09:29.000000000 +0100
12624 +++ linux-2.4.30-brcm/arch/mips/kernel/traps.c 2005-05-22 22:55:51.000000000 +0200
12625 @@ -913,6 +913,7 @@
12626 void __init trap_init(void)
12627 {
12628 extern char except_vec1_generic;
12629 + extern char except_vec2_generic;
12630 extern char except_vec3_generic, except_vec3_r4000;
12631 extern char except_vec_ejtag_debug;
12632 extern char except_vec4;
12633 @@ -922,6 +923,7 @@
12634
12635 /* Copy the generic exception handler code to it's final destination. */
12636 memcpy((void *)(KSEG0 + 0x80), &except_vec1_generic, 0x80);
12637 + memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80);
12638
12639 /*
12640 * Setup default vectors
12641 @@ -980,6 +982,12 @@
12642 set_except_vector(13, handle_tr);
12643 set_except_vector(22, handle_mdmx);
12644
12645 + if (current_cpu_data.cputype == CPU_SB1) {
12646 + /* Enable timer interrupt and scd mapped interrupt */
12647 + clear_c0_status(0xf000);
12648 + set_c0_status(0xc00);
12649 + }
12650 +
12651 if (cpu_has_fpu && !cpu_has_nofpuex)
12652 set_except_vector(15, handle_fpe);
12653
12654 diff -Nur linux-2.4.30/arch/mips/Makefile linux-2.4.30-brcm/arch/mips/Makefile
12655 --- linux-2.4.30/arch/mips/Makefile 2005-01-19 15:09:26.000000000 +0100
12656 +++ linux-2.4.30-brcm/arch/mips/Makefile 2005-05-25 18:53:09.000000000 +0200
12657 @@ -46,10 +46,10 @@
12658 GCCFLAGS := -I $(TOPDIR)/include/asm/gcc
12659 GCCFLAGS += -G 0 -mno-abicalls -fno-pic -pipe
12660 GCCFLAGS += $(call check_gcc, -finline-limit=100000,)
12661 -LINKFLAGS += -G 0 -static -n
12662 -MODFLAGS += -mlong-calls
12663 +LINKFLAGS += -G 0 -static -n -nostdlib
12664 +MODFLAGS += -mlong-calls -fno-common
12665
12666 -ifdef CONFIG_DEBUG_INFO
12667 +ifdef CONFIG_REMOTE_DEBUG
12668 GCCFLAGS += -g
12669 ifdef CONFIG_SB1XXX_CORELIS
12670 GCCFLAGS += -mno-sched-prolog -fno-omit-frame-pointer
12671 @@ -71,13 +71,13 @@
12672 set_gccflags = $(shell \
12673 while :; do \
12674 cpu=$(1); isa=-$(2); \
12675 - for gcc_opt in -march= -mcpu=; do \
12676 + for gcc_opt in -march= -mtune=; do \
12677 $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \
12678 -xc /dev/null > /dev/null 2>&1 && \
12679 break 2; \
12680 done; \
12681 cpu=$(3); isa=-$(4); \
12682 - for gcc_opt in -march= -mcpu=; do \
12683 + for gcc_opt in -march= -mtune=; do \
12684 $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \
12685 -xc /dev/null > /dev/null 2>&1 && \
12686 break 2; \
12687 @@ -92,7 +92,7 @@
12688 fi; \
12689 gas_abi=-Wa,-32; gas_cpu=$$cpu; gas_isa=-Wa,$$isa; \
12690 while :; do \
12691 - for gas_opt in -Wa,-march= -Wa,-mcpu=; do \
12692 + for gas_opt in -Wa,-march= -Wa,-mtune=; do \
12693 $(CC) $$gas_abi $$gas_opt$$cpu $$gas_isa -Wa,-Z -c \
12694 -o /dev/null -xassembler /dev/null > /dev/null 2>&1 && \
12695 break 2; \
12696 @@ -174,6 +174,7 @@
12697 endif
12698
12699 AFLAGS += $(GCCFLAGS)
12700 +ASFLAGS += $(GCCFLAGS)
12701 CFLAGS += $(GCCFLAGS)
12702
12703 LD += -m $(ld-emul)
12704 @@ -715,6 +716,19 @@
12705 endif
12706
12707 #
12708 +# Broadcom BCM947XX variants
12709 +#
12710 +ifdef CONFIG_BCM947XX
12711 +LIBS += arch/mips/bcm947xx/generic/brcm.o arch/mips/bcm947xx/bcm947xx.o
12712 +SUBDIRS += arch/mips/bcm947xx/generic arch/mips/bcm947xx
12713 +LOADADDR := 0x80001000
12714 +
12715 +zImage: vmlinux
12716 + $(MAKE) -C arch/$(ARCH)/bcm947xx/compressed
12717 +export LOADADDR
12718 +endif
12719 +
12720 +#
12721 # Choosing incompatible machines durings configuration will result in
12722 # error messages during linking. Select a default linkscript if
12723 # none has been choosen above.
12724 @@ -767,6 +781,7 @@
12725 $(MAKE) -C arch/$(ARCH)/tools clean
12726 $(MAKE) -C arch/mips/baget clean
12727 $(MAKE) -C arch/mips/lasat clean
12728 + $(MAKE) -C arch/mips/bcm947xx/compressed clean
12729
12730 archmrproper:
12731 @$(MAKEBOOT) mrproper
12732 diff -Nur linux-2.4.30/arch/mips/mm/c-r4k.c linux-2.4.30-brcm/arch/mips/mm/c-r4k.c
12733 --- linux-2.4.30/arch/mips/mm/c-r4k.c 2005-01-19 15:09:29.000000000 +0100
12734 +++ linux-2.4.30-brcm/arch/mips/mm/c-r4k.c 2005-05-26 08:53:48.000000000 +0200
12735 @@ -1114,3 +1114,47 @@
12736 build_clear_page();
12737 build_copy_page();
12738 }
12739 +
12740 +#ifdef CONFIG_BCM4704
12741 +static void __init mips32_icache_fill(unsigned long addr, uint nbytes)
12742 +{
12743 + unsigned long ic_lsize = current_cpu_data.icache.linesz;
12744 + int i;
12745 + for (i = 0; i < nbytes; i += ic_lsize)
12746 + fill_icache_line((addr + i));
12747 +}
12748 +
12749 +/*
12750 + * This must be run from the cache on 4704A0
12751 + * so there are no mips core BIU ops in progress
12752 + * when the PFC is enabled.
12753 + */
12754 +#define PFC_CR0 0xff400000 /* control reg 0 */
12755 +#define PFC_CR1 0xff400004 /* control reg 1 */
12756 +static void __init enable_pfc(u32 mode)
12757 +{
12758 + /* write range */
12759 + *(volatile u32 *)PFC_CR1 = 0xffff0000;
12760 +
12761 + /* enable */
12762 + *(volatile u32 *)PFC_CR0 = mode;
12763 +}
12764 +#endif
12765 +
12766 +
12767 +void check_enable_mips_pfc(int val)
12768 +{
12769 +
12770 +#ifdef CONFIG_BCM4704
12771 + struct cpuinfo_mips *c = &current_cpu_data;
12772 +
12773 + /* enable prefetch cache */
12774 + if (((c->processor_id & (PRID_COMP_MASK | PRID_IMP_MASK)) == PRID_IMP_BCM3302)
12775 + && (read_c0_diag() & (1 << 29))) {
12776 + mips32_icache_fill((unsigned long) &enable_pfc, 64);
12777 + enable_pfc(val);
12778 + }
12779 +#endif
12780 +}
12781 +
12782 +
12783 diff -Nur linux-2.4.30/arch/mips/pci/Makefile linux-2.4.30-brcm/arch/mips/pci/Makefile
12784 --- linux-2.4.30/arch/mips/pci/Makefile 2005-01-19 15:09:29.000000000 +0100
12785 +++ linux-2.4.30-brcm/arch/mips/pci/Makefile 2005-05-26 01:02:53.000000000 +0200
12786 @@ -13,7 +13,9 @@
12787 obj-$(CONFIG_MIPS_MSC) += ops-msc.o
12788 obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o
12789 obj-$(CONFIG_SNI_RM200_PCI) += ops-sni.o
12790 +ifndef CONFIG_BCM947XX
12791 obj-y += pci.o
12792 +endif
12793 obj-$(CONFIG_PCI_AUTO) += pci_auto.o
12794
12795 include $(TOPDIR)/Rules.make
12796 diff -Nur linux-2.4.30/drivers/char/serial.c linux-2.4.30-brcm/drivers/char/serial.c
12797 --- linux-2.4.30/drivers/char/serial.c 2005-01-19 15:09:50.000000000 +0100
12798 +++ linux-2.4.30-brcm/drivers/char/serial.c 2005-05-22 22:55:52.000000000 +0200
12799 @@ -422,6 +422,10 @@
12800 return inb(info->port+1);
12801 #endif
12802 case SERIAL_IO_MEM:
12803 +#ifdef CONFIG_BCM4310
12804 + readb((unsigned long) info->iomem_base +
12805 + (UART_SCR<<info->iomem_reg_shift));
12806 +#endif
12807 return readb((unsigned long) info->iomem_base +
12808 (offset<<info->iomem_reg_shift));
12809 default:
12810 @@ -442,6 +446,9 @@
12811 case SERIAL_IO_MEM:
12812 writeb(value, (unsigned long) info->iomem_base +
12813 (offset<<info->iomem_reg_shift));
12814 +#ifdef CONFIG_BCM4704
12815 + *((volatile unsigned int *) KSEG1ADDR(0x18000000));
12816 +#endif
12817 break;
12818 default:
12819 outb(value, info->port+offset);
12820 @@ -5972,6 +5979,13 @@
12821 * Divisor, bytesize and parity
12822 */
12823 state = rs_table + co->index;
12824 + /*
12825 + * Safe guard: state structure must have been initialized
12826 + */
12827 + if (state->iomem_base == NULL) {
12828 + printk("!unable to setup serial console!\n");
12829 + return -1;
12830 + }
12831 if (doflow)
12832 state->flags |= ASYNC_CONS_FLOW;
12833 info = &async_sercons;
12834 diff -Nur linux-2.4.30/drivers/mtd/chips/cfi_cmdset_0701.c linux-2.4.30-brcm/drivers/mtd/chips/cfi_cmdset_0701.c
12835 --- linux-2.4.30/drivers/mtd/chips/cfi_cmdset_0701.c 1970-01-01 01:00:00.000000000 +0100
12836 +++ linux-2.4.30-brcm/drivers/mtd/chips/cfi_cmdset_0701.c 2005-05-22 22:55:52.000000000 +0200
12837 @@ -0,0 +1,855 @@
12838 +/*
12839 + * Common Flash Interface support:
12840 + * SST Standard Vendor Command Set (ID 0x0701)
12841 + *
12842 + * Copyright (C) 2000 Crossnet Co. <info@crossnet.co.jp>
12843 + *
12844 + * 2_by_8 routines added by Simon Munton
12845 + *
12846 + * This code is GPL
12847 + *
12848 + * $Id: cfi_cmdset_0701.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
12849 + *
12850 + */
12851 +
12852 +#include <linux/module.h>
12853 +#include <linux/types.h>
12854 +#include <linux/kernel.h>
12855 +#include <linux/sched.h>
12856 +#include <asm/io.h>
12857 +#include <asm/byteorder.h>
12858 +
12859 +#include <linux/errno.h>
12860 +#include <linux/slab.h>
12861 +#include <linux/delay.h>
12862 +#include <linux/interrupt.h>
12863 +#include <linux/mtd/map.h>
12864 +#include <linux/mtd/cfi.h>
12865 +
12866 +static int cfi_sststd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
12867 +static int cfi_sststd_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
12868 +static int cfi_sststd_erase_onesize(struct mtd_info *, struct erase_info *);
12869 +static int cfi_sststd_erase_varsize(struct mtd_info *, struct erase_info *);
12870 +static void cfi_sststd_sync (struct mtd_info *);
12871 +static int cfi_sststd_suspend (struct mtd_info *);
12872 +static void cfi_sststd_resume (struct mtd_info *);
12873 +
12874 +static void cfi_sststd_destroy(struct mtd_info *);
12875 +
12876 +struct mtd_info *cfi_cmdset_0701(struct map_info *, int);
12877 +static struct mtd_info *cfi_sststd_setup (struct map_info *);
12878 +
12879 +
12880 +static struct mtd_chip_driver cfi_sststd_chipdrv = {
12881 + probe: NULL, /* Not usable directly */
12882 + destroy: cfi_sststd_destroy,
12883 + name: "cfi_cmdset_0701",
12884 + module: THIS_MODULE
12885 +};
12886 +
12887 +struct mtd_info *cfi_cmdset_0701(struct map_info *map, int primary)
12888 +{
12889 + struct cfi_private *cfi = map->fldrv_priv;
12890 + int ofs_factor = cfi->interleave * cfi->device_type;
12891 + int i;
12892 + __u8 major, minor;
12893 + __u32 base = cfi->chips[0].start;
12894 +
12895 + if (cfi->cfi_mode==1){
12896 + __u16 adr = primary?cfi->cfiq->P_ADR:cfi->cfiq->A_ADR;
12897 +
12898 + cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
12899 + cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
12900 + cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL);
12901 +
12902 + major = cfi_read_query(map, base + (adr+3)*ofs_factor);
12903 + minor = cfi_read_query(map, base + (adr+4)*ofs_factor);
12904 +
12905 + printk(" SST Query Table v%c.%c at 0x%4.4X\n",
12906 + major, minor, adr);
12907 + cfi_send_gen_cmd(0xf0, 0x5555, base, map, cfi, cfi->device_type, NULL);
12908 +
12909 + cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
12910 + cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
12911 + cfi_send_gen_cmd(0x90, 0x5555, base, map, cfi, cfi->device_type, NULL);
12912 + cfi->mfr = cfi_read_query(map, base);
12913 + cfi->id = cfi_read_query(map, base + ofs_factor);
12914 +
12915 + cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
12916 + cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
12917 + cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL);
12918 +
12919 + switch (cfi->device_type) {
12920 + case CFI_DEVICETYPE_X16:
12921 + cfi->addr_unlock1 = 0x5555;
12922 + cfi->addr_unlock2 = 0x2AAA;
12923 + break;
12924 + default:
12925 + printk(KERN_NOTICE "Eep. Unknown cfi_cmdset_0701 device type %d\n", cfi->device_type);
12926 + return NULL;
12927 + }
12928 + } /* CFI mode */
12929 +
12930 + for (i=0; i< cfi->numchips; i++) {
12931 + cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp;
12932 + cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp;
12933 + cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp;
12934 + }
12935 +
12936 + map->fldrv = &cfi_sststd_chipdrv;
12937 + MOD_INC_USE_COUNT;
12938 +
12939 + cfi_send_gen_cmd(0xf0, 0x5555, base, map, cfi, cfi->device_type, NULL);
12940 + return cfi_sststd_setup(map);
12941 +}
12942 +
12943 +static struct mtd_info *cfi_sststd_setup(struct map_info *map)
12944 +{
12945 + struct cfi_private *cfi = map->fldrv_priv;
12946 + struct mtd_info *mtd;
12947 + unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave;
12948 +
12949 + mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
12950 + printk("number of %s chips: %d\n", (cfi->cfi_mode)?"JEDEC":"CFI",cfi->numchips);
12951 +
12952 + if (!mtd) {
12953 + printk("Failed to allocate memory for MTD device\n");
12954 + kfree(cfi->cmdset_priv);
12955 + return NULL;
12956 + }
12957 +
12958 + memset(mtd, 0, sizeof(*mtd));
12959 + mtd->priv = map;
12960 + mtd->type = MTD_NORFLASH;
12961 + /* Also select the correct geometry setup too */
12962 + mtd->size = devsize * cfi->numchips;
12963 +
12964 + if (cfi->cfiq->NumEraseRegions == 1) {
12965 + /* No need to muck about with multiple erase sizes */
12966 + mtd->erasesize = ((cfi->cfiq->EraseRegionInfo[0] >> 8) & ~0xff) * cfi->interleave;
12967 + } else {
12968 + unsigned long offset = 0;
12969 + int i,j;
12970 +
12971 + mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
12972 + mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) * mtd->numeraseregions, GFP_KERNEL);
12973 + if (!mtd->eraseregions) {
12974 + printk("Failed to allocate memory for MTD erase region info\n");
12975 + kfree(cfi->cmdset_priv);
12976 + return NULL;
12977 + }
12978 +
12979 + for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
12980 + unsigned long ernum, ersize;
12981 + ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
12982 + ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1;
12983 +
12984 + if (mtd->erasesize < ersize) {
12985 + mtd->erasesize = ersize;
12986 + }
12987 + for (j=0; j<cfi->numchips; j++) {
12988 + mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset;
12989 + mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize;
12990 + mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum;
12991 + }
12992 + offset += (ersize * ernum);
12993 + }
12994 +
12995 + // debug
12996 + for (i=0; i<mtd->numeraseregions;i++){
12997 + printk("%d: offset=0x%x,size=0x%x,blocks=%d\n",
12998 + i,mtd->eraseregions[i].offset,
12999 + mtd->eraseregions[i].erasesize,
13000 + mtd->eraseregions[i].numblocks);
13001 + }
13002 + }
13003 +
13004 + switch (CFIDEV_BUSWIDTH)
13005 + {
13006 + case 1:
13007 + case 2:
13008 + case 4:
13009 + if (mtd->numeraseregions > 1)
13010 + mtd->erase = cfi_sststd_erase_varsize;
13011 + else
13012 + mtd->erase = cfi_sststd_erase_onesize;
13013 + mtd->read = cfi_sststd_read;
13014 + mtd->write = cfi_sststd_write;
13015 + break;
13016 +
13017 + default:
13018 + printk("Unsupported buswidth\n");
13019 + kfree(mtd);
13020 + kfree(cfi->cmdset_priv);
13021 + return NULL;
13022 + break;
13023 + }
13024 + mtd->sync = cfi_sststd_sync;
13025 + mtd->suspend = cfi_sststd_suspend;
13026 + mtd->resume = cfi_sststd_resume;
13027 + mtd->flags = MTD_CAP_NORFLASH;
13028 + map->fldrv = &cfi_sststd_chipdrv;
13029 + mtd->name = map->name;
13030 + MOD_INC_USE_COUNT;
13031 + return mtd;
13032 +}
13033 +
13034 +static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf)
13035 +{
13036 + DECLARE_WAITQUEUE(wait, current);
13037 + unsigned long timeo = jiffies + HZ;
13038 +
13039 + retry:
13040 + cfi_spin_lock(chip->mutex);
13041 +
13042 + if (chip->state != FL_READY){
13043 + printk("Waiting for chip to read, status = %d\n", chip->state);
13044 + set_current_state(TASK_UNINTERRUPTIBLE);
13045 + add_wait_queue(&chip->wq, &wait);
13046 +
13047 + cfi_spin_unlock(chip->mutex);
13048 +
13049 + schedule();
13050 + remove_wait_queue(&chip->wq, &wait);
13051 + timeo = jiffies + HZ;
13052 +
13053 + goto retry;
13054 + }
13055 +
13056 + adr += chip->start;
13057 +
13058 + chip->state = FL_READY;
13059 +
13060 + map->copy_from(map, buf, adr, len);
13061 +
13062 + wake_up(&chip->wq);
13063 + cfi_spin_unlock(chip->mutex);
13064 +
13065 + return 0;
13066 +}
13067 +
13068 +static int cfi_sststd_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
13069 +{
13070 + struct map_info *map = mtd->priv;
13071 + struct cfi_private *cfi = map->fldrv_priv;
13072 + unsigned long ofs;
13073 + int chipnum;
13074 + int ret = 0;
13075 +
13076 + /* ofs: offset within the first chip that the first read should start */
13077 +
13078 + chipnum = (from >> cfi->chipshift);
13079 + ofs = from - (chipnum << cfi->chipshift);
13080 +
13081 +
13082 + *retlen = 0;
13083 +
13084 + while (len) {
13085 + unsigned long thislen;
13086 +
13087 + if (chipnum >= cfi->numchips)
13088 + break;
13089 +
13090 + if ((len + ofs -1) >> cfi->chipshift)
13091 + thislen = (1<<cfi->chipshift) - ofs;
13092 + else
13093 + thislen = len;
13094 +
13095 + ret = do_read_onechip(map, &cfi->chips[chipnum], ofs, thislen, buf);
13096 + if (ret)
13097 + break;
13098 +
13099 + *retlen += thislen;
13100 + len -= thislen;
13101 + buf += thislen;
13102 +
13103 + ofs = 0;
13104 + chipnum++;
13105 + }
13106 + return ret;
13107 +}
13108 +
13109 +static int do_write_oneword(struct map_info *map, struct flchip *chip, unsigned long adr, __u32 datum, int fast)
13110 +{
13111 + unsigned long timeo = jiffies + HZ;
13112 + unsigned int Last[4];
13113 + unsigned long Count = 0;
13114 + struct cfi_private *cfi = map->fldrv_priv;
13115 + DECLARE_WAITQUEUE(wait, current);
13116 + int ret = 0;
13117 +
13118 + retry:
13119 + cfi_spin_lock(chip->mutex);
13120 +
13121 + if (chip->state != FL_READY){
13122 + printk("Waiting for chip to write, status = %d\n", chip->state);
13123 + set_current_state(TASK_UNINTERRUPTIBLE);
13124 + add_wait_queue(&chip->wq, &wait);
13125 +
13126 + cfi_spin_unlock(chip->mutex);
13127 +
13128 + schedule();
13129 + remove_wait_queue(&chip->wq, &wait);
13130 + printk("Wake up to write:\n");
13131 + timeo = jiffies + HZ;
13132 +
13133 + goto retry;
13134 + }
13135 +
13136 + chip->state = FL_WRITING;
13137 +
13138 + adr += chip->start;
13139 + ENABLE_VPP(map);
13140 + cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13141 + cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13142 + cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13143 +
13144 + cfi_write(map, datum, adr);
13145 +
13146 + cfi_spin_unlock(chip->mutex);
13147 + cfi_udelay(chip->word_write_time);
13148 + cfi_spin_lock(chip->mutex);
13149 +
13150 + Last[0] = cfi_read(map, adr);
13151 + // printk("Last[0] is %x\n", Last[0]);
13152 + Last[1] = cfi_read(map, adr);
13153 + // printk("Last[1] is %x\n", Last[1]);
13154 + Last[2] = cfi_read(map, adr);
13155 + // printk("Last[2] is %x\n", Last[2]);
13156 +
13157 + for (Count = 3; Last[(Count - 1) % 4] != Last[(Count - 2) % 4] && Count < 10000; Count++){
13158 + cfi_spin_unlock(chip->mutex);
13159 + cfi_udelay(10);
13160 + cfi_spin_lock(chip->mutex);
13161 +
13162 + Last[Count % 4] = cfi_read(map, adr);
13163 + // printk("Last[%d%%4] is %x\n", Count, Last[Count%4]);
13164 + }
13165 +
13166 + if (Last[(Count - 1) % 4] != datum){
13167 + printk("Last[%ld] is %x, datum is %x\n",(Count - 1) % 4,Last[(Count - 1) % 4],datum);
13168 + cfi_send_gen_cmd(0xF0, 0, chip->start, map, cfi, cfi->device_type, NULL);
13169 + DISABLE_VPP(map);
13170 + ret = -EIO;
13171 + }
13172 + DISABLE_VPP(map);
13173 + chip->state = FL_READY;
13174 + wake_up(&chip->wq);
13175 + cfi_spin_unlock(chip->mutex);
13176 +
13177 + return ret;
13178 +}
13179 +
13180 +static int cfi_sststd_write (struct mtd_info *mtd, loff_t to , size_t len, size_t *retlen, const u_char *buf)
13181 +{
13182 + struct map_info *map = mtd->priv;
13183 + struct cfi_private *cfi = map->fldrv_priv;
13184 + int ret = 0;
13185 + int chipnum;
13186 + unsigned long ofs, chipstart;
13187 +
13188 + *retlen = 0;
13189 + if (!len)
13190 + return 0;
13191 +
13192 + chipnum = to >> cfi->chipshift;
13193 + ofs = to - (chipnum << cfi->chipshift);
13194 + chipstart = cfi->chips[chipnum].start;
13195 +
13196 + /* If it's not bus-aligned, do the first byte write */
13197 + if (ofs & (CFIDEV_BUSWIDTH-1)) {
13198 + unsigned long bus_ofs = ofs & ~(CFIDEV_BUSWIDTH-1);
13199 + int i = ofs - bus_ofs;
13200 + int n = 0;
13201 + u_char tmp_buf[4];
13202 + __u32 datum;
13203 +
13204 + map->copy_from(map, tmp_buf, bus_ofs + cfi->chips[chipnum].start, CFIDEV_BUSWIDTH);
13205 + while (len && i < CFIDEV_BUSWIDTH)
13206 + tmp_buf[i++] = buf[n++], len--;
13207 +
13208 + if (cfi_buswidth_is_2()) {
13209 + datum = *(__u16*)tmp_buf;
13210 + } else if (cfi_buswidth_is_4()) {
13211 + datum = *(__u32*)tmp_buf;
13212 + } else {
13213 + return -EINVAL; /* should never happen, but be safe */
13214 + }
13215 +
13216 + ret = do_write_oneword(map, &cfi->chips[chipnum],
13217 + bus_ofs, datum, 0);
13218 + if (ret)
13219 + return ret;
13220 +
13221 + ofs += n;
13222 + buf += n;
13223 + (*retlen) += n;
13224 +
13225 + if (ofs >> cfi->chipshift) {
13226 + chipnum ++;
13227 + ofs = 0;
13228 + if (chipnum == cfi->numchips)
13229 + return 0;
13230 + }
13231 + }
13232 +
13233 + /* We are now aligned, write as much as possible */
13234 + while(len >= CFIDEV_BUSWIDTH) {
13235 + __u32 datum;
13236 +
13237 + if (cfi_buswidth_is_1()) {
13238 + datum = *(__u8*)buf;
13239 + } else if (cfi_buswidth_is_2()) {
13240 + datum = *(__u16*)buf;
13241 + } else if (cfi_buswidth_is_4()) {
13242 + datum = *(__u32*)buf;
13243 + } else {
13244 + return -EINVAL;
13245 + }
13246 + ret = do_write_oneword(map, &cfi->chips[chipnum],
13247 + ofs, datum, cfi->fast_prog);
13248 + if (ret) {
13249 + return ret;
13250 + }
13251 +
13252 + ofs += CFIDEV_BUSWIDTH;
13253 + buf += CFIDEV_BUSWIDTH;
13254 + (*retlen) += CFIDEV_BUSWIDTH;
13255 + len -= CFIDEV_BUSWIDTH;
13256 +
13257 + if (ofs >> cfi->chipshift) {
13258 + chipnum ++;
13259 + ofs = 0;
13260 + if (chipnum == cfi->numchips)
13261 + return 0;
13262 + chipstart = cfi->chips[chipnum].start;
13263 + }
13264 + }
13265 +
13266 + if (len & (CFIDEV_BUSWIDTH-1)) {
13267 + int i = 0, n = 0;
13268 + u_char tmp_buf[4];
13269 + __u32 datum;
13270 +
13271 + map->copy_from(map, tmp_buf, ofs + cfi->chips[chipnum].start, CFIDEV_BUSWIDTH);
13272 + while (len--)
13273 + tmp_buf[i++] = buf[n++];
13274 +
13275 + if (cfi_buswidth_is_2()) {
13276 + datum = *(__u16*)tmp_buf;
13277 + } else if (cfi_buswidth_is_4()) {
13278 + datum = *(__u32*)tmp_buf;
13279 + } else {
13280 + return -EINVAL; /* should never happen, but be safe */
13281 + }
13282 +
13283 + ret = do_write_oneword(map, &cfi->chips[chipnum],
13284 + ofs, datum, 0);
13285 + if (ret)
13286 + return ret;
13287 +
13288 + (*retlen) += n;
13289 + }
13290 +
13291 + return 0;
13292 +}
13293 +
13294 +static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr)
13295 +{
13296 + unsigned int status;
13297 + unsigned long timeo = jiffies + HZ;
13298 + struct cfi_private *cfi = map->fldrv_priv;
13299 + unsigned int rdy_mask;
13300 + DECLARE_WAITQUEUE(wait, current);
13301 +
13302 + retry:
13303 + cfi_spin_lock(chip->mutex);
13304 +
13305 + if (chip->state != FL_READY){
13306 + set_current_state(TASK_UNINTERRUPTIBLE);
13307 + add_wait_queue(&chip->wq, &wait);
13308 +
13309 + cfi_spin_unlock(chip->mutex);
13310 +
13311 + schedule();
13312 + remove_wait_queue(&chip->wq, &wait);
13313 + timeo = jiffies + HZ;
13314 +
13315 + goto retry;
13316 + }
13317 +
13318 + chip->state = FL_ERASING;
13319 +
13320 + adr += chip->start;
13321 + ENABLE_VPP(map);
13322 + cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13323 + cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13324 + cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13325 + cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13326 + cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13327 + cfi_write(map, CMD(0x30), adr);
13328 +
13329 + timeo = jiffies + (HZ*20);
13330 +
13331 + cfi_spin_unlock(chip->mutex);
13332 + schedule_timeout(HZ);
13333 + cfi_spin_lock(chip->mutex);
13334 +
13335 + rdy_mask = CMD(0x80);
13336 +
13337 + /* Once the state machine's known to be working I'll do that */
13338 +
13339 + while ( ( (status = cfi_read(map,adr)) & rdy_mask ) != rdy_mask ) {
13340 + static int z=0;
13341 +
13342 + if (chip->state != FL_ERASING) {
13343 + /* Someone's suspended the erase. Sleep */
13344 + set_current_state(TASK_UNINTERRUPTIBLE);
13345 + add_wait_queue(&chip->wq, &wait);
13346 +
13347 + cfi_spin_unlock(chip->mutex);
13348 + printk("erase suspended. Sleeping\n");
13349 +
13350 + schedule();
13351 + remove_wait_queue(&chip->wq, &wait);
13352 + timeo = jiffies + (HZ*2);
13353 + cfi_spin_lock(chip->mutex);
13354 + continue;
13355 + }
13356 +
13357 + /* OK Still waiting */
13358 + if (time_after(jiffies, timeo)) {
13359 + chip->state = FL_READY;
13360 + cfi_spin_unlock(chip->mutex);
13361 + printk("waiting for erase to complete timed out.");
13362 + DISABLE_VPP(map);
13363 + return -EIO;
13364 + }
13365 +
13366 + /* Latency issues. Drop the lock, wait a while and retry */
13367 + cfi_spin_unlock(chip->mutex);
13368 +
13369 + z++;
13370 + if ( 0 && !(z % 100 ))
13371 + printk("chip not ready yet after erase. looping\n");
13372 +
13373 + cfi_udelay(1);
13374 +
13375 + cfi_spin_lock(chip->mutex);
13376 + continue;
13377 + }
13378 +
13379 + /* Done and happy. */
13380 + DISABLE_VPP(map);
13381 + chip->state = FL_READY;
13382 + wake_up(&chip->wq);
13383 + cfi_spin_unlock(chip->mutex);
13384 + return 0;
13385 +}
13386 +
13387 +static int cfi_sststd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
13388 +{
13389 + struct map_info *map = mtd->priv;
13390 + struct cfi_private *cfi = map->fldrv_priv;
13391 + unsigned long adr, len;
13392 + int chipnum, ret = 0;
13393 + int i, first;
13394 + struct mtd_erase_region_info *regions = mtd->eraseregions;
13395 +
13396 + if (instr->addr > mtd->size)
13397 + return -EINVAL;
13398 +
13399 + if ((instr->len + instr->addr) > mtd->size)
13400 + return -EINVAL;
13401 +
13402 + /* Check that both start and end of the requested erase are
13403 + * aligned with the erasesize at the appropriate addresses.
13404 + */
13405 +
13406 + i = 0;
13407 +
13408 + /* Skip all erase regions which are ended before the start of
13409 + the requested erase. Actually, to save on the calculations,
13410 + we skip to the first erase region which starts after the
13411 + start of the requested erase, and then go back one.
13412 + */
13413 +
13414 + while (i < mtd->numeraseregions && instr->addr >= regions[i].offset)
13415 + i++;
13416 + i--;
13417 +
13418 + /* OK, now i is pointing at the erase region in which this
13419 + erase request starts. Check the start of the requested
13420 + erase range is aligned with the erase size which is in
13421 + effect here.
13422 + */
13423 +
13424 + if (instr->addr & (regions[i].erasesize-1))
13425 + return -EINVAL;
13426 +
13427 + /* Remember the erase region we start on */
13428 + first = i;
13429 +
13430 + /* Next, check that the end of the requested erase is aligned
13431 + * with the erase region at that address.
13432 + */
13433 +
13434 + while (i<mtd->numeraseregions && (instr->addr + instr->len) >= regions[i].offset)
13435 + i++;
13436 +
13437 + /* As before, drop back one to point at the region in which
13438 + the address actually falls
13439 + */
13440 + i--;
13441 +
13442 + if ((instr->addr + instr->len) & (regions[i].erasesize-1))
13443 + return -EINVAL;
13444 +
13445 + chipnum = instr->addr >> cfi->chipshift;
13446 + adr = instr->addr - (chipnum << cfi->chipshift);
13447 + len = instr->len;
13448 +
13449 + i=first;
13450 +
13451 + while(len) {
13452 + ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr);
13453 +
13454 + if (ret)
13455 + return ret;
13456 +
13457 + adr += regions[i].erasesize;
13458 + len -= regions[i].erasesize;
13459 +
13460 + if (adr % (1<< cfi->chipshift) == ((regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift)))
13461 + i++;
13462 +
13463 + if (adr >> cfi->chipshift) {
13464 + adr = 0;
13465 + chipnum++;
13466 +
13467 + if (chipnum >= cfi->numchips)
13468 + break;
13469 + }
13470 + }
13471 +
13472 + instr->state = MTD_ERASE_DONE;
13473 + if (instr->callback)
13474 + instr->callback(instr);
13475 +
13476 + return 0;
13477 +}
13478 +
13479 +static int cfi_sststd_erase_onesize(struct mtd_info *mtd, struct erase_info *instr)
13480 +{
13481 + struct map_info *map = mtd->priv;
13482 + struct cfi_private *cfi = map->fldrv_priv;
13483 + unsigned long adr, len;
13484 + int chipnum, ret = 0;
13485 +
13486 + if (instr->addr & (mtd->erasesize - 1))
13487 + return -EINVAL;
13488 +
13489 + if (instr->len & (mtd->erasesize -1))
13490 + return -EINVAL;
13491 +
13492 + if ((instr->len + instr->addr) > mtd->size)
13493 + return -EINVAL;
13494 +
13495 + chipnum = instr->addr >> cfi->chipshift;
13496 + adr = instr->addr - (chipnum << cfi->chipshift);
13497 + len = instr->len;
13498 +
13499 + while(len) {
13500 + ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr);
13501 +
13502 + if (ret)
13503 + return ret;
13504 +
13505 + adr += mtd->erasesize;
13506 + len -= mtd->erasesize;
13507 +
13508 + if (adr >> cfi->chipshift) {
13509 + adr = 0;
13510 + chipnum++;
13511 +
13512 + if (chipnum >= cfi->numchips)
13513 + break;
13514 + }
13515 + }
13516 +
13517 + instr->state = MTD_ERASE_DONE;
13518 + if (instr->callback)
13519 + instr->callback(instr);
13520 +
13521 + return 0;
13522 +}
13523 +
13524 +static void cfi_sststd_sync (struct mtd_info *mtd)
13525 +{
13526 + struct map_info *map = mtd->priv;
13527 + struct cfi_private *cfi = map->fldrv_priv;
13528 + int i;
13529 + struct flchip *chip;
13530 + int ret = 0;
13531 + DECLARE_WAITQUEUE(wait, current);
13532 +
13533 + for (i=0; !ret && i<cfi->numchips; i++) {
13534 + chip = &cfi->chips[i];
13535 +
13536 + retry:
13537 + cfi_spin_lock(chip->mutex);
13538 +
13539 + switch(chip->state) {
13540 + case FL_READY:
13541 + case FL_STATUS:
13542 + case FL_CFI_QUERY:
13543 + case FL_JEDEC_QUERY:
13544 + chip->oldstate = chip->state;
13545 + chip->state = FL_SYNCING;
13546 + /* No need to wake_up() on this state change -
13547 + * as the whole point is that nobody can do anything
13548 + * with the chip now anyway.
13549 + */
13550 + case FL_SYNCING:
13551 + cfi_spin_unlock(chip->mutex);
13552 + break;
13553 +
13554 + default:
13555 + /* Not an idle state */
13556 + add_wait_queue(&chip->wq, &wait);
13557 +
13558 + cfi_spin_unlock(chip->mutex);
13559 +
13560 + schedule();
13561 +
13562 + remove_wait_queue(&chip->wq, &wait);
13563 +
13564 + goto retry;
13565 + }
13566 + }
13567 +
13568 + /* Unlock the chips again */
13569 +
13570 + for (i--; i >=0; i--) {
13571 + chip = &cfi->chips[i];
13572 +
13573 + cfi_spin_lock(chip->mutex);
13574 +
13575 + if (chip->state == FL_SYNCING) {
13576 + chip->state = chip->oldstate;
13577 + wake_up(&chip->wq);
13578 + }
13579 + cfi_spin_unlock(chip->mutex);
13580 + }
13581 +}
13582 +
13583 +
13584 +static int cfi_sststd_suspend(struct mtd_info *mtd)
13585 +{
13586 + struct map_info *map = mtd->priv;
13587 + struct cfi_private *cfi = map->fldrv_priv;
13588 + int i;
13589 + struct flchip *chip;
13590 + int ret = 0;
13591 +//printk("suspend\n");
13592 +
13593 + for (i=0; !ret && i<cfi->numchips; i++) {
13594 + chip = &cfi->chips[i];
13595 +
13596 + cfi_spin_lock(chip->mutex);
13597 +
13598 + switch(chip->state) {
13599 + case FL_READY:
13600 + case FL_STATUS:
13601 + case FL_CFI_QUERY:
13602 + case FL_JEDEC_QUERY:
13603 + chip->oldstate = chip->state;
13604 + chip->state = FL_PM_SUSPENDED;
13605 + /* No need to wake_up() on this state change -
13606 + * as the whole point is that nobody can do anything
13607 + * with the chip now anyway.
13608 + */
13609 + case FL_PM_SUSPENDED:
13610 + break;
13611 +
13612 + default:
13613 + ret = -EAGAIN;
13614 + break;
13615 + }
13616 + cfi_spin_unlock(chip->mutex);
13617 + }
13618 +
13619 + /* Unlock the chips again */
13620 +
13621 + if (ret) {
13622 + for (i--; i >=0; i--) {
13623 + chip = &cfi->chips[i];
13624 +
13625 + cfi_spin_lock(chip->mutex);
13626 +
13627 + if (chip->state == FL_PM_SUSPENDED) {
13628 + chip->state = chip->oldstate;
13629 + wake_up(&chip->wq);
13630 + }
13631 + cfi_spin_unlock(chip->mutex);
13632 + }
13633 + }
13634 +
13635 + return ret;
13636 +}
13637 +
13638 +static void cfi_sststd_resume(struct mtd_info *mtd)
13639 +{
13640 + struct map_info *map = mtd->priv;
13641 + struct cfi_private *cfi = map->fldrv_priv;
13642 + int i;
13643 + struct flchip *chip;
13644 +//printk("resume\n");
13645 +
13646 + for (i=0; i<cfi->numchips; i++) {
13647 +
13648 + chip = &cfi->chips[i];
13649 +
13650 + cfi_spin_lock(chip->mutex);
13651 +
13652 + if (chip->state == FL_PM_SUSPENDED) {
13653 + chip->state = FL_READY;
13654 + cfi_write(map, CMD(0xF0), chip->start);
13655 + wake_up(&chip->wq);
13656 + }
13657 + else
13658 + printk("Argh. Chip not in PM_SUSPENDED state upon resume()\n");
13659 +
13660 + cfi_spin_unlock(chip->mutex);
13661 + }
13662 +}
13663 +
13664 +static void cfi_sststd_destroy(struct mtd_info *mtd)
13665 +{
13666 + struct map_info *map = mtd->priv;
13667 + struct cfi_private *cfi = map->fldrv_priv;
13668 + kfree(cfi->cmdset_priv);
13669 + kfree(cfi);
13670 +}
13671 +
13672 +#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE)
13673 +#define cfi_sststd_init init_module
13674 +#define cfi_sststd_exit cleanup_module
13675 +#endif
13676 +
13677 +static char im_name[]="cfi_cmdset_0701";
13678 +
13679 +mod_init_t cfi_sststd_init(void)
13680 +{
13681 + inter_module_register(im_name, THIS_MODULE, &cfi_cmdset_0701);
13682 + return 0;
13683 +}
13684 +
13685 +mod_exit_t cfi_sststd_exit(void)
13686 +{
13687 + inter_module_unregister(im_name);
13688 +}
13689 +
13690 +module_init(cfi_sststd_init);
13691 +module_exit(cfi_sststd_exit);
13692 +
13693 diff -Nur linux-2.4.30/drivers/mtd/chips/cfi_probe.c linux-2.4.30-brcm/drivers/mtd/chips/cfi_probe.c
13694 --- linux-2.4.30/drivers/mtd/chips/cfi_probe.c 2003-06-13 16:51:34.000000000 +0200
13695 +++ linux-2.4.30-brcm/drivers/mtd/chips/cfi_probe.c 2005-05-22 22:55:52.000000000 +0200
13696 @@ -67,8 +67,15 @@
13697 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
13698 cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
13699
13700 - if (!qry_present(map,base,cfi))
13701 - return 0;
13702 + if (!qry_present(map,base,cfi)) {
13703 + /* rather broken SST cfi probe (requires SST unlock) */
13704 + cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
13705 + cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
13706 + cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
13707 + cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL);
13708 + if (!qry_present(map,base,cfi))
13709 + return 0;
13710 + }
13711
13712 if (!cfi->numchips) {
13713 /* This is the first time we're called. Set up the CFI
13714 diff -Nur linux-2.4.30/drivers/mtd/chips/Config.in linux-2.4.30-brcm/drivers/mtd/chips/Config.in
13715 --- linux-2.4.30/drivers/mtd/chips/Config.in 2003-06-13 16:51:34.000000000 +0200
13716 +++ linux-2.4.30-brcm/drivers/mtd/chips/Config.in 2005-05-22 22:55:52.000000000 +0200
13717 @@ -45,6 +45,7 @@
13718 dep_tristate ' Support for Intel/Sharp flash chips' CONFIG_MTD_CFI_INTELEXT $CONFIG_MTD_GEN_PROBE
13719 dep_tristate ' Support for AMD/Fujitsu flash chips' CONFIG_MTD_CFI_AMDSTD $CONFIG_MTD_GEN_PROBE
13720 dep_tristate ' Support for ST (Advanced Architecture) flash chips' CONFIG_MTD_CFI_STAA $CONFIG_MTD_GEN_PROBE
13721 +dep_tristate ' Support for SST flash chips' CONFIG_MTD_CFI_SSTSTD $CONFIG_MTD_GEN_PROBE
13722
13723 dep_tristate ' Support for RAM chips in bus mapping' CONFIG_MTD_RAM $CONFIG_MTD
13724 dep_tristate ' Support for ROM chips in bus mapping' CONFIG_MTD_ROM $CONFIG_MTD
13725 diff -Nur linux-2.4.30/drivers/mtd/chips/gen_probe.c linux-2.4.30-brcm/drivers/mtd/chips/gen_probe.c
13726 --- linux-2.4.30/drivers/mtd/chips/gen_probe.c 2003-08-25 13:44:42.000000000 +0200
13727 +++ linux-2.4.30-brcm/drivers/mtd/chips/gen_probe.c 2005-05-22 22:55:52.000000000 +0200
13728 @@ -332,9 +332,13 @@
13729 return cfi_cmdset_0002(map, primary);
13730 #endif
13731 #ifdef CONFIG_MTD_CFI_STAA
13732 - case 0x0020:
13733 + case 0x0020:
13734 return cfi_cmdset_0020(map, primary);
13735 #endif
13736 +#ifdef CONFIG_MTD_CFI_SSTSTD
13737 + case 0x0701:
13738 + return cfi_cmdset_0701(map, primary);
13739 +#endif
13740 }
13741
13742 return cfi_cmdset_unknown(map, primary);
13743 diff -Nur linux-2.4.30/drivers/mtd/chips/Makefile linux-2.4.30-brcm/drivers/mtd/chips/Makefile
13744 --- linux-2.4.30/drivers/mtd/chips/Makefile 2003-06-13 16:51:34.000000000 +0200
13745 +++ linux-2.4.30-brcm/drivers/mtd/chips/Makefile 2005-05-22 22:55:52.000000000 +0200
13746 @@ -18,6 +18,7 @@
13747 obj-$(CONFIG_MTD_AMDSTD) += amd_flash.o
13748 obj-$(CONFIG_MTD_CFI) += cfi_probe.o
13749 obj-$(CONFIG_MTD_CFI_STAA) += cfi_cmdset_0020.o
13750 +obj-$(CONFIG_MTD_CFI_SSTSTD) += cfi_cmdset_0701.o
13751 obj-$(CONFIG_MTD_CFI_AMDSTD) += cfi_cmdset_0002.o
13752 obj-$(CONFIG_MTD_CFI_INTELEXT) += cfi_cmdset_0001.o
13753 obj-$(CONFIG_MTD_GEN_PROBE) += gen_probe.o
13754 diff -Nur linux-2.4.30/drivers/mtd/maps/bcm947xx-flash.c linux-2.4.30-brcm/drivers/mtd/maps/bcm947xx-flash.c
13755 --- linux-2.4.30/drivers/mtd/maps/bcm947xx-flash.c 1970-01-01 01:00:00.000000000 +0100
13756 +++ linux-2.4.30-brcm/drivers/mtd/maps/bcm947xx-flash.c 2005-05-22 22:55:52.000000000 +0200
13757 @@ -0,0 +1,236 @@
13758 +/*
13759 + * Flash mapping for BCM947XX boards
13760 + *
13761 + * Copyright 2004, Broadcom Corporation
13762 + * All Rights Reserved.
13763 + *
13764 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
13765 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13766 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
13767 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
13768 + *
13769 + * $Id: bcm947xx-flash.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
13770 + */
13771 +
13772 +#include <linux/module.h>
13773 +#include <linux/types.h>
13774 +#include <linux/kernel.h>
13775 +#include <asm/io.h>
13776 +#include <linux/mtd/mtd.h>
13777 +#include <linux/mtd/map.h>
13778 +#include <linux/mtd/partitions.h>
13779 +#include <linux/config.h>
13780 +
13781 +#include <typedefs.h>
13782 +#include <bcmnvram.h>
13783 +#include <bcmutils.h>
13784 +#include <sbconfig.h>
13785 +#include <sbchipc.h>
13786 +#include <sbutils.h>
13787 +#include <trxhdr.h>
13788 +
13789 +/* Global SB handle */
13790 +extern void *bcm947xx_sbh;
13791 +extern spinlock_t bcm947xx_sbh_lock;
13792 +
13793 +/* Convenience */
13794 +#define sbh bcm947xx_sbh
13795 +#define sbh_lock bcm947xx_sbh_lock
13796 +
13797 +#ifdef CONFIG_MTD_PARTITIONS
13798 +extern struct mtd_partition * init_mtd_partitions(struct mtd_info *mtd, size_t size);
13799 +#endif
13800 +
13801 +#define WINDOW_ADDR 0x1fc00000
13802 +#define WINDOW_SIZE 0x400000
13803 +#define BUSWIDTH 2
13804 +
13805 +/* e.g., flash=2M or flash=4M */
13806 +static int flash = 0;
13807 +MODULE_PARM(flash, "i");
13808 +static int __init
13809 +bcm947xx_setup(char *str)
13810 +{
13811 + flash = memparse(str, &str);
13812 + return 1;
13813 +}
13814 +__setup("flash=", bcm947xx_setup);
13815 +
13816 +static struct mtd_info *bcm947xx_mtd;
13817 +
13818 +__u8 bcm947xx_map_read8(struct map_info *map, unsigned long ofs)
13819 +{
13820 + if (map->map_priv_2 == 1)
13821 + return __raw_readb(map->map_priv_1 + ofs);
13822 +
13823 + u16 val = __raw_readw(map->map_priv_1 + (ofs & ~1));
13824 + if (ofs & 1)
13825 + return ((val >> 8) & 0xff);
13826 + else
13827 + return (val & 0xff);
13828 +}
13829 +
13830 +__u16 bcm947xx_map_read16(struct map_info *map, unsigned long ofs)
13831 +{
13832 + return __raw_readw(map->map_priv_1 + ofs);
13833 +}
13834 +
13835 +__u32 bcm947xx_map_read32(struct map_info *map, unsigned long ofs)
13836 +{
13837 + return __raw_readl(map->map_priv_1 + ofs);
13838 +}
13839 +
13840 +void bcm947xx_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
13841 +{
13842 + if (len==1) {
13843 + memcpy_fromio(to, map->map_priv_1 + from, len);
13844 + } else {
13845 + int i;
13846 + u16 *dest = (u16 *) to;
13847 + u16 *src = (u16 *) (map->map_priv_1 + from);
13848 + for (i = 0; i < (len / 2); i++) {
13849 + dest[i] = src[i];
13850 + }
13851 + if (len & 1)
13852 + *((u8 *)dest+len-1) = src[i] & 0xff;
13853 + }
13854 +}
13855 +
13856 +void bcm947xx_map_write8(struct map_info *map, __u8 d, unsigned long adr)
13857 +{
13858 + __raw_writeb(d, map->map_priv_1 + adr);
13859 + mb();
13860 +}
13861 +
13862 +void bcm947xx_map_write16(struct map_info *map, __u16 d, unsigned long adr)
13863 +{
13864 + __raw_writew(d, map->map_priv_1 + adr);
13865 + mb();
13866 +}
13867 +
13868 +void bcm947xx_map_write32(struct map_info *map, __u32 d, unsigned long adr)
13869 +{
13870 + __raw_writel(d, map->map_priv_1 + adr);
13871 + mb();
13872 +}
13873 +
13874 +void bcm947xx_map_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
13875 +{
13876 + memcpy_toio(map->map_priv_1 + to, from, len);
13877 +}
13878 +
13879 +struct map_info bcm947xx_map = {
13880 + name: "Physically mapped flash",
13881 + size: WINDOW_SIZE,
13882 + buswidth: BUSWIDTH,
13883 + read8: bcm947xx_map_read8,
13884 + read16: bcm947xx_map_read16,
13885 + read32: bcm947xx_map_read32,
13886 + copy_from: bcm947xx_map_copy_from,
13887 + write8: bcm947xx_map_write8,
13888 + write16: bcm947xx_map_write16,
13889 + write32: bcm947xx_map_write32,
13890 + copy_to: bcm947xx_map_copy_to
13891 +};
13892 +
13893 +#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE)
13894 +#define init_bcm947xx_map init_module
13895 +#define cleanup_bcm947xx_map cleanup_module
13896 +#endif
13897 +
13898 +mod_init_t init_bcm947xx_map(void)
13899 +{
13900 + ulong flags;
13901 + uint coreidx;
13902 + chipcregs_t *cc;
13903 + uint32 fltype;
13904 + uint window_addr = 0, window_size = 0;
13905 + size_t size;
13906 + int ret = 0;
13907 +#ifdef CONFIG_MTD_PARTITIONS
13908 + struct mtd_partition *parts;
13909 + int i;
13910 +#endif
13911 +
13912 + spin_lock_irqsave(&sbh_lock, flags);
13913 + coreidx = sb_coreidx(sbh);
13914 +
13915 + /* Check strapping option if chipcommon exists */
13916 + if ((cc = sb_setcore(sbh, SB_CC, 0))) {
13917 + fltype = readl(&cc->capabilities) & CAP_FLASH_MASK;
13918 + if (fltype == PFLASH) {
13919 + bcm947xx_map.map_priv_2 = 1;
13920 + window_addr = 0x1c000000;
13921 + bcm947xx_map.size = window_size = 32 * 1024 * 1024;
13922 + if ((readl(&cc->flash_config) & CC_CFG_DS) == 0)
13923 + bcm947xx_map.buswidth = 1;
13924 + }
13925 + } else {
13926 + fltype = PFLASH;
13927 + bcm947xx_map.map_priv_2 = 0;
13928 + window_addr = WINDOW_ADDR;
13929 + window_size = WINDOW_SIZE;
13930 + }
13931 +
13932 + sb_setcoreidx(sbh, coreidx);
13933 + spin_unlock_irqrestore(&sbh_lock, flags);
13934 +
13935 + if (fltype != PFLASH) {
13936 + printk(KERN_ERR "pflash: found no supported devices\n");
13937 + ret = -ENODEV;
13938 + goto fail;
13939 + }
13940 +
13941 + bcm947xx_map.map_priv_1 = (unsigned long) ioremap(window_addr, window_size);
13942 + if (!bcm947xx_map.map_priv_1) {
13943 + printk(KERN_ERR "pflash: ioremap failed\n");
13944 + ret = -EIO;
13945 + goto fail;
13946 + }
13947 +
13948 + if (!(bcm947xx_mtd = do_map_probe("cfi_probe", &bcm947xx_map))) {
13949 + printk(KERN_ERR "pflash: cfi_probe failed\n");
13950 + ret = -ENXIO;
13951 + goto fail;
13952 + }
13953 +
13954 + bcm947xx_mtd->module = THIS_MODULE;
13955 +
13956 + /* Allow size override for testing */
13957 + size = flash ? : bcm947xx_mtd->size;
13958 +
13959 + printk(KERN_NOTICE "Flash device: 0x%x at 0x%x\n", size, window_addr);
13960 +
13961 +#ifdef CONFIG_MTD_PARTITIONS
13962 + parts = init_mtd_partitions(bcm947xx_mtd, size);
13963 + for (i = 0; parts[i].name; i++);
13964 + ret = add_mtd_partitions(bcm947xx_mtd, parts, i);
13965 + if (ret) {
13966 + printk(KERN_ERR "pflash: add_mtd_partitions failed\n");
13967 + goto fail;
13968 + }
13969 +#endif
13970 +
13971 + return 0;
13972 +
13973 + fail:
13974 + if (bcm947xx_mtd)
13975 + map_destroy(bcm947xx_mtd);
13976 + if (bcm947xx_map.map_priv_1)
13977 + iounmap((void *) bcm947xx_map.map_priv_1);
13978 + bcm947xx_map.map_priv_1 = 0;
13979 + return ret;
13980 +}
13981 +
13982 +mod_exit_t cleanup_bcm947xx_map(void)
13983 +{
13984 +#ifdef CONFIG_MTD_PARTITIONS
13985 + del_mtd_partitions(bcm947xx_mtd);
13986 +#endif
13987 + map_destroy(bcm947xx_mtd);
13988 + iounmap((void *) bcm947xx_map.map_priv_1);
13989 + bcm947xx_map.map_priv_1 = 0;
13990 +}
13991 +
13992 +module_init(init_bcm947xx_map);
13993 +module_exit(cleanup_bcm947xx_map);
13994 diff -Nur linux-2.4.30/drivers/mtd/maps/Config.in linux-2.4.30-brcm/drivers/mtd/maps/Config.in
13995 --- linux-2.4.30/drivers/mtd/maps/Config.in 2003-06-13 16:51:34.000000000 +0200
13996 +++ linux-2.4.30-brcm/drivers/mtd/maps/Config.in 2005-05-25 18:58:03.000000000 +0200
13997 @@ -48,6 +48,7 @@
13998 fi
13999
14000 if [ "$CONFIG_MIPS" = "y" ]; then
14001 + dep_tristate ' CFI Flash device mapped on Broadcom BCM947XX boards' CONFIG_MTD_BCM947XX $CONFIG_MTD_CFI
14002 dep_tristate ' Pb1000 MTD support' CONFIG_MTD_PB1000 $CONFIG_MIPS_PB1000
14003 dep_tristate ' Pb1500 MTD support' CONFIG_MTD_PB1500 $CONFIG_MIPS_PB1500
14004 dep_tristate ' Pb1100 MTD support' CONFIG_MTD_PB1100 $CONFIG_MIPS_PB1100
14005 diff -Nur linux-2.4.30/drivers/mtd/maps/Makefile linux-2.4.30-brcm/drivers/mtd/maps/Makefile
14006 --- linux-2.4.30/drivers/mtd/maps/Makefile 2003-06-13 16:51:34.000000000 +0200
14007 +++ linux-2.4.30-brcm/drivers/mtd/maps/Makefile 2005-05-25 18:57:31.000000000 +0200
14008 @@ -3,6 +3,8 @@
14009 #
14010 # $Id: Makefile,v 1.37 2003/01/24 14:26:38 dwmw2 Exp $
14011
14012 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include
14013 +
14014 BELOW25 := $(shell echo $(PATCHLEVEL) | sed s/[1234]/y/)
14015
14016 ifeq ($(BELOW25),y)
14017 @@ -10,6 +12,7 @@
14018 endif
14019
14020 # Chip mappings
14021 +obj-$(CONFIG_MTD_BCM947XX) += bcm947xx-flash.o
14022 obj-$(CONFIG_MTD_CDB89712) += cdb89712.o
14023 obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o
14024 obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o
14025 diff -Nur linux-2.4.30/drivers/net/Config.in linux-2.4.30-brcm/drivers/net/Config.in
14026 --- linux-2.4.30/drivers/net/Config.in 2005-01-19 15:09:56.000000000 +0100
14027 +++ linux-2.4.30-brcm/drivers/net/Config.in 2005-05-25 04:34:51.000000000 +0200
14028 @@ -2,6 +2,8 @@
14029 # Network device configuration
14030 #
14031
14032 +tristate 'Broadcom Home Network Division' CONFIG_HND $CONFIG_PCI
14033 +
14034 source drivers/net/arcnet/Config.in
14035
14036 tristate 'Dummy net driver support' CONFIG_DUMMY
14037 @@ -173,6 +175,7 @@
14038
14039 dep_tristate ' Apricot Xen-II on board Ethernet' CONFIG_APRICOT $CONFIG_ISA
14040 dep_tristate ' Broadcom 4400 ethernet support (EXPERIMENTAL)' CONFIG_B44 $CONFIG_PCI $CONFIG_EXPERIMENTAL
14041 + dep_tristate ' Proprietary Broadcom 10/100 Ethernet support' CONFIG_ET $CONFIG_PCI
14042 dep_tristate ' CS89x0 support' CONFIG_CS89x0 $CONFIG_ISA
14043 dep_tristate ' DECchip Tulip (dc21x4x) PCI support' CONFIG_TULIP $CONFIG_PCI
14044 if [ "$CONFIG_TULIP" = "y" -o "$CONFIG_TULIP" = "m" ]; then
14045 diff -Nur linux-2.4.30/drivers/net/diag/diag_led.c linux-2.4.30-brcm/drivers/net/diag/diag_led.c
14046 --- linux-2.4.30/drivers/net/diag/diag_led.c 1970-01-01 01:00:00.000000000 +0100
14047 +++ linux-2.4.30-brcm/drivers/net/diag/diag_led.c 2005-05-25 20:41:19.000000000 +0200
14048 @@ -0,0 +1,244 @@
14049 +/*
14050 + * diag_led.c - replacement diag module
14051 + *
14052 + * Copyright (C) 2004 Mike Baker,
14053 + * Imre Kaloz <kaloz@dune.hu>
14054 + *
14055 + * This program is free software; you can redistribute it and/or
14056 + * modify it under the terms of the GNU General Public License
14057 + * as published by the Free Software Foundation; either version 2
14058 + * of the License, or (at your option) any later version.
14059 + *
14060 + * This program is distributed in the hope that it will be useful,
14061 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14062 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14063 + * GNU General Public License for more details.
14064 + *
14065 + * You should have received a copy of the GNU General Public License
14066 + * along with this program; if not, write to the Free Software
14067 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
14068 + *
14069 + * $Id: diag_led.c,v 1.5 2005/04/18 09:05:24 mbm Exp $
14070 + */
14071 +
14072 +/*
14073 + * ChangeLog:
14074 + * 2004/03/28 initial release
14075 + * 2004/08/26 asus & buffalo support added
14076 + * 2005/03/14 asus wl-500g deluxe and buffalo v2 support added
14077 + * 2005/04/13 added licensing informations
14078 + * 2005/04/18 base reset polarity off initial readings
14079 + */
14080 +
14081 +#include <linux/module.h>
14082 +#include <linux/init.h>
14083 +#include <linux/kernel.h>
14084 +#include <linux/sysctl.h>
14085 +#include <asm/io.h>
14086 +#include <typedefs.h>
14087 +#include <bcmdevs.h>
14088 +#include <sbutils.h>
14089 +
14090 +extern char * nvram_get(const char *name);
14091 +static void *sbh;
14092 +
14093 +// v2.x - - - - -
14094 +#define DIAG_GPIO (1<<1)
14095 +#define DMZ_GPIO (1<<7)
14096 +
14097 +static void set_gpio(uint32 mask, uint32 value) {
14098 + sb_gpiocontrol(sbh,mask,0);
14099 + sb_gpioouten(sbh,mask,mask);
14100 + sb_gpioout(sbh,mask,value);
14101 +}
14102 +
14103 +static void v2_set_diag(u8 state) {
14104 + set_gpio(DIAG_GPIO,state);
14105 +}
14106 +static void v2_set_dmz(u8 state) {
14107 + set_gpio(DMZ_GPIO,state);
14108 +}
14109 +
14110 +// v1.x - - - - -
14111 +#define LED_DIAG 0x13
14112 +#define LED_DMZ 0x12
14113 +
14114 +static void v1_set_diag(u8 state) {
14115 + if (!state) {
14116 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG)=0xFF;
14117 + } else {
14118 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG);
14119 + }
14120 +}
14121 +static void v1_set_dmz(u8 state) {
14122 + if (!state) {
14123 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ)=0xFF;
14124 + } else {
14125 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ);
14126 + }
14127 +}
14128 +
14129 +// - - - - -
14130 +static void ignore(u8 ignored) {};
14131 +
14132 +// - - - - -
14133 +#define BIT_DMZ 0x01
14134 +#define BIT_DIAG 0x04
14135 +
14136 +void (*set_diag)(u8 state);
14137 +void (*set_dmz)(u8 state);
14138 +
14139 +static unsigned int diag = 0;
14140 +
14141 +static void diag_change()
14142 +{
14143 + set_diag(0xFF); // off
14144 + set_dmz(0xFF); // off
14145 +
14146 + if(diag & BIT_DIAG)
14147 + set_diag(0x00); // on
14148 + if(diag & BIT_DMZ)
14149 + set_dmz(0x00); // on
14150 +}
14151 +
14152 +static int proc_diag(ctl_table *table, int write, struct file *filp,
14153 + void *buffer, size_t *lenp)
14154 +{
14155 + int r;
14156 + r = proc_dointvec(table, write, filp, buffer, lenp);
14157 + if (write && !r) {
14158 + diag_change();
14159 + }
14160 + return r;
14161 +}
14162 +
14163 +// - - - - -
14164 +static unsigned char reset_gpio = 0;
14165 +static unsigned char reset_polarity = 0;
14166 +static unsigned int reset = 0;
14167 +
14168 +static int proc_reset(ctl_table *table, int write, struct file *filp,
14169 + void *buffer, size_t *lenp)
14170 +{
14171 +
14172 + if (reset_gpio) {
14173 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
14174 + sb_gpioouten(sbh,reset_gpio,0);
14175 + reset=!(sb_gpioin(sbh)&reset_gpio);
14176 +
14177 + if (reset_polarity) reset=!reset;
14178 + } else {
14179 + reset=0;
14180 + }
14181 +
14182 + return proc_dointvec(table, write, filp, buffer, lenp);
14183 +}
14184 +
14185 +// - - - - -
14186 +static struct ctl_table_header *diag_sysctl_header;
14187 +
14188 +static ctl_table sys_diag[] = {
14189 + {
14190 + ctl_name: 2000,
14191 + procname: "diag",
14192 + data: &diag,
14193 + maxlen: sizeof(diag),
14194 + mode: 0644,
14195 + proc_handler: proc_diag
14196 + },
14197 + {
14198 + ctl_name: 2001,
14199 + procname: "reset",
14200 + data: &reset,
14201 + maxlen: sizeof(reset),
14202 + mode: 0444,
14203 + proc_handler: proc_reset
14204 + },
14205 + { 0 }
14206 +};
14207 +
14208 +static int __init diag_init()
14209 +{
14210 + char *buf;
14211 + u32 board_type;
14212 + sbh = sb_kattach();
14213 + sb_gpiosetcore(sbh);
14214 +
14215 + board_type = sb_boardtype(sbh);
14216 + printk(KERN_INFO "diag boardtype: %08x\n",board_type);
14217 +
14218 + set_diag=ignore;
14219 + set_dmz=ignore;
14220 +
14221 + if ((board_type & 0xf00) == 0x400) {
14222 + buf=nvram_get("boardtype")?:"";
14223 + if (!strcmp(buf,"bcm94710dev")) {
14224 + buf=nvram_get("boardnum")?:"";
14225 + if (!strcmp(buf,"42")) {
14226 + // wrt54g v1.x
14227 + set_diag=v1_set_diag;
14228 + set_dmz=v1_set_dmz;
14229 + reset_gpio=(1<<6);
14230 + }
14231 + if (!strcmp(buf,"asusX")) {
14232 + //asus wl-500g
14233 + reset_gpio=(1<<6);
14234 + }
14235 + }
14236 + if (!strcmp(buf,"bcm94710ap")) {
14237 + buf=nvram_get("boardnum")?:"";
14238 + if (!strcmp(buf,"42")) {
14239 + // buffalo
14240 + set_dmz=v2_set_dmz;
14241 + reset_gpio=(1<<4);
14242 + }
14243 + if (!strcmp(buf,"44")) {
14244 + //dell truemobile
14245 + set_dmz=v2_set_dmz;
14246 + reset_gpio=(1<<0);
14247 + }
14248 + }
14249 + } else {
14250 + buf=nvram_get("boardnum")?:"";
14251 + if (!strcmp(buf,"42")) {
14252 + //linksys
14253 + set_diag=v2_set_diag;
14254 + set_dmz=v2_set_dmz;
14255 + reset_gpio=(1<<6);
14256 + }
14257 + if (!strcmp(buf,"44")) {
14258 + //motorola
14259 + reset_gpio=(1<<5);
14260 + }
14261 + if (!strcmp(buf,"00")) {
14262 + //buffalo
14263 + reset_gpio=(1<<7);
14264 + }
14265 + if (!strcmp(buf,"45")) {
14266 + //wl-500g deluxe
14267 + reset_gpio=(1<<6);
14268 + }
14269 + }
14270 +
14271 +
14272 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
14273 + sb_gpioouten(sbh,reset_gpio,0);
14274 + reset_polarity=!(sb_gpioin(sbh)&reset_gpio);
14275 +
14276 + diag_sysctl_header = register_sysctl_table(sys_diag, 0);
14277 + diag_change();
14278 +
14279 + return 0;
14280 +}
14281 +
14282 +static void __exit diag_exit()
14283 +{
14284 + unregister_sysctl_table(diag_sysctl_header);
14285 +}
14286 +
14287 +EXPORT_NO_SYMBOLS;
14288 +MODULE_AUTHOR("openwrt.org");
14289 +MODULE_LICENSE("GPL");
14290 +
14291 +module_init(diag_init);
14292 +module_exit(diag_exit);
14293 diff -Nur linux-2.4.30/drivers/net/diag/Makefile linux-2.4.30-brcm/drivers/net/diag/Makefile
14294 --- linux-2.4.30/drivers/net/diag/Makefile 1970-01-01 01:00:00.000000000 +0100
14295 +++ linux-2.4.30-brcm/drivers/net/diag/Makefile 2005-05-26 17:13:16.000000000 +0200
14296 @@ -0,0 +1,13 @@
14297 +#$Id$
14298 +
14299 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
14300 +
14301 +O_TARGET := diag.o
14302 +
14303 +MAC_OBJS := diag_led.o
14304 +
14305 +export-objs :=
14306 +obj-y := $(MAC_OBJS)
14307 +obj-m := $(O_TARGET)
14308 +
14309 +include $(TOPDIR)/Rules.make
14310 diff -Nur linux-2.4.30/drivers/net/et/Makefile linux-2.4.30-brcm/drivers/net/et/Makefile
14311 --- linux-2.4.30/drivers/net/et/Makefile 1970-01-01 01:00:00.000000000 +0100
14312 +++ linux-2.4.30-brcm/drivers/net/et/Makefile 2005-05-26 02:37:05.000000000 +0200
14313 @@ -0,0 +1,21 @@
14314 +#
14315 +# Makefile for the Broadcom et driver
14316 +#
14317 +# Copyright 2004, Broadcom Corporation
14318 +# All Rights Reserved.
14319 +#
14320 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14321 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14322 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14323 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14324 +#
14325 +# $Id: Makefile,v 1.1 2005/03/16 13:50:00 wbx Exp $
14326 +#
14327 +
14328 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCM47XX_CHOPS -DDMA -DBCMDRIVER
14329 +
14330 +O_TARGET := et.o
14331 +obj-y := et_linux.o etc.o etc47xx.o etc_robo.o etc_adm.o
14332 +obj-m := $(O_TARGET)
14333 +
14334 +include $(TOPDIR)/Rules.make
14335 diff -Nur linux-2.4.30/drivers/net/hnd/bcmsrom.c linux-2.4.30-brcm/drivers/net/hnd/bcmsrom.c
14336 --- linux-2.4.30/drivers/net/hnd/bcmsrom.c 1970-01-01 01:00:00.000000000 +0100
14337 +++ linux-2.4.30-brcm/drivers/net/hnd/bcmsrom.c 2005-05-22 23:00:53.000000000 +0200
14338 @@ -0,0 +1,714 @@
14339 +/*
14340 + * Misc useful routines to access NIC SROM/OTP .
14341 + *
14342 + * Copyright 2004, Broadcom Corporation
14343 + * All Rights Reserved.
14344 + *
14345 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14346 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14347 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14348 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14349 + * $Id$
14350 + */
14351 +
14352 +#include <typedefs.h>
14353 +#include <osl.h>
14354 +#include <bcmutils.h>
14355 +#include <bcmsrom.h>
14356 +#include <bcmdevs.h>
14357 +#include <bcmendian.h>
14358 +#include <sbpcmcia.h>
14359 +#include <pcicfg.h>
14360 +#include <sbutils.h>
14361 +
14362 +#include <proto/ethernet.h> /* for sprom content groking */
14363 +
14364 +#define VARS_MAX 4096 /* should be reduced */
14365 +
14366 +#define WRITE_ENABLE_DELAY 500 /* 500 ms after write enable/disable toggle */
14367 +#define WRITE_WORD_DELAY 20 /* 20 ms between each word write */
14368 +
14369 +static int initvars_srom_pci(void *osh, void *curmap, char **vars, int *count);
14370 +static int initvars_cis_pcmcia(void *sbh, void *curmap, void *osh, char **vars, int *count);
14371 +static int srom_parsecis(void *osh, uint8 *cis, char **vars, int *count);
14372 +static int sprom_cmd_pcmcia(void *osh, uint8 cmd);
14373 +static int sprom_read_pcmcia(void *osh, uint16 addr, uint16 *data);
14374 +static int sprom_write_pcmcia(void *osh, uint16 addr, uint16 data);
14375 +static int sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc);
14376 +
14377 +/*
14378 + * Initialize local vars from the right source for this platform.
14379 + * Return 0 on success, nonzero on error.
14380 + */
14381 +int
14382 +srom_var_init(void *sbh, uint bustype, void *curmap, void *osh, char **vars, int *count)
14383 +{
14384 + ASSERT(bustype == BUSTYPE(bustype));
14385 + if (vars == NULL)
14386 + return (0);
14387 +
14388 + switch (BUSTYPE(bustype)) {
14389 + case SB_BUS:
14390 + /* These two could be asserts ... */
14391 + *vars = NULL;
14392 + *count = 0;
14393 + return(0);
14394 +
14395 + case PCI_BUS:
14396 + ASSERT(curmap); /* can not be NULL */
14397 + return(initvars_srom_pci(osh, curmap, vars, count));
14398 +
14399 + case PCMCIA_BUS:
14400 + return(initvars_cis_pcmcia(sbh, curmap, osh, vars, count));
14401 +
14402 +
14403 + default:
14404 + ASSERT(0);
14405 + }
14406 + return (-1);
14407 +}
14408 +
14409 +/* support only 16-bit word read from srom */
14410 +int
14411 +srom_read(uint bustype, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf)
14412 +{
14413 + void *srom;
14414 + uint i, off, nw;
14415 +
14416 + ASSERT(bustype == BUSTYPE(bustype));
14417 +
14418 + /* check input - 16-bit access only */
14419 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
14420 + return 1;
14421 +
14422 + off = byteoff / 2;
14423 + nw = nbytes / 2;
14424 +
14425 + if (BUSTYPE(bustype) == PCI_BUS) {
14426 + if (!curmap)
14427 + return 1;
14428 + srom = (uchar*)curmap + PCI_BAR0_SPROM_OFFSET;
14429 + if (sprom_read_pci(srom, off, buf, nw, FALSE))
14430 + return 1;
14431 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
14432 + for (i = 0; i < nw; i++) {
14433 + if (sprom_read_pcmcia(osh, (uint16)(off + i), (uint16*)(buf + i)))
14434 + return 1;
14435 + }
14436 + } else {
14437 + return 1;
14438 + }
14439 +
14440 + return 0;
14441 +}
14442 +
14443 +/* support only 16-bit word write into srom */
14444 +int
14445 +srom_write(uint bustype, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf)
14446 +{
14447 + uint16 *srom;
14448 + uint i, off, nw, crc_range;
14449 + uint16 image[SPROM_SIZE], *p;
14450 + uint8 crc;
14451 + volatile uint32 val32;
14452 +
14453 + ASSERT(bustype == BUSTYPE(bustype));
14454 +
14455 + /* check input - 16-bit access only */
14456 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
14457 + return 1;
14458 +
14459 + crc_range = (((BUSTYPE(bustype) == PCMCIA_BUS) || (BUSTYPE(bustype) == SDIO_BUS)) ? SPROM_SIZE : SPROM_CRC_RANGE) * 2;
14460 +
14461 + /* if changes made inside crc cover range */
14462 + if (byteoff < crc_range) {
14463 + nw = (((byteoff + nbytes) > crc_range) ? byteoff + nbytes : crc_range) / 2;
14464 + /* read data including entire first 64 words from srom */
14465 + if (srom_read(bustype, curmap, osh, 0, nw * 2, image))
14466 + return 1;
14467 + /* make changes */
14468 + bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes);
14469 + /* calculate crc */
14470 + htol16_buf(image, crc_range);
14471 + crc = ~hndcrc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE);
14472 + ltoh16_buf(image, crc_range);
14473 + image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff);
14474 + p = image;
14475 + off = 0;
14476 + } else {
14477 + p = buf;
14478 + off = byteoff / 2;
14479 + nw = nbytes / 2;
14480 + }
14481 +
14482 + if (BUSTYPE(bustype) == PCI_BUS) {
14483 + srom = (uint16*)((uchar*)curmap + PCI_BAR0_SPROM_OFFSET);
14484 + /* enable writes to the SPROM */
14485 + val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32));
14486 + val32 |= SPROM_WRITEEN;
14487 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32);
14488 + bcm_mdelay(WRITE_ENABLE_DELAY);
14489 + /* write srom */
14490 + for (i = 0; i < nw; i++) {
14491 + W_REG(&srom[off + i], p[i]);
14492 + bcm_mdelay(WRITE_WORD_DELAY);
14493 + }
14494 + /* disable writes to the SPROM */
14495 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 & ~SPROM_WRITEEN);
14496 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
14497 + /* enable writes to the SPROM */
14498 + if (sprom_cmd_pcmcia(osh, SROM_WEN))
14499 + return 1;
14500 + bcm_mdelay(WRITE_ENABLE_DELAY);
14501 + /* write srom */
14502 + for (i = 0; i < nw; i++) {
14503 + sprom_write_pcmcia(osh, (uint16)(off + i), p[i]);
14504 + bcm_mdelay(WRITE_WORD_DELAY);
14505 + }
14506 + /* disable writes to the SPROM */
14507 + if (sprom_cmd_pcmcia(osh, SROM_WDS))
14508 + return 1;
14509 + } else {
14510 + return 1;
14511 + }
14512 +
14513 + bcm_mdelay(WRITE_ENABLE_DELAY);
14514 + return 0;
14515 +}
14516 +
14517 +
14518 +static int
14519 +srom_parsecis(void *osh, uint8 *cis, char **vars, int *count)
14520 +{
14521 + char eabuf[32];
14522 + char *vp, *base;
14523 + uint8 tup, tlen, sromrev = 1;
14524 + int i, j;
14525 + uint varsize;
14526 + bool ag_init = FALSE;
14527 + uint16 w;
14528 +
14529 + ASSERT(vars);
14530 + ASSERT(count);
14531 +
14532 + base = vp = MALLOC(osh, VARS_MAX);
14533 + ASSERT(vp);
14534 +
14535 + i = 0;
14536 + do {
14537 + tup = cis[i++];
14538 + tlen = cis[i++];
14539 + if ((i + tlen) >= CIS_SIZE)
14540 + break;
14541 +
14542 + switch (tup) {
14543 + case CISTPL_MANFID:
14544 + vp += sprintf(vp, "manfid=%d", (cis[i + 1] << 8) + cis[i]);
14545 + vp++;
14546 + vp += sprintf(vp, "prodid=%d", (cis[i + 3] << 8) + cis[i + 2]);
14547 + vp++;
14548 + break;
14549 +
14550 + case CISTPL_FUNCE:
14551 + if (cis[i] == LAN_NID) {
14552 + ASSERT(cis[i + 1] == ETHER_ADDR_LEN);
14553 + bcm_ether_ntoa((uchar*)&cis[i + 2], eabuf);
14554 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
14555 + vp++;
14556 + }
14557 + break;
14558 +
14559 + case CISTPL_CFTABLE:
14560 + vp += sprintf(vp, "regwindowsz=%d", (cis[i + 7] << 8) | cis[i + 6]);
14561 + vp++;
14562 + break;
14563 +
14564 + case CISTPL_BRCM_HNBU:
14565 + switch (cis[i]) {
14566 + case HNBU_CHIPID:
14567 + vp += sprintf(vp, "vendid=%d", (cis[i + 2] << 8) + cis[i + 1]);
14568 + vp++;
14569 + vp += sprintf(vp, "devid=%d", (cis[i + 4] << 8) + cis[i + 3]);
14570 + vp++;
14571 + if (tlen == 7) {
14572 + vp += sprintf(vp, "chiprev=%d", (cis[i + 6] << 8) + cis[i + 5]);
14573 + vp++;
14574 + }
14575 + break;
14576 +
14577 + case HNBU_BOARDREV:
14578 + vp += sprintf(vp, "boardrev=%d", cis[i + 1]);
14579 + vp++;
14580 + break;
14581 +
14582 + case HNBU_AA:
14583 + vp += sprintf(vp, "aa0=%d", cis[i + 1]);
14584 + vp++;
14585 + break;
14586 +
14587 + case HNBU_AG:
14588 + vp += sprintf(vp, "ag0=%d", cis[i + 1]);
14589 + vp++;
14590 + ag_init = TRUE;
14591 + break;
14592 +
14593 + case HNBU_CC:
14594 + vp += sprintf(vp, "cc=%d", cis[i + 1]);
14595 + vp++;
14596 + break;
14597 +
14598 + case HNBU_PAPARMS:
14599 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + tlen - 1]);
14600 + vp++;
14601 + if (tlen == 9) {
14602 + /* New version */
14603 + for (j = 0; j < 3; j++) {
14604 + vp += sprintf(vp, "pa0b%d=%d", j,
14605 + (cis[i + (j * 2) + 2] << 8) + cis[i + (j * 2) + 1]);
14606 + vp++;
14607 + }
14608 + vp += sprintf(vp, "pa0itssit=%d", cis[i + 7]);
14609 + vp++;
14610 + }
14611 + break;
14612 +
14613 + case HNBU_OEM:
14614 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
14615 + cis[i + 1], cis[i + 2], cis[i + 3], cis[i + 4],
14616 + cis[i + 5], cis[i + 6], cis[i + 7], cis[i + 8]);
14617 + vp++;
14618 + break;
14619 + case HNBU_BOARDFLAGS:
14620 + w = (cis[i + 2] << 8) + cis[i + 1];
14621 + if (w == 0xffff) w = 0;
14622 + vp += sprintf(vp, "boardflags=%d", w);
14623 + vp++;
14624 + break;
14625 + case HNBU_LED:
14626 + if (cis[i + 1] != 0xff) {
14627 + vp += sprintf(vp, "wl0gpio0=%d", cis[i + 1]);
14628 + vp++;
14629 + }
14630 + if (cis[i + 2] != 0xff) {
14631 + vp += sprintf(vp, "wl0gpio1=%d", cis[i + 2]);
14632 + vp++;
14633 + }
14634 + if (cis[i + 3] != 0xff) {
14635 + vp += sprintf(vp, "wl0gpio2=%d", cis[i + 3]);
14636 + vp++;
14637 + }
14638 + if (cis[i + 4] != 0xff) {
14639 + vp += sprintf(vp, "wl0gpio3=%d", cis[i + 4]);
14640 + vp++;
14641 + }
14642 + break;
14643 + }
14644 + break;
14645 +
14646 + }
14647 + i += tlen;
14648 + } while (tup != 0xff);
14649 +
14650 + /* Set the srom version */
14651 + vp += sprintf(vp, "sromrev=%d", sromrev);
14652 + vp++;
14653 +
14654 + /* For now just set boardflags2 to zero */
14655 + vp += sprintf(vp, "boardflags2=0");
14656 + vp++;
14657 +
14658 + /* if there is no antenna gain field, set default */
14659 + if (ag_init == FALSE) {
14660 + vp += sprintf(vp, "ag0=%d", 0xff);
14661 + vp++;
14662 + }
14663 +
14664 + /* final nullbyte terminator */
14665 + *vp++ = '\0';
14666 + varsize = (uint)(vp - base);
14667 +
14668 + ASSERT((vp - base) < VARS_MAX);
14669 +
14670 + if (varsize == VARS_MAX) {
14671 + *vars = base;
14672 + } else {
14673 + vp = MALLOC(osh, varsize);
14674 + ASSERT(vp);
14675 + bcopy(base, vp, varsize);
14676 + MFREE(osh, base, VARS_MAX);
14677 + *vars = vp;
14678 + }
14679 + *count = varsize;
14680 +
14681 + return (0);
14682 +}
14683 +
14684 +
14685 +/* set PCMCIA sprom command register */
14686 +static int
14687 +sprom_cmd_pcmcia(void *osh, uint8 cmd)
14688 +{
14689 + uint8 status = 0;
14690 + uint wait_cnt = 1000;
14691 +
14692 + /* write sprom command register */
14693 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_CS, &cmd, 1);
14694 +
14695 + /* wait status */
14696 + while (wait_cnt--) {
14697 + OSL_PCMCIA_READ_ATTR(osh, SROM_CS, &status, 1);
14698 + if (status & SROM_DONE)
14699 + return 0;
14700 + }
14701 +
14702 + return 1;
14703 +}
14704 +
14705 +/* read a word from the PCMCIA srom */
14706 +static int
14707 +sprom_read_pcmcia(void *osh, uint16 addr, uint16 *data)
14708 +{
14709 + uint8 addr_l, addr_h, data_l, data_h;
14710 +
14711 + addr_l = (uint8)((addr * 2) & 0xff);
14712 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
14713 +
14714 + /* set address */
14715 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
14716 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
14717 +
14718 + /* do read */
14719 + if (sprom_cmd_pcmcia(osh, SROM_READ))
14720 + return 1;
14721 +
14722 + /* read data */
14723 + data_h = data_l = 0;
14724 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAH, &data_h, 1);
14725 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAL, &data_l, 1);
14726 +
14727 + *data = (data_h << 8) | data_l;
14728 + return 0;
14729 +}
14730 +
14731 +/* write a word to the PCMCIA srom */
14732 +static int
14733 +sprom_write_pcmcia(void *osh, uint16 addr, uint16 data)
14734 +{
14735 + uint8 addr_l, addr_h, data_l, data_h;
14736 +
14737 + addr_l = (uint8)((addr * 2) & 0xff);
14738 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
14739 + data_l = (uint8)(data & 0xff);
14740 + data_h = (uint8)((data >> 8) & 0xff);
14741 +
14742 + /* set address */
14743 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
14744 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
14745 +
14746 + /* write data */
14747 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAH, &data_h, 1);
14748 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAL, &data_l, 1);
14749 +
14750 + /* do write */
14751 + return sprom_cmd_pcmcia(osh, SROM_WRITE);
14752 +}
14753 +
14754 +/*
14755 + * Read in and validate sprom.
14756 + * Return 0 on success, nonzero on error.
14757 + */
14758 +static int
14759 +sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc)
14760 +{
14761 + uint8 chk8;
14762 + uint i;
14763 +
14764 + /* read the sprom */
14765 + for (i = 0; i < nwords; i++)
14766 + buf[i] = R_REG(&sprom[wordoff + i]);
14767 +
14768 + if (check_crc) {
14769 + /* fixup the endianness so crc8 will pass */
14770 + htol16_buf(buf, nwords * 2);
14771 + if ((chk8 = hndcrc8((uchar*)buf, nwords * 2, CRC8_INIT_VALUE)) != CRC8_GOOD_VALUE)
14772 + return (1);
14773 + /* now correct the endianness of the byte array */
14774 + ltoh16_buf(buf, nwords * 2);
14775 + }
14776 +
14777 + return (0);
14778 +}
14779 +
14780 +/*
14781 + * Initialize nonvolatile variable table from sprom.
14782 + * Return 0 on success, nonzero on error.
14783 + */
14784 +
14785 +static int
14786 +initvars_srom_pci(void *osh, void *curmap, char **vars, int *count)
14787 +{
14788 + uint16 w, b[64];
14789 + uint8 sromrev;
14790 + struct ether_addr ea;
14791 + char eabuf[32];
14792 + uint32 bfl;
14793 + int c, woff, i;
14794 + char *vp, *base;
14795 +
14796 + if (sprom_read_pci((void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, sizeof(b)/sizeof(b[0]), TRUE))
14797 + return (-1);
14798 +
14799 + /* top word of sprom contains version and crc8 */
14800 + sromrev = b[63] & 0xff;
14801 + /* bcm4401 sroms misprogrammed */
14802 + if (sromrev == 0x10)
14803 + sromrev = 1;
14804 + if ((sromrev != 1) && (sromrev != 2))
14805 + return (-2);
14806 +
14807 + ASSERT(vars);
14808 + ASSERT(count);
14809 +
14810 + base = vp = MALLOC(osh, VARS_MAX);
14811 + ASSERT(vp);
14812 +
14813 + vp += sprintf(vp, "sromrev=%d", sromrev);
14814 + vp++;
14815 +
14816 + if (sromrev >= 2) {
14817 + /* New section takes over the 4th hardware function space */
14818 +
14819 + /* Word 29 is max power 11a high/low */
14820 + w = b[29];
14821 + vp += sprintf(vp, "pa1himaxpwr=%d", w & 0xff);
14822 + vp++;
14823 + vp += sprintf(vp, "pa1lomaxpwr=%d", (w >> 8) & 0xff);
14824 + vp++;
14825 +
14826 + /* Words 30-32 set the 11alow pa settings,
14827 + * 33-35 are the 11ahigh ones.
14828 + */
14829 + for (i = 0; i < 3; i++) {
14830 + vp += sprintf(vp, "pa1lob%d=%d", i, b[30 + i]);
14831 + vp++;
14832 + vp += sprintf(vp, "pa1hib%d=%d", i, b[33 + i]);
14833 + vp++;
14834 + }
14835 + w = b[59];
14836 + if (w == 0)
14837 + vp += sprintf(vp, "ccode=");
14838 + else
14839 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff));
14840 + vp++;
14841 +
14842 + }
14843 +
14844 + /* parameter section of sprom starts at byte offset 72 */
14845 + woff = 72/2;
14846 +
14847 + /* first 6 bytes are il0macaddr */
14848 + ea.octet[0] = (b[woff] >> 8) & 0xff;
14849 + ea.octet[1] = b[woff] & 0xff;
14850 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
14851 + ea.octet[3] = b[woff+1] & 0xff;
14852 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
14853 + ea.octet[5] = b[woff+2] & 0xff;
14854 + woff += ETHER_ADDR_LEN/2 ;
14855 + bcm_ether_ntoa((uchar*)&ea, eabuf);
14856 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
14857 + vp++;
14858 +
14859 + /* next 6 bytes are et0macaddr */
14860 + ea.octet[0] = (b[woff] >> 8) & 0xff;
14861 + ea.octet[1] = b[woff] & 0xff;
14862 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
14863 + ea.octet[3] = b[woff+1] & 0xff;
14864 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
14865 + ea.octet[5] = b[woff+2] & 0xff;
14866 + woff += ETHER_ADDR_LEN/2 ;
14867 + bcm_ether_ntoa((uchar*)&ea, eabuf);
14868 + vp += sprintf(vp, "et0macaddr=%s", eabuf);
14869 + vp++;
14870 +
14871 + /* next 6 bytes are et1macaddr */
14872 + ea.octet[0] = (b[woff] >> 8) & 0xff;
14873 + ea.octet[1] = b[woff] & 0xff;
14874 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
14875 + ea.octet[3] = b[woff+1] & 0xff;
14876 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
14877 + ea.octet[5] = b[woff+2] & 0xff;
14878 + woff += ETHER_ADDR_LEN/2 ;
14879 + bcm_ether_ntoa((uchar*)&ea, eabuf);
14880 + vp += sprintf(vp, "et1macaddr=%s", eabuf);
14881 + vp++;
14882 +
14883 + /*
14884 + * Enet phy settings one or two singles or a dual
14885 + * Bits 4-0 : MII address for enet0 (0x1f for not there)
14886 + * Bits 9-5 : MII address for enet1 (0x1f for not there)
14887 + * Bit 14 : Mdio for enet0
14888 + * Bit 15 : Mdio for enet1
14889 + */
14890 + w = b[woff];
14891 + vp += sprintf(vp, "et0phyaddr=%d", (w & 0x1f));
14892 + vp++;
14893 + vp += sprintf(vp, "et1phyaddr=%d", ((w >> 5) & 0x1f));
14894 + vp++;
14895 + vp += sprintf(vp, "et0mdcport=%d", ((w >> 14) & 0x1));
14896 + vp++;
14897 + vp += sprintf(vp, "et1mdcport=%d", ((w >> 15) & 0x1));
14898 + vp++;
14899 +
14900 + /* Word 46 has board rev, antennas 0/1 & Country code/control */
14901 + w = b[46];
14902 + vp += sprintf(vp, "boardrev=%d", w & 0xff);
14903 + vp++;
14904 +
14905 + if (sromrev > 1)
14906 + vp += sprintf(vp, "cctl=%d", (w >> 8) & 0xf);
14907 + else
14908 + vp += sprintf(vp, "cc=%d", (w >> 8) & 0xf);
14909 + vp++;
14910 +
14911 + vp += sprintf(vp, "aa0=%d", (w >> 12) & 0x3);
14912 + vp++;
14913 +
14914 + vp += sprintf(vp, "aa1=%d", (w >> 14) & 0x3);
14915 + vp++;
14916 +
14917 + /* Words 47-49 set the (wl) pa settings */
14918 + woff = 47;
14919 +
14920 + for (i = 0; i < 3; i++) {
14921 + vp += sprintf(vp, "pa0b%d=%d", i, b[woff+i]);
14922 + vp++;
14923 + vp += sprintf(vp, "pa1b%d=%d", i, b[woff+i+6]);
14924 + vp++;
14925 + }
14926 +
14927 + /*
14928 + * Words 50-51 set the customer-configured wl led behavior.
14929 + * 8 bits/gpio pin. High bit: activehi=0, activelo=1;
14930 + * LED behavior values defined in wlioctl.h .
14931 + */
14932 + w = b[50];
14933 + if ((w != 0) && (w != 0xffff)) {
14934 + /* gpio0 */
14935 + vp += sprintf(vp, "wl0gpio0=%d", (w & 0xff));
14936 + vp++;
14937 +
14938 + /* gpio1 */
14939 + vp += sprintf(vp, "wl0gpio1=%d", (w >> 8) & 0xff);
14940 + vp++;
14941 + }
14942 + w = b[51];
14943 + if ((w != 0) && (w != 0xffff)) {
14944 + /* gpio2 */
14945 + vp += sprintf(vp, "wl0gpio2=%d", w & 0xff);
14946 + vp++;
14947 +
14948 + /* gpio3 */
14949 + vp += sprintf(vp, "wl0gpio3=%d", (w >> 8) & 0xff);
14950 + vp++;
14951 + }
14952 +
14953 + /* Word 52 is max power 0/1 */
14954 + w = b[52];
14955 + vp += sprintf(vp, "pa0maxpwr=%d", w & 0xff);
14956 + vp++;
14957 + vp += sprintf(vp, "pa1maxpwr=%d", (w >> 8) & 0xff);
14958 + vp++;
14959 +
14960 + /* Word 56 is idle tssi target 0/1 */
14961 + w = b[56];
14962 + vp += sprintf(vp, "pa0itssit=%d", w & 0xff);
14963 + vp++;
14964 + vp += sprintf(vp, "pa1itssit=%d", (w >> 8) & 0xff);
14965 + vp++;
14966 +
14967 + /* Word 57 is boardflags, if not programmed make it zero */
14968 + bfl = (uint32)b[57];
14969 + if (bfl == 0xffff) bfl = 0;
14970 + if (sromrev > 1) {
14971 + /* Word 28 is boardflags2 */
14972 + bfl |= (uint32)b[28] << 16;
14973 + }
14974 + vp += sprintf(vp, "boardflags=%d", bfl);
14975 + vp++;
14976 +
14977 + /* Word 58 is antenna gain 0/1 */
14978 + w = b[58];
14979 + vp += sprintf(vp, "ag0=%d", w & 0xff);
14980 + vp++;
14981 +
14982 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff);
14983 + vp++;
14984 +
14985 + if (sromrev == 1) {
14986 + /* set the oem string */
14987 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
14988 + ((b[59] >> 8) & 0xff), (b[59] & 0xff),
14989 + ((b[60] >> 8) & 0xff), (b[60] & 0xff),
14990 + ((b[61] >> 8) & 0xff), (b[61] & 0xff),
14991 + ((b[62] >> 8) & 0xff), (b[62] & 0xff));
14992 + vp++;
14993 + } else {
14994 + /* Word 60 OFDM tx power offset from CCK level */
14995 + /* OFDM Power Offset - opo */
14996 + vp += sprintf(vp, "opo=%d", b[60] & 0xff);
14997 + vp++;
14998 + }
14999 +
15000 + /* final nullbyte terminator */
15001 + *vp++ = '\0';
15002 +
15003 + c = (int)(vp - base);
15004 + ASSERT((vp - base) <= VARS_MAX);
15005 +
15006 + if (c == VARS_MAX) {
15007 + *vars = base;
15008 + } else {
15009 + vp = MALLOC(osh, c);
15010 + ASSERT(vp);
15011 + bcopy(base, vp, c);
15012 + MFREE(osh, base, VARS_MAX);
15013 + *vars = vp;
15014 + }
15015 + *count = c;
15016 +
15017 + return (0);
15018 +}
15019 +
15020 +/*
15021 + * Read the cis and call parsecis to initialize the vars.
15022 + * Return 0 on success, nonzero on error.
15023 + */
15024 +static int
15025 +initvars_cis_pcmcia(void *sbh, void *curmap, void *osh, char **vars, int *count)
15026 +{
15027 + uint8 *cis = NULL;
15028 + int rc;
15029 + uint data_sz;
15030 +
15031 + data_sz = (sb_pcmciarev(sbh) == 1) ? (SPROM_SIZE * 2) : CIS_SIZE;
15032 +
15033 + if ((cis = MALLOC(osh, data_sz)) == NULL)
15034 + return (-2);
15035 +
15036 + if (sb_pcmciarev(sbh) == 1) {
15037 + if (srom_read(PCMCIA_BUS, (void *)NULL, osh, 0, data_sz, (uint16 *)cis)) {
15038 + MFREE(osh, cis, data_sz);
15039 + return (-1);
15040 + }
15041 + /* fix up endianess for 16-bit data vs 8-bit parsing */
15042 + ltoh16_buf((uint16 *)cis, data_sz);
15043 + } else
15044 + OSL_PCMCIA_READ_ATTR(osh, 0, cis, data_sz);
15045 +
15046 + rc = srom_parsecis(osh, cis, vars, count);
15047 +
15048 + MFREE(osh, cis, data_sz);
15049 +
15050 + return (rc);
15051 +}
15052 +
15053 diff -Nur linux-2.4.30/drivers/net/hnd/bcmutils.c linux-2.4.30-brcm/drivers/net/hnd/bcmutils.c
15054 --- linux-2.4.30/drivers/net/hnd/bcmutils.c 1970-01-01 01:00:00.000000000 +0100
15055 +++ linux-2.4.30-brcm/drivers/net/hnd/bcmutils.c 2005-05-24 20:26:25.000000000 +0200
15056 @@ -0,0 +1,862 @@
15057 +/*
15058 + * Misc useful OS-independent routines.
15059 + *
15060 + * Copyright 2004, Broadcom Corporation
15061 + * All Rights Reserved.
15062 + *
15063 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
15064 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
15065 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
15066 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
15067 + * $Id$
15068 + */
15069 +
15070 +#include <typedefs.h>
15071 +#include <osl.h>
15072 +#include <bcmnvram.h>
15073 +#include <bcmutils.h>
15074 +#include <bcmendian.h>
15075 +#include <bcmdevs.h>
15076 +
15077 +#ifdef BCMDRIVER
15078 +/* copy a pkt buffer chain into a buffer */
15079 +uint
15080 +pktcopy(void *drv, void *p, uint offset, int len, uchar *buf)
15081 +{
15082 + uint n, ret = 0;
15083 +
15084 + if (len < 0)
15085 + len = 4096; /* "infinite" */
15086 +
15087 + /* skip 'offset' bytes */
15088 + for (; p && offset; p = PKTNEXT(drv, p)) {
15089 + if (offset < (uint)PKTLEN(drv, p))
15090 + break;
15091 + offset -= PKTLEN(drv, p);
15092 + }
15093 +
15094 + if (!p)
15095 + return 0;
15096 +
15097 + /* copy the data */
15098 + for (; p && len; p = PKTNEXT(drv, p)) {
15099 + n = MIN((uint)PKTLEN(drv, p) - offset, (uint)len);
15100 + bcopy(PKTDATA(drv, p) + offset, buf, n);
15101 + buf += n;
15102 + len -= n;
15103 + ret += n;
15104 + offset = 0;
15105 + }
15106 +
15107 + return ret;
15108 +}
15109 +
15110 +/* return total length of buffer chain */
15111 +uint
15112 +pkttotlen(void *drv, void *p)
15113 +{
15114 + uint total;
15115 +
15116 + total = 0;
15117 + for (; p; p = PKTNEXT(drv, p))
15118 + total += PKTLEN(drv, p);
15119 + return (total);
15120 +}
15121 +
15122 +void
15123 +pktq_init(struct pktq *q, uint maxlen, const bool prio_map[])
15124 +{
15125 + q->head = q->tail = NULL;
15126 + q->maxlen = maxlen;
15127 + q->len = 0;
15128 + if (prio_map) {
15129 + q->priority = TRUE;
15130 + bcopy(prio_map, q->prio_map, sizeof(q->prio_map));
15131 + }
15132 + else
15133 + q->priority = FALSE;
15134 +}
15135 +
15136 +/* should always check pktq_full before calling pktenq */
15137 +void
15138 +pktenq(struct pktq *q, void *p, bool lifo)
15139 +{
15140 + void *next, *prev;
15141 +
15142 + /* allow 10 pkts slack */
15143 + ASSERT(q->len < (q->maxlen + 10));
15144 +
15145 + /* Queueing chains not allowed */
15146 + ASSERT(PKTLINK(p) == NULL);
15147 +
15148 + /* Queue is empty */
15149 + if (q->tail == NULL) {
15150 + ASSERT(q->head == NULL);
15151 + q->head = q->tail = p;
15152 + }
15153 +
15154 + /* Insert at head or tail */
15155 + else if (q->priority == FALSE) {
15156 + /* Insert at head (LIFO) */
15157 + if (lifo) {
15158 + PKTSETLINK(p, q->head);
15159 + q->head = p;
15160 + }
15161 + /* Insert at tail (FIFO) */
15162 + else {
15163 + ASSERT(PKTLINK(q->tail) == NULL);
15164 + PKTSETLINK(q->tail, p);
15165 + PKTSETLINK(p, NULL);
15166 + q->tail = p;
15167 + }
15168 + }
15169 +
15170 + /* Insert by priority */
15171 + else {
15172 + /* legal priorities 0-7 */
15173 + ASSERT(PKTPRIO(p) <= MAXPRIO);
15174 +
15175 + ASSERT(q->head);
15176 + ASSERT(q->tail);
15177 + /* Shortcut to insertion at tail */
15178 + if (_pktq_pri(q, PKTPRIO(p)) < _pktq_pri(q, PKTPRIO(q->tail)) ||
15179 + (!lifo && _pktq_pri(q, PKTPRIO(p)) <= _pktq_pri(q, PKTPRIO(q->tail)))) {
15180 + prev = q->tail;
15181 + next = NULL;
15182 + }
15183 + /* Insert at head or in the middle */
15184 + else {
15185 + prev = NULL;
15186 + next = q->head;
15187 + }
15188 + /* Walk the queue */
15189 + for (; next; prev = next, next = PKTLINK(next)) {
15190 + /* Priority queue invariant */
15191 + ASSERT(!prev || _pktq_pri(q, PKTPRIO(prev)) >= _pktq_pri(q, PKTPRIO(next)));
15192 + /* Insert at head of string of packets of same priority (LIFO) */
15193 + if (lifo) {
15194 + if (_pktq_pri(q, PKTPRIO(p)) >= _pktq_pri(q, PKTPRIO(next)))
15195 + break;
15196 + }
15197 + /* Insert at tail of string of packets of same priority (FIFO) */
15198 + else {
15199 + if (_pktq_pri(q, PKTPRIO(p)) > _pktq_pri(q, PKTPRIO(next)))
15200 + break;
15201 + }
15202 + }
15203 + /* Insert at tail */
15204 + if (next == NULL) {
15205 + ASSERT(PKTLINK(q->tail) == NULL);
15206 + PKTSETLINK(q->tail, p);
15207 + PKTSETLINK(p, NULL);
15208 + q->tail = p;
15209 + }
15210 + /* Insert in the middle */
15211 + else if (prev) {
15212 + PKTSETLINK(prev, p);
15213 + PKTSETLINK(p, next);
15214 + }
15215 + /* Insert at head */
15216 + else {
15217 + PKTSETLINK(p, q->head);
15218 + q->head = p;
15219 + }
15220 + }
15221 +
15222 + /* List invariants after insertion */
15223 + ASSERT(q->head);
15224 + ASSERT(PKTLINK(q->tail) == NULL);
15225 +
15226 + q->len++;
15227 +}
15228 +
15229 +/* dequeue packet at head */
15230 +void*
15231 +pktdeq(struct pktq *q)
15232 +{
15233 + void *p;
15234 +
15235 + if ((p = q->head)) {
15236 + ASSERT(q->tail);
15237 + q->head = PKTLINK(p);
15238 + PKTSETLINK(p, NULL);
15239 + q->len--;
15240 + if (q->head == NULL)
15241 + q->tail = NULL;
15242 + }
15243 + else {
15244 + ASSERT(q->tail == NULL);
15245 + }
15246 +
15247 + return (p);
15248 +}
15249 +
15250 +/* dequeue packet at tail */
15251 +void*
15252 +pktdeqtail(struct pktq *q)
15253 +{
15254 + void *p;
15255 + void *next, *prev;
15256 +
15257 + if (q->head == q->tail) { /* last packet on queue or queue empty */
15258 + p = q->head;
15259 + q->head = q->tail = NULL;
15260 + q->len = 0;
15261 + return(p);
15262 + }
15263 +
15264 + /* start walk at head */
15265 + prev = NULL;
15266 + next = q->head;
15267 +
15268 + /* Walk the queue to find prev of q->tail */
15269 + for (; next; prev = next, next = PKTLINK(next)) {
15270 + if (next == q->tail)
15271 + break;
15272 + }
15273 +
15274 + ASSERT(prev);
15275 +
15276 + PKTSETLINK(prev, NULL);
15277 + q->tail = prev;
15278 + q->len--;
15279 + p = next;
15280 +
15281 + return (p);
15282 +}
15283 +
15284 +unsigned char bcm_ctype[] = {
15285 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */
15286 + _BCM_C,_BCM_C|_BCM_S,_BCM_C|_BCM_S,_BCM_C|_BCM_S,_BCM_C|_BCM_S,_BCM_C|_BCM_S,_BCM_C,_BCM_C, /* 8-15 */
15287 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */
15288 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */
15289 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */
15290 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */
15291 + _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */
15292 + _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */
15293 + _BCM_P,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U, /* 64-71 */
15294 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */
15295 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */
15296 + _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */
15297 + _BCM_P,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L, /* 96-103 */
15298 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */
15299 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */
15300 + _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */
15301 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
15302 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
15303 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 160-175 */
15304 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 176-191 */
15305 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 192-207 */
15306 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_L, /* 208-223 */
15307 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 224-239 */
15308 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L /* 240-255 */
15309 +};
15310 +
15311 +uchar
15312 +bcm_toupper(uchar c)
15313 +{
15314 + if (bcm_islower(c))
15315 + c -= 'a'-'A';
15316 + return (c);
15317 +}
15318 +
15319 +ulong
15320 +bcm_strtoul(char *cp, char **endp, uint base)
15321 +{
15322 + ulong result, value;
15323 + bool minus;
15324 +
15325 + minus = FALSE;
15326 +
15327 + while (bcm_isspace(*cp))
15328 + cp++;
15329 +
15330 + if (cp[0] == '+')
15331 + cp++;
15332 + else if (cp[0] == '-') {
15333 + minus = TRUE;
15334 + cp++;
15335 + }
15336 +
15337 + if (base == 0) {
15338 + if (cp[0] == '0') {
15339 + if ((cp[1] == 'x') || (cp[1] == 'X')) {
15340 + base = 16;
15341 + cp = &cp[2];
15342 + } else {
15343 + base = 8;
15344 + cp = &cp[1];
15345 + }
15346 + } else
15347 + base = 10;
15348 + } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) {
15349 + cp = &cp[2];
15350 + }
15351 +
15352 + result = 0;
15353 +
15354 + while (bcm_isxdigit(*cp) &&
15355 + (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) {
15356 + result = result*base + value;
15357 + cp++;
15358 + }
15359 +
15360 + if (minus)
15361 + result = (ulong)(result * -1);
15362 +
15363 + if (endp)
15364 + *endp = (char *)cp;
15365 +
15366 + return (result);
15367 +}
15368 +
15369 +uint
15370 +bcm_atoi(char *s)
15371 +{
15372 + uint n;
15373 +
15374 + n = 0;
15375 +
15376 + while (bcm_isdigit(*s))
15377 + n = (n * 10) + *s++ - '0';
15378 + return (n);
15379 +}
15380 +
15381 +/* return pointer to location of substring 'needle' in 'haystack' */
15382 +char*
15383 +bcmstrstr(char *haystack, char *needle)
15384 +{
15385 + int len, nlen;
15386 + int i;
15387 +
15388 + if ((haystack == NULL) || (needle == NULL))
15389 + return (haystack);
15390 +
15391 + nlen = strlen(needle);
15392 + len = strlen(haystack) - nlen + 1;
15393 +
15394 + for (i = 0; i < len; i++)
15395 + if (bcmp(needle, &haystack[i], nlen) == 0)
15396 + return (&haystack[i]);
15397 + return (NULL);
15398 +}
15399 +
15400 +char*
15401 +bcmstrcat(char *dest, const char *src)
15402 +{
15403 + strcpy(&dest[strlen(dest)], src);
15404 + return (dest);
15405 +}
15406 +
15407 +#if defined(CONFIG_USBRNDIS_RETAIL) || defined(NDIS_MINIPORT_DRIVER)
15408 +/* registry routine buffer preparation utility functions:
15409 + * parameter order is like strncpy, but returns count
15410 + * of bytes copied. Minimum bytes copied is null char(1)/wchar(2)
15411 + */
15412 +ulong
15413 +wchar2ascii(
15414 + char *abuf,
15415 + ushort *wbuf,
15416 + ushort wbuflen,
15417 + ulong abuflen
15418 +)
15419 +{
15420 + ulong copyct = 1;
15421 + ushort i;
15422 +
15423 + if (abuflen == 0)
15424 + return 0;
15425 +
15426 + /* wbuflen is in bytes */
15427 + wbuflen /= sizeof(ushort);
15428 +
15429 + for (i = 0; i < wbuflen; ++i) {
15430 + if (--abuflen == 0)
15431 + break;
15432 + *abuf++ = (char) *wbuf++;
15433 + ++copyct;
15434 + }
15435 + *abuf = '\0';
15436 +
15437 + return copyct;
15438 +}
15439 +#endif
15440 +
15441 +char*
15442 +bcm_ether_ntoa(char *ea, char *buf)
15443 +{
15444 + sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x",
15445 + (uchar)ea[0]&0xff, (uchar)ea[1]&0xff, (uchar)ea[2]&0xff,
15446 + (uchar)ea[3]&0xff, (uchar)ea[4]&0xff, (uchar)ea[5]&0xff);
15447 + return (buf);
15448 +}
15449 +
15450 +/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
15451 +int
15452 +bcm_ether_atoe(char *p, char *ea)
15453 +{
15454 + int i = 0;
15455 +
15456 + for (;;) {
15457 + ea[i++] = (char) bcm_strtoul(p, &p, 16);
15458 + if (!*p++ || i == 6)
15459 + break;
15460 + }
15461 +
15462 + return (i == 6);
15463 +}
15464 +
15465 +void
15466 +bcm_mdelay(uint ms)
15467 +{
15468 + uint i;
15469 +
15470 + for (i = 0; i < ms; i++) {
15471 + OSL_DELAY(1000);
15472 + }
15473 +}
15474 +
15475 +/*
15476 + * Search the name=value vars for a specific one and return its value.
15477 + * Returns NULL if not found.
15478 + */
15479 +char*
15480 +getvar(char *vars, char *name)
15481 +{
15482 + char *s;
15483 + int len;
15484 +
15485 + len = strlen(name);
15486 +
15487 + /* first look in vars[] */
15488 + for (s = vars; s && *s; ) {
15489 + if ((bcmp(s, name, len) == 0) && (s[len] == '='))
15490 + return (&s[len+1]);
15491 +
15492 + while (*s++)
15493 + ;
15494 + }
15495 +
15496 + /* then query nvram */
15497 + return (BCMINIT(nvram_get)(name));
15498 +}
15499 +
15500 +/*
15501 + * Search the vars for a specific one and return its value as
15502 + * an integer. Returns 0 if not found.
15503 + */
15504 +int
15505 +getintvar(char *vars, char *name)
15506 +{
15507 + char *val;
15508 +
15509 + if ((val = getvar(vars, name)) == NULL)
15510 + return (0);
15511 +
15512 + return (bcm_strtoul(val, NULL, 0));
15513 +}
15514 +
15515 +/* Return gpio pin number assigned to the named pin */
15516 +/*
15517 +* Variable should be in format:
15518 +*
15519 +* gpio<N>=pin_name
15520 +*
15521 +* 'def_pin' is returned if there is no such variable found.
15522 +*/
15523 +uint
15524 +getgpiopin(char *vars, char *pin_name, uint def_pin)
15525 +{
15526 + char name[] = "gpioXXXX";
15527 + char *val;
15528 + uint pin;
15529 +
15530 + /* Go thru all possibilities till a match in pin name */
15531 + for (pin = 0; pin < GPIO_NUMPINS; pin ++) {
15532 + sprintf(name, "gpio%d", pin);
15533 + val = getvar(vars, name);
15534 + if (val && !strcmp(val, pin_name))
15535 + return pin;
15536 + }
15537 + return def_pin;
15538 +}
15539 +
15540 +#endif /* #ifdef BCMDRIVER */
15541 +
15542 +/*******************************************************************************
15543 + * crc8
15544 + *
15545 + * Computes a crc8 over the input data using the polynomial:
15546 + *
15547 + * x^8 + x^7 +x^6 + x^4 + x^2 + 1
15548 + *
15549 + * The caller provides the initial value (either CRC8_INIT_VALUE
15550 + * or the previous returned value) to allow for processing of
15551 + * discontiguous blocks of data. When generating the CRC the
15552 + * caller is responsible for complementing the final return value
15553 + * and inserting it into the byte stream. When checking, a final
15554 + * return value of CRC8_GOOD_VALUE indicates a valid CRC.
15555 + *
15556 + * Reference: Dallas Semiconductor Application Note 27
15557 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
15558 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
15559 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
15560 + *
15561 + ******************************************************************************/
15562 +
15563 +static uint8 crc8_table[256] = {
15564 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
15565 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
15566 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
15567 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
15568 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
15569 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
15570 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
15571 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
15572 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
15573 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
15574 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
15575 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
15576 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
15577 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
15578 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
15579 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
15580 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
15581 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
15582 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
15583 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
15584 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
15585 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
15586 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
15587 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
15588 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
15589 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
15590 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
15591 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
15592 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
15593 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
15594 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
15595 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
15596 +};
15597 +
15598 +#define CRC_INNER_LOOP(n, c, x) \
15599 + (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff]
15600 +
15601 +uint8
15602 +hndcrc8(
15603 + uint8 *pdata, /* pointer to array of data to process */
15604 + uint nbytes, /* number of input data bytes to process */
15605 + uint8 crc /* either CRC8_INIT_VALUE or previous return value */
15606 +)
15607 +{
15608 + /* hard code the crc loop instead of using CRC_INNER_LOOP macro
15609 + * to avoid the undefined and unnecessary (uint8 >> 8) operation. */
15610 + while (nbytes-- > 0)
15611 + crc = crc8_table[(crc ^ *pdata++) & 0xff];
15612 +
15613 + return crc;
15614 +}
15615 +
15616 +/*******************************************************************************
15617 + * crc16
15618 + *
15619 + * Computes a crc16 over the input data using the polynomial:
15620 + *
15621 + * x^16 + x^12 +x^5 + 1
15622 + *
15623 + * The caller provides the initial value (either CRC16_INIT_VALUE
15624 + * or the previous returned value) to allow for processing of
15625 + * discontiguous blocks of data. When generating the CRC the
15626 + * caller is responsible for complementing the final return value
15627 + * and inserting it into the byte stream. When checking, a final
15628 + * return value of CRC16_GOOD_VALUE indicates a valid CRC.
15629 + *
15630 + * Reference: Dallas Semiconductor Application Note 27
15631 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
15632 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
15633 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
15634 + *
15635 + ******************************************************************************/
15636 +
15637 +static uint16 crc16_table[256] = {
15638 + 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
15639 + 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
15640 + 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
15641 + 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
15642 + 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
15643 + 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
15644 + 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
15645 + 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
15646 + 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
15647 + 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
15648 + 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
15649 + 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
15650 + 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
15651 + 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
15652 + 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
15653 + 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
15654 + 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
15655 + 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
15656 + 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
15657 + 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
15658 + 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
15659 + 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
15660 + 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
15661 + 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
15662 + 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
15663 + 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
15664 + 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
15665 + 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
15666 + 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
15667 + 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
15668 + 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
15669 + 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
15670 +};
15671 +
15672 +uint16
15673 +hndcrc16(
15674 + uint8 *pdata, /* pointer to array of data to process */
15675 + uint nbytes, /* number of input data bytes to process */
15676 + uint16 crc /* either CRC16_INIT_VALUE or previous return value */
15677 +)
15678 +{
15679 + while (nbytes-- > 0)
15680 + CRC_INNER_LOOP(16, crc, *pdata++);
15681 + return crc;
15682 +}
15683 +
15684 +static uint32 crc32_table[256] = {
15685 + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
15686 + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
15687 + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
15688 + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
15689 + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
15690 + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
15691 + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
15692 + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
15693 + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
15694 + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
15695 + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
15696 + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
15697 + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
15698 + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
15699 + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
15700 + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
15701 + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
15702 + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
15703 + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
15704 + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
15705 + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
15706 + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
15707 + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
15708 + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
15709 + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
15710 + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
15711 + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
15712 + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
15713 + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
15714 + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
15715 + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
15716 + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
15717 + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
15718 + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
15719 + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
15720 + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
15721 + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
15722 + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
15723 + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
15724 + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
15725 + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
15726 + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
15727 + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
15728 + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
15729 + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
15730 + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
15731 + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
15732 + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
15733 + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
15734 + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
15735 + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
15736 + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
15737 + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
15738 + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
15739 + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
15740 + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
15741 + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
15742 + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
15743 + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
15744 + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
15745 + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
15746 + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
15747 + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
15748 + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
15749 +};
15750 +
15751 +uint32
15752 +hndcrc32(
15753 + uint8 *pdata, /* pointer to array of data to process */
15754 + uint nbytes, /* number of input data bytes to process */
15755 + uint32 crc /* either CRC32_INIT_VALUE or previous return value */
15756 +)
15757 +{
15758 + uint8 *pend;
15759 +#ifdef __mips__
15760 + uint8 tmp[4];
15761 + ulong *tptr = (ulong *)tmp;
15762 +
15763 + /* in case the beginning of the buffer isn't aligned */
15764 + pend = (uint8 *)((uint)(pdata + 3) & 0xfffffffc);
15765 + nbytes -= (pend - pdata);
15766 + while (pdata < pend)
15767 + CRC_INNER_LOOP(32, crc, *pdata++);
15768 +
15769 + /* handle bulk of data as 32-bit words */
15770 + pend = pdata + (nbytes & 0xfffffffc);
15771 + while (pdata < pend) {
15772 + *tptr = *((ulong *)pdata)++;
15773 + CRC_INNER_LOOP(32, crc, tmp[0]);
15774 + CRC_INNER_LOOP(32, crc, tmp[1]);
15775 + CRC_INNER_LOOP(32, crc, tmp[2]);
15776 + CRC_INNER_LOOP(32, crc, tmp[3]);
15777 + }
15778 +
15779 + /* 1-3 bytes at end of buffer */
15780 + pend = pdata + (nbytes & 0x03);
15781 + while (pdata < pend)
15782 + CRC_INNER_LOOP(32, crc, *pdata++);
15783 +#else
15784 + pend = pdata + nbytes;
15785 + while (pdata < pend)
15786 + CRC_INNER_LOOP(32, crc, *pdata++);
15787 +#endif
15788 +
15789 + return crc;
15790 +}
15791 +
15792 +#ifdef notdef
15793 +#define CLEN 1499
15794 +#define CBUFSIZ (CLEN+4)
15795 +#define CNBUFS 5
15796 +
15797 +void testcrc32(void)
15798 +{
15799 + uint j,k,l;
15800 + uint8 *buf;
15801 + uint len[CNBUFS];
15802 + uint32 crcr;
15803 + uint32 crc32tv[CNBUFS] =
15804 + {0xd2cb1faa, 0xd385c8fa, 0xf5b4f3f3, 0x55789e20, 0x00343110};
15805 +
15806 + ASSERT((buf = MALLOC(CBUFSIZ*CNBUFS)) != NULL);
15807 +
15808 + /* step through all possible alignments */
15809 + for (l=0;l<=4;l++) {
15810 + for (j=0; j<CNBUFS; j++) {
15811 + len[j] = CLEN;
15812 + for (k=0; k<len[j]; k++)
15813 + *(buf + j*CBUFSIZ + (k+l)) = (j+k) & 0xff;
15814 + }
15815 +
15816 + for (j=0; j<CNBUFS; j++) {
15817 + crcr = crc32(buf + j*CBUFSIZ + l, len[j], CRC32_INIT_VALUE);
15818 + ASSERT(crcr == crc32tv[j]);
15819 + }
15820 + }
15821 +
15822 + MFREE(buf, CBUFSIZ*CNBUFS);
15823 + return;
15824 +}
15825 +#endif
15826 +
15827 +
15828 +/*
15829 + * Advance from the current 1-byte tag/1-byte length/variable-length value
15830 + * triple, to the next, returning a pointer to the next.
15831 + */
15832 +bcm_tlv_t *
15833 +bcm_next_tlv(bcm_tlv_t *elt, int *buflen)
15834 +{
15835 + int len;
15836 +
15837 + /* validate current elt */
15838 + if (*buflen < 2) {
15839 + return NULL;
15840 + }
15841 +
15842 + len = elt->len;
15843 +
15844 + /* validate remaining buflen */
15845 + if (*buflen >= (2 + len + 2)) {
15846 + elt = (bcm_tlv_t*)(elt->data + len);
15847 + *buflen -= (2 + len);
15848 + } else {
15849 + elt = NULL;
15850 + }
15851 +
15852 + return elt;
15853 +}
15854 +
15855 +/*
15856 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
15857 + * triples, returning a pointer to the substring whose first element
15858 + * matches tag
15859 + */
15860 +bcm_tlv_t *
15861 +bcm_parse_tlvs(void *buf, int buflen, uint key)
15862 +{
15863 + bcm_tlv_t *elt;
15864 + int totlen;
15865 +
15866 + elt = (bcm_tlv_t*)buf;
15867 + totlen = buflen;
15868 +
15869 + /* find tagged parameter */
15870 + while (totlen >= 2) {
15871 + int len = elt->len;
15872 +
15873 + /* validate remaining totlen */
15874 + if ((elt->id == key) && (totlen >= (len + 2)))
15875 + return (elt);
15876 +
15877 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
15878 + totlen -= (len + 2);
15879 + }
15880 +
15881 + return NULL;
15882 +}
15883 +
15884 +/*
15885 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
15886 + * triples, returning a pointer to the substring whose first element
15887 + * matches tag. Stop parsing when we see an element whose ID is greater
15888 + * than the target key.
15889 + */
15890 +bcm_tlv_t *
15891 +bcm_parse_ordered_tlvs(void *buf, int buflen, uint key)
15892 +{
15893 + bcm_tlv_t *elt;
15894 + int totlen;
15895 +
15896 + elt = (bcm_tlv_t*)buf;
15897 + totlen = buflen;
15898 +
15899 + /* find tagged parameter */
15900 + while (totlen >= 2) {
15901 + uint id = elt->id;
15902 + int len = elt->len;
15903 +
15904 + /* Punt if we start seeing IDs > than target key */
15905 + if (id > key)
15906 + return(NULL);
15907 +
15908 + /* validate remaining totlen */
15909 + if ((id == key) && (totlen >= (len + 2)))
15910 + return (elt);
15911 +
15912 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
15913 + totlen -= (len + 2);
15914 + }
15915 + return NULL;
15916 +}
15917 +
15918 +
15919 diff -Nur linux-2.4.30/drivers/net/hnd/hnddma.c linux-2.4.30-brcm/drivers/net/hnd/hnddma.c
15920 --- linux-2.4.30/drivers/net/hnd/hnddma.c 1970-01-01 01:00:00.000000000 +0100
15921 +++ linux-2.4.30-brcm/drivers/net/hnd/hnddma.c 2005-05-25 01:12:49.000000000 +0200
15922 @@ -0,0 +1,865 @@
15923 +/*
15924 + * Generic Broadcom Home Networking Division (HND) DMA module.
15925 + * This supports the following chips: BCM42xx, 44xx, 47xx .
15926 + *
15927 + * Copyright 2004, Broadcom Corporation
15928 + * All Rights Reserved.
15929 + *
15930 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
15931 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
15932 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
15933 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
15934 + *
15935 + * $Id$
15936 + */
15937 +
15938 +#include <typedefs.h>
15939 +#include <osl.h>
15940 +#include <bcmendian.h>
15941 +#include <sbconfig.h>
15942 +#include <bcmutils.h>
15943 +
15944 +struct dma_info; /* forward declaration */
15945 +#define di_t struct dma_info
15946 +#include <hnddma.h>
15947 +
15948 +/* debug/trace */
15949 +#define DMA_ERROR(args)
15950 +#define DMA_TRACE(args)
15951 +
15952 +/* default dma message level(if input msg_level pointer is null in dma_attach()) */
15953 +static uint dma_msg_level = 0;
15954 +
15955 +#define MAXNAMEL 8
15956 +#define MAXDD (DMAMAXRINGSZ / sizeof (dmadd_t))
15957 +
15958 +/* dma engine software state */
15959 +typedef struct dma_info {
15960 + hnddma_t hnddma; /* exported structure */
15961 + uint *msg_level; /* message level pointer */
15962 +
15963 + char name[MAXNAMEL]; /* callers name for diag msgs */
15964 + void *drv; /* driver handle */
15965 + void *osh; /* os handle */
15966 + dmaregs_t *regs; /* dma engine registers */
15967 +
15968 + dmadd_t *txd; /* pointer to chip-specific tx descriptor ring */
15969 + uint txin; /* index of next descriptor to reclaim */
15970 + uint txout; /* index of next descriptor to post */
15971 + uint txavail; /* # free tx descriptors */
15972 + void **txp; /* pointer to parallel array of pointers to packets */
15973 + ulong txdpa; /* physical address of descriptor ring */
15974 + uint txdalign; /* #bytes added to alloc'd mem to align txd */
15975 + uint txdalloc; /* #bytes allocated for the ring */
15976 +
15977 + dmadd_t *rxd; /* pointer to chip-specific rx descriptor ring */
15978 + uint rxin; /* index of next descriptor to reclaim */
15979 + uint rxout; /* index of next descriptor to post */
15980 + void **rxp; /* pointer to parallel array of pointers to packets */
15981 + ulong rxdpa; /* physical address of descriptor ring */
15982 + uint rxdalign; /* #bytes added to alloc'd mem to align rxd */
15983 + uint rxdalloc; /* #bytes allocated for the ring */
15984 +
15985 + /* tunables */
15986 + uint ntxd; /* # tx descriptors */
15987 + uint nrxd; /* # rx descriptors */
15988 + uint rxbufsize; /* rx buffer size in bytes */
15989 + uint nrxpost; /* # rx buffers to keep posted */
15990 + uint rxoffset; /* rxcontrol offset */
15991 + uint ddoffset; /* add to get dma address of descriptor ring */
15992 + uint dataoffset; /* add to get dma address of data buffer */
15993 +} dma_info_t;
15994 +
15995 +/* descriptor bumping macros */
15996 +#define XXD(x, n) ((x) & ((n) - 1))
15997 +#define TXD(x) XXD((x), di->ntxd)
15998 +#define RXD(x) XXD((x), di->nrxd)
15999 +#define NEXTTXD(i) TXD(i + 1)
16000 +#define PREVTXD(i) TXD(i - 1)
16001 +#define NEXTRXD(i) RXD(i + 1)
16002 +#define NTXDACTIVE(h, t) TXD(t - h)
16003 +#define NRXDACTIVE(h, t) RXD(t - h)
16004 +
16005 +/* macros to convert between byte offsets and indexes */
16006 +#define B2I(bytes) ((bytes) / sizeof (dmadd_t))
16007 +#define I2B(index) ((index) * sizeof (dmadd_t))
16008 +
16009 +/*
16010 + * This assume the largest i/o address is, in fact, the pci big window
16011 + * and that the pci core sb2pcitranslation2 register has been left with
16012 + * the default 0x0 pci base address.
16013 + */
16014 +#define MAXDMAADDR SB_PCI_DMA_SZ
16015 +#define DMA_ADDRESSABLE(x) !((x) & ~(MAXDMAADDR - 1))
16016 +
16017 +/* prototypes */
16018 +
16019 +void*
16020 +dma_attach(void *drv, void *osh, char *name, dmaregs_t *regs, uint ntxd, uint nrxd,
16021 + uint rxbufsize, uint nrxpost, uint rxoffset, uint ddoffset, uint dataoffset, uint *msg_level)
16022 +{
16023 + dma_info_t *di;
16024 + uint size;
16025 + void *va;
16026 +
16027 + ASSERT(ntxd <= MAXDD);
16028 + ASSERT(ISPOWEROF2(ntxd));
16029 + ASSERT(nrxd <= MAXDD);
16030 + ASSERT(ISPOWEROF2(nrxd));
16031 +
16032 + /* allocate private info structure */
16033 + if ((di = MALLOC(osh, sizeof (dma_info_t))) == NULL) {
16034 + return (NULL);
16035 + }
16036 + bzero((char*)di, sizeof (dma_info_t));
16037 +
16038 + /* allocate tx packet pointer vector */
16039 + if (ntxd) {
16040 + size = ntxd * sizeof (void*);
16041 + if ((di->txp = MALLOC(osh, size)) == NULL)
16042 + goto fail;
16043 + bzero((char*)di->txp, size);
16044 + }
16045 +
16046 + /* allocate rx packet pointer vector */
16047 + if (nrxd) {
16048 + size = nrxd * sizeof (void*);
16049 + if ((di->rxp = MALLOC(osh, size)) == NULL)
16050 + goto fail;
16051 + bzero((char*)di->rxp, size);
16052 + }
16053 +
16054 + /* set message level */
16055 + di->msg_level = msg_level ? msg_level : &dma_msg_level;
16056 +
16057 + DMA_TRACE(("%s: dma_attach: drv %p osh %p regs %p ntxd %d nrxd %d rxbufsize %d nrxpost %d rxoffset %d ddoffset 0x%x dataoffset 0x%x\n", name, drv, osh, regs, ntxd, nrxd, rxbufsize, nrxpost, rxoffset, ddoffset, dataoffset));
16058 +
16059 + /* make a private copy of our callers name */
16060 + strncpy(di->name, name, MAXNAMEL);
16061 + di->name[MAXNAMEL-1] = '\0';
16062 +
16063 + di->drv = drv;
16064 + di->osh = osh;
16065 + di->regs = regs;
16066 +
16067 + /* allocate transmit descriptor ring */
16068 + if (ntxd) {
16069 + /* only need ntxd descriptors but it must be DMARINGALIGNed */
16070 + size = ntxd * sizeof (dmadd_t);
16071 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, DMARINGALIGN))
16072 + size += DMARINGALIGN;
16073 + if ((va = DMA_ALLOC_CONSISTENT(osh, size, &di->txdpa)) == NULL)
16074 + goto fail;
16075 + di->txd = (dmadd_t*) ROUNDUP((uintptr)va, DMARINGALIGN);
16076 + di->txdalign = (uint)((int8*)di->txd - (int8*)va);
16077 + di->txdpa += di->txdalign;
16078 + di->txdalloc = size;
16079 + ASSERT(ISALIGNED((uintptr)di->txd, DMARINGALIGN));
16080 + ASSERT(DMA_ADDRESSABLE(di->txdpa));
16081 + }
16082 +
16083 + /* allocate receive descriptor ring */
16084 + if (nrxd) {
16085 + /* only need nrxd descriptors but it must be DMARINGALIGNed */
16086 + size = nrxd * sizeof (dmadd_t);
16087 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, DMARINGALIGN))
16088 + size += DMARINGALIGN;
16089 + if ((va = DMA_ALLOC_CONSISTENT(osh, size, &di->rxdpa)) == NULL)
16090 + goto fail;
16091 + di->rxd = (dmadd_t*) ROUNDUP((uintptr)va, DMARINGALIGN);
16092 + di->rxdalign = (uint)((int8*)di->rxd - (int8*)va);
16093 + di->rxdpa += di->rxdalign;
16094 + di->rxdalloc = size;
16095 + ASSERT(ISALIGNED((uintptr)di->rxd, DMARINGALIGN));
16096 + ASSERT(DMA_ADDRESSABLE(di->rxdpa));
16097 + }
16098 +
16099 + /* save tunables */
16100 + di->ntxd = ntxd;
16101 + di->nrxd = nrxd;
16102 + di->rxbufsize = rxbufsize;
16103 + di->nrxpost = nrxpost;
16104 + di->rxoffset = rxoffset;
16105 + di->ddoffset = ddoffset;
16106 + di->dataoffset = dataoffset;
16107 +
16108 + return ((void*)di);
16109 +
16110 +fail:
16111 + dma_detach((void*)di);
16112 + return (NULL);
16113 +}
16114 +
16115 +/* may be called with core in reset */
16116 +void
16117 +dma_detach(dma_info_t *di)
16118 +{
16119 + if (di == NULL)
16120 + return;
16121 +
16122 + DMA_TRACE(("%s: dma_detach\n", di->name));
16123 +
16124 + /* shouldn't be here if descriptors are unreclaimed */
16125 + ASSERT(di->txin == di->txout);
16126 + ASSERT(di->rxin == di->rxout);
16127 +
16128 + /* free dma descriptor rings */
16129 + if (di->txd)
16130 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->txd - di->txdalign),
16131 + di->txdalloc, (di->txdpa - di->txdalign));
16132 + if (di->rxd)
16133 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->rxd - di->rxdalign),
16134 + di->rxdalloc, (di->rxdpa - di->rxdalign));
16135 +
16136 + /* free packet pointer vectors */
16137 + if (di->txp)
16138 + MFREE(di->osh, (void*)di->txp, (di->ntxd * sizeof (void*)));
16139 + if (di->rxp)
16140 + MFREE(di->osh, (void*)di->rxp, (di->nrxd * sizeof (void*)));
16141 +
16142 + /* free our private info structure */
16143 + MFREE(di->osh, (void*)di, sizeof (dma_info_t));
16144 +}
16145 +
16146 +
16147 +void
16148 +dma_txreset(dma_info_t *di)
16149 +{
16150 + uint32 status;
16151 +
16152 + DMA_TRACE(("%s: dma_txreset\n", di->name));
16153 +
16154 + /* suspend tx DMA first */
16155 + W_REG(&di->regs->xmtcontrol, XC_SE);
16156 + SPINWAIT((status = (R_REG(&di->regs->xmtstatus) & XS_XS_MASK)) != XS_XS_DISABLED &&
16157 + status != XS_XS_IDLE &&
16158 + status != XS_XS_STOPPED,
16159 + 10000);
16160 +
16161 + W_REG(&di->regs->xmtcontrol, 0);
16162 + SPINWAIT((status = (R_REG(&di->regs->xmtstatus) & XS_XS_MASK)) != XS_XS_DISABLED,
16163 + 10000);
16164 +
16165 + if (status != XS_XS_DISABLED) {
16166 + DMA_ERROR(("%s: dma_txreset: dma cannot be stopped\n", di->name));
16167 + }
16168 +
16169 + /* wait for the last transaction to complete */
16170 + OSL_DELAY(300);
16171 +}
16172 +
16173 +void
16174 +dma_rxreset(dma_info_t *di)
16175 +{
16176 + uint32 status;
16177 +
16178 + DMA_TRACE(("%s: dma_rxreset\n", di->name));
16179 +
16180 + W_REG(&di->regs->rcvcontrol, 0);
16181 + SPINWAIT((status = (R_REG(&di->regs->rcvstatus) & RS_RS_MASK)) != RS_RS_DISABLED,
16182 + 10000);
16183 +
16184 + if (status != RS_RS_DISABLED) {
16185 + DMA_ERROR(("%s: dma_rxreset: dma cannot be stopped\n", di->name));
16186 + }
16187 +}
16188 +
16189 +void
16190 +dma_txinit(dma_info_t *di)
16191 +{
16192 + DMA_TRACE(("%s: dma_txinit\n", di->name));
16193 +
16194 + di->txin = di->txout = 0;
16195 + di->txavail = di->ntxd - 1;
16196 +
16197 + /* clear tx descriptor ring */
16198 + BZERO_SM((void*)di->txd, (di->ntxd * sizeof (dmadd_t)));
16199 +
16200 + W_REG(&di->regs->xmtcontrol, XC_XE);
16201 + W_REG(&di->regs->xmtaddr, (di->txdpa + di->ddoffset));
16202 +}
16203 +
16204 +bool
16205 +dma_txenabled(dma_info_t *di)
16206 +{
16207 + uint32 xc;
16208 +
16209 + /* If the chip is dead, it is not enabled :-) */
16210 + xc = R_REG(&di->regs->xmtcontrol);
16211 + return ((xc != 0xffffffff) && (xc & XC_XE));
16212 +}
16213 +
16214 +void
16215 +dma_txsuspend(dma_info_t *di)
16216 +{
16217 + DMA_TRACE(("%s: dma_txsuspend\n", di->name));
16218 + OR_REG(&di->regs->xmtcontrol, XC_SE);
16219 +}
16220 +
16221 +void
16222 +dma_txresume(dma_info_t *di)
16223 +{
16224 + DMA_TRACE(("%s: dma_txresume\n", di->name));
16225 + AND_REG(&di->regs->xmtcontrol, ~XC_SE);
16226 +}
16227 +
16228 +bool
16229 +dma_txsuspended(dma_info_t *di)
16230 +{
16231 + if (!(R_REG(&di->regs->xmtcontrol) & XC_SE))
16232 + return 0;
16233 +
16234 + if ((R_REG(&di->regs->xmtstatus) & XS_XS_MASK) != XS_XS_IDLE)
16235 + return 0;
16236 +
16237 + OSL_DELAY(2);
16238 + return ((R_REG(&di->regs->xmtstatus) & XS_XS_MASK) == XS_XS_IDLE);
16239 +}
16240 +
16241 +bool
16242 +dma_txstopped(dma_info_t *di)
16243 +{
16244 + return ((R_REG(&di->regs->xmtstatus) & XS_XS_MASK) == XS_XS_STOPPED);
16245 +}
16246 +
16247 +bool
16248 +dma_rxstopped(dma_info_t *di)
16249 +{
16250 + return ((R_REG(&di->regs->rcvstatus) & RS_RS_MASK) == RS_RS_STOPPED);
16251 +}
16252 +
16253 +void
16254 +dma_fifoloopbackenable(dma_info_t *di)
16255 +{
16256 + DMA_TRACE(("%s: dma_fifoloopbackenable\n", di->name));
16257 + OR_REG(&di->regs->xmtcontrol, XC_LE);
16258 +}
16259 +
16260 +void
16261 +dma_rxinit(dma_info_t *di)
16262 +{
16263 + DMA_TRACE(("%s: dma_rxinit\n", di->name));
16264 +
16265 + di->rxin = di->rxout = 0;
16266 +
16267 + /* clear rx descriptor ring */
16268 + BZERO_SM((void*)di->rxd, (di->nrxd * sizeof (dmadd_t)));
16269 +
16270 + dma_rxenable(di);
16271 + W_REG(&di->regs->rcvaddr, (di->rxdpa + di->ddoffset));
16272 +}
16273 +
16274 +void
16275 +dma_rxenable(dma_info_t *di)
16276 +{
16277 + DMA_TRACE(("%s: dma_rxenable\n", di->name));
16278 + W_REG(&di->regs->rcvcontrol, ((di->rxoffset << RC_RO_SHIFT) | RC_RE));
16279 +}
16280 +
16281 +bool
16282 +dma_rxenabled(dma_info_t *di)
16283 +{
16284 + uint32 rc;
16285 +
16286 + rc = R_REG(&di->regs->rcvcontrol);
16287 + return ((rc != 0xffffffff) && (rc & RC_RE));
16288 +}
16289 +
16290 +/*
16291 + * The BCM47XX family supports full 32bit dma engine buffer addressing so
16292 + * dma buffers can cross 4 Kbyte page boundaries.
16293 + */
16294 +int
16295 +dma_txfast(dma_info_t *di, void *p0, uint32 coreflags)
16296 +{
16297 + void *p, *next;
16298 + uchar *data;
16299 + uint len;
16300 + uint txout;
16301 + uint32 ctrl;
16302 + uint32 pa;
16303 +
16304 + DMA_TRACE(("%s: dma_txfast\n", di->name));
16305 +
16306 + txout = di->txout;
16307 + ctrl = 0;
16308 +
16309 + /*
16310 + * Walk the chain of packet buffers
16311 + * allocating and initializing transmit descriptor entries.
16312 + */
16313 + for (p = p0; p; p = next) {
16314 + data = PKTDATA(di->drv, p);
16315 + len = PKTLEN(di->drv, p);
16316 + next = PKTNEXT(di->drv, p);
16317 +
16318 + /* return nonzero if out of tx descriptors */
16319 + if (NEXTTXD(txout) == di->txin)
16320 + goto outoftxd;
16321 +
16322 + if (len == 0)
16323 + continue;
16324 +
16325 + /* get physical address of buffer start */
16326 + pa = (uint32) DMA_MAP(di->osh, data, len, DMA_TX, p);
16327 + ASSERT(DMA_ADDRESSABLE(pa));
16328 +
16329 + /* build the descriptor control value */
16330 + ctrl = len & CTRL_BC_MASK;
16331 +
16332 + ctrl |= coreflags;
16333 +
16334 + if (p == p0)
16335 + ctrl |= CTRL_SOF;
16336 + if (next == NULL)
16337 + ctrl |= (CTRL_IOC | CTRL_EOF);
16338 + if (txout == (di->ntxd - 1))
16339 + ctrl |= CTRL_EOT;
16340 +
16341 + /* init the tx descriptor */
16342 + W_SM(&di->txd[txout].ctrl, BUS_SWAP32(ctrl));
16343 + W_SM(&di->txd[txout].addr, BUS_SWAP32(pa + di->dataoffset));
16344 +
16345 + ASSERT(di->txp[txout] == NULL);
16346 +
16347 + txout = NEXTTXD(txout);
16348 + }
16349 +
16350 + /* if last txd eof not set, fix it */
16351 + if (!(ctrl & CTRL_EOF))
16352 + W_SM(&di->txd[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF));
16353 +
16354 + /* save the packet */
16355 + di->txp[PREVTXD(txout)] = p0;
16356 +
16357 + /* bump the tx descriptor index */
16358 + di->txout = txout;
16359 +
16360 + /* kick the chip */
16361 + W_REG(&di->regs->xmtptr, I2B(txout));
16362 +
16363 + /* tx flow control */
16364 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16365 +
16366 + return (0);
16367 +
16368 +outoftxd:
16369 + DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name));
16370 + PKTFREE(di->drv, p0, TRUE);
16371 + di->txavail = 0;
16372 + di->hnddma.txnobuf++;
16373 + return (-1);
16374 +}
16375 +
16376 +#define PAGESZ 4096
16377 +#define PAGEBASE(x) ((uintptr)(x) & ~4095)
16378 +
16379 +/*
16380 + * Just like above except go through the extra effort of splitting
16381 + * buffers that cross 4Kbyte boundaries into multiple tx descriptors.
16382 + */
16383 +int
16384 +dma_tx(dma_info_t *di, void *p0, uint32 coreflags)
16385 +{
16386 + void *p, *next;
16387 + uchar *data;
16388 + uint plen, len;
16389 + uchar *page, *start, *end;
16390 + uint txout;
16391 + uint32 ctrl;
16392 + uint32 pa;
16393 +
16394 + DMA_TRACE(("%s: dma_tx\n", di->name));
16395 +
16396 + txout = di->txout;
16397 + ctrl = 0;
16398 +
16399 + /*
16400 + * Walk the chain of packet buffers
16401 + * splitting those that cross 4 Kbyte boundaries
16402 + * allocating and initializing transmit descriptor entries.
16403 + */
16404 + for (p = p0; p; p = next) {
16405 + data = PKTDATA(di->drv, p);
16406 + plen = PKTLEN(di->drv, p);
16407 + next = PKTNEXT(di->drv, p);
16408 +
16409 + if (plen == 0)
16410 + continue;
16411 +
16412 + for (page = (uchar*)PAGEBASE(data);
16413 + page <= (uchar*)PAGEBASE(data + plen - 1);
16414 + page += PAGESZ) {
16415 +
16416 + /* return nonzero if out of tx descriptors */
16417 + if (NEXTTXD(txout) == di->txin)
16418 + goto outoftxd;
16419 +
16420 + start = (page == (uchar*)PAGEBASE(data))? data: page;
16421 + end = (page == (uchar*)PAGEBASE(data + plen))?
16422 + (data + plen): (page + PAGESZ);
16423 + len = (uint)(end - start);
16424 +
16425 + /* build the descriptor control value */
16426 + ctrl = len & CTRL_BC_MASK;
16427 +
16428 + ctrl |= coreflags;
16429 +
16430 + if ((p == p0) && (start == data))
16431 + ctrl |= CTRL_SOF;
16432 + if ((next == NULL) && (end == (data + plen)))
16433 + ctrl |= (CTRL_IOC | CTRL_EOF);
16434 + if (txout == (di->ntxd - 1))
16435 + ctrl |= CTRL_EOT;
16436 +
16437 + /* get physical address of buffer start */
16438 + pa = (uint32) DMA_MAP(di->osh, start, len, DMA_TX, p);
16439 + ASSERT(DMA_ADDRESSABLE(pa));
16440 +
16441 + /* init the tx descriptor */
16442 + W_SM(&di->txd[txout].ctrl, BUS_SWAP32(ctrl));
16443 + W_SM(&di->txd[txout].addr, BUS_SWAP32(pa + di->dataoffset));
16444 +
16445 + ASSERT(di->txp[txout] == NULL);
16446 +
16447 + txout = NEXTTXD(txout);
16448 + }
16449 + }
16450 +
16451 + /* if last txd eof not set, fix it */
16452 + if (!(ctrl & CTRL_EOF))
16453 + W_SM(&di->txd[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF));
16454 +
16455 + /* save the packet */
16456 + di->txp[PREVTXD(txout)] = p0;
16457 +
16458 + /* bump the tx descriptor index */
16459 + di->txout = txout;
16460 +
16461 + /* kick the chip */
16462 + W_REG(&di->regs->xmtptr, I2B(txout));
16463 +
16464 + /* tx flow control */
16465 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16466 +
16467 + return (0);
16468 +
16469 +outoftxd:
16470 + DMA_ERROR(("%s: dma_tx: out of txds\n", di->name));
16471 + PKTFREE(di->drv, p0, TRUE);
16472 + di->txavail = 0;
16473 + di->hnddma.txnobuf++;
16474 + return (-1);
16475 +}
16476 +
16477 +/* returns a pointer to the next frame received, or NULL if there are no more */
16478 +void*
16479 +dma_rx(dma_info_t *di)
16480 +{
16481 + void *p;
16482 + uint len;
16483 + int skiplen = 0;
16484 +
16485 + while ((p = dma_getnextrxp(di, FALSE))) {
16486 + /* skip giant packets which span multiple rx descriptors */
16487 + if (skiplen > 0) {
16488 + skiplen -= di->rxbufsize;
16489 + if (skiplen < 0)
16490 + skiplen = 0;
16491 + PKTFREE(di->drv, p, FALSE);
16492 + continue;
16493 + }
16494 +
16495 + len = ltoh16(*(uint16*)(PKTDATA(di->drv, p)));
16496 + DMA_TRACE(("%s: dma_rx len %d\n", di->name, len));
16497 +
16498 + /* bad frame length check */
16499 + if (len > (di->rxbufsize - di->rxoffset)) {
16500 + DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len));
16501 + if (len > 0)
16502 + skiplen = len - (di->rxbufsize - di->rxoffset);
16503 + PKTFREE(di->drv, p, FALSE);
16504 + di->hnddma.rxgiants++;
16505 + continue;
16506 + }
16507 +
16508 + /* set actual length */
16509 + PKTSETLEN(di->drv, p, (di->rxoffset + len));
16510 +
16511 + break;
16512 + }
16513 +
16514 + return (p);
16515 +}
16516 +
16517 +/* post receive buffers */
16518 +void
16519 +dma_rxfill(dma_info_t *di)
16520 +{
16521 + void *p;
16522 + uint rxin, rxout;
16523 + uint ctrl;
16524 + uint n;
16525 + uint i;
16526 + uint32 pa;
16527 + uint rxbufsize;
16528 +
16529 + /*
16530 + * Determine how many receive buffers we're lacking
16531 + * from the full complement, allocate, initialize,
16532 + * and post them, then update the chip rx lastdscr.
16533 + */
16534 +
16535 + rxin = di->rxin;
16536 + rxout = di->rxout;
16537 + rxbufsize = di->rxbufsize;
16538 +
16539 + n = di->nrxpost - NRXDACTIVE(rxin, rxout);
16540 +
16541 + DMA_TRACE(("%s: dma_rxfill: post %d\n", di->name, n));
16542 +
16543 + for (i = 0; i < n; i++) {
16544 + if ((p = PKTGET(di->drv, rxbufsize, FALSE)) == NULL) {
16545 + DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", di->name));
16546 + di->hnddma.rxnobuf++;
16547 + break;
16548 + }
16549 +
16550 + *(uint32*)(OSL_UNCACHED(PKTDATA(di->drv, p))) = 0;
16551 +
16552 + pa = (uint32) DMA_MAP(di->osh, PKTDATA(di->drv, p), rxbufsize, DMA_RX, p);
16553 + ASSERT(ISALIGNED(pa, 4));
16554 + ASSERT(DMA_ADDRESSABLE(pa));
16555 +
16556 + /* save the free packet pointer */
16557 + ASSERT(di->rxp[rxout] == NULL);
16558 + di->rxp[rxout] = p;
16559 +
16560 + /* prep the descriptor control value */
16561 + ctrl = rxbufsize;
16562 + if (rxout == (di->nrxd - 1))
16563 + ctrl |= CTRL_EOT;
16564 +
16565 + /* init the rx descriptor */
16566 + W_SM(&di->rxd[rxout].ctrl, BUS_SWAP32(ctrl));
16567 + W_SM(&di->rxd[rxout].addr, BUS_SWAP32(pa + di->dataoffset));
16568 +
16569 + rxout = NEXTRXD(rxout);
16570 + }
16571 +
16572 + di->rxout = rxout;
16573 +
16574 + /* update the chip lastdscr pointer */
16575 + W_REG(&di->regs->rcvptr, I2B(rxout));
16576 +}
16577 +
16578 +void
16579 +dma_txreclaim(dma_info_t *di, bool forceall)
16580 +{
16581 + void *p;
16582 +
16583 + DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, forceall ? "all" : ""));
16584 +
16585 + while ((p = dma_getnexttxp(di, forceall)))
16586 + PKTFREE(di->drv, p, TRUE);
16587 +}
16588 +
16589 +/*
16590 + * Reclaim next completed txd (txds if using chained buffers) and
16591 + * return associated packet.
16592 + * If 'force' is true, reclaim txd(s) and return associated packet
16593 + * regardless of the value of the hardware "curr" pointer.
16594 + */
16595 +void*
16596 +dma_getnexttxp(dma_info_t *di, bool forceall)
16597 +{
16598 + uint start, end, i;
16599 + void *txp;
16600 +
16601 + DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, forceall ? "all" : ""));
16602 +
16603 + txp = NULL;
16604 +
16605 + start = di->txin;
16606 + if (forceall)
16607 + end = di->txout;
16608 + else
16609 + end = B2I(R_REG(&di->regs->xmtstatus) & XS_CD_MASK);
16610 +
16611 + if ((start == 0) && (end > di->txout))
16612 + goto bogus;
16613 +
16614 + for (i = start; i != end && !txp; i = NEXTTXD(i)) {
16615 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->txd[i].addr)) - di->dataoffset),
16616 + (BUS_SWAP32(R_SM(&di->txd[i].ctrl)) & CTRL_BC_MASK), DMA_TX, di->txp[i]);
16617 + W_SM(&di->txd[i].addr, 0xdeadbeef);
16618 + txp = di->txp[i];
16619 + di->txp[i] = NULL;
16620 + }
16621 +
16622 + di->txin = i;
16623 +
16624 + /* tx flow control */
16625 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16626 +
16627 + return (txp);
16628 +
16629 +bogus:
16630 +/*
16631 + DMA_ERROR(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n",
16632 + start, end, di->txout, forceall));
16633 +*/
16634 + return (NULL);
16635 +}
16636 +
16637 +/* like getnexttxp but no reclaim */
16638 +void*
16639 +dma_peeknexttxp(dma_info_t *di)
16640 +{
16641 + uint end, i;
16642 +
16643 + end = B2I(R_REG(&di->regs->xmtstatus) & XS_CD_MASK);
16644 +
16645 + for (i = di->txin; i != end; i = NEXTTXD(i))
16646 + if (di->txp[i])
16647 + return (di->txp[i]);
16648 +
16649 + return (NULL);
16650 +}
16651 +
16652 +void
16653 +dma_rxreclaim(dma_info_t *di)
16654 +{
16655 + void *p;
16656 +
16657 + DMA_TRACE(("%s: dma_rxreclaim\n", di->name));
16658 +
16659 + while ((p = dma_getnextrxp(di, TRUE)))
16660 + PKTFREE(di->drv, p, FALSE);
16661 +}
16662 +
16663 +void *
16664 +dma_getnextrxp(dma_info_t *di, bool forceall)
16665 +{
16666 + uint i;
16667 + void *rxp;
16668 +
16669 + /* if forcing, dma engine must be disabled */
16670 + ASSERT(!forceall || !dma_rxenabled(di));
16671 +
16672 + i = di->rxin;
16673 +
16674 + /* return if no packets posted */
16675 + if (i == di->rxout)
16676 + return (NULL);
16677 +
16678 + /* ignore curr if forceall */
16679 + if (!forceall && (i == B2I(R_REG(&di->regs->rcvstatus) & RS_CD_MASK)))
16680 + return (NULL);
16681 +
16682 + /* get the packet pointer that corresponds to the rx descriptor */
16683 + rxp = di->rxp[i];
16684 + ASSERT(rxp);
16685 + di->rxp[i] = NULL;
16686 +
16687 + /* clear this packet from the descriptor ring */
16688 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->rxd[i].addr)) - di->dataoffset),
16689 + di->rxbufsize, DMA_RX, rxp);
16690 + W_SM(&di->rxd[i].addr, 0xdeadbeef);
16691 +
16692 + di->rxin = NEXTRXD(i);
16693 +
16694 + return (rxp);
16695 +}
16696 +
16697 +
16698 +uintptr
16699 +dma_getvar(dma_info_t *di, char *name)
16700 +{
16701 + if (!strcmp(name, "&txavail"))
16702 + return ((uintptr) &di->txavail);
16703 + else {
16704 + ASSERT(0);
16705 + }
16706 + return (0);
16707 +}
16708 +
16709 +void
16710 +dma_txblock(dma_info_t *di)
16711 +{
16712 + di->txavail = 0;
16713 +}
16714 +
16715 +void
16716 +dma_txunblock(dma_info_t *di)
16717 +{
16718 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16719 +}
16720 +
16721 +uint
16722 +dma_txactive(dma_info_t *di)
16723 +{
16724 + return (NTXDACTIVE(di->txin, di->txout));
16725 +}
16726 +
16727 +/*
16728 + * Rotate all active tx dma ring entries "forward" by (ActiveDescriptor - txin).
16729 + */
16730 +void
16731 +dma_txrotate(di_t *di)
16732 +{
16733 + uint ad;
16734 + uint nactive;
16735 + uint rot;
16736 + uint old, new;
16737 + uint32 w;
16738 + uint first, last;
16739 +
16740 + ASSERT(dma_txsuspended(di));
16741 +
16742 + nactive = dma_txactive(di);
16743 + ad = B2I((R_REG(&di->regs->xmtstatus) & XS_AD_MASK) >> XS_AD_SHIFT);
16744 + rot = TXD(ad - di->txin);
16745 +
16746 + ASSERT(rot < di->ntxd);
16747 +
16748 + /* full-ring case is a lot harder - don't worry about this */
16749 + if (rot >= (di->ntxd - nactive)) {
16750 + DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name));
16751 + return;
16752 + }
16753 +
16754 + first = di->txin;
16755 + last = PREVTXD(di->txout);
16756 +
16757 + /* move entries starting at last and moving backwards to first */
16758 + for (old = last; old != PREVTXD(first); old = PREVTXD(old)) {
16759 + new = TXD(old + rot);
16760 +
16761 + /*
16762 + * Move the tx dma descriptor.
16763 + * EOT is set only in the last entry in the ring.
16764 + */
16765 + w = R_SM(&di->txd[old].ctrl) & ~CTRL_EOT;
16766 + if (new == (di->ntxd - 1))
16767 + w |= CTRL_EOT;
16768 + W_SM(&di->txd[new].ctrl, w);
16769 + W_SM(&di->txd[new].addr, R_SM(&di->txd[old].addr));
16770 +
16771 + /* zap the old tx dma descriptor address field */
16772 + W_SM(&di->txd[old].addr, 0xdeadbeef);
16773 +
16774 + /* move the corresponding txp[] entry */
16775 + ASSERT(di->txp[new] == NULL);
16776 + di->txp[new] = di->txp[old];
16777 + di->txp[old] = NULL;
16778 + }
16779 +
16780 + /* update txin and txout */
16781 + di->txin = ad;
16782 + di->txout = TXD(di->txout + rot);
16783 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16784 +
16785 + /* kick the chip */
16786 + W_REG(&di->regs->xmtptr, I2B(di->txout));
16787 +}
16788 diff -Nur linux-2.4.30/drivers/net/hnd/linux_osl.c linux-2.4.30-brcm/drivers/net/hnd/linux_osl.c
16789 --- linux-2.4.30/drivers/net/hnd/linux_osl.c 1970-01-01 01:00:00.000000000 +0100
16790 +++ linux-2.4.30-brcm/drivers/net/hnd/linux_osl.c 2005-05-22 23:01:31.000000000 +0200
16791 @@ -0,0 +1,640 @@
16792 +/*
16793 + * Linux OS Independent Layer
16794 + *
16795 + * Copyright 2004, Broadcom Corporation
16796 + * All Rights Reserved.
16797 + *
16798 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
16799 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
16800 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
16801 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
16802 + *
16803 + * $Id$
16804 + */
16805 +
16806 +#define LINUX_OSL
16807 +
16808 +#include <typedefs.h>
16809 +#include <bcmendian.h>
16810 +#include <linux/module.h>
16811 +#include <linuxver.h>
16812 +#include <linux_osl.h>
16813 +#include <bcmutils.h>
16814 +#include <linux/delay.h>
16815 +#ifdef mips
16816 +#include <asm/paccess.h>
16817 +#endif
16818 +#include <pcicfg.h>
16819 +
16820 +#define PCI_CFG_RETRY 10
16821 +
16822 +#define OS_HANDLE_MAGIC 0x1234abcd
16823 +#define BCM_MEM_FILENAME_LEN 24
16824 +
16825 +typedef struct bcm_mem_link {
16826 + struct bcm_mem_link *prev;
16827 + struct bcm_mem_link *next;
16828 + uint size;
16829 + int line;
16830 + char file[BCM_MEM_FILENAME_LEN];
16831 +} bcm_mem_link_t;
16832 +
16833 +typedef struct os_handle {
16834 + uint magic;
16835 + void *pdev;
16836 + uint malloced;
16837 + uint failed;
16838 + bcm_mem_link_t *dbgmem_list;
16839 +} os_handle_t;
16840 +
16841 +void *
16842 +osl_attach(void *pdev)
16843 +{
16844 + os_handle_t *osh;
16845 +
16846 + osh = kmalloc(sizeof(os_handle_t), GFP_ATOMIC);
16847 + ASSERT(osh);
16848 +
16849 + osh->magic = OS_HANDLE_MAGIC;
16850 + osh->malloced = 0;
16851 + osh->failed = 0;
16852 + osh->dbgmem_list = NULL;
16853 + osh->pdev = pdev;
16854 +
16855 + return osh;
16856 +}
16857 +
16858 +void
16859 +osl_detach(void *osh)
16860 +{
16861 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
16862 + kfree(osh);
16863 +}
16864 +
16865 +void*
16866 +osl_pktget(void *drv, uint len, bool send)
16867 +{
16868 + struct sk_buff *skb;
16869 +
16870 + if ((skb = dev_alloc_skb(len)) == NULL)
16871 + return (NULL);
16872 +
16873 + skb_put(skb, len);
16874 +
16875 + /* ensure the cookie field is cleared */
16876 + PKTSETCOOKIE(skb, NULL);
16877 +
16878 + return ((void*) skb);
16879 +}
16880 +
16881 +void
16882 +osl_pktfree(void *p)
16883 +{
16884 + struct sk_buff *skb, *nskb;
16885 +
16886 + skb = (struct sk_buff*) p;
16887 +
16888 + /* perversion: we use skb->next to chain multi-skb packets */
16889 + while (skb) {
16890 + nskb = skb->next;
16891 + skb->next = NULL;
16892 + if (skb->destructor) {
16893 + /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if destructor exists */
16894 + dev_kfree_skb_any(skb);
16895 + } else {
16896 + /* can free immediately (even in_irq()) if destructor does not exist */
16897 + dev_kfree_skb(skb);
16898 + }
16899 + skb = nskb;
16900 + }
16901 +}
16902 +
16903 +uint32
16904 +osl_pci_read_config(void *osh, uint offset, uint size)
16905 +{
16906 + struct pci_dev *pdev;
16907 + uint val;
16908 + uint retry=PCI_CFG_RETRY;
16909 +
16910 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
16911 +
16912 + /* only 4byte access supported */
16913 + ASSERT(size == 4);
16914 +
16915 + pdev = ((os_handle_t *)osh)->pdev;
16916 + do {
16917 + pci_read_config_dword(pdev, offset, &val);
16918 + if (val != 0xffffffff)
16919 + break;
16920 + } while (retry--);
16921 +
16922 +
16923 + return (val);
16924 +}
16925 +
16926 +void
16927 +osl_pci_write_config(void *osh, uint offset, uint size, uint val)
16928 +{
16929 + struct pci_dev *pdev;
16930 + uint retry=PCI_CFG_RETRY;
16931 +
16932 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
16933 +
16934 + /* only 4byte access supported */
16935 + ASSERT(size == 4);
16936 +
16937 + pdev = ((os_handle_t *)osh)->pdev;
16938 +
16939 + do {
16940 + pci_write_config_dword(pdev, offset, val);
16941 + if (offset!=PCI_BAR0_WIN)
16942 + break;
16943 + if (osl_pci_read_config(osh,offset,size) == val)
16944 + break;
16945 + } while (retry--);
16946 +
16947 +}
16948 +
16949 +static void
16950 +osl_pcmcia_attr(void *osh, uint offset, char *buf, int size, bool write)
16951 +{
16952 +}
16953 +
16954 +void
16955 +osl_pcmcia_read_attr(void *osh, uint offset, void *buf, int size)
16956 +{
16957 + osl_pcmcia_attr(osh, offset, (char *) buf, size, FALSE);
16958 +}
16959 +
16960 +void
16961 +osl_pcmcia_write_attr(void *osh, uint offset, void *buf, int size)
16962 +{
16963 + osl_pcmcia_attr(osh, offset, (char *) buf, size, TRUE);
16964 +}
16965 +
16966 +
16967 +#ifdef BCMDBG_MEM
16968 +
16969 +void*
16970 +osl_debug_malloc(void *osh, uint size, int line, char* file)
16971 +{
16972 + bcm_mem_link_t *p;
16973 + char* basename;
16974 + os_handle_t *h = (os_handle_t *)osh;
16975 +
16976 + if (size == 0) {
16977 + return NULL;
16978 + }
16979 +
16980 + p = (bcm_mem_link_t*)osl_malloc(osh, sizeof(bcm_mem_link_t) + size);
16981 + if (p == NULL)
16982 + return p;
16983 +
16984 + p->size = size;
16985 + p->line = line;
16986 +
16987 + basename = strrchr(file, '/');
16988 + /* skip the '/' */
16989 + if (basename)
16990 + basename++;
16991 +
16992 + if (!basename)
16993 + basename = file;
16994 +
16995 + strncpy(p->file, basename, BCM_MEM_FILENAME_LEN);
16996 + p->file[BCM_MEM_FILENAME_LEN - 1] = '\0';
16997 +
16998 + /* link this block */
16999 + p->prev = NULL;
17000 + p->next = h->dbgmem_list;
17001 + if (p->next)
17002 + p->next->prev = p;
17003 + h->dbgmem_list = p;
17004 +
17005 + return p + 1;
17006 +}
17007 +
17008 +void
17009 +osl_debug_mfree(void *osh, void *addr, uint size, int line, char* file)
17010 +{
17011 + bcm_mem_link_t *p = (bcm_mem_link_t *)((int8*)addr - sizeof(bcm_mem_link_t));
17012 + os_handle_t *h = (os_handle_t *)osh;
17013 +
17014 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
17015 +
17016 + if (p->size == 0) {
17017 + printk("osl_debug_mfree: double free on addr 0x%x size %d at line %d file %s\n",
17018 + (uint)addr, size, line, file);
17019 + return;
17020 + }
17021 +
17022 + if (p->size != size) {
17023 + printk("osl_debug_mfree: dealloc size %d does not match alloc size %d on addr 0x%x at line %d file %s\n",
17024 + size, p->size, (uint)addr, line, file);
17025 + return;
17026 + }
17027 +
17028 + /* unlink this block */
17029 + if (p->prev)
17030 + p->prev->next = p->next;
17031 + if (p->next)
17032 + p->next->prev = p->prev;
17033 + if (h->dbgmem_list == p)
17034 + h->dbgmem_list = p->next;
17035 + p->next = p->prev = NULL;
17036 +
17037 + osl_mfree(osh, p, size + sizeof(bcm_mem_link_t));
17038 +}
17039 +
17040 +char*
17041 +osl_debug_memdump(void *osh, char *buf, uint sz)
17042 +{
17043 + bcm_mem_link_t *p;
17044 + char *obuf;
17045 + os_handle_t *h = (os_handle_t *)osh;
17046 +
17047 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
17048 + obuf = buf;
17049 +
17050 + buf += sprintf(buf, " Address\tSize\tFile:line\n");
17051 + for (p = h->dbgmem_list; p && ((buf - obuf) < (sz - 128)); p = p->next)
17052 + buf += sprintf(buf, "0x%08x\t%5d\t%s:%d\n",
17053 + (int)p + sizeof(bcm_mem_link_t), p->size, p->file, p->line);
17054 +
17055 + return (obuf);
17056 +}
17057 +
17058 +#endif /* BCMDBG_MEM */
17059 +
17060 +void*
17061 +osl_malloc(void *osh, uint size)
17062 +{
17063 + os_handle_t *h = (os_handle_t *)osh;
17064 + void *addr;
17065 +
17066 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
17067 + h->malloced += size;
17068 + addr = kmalloc(size, GFP_ATOMIC);
17069 + if (!addr)
17070 + h->failed++;
17071 + return (addr);
17072 +}
17073 +
17074 +void
17075 +osl_mfree(void *osh, void *addr, uint size)
17076 +{
17077 + os_handle_t *h = (os_handle_t *)osh;
17078 +
17079 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
17080 + h->malloced -= size;
17081 + kfree(addr);
17082 +}
17083 +
17084 +uint
17085 +osl_malloced(void *osh)
17086 +{
17087 + os_handle_t *h = (os_handle_t *)osh;
17088 +
17089 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
17090 + return (h->malloced);
17091 +}
17092 +
17093 +uint osl_malloc_failed(void *osh)
17094 +{
17095 + os_handle_t *h = (os_handle_t *)osh;
17096 +
17097 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
17098 + return (h->failed);
17099 +}
17100 +
17101 +void*
17102 +osl_dma_alloc_consistent(void *osh, uint size, ulong *pap)
17103 +{
17104 + struct pci_dev *dev;
17105 +
17106 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
17107 +
17108 + dev = ((os_handle_t *)osh)->pdev;
17109 + return (pci_alloc_consistent(dev, size, (dma_addr_t*)pap));
17110 +}
17111 +
17112 +void
17113 +osl_dma_free_consistent(void *osh, void *va, uint size, ulong pa)
17114 +{
17115 + struct pci_dev *dev;
17116 +
17117 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
17118 +
17119 + dev = ((os_handle_t *)osh)->pdev;
17120 + pci_free_consistent(dev, size, va, (dma_addr_t)pa);
17121 +}
17122 +
17123 +uint
17124 +osl_dma_map(void *osh, void *va, uint size, int direction)
17125 +{
17126 + int dir;
17127 + struct pci_dev *dev;
17128 +
17129 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
17130 +
17131 + dev = ((os_handle_t *)osh)->pdev;
17132 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
17133 + return (pci_map_single(dev, va, size, dir));
17134 +}
17135 +
17136 +void
17137 +osl_dma_unmap(void *osh, uint pa, uint size, int direction)
17138 +{
17139 + int dir;
17140 + struct pci_dev *dev;
17141 +
17142 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
17143 +
17144 + dev = ((os_handle_t *)osh)->pdev;
17145 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
17146 + pci_unmap_single(dev, (uint32)pa, size, dir);
17147 +}
17148 +
17149 +#if defined(BINOSL)
17150 +void
17151 +osl_assert(char *exp, char *file, int line)
17152 +{
17153 + char tempbuf[255];
17154 +
17155 + sprintf(tempbuf, "assertion \"%s\" failed: file \"%s\", line %d\n", exp, file, line);
17156 + panic(tempbuf);
17157 +}
17158 +#endif /* BCMDBG || BINOSL */
17159 +
17160 +/*
17161 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
17162 + */
17163 +#ifdef BINOSL
17164 +
17165 +int
17166 +osl_printf(const char *format, ...)
17167 +{
17168 + va_list args;
17169 + char buf[1024];
17170 + int len;
17171 +
17172 + /* sprintf into a local buffer because there *is* no "vprintk()".. */
17173 + va_start(args, format);
17174 + len = vsprintf(buf, format, args);
17175 + va_end(args);
17176 +
17177 + if (len > sizeof (buf)) {
17178 + printk("osl_printf: buffer overrun\n");
17179 + return (0);
17180 + }
17181 +
17182 + return (printk(buf));
17183 +}
17184 +
17185 +int
17186 +osl_sprintf(char *buf, const char *format, ...)
17187 +{
17188 + va_list args;
17189 + int rc;
17190 +
17191 + va_start(args, format);
17192 + rc = vsprintf(buf, format, args);
17193 + va_end(args);
17194 + return (rc);
17195 +}
17196 +
17197 +int
17198 +osl_strcmp(const char *s1, const char *s2)
17199 +{
17200 + return (strcmp(s1, s2));
17201 +}
17202 +
17203 +int
17204 +osl_strncmp(const char *s1, const char *s2, uint n)
17205 +{
17206 + return (strncmp(s1, s2, n));
17207 +}
17208 +
17209 +int
17210 +osl_strlen(char *s)
17211 +{
17212 + return (strlen(s));
17213 +}
17214 +
17215 +char*
17216 +osl_strcpy(char *d, const char *s)
17217 +{
17218 + return (strcpy(d, s));
17219 +}
17220 +
17221 +char*
17222 +osl_strncpy(char *d, const char *s, uint n)
17223 +{
17224 + return (strncpy(d, s, n));
17225 +}
17226 +
17227 +void
17228 +bcopy(const void *src, void *dst, int len)
17229 +{
17230 + memcpy(dst, src, len);
17231 +}
17232 +
17233 +int
17234 +bcmp(const void *b1, const void *b2, int len)
17235 +{
17236 + return (memcmp(b1, b2, len));
17237 +}
17238 +
17239 +void
17240 +bzero(void *b, int len)
17241 +{
17242 + memset(b, '\0', len);
17243 +}
17244 +
17245 +uint32
17246 +osl_readl(volatile uint32 *r)
17247 +{
17248 + return (readl(r));
17249 +}
17250 +
17251 +uint16
17252 +osl_readw(volatile uint16 *r)
17253 +{
17254 + return (readw(r));
17255 +}
17256 +
17257 +uint8
17258 +osl_readb(volatile uint8 *r)
17259 +{
17260 + return (readb(r));
17261 +}
17262 +
17263 +void
17264 +osl_writel(uint32 v, volatile uint32 *r)
17265 +{
17266 + writel(v, r);
17267 +}
17268 +
17269 +void
17270 +osl_writew(uint16 v, volatile uint16 *r)
17271 +{
17272 + writew(v, r);
17273 +}
17274 +
17275 +void
17276 +osl_writeb(uint8 v, volatile uint8 *r)
17277 +{
17278 + writeb(v, r);
17279 +}
17280 +
17281 +void *
17282 +osl_uncached(void *va)
17283 +{
17284 +#ifdef mips
17285 + return ((void*)KSEG1ADDR(va));
17286 +#else
17287 + return ((void*)va);
17288 +#endif
17289 +}
17290 +
17291 +uint
17292 +osl_getcycles(void)
17293 +{
17294 + uint cycles;
17295 +
17296 +#if defined(mips)
17297 + cycles = read_c0_count() * 2;
17298 +#elif defined(__i386__)
17299 + rdtscl(cycles);
17300 +#else
17301 + cycles = 0;
17302 +#endif
17303 + return cycles;
17304 +}
17305 +
17306 +void *
17307 +osl_reg_map(uint32 pa, uint size)
17308 +{
17309 + return (ioremap_nocache((unsigned long)pa, (unsigned long)size));
17310 +}
17311 +
17312 +void
17313 +osl_reg_unmap(void *va)
17314 +{
17315 + iounmap(va);
17316 +}
17317 +
17318 +int
17319 +osl_busprobe(uint32 *val, uint32 addr)
17320 +{
17321 +#ifdef mips
17322 + return get_dbe(*val, (uint32*)addr);
17323 +#else
17324 + *val = readl(addr);
17325 + return 0;
17326 +#endif
17327 +}
17328 +
17329 +void
17330 +osl_delay(uint usec)
17331 +{
17332 + udelay(usec);
17333 +}
17334 +
17335 +uchar*
17336 +osl_pktdata(void *drv, void *skb)
17337 +{
17338 + return (((struct sk_buff*)skb)->data);
17339 +}
17340 +
17341 +uint
17342 +osl_pktlen(void *drv, void *skb)
17343 +{
17344 + return (((struct sk_buff*)skb)->len);
17345 +}
17346 +
17347 +uint
17348 +osl_pktheadroom(void *drv, void *skb)
17349 +{
17350 + return (uint) skb_headroom((struct sk_buff *) skb);
17351 +}
17352 +
17353 +uint
17354 +osl_pkttailroom(void *drv, void *skb)
17355 +{
17356 + return (uint) skb_tailroom((struct sk_buff *) skb);
17357 +}
17358 +
17359 +void*
17360 +osl_pktnext(void *drv, void *skb)
17361 +{
17362 + return (((struct sk_buff*)skb)->next);
17363 +}
17364 +
17365 +void
17366 +osl_pktsetnext(void *skb, void *x)
17367 +{
17368 + ((struct sk_buff*)skb)->next = (struct sk_buff*)x;
17369 +}
17370 +
17371 +void
17372 +osl_pktsetlen(void *drv, void *skb, uint len)
17373 +{
17374 + __skb_trim((struct sk_buff*)skb, len);
17375 +}
17376 +
17377 +uchar*
17378 +osl_pktpush(void *drv, void *skb, int bytes)
17379 +{
17380 + return (skb_push((struct sk_buff*)skb, bytes));
17381 +}
17382 +
17383 +uchar*
17384 +osl_pktpull(void *drv, void *skb, int bytes)
17385 +{
17386 + return (skb_pull((struct sk_buff*)skb, bytes));
17387 +}
17388 +
17389 +void*
17390 +osl_pktdup(void *drv, void *skb)
17391 +{
17392 + return (skb_clone((struct sk_buff*)skb, GFP_ATOMIC));
17393 +}
17394 +
17395 +void*
17396 +osl_pktcookie(void *skb)
17397 +{
17398 + return ((void*)((struct sk_buff*)skb)->csum);
17399 +}
17400 +
17401 +void
17402 +osl_pktsetcookie(void *skb, void *x)
17403 +{
17404 + ((struct sk_buff*)skb)->csum = (uint)x;
17405 +}
17406 +
17407 +void*
17408 +osl_pktlink(void *skb)
17409 +{
17410 + return (((struct sk_buff*)skb)->prev);
17411 +}
17412 +
17413 +void
17414 +osl_pktsetlink(void *skb, void *x)
17415 +{
17416 + ((struct sk_buff*)skb)->prev = (struct sk_buff*)x;
17417 +}
17418 +
17419 +uint
17420 +osl_pktprio(void *skb)
17421 +{
17422 + return (((struct sk_buff*)skb)->priority);
17423 +}
17424 +
17425 +void
17426 +osl_pktsetprio(void *skb, uint x)
17427 +{
17428 + ((struct sk_buff*)skb)->priority = x;
17429 +}
17430 +
17431 +#endif /* BINOSL */
17432 diff -Nur linux-2.4.30/drivers/net/hnd/Makefile linux-2.4.30-brcm/drivers/net/hnd/Makefile
17433 --- linux-2.4.30/drivers/net/hnd/Makefile 1970-01-01 01:00:00.000000000 +0100
17434 +++ linux-2.4.30-brcm/drivers/net/hnd/Makefile 2005-05-25 18:54:08.000000000 +0200
17435 @@ -0,0 +1,19 @@
17436 +#
17437 +# Makefile for the BCM47xx specific kernel interface routines
17438 +# under Linux.
17439 +#
17440 +
17441 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
17442 +
17443 +O_TARGET := hnd.o
17444 +
17445 +HND_OBJS := bcmutils.o hnddma.o linux_osl.o sbutils.o bcmsrom.o
17446 +
17447 +export-objs := shared_ksyms.o
17448 +obj-y := shared_ksyms.o $(HND_OBJS)
17449 +obj-m := $(O_TARGET)
17450 +
17451 +include $(TOPDIR)/Rules.make
17452 +
17453 +shared_ksyms.c: shared_ksyms.sh $(HND_OBJS)
17454 + sh -e $< $(HND_OBJS) > $@
17455 diff -Nur linux-2.4.30/drivers/net/hnd/sbutils.c linux-2.4.30-brcm/drivers/net/hnd/sbutils.c
17456 --- linux-2.4.30/drivers/net/hnd/sbutils.c 1970-01-01 01:00:00.000000000 +0100
17457 +++ linux-2.4.30-brcm/drivers/net/hnd/sbutils.c 2005-05-22 23:01:41.000000000 +0200
17458 @@ -0,0 +1,2063 @@
17459 +/*
17460 + * Misc utility routines for accessing chip-specific features
17461 + * of the SiliconBackplane-based Broadcom chips.
17462 + *
17463 + * Copyright 2004, Broadcom Corporation
17464 + * All Rights Reserved.
17465 + *
17466 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
17467 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
17468 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
17469 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
17470 + * $Id$
17471 + */
17472 +
17473 +#include <typedefs.h>
17474 +#include <osl.h>
17475 +#include <bcmutils.h>
17476 +#include <bcmdevs.h>
17477 +#include <sbconfig.h>
17478 +#include <sbchipc.h>
17479 +#include <sbpci.h>
17480 +#include <pcicfg.h>
17481 +#include <sbpcmcia.h>
17482 +#include <sbextif.h>
17483 +#include <sbutils.h>
17484 +#include <bcmsrom.h>
17485 +
17486 +/* debug/trace */
17487 +#define SB_ERROR(args)
17488 +
17489 +
17490 +#define CLOCK_BASE_5350 12500000 /* Specific to 5350*/
17491 +
17492 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg);
17493 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg);
17494 +typedef bool (*sb_intrsenabled_t)(void *intr_arg);
17495 +
17496 +/* misc sb info needed by some of the routines */
17497 +typedef struct sb_info {
17498 + uint chip; /* chip number */
17499 + uint chiprev; /* chip revision */
17500 + uint chippkg; /* chip package option */
17501 + uint boardtype; /* board type */
17502 + uint boardvendor; /* board vendor id */
17503 + uint bustype; /* what bus type we are going through */
17504 +
17505 + void *osh; /* osl os handle */
17506 + void *sdh; /* bcmsdh handle */
17507 +
17508 + void *curmap; /* current regs va */
17509 + void *regs[SB_MAXCORES]; /* other regs va */
17510 +
17511 + uint curidx; /* current core index */
17512 + uint dev_coreid; /* the core provides driver functions */
17513 + uint pciidx; /* pci core index */
17514 + uint pcirev; /* pci core rev */
17515 +
17516 + uint pcmciaidx; /* pcmcia core index */
17517 + uint pcmciarev; /* pcmcia core rev */
17518 + bool memseg; /* flag to toggle MEM_SEG register */
17519 +
17520 + uint ccrev; /* chipc core rev */
17521 +
17522 + uint gpioidx; /* gpio control core index */
17523 + uint gpioid; /* gpio control coretype */
17524 +
17525 + uint numcores; /* # discovered cores */
17526 + uint coreid[SB_MAXCORES]; /* id of each core */
17527 +
17528 + void *intr_arg; /* interrupt callback function arg */
17529 + sb_intrsoff_t intrsoff_fn; /* function turns chip interrupts off */
17530 + sb_intrsrestore_t intrsrestore_fn; /* function restore chip interrupts */
17531 + sb_intrsenabled_t intrsenabled_fn; /* function to check if chip interrupts are enabled */
17532 +} sb_info_t;
17533 +
17534 +/* local prototypes */
17535 +static void* BCMINIT(sb_doattach)(sb_info_t *si, uint devid, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz);
17536 +static void BCMINIT(sb_scan)(sb_info_t *si);
17537 +static uint sb_corereg(void *sbh, uint coreidx, uint regoff, uint mask, uint val);
17538 +static uint _sb_coreidx(void *sbh);
17539 +static uint sb_findcoreidx(void *sbh, uint coreid, uint coreunit);
17540 +static uint BCMINIT(sb_pcidev2chip)(uint pcidev);
17541 +static uint BCMINIT(sb_chip2numcores)(uint chip);
17542 +
17543 +#define SB_INFO(sbh) (sb_info_t*)sbh
17544 +#define SET_SBREG(sbh, r, mask, val) W_SBREG((sbh), (r), ((R_SBREG((sbh), (r)) & ~(mask)) | (val)))
17545 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && ISALIGNED((x), SB_CORE_SIZE))
17546 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE))
17547 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF)
17548 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES)
17549 +#define BADIDX (SB_MAXCORES+1)
17550 +#define NOREV (SBIDH_RC_MASK + 1)
17551 +
17552 +#define R_SBREG(sbh, sbr) sb_read_sbreg((sbh), (sbr))
17553 +#define W_SBREG(sbh, sbr, v) sb_write_sbreg((sbh), (sbr), (v))
17554 +#define AND_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) & (v)))
17555 +#define OR_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) | (v)))
17556 +
17557 +/*
17558 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/
17559 + * after core switching to avoid invalid register accesss inside ISR.
17560 + */
17561 +#define INTR_OFF(si, intr_val) \
17562 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
17563 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); }
17564 +#define INTR_RESTORE(si, intr_val) \
17565 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
17566 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
17567 +
17568 +/* power control defines */
17569 +#define LPOMINFREQ 25000 /* low power oscillator min */
17570 +#define LPOMAXFREQ 43000 /* low power oscillator max */
17571 +#define XTALMINFREQ 19800000 /* 20mhz - 1% */
17572 +#define XTALMAXFREQ 20200000 /* 20mhz + 1% */
17573 +#define PCIMINFREQ 25000000 /* 25mhz */
17574 +#define PCIMAXFREQ 34000000 /* 33mhz + fudge */
17575 +#define SCC_DEF_DIV 0 /* default slow clock divider */
17576 +
17577 +#define XTAL_ON_DELAY 1000 /* Xtal power on delay in us */
17578 +
17579 +#define SCC_LOW2FAST_LIMIT 5000 /* turn on fast clock time, in unit of ms */
17580 +
17581 +static uint32
17582 +sb_read_sbreg(void *sbh, volatile uint32 *sbr)
17583 +{
17584 + sb_info_t *si;
17585 + uint8 tmp;
17586 + uint32 val, intr_val = 0;
17587 +
17588 + si = SB_INFO(sbh);
17589 +
17590 + /*
17591 + * compact flash only has 11 bits address, while we needs 12 bits address.
17592 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
17593 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
17594 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
17595 + */
17596 + if(si->memseg) {
17597 + INTR_OFF(si, intr_val);
17598 + tmp = 1;
17599 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
17600 + (uintptr)sbr &= ~(1 << 11); /* mask out bit 11*/
17601 + }
17602 +
17603 + val = R_REG(sbr);
17604 +
17605 + if(si->memseg) {
17606 + tmp = 0;
17607 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
17608 + INTR_RESTORE(si, intr_val);
17609 + }
17610 +
17611 + return (val);
17612 +}
17613 +
17614 +static void
17615 +sb_write_sbreg(void *sbh, volatile uint32 *sbr, uint32 v)
17616 +{
17617 + sb_info_t *si;
17618 + uint8 tmp;
17619 + volatile uint32 dummy;
17620 + uint32 intr_val = 0;
17621 +
17622 + si = SB_INFO(sbh);
17623 +
17624 + /*
17625 + * compact flash only has 11 bits address, while we needs 12 bits address.
17626 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
17627 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
17628 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
17629 + */
17630 + if(si->memseg) {
17631 + INTR_OFF(si, intr_val);
17632 + tmp = 1;
17633 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
17634 + (uintptr)sbr &= ~(1 << 11); /* mask out bit 11 */
17635 + }
17636 +
17637 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) {
17638 +#ifdef IL_BIGENDIAN
17639 + dummy = R_REG(sbr);
17640 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
17641 + dummy = R_REG(sbr);
17642 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
17643 +#else
17644 + dummy = R_REG(sbr);
17645 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
17646 + dummy = R_REG(sbr);
17647 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
17648 +#endif
17649 + } else
17650 + W_REG(sbr, v);
17651 +
17652 + if(si->memseg) {
17653 + tmp = 0;
17654 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
17655 + INTR_RESTORE(si, intr_val);
17656 + }
17657 +}
17658 +
17659 +/*
17660 + * Allocate a sb handle.
17661 + * devid - pci device id (used to determine chip#)
17662 + * osh - opaque OS handle
17663 + * regs - virtual address of initial core registers
17664 + * bustype - pci/pcmcia/sb/sdio/etc
17665 + * vars - pointer to a pointer area for "environment" variables
17666 + * varsz - pointer to int to return the size of the vars
17667 + */
17668 +void*
17669 +BCMINITFN(sb_attach)(uint devid, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz)
17670 +{
17671 + sb_info_t *si;
17672 +
17673 + /* alloc sb_info_t */
17674 + if ((si = MALLOC(osh, sizeof (sb_info_t))) == NULL) {
17675 + SB_ERROR(("sb_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh)));
17676 + return (NULL);
17677 + }
17678 +
17679 + if (BCMINIT(sb_doattach)(si, devid, osh, regs, bustype, sdh, vars, varsz) == NULL) {
17680 + MFREE(osh, si, sizeof (sb_info_t));
17681 + return (NULL);
17682 + }
17683 + return si;
17684 +}
17685 +
17686 +/* Using sb_kattach depends on SB_BUS support, either implicit */
17687 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */
17688 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS)
17689 +
17690 +/* global kernel resource */
17691 +static sb_info_t ksi;
17692 +
17693 +/* generic kernel variant of sb_attach() */
17694 +void*
17695 +BCMINITFN(sb_kattach)()
17696 +{
17697 + uint32 *regs;
17698 + char *unused;
17699 + int varsz;
17700 +
17701 + if (ksi.curmap == NULL) {
17702 + uint32 cid;
17703 +
17704 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE);
17705 + cid = R_REG((uint32 *)regs);
17706 + if (((cid & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
17707 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) &&
17708 + ((cid & CID_REV_MASK) <= 0x00020000)) {
17709 + uint32 *scc, val;
17710 +
17711 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl));
17712 + val = R_REG(scc);
17713 + SB_ERROR((" initial scc = 0x%x\n", val));
17714 + val |= SCC_SS_XTAL;
17715 + W_REG(scc, val);
17716 + }
17717 +
17718 + if (BCMINIT(sb_doattach)(&ksi, BCM4710_DEVICE_ID, NULL, (void*)regs,
17719 + SB_BUS, NULL, &unused, &varsz) == NULL) {
17720 + return NULL;
17721 + }
17722 + }
17723 +
17724 + return &ksi;
17725 +}
17726 +#endif
17727 +
17728 +static void*
17729 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz)
17730 +{
17731 + uint origidx;
17732 + chipcregs_t *cc;
17733 + uint32 w;
17734 + int res;
17735 +
17736 + ASSERT(GOODREGS(regs));
17737 +
17738 + bzero((uchar*)si, sizeof (sb_info_t));
17739 +
17740 + si->pciidx = si->gpioidx = BADIDX;
17741 +
17742 + si->osh = osh;
17743 + si->curmap = regs;
17744 + si->sdh = sdh;
17745 +
17746 + /* check to see if we are a sb core mimic'ing a pci core */
17747 + if (bustype == PCI_BUS) {
17748 + if (OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof (uint32)) == 0xffffffff)
17749 + bustype = SB_BUS;
17750 + else
17751 + bustype = PCI_BUS;
17752 + }
17753 +
17754 + si->bustype = bustype;
17755 + if (si->bustype != BUSTYPE(si->bustype)) {
17756 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n",
17757 + si->bustype, BUSTYPE(si->bustype)));
17758 + return NULL;
17759 + }
17760 +
17761 + /* need to set memseg flag for CF card first before any sb registers access */
17762 + if (BUSTYPE(si->bustype) == PCMCIA_BUS)
17763 + si->memseg = TRUE;
17764 +
17765 + /* kludge to enable the clock on the 4306 which lacks a slowclock */
17766 + if (BUSTYPE(si->bustype) == PCI_BUS)
17767 + sb_pwrctl_xtal((void*)si, XTAL|PLL, ON);
17768 +
17769 + /* initialize current core index value */
17770 + si->curidx = _sb_coreidx((void*)si);
17771 + if (si->curidx == BADIDX) {
17772 + return NULL;
17773 + }
17774 +
17775 + /* keep and reuse the initial register mapping */
17776 + origidx = si->curidx;
17777 + if (BUSTYPE(si->bustype) == SB_BUS)
17778 + si->regs[origidx] = regs;
17779 +
17780 + /* is core-0 a chipcommon core? */
17781 + si->numcores = 1;
17782 + cc = (chipcregs_t*) sb_setcoreidx((void*)si, 0);
17783 + if (sb_coreid((void*)si) != SB_CC)
17784 + cc = NULL;
17785 +
17786 + /* determine chip id and rev */
17787 + if (cc) {
17788 + /* chip common core found! */
17789 + si->chip = R_REG(&cc->chipid) & CID_ID_MASK;
17790 + si->chiprev = (R_REG(&cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT;
17791 + si->chippkg = (R_REG(&cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT;
17792 + } else {
17793 + /* The only pcmcia chip without a chipcommon core is a 4301 */
17794 + if (BUSTYPE(si->bustype) == PCMCIA_BUS)
17795 + devid = BCM4301_DEVICE_ID;
17796 +
17797 + /* no chip common core -- must convert device id to chip id */
17798 + if ((si->chip = BCMINIT(sb_pcidev2chip)(devid)) == 0) {
17799 + SB_ERROR(("sb_attach: unrecognized device id 0x%04x\n", devid));
17800 + return NULL;
17801 + }
17802 + }
17803 +
17804 + /* get chipcommon rev */
17805 + si->ccrev = cc ? sb_corerev((void*)si) : NOREV;
17806 +
17807 + /* determine numcores */
17808 + if (cc && ((si->ccrev == 4) || (si->ccrev >= 6)))
17809 + si->numcores = (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT;
17810 + else
17811 + si->numcores = BCMINIT(sb_chip2numcores)(si->chip);
17812 +
17813 + /* return to original core */
17814 + sb_setcoreidx((void*)si, origidx);
17815 +
17816 + /* sanity checks */
17817 + ASSERT(si->chip);
17818 +
17819 + /* scan for cores */
17820 + BCMINIT(sb_scan)(si);
17821 +
17822 + /* srom_var_init() depends on sb_scan() info */
17823 + if ((res = srom_var_init(si, si->bustype, si->curmap, osh, vars, varsz))) {
17824 + SB_ERROR(("sb_attach: srom_var_init failed: bad srom\n"));
17825 + return (NULL);
17826 + }
17827 +
17828 + if (cc == NULL) {
17829 + /*
17830 + * The chip revision number is hardwired into all
17831 + * of the pci function config rev fields and is
17832 + * independent from the individual core revision numbers.
17833 + * For example, the "A0" silicon of each chip is chip rev 0.
17834 + * For PCMCIA we get it from the CIS instead.
17835 + */
17836 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) {
17837 + ASSERT(vars);
17838 + si->chiprev = getintvar(*vars, "chiprev");
17839 + } else if (BUSTYPE(si->bustype) == PCI_BUS) {
17840 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_REV, sizeof (uint32));
17841 + si->chiprev = w & 0xff;
17842 + } else
17843 + si->chiprev = 0;
17844 + }
17845 +
17846 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) {
17847 + w = getintvar(*vars, "regwindowsz");
17848 + si->memseg = (w <= CFTABLE_REGWIN_2K) ? TRUE : FALSE;
17849 + }
17850 +
17851 + /* gpio control core is required */
17852 + if (!GOODIDX(si->gpioidx)) {
17853 + SB_ERROR(("sb_attach: gpio control core not found\n"));
17854 + return NULL;
17855 + }
17856 +
17857 + /* get boardtype and boardrev */
17858 + switch (BUSTYPE(si->bustype)) {
17859 + case PCI_BUS:
17860 + /* do a pci config read to get subsystem id and subvendor id */
17861 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_SVID, sizeof (uint32));
17862 + si->boardvendor = w & 0xffff;
17863 + si->boardtype = (w >> 16) & 0xffff;
17864 + break;
17865 +
17866 + case PCMCIA_BUS:
17867 + case SDIO_BUS:
17868 + si->boardvendor = getintvar(*vars, "manfid");
17869 + si->boardtype = getintvar(*vars, "prodid");
17870 + break;
17871 +
17872 + case SB_BUS:
17873 + si->boardvendor = VENDOR_BROADCOM;
17874 + si->boardtype = 0xffff;
17875 + break;
17876 + }
17877 +
17878 + if (si->boardtype == 0) {
17879 + SB_ERROR(("sb_attach: unknown board type\n"));
17880 + ASSERT(si->boardtype);
17881 + }
17882 +
17883 +
17884 + return ((void*)si);
17885 +}
17886 +
17887 +uint
17888 +sb_coreid(void *sbh)
17889 +{
17890 + sb_info_t *si;
17891 + sbconfig_t *sb;
17892 +
17893 + si = SB_INFO(sbh);
17894 + sb = REGS2SB(si->curmap);
17895 +
17896 + return ((R_SBREG(sbh, &(sb)->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT);
17897 +}
17898 +
17899 +uint
17900 +sb_coreidx(void *sbh)
17901 +{
17902 + sb_info_t *si;
17903 +
17904 + si = SB_INFO(sbh);
17905 + return (si->curidx);
17906 +}
17907 +
17908 +/* return current index of core */
17909 +static uint
17910 +_sb_coreidx(void *sbh)
17911 +{
17912 + sb_info_t *si;
17913 + sbconfig_t *sb;
17914 + uint32 sbaddr = 0;
17915 +
17916 + si = SB_INFO(sbh);
17917 + ASSERT(si);
17918 +
17919 + switch (BUSTYPE(si->bustype)) {
17920 + case SB_BUS:
17921 + sb = REGS2SB(si->curmap);
17922 + sbaddr = sb_base(R_SBREG(sbh, &sb->sbadmatch0));
17923 + break;
17924 +
17925 + case PCI_BUS:
17926 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32));
17927 + break;
17928 +
17929 + case PCMCIA_BUS: {
17930 + uint8 tmp = 0;
17931 +
17932 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
17933 + sbaddr = (uint)tmp << 12;
17934 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
17935 + sbaddr |= (uint)tmp << 16;
17936 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
17937 + sbaddr |= (uint)tmp << 24;
17938 + break;
17939 + }
17940 + default:
17941 + ASSERT(0);
17942 + }
17943 +
17944 + if (!GOODCOREADDR(sbaddr))
17945 + return BADIDX;
17946 +
17947 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE);
17948 +}
17949 +
17950 +uint
17951 +sb_corevendor(void *sbh)
17952 +{
17953 + sb_info_t *si;
17954 + sbconfig_t *sb;
17955 +
17956 + si = SB_INFO(sbh);
17957 + sb = REGS2SB(si->curmap);
17958 +
17959 + return ((R_SBREG(sbh, &(sb)->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT);
17960 +}
17961 +
17962 +uint
17963 +sb_corerev(void *sbh)
17964 +{
17965 + sb_info_t *si;
17966 + sbconfig_t *sb;
17967 +
17968 + si = SB_INFO(sbh);
17969 + sb = REGS2SB(si->curmap);
17970 +
17971 + return (R_SBREG(sbh, &(sb)->sbidhigh) & SBIDH_RC_MASK);
17972 +}
17973 +
17974 +void *
17975 +sb_osh(void *sbh)
17976 +{
17977 + sb_info_t *si;
17978 +
17979 + si = SB_INFO(sbh);
17980 + return si->osh;
17981 +}
17982 +
17983 +#define SBTML_ALLOW (SBTML_PE | SBTML_FGC | SBTML_FL_MASK)
17984 +
17985 +/* set/clear sbtmstatelow core-specific flags */
17986 +uint32
17987 +sb_coreflags(void *sbh, uint32 mask, uint32 val)
17988 +{
17989 + sb_info_t *si;
17990 + sbconfig_t *sb;
17991 + uint32 w;
17992 +
17993 + si = SB_INFO(sbh);
17994 + sb = REGS2SB(si->curmap);
17995 +
17996 + ASSERT((val & ~mask) == 0);
17997 + ASSERT((mask & ~SBTML_ALLOW) == 0);
17998 +
17999 + /* mask and set */
18000 + if (mask || val) {
18001 + w = (R_SBREG(sbh, &sb->sbtmstatelow) & ~mask) | val;
18002 + W_SBREG(sbh, &sb->sbtmstatelow, w);
18003 + }
18004 +
18005 + /* return the new value */
18006 + return (R_SBREG(sbh, &sb->sbtmstatelow) & SBTML_ALLOW);
18007 +}
18008 +
18009 +/* set/clear sbtmstatehigh core-specific flags */
18010 +uint32
18011 +sb_coreflagshi(void *sbh, uint32 mask, uint32 val)
18012 +{
18013 + sb_info_t *si;
18014 + sbconfig_t *sb;
18015 + uint32 w;
18016 +
18017 + si = SB_INFO(sbh);
18018 + sb = REGS2SB(si->curmap);
18019 +
18020 + ASSERT((val & ~mask) == 0);
18021 + ASSERT((mask & ~SBTMH_FL_MASK) == 0);
18022 +
18023 + /* mask and set */
18024 + if (mask || val) {
18025 + w = (R_SBREG(sbh, &sb->sbtmstatehigh) & ~mask) | val;
18026 + W_SBREG(sbh, &sb->sbtmstatehigh, w);
18027 + }
18028 +
18029 + /* return the new value */
18030 + return (R_SBREG(sbh, &sb->sbtmstatehigh) & SBTMH_FL_MASK);
18031 +}
18032 +
18033 +bool
18034 +sb_iscoreup(void *sbh)
18035 +{
18036 + sb_info_t *si;
18037 + sbconfig_t *sb;
18038 +
18039 + si = SB_INFO(sbh);
18040 + sb = REGS2SB(si->curmap);
18041 +
18042 + return ((R_SBREG(sbh, &(sb)->sbtmstatelow) & (SBTML_RESET | SBTML_REJ | SBTML_CLK)) == SBTML_CLK);
18043 +}
18044 +
18045 +/*
18046 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation,
18047 + * switch back to the original core, and return the new value.
18048 + */
18049 +static uint
18050 +sb_corereg(void *sbh, uint coreidx, uint regoff, uint mask, uint val)
18051 +{
18052 + sb_info_t *si;
18053 + uint origidx;
18054 + uint32 *r;
18055 + uint w;
18056 + uint intr_val = 0;
18057 +
18058 + ASSERT(GOODIDX(coreidx));
18059 + ASSERT(regoff < SB_CORE_SIZE);
18060 + ASSERT((val & ~mask) == 0);
18061 +
18062 + si = SB_INFO(sbh);
18063 +
18064 + INTR_OFF(si, intr_val);
18065 +
18066 + /* save current core index */
18067 + origidx = sb_coreidx(sbh);
18068 +
18069 + /* switch core */
18070 + r = (uint32*) ((uchar*) sb_setcoreidx(sbh, coreidx) + regoff);
18071 +
18072 + /* mask and set */
18073 + if (mask || val) {
18074 + if (regoff >= SBCONFIGOFF) {
18075 + w = (R_SBREG(sbh, r) & ~mask) | val;
18076 + W_SBREG(sbh, r, w);
18077 + } else {
18078 + w = (R_REG(r) & ~mask) | val;
18079 + W_REG(r, w);
18080 + }
18081 + }
18082 +
18083 + /* readback */
18084 + if (regoff >= SBCONFIGOFF)
18085 + w = R_SBREG(sbh, r);
18086 + else
18087 + w = R_REG(r);
18088 +
18089 + /* restore core index */
18090 + if (origidx != coreidx)
18091 + sb_setcoreidx(sbh, origidx);
18092 +
18093 + INTR_RESTORE(si, intr_val);
18094 + return (w);
18095 +}
18096 +
18097 +/* scan the sb enumerated space to identify all cores */
18098 +static void
18099 +BCMINITFN(sb_scan)(sb_info_t *si)
18100 +{
18101 + void *sbh;
18102 + uint origidx;
18103 + uint i;
18104 +
18105 + sbh = (void*) si;
18106 +
18107 + /* numcores should already be set */
18108 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES));
18109 +
18110 + /* save current core index */
18111 + origidx = sb_coreidx(sbh);
18112 +
18113 + si->pciidx = si->pcmciaidx = si->gpioidx = BADIDX;
18114 + si->pcirev = si->pcmciarev = NOREV;
18115 +
18116 + for (i = 0; i < si->numcores; i++) {
18117 + sb_setcoreidx(sbh, i);
18118 + si->coreid[i] = sb_coreid(sbh);
18119 +
18120 + if (si->coreid[i] == SB_PCI) {
18121 + si->pciidx = i;
18122 + si->pcirev = sb_corerev(sbh);
18123 +
18124 + } else if (si->coreid[i] == SB_PCMCIA) {
18125 + si->pcmciaidx = i;
18126 + si->pcmciarev = sb_corerev(sbh);
18127 + }
18128 + }
18129 +
18130 + /*
18131 + * Find the gpio "controlling core" type and index.
18132 + * Precedence:
18133 + * - if there's a chip common core - use that
18134 + * - else if there's a pci core (rev >= 2) - use that
18135 + * - else there had better be an extif core (4710 only)
18136 + */
18137 + if (GOODIDX(sb_findcoreidx(sbh, SB_CC, 0))) {
18138 + si->gpioidx = sb_findcoreidx(sbh, SB_CC, 0);
18139 + si->gpioid = SB_CC;
18140 + } else if (GOODIDX(si->pciidx) && (si->pcirev >= 2)) {
18141 + si->gpioidx = si->pciidx;
18142 + si->gpioid = SB_PCI;
18143 + } else if (sb_findcoreidx(sbh, SB_EXTIF, 0)) {
18144 + si->gpioidx = sb_findcoreidx(sbh, SB_EXTIF, 0);
18145 + si->gpioid = SB_EXTIF;
18146 + } else
18147 + ASSERT(si->gpioidx != BADIDX);
18148 +
18149 + /* return to original core index */
18150 + sb_setcoreidx(sbh, origidx);
18151 +}
18152 +
18153 +/* may be called with core in reset */
18154 +void
18155 +sb_detach(void *sbh)
18156 +{
18157 + sb_info_t *si;
18158 + uint idx;
18159 +
18160 + si = SB_INFO(sbh);
18161 +
18162 + if (si == NULL)
18163 + return;
18164 +
18165 + if (BUSTYPE(si->bustype) == SB_BUS)
18166 + for (idx = 0; idx < SB_MAXCORES; idx++)
18167 + if (si->regs[idx]) {
18168 + REG_UNMAP(si->regs[idx]);
18169 + si->regs[idx] = NULL;
18170 + }
18171 +
18172 + MFREE(si->osh, si, sizeof (sb_info_t));
18173 +}
18174 +
18175 +/* use pci dev id to determine chip id for chips not having a chipcommon core */
18176 +static uint
18177 +BCMINITFN(sb_pcidev2chip)(uint pcidev)
18178 +{
18179 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID))
18180 + return (BCM4710_DEVICE_ID);
18181 + if ((pcidev >= BCM4610_DEVICE_ID) && (pcidev <= BCM4610_USB_ID))
18182 + return (BCM4610_DEVICE_ID);
18183 + if ((pcidev >= BCM4402_DEVICE_ID) && (pcidev <= BCM4402_V90_ID))
18184 + return (BCM4402_DEVICE_ID);
18185 + if (pcidev == BCM4401_ENET_ID)
18186 + return (BCM4402_DEVICE_ID);
18187 + if ((pcidev >= BCM4307_V90_ID) && (pcidev <= BCM4307_D11B_ID))
18188 + return (BCM4307_DEVICE_ID);
18189 + if (pcidev == BCM4301_DEVICE_ID)
18190 + return (BCM4301_DEVICE_ID);
18191 +
18192 + return (0);
18193 +}
18194 +
18195 +/* convert chip number to number of i/o cores */
18196 +static uint
18197 +BCMINITFN(sb_chip2numcores)(uint chip)
18198 +{
18199 + if (chip == 0x4710)
18200 + return (9);
18201 + if (chip == 0x4610)
18202 + return (9);
18203 + if (chip == 0x4402)
18204 + return (3);
18205 + if ((chip == 0x4307) || (chip == 0x4301))
18206 + return (5);
18207 + if (chip == 0x4310)
18208 + return (8);
18209 + if (chip == 0x4306) /* < 4306c0 */
18210 + return (6);
18211 + if (chip == 0x4704)
18212 + return (9);
18213 + if (chip == 0x5365)
18214 + return (7);
18215 +
18216 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip));
18217 + ASSERT(0);
18218 + return (1);
18219 +}
18220 +
18221 +/* return index of coreid or BADIDX if not found */
18222 +static uint
18223 +sb_findcoreidx(void *sbh, uint coreid, uint coreunit)
18224 +{
18225 + sb_info_t *si;
18226 + uint found;
18227 + uint i;
18228 +
18229 + si = SB_INFO(sbh);
18230 + found = 0;
18231 +
18232 + for (i = 0; i < si->numcores; i++)
18233 + if (si->coreid[i] == coreid) {
18234 + if (found == coreunit)
18235 + return (i);
18236 + found++;
18237 + }
18238 +
18239 + return (BADIDX);
18240 +}
18241 +
18242 +/*
18243 + * this function changes logical "focus" to the indiciated core,
18244 + * must be called with interrupt off.
18245 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
18246 + */
18247 +void*
18248 +sb_setcoreidx(void *sbh, uint coreidx)
18249 +{
18250 + sb_info_t *si;
18251 + uint32 sbaddr;
18252 + uint8 tmp;
18253 +
18254 + si = SB_INFO(sbh);
18255 +
18256 + if (coreidx >= si->numcores)
18257 + return (NULL);
18258 +
18259 + /*
18260 + * If the user has provided an interrupt mask enabled function,
18261 + * then assert interrupts are disabled before switching the core.
18262 + */
18263 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg));
18264 +
18265 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE);
18266 +
18267 + switch (BUSTYPE(si->bustype)) {
18268 + case SB_BUS:
18269 + /* map new one */
18270 + if (!si->regs[coreidx]) {
18271 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE);
18272 + ASSERT(GOODREGS(si->regs[coreidx]));
18273 + }
18274 + si->curmap = si->regs[coreidx];
18275 + break;
18276 +
18277 + case PCI_BUS:
18278 + /* point bar0 window */
18279 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr);
18280 + break;
18281 +
18282 + case PCMCIA_BUS:
18283 + tmp = (sbaddr >> 12) & 0x0f;
18284 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
18285 + tmp = (sbaddr >> 16) & 0xff;
18286 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
18287 + tmp = (sbaddr >> 24) & 0xff;
18288 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
18289 + break;
18290 + }
18291 +
18292 + si->curidx = coreidx;
18293 +
18294 + return (si->curmap);
18295 +}
18296 +
18297 +/*
18298 + * this function changes logical "focus" to the indiciated core,
18299 + * must be called with interrupt off.
18300 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
18301 + */
18302 +void*
18303 +sb_setcore(void *sbh, uint coreid, uint coreunit)
18304 +{
18305 + sb_info_t *si;
18306 + uint idx;
18307 +
18308 + si = SB_INFO(sbh);
18309 +
18310 + idx = sb_findcoreidx(sbh, coreid, coreunit);
18311 + if (!GOODIDX(idx))
18312 + return (NULL);
18313 +
18314 + return (sb_setcoreidx(sbh, idx));
18315 +}
18316 +
18317 +/* return chip number */
18318 +uint
18319 +BCMINITFN(sb_chip)(void *sbh)
18320 +{
18321 + sb_info_t *si;
18322 +
18323 + si = SB_INFO(sbh);
18324 + return (si->chip);
18325 +}
18326 +
18327 +/* return chip revision number */
18328 +uint
18329 +BCMINITFN(sb_chiprev)(void *sbh)
18330 +{
18331 + sb_info_t *si;
18332 +
18333 + si = SB_INFO(sbh);
18334 + return (si->chiprev);
18335 +}
18336 +
18337 +/* return chip common revision number */
18338 +uint
18339 +BCMINITFN(sb_chipcrev)(void *sbh)
18340 +{
18341 + sb_info_t *si;
18342 +
18343 + si = SB_INFO(sbh);
18344 + return (si->ccrev);
18345 +}
18346 +
18347 +/* return chip package option */
18348 +uint
18349 +BCMINITFN(sb_chippkg)(void *sbh)
18350 +{
18351 + sb_info_t *si;
18352 +
18353 + si = SB_INFO(sbh);
18354 + return (si->chippkg);
18355 +}
18356 +
18357 +/* return PCI core rev. */
18358 +uint
18359 +BCMINITFN(sb_pcirev)(void *sbh)
18360 +{
18361 + sb_info_t *si;
18362 +
18363 + si = SB_INFO(sbh);
18364 + return (si->pcirev);
18365 +}
18366 +
18367 +/* return PCMCIA core rev. */
18368 +uint
18369 +BCMINITFN(sb_pcmciarev)(void *sbh)
18370 +{
18371 + sb_info_t *si;
18372 +
18373 + si = SB_INFO(sbh);
18374 + return (si->pcmciarev);
18375 +}
18376 +
18377 +/* return board vendor id */
18378 +uint
18379 +BCMINITFN(sb_boardvendor)(void *sbh)
18380 +{
18381 + sb_info_t *si;
18382 +
18383 + si = SB_INFO(sbh);
18384 + return (si->boardvendor);
18385 +}
18386 +
18387 +/* return boardtype */
18388 +uint
18389 +BCMINITFN(sb_boardtype)(void *sbh)
18390 +{
18391 + sb_info_t *si;
18392 + char *var;
18393 +
18394 + si = SB_INFO(sbh);
18395 +
18396 + if (BUSTYPE(si->bustype) == SB_BUS && si->boardtype == 0xffff) {
18397 + /* boardtype format is a hex string */
18398 + si->boardtype = getintvar(NULL, "boardtype");
18399 +
18400 + /* backward compatibility for older boardtype string format */
18401 + if ((si->boardtype == 0) && (var = getvar(NULL, "boardtype"))) {
18402 + if (!strcmp(var, "bcm94710dev"))
18403 + si->boardtype = BCM94710D_BOARD;
18404 + else if (!strcmp(var, "bcm94710ap"))
18405 + si->boardtype = BCM94710AP_BOARD;
18406 + else if (!strcmp(var, "bcm94310u"))
18407 + si->boardtype = BCM94310U_BOARD;
18408 + else if (!strcmp(var, "bu4711"))
18409 + si->boardtype = BU4711_BOARD;
18410 + else if (!strcmp(var, "bu4710"))
18411 + si->boardtype = BU4710_BOARD;
18412 + else if (!strcmp(var, "bcm94702mn"))
18413 + si->boardtype = BCM94702MN_BOARD;
18414 + else if (!strcmp(var, "bcm94710r1"))
18415 + si->boardtype = BCM94710R1_BOARD;
18416 + else if (!strcmp(var, "bcm94710r4"))
18417 + si->boardtype = BCM94710R4_BOARD;
18418 + else if (!strcmp(var, "bcm94702cpci"))
18419 + si->boardtype = BCM94702CPCI_BOARD;
18420 + else if (!strcmp(var, "bcm95380_rr"))
18421 + si->boardtype = BCM95380RR_BOARD;
18422 + }
18423 + }
18424 +
18425 + return (si->boardtype);
18426 +}
18427 +
18428 +/* return bus type of sdh device */
18429 +uint
18430 +sb_bus(void *sbh)
18431 +{
18432 + sb_info_t *si;
18433 +
18434 + si = SB_INFO(sbh);
18435 + return (si->bustype);
18436 +}
18437 +
18438 +/* return list of found cores */
18439 +uint
18440 +sb_corelist(void *sbh, uint coreid[])
18441 +{
18442 + sb_info_t *si;
18443 +
18444 + si = SB_INFO(sbh);
18445 +
18446 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof (uint)));
18447 + return (si->numcores);
18448 +}
18449 +
18450 +/* return current register mapping */
18451 +void *
18452 +sb_coreregs(void *sbh)
18453 +{
18454 + sb_info_t *si;
18455 +
18456 + si = SB_INFO(sbh);
18457 + ASSERT(GOODREGS(si->curmap));
18458 +
18459 + return (si->curmap);
18460 +}
18461 +
18462 +
18463 +/* do buffered registers update */
18464 +void
18465 +sb_commit(void *sbh)
18466 +{
18467 + sb_info_t *si;
18468 + uint origidx;
18469 + uint intr_val = 0;
18470 +
18471 + si = SB_INFO(sbh);
18472 +
18473 + origidx = si->curidx;
18474 + ASSERT(GOODIDX(origidx));
18475 +
18476 + INTR_OFF(si, intr_val);
18477 +
18478 + /* switch over to chipcommon core if there is one, else use pci */
18479 + if (si->ccrev != NOREV) {
18480 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0);
18481 +
18482 + /* do the buffer registers update */
18483 + W_REG(&ccregs->broadcastaddress, SB_COMMIT);
18484 + W_REG(&ccregs->broadcastdata, 0x0);
18485 + } else if (si->pciidx != BADIDX) {
18486 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0);
18487 +
18488 + /* do the buffer registers update */
18489 + W_REG(&pciregs->bcastaddr, SB_COMMIT);
18490 + W_REG(&pciregs->bcastdata, 0x0);
18491 + } else {
18492 + ASSERT((si->ccrev != NOREV) && (si->pciidx != BADIDX));
18493 + }
18494 +
18495 + /* restore core index */
18496 + sb_setcoreidx(sbh, origidx);
18497 + INTR_RESTORE(si, intr_val);
18498 +}
18499 +
18500 +/* reset and re-enable a core */
18501 +void
18502 +sb_core_reset(void *sbh, uint32 bits)
18503 +{
18504 + sb_info_t *si;
18505 + sbconfig_t *sb;
18506 + volatile uint32 dummy;
18507 +
18508 + si = SB_INFO(sbh);
18509 + ASSERT(GOODREGS(si->curmap));
18510 + sb = REGS2SB(si->curmap);
18511 +
18512 + /*
18513 + * Must do the disable sequence first to work for arbitrary current core state.
18514 + */
18515 + sb_core_disable(sbh, bits);
18516 +
18517 + /*
18518 + * Now do the initialization sequence.
18519 + */
18520 +
18521 + /* set reset while enabling the clock and forcing them on throughout the core */
18522 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits));
18523 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18524 +
18525 + if (sb_coreid(sbh) == SB_ILINE100) {
18526 + bcm_mdelay(50);
18527 + } else {
18528 + OSL_DELAY(1);
18529 + }
18530 +
18531 + if (R_SBREG(sbh, &sb->sbtmstatehigh) & SBTMH_SERR) {
18532 + W_SBREG(sbh, &sb->sbtmstatehigh, 0);
18533 + }
18534 + if ((dummy = R_SBREG(sbh, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) {
18535 + AND_SBREG(sbh, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO));
18536 + }
18537 +
18538 + /* clear reset and allow it to propagate throughout the core */
18539 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits));
18540 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18541 + OSL_DELAY(1);
18542 +
18543 + /* leave clock enabled */
18544 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_CLK | bits));
18545 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18546 + OSL_DELAY(1);
18547 +}
18548 +
18549 +void
18550 +sb_core_tofixup(void *sbh)
18551 +{
18552 + sb_info_t *si;
18553 + sbconfig_t *sb;
18554 +
18555 + si = SB_INFO(sbh);
18556 +
18557 + if ((si->pciidx == BADIDX) || (si->pcirev >= 5))
18558 + return;
18559 +
18560 + ASSERT(GOODREGS(si->curmap));
18561 + sb = REGS2SB(si->curmap);
18562 +
18563 + if (BUSTYPE(si->bustype) == SB_BUS) {
18564 + SET_SBREG(sbh, &sb->sbimconfiglow,
18565 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
18566 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3);
18567 + } else {
18568 + if (sb_coreid(sbh) == SB_PCI) {
18569 + SET_SBREG(sbh, &sb->sbimconfiglow,
18570 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
18571 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
18572 + } else {
18573 + SET_SBREG(sbh, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0);
18574 + }
18575 + }
18576 +
18577 + sb_commit(sbh);
18578 +}
18579 +
18580 +void
18581 +sb_core_disable(void *sbh, uint32 bits)
18582 +{
18583 + sb_info_t *si;
18584 + volatile uint32 dummy;
18585 + sbconfig_t *sb;
18586 +
18587 + si = SB_INFO(sbh);
18588 +
18589 + ASSERT(GOODREGS(si->curmap));
18590 + sb = REGS2SB(si->curmap);
18591 +
18592 + /* if core is already in reset, just return */
18593 + if (R_SBREG(sbh, &sb->sbtmstatelow) & SBTML_RESET)
18594 + return;
18595 +
18596 + /* if clocks are not enabled, put into reset and return */
18597 + if ((R_SBREG(sbh, &sb->sbtmstatelow) & SBTML_CLK) == 0)
18598 + goto disable;
18599 +
18600 + /* set the target reject bit and spin until busy is clear */
18601 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_CLK | SBTML_REJ));
18602 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18603 + OSL_DELAY(1);
18604 + SPINWAIT((R_SBREG(sbh, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
18605 +
18606 + if (R_SBREG(sbh, &sb->sbidlow) & SBIDL_INIT) {
18607 + OR_SBREG(sbh, &sb->sbimstate, SBIM_RJ);
18608 + dummy = R_SBREG(sbh, &sb->sbimstate);
18609 + OSL_DELAY(1);
18610 + SPINWAIT((R_SBREG(sbh, &sb->sbimstate) & SBIM_BY), 100000);
18611 + }
18612 +
18613 + /* set reset and reject while enabling the clocks */
18614 + W_SBREG(sbh, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | SBTML_REJ | SBTML_RESET));
18615 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18616 + OSL_DELAY(10);
18617 +
18618 + /* don't forget to clear the initiator reject bit */
18619 + if (R_SBREG(sbh, &sb->sbidlow) & SBIDL_INIT)
18620 + AND_SBREG(sbh, &sb->sbimstate, ~SBIM_RJ);
18621 +
18622 +disable:
18623 + /* leave reset and reject asserted */
18624 + W_SBREG(sbh, &sb->sbtmstatelow, (bits | SBTML_REJ | SBTML_RESET));
18625 + OSL_DELAY(1);
18626 +}
18627 +
18628 +void
18629 +sb_watchdog(void *sbh, uint ticks)
18630 +{
18631 + sb_info_t *si = SB_INFO(sbh);
18632 +
18633 + /* instant NMI */
18634 + switch (si->gpioid) {
18635 + case SB_CC:
18636 + sb_corereg(sbh, si->gpioidx, OFFSETOF(chipcregs_t, watchdog), ~0, ticks);
18637 + break;
18638 + case SB_EXTIF:
18639 + sb_corereg(sbh, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks);
18640 + break;
18641 + }
18642 +}
18643 +
18644 +/* initialize the pcmcia core */
18645 +void
18646 +sb_pcmcia_init(void *sbh)
18647 +{
18648 + sb_info_t *si;
18649 + uint8 cor;
18650 +
18651 + si = SB_INFO(sbh);
18652 +
18653 + /* enable d11 mac interrupts */
18654 + if (si->chip == BCM4301_DEVICE_ID) {
18655 + /* Have to use FCR2 in 4301 */
18656 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
18657 + cor |= COR_IRQEN | COR_FUNEN;
18658 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
18659 + } else {
18660 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
18661 + cor |= COR_IRQEN | COR_FUNEN;
18662 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
18663 + }
18664 +
18665 +}
18666 +
18667 +
18668 +/*
18669 + * Configure the pci core for pci client (NIC) action
18670 + * and get appropriate dma offset value.
18671 + * coremask is the bitvec of cores by index to be enabled.
18672 + */
18673 +void
18674 +sb_pci_setup(void *sbh, uint32 *dmaoffset, uint coremask)
18675 +{
18676 + sb_info_t *si;
18677 + sbconfig_t *sb;
18678 + sbpciregs_t *pciregs;
18679 + uint32 sbflag;
18680 + uint32 w;
18681 + uint idx;
18682 +
18683 + si = SB_INFO(sbh);
18684 +
18685 + if (dmaoffset)
18686 + *dmaoffset = 0;
18687 +
18688 + /* if not pci bus, we're done */
18689 + if (BUSTYPE(si->bustype) != PCI_BUS)
18690 + return;
18691 +
18692 + ASSERT(si->pciidx != BADIDX);
18693 +
18694 + /* get current core index */
18695 + idx = si->curidx;
18696 +
18697 + /* we interrupt on this backplane flag number */
18698 + ASSERT(GOODREGS(si->curmap));
18699 + sb = REGS2SB(si->curmap);
18700 + sbflag = R_SBREG(sbh, &sb->sbtpsflag) & SBTPS_NUM0_MASK;
18701 +
18702 + /* switch over to pci core */
18703 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->pciidx);
18704 + sb = REGS2SB(pciregs);
18705 +
18706 + /*
18707 + * Enable sb->pci interrupts. Assume
18708 + * PCI rev 2.3 support was added in pci core rev 6 and things changed..
18709 + */
18710 + if (si->pcirev < 6) {
18711 + /* set sbintvec bit for our flag number */
18712 + OR_SBREG(sbh, &sb->sbintvec, (1 << sbflag));
18713 + } else {
18714 + /* pci config write to set this core bit in PCIIntMask */
18715 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32));
18716 + w |= (coremask << PCI_SBIM_SHIFT);
18717 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w);
18718 + }
18719 +
18720 + /* enable prefetch and bursts for dma big window */
18721 + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST));
18722 +
18723 + /* enable read multiple for dma big window */
18724 + if (si->pcirev >= 11)
18725 + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI);
18726 +
18727 + if (si->pcirev < 5) {
18728 + SET_SBREG(sbh, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
18729 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
18730 + sb_commit(sbh);
18731 + }
18732 +
18733 + /* switch back to previous core */
18734 + sb_setcoreidx(sbh, idx);
18735 +
18736 + /* use large sb pci dma window */
18737 + if (dmaoffset)
18738 + *dmaoffset = SB_PCI_DMA;
18739 +}
18740 +
18741 +uint32
18742 +sb_base(uint32 admatch)
18743 +{
18744 + uint32 base;
18745 + uint type;
18746 +
18747 + type = admatch & SBAM_TYPE_MASK;
18748 + ASSERT(type < 3);
18749 +
18750 + base = 0;
18751 +
18752 + if (type == 0) {
18753 + base = admatch & SBAM_BASE0_MASK;
18754 + } else if (type == 1) {
18755 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
18756 + base = admatch & SBAM_BASE1_MASK;
18757 + } else if (type == 2) {
18758 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
18759 + base = admatch & SBAM_BASE2_MASK;
18760 + }
18761 +
18762 + return (base);
18763 +}
18764 +
18765 +uint32
18766 +sb_size(uint32 admatch)
18767 +{
18768 + uint32 size;
18769 + uint type;
18770 +
18771 + type = admatch & SBAM_TYPE_MASK;
18772 + ASSERT(type < 3);
18773 +
18774 + size = 0;
18775 +
18776 + if (type == 0) {
18777 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1);
18778 + } else if (type == 1) {
18779 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
18780 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1);
18781 + } else if (type == 2) {
18782 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
18783 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1);
18784 + }
18785 +
18786 + return (size);
18787 +}
18788 +
18789 +/* return the core-type instantiation # of the current core */
18790 +uint
18791 +sb_coreunit(void *sbh)
18792 +{
18793 + sb_info_t *si;
18794 + uint idx;
18795 + uint coreid;
18796 + uint coreunit;
18797 + uint i;
18798 +
18799 + si = SB_INFO(sbh);
18800 + coreunit = 0;
18801 +
18802 + idx = si->curidx;
18803 +
18804 + ASSERT(GOODREGS(si->curmap));
18805 + coreid = sb_coreid(sbh);
18806 +
18807 + /* count the cores of our type */
18808 + for (i = 0; i < idx; i++)
18809 + if (si->coreid[i] == coreid)
18810 + coreunit++;
18811 +
18812 + return (coreunit);
18813 +}
18814 +
18815 +static INLINE uint32
18816 +factor6(uint32 x)
18817 +{
18818 + switch (x) {
18819 + case CC_F6_2: return 2;
18820 + case CC_F6_3: return 3;
18821 + case CC_F6_4: return 4;
18822 + case CC_F6_5: return 5;
18823 + case CC_F6_6: return 6;
18824 + case CC_F6_7: return 7;
18825 + default: return 0;
18826 + }
18827 +}
18828 +
18829 +/* calculate the speed the SB would run at given a set of clockcontrol values */
18830 +uint32
18831 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m)
18832 +{
18833 + uint32 n1, n2, clock, m1, m2, m3, mc;
18834 +
18835 + n1 = n & CN_N1_MASK;
18836 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT;
18837 +
18838 + if (pll_type == PLL_TYPE6) {
18839 + if (m & CC_T6_MMASK)
18840 + return CC_T6_M1;
18841 + else
18842 + return CC_T6_M0;
18843 + } else if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE4)|| (pll_type == PLL_TYPE3)) {
18844 + n1 = factor6(n1);
18845 + n2 += CC_F5_BIAS;
18846 + } else if (pll_type == PLL_TYPE2) {
18847 + n1 += CC_T2_BIAS;
18848 + n2 += CC_T2_BIAS;
18849 + ASSERT((n1 >= 2) && (n1 <= 7));
18850 + ASSERT((n2 >= 5) && (n2 <= 23));
18851 + } else if (pll_type == PLL_TYPE5) {
18852 + return (100000000);
18853 + } else
18854 + ASSERT((pll_type >= PLL_TYPE1) && (pll_type <= PLL_TYPE4));
18855 +
18856 + /* Special case for 5350 */
18857 + if (pll_type == PLL_TYPE3)
18858 + clock = CLOCK_BASE_5350 * n1 * n2;
18859 + else
18860 + clock = CC_CLOCK_BASE * n1 * n2;
18861 +
18862 + if (clock == 0)
18863 + return 0;
18864 +
18865 + m1 = m & CC_M1_MASK;
18866 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT;
18867 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT;
18868 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT;
18869 +
18870 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE4) || (pll_type == PLL_TYPE3)) {
18871 + m1 = factor6(m1);
18872 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3))
18873 + m2 += CC_F5_BIAS;
18874 + else
18875 + m2 = factor6(m2);
18876 + m3 = factor6(m3);
18877 +
18878 + switch (mc) {
18879 + case CC_MC_BYPASS: return (clock);
18880 + case CC_MC_M1: return (clock / m1);
18881 + case CC_MC_M1M2: return (clock / (m1 * m2));
18882 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3));
18883 + case CC_MC_M1M3: return (clock / (m1 * m3));
18884 + default: return (0);
18885 + }
18886 + } else {
18887 + ASSERT(pll_type == PLL_TYPE2);
18888 +
18889 + m1 += CC_T2_BIAS;
18890 + m2 += CC_T2M2_BIAS;
18891 + m3 += CC_T2_BIAS;
18892 + ASSERT((m1 >= 2) && (m1 <= 7));
18893 + ASSERT((m2 >= 3) && (m2 <= 10));
18894 + ASSERT((m3 >= 2) && (m3 <= 7));
18895 +
18896 + if ((mc & CC_T2MC_M1BYP) == 0)
18897 + clock /= m1;
18898 + if ((mc & CC_T2MC_M2BYP) == 0)
18899 + clock /= m2;
18900 + if ((mc & CC_T2MC_M3BYP) == 0)
18901 + clock /= m3;
18902 +
18903 + return(clock);
18904 + }
18905 +}
18906 +
18907 +/* returns the current speed the SB is running at */
18908 +uint32
18909 +sb_clock(void *sbh)
18910 +{
18911 + sb_info_t *si;
18912 + extifregs_t *eir;
18913 + chipcregs_t *cc;
18914 + uint32 n, m;
18915 + uint idx;
18916 + uint32 pll_type, rate;
18917 + uint intr_val = 0;
18918 +
18919 + si = SB_INFO(sbh);
18920 + idx = si->curidx;
18921 + pll_type = PLL_TYPE1;
18922 +
18923 + INTR_OFF(si, intr_val);
18924 +
18925 + /* switch to extif or chipc core */
18926 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
18927 + n = R_REG(&eir->clockcontrol_n);
18928 + m = R_REG(&eir->clockcontrol_sb);
18929 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
18930 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
18931 + n = R_REG(&cc->clockcontrol_n);
18932 + if (pll_type == PLL_TYPE6)
18933 + m = R_REG(&cc->clockcontrol_mips);
18934 + else if (pll_type == PLL_TYPE3)
18935 + {
18936 + // Added by Chen-I for 5365
18937 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
18938 + m = R_REG(&cc->clockcontrol_sb);
18939 + else m = R_REG(&cc->clockcontrol_m2);
18940 + }
18941 + else
18942 + m = R_REG(&cc->clockcontrol_sb);
18943 + } else {
18944 + INTR_RESTORE(si, intr_val);
18945 + return 0;
18946 + }
18947 +
18948 + // Added by Chen-I for 5365
18949 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
18950 + {
18951 + rate = 100000000;
18952 + }
18953 + else
18954 + {
18955 + /* calculate rate */
18956 + rate = sb_clock_rate(pll_type, n, m);
18957 + if (pll_type == PLL_TYPE3) rate = rate / 2;
18958 + }
18959 +
18960 + /* switch back to previous core */
18961 + sb_setcoreidx(sbh, idx);
18962 +
18963 + INTR_RESTORE(si, intr_val);
18964 +
18965 + return rate;
18966 +}
18967 +
18968 +/* change logical "focus" to the gpio core for optimized access */
18969 +void*
18970 +sb_gpiosetcore(void *sbh)
18971 +{
18972 + sb_info_t *si;
18973 +
18974 + si = SB_INFO(sbh);
18975 +
18976 + return (sb_setcoreidx(sbh, si->gpioidx));
18977 +}
18978 +
18979 +/* mask&set gpiocontrol bits */
18980 +uint32
18981 +sb_gpiocontrol(void *sbh, uint32 mask, uint32 val)
18982 +{
18983 + sb_info_t *si;
18984 + uint regoff;
18985 +
18986 + si = SB_INFO(sbh);
18987 + regoff = 0;
18988 +
18989 + switch (si->gpioid) {
18990 + case SB_CC:
18991 + regoff = OFFSETOF(chipcregs_t, gpiocontrol);
18992 + break;
18993 +
18994 + case SB_PCI:
18995 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol);
18996 + break;
18997 +
18998 + case SB_EXTIF:
18999 + return (0);
19000 + }
19001 +
19002 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
19003 +}
19004 +
19005 +/* mask&set gpio output enable bits */
19006 +uint32
19007 +sb_gpioouten(void *sbh, uint32 mask, uint32 val)
19008 +{
19009 + sb_info_t *si;
19010 + uint regoff;
19011 +
19012 + si = SB_INFO(sbh);
19013 + regoff = 0;
19014 +
19015 + switch (si->gpioid) {
19016 + case SB_CC:
19017 + regoff = OFFSETOF(chipcregs_t, gpioouten);
19018 + break;
19019 +
19020 + case SB_PCI:
19021 + regoff = OFFSETOF(sbpciregs_t, gpioouten);
19022 + break;
19023 +
19024 + case SB_EXTIF:
19025 + regoff = OFFSETOF(extifregs_t, gpio[0].outen);
19026 + break;
19027 + }
19028 +
19029 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
19030 +}
19031 +
19032 +/* mask&set gpio output bits */
19033 +uint32
19034 +sb_gpioout(void *sbh, uint32 mask, uint32 val)
19035 +{
19036 + sb_info_t *si;
19037 + uint regoff;
19038 +
19039 + si = SB_INFO(sbh);
19040 + regoff = 0;
19041 +
19042 + switch (si->gpioid) {
19043 + case SB_CC:
19044 + regoff = OFFSETOF(chipcregs_t, gpioout);
19045 + break;
19046 +
19047 + case SB_PCI:
19048 + regoff = OFFSETOF(sbpciregs_t, gpioout);
19049 + break;
19050 +
19051 + case SB_EXTIF:
19052 + regoff = OFFSETOF(extifregs_t, gpio[0].out);
19053 + break;
19054 + }
19055 +
19056 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
19057 +}
19058 +
19059 +/* return the current gpioin register value */
19060 +uint32
19061 +sb_gpioin(void *sbh)
19062 +{
19063 + sb_info_t *si;
19064 + uint regoff;
19065 +
19066 + si = SB_INFO(sbh);
19067 + regoff = 0;
19068 +
19069 + switch (si->gpioid) {
19070 + case SB_CC:
19071 + regoff = OFFSETOF(chipcregs_t, gpioin);
19072 + break;
19073 +
19074 + case SB_PCI:
19075 + regoff = OFFSETOF(sbpciregs_t, gpioin);
19076 + break;
19077 +
19078 + case SB_EXTIF:
19079 + regoff = OFFSETOF(extifregs_t, gpioin);
19080 + break;
19081 + }
19082 +
19083 + return (sb_corereg(sbh, si->gpioidx, regoff, 0, 0));
19084 +}
19085 +
19086 +/* mask&set gpio interrupt polarity bits */
19087 +uint32
19088 +sb_gpiointpolarity(void *sbh, uint32 mask, uint32 val)
19089 +{
19090 + sb_info_t *si;
19091 + uint regoff;
19092 +
19093 + si = SB_INFO(sbh);
19094 + regoff = 0;
19095 +
19096 + switch (si->gpioid) {
19097 + case SB_CC:
19098 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity);
19099 + break;
19100 +
19101 + case SB_PCI:
19102 + /* pci gpio implementation does not support interrupt polarity */
19103 + ASSERT(0);
19104 + break;
19105 +
19106 + case SB_EXTIF:
19107 + regoff = OFFSETOF(extifregs_t, gpiointpolarity);
19108 + break;
19109 + }
19110 +
19111 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
19112 +}
19113 +
19114 +/* mask&set gpio interrupt mask bits */
19115 +uint32
19116 +sb_gpiointmask(void *sbh, uint32 mask, uint32 val)
19117 +{
19118 + sb_info_t *si;
19119 + uint regoff;
19120 +
19121 + si = SB_INFO(sbh);
19122 + regoff = 0;
19123 +
19124 + switch (si->gpioid) {
19125 + case SB_CC:
19126 + regoff = OFFSETOF(chipcregs_t, gpiointmask);
19127 + break;
19128 +
19129 + case SB_PCI:
19130 + /* pci gpio implementation does not support interrupt mask */
19131 + ASSERT(0);
19132 + break;
19133 +
19134 + case SB_EXTIF:
19135 + regoff = OFFSETOF(extifregs_t, gpiointmask);
19136 + break;
19137 + }
19138 +
19139 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
19140 +}
19141 +
19142 +
19143 +/*
19144 + * Return the slow clock source.
19145 + * Three sources of SLOW CLOCK: LPO, Xtal, PCI
19146 + */
19147 +static uint
19148 +sb_slowclk_src(void *sbh)
19149 +{
19150 + sb_info_t *si;
19151 + chipcregs_t *cc;
19152 + uint32 v;
19153 +
19154 + si = SB_INFO(sbh);
19155 +
19156 + ASSERT(sb_coreid(sbh) == SB_CC);
19157 +
19158 + if (si->ccrev < 6) {
19159 + switch (BUSTYPE(si->bustype)) {
19160 + case PCMCIA_BUS: return (SCC_SS_XTAL);
19161 + case PCI_BUS:
19162 + v = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
19163 + if (v & PCI_CFG_GPIO_SCS)
19164 + return (SCC_SS_PCI);
19165 + else
19166 + return (SCC_SS_XTAL);
19167 + default: return (SCC_SS_XTAL);
19168 + }
19169 + } else if (si->ccrev < 10) {
19170 + cc = (chipcregs_t*) sb_setcoreidx(sbh, si->curidx);
19171 + v = R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK;
19172 + return (v);
19173 + } else {
19174 + return (SCC_SS_XTAL);
19175 + }
19176 +}
19177 +
19178 +/*
19179 + * Return the slowclock min or max frequency.
19180 + * Three sources of SLOW CLOCK:
19181 + * 1. On Chip LPO - 32khz or 160khz
19182 + * 2. On Chip Xtal OSC - 20mhz/4*(divider+1)
19183 + * 3. External PCI clock - 66mhz/4*(divider+1)
19184 + */
19185 +static uint
19186 +sb_slowclk_freq(void *sbh, bool max)
19187 +{
19188 + sb_info_t *si;
19189 + chipcregs_t *cc;
19190 + uint32 slowclk;
19191 + uint div;
19192 +
19193 + si = SB_INFO(sbh);
19194 +
19195 + ASSERT(sb_coreid(sbh) == SB_CC);
19196 +
19197 + cc = (chipcregs_t*) sb_setcoreidx(sbh, si->curidx);
19198 +
19199 + /* shouldn't be here unless we've established the chip has dynamic power control */
19200 + ASSERT(R_REG(&cc->capabilities) & CAP_PWR_CTL);
19201 +
19202 + slowclk = sb_slowclk_src(sbh);
19203 + if (si->ccrev < 6) {
19204 + if (slowclk == SCC_SS_PCI)
19205 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64));
19206 + else
19207 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32));
19208 + } else if (si->ccrev < 10) {
19209 + div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHF) + 1);
19210 + if (slowclk == SCC_SS_LPO)
19211 + return (max? LPOMAXFREQ : LPOMINFREQ);
19212 + else if (slowclk == SCC_SS_XTAL)
19213 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div));
19214 + else if (slowclk == SCC_SS_PCI)
19215 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div));
19216 + else
19217 + ASSERT(0);
19218 + } else {
19219 + /* Chipc rev 10 is InstaClock */
19220 + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHF;
19221 + div = 4 * (div + 1);
19222 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div));
19223 + }
19224 + return (0);
19225 +}
19226 +
19227 +static void
19228 +sb_pwrctl_setdelay(void *sbh, void *chipcregs)
19229 +{
19230 + sb_info_t *si;
19231 + chipcregs_t * cc;
19232 + uint slowmaxfreq, pll_delay, slowclk;
19233 + uint pll_on_delay, fref_sel_delay;
19234 +
19235 + si = SB_INFO(sbh);
19236 + pll_delay = PLL_DELAY;
19237 +
19238 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay
19239 + * since the xtal will also be powered down by dynamic power control logic.
19240 + */
19241 + slowclk = sb_slowclk_src(sbh);
19242 + if (slowclk != SCC_SS_XTAL)
19243 + pll_delay += XTAL_ON_DELAY;
19244 +
19245 + /* Starting with 4318 it is ILP that is used for the delays */
19246 + slowmaxfreq = sb_slowclk_freq(sbh, (si->ccrev >= 10) ? FALSE : TRUE);
19247 +
19248 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
19249 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
19250 +
19251 + cc = (chipcregs_t *)chipcregs;
19252 + W_REG(&cc->pll_on_delay, pll_on_delay);
19253 + W_REG(&cc->fref_sel_delay, fref_sel_delay);
19254 +}
19255 +
19256 +/* set or get slow clock divider */
19257 +int
19258 +sb_pwrctl_slowclk(void *sbh, bool set, uint *div)
19259 +{
19260 + sb_info_t *si;
19261 + uint origidx;
19262 + chipcregs_t *cc;
19263 + uint intr_val = 0;
19264 + uint err = 0;
19265 +
19266 + si = SB_INFO(sbh);
19267 +
19268 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
19269 + if (si->ccrev < 6)
19270 + return 1;
19271 +
19272 + /* chipcommon cores rev10 are a whole new ball game */
19273 + if (si->ccrev >= 10)
19274 + return 1;
19275 +
19276 + if (set && ((*div % 4) || (*div < 4)))
19277 + return 2;
19278 +
19279 + INTR_OFF(si, intr_val);
19280 + origidx = si->curidx;
19281 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
19282 + ASSERT(cc != NULL);
19283 +
19284 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) {
19285 + err = 3;
19286 + goto done;
19287 + }
19288 +
19289 + if (set) {
19290 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, ((*div / 4 - 1) << SCC_CD_SHF));
19291 + sb_pwrctl_setdelay(sbh, (void *)cc);
19292 + } else
19293 + *div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHF) + 1);
19294 +
19295 +done:
19296 + sb_setcoreidx(sbh, origidx);
19297 + INTR_RESTORE(si, intr_val);
19298 + return err;
19299 +}
19300 +
19301 +/* initialize power control delay registers */
19302 +void
19303 +sb_pwrctl_init(void *sbh)
19304 +{
19305 + sb_info_t *si;
19306 + uint origidx;
19307 + chipcregs_t *cc;
19308 +
19309 + si = SB_INFO(sbh);
19310 +
19311 + origidx = si->curidx;
19312 +
19313 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
19314 + return;
19315 +
19316 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
19317 + goto done;
19318 +
19319 + /* 4317pc does not work with SlowClock less than 5Mhz */
19320 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) {
19321 + if ((si->ccrev >= 6) && (si->ccrev < 10))
19322 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, (SCC_DEF_DIV << SCC_CD_SHF));
19323 + }
19324 +
19325 + sb_pwrctl_setdelay(sbh, (void *)cc);
19326 +
19327 +done:
19328 + sb_setcoreidx(sbh, origidx);
19329 +}
19330 +
19331 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */
19332 +uint16
19333 +sb_pwrctl_fast_pwrup_delay(void *sbh)
19334 +{
19335 + sb_info_t *si;
19336 + uint origidx;
19337 + chipcregs_t *cc;
19338 + uint slowminfreq;
19339 + uint16 fpdelay;
19340 + uint intr_val = 0;
19341 +
19342 + si = SB_INFO(sbh);
19343 + fpdelay = 0;
19344 + origidx = si->curidx;
19345 +
19346 + if (BUSTYPE(si->bustype) == SB_BUS)
19347 + goto done;
19348 +
19349 + INTR_OFF(si, intr_val);
19350 +
19351 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
19352 + goto done;
19353 +
19354 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
19355 + goto done;
19356 +
19357 + slowminfreq = sb_slowclk_freq(sbh, FALSE);
19358 + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq;
19359 +
19360 +done:
19361 + sb_setcoreidx(sbh, origidx);
19362 + INTR_RESTORE(si, intr_val);
19363 + return (fpdelay);
19364 +}
19365 +
19366 +/* turn primary xtal and/or pll off/on */
19367 +int
19368 +sb_pwrctl_xtal(void *sbh, uint what, bool on)
19369 +{
19370 + sb_info_t *si;
19371 + uint32 in, out, outen;
19372 +
19373 + si = SB_INFO(sbh);
19374 +
19375 + switch (BUSTYPE(si->bustype)) {
19376 +
19377 +
19378 + case PCMCIA_BUS:
19379 + return (0);
19380 +
19381 +
19382 + case PCI_BUS:
19383 +
19384 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof (uint32));
19385 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
19386 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32));
19387 +
19388 + /*
19389 + * Avoid glitching the clock if GPRS is already using it.
19390 + * We can't actually read the state of the PLLPD so we infer it
19391 + * by the value of XTAL_PU which *is* readable via gpioin.
19392 + */
19393 + if (on && (in & PCI_CFG_GPIO_XTAL))
19394 + return (0);
19395 +
19396 + if (what & XTAL)
19397 + outen |= PCI_CFG_GPIO_XTAL;
19398 + if (what & PLL)
19399 + outen |= PCI_CFG_GPIO_PLL;
19400 +
19401 + if (on) {
19402 + /* turn primary xtal on */
19403 + if (what & XTAL) {
19404 + out |= PCI_CFG_GPIO_XTAL;
19405 + if (what & PLL)
19406 + out |= PCI_CFG_GPIO_PLL;
19407 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
19408 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
19409 + OSL_DELAY(XTAL_ON_DELAY);
19410 + }
19411 +
19412 + /* turn pll on */
19413 + if (what & PLL) {
19414 + out &= ~PCI_CFG_GPIO_PLL;
19415 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
19416 + OSL_DELAY(2000);
19417 + }
19418 + } else {
19419 + if (what & XTAL)
19420 + out &= ~PCI_CFG_GPIO_XTAL;
19421 + if (what & PLL)
19422 + out |= PCI_CFG_GPIO_PLL;
19423 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
19424 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
19425 + }
19426 +
19427 + default:
19428 + return (-1);
19429 + }
19430 +
19431 + return (0);
19432 +}
19433 +
19434 +/* set dynamic power control mode (forceslow, forcefast, dynamic) */
19435 +/* returns true if ignore pll off is set and false if it is not */
19436 +bool
19437 +sb_pwrctl_clk(void *sbh, uint mode)
19438 +{
19439 + sb_info_t *si;
19440 + uint origidx;
19441 + chipcregs_t *cc;
19442 + uint32 scc;
19443 + bool forcefastclk=FALSE;
19444 + uint intr_val = 0;
19445 +
19446 + si = SB_INFO(sbh);
19447 +
19448 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
19449 + if (si->ccrev < 6)
19450 + return (FALSE);
19451 +
19452 + /* chipcommon cores rev10 are a whole new ball game */
19453 + if (si->ccrev >= 10)
19454 + return (FALSE);
19455 +
19456 + INTR_OFF(si, intr_val);
19457 +
19458 + origidx = si->curidx;
19459 +
19460 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
19461 + ASSERT(cc != NULL);
19462 +
19463 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
19464 + goto done;
19465 +
19466 + switch (mode) {
19467 + case CLK_FAST: /* force fast (pll) clock */
19468 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */
19469 + sb_pwrctl_xtal(sbh, XTAL, ON);
19470 +
19471 + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
19472 + break;
19473 +
19474 + case CLK_SLOW: /* force slow clock */
19475 + if ((BUSTYPE(si->bustype) == SDIO_BUS) || (BUSTYPE(si->bustype) == PCMCIA_BUS))
19476 + return (-1);
19477 +
19478 + if (si->ccrev >= 6)
19479 + OR_REG(&cc->slow_clk_ctl, SCC_FS);
19480 + break;
19481 +
19482 + case CLK_DYNAMIC: /* enable dynamic power control */
19483 + scc = R_REG(&cc->slow_clk_ctl);
19484 + scc &= ~(SCC_FS | SCC_IP | SCC_XC);
19485 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
19486 + scc |= SCC_XC;
19487 + W_REG(&cc->slow_clk_ctl, scc);
19488 +
19489 + /* for dynamic control, we have to release our xtal_pu "force on" */
19490 + if (scc & SCC_XC)
19491 + sb_pwrctl_xtal(sbh, XTAL, OFF);
19492 + break;
19493 + }
19494 +
19495 + /* Is the h/w forcing the use of the fast clk */
19496 + forcefastclk = (bool)((R_REG(&cc->slow_clk_ctl) & SCC_IP) == SCC_IP);
19497 +
19498 +done:
19499 + sb_setcoreidx(sbh, origidx);
19500 + INTR_RESTORE(si, intr_val);
19501 + return (forcefastclk);
19502 +}
19503 +
19504 +/* register driver interrupt disabling and restoring callback functions */
19505 +void
19506 +sb_register_intr_callback(void *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg)
19507 +{
19508 + sb_info_t *si;
19509 +
19510 + si = SB_INFO(sbh);
19511 + si->intr_arg = intr_arg;
19512 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn;
19513 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn;
19514 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn;
19515 + /* save current core id. when this function called, the current core
19516 + * must be the core which provides driver functions(il, et, wl, etc.)
19517 + */
19518 + si->dev_coreid = si->coreid[si->curidx];
19519 +}
19520 +
19521 +
19522 diff -Nur linux-2.4.30/drivers/net/hnd/shared_ksyms.sh linux-2.4.30-brcm/drivers/net/hnd/shared_ksyms.sh
19523 --- linux-2.4.30/drivers/net/hnd/shared_ksyms.sh 1970-01-01 01:00:00.000000000 +0100
19524 +++ linux-2.4.30-brcm/drivers/net/hnd/shared_ksyms.sh 2005-05-22 22:55:51.000000000 +0200
19525 @@ -0,0 +1,21 @@
19526 +#!/bin/sh
19527 +#
19528 +# Copyright 2004, Broadcom Corporation
19529 +# All Rights Reserved.
19530 +#
19531 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
19532 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
19533 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
19534 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
19535 +#
19536 +# $Id: shared_ksyms.sh,v 1.1 2005/03/16 13:50:00 wbx Exp $
19537 +#
19538 +
19539 +cat <<EOF
19540 +#include <linux/config.h>
19541 +#include <linux/module.h>
19542 +EOF
19543 +
19544 +for file in $* ; do
19545 + ${NM} $file | sed -ne 's/[0-9A-Fa-f]* [DT] \([^ ]*\)/extern void \1; EXPORT_SYMBOL(\1);/p'
19546 +done
19547 diff -Nur linux-2.4.30/drivers/net/Makefile linux-2.4.30-brcm/drivers/net/Makefile
19548 --- linux-2.4.30/drivers/net/Makefile 2005-01-19 15:09:56.000000000 +0100
19549 +++ linux-2.4.30-brcm/drivers/net/Makefile 2005-05-25 19:07:52.000000000 +0200
19550 @@ -3,6 +3,8 @@
19551 # Makefile for the Linux network (ethercard) device drivers.
19552 #
19553
19554 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include
19555 +
19556 obj-y :=
19557 obj-m :=
19558 obj-n :=
19559 @@ -21,6 +23,8 @@
19560 list-multi := rcpci.o
19561 rcpci-objs := rcpci45.o rclanmtl.o
19562
19563 +subdir-m += diag
19564 +
19565 ifeq ($(CONFIG_TULIP),y)
19566 obj-y += tulip/tulip.o
19567 endif
19568 @@ -39,6 +43,9 @@
19569 obj-$(CONFIG_ISDN) += slhc.o
19570 endif
19571
19572 +subdir-$(CONFIG_HND) += hnd
19573 +subdir-$(CONFIG_ET) += et
19574 +subdir-$(CONFIG_WL) += wl
19575 subdir-$(CONFIG_NET_PCMCIA) += pcmcia
19576 subdir-$(CONFIG_NET_WIRELESS) += wireless
19577 subdir-$(CONFIG_TULIP) += tulip
19578 @@ -69,6 +76,16 @@
19579 obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o
19580 obj-$(CONFIG_SUNGEM) += sungem.o
19581
19582 +ifeq ($(CONFIG_HND),y)
19583 + obj-y += hnd/hnd.o
19584 +endif
19585 +ifeq ($(CONFIG_ET),y)
19586 + obj-y += et/et.o
19587 +endif
19588 +ifeq ($(CONFIG_WL),y)
19589 + obj-y += wl/wl.o
19590 +endif
19591 +
19592 obj-$(CONFIG_MACE) += mace.o
19593 obj-$(CONFIG_BMAC) += bmac.o
19594 obj-$(CONFIG_GMAC) += gmac.o
19595 @@ -265,6 +282,7 @@
19596 endif
19597 endif
19598
19599 +
19600 include $(TOPDIR)/Rules.make
19601
19602 clean:
19603 diff -Nur linux-2.4.30/drivers/net/wireless/Config.in linux-2.4.30-brcm/drivers/net/wireless/Config.in
19604 --- linux-2.4.30/drivers/net/wireless/Config.in 2004-11-17 12:54:21.000000000 +0100
19605 +++ linux-2.4.30-brcm/drivers/net/wireless/Config.in 2005-05-22 22:55:52.000000000 +0200
19606 @@ -13,6 +13,7 @@
19607 fi
19608
19609 if [ "$CONFIG_PCI" = "y" ]; then
19610 + dep_tristate ' Proprietary Broadcom BCM43xx 802.11 Wireless support' CONFIG_WL
19611 dep_tristate ' Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.) (EXPERIMENTAL)' CONFIG_PLX_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
19612 dep_tristate ' Hermes in TMD7160/NCP130 based PCI adaptor support (Pheecom WL-PCI etc.) (EXPERIMENTAL)' CONFIG_TMD_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
19613 dep_tristate ' Prism 2.5 PCI 802.11b adaptor support (EXPERIMENTAL)' CONFIG_PCI_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
19614 diff -Nur linux-2.4.30/drivers/net/wl/Makefile linux-2.4.30-brcm/drivers/net/wl/Makefile
19615 --- linux-2.4.30/drivers/net/wl/Makefile 1970-01-01 01:00:00.000000000 +0100
19616 +++ linux-2.4.30-brcm/drivers/net/wl/Makefile 2005-05-26 12:04:50.000000000 +0200
19617 @@ -0,0 +1,26 @@
19618 +#
19619 +# Makefile for the Broadcom wl driver
19620 +#
19621 +# Copyright 2004, Broadcom Corporation
19622 +# All Rights Reserved.
19623 +#
19624 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
19625 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
19626 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
19627 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
19628 +#
19629 +# $Id: Makefile,v 1.2 2005/03/29 03:32:18 mbm Exp $
19630 +
19631 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include
19632 +
19633 +O_TARGET := wl.o
19634 +
19635 +obj-y := apsta_aeskeywrap.o apsta_aes.o apsta_bcmwpa.o apsta_d11ucode.o
19636 +obj-y += apsta_hmac.o apsta_md5.o apsta_passhash.o apsta_prf.o apsta_rc4.o
19637 +obj-y += apsta_rijndael-alg-fst.o apsta_sha1.o apsta_tkhash.o apsta_wlc_led.o
19638 +obj-y += apsta_wlc_phy.o apsta_wlc_rate.o apsta_wlc_security.o
19639 +obj-y += apsta_wlc_sup.o apsta_wlc_wet.o apsta_wl_linux.o apsta_wlc.o
19640 +
19641 +obj-m := $(O_TARGET)
19642 +
19643 +include $(TOPDIR)/Rules.make
19644 diff -Nur linux-2.4.30/drivers/parport/Config.in linux-2.4.30-brcm/drivers/parport/Config.in
19645 --- linux-2.4.30/drivers/parport/Config.in 2004-02-18 14:36:31.000000000 +0100
19646 +++ linux-2.4.30-brcm/drivers/parport/Config.in 2005-05-22 22:55:52.000000000 +0200
19647 @@ -11,6 +11,7 @@
19648 tristate 'Parallel port support' CONFIG_PARPORT
19649 if [ "$CONFIG_PARPORT" != "n" ]; then
19650 dep_tristate ' PC-style hardware' CONFIG_PARPORT_PC $CONFIG_PARPORT
19651 + dep_tristate ' Asus WL500g parallel port' CONFIG_PARPORT_SPLINK $CONFIG_PARPORT
19652 if [ "$CONFIG_PARPORT_PC" != "n" -a "$CONFIG_SERIAL" != "n" ]; then
19653 if [ "$CONFIG_SERIAL" = "m" ]; then
19654 define_tristate CONFIG_PARPORT_PC_CML1 m
19655 diff -Nur linux-2.4.30/drivers/parport/Makefile linux-2.4.30-brcm/drivers/parport/Makefile
19656 --- linux-2.4.30/drivers/parport/Makefile 2004-08-08 01:26:05.000000000 +0200
19657 +++ linux-2.4.30-brcm/drivers/parport/Makefile 2005-05-22 22:55:52.000000000 +0200
19658 @@ -22,6 +22,7 @@
19659
19660 obj-$(CONFIG_PARPORT) += parport.o
19661 obj-$(CONFIG_PARPORT_PC) += parport_pc.o
19662 +obj-$(CONFIG_PARPORT_SPLINK) += parport_splink.o
19663 obj-$(CONFIG_PARPORT_PC_PCMCIA) += parport_cs.o
19664 obj-$(CONFIG_PARPORT_AMIGA) += parport_amiga.o
19665 obj-$(CONFIG_PARPORT_MFC3) += parport_mfc3.o
19666 diff -Nur linux-2.4.30/drivers/parport/parport_splink.c linux-2.4.30-brcm/drivers/parport/parport_splink.c
19667 --- linux-2.4.30/drivers/parport/parport_splink.c 1970-01-01 01:00:00.000000000 +0100
19668 +++ linux-2.4.30-brcm/drivers/parport/parport_splink.c 2005-05-22 22:55:52.000000000 +0200
19669 @@ -0,0 +1,345 @@
19670 +/* Low-level parallel port routines for the ASUS WL-500g built-in port
19671 + *
19672 + * Author: Nuno Grilo <nuno.grilo@netcabo.pt>
19673 + * Based on parport_pc source
19674 + */
19675 +
19676 +#include <linux/config.h>
19677 +#include <linux/module.h>
19678 +#include <linux/init.h>
19679 +#include <linux/ioport.h>
19680 +#include <linux/kernel.h>
19681 +#include <linux/slab.h>
19682 +#include <linux/parport.h>
19683 +#include <linux/parport_pc.h>
19684 +
19685 +#define SPLINK_ADDRESS 0xBF800010
19686 +
19687 +#undef DEBUG
19688 +
19689 +#ifdef DEBUG
19690 +#define DPRINTK printk
19691 +#else
19692 +#define DPRINTK(stuff...)
19693 +#endif
19694 +
19695 +
19696 +/* __parport_splink_frob_control differs from parport_splink_frob_control in that
19697 + * it doesn't do any extra masking. */
19698 +static __inline__ unsigned char __parport_splink_frob_control (struct parport *p,
19699 + unsigned char mask,
19700 + unsigned char val)
19701 +{
19702 + struct parport_pc_private *priv = p->physport->private_data;
19703 + unsigned char *io = (unsigned char *) p->base;
19704 + unsigned char ctr = priv->ctr;
19705 +#ifdef DEBUG_PARPORT
19706 + printk (KERN_DEBUG
19707 + "__parport_splink_frob_control(%02x,%02x): %02x -> %02x\n",
19708 + mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
19709 +#endif
19710 + ctr = (ctr & ~mask) ^ val;
19711 + ctr &= priv->ctr_writable; /* only write writable bits. */
19712 + *(io+2) = ctr;
19713 + priv->ctr = ctr; /* Update soft copy */
19714 + return ctr;
19715 +}
19716 +
19717 +
19718 +
19719 +static void parport_splink_data_forward (struct parport *p)
19720 +{
19721 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
19722 + __parport_splink_frob_control (p, 0x20, 0);
19723 +}
19724 +
19725 +static void parport_splink_data_reverse (struct parport *p)
19726 +{
19727 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
19728 + __parport_splink_frob_control (p, 0x20, 0x20);
19729 +}
19730 +
19731 +/*
19732 +static void parport_splink_interrupt(int irq, void *dev_id, struct pt_regs *regs)
19733 +{
19734 + DPRINTK(KERN_DEBUG "parport_splink: IRQ handler called\n");
19735 + parport_generic_irq(irq, (struct parport *) dev_id, regs);
19736 +}
19737 +*/
19738 +
19739 +static void parport_splink_enable_irq(struct parport *p)
19740 +{
19741 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_enable_irq called\n");
19742 + __parport_splink_frob_control (p, 0x10, 0x10);
19743 +}
19744 +
19745 +static void parport_splink_disable_irq(struct parport *p)
19746 +{
19747 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_disable_irq called\n");
19748 + __parport_splink_frob_control (p, 0x10, 0);
19749 +}
19750 +
19751 +static void parport_splink_init_state(struct pardevice *dev, struct parport_state *s)
19752 +{
19753 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_init_state called\n");
19754 + s->u.pc.ctr = 0xc | (dev->irq_func ? 0x10 : 0x0);
19755 + if (dev->irq_func &&
19756 + dev->port->irq != PARPORT_IRQ_NONE)
19757 + /* Set ackIntEn */
19758 + s->u.pc.ctr |= 0x10;
19759 +}
19760 +
19761 +static void parport_splink_save_state(struct parport *p, struct parport_state *s)
19762 +{
19763 + const struct parport_pc_private *priv = p->physport->private_data;
19764 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_save_state called\n");
19765 + s->u.pc.ctr = priv->ctr;
19766 +}
19767 +
19768 +static void parport_splink_restore_state(struct parport *p, struct parport_state *s)
19769 +{
19770 + struct parport_pc_private *priv = p->physport->private_data;
19771 + unsigned char *io = (unsigned char *) p->base;
19772 + unsigned char ctr = s->u.pc.ctr;
19773 +
19774 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_restore_state called\n");
19775 + *(io+2) = ctr;
19776 + priv->ctr = ctr;
19777 +}
19778 +
19779 +static void parport_splink_setup_interrupt(void) {
19780 + return;
19781 +}
19782 +
19783 +static void parport_splink_write_data(struct parport *p, unsigned char d) {
19784 + DPRINTK(KERN_DEBUG "parport_splink: write data called\n");
19785 + unsigned char *io = (unsigned char *) p->base;
19786 + *io = d;
19787 +}
19788 +
19789 +static unsigned char parport_splink_read_data(struct parport *p) {
19790 + DPRINTK(KERN_DEBUG "parport_splink: read data called\n");
19791 + unsigned char *io = (unsigned char *) p->base;
19792 + return *io;
19793 +}
19794 +
19795 +static void parport_splink_write_control(struct parport *p, unsigned char d)
19796 +{
19797 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
19798 + PARPORT_CONTROL_AUTOFD |
19799 + PARPORT_CONTROL_INIT |
19800 + PARPORT_CONTROL_SELECT);
19801 +
19802 + DPRINTK(KERN_DEBUG "parport_splink: write control called\n");
19803 + /* Take this out when drivers have adapted to the newer interface. */
19804 + if (d & 0x20) {
19805 + printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
19806 + p->name, p->cad->name);
19807 + parport_splink_data_reverse (p);
19808 + }
19809 +
19810 + __parport_splink_frob_control (p, wm, d & wm);
19811 +}
19812 +
19813 +static unsigned char parport_splink_read_control(struct parport *p)
19814 +{
19815 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
19816 + PARPORT_CONTROL_AUTOFD |
19817 + PARPORT_CONTROL_INIT |
19818 + PARPORT_CONTROL_SELECT);
19819 + DPRINTK(KERN_DEBUG "parport_splink: read control called\n");
19820 + const struct parport_pc_private *priv = p->physport->private_data;
19821 + return priv->ctr & wm; /* Use soft copy */
19822 +}
19823 +
19824 +static unsigned char parport_splink_frob_control (struct parport *p, unsigned char mask,
19825 + unsigned char val)
19826 +{
19827 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
19828 + PARPORT_CONTROL_AUTOFD |
19829 + PARPORT_CONTROL_INIT |
19830 + PARPORT_CONTROL_SELECT);
19831 +
19832 + DPRINTK(KERN_DEBUG "parport_splink: frob control called\n");
19833 + /* Take this out when drivers have adapted to the newer interface. */
19834 + if (mask & 0x20) {
19835 + printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
19836 + p->name, p->cad->name,
19837 + (val & 0x20) ? "reverse" : "forward");
19838 + if (val & 0x20)
19839 + parport_splink_data_reverse (p);
19840 + else
19841 + parport_splink_data_forward (p);
19842 + }
19843 +
19844 + /* Restrict mask and val to control lines. */
19845 + mask &= wm;
19846 + val &= wm;
19847 +
19848 + return __parport_splink_frob_control (p, mask, val);
19849 +}
19850 +
19851 +static unsigned char parport_splink_read_status(struct parport *p)
19852 +{
19853 + DPRINTK(KERN_DEBUG "parport_splink: read status called\n");
19854 + unsigned char *io = (unsigned char *) p->base;
19855 + return *(io+1);
19856 +}
19857 +
19858 +static void parport_splink_inc_use_count(void)
19859 +{
19860 +#ifdef MODULE
19861 + MOD_INC_USE_COUNT;
19862 +#endif
19863 +}
19864 +
19865 +static void parport_splink_dec_use_count(void)
19866 +{
19867 +#ifdef MODULE
19868 + MOD_DEC_USE_COUNT;
19869 +#endif
19870 +}
19871 +
19872 +static struct parport_operations parport_splink_ops =
19873 +{
19874 + parport_splink_write_data,
19875 + parport_splink_read_data,
19876 +
19877 + parport_splink_write_control,
19878 + parport_splink_read_control,
19879 + parport_splink_frob_control,
19880 +
19881 + parport_splink_read_status,
19882 +
19883 + parport_splink_enable_irq,
19884 + parport_splink_disable_irq,
19885 +
19886 + parport_splink_data_forward,
19887 + parport_splink_data_reverse,
19888 +
19889 + parport_splink_init_state,
19890 + parport_splink_save_state,
19891 + parport_splink_restore_state,
19892 +
19893 + parport_splink_inc_use_count,
19894 + parport_splink_dec_use_count,
19895 +
19896 + parport_ieee1284_epp_write_data,
19897 + parport_ieee1284_epp_read_data,
19898 + parport_ieee1284_epp_write_addr,
19899 + parport_ieee1284_epp_read_addr,
19900 +
19901 + parport_ieee1284_ecp_write_data,
19902 + parport_ieee1284_ecp_read_data,
19903 + parport_ieee1284_ecp_write_addr,
19904 +
19905 + parport_ieee1284_write_compat,
19906 + parport_ieee1284_read_nibble,
19907 + parport_ieee1284_read_byte,
19908 +};
19909 +
19910 +/* --- Initialisation code -------------------------------- */
19911 +
19912 +static struct parport *parport_splink_probe_port (unsigned long int base)
19913 +{
19914 + struct parport_pc_private *priv;
19915 + struct parport_operations *ops;
19916 + struct parport *p;
19917 +
19918 + if (check_mem_region(base, 3)) {
19919 + printk (KERN_DEBUG "parport (0x%lx): iomem region not available\n", base);
19920 + return NULL;
19921 + }
19922 + priv = kmalloc (sizeof (struct parport_pc_private), GFP_KERNEL);
19923 + if (!priv) {
19924 + printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base);
19925 + return NULL;
19926 + }
19927 + ops = kmalloc (sizeof (struct parport_operations), GFP_KERNEL);
19928 + if (!ops) {
19929 + printk (KERN_DEBUG "parport (0x%lx): no memory for ops!\n",
19930 + base);
19931 + kfree (priv);
19932 + return NULL;
19933 + }
19934 + memcpy (ops, &parport_splink_ops, sizeof (struct parport_operations));
19935 + priv->ctr = 0xc;
19936 + priv->ctr_writable = 0xff;
19937 +
19938 + if (!(p = parport_register_port(base, PARPORT_IRQ_NONE,
19939 + PARPORT_DMA_NONE, ops))) {
19940 + printk (KERN_DEBUG "parport (0x%lx): registration failed!\n",
19941 + base);
19942 + kfree (priv);
19943 + kfree (ops);
19944 + return NULL;
19945 + }
19946 +
19947 + p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;
19948 + p->size = (p->modes & PARPORT_MODE_EPP)?8:3;
19949 + p->private_data = priv;
19950 +
19951 + parport_proc_register(p);
19952 + request_mem_region (p->base, 3, p->name);
19953 +
19954 + /* Done probing. Now put the port into a sensible start-up state. */
19955 + parport_splink_write_data(p, 0);
19956 + parport_splink_data_forward (p);
19957 +
19958 + /* Now that we've told the sharing engine about the port, and
19959 + found out its characteristics, let the high-level drivers
19960 + know about it. */
19961 + parport_announce_port (p);
19962 +
19963 + DPRINTK(KERN_DEBUG "parport (0x%lx): init ok!\n",
19964 + base);
19965 + return p;
19966 +}
19967 +
19968 +static void parport_splink_unregister_port(struct parport *p) {
19969 + struct parport_pc_private *priv = p->private_data;
19970 + struct parport_operations *ops = p->ops;
19971 +
19972 + if (p->irq != PARPORT_IRQ_NONE)
19973 + free_irq(p->irq, p);
19974 + release_mem_region(p->base, 3);
19975 + parport_proc_unregister(p);
19976 + kfree (priv);
19977 + parport_unregister_port(p);
19978 + kfree (ops);
19979 +}
19980 +
19981 +
19982 +int parport_splink_init(void)
19983 +{
19984 + int ret;
19985 +
19986 + DPRINTK(KERN_DEBUG "parport_splink init called\n");
19987 + parport_splink_setup_interrupt();
19988 + ret = !parport_splink_probe_port(SPLINK_ADDRESS);
19989 +
19990 + return ret;
19991 +}
19992 +
19993 +void parport_splink_cleanup(void) {
19994 + struct parport *p = parport_enumerate(), *tmp;
19995 + DPRINTK(KERN_DEBUG "parport_splink cleanup called\n");
19996 + if (p->size) {
19997 + if (p->modes & PARPORT_MODE_PCSPP) {
19998 + while(p) {
19999 + tmp = p->next;
20000 + parport_splink_unregister_port(p);
20001 + p = tmp;
20002 + }
20003 + }
20004 + }
20005 +}
20006 +
20007 +MODULE_AUTHOR("Nuno Grilo <nuno.grilo@netcabo.pt>");
20008 +MODULE_DESCRIPTION("Parport Driver for ASUS WL-500g router builtin Port");
20009 +MODULE_SUPPORTED_DEVICE("ASUS WL-500g builtin Parallel Port");
20010 +MODULE_LICENSE("GPL");
20011 +
20012 +module_init(parport_splink_init)
20013 +module_exit(parport_splink_cleanup)
20014 +
20015 diff -Nur linux-2.4.30/drivers/pcmcia/bcm4710_generic.c linux-2.4.30-brcm/drivers/pcmcia/bcm4710_generic.c
20016 --- linux-2.4.30/drivers/pcmcia/bcm4710_generic.c 1970-01-01 01:00:00.000000000 +0100
20017 +++ linux-2.4.30-brcm/drivers/pcmcia/bcm4710_generic.c 2005-05-22 22:55:52.000000000 +0200
20018 @@ -0,0 +1,912 @@
20019 +/*
20020 + *
20021 + * bcm47xx pcmcia driver
20022 + *
20023 + * Copyright 2004, Broadcom Corporation
20024 + * All Rights Reserved.
20025 + *
20026 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
20027 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
20028 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
20029 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
20030 + *
20031 + * Based on sa1100_generic.c from www.handhelds.org,
20032 + * and au1000_generic.c from oss.sgi.com.
20033 + *
20034 + * $Id: bcm4710_generic.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
20035 + */
20036 +#include <linux/module.h>
20037 +#include <linux/init.h>
20038 +#include <linux/config.h>
20039 +#include <linux/delay.h>
20040 +#include <linux/ioport.h>
20041 +#include <linux/kernel.h>
20042 +#include <linux/tqueue.h>
20043 +#include <linux/timer.h>
20044 +#include <linux/mm.h>
20045 +#include <linux/proc_fs.h>
20046 +#include <linux/version.h>
20047 +#include <linux/types.h>
20048 +#include <linux/vmalloc.h>
20049 +
20050 +#include <pcmcia/version.h>
20051 +#include <pcmcia/cs_types.h>
20052 +#include <pcmcia/cs.h>
20053 +#include <pcmcia/ss.h>
20054 +#include <pcmcia/bulkmem.h>
20055 +#include <pcmcia/cistpl.h>
20056 +#include <pcmcia/bus_ops.h>
20057 +#include "cs_internal.h"
20058 +
20059 +#include <asm/io.h>
20060 +#include <asm/irq.h>
20061 +#include <asm/system.h>
20062 +
20063 +#include <typedefs.h>
20064 +#include <bcm4710.h>
20065 +#include <sbextif.h>
20066 +
20067 +#include "bcm4710pcmcia.h"
20068 +
20069 +#ifdef PCMCIA_DEBUG
20070 +static int pc_debug = PCMCIA_DEBUG;
20071 +#endif
20072 +
20073 +MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm47xx Socket Controller");
20074 +
20075 +/* This structure maintains housekeeping state for each socket, such
20076 + * as the last known values of the card detect pins, or the Card Services
20077 + * callback value associated with the socket:
20078 + */
20079 +static struct bcm47xx_pcmcia_socket *pcmcia_socket;
20080 +static int socket_count;
20081 +
20082 +
20083 +/* Returned by the low-level PCMCIA interface: */
20084 +static struct pcmcia_low_level *pcmcia_low_level;
20085 +
20086 +/* Event poll timer structure */
20087 +static struct timer_list poll_timer;
20088 +
20089 +
20090 +/* Prototypes for routines which are used internally: */
20091 +
20092 +static int bcm47xx_pcmcia_driver_init(void);
20093 +static void bcm47xx_pcmcia_driver_shutdown(void);
20094 +static void bcm47xx_pcmcia_task_handler(void *data);
20095 +static void bcm47xx_pcmcia_poll_event(unsigned long data);
20096 +static void bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs);
20097 +static struct tq_struct bcm47xx_pcmcia_task;
20098 +
20099 +#ifdef CONFIG_PROC_FS
20100 +static int bcm47xx_pcmcia_proc_status(char *buf, char **start,
20101 + off_t pos, int count, int *eof, void *data);
20102 +#endif
20103 +
20104 +
20105 +/* Prototypes for operations which are exported to the
20106 + * in-kernel PCMCIA core:
20107 + */
20108 +
20109 +static int bcm47xx_pcmcia_init(unsigned int sock);
20110 +static int bcm47xx_pcmcia_suspend(unsigned int sock);
20111 +static int bcm47xx_pcmcia_register_callback(unsigned int sock,
20112 + void (*handler)(void *, unsigned int), void *info);
20113 +static int bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap);
20114 +static int bcm47xx_pcmcia_get_status(unsigned int sock, u_int *value);
20115 +static int bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state);
20116 +static int bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state);
20117 +static int bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *io);
20118 +static int bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *io);
20119 +static int bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *mem);
20120 +static int bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *mem);
20121 +#ifdef CONFIG_PROC_FS
20122 +static void bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base);
20123 +#endif
20124 +
20125 +static struct pccard_operations bcm47xx_pcmcia_operations = {
20126 + bcm47xx_pcmcia_init,
20127 + bcm47xx_pcmcia_suspend,
20128 + bcm47xx_pcmcia_register_callback,
20129 + bcm47xx_pcmcia_inquire_socket,
20130 + bcm47xx_pcmcia_get_status,
20131 + bcm47xx_pcmcia_get_socket,
20132 + bcm47xx_pcmcia_set_socket,
20133 + bcm47xx_pcmcia_get_io_map,
20134 + bcm47xx_pcmcia_set_io_map,
20135 + bcm47xx_pcmcia_get_mem_map,
20136 + bcm47xx_pcmcia_set_mem_map,
20137 +#ifdef CONFIG_PROC_FS
20138 + bcm47xx_pcmcia_proc_setup
20139 +#endif
20140 +};
20141 +
20142 +
20143 +/*
20144 + * bcm47xx_pcmcia_driver_init()
20145 + *
20146 + * This routine performs a basic sanity check to ensure that this
20147 + * kernel has been built with the appropriate board-specific low-level
20148 + * PCMCIA support, performs low-level PCMCIA initialization, registers
20149 + * this socket driver with Card Services, and then spawns the daemon
20150 + * thread which is the real workhorse of the socket driver.
20151 + *
20152 + * Please see linux/Documentation/arm/SA1100/PCMCIA for more information
20153 + * on the low-level kernel interface.
20154 + *
20155 + * Returns: 0 on success, -1 on error
20156 + */
20157 +static int __init bcm47xx_pcmcia_driver_init(void)
20158 +{
20159 + servinfo_t info;
20160 + struct pcmcia_init pcmcia_init;
20161 + struct pcmcia_state state;
20162 + unsigned int i;
20163 + unsigned long tmp;
20164 +
20165 +
20166 + printk("\nBCM47XX PCMCIA (CS release %s)\n", CS_RELEASE);
20167 +
20168 + CardServices(GetCardServicesInfo, &info);
20169 +
20170 + if (info.Revision != CS_RELEASE_CODE) {
20171 + printk(KERN_ERR "Card Services release codes do not match\n");
20172 + return -1;
20173 + }
20174 +
20175 +#ifdef CONFIG_BCM4710
20176 + pcmcia_low_level=&bcm4710_pcmcia_ops;
20177 +#else
20178 +#error Unsupported Broadcom BCM47XX board.
20179 +#endif
20180 +
20181 + pcmcia_init.handler=bcm47xx_pcmcia_interrupt;
20182 +
20183 + if ((socket_count = pcmcia_low_level->init(&pcmcia_init)) < 0) {
20184 + printk(KERN_ERR "Unable to initialize PCMCIA service.\n");
20185 + return -EIO;
20186 + } else {
20187 + printk("\t%d PCMCIA sockets initialized.\n", socket_count);
20188 + }
20189 +
20190 + pcmcia_socket =
20191 + kmalloc(sizeof(struct bcm47xx_pcmcia_socket) * socket_count,
20192 + GFP_KERNEL);
20193 + memset(pcmcia_socket, 0,
20194 + sizeof(struct bcm47xx_pcmcia_socket) * socket_count);
20195 + if (!pcmcia_socket) {
20196 + printk(KERN_ERR "Card Services can't get memory \n");
20197 + return -1;
20198 + }
20199 +
20200 + for (i = 0; i < socket_count; i++) {
20201 + if (pcmcia_low_level->socket_state(i, &state) < 0) {
20202 + printk(KERN_ERR "Unable to get PCMCIA status\n");
20203 + return -EIO;
20204 + }
20205 + pcmcia_socket[i].k_state = state;
20206 + pcmcia_socket[i].cs_state.csc_mask = SS_DETECT;
20207 +
20208 + if (i == 0) {
20209 + pcmcia_socket[i].virt_io =
20210 + (unsigned long)ioremap_nocache(EXTIF_PCMCIA_IOBASE(BCM4710_EXTIF), 0x1000);
20211 + /* Substract ioport base which gets added by in/out */
20212 + pcmcia_socket[i].virt_io -= mips_io_port_base;
20213 + pcmcia_socket[i].phys_attr =
20214 + (unsigned long)EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF);
20215 + pcmcia_socket[i].phys_mem =
20216 + (unsigned long)EXTIF_PCMCIA_MEMBASE(BCM4710_EXTIF);
20217 + } else {
20218 + printk(KERN_ERR "bcm4710: socket 1 not supported\n");
20219 + return 1;
20220 + }
20221 + }
20222 +
20223 + /* Only advertise as many sockets as we can detect: */
20224 + if (register_ss_entry(socket_count, &bcm47xx_pcmcia_operations) < 0) {
20225 + printk(KERN_ERR "Unable to register socket service routine\n");
20226 + return -ENXIO;
20227 + }
20228 +
20229 + /* Start the event poll timer.
20230 + * It will reschedule by itself afterwards.
20231 + */
20232 + bcm47xx_pcmcia_poll_event(0);
20233 +
20234 + DEBUG(1, "bcm4710: initialization complete\n");
20235 + return 0;
20236 +
20237 +}
20238 +
20239 +module_init(bcm47xx_pcmcia_driver_init);
20240 +
20241 +
20242 +/*
20243 + * bcm47xx_pcmcia_driver_shutdown()
20244 + *
20245 + * Invokes the low-level kernel service to free IRQs associated with this
20246 + * socket controller and reset GPIO edge detection.
20247 + */
20248 +static void __exit bcm47xx_pcmcia_driver_shutdown(void)
20249 +{
20250 + int i;
20251 +
20252 + del_timer_sync(&poll_timer);
20253 + unregister_ss_entry(&bcm47xx_pcmcia_operations);
20254 + pcmcia_low_level->shutdown();
20255 + flush_scheduled_tasks();
20256 + for (i = 0; i < socket_count; i++) {
20257 + if (pcmcia_socket[i].virt_io)
20258 + iounmap((void *)pcmcia_socket[i].virt_io);
20259 + if (pcmcia_socket[i].phys_attr)
20260 + iounmap((void *)pcmcia_socket[i].phys_attr);
20261 + if (pcmcia_socket[i].phys_mem)
20262 + iounmap((void *)pcmcia_socket[i].phys_mem);
20263 + }
20264 + DEBUG(1, "bcm4710: shutdown complete\n");
20265 +}
20266 +
20267 +module_exit(bcm47xx_pcmcia_driver_shutdown);
20268 +
20269 +/*
20270 + * bcm47xx_pcmcia_init()
20271 + * We perform all of the interesting initialization tasks in
20272 + * bcm47xx_pcmcia_driver_init().
20273 + *
20274 + * Returns: 0
20275 + */
20276 +static int bcm47xx_pcmcia_init(unsigned int sock)
20277 +{
20278 + DEBUG(1, "%s(): initializing socket %u\n", __FUNCTION__, sock);
20279 +
20280 + return 0;
20281 +}
20282 +
20283 +/*
20284 + * bcm47xx_pcmcia_suspend()
20285 + *
20286 + * We don't currently perform any actions on a suspend.
20287 + *
20288 + * Returns: 0
20289 + */
20290 +static int bcm47xx_pcmcia_suspend(unsigned int sock)
20291 +{
20292 + DEBUG(1, "%s(): suspending socket %u\n", __FUNCTION__, sock);
20293 +
20294 + return 0;
20295 +}
20296 +
20297 +
20298 +/*
20299 + * bcm47xx_pcmcia_events()
20300 + *
20301 + * Helper routine to generate a Card Services event mask based on
20302 + * state information obtained from the kernel low-level PCMCIA layer
20303 + * in a recent (and previous) sampling. Updates `prev_state'.
20304 + *
20305 + * Returns: an event mask for the given socket state.
20306 + */
20307 +static inline unsigned
20308 +bcm47xx_pcmcia_events(struct pcmcia_state *state,
20309 + struct pcmcia_state *prev_state,
20310 + unsigned int mask, unsigned int flags)
20311 +{
20312 + unsigned int events=0;
20313 +
20314 + if (state->bvd1 != prev_state->bvd1) {
20315 +
20316 + DEBUG(3, "%s(): card BVD1 value %u\n", __FUNCTION__, state->bvd1);
20317 +
20318 + events |= mask & (flags & SS_IOCARD) ? SS_STSCHG : SS_BATDEAD;
20319 + }
20320 +
20321 + if (state->bvd2 != prev_state->bvd2) {
20322 +
20323 + DEBUG(3, "%s(): card BVD2 value %u\n", __FUNCTION__, state->bvd2);
20324 +
20325 + events |= mask & (flags & SS_IOCARD) ? 0 : SS_BATWARN;
20326 + }
20327 +
20328 + if (state->detect != prev_state->detect) {
20329 +
20330 + DEBUG(3, "%s(): card detect value %u\n", __FUNCTION__, state->detect);
20331 +
20332 + events |= mask & SS_DETECT;
20333 + }
20334 +
20335 +
20336 + if (state->ready != prev_state->ready) {
20337 +
20338 + DEBUG(3, "%s(): card ready value %u\n", __FUNCTION__, state->ready);
20339 +
20340 + events |= mask & ((flags & SS_IOCARD) ? 0 : SS_READY);
20341 + }
20342 +
20343 + if (events != 0) {
20344 + DEBUG(2, "events: %s%s%s%s%s\n",
20345 + (events & SS_DETECT) ? "DETECT " : "",
20346 + (events & SS_READY) ? "READY " : "",
20347 + (events & SS_BATDEAD) ? "BATDEAD " : "",
20348 + (events & SS_BATWARN) ? "BATWARN " : "",
20349 + (events & SS_STSCHG) ? "STSCHG " : "");
20350 + }
20351 +
20352 + *prev_state=*state;
20353 + return events;
20354 +}
20355 +
20356 +
20357 +/*
20358 + * bcm47xx_pcmcia_task_handler()
20359 + *
20360 + * Processes serviceable socket events using the "eventd" thread context.
20361 + *
20362 + * Event processing (specifically, the invocation of the Card Services event
20363 + * callback) occurs in this thread rather than in the actual interrupt
20364 + * handler due to the use of scheduling operations in the PCMCIA core.
20365 + */
20366 +static void bcm47xx_pcmcia_task_handler(void *data)
20367 +{
20368 + struct pcmcia_state state;
20369 + int i, events, irq_status;
20370 +
20371 + DEBUG(4, "%s(): entering PCMCIA monitoring thread\n", __FUNCTION__);
20372 +
20373 + for (i = 0; i < socket_count; i++) {
20374 + if ((irq_status = pcmcia_low_level->socket_state(i, &state)) < 0)
20375 + printk(KERN_ERR "Error in kernel low-level PCMCIA service.\n");
20376 +
20377 + events = bcm47xx_pcmcia_events(&state,
20378 + &pcmcia_socket[i].k_state,
20379 + pcmcia_socket[i].cs_state.csc_mask,
20380 + pcmcia_socket[i].cs_state.flags);
20381 +
20382 + if (pcmcia_socket[i].handler != NULL) {
20383 + pcmcia_socket[i].handler(pcmcia_socket[i].handler_info,
20384 + events);
20385 + }
20386 + }
20387 +}
20388 +
20389 +static struct tq_struct bcm47xx_pcmcia_task = {
20390 + routine: bcm47xx_pcmcia_task_handler
20391 +};
20392 +
20393 +
20394 +/*
20395 + * bcm47xx_pcmcia_poll_event()
20396 + *
20397 + * Let's poll for events in addition to IRQs since IRQ only is unreliable...
20398 + */
20399 +static void bcm47xx_pcmcia_poll_event(unsigned long dummy)
20400 +{
20401 + DEBUG(4, "%s(): polling for events\n", __FUNCTION__);
20402 +
20403 + poll_timer.function = bcm47xx_pcmcia_poll_event;
20404 + poll_timer.expires = jiffies + BCM47XX_PCMCIA_POLL_PERIOD;
20405 + add_timer(&poll_timer);
20406 + schedule_task(&bcm47xx_pcmcia_task);
20407 +}
20408 +
20409 +
20410 +/*
20411 + * bcm47xx_pcmcia_interrupt()
20412 + *
20413 + * Service routine for socket driver interrupts (requested by the
20414 + * low-level PCMCIA init() operation via bcm47xx_pcmcia_thread()).
20415 + *
20416 + * The actual interrupt-servicing work is performed by
20417 + * bcm47xx_pcmcia_task(), largely because the Card Services event-
20418 + * handling code performs scheduling operations which cannot be
20419 + * executed from within an interrupt context.
20420 + */
20421 +static void
20422 +bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs)
20423 +{
20424 + DEBUG(3, "%s(): servicing IRQ %d\n", __FUNCTION__, irq);
20425 + schedule_task(&bcm47xx_pcmcia_task);
20426 +}
20427 +
20428 +
20429 +/*
20430 + * bcm47xx_pcmcia_register_callback()
20431 + *
20432 + * Implements the register_callback() operation for the in-kernel
20433 + * PCMCIA service (formerly SS_RegisterCallback in Card Services). If
20434 + * the function pointer `handler' is not NULL, remember the callback
20435 + * location in the state for `sock', and increment the usage counter
20436 + * for the driver module. (The callback is invoked from the interrupt
20437 + * service routine, bcm47xx_pcmcia_interrupt(), to notify Card Services
20438 + * of interesting events.) Otherwise, clear the callback pointer in the
20439 + * socket state and decrement the module usage count.
20440 + *
20441 + * Returns: 0
20442 + */
20443 +static int
20444 +bcm47xx_pcmcia_register_callback(unsigned int sock,
20445 + void (*handler)(void *, unsigned int), void *info)
20446 +{
20447 + if (handler == NULL) {
20448 + pcmcia_socket[sock].handler = NULL;
20449 + MOD_DEC_USE_COUNT;
20450 + } else {
20451 + MOD_INC_USE_COUNT;
20452 + pcmcia_socket[sock].handler = handler;
20453 + pcmcia_socket[sock].handler_info = info;
20454 + }
20455 + return 0;
20456 +}
20457 +
20458 +
20459 +/*
20460 + * bcm47xx_pcmcia_inquire_socket()
20461 + *
20462 + * Implements the inquire_socket() operation for the in-kernel PCMCIA
20463 + * service (formerly SS_InquireSocket in Card Services). Of note is
20464 + * the setting of the SS_CAP_PAGE_REGS bit in the `features' field of
20465 + * `cap' to "trick" Card Services into tolerating large "I/O memory"
20466 + * addresses. Also set is SS_CAP_STATIC_MAP, which disables the memory
20467 + * resource database check. (Mapped memory is set up within the socket
20468 + * driver itself.)
20469 + *
20470 + * In conjunction with the STATIC_MAP capability is a new field,
20471 + * `io_offset', recommended by David Hinds. Rather than go through
20472 + * the SetIOMap interface (which is not quite suited for communicating
20473 + * window locations up from the socket driver), we just pass up
20474 + * an offset which is applied to client-requested base I/O addresses
20475 + * in alloc_io_space().
20476 + *
20477 + * Returns: 0 on success, -1 if no pin has been configured for `sock'
20478 + */
20479 +static int
20480 +bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap)
20481 +{
20482 + struct pcmcia_irq_info irq_info;
20483 +
20484 + if (sock >= socket_count) {
20485 + printk(KERN_ERR "bcm47xx: socket %u not configured\n", sock);
20486 + return -1;
20487 + }
20488 +
20489 + /* SS_CAP_PAGE_REGS: used by setup_cis_mem() in cistpl.c to set the
20490 + * force_low argument to validate_mem() in rsrc_mgr.c -- since in
20491 + * general, the mapped * addresses of the PCMCIA memory regions
20492 + * will not be within 0xffff, setting force_low would be
20493 + * undesirable.
20494 + *
20495 + * SS_CAP_STATIC_MAP: don't bother with the (user-configured) memory
20496 + * resource database; we instead pass up physical address ranges
20497 + * and allow other parts of Card Services to deal with remapping.
20498 + *
20499 + * SS_CAP_PCCARD: we can deal with 16-bit PCMCIA & CF cards, but
20500 + * not 32-bit CardBus devices.
20501 + */
20502 + cap->features = (SS_CAP_PAGE_REGS | SS_CAP_STATIC_MAP | SS_CAP_PCCARD);
20503 +
20504 + irq_info.sock = sock;
20505 + irq_info.irq = -1;
20506 +
20507 + if (pcmcia_low_level->get_irq_info(&irq_info) < 0) {
20508 + printk(KERN_ERR "Error obtaining IRQ info socket %u\n", sock);
20509 + return -1;
20510 + }
20511 +
20512 + cap->irq_mask = 0;
20513 + cap->map_size = PAGE_SIZE;
20514 + cap->pci_irq = irq_info.irq;
20515 + cap->io_offset = pcmcia_socket[sock].virt_io;
20516 +
20517 + return 0;
20518 +}
20519 +
20520 +
20521 +/*
20522 + * bcm47xx_pcmcia_get_status()
20523 + *
20524 + * Implements the get_status() operation for the in-kernel PCMCIA
20525 + * service (formerly SS_GetStatus in Card Services). Essentially just
20526 + * fills in bits in `status' according to internal driver state or
20527 + * the value of the voltage detect chipselect register.
20528 + *
20529 + * As a debugging note, during card startup, the PCMCIA core issues
20530 + * three set_socket() commands in a row the first with RESET deasserted,
20531 + * the second with RESET asserted, and the last with RESET deasserted
20532 + * again. Following the third set_socket(), a get_status() command will
20533 + * be issued. The kernel is looking for the SS_READY flag (see
20534 + * setup_socket(), reset_socket(), and unreset_socket() in cs.c).
20535 + *
20536 + * Returns: 0
20537 + */
20538 +static int
20539 +bcm47xx_pcmcia_get_status(unsigned int sock, unsigned int *status)
20540 +{
20541 + struct pcmcia_state state;
20542 +
20543 +
20544 + if ((pcmcia_low_level->socket_state(sock, &state)) < 0) {
20545 + printk(KERN_ERR "Unable to get PCMCIA status from kernel.\n");
20546 + return -1;
20547 + }
20548 +
20549 + pcmcia_socket[sock].k_state = state;
20550 +
20551 + *status = state.detect ? SS_DETECT : 0;
20552 +
20553 + *status |= state.ready ? SS_READY : 0;
20554 +
20555 + /* The power status of individual sockets is not available
20556 + * explicitly from the hardware, so we just remember the state
20557 + * and regurgitate it upon request:
20558 + */
20559 + *status |= pcmcia_socket[sock].cs_state.Vcc ? SS_POWERON : 0;
20560 +
20561 + if (pcmcia_socket[sock].cs_state.flags & SS_IOCARD)
20562 + *status |= state.bvd1 ? SS_STSCHG : 0;
20563 + else {
20564 + if (state.bvd1 == 0)
20565 + *status |= SS_BATDEAD;
20566 + else if (state.bvd2 == 0)
20567 + *status |= SS_BATWARN;
20568 + }
20569 +
20570 + *status |= state.vs_3v ? SS_3VCARD : 0;
20571 +
20572 + *status |= state.vs_Xv ? SS_XVCARD : 0;
20573 +
20574 + DEBUG(2, "\tstatus: %s%s%s%s%s%s%s%s\n",
20575 + (*status&SS_DETECT)?"DETECT ":"",
20576 + (*status&SS_READY)?"READY ":"",
20577 + (*status&SS_BATDEAD)?"BATDEAD ":"",
20578 + (*status&SS_BATWARN)?"BATWARN ":"",
20579 + (*status&SS_POWERON)?"POWERON ":"",
20580 + (*status&SS_STSCHG)?"STSCHG ":"",
20581 + (*status&SS_3VCARD)?"3VCARD ":"",
20582 + (*status&SS_XVCARD)?"XVCARD ":"");
20583 +
20584 + return 0;
20585 +}
20586 +
20587 +
20588 +/*
20589 + * bcm47xx_pcmcia_get_socket()
20590 + *
20591 + * Implements the get_socket() operation for the in-kernel PCMCIA
20592 + * service (formerly SS_GetSocket in Card Services). Not a very
20593 + * exciting routine.
20594 + *
20595 + * Returns: 0
20596 + */
20597 +static int
20598 +bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state)
20599 +{
20600 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
20601 +
20602 + /* This information was given to us in an earlier call to set_socket(),
20603 + * so we're just regurgitating it here:
20604 + */
20605 + *state = pcmcia_socket[sock].cs_state;
20606 + return 0;
20607 +}
20608 +
20609 +
20610 +/*
20611 + * bcm47xx_pcmcia_set_socket()
20612 + *
20613 + * Implements the set_socket() operation for the in-kernel PCMCIA
20614 + * service (formerly SS_SetSocket in Card Services). We more or
20615 + * less punt all of this work and let the kernel handle the details
20616 + * of power configuration, reset, &c. We also record the value of
20617 + * `state' in order to regurgitate it to the PCMCIA core later.
20618 + *
20619 + * Returns: 0
20620 + */
20621 +static int
20622 +bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state)
20623 +{
20624 + struct pcmcia_configure configure;
20625 +
20626 + DEBUG(2, "\tmask: %s%s%s%s%s%s\n\tflags: %s%s%s%s%s%s\n"
20627 + "\tVcc %d Vpp %d irq %d\n",
20628 + (state->csc_mask == 0) ? "<NONE>" : "",
20629 + (state->csc_mask & SS_DETECT) ? "DETECT " : "",
20630 + (state->csc_mask & SS_READY) ? "READY " : "",
20631 + (state->csc_mask & SS_BATDEAD) ? "BATDEAD " : "",
20632 + (state->csc_mask & SS_BATWARN) ? "BATWARN " : "",
20633 + (state->csc_mask & SS_STSCHG) ? "STSCHG " : "",
20634 + (state->flags == 0) ? "<NONE>" : "",
20635 + (state->flags & SS_PWR_AUTO) ? "PWR_AUTO " : "",
20636 + (state->flags & SS_IOCARD) ? "IOCARD " : "",
20637 + (state->flags & SS_RESET) ? "RESET " : "",
20638 + (state->flags & SS_SPKR_ENA) ? "SPKR_ENA " : "",
20639 + (state->flags & SS_OUTPUT_ENA) ? "OUTPUT_ENA " : "",
20640 + state->Vcc, state->Vpp, state->io_irq);
20641 +
20642 + configure.sock = sock;
20643 + configure.vcc = state->Vcc;
20644 + configure.vpp = state->Vpp;
20645 + configure.output = (state->flags & SS_OUTPUT_ENA) ? 1 : 0;
20646 + configure.speaker = (state->flags & SS_SPKR_ENA) ? 1 : 0;
20647 + configure.reset = (state->flags & SS_RESET) ? 1 : 0;
20648 +
20649 + if (pcmcia_low_level->configure_socket(&configure) < 0) {
20650 + printk(KERN_ERR "Unable to configure socket %u\n", sock);
20651 + return -1;
20652 + }
20653 +
20654 + pcmcia_socket[sock].cs_state = *state;
20655 + return 0;
20656 +}
20657 +
20658 +
20659 +/*
20660 + * bcm47xx_pcmcia_get_io_map()
20661 + *
20662 + * Implements the get_io_map() operation for the in-kernel PCMCIA
20663 + * service (formerly SS_GetIOMap in Card Services). Just returns an
20664 + * I/O map descriptor which was assigned earlier by a set_io_map().
20665 + *
20666 + * Returns: 0 on success, -1 if the map index was out of range
20667 + */
20668 +static int
20669 +bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *map)
20670 +{
20671 + DEBUG(2, "bcm47xx_pcmcia_get_io_map: sock %d\n", sock);
20672 +
20673 + if (map->map >= MAX_IO_WIN) {
20674 + printk(KERN_ERR "%s(): map (%d) out of range\n",
20675 + __FUNCTION__, map->map);
20676 + return -1;
20677 + }
20678 +
20679 + *map = pcmcia_socket[sock].io_map[map->map];
20680 + return 0;
20681 +}
20682 +
20683 +
20684 +/*
20685 + * bcm47xx_pcmcia_set_io_map()
20686 + *
20687 + * Implements the set_io_map() operation for the in-kernel PCMCIA
20688 + * service (formerly SS_SetIOMap in Card Services). We configure
20689 + * the map speed as requested, but override the address ranges
20690 + * supplied by Card Services.
20691 + *
20692 + * Returns: 0 on success, -1 on error
20693 + */
20694 +int
20695 +bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *map)
20696 +{
20697 + unsigned int speed;
20698 + unsigned long start;
20699 +
20700 + DEBUG(2, "\tmap %u speed %u\n\tstart 0x%08lx stop 0x%08lx\n"
20701 + "\tflags: %s%s%s%s%s%s%s%s\n",
20702 + map->map, map->speed, map->start, map->stop,
20703 + (map->flags == 0) ? "<NONE>" : "",
20704 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
20705 + (map->flags & MAP_16BIT) ? "16BIT " : "",
20706 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
20707 + (map->flags & MAP_0WS) ? "0WS " : "",
20708 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
20709 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "",
20710 + (map->flags & MAP_PREFETCH) ? "PREFETCH " : "");
20711 +
20712 + if (map->map >= MAX_IO_WIN) {
20713 + printk(KERN_ERR "%s(): map (%d) out of range\n",
20714 + __FUNCTION__, map->map);
20715 + return -1;
20716 + }
20717 +
20718 + if (map->flags & MAP_ACTIVE) {
20719 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_IO_SPEED;
20720 + pcmcia_socket[sock].speed_io = speed;
20721 + }
20722 +
20723 + start = map->start;
20724 +
20725 + if (map->stop == 1) {
20726 + map->stop = PAGE_SIZE - 1;
20727 + }
20728 +
20729 + map->start = pcmcia_socket[sock].virt_io;
20730 + map->stop = map->start + (map->stop - start);
20731 + pcmcia_socket[sock].io_map[map->map] = *map;
20732 + DEBUG(2, "set_io_map %d start %x stop %x\n",
20733 + map->map, map->start, map->stop);
20734 + return 0;
20735 +}
20736 +
20737 +
20738 +/*
20739 + * bcm47xx_pcmcia_get_mem_map()
20740 + *
20741 + * Implements the get_mem_map() operation for the in-kernel PCMCIA
20742 + * service (formerly SS_GetMemMap in Card Services). Just returns a
20743 + * memory map descriptor which was assigned earlier by a
20744 + * set_mem_map() request.
20745 + *
20746 + * Returns: 0 on success, -1 if the map index was out of range
20747 + */
20748 +static int
20749 +bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *map)
20750 +{
20751 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
20752 +
20753 + if (map->map >= MAX_WIN) {
20754 + printk(KERN_ERR "%s(): map (%d) out of range\n",
20755 + __FUNCTION__, map->map);
20756 + return -1;
20757 + }
20758 +
20759 + *map = pcmcia_socket[sock].mem_map[map->map];
20760 + return 0;
20761 +}
20762 +
20763 +
20764 +/*
20765 + * bcm47xx_pcmcia_set_mem_map()
20766 + *
20767 + * Implements the set_mem_map() operation for the in-kernel PCMCIA
20768 + * service (formerly SS_SetMemMap in Card Services). We configure
20769 + * the map speed as requested, but override the address ranges
20770 + * supplied by Card Services.
20771 + *
20772 + * Returns: 0 on success, -1 on error
20773 + */
20774 +static int
20775 +bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *map)
20776 +{
20777 + unsigned int speed;
20778 + unsigned long start;
20779 + u_long flags;
20780 +
20781 + if (map->map >= MAX_WIN) {
20782 + printk(KERN_ERR "%s(): map (%d) out of range\n",
20783 + __FUNCTION__, map->map);
20784 + return -1;
20785 + }
20786 +
20787 + DEBUG(2, "\tmap %u speed %u\n\tsys_start %#lx\n"
20788 + "\tsys_stop %#lx\n\tcard_start %#x\n"
20789 + "\tflags: %s%s%s%s%s%s%s%s\n",
20790 + map->map, map->speed, map->sys_start, map->sys_stop,
20791 + map->card_start, (map->flags == 0) ? "<NONE>" : "",
20792 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
20793 + (map->flags & MAP_16BIT) ? "16BIT " : "",
20794 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
20795 + (map->flags & MAP_0WS) ? "0WS " : "",
20796 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
20797 + (map->flags & MAP_ATTRIB) ? "ATTRIB " : "",
20798 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "");
20799 +
20800 + if (map->flags & MAP_ACTIVE) {
20801 + /* When clients issue RequestMap, the access speed is not always
20802 + * properly configured:
20803 + */
20804 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_MEM_SPEED;
20805 +
20806 + /* TBD */
20807 + if (map->flags & MAP_ATTRIB) {
20808 + pcmcia_socket[sock].speed_attr = speed;
20809 + } else {
20810 + pcmcia_socket[sock].speed_mem = speed;
20811 + }
20812 + }
20813 +
20814 + save_flags(flags);
20815 + cli();
20816 + start = map->sys_start;
20817 +
20818 + if (map->sys_stop == 0)
20819 + map->sys_stop = PAGE_SIZE - 1;
20820 +
20821 + if (map->flags & MAP_ATTRIB) {
20822 + map->sys_start = pcmcia_socket[sock].phys_attr +
20823 + map->card_start;
20824 + } else {
20825 + map->sys_start = pcmcia_socket[sock].phys_mem +
20826 + map->card_start;
20827 + }
20828 +
20829 + map->sys_stop = map->sys_start + (map->sys_stop - start);
20830 + pcmcia_socket[sock].mem_map[map->map] = *map;
20831 + restore_flags(flags);
20832 + DEBUG(2, "set_mem_map %d start %x stop %x card_start %x\n",
20833 + map->map, map->sys_start, map->sys_stop,
20834 + map->card_start);
20835 + return 0;
20836 +}
20837 +
20838 +
20839 +#if defined(CONFIG_PROC_FS)
20840 +
20841 +/*
20842 + * bcm47xx_pcmcia_proc_setup()
20843 + *
20844 + * Implements the proc_setup() operation for the in-kernel PCMCIA
20845 + * service (formerly SS_ProcSetup in Card Services).
20846 + *
20847 + * Returns: 0 on success, -1 on error
20848 + */
20849 +static void
20850 +bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base)
20851 +{
20852 + struct proc_dir_entry *entry;
20853 +
20854 + if ((entry = create_proc_entry("status", 0, base)) == NULL) {
20855 + printk(KERN_ERR "Unable to install \"status\" procfs entry\n");
20856 + return;
20857 + }
20858 +
20859 + entry->read_proc = bcm47xx_pcmcia_proc_status;
20860 + entry->data = (void *)sock;
20861 +}
20862 +
20863 +
20864 +/*
20865 + * bcm47xx_pcmcia_proc_status()
20866 + *
20867 + * Implements the /proc/bus/pccard/??/status file.
20868 + *
20869 + * Returns: the number of characters added to the buffer
20870 + */
20871 +static int
20872 +bcm47xx_pcmcia_proc_status(char *buf, char **start, off_t pos,
20873 + int count, int *eof, void *data)
20874 +{
20875 + char *p = buf;
20876 + unsigned int sock = (unsigned int)data;
20877 +
20878 + p += sprintf(p, "k_flags : %s%s%s%s%s%s%s\n",
20879 + pcmcia_socket[sock].k_state.detect ? "detect " : "",
20880 + pcmcia_socket[sock].k_state.ready ? "ready " : "",
20881 + pcmcia_socket[sock].k_state.bvd1 ? "bvd1 " : "",
20882 + pcmcia_socket[sock].k_state.bvd2 ? "bvd2 " : "",
20883 + pcmcia_socket[sock].k_state.wrprot ? "wrprot " : "",
20884 + pcmcia_socket[sock].k_state.vs_3v ? "vs_3v " : "",
20885 + pcmcia_socket[sock].k_state.vs_Xv ? "vs_Xv " : "");
20886 +
20887 + p += sprintf(p, "status : %s%s%s%s%s%s%s%s%s\n",
20888 + pcmcia_socket[sock].k_state.detect ? "SS_DETECT " : "",
20889 + pcmcia_socket[sock].k_state.ready ? "SS_READY " : "",
20890 + pcmcia_socket[sock].cs_state.Vcc ? "SS_POWERON " : "",
20891 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ? "SS_IOCARD " : "",
20892 + (pcmcia_socket[sock].cs_state.flags & SS_IOCARD &&
20893 + pcmcia_socket[sock].k_state.bvd1) ? "SS_STSCHG " : "",
20894 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
20895 + (pcmcia_socket[sock].k_state.bvd1 == 0)) ? "SS_BATDEAD " : "",
20896 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
20897 + (pcmcia_socket[sock].k_state.bvd2 == 0)) ? "SS_BATWARN " : "",
20898 + pcmcia_socket[sock].k_state.vs_3v ? "SS_3VCARD " : "",
20899 + pcmcia_socket[sock].k_state.vs_Xv ? "SS_XVCARD " : "");
20900 +
20901 + p += sprintf(p, "mask : %s%s%s%s%s\n",
20902 + pcmcia_socket[sock].cs_state.csc_mask & SS_DETECT ? "SS_DETECT " : "",
20903 + pcmcia_socket[sock].cs_state.csc_mask & SS_READY ? "SS_READY " : "",
20904 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATDEAD ? "SS_BATDEAD " : "",
20905 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATWARN ? "SS_BATWARN " : "",
20906 + pcmcia_socket[sock].cs_state.csc_mask & SS_STSCHG ? "SS_STSCHG " : "");
20907 +
20908 + p += sprintf(p, "cs_flags : %s%s%s%s%s\n",
20909 + pcmcia_socket[sock].cs_state.flags & SS_PWR_AUTO ?
20910 + "SS_PWR_AUTO " : "",
20911 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ?
20912 + "SS_IOCARD " : "",
20913 + pcmcia_socket[sock].cs_state.flags & SS_RESET ?
20914 + "SS_RESET " : "",
20915 + pcmcia_socket[sock].cs_state.flags & SS_SPKR_ENA ?
20916 + "SS_SPKR_ENA " : "",
20917 + pcmcia_socket[sock].cs_state.flags & SS_OUTPUT_ENA ?
20918 + "SS_OUTPUT_ENA " : "");
20919 +
20920 + p += sprintf(p, "Vcc : %d\n", pcmcia_socket[sock].cs_state.Vcc);
20921 + p += sprintf(p, "Vpp : %d\n", pcmcia_socket[sock].cs_state.Vpp);
20922 + p += sprintf(p, "irq : %d\n", pcmcia_socket[sock].cs_state.io_irq);
20923 + p += sprintf(p, "I/O : %u\n", pcmcia_socket[sock].speed_io);
20924 + p += sprintf(p, "attribute: %u\n", pcmcia_socket[sock].speed_attr);
20925 + p += sprintf(p, "common : %u\n", pcmcia_socket[sock].speed_mem);
20926 + return p-buf;
20927 +}
20928 +
20929 +
20930 +#endif /* defined(CONFIG_PROC_FS) */
20931 diff -Nur linux-2.4.30/drivers/pcmcia/bcm4710_pcmcia.c linux-2.4.30-brcm/drivers/pcmcia/bcm4710_pcmcia.c
20932 --- linux-2.4.30/drivers/pcmcia/bcm4710_pcmcia.c 1970-01-01 01:00:00.000000000 +0100
20933 +++ linux-2.4.30-brcm/drivers/pcmcia/bcm4710_pcmcia.c 2005-05-22 22:55:52.000000000 +0200
20934 @@ -0,0 +1,266 @@
20935 +/*
20936 + * BCM4710 specific pcmcia routines.
20937 + *
20938 + * Copyright 2004, Broadcom Corporation
20939 + * All Rights Reserved.
20940 + *
20941 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
20942 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
20943 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
20944 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
20945 + *
20946 + * $Id: bcm4710_pcmcia.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
20947 + */
20948 +#include <linux/module.h>
20949 +#include <linux/init.h>
20950 +#include <linux/config.h>
20951 +#include <linux/delay.h>
20952 +#include <linux/ioport.h>
20953 +#include <linux/kernel.h>
20954 +#include <linux/tqueue.h>
20955 +#include <linux/timer.h>
20956 +#include <linux/mm.h>
20957 +#include <linux/proc_fs.h>
20958 +#include <linux/version.h>
20959 +#include <linux/types.h>
20960 +#include <linux/pci.h>
20961 +
20962 +#include <pcmcia/version.h>
20963 +#include <pcmcia/cs_types.h>
20964 +#include <pcmcia/cs.h>
20965 +#include <pcmcia/ss.h>
20966 +#include <pcmcia/bulkmem.h>
20967 +#include <pcmcia/cistpl.h>
20968 +#include <pcmcia/bus_ops.h>
20969 +#include "cs_internal.h"
20970 +
20971 +#include <asm/io.h>
20972 +#include <asm/irq.h>
20973 +#include <asm/system.h>
20974 +
20975 +
20976 +#include <typedefs.h>
20977 +#include <bcmdevs.h>
20978 +#include <bcm4710.h>
20979 +#include <sbconfig.h>
20980 +#include <sbextif.h>
20981 +
20982 +#include "bcm4710pcmcia.h"
20983 +
20984 +/* Use a static var for irq dev_id */
20985 +static int bcm47xx_pcmcia_dev_id;
20986 +
20987 +/* Do we think we have a card or not? */
20988 +static int bcm47xx_pcmcia_present = 0;
20989 +
20990 +
20991 +static void bcm4710_pcmcia_reset(void)
20992 +{
20993 + extifregs_t *eir;
20994 + unsigned long s;
20995 + uint32 out0, out1, outen;
20996 +
20997 +
20998 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
20999 +
21000 + save_and_cli(s);
21001 +
21002 + /* Use gpio7 to reset the pcmcia slot */
21003 + outen = readl(&eir->gpio[0].outen);
21004 + outen |= BCM47XX_PCMCIA_RESET;
21005 + out0 = readl(&eir->gpio[0].out);
21006 + out0 &= ~(BCM47XX_PCMCIA_RESET);
21007 + out1 = out0 | BCM47XX_PCMCIA_RESET;
21008 +
21009 + writel(out0, &eir->gpio[0].out);
21010 + writel(outen, &eir->gpio[0].outen);
21011 + mdelay(1);
21012 + writel(out1, &eir->gpio[0].out);
21013 + mdelay(1);
21014 + writel(out0, &eir->gpio[0].out);
21015 +
21016 + restore_flags(s);
21017 +}
21018 +
21019 +
21020 +static int bcm4710_pcmcia_init(struct pcmcia_init *init)
21021 +{
21022 + struct pci_dev *pdev;
21023 + extifregs_t *eir;
21024 + uint32 outen, intp, intm, tmp;
21025 + uint16 *attrsp;
21026 + int rc = 0, i;
21027 + extern unsigned long bcm4710_cpu_cycle;
21028 +
21029 +
21030 + if (!(pdev = pci_find_device(VENDOR_BROADCOM, SB_EXTIF, NULL))) {
21031 + printk(KERN_ERR "bcm4710_pcmcia: extif not found\n");
21032 + return -ENODEV;
21033 + }
21034 + eir = (extifregs_t *) ioremap_nocache(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
21035 +
21036 + /* Initialize the pcmcia i/f: 16bit no swap */
21037 + writel(CF_EM_PCMCIA | CF_DS | CF_EN, &eir->pcmcia_config);
21038 +
21039 +#ifdef notYet
21040 +
21041 + /* Set the timing for memory accesses */
21042 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
21043 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
21044 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
21045 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
21046 + writel(tmp, &eir->pcmcia_memwait); /* 0x01020a0c for a 100Mhz clock */
21047 +
21048 + /* Set the timing for I/O accesses */
21049 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
21050 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
21051 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
21052 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
21053 + writel(tmp, &eir->pcmcia_iowait); /* 0x01020a0c for a 100Mhz clock */
21054 +
21055 + /* Set the timing for attribute accesses */
21056 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
21057 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
21058 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
21059 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
21060 + writel(tmp, &eir->pcmcia_attrwait); /* 0x01020a0c for a 100Mhz clock */
21061 +
21062 +#endif
21063 + /* Make sure gpio0 and gpio5 are inputs */
21064 + outen = readl(&eir->gpio[0].outen);
21065 + outen &= ~(BCM47XX_PCMCIA_WP | BCM47XX_PCMCIA_STSCHG | BCM47XX_PCMCIA_RESET);
21066 + writel(outen, &eir->gpio[0].outen);
21067 +
21068 + /* Issue a reset to the pcmcia socket */
21069 + bcm4710_pcmcia_reset();
21070 +
21071 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
21072 + /* Setup gpio5 to be the STSCHG interrupt */
21073 + intp = readl(&eir->gpiointpolarity);
21074 + writel(intp | BCM47XX_PCMCIA_STSCHG, &eir->gpiointpolarity); /* Active low */
21075 + intm = readl(&eir->gpiointmask);
21076 + writel(intm | BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Enable it */
21077 +#endif
21078 +
21079 + DEBUG(2, "bcm4710_pcmcia after reset:\n");
21080 + DEBUG(2, "\textstatus\t= 0x%08x:\n", readl(&eir->extstatus));
21081 + DEBUG(2, "\tpcmcia_config\t= 0x%08x:\n", readl(&eir->pcmcia_config));
21082 + DEBUG(2, "\tpcmcia_memwait\t= 0x%08x:\n", readl(&eir->pcmcia_memwait));
21083 + DEBUG(2, "\tpcmcia_attrwait\t= 0x%08x:\n", readl(&eir->pcmcia_attrwait));
21084 + DEBUG(2, "\tpcmcia_iowait\t= 0x%08x:\n", readl(&eir->pcmcia_iowait));
21085 + DEBUG(2, "\tgpioin\t\t= 0x%08x:\n", readl(&eir->gpioin));
21086 + DEBUG(2, "\tgpio_outen0\t= 0x%08x:\n", readl(&eir->gpio[0].outen));
21087 + DEBUG(2, "\tgpio_out0\t= 0x%08x:\n", readl(&eir->gpio[0].out));
21088 + DEBUG(2, "\tgpiointpolarity\t= 0x%08x:\n", readl(&eir->gpiointpolarity));
21089 + DEBUG(2, "\tgpiointmask\t= 0x%08x:\n", readl(&eir->gpiointmask));
21090 +
21091 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
21092 + /* Request pcmcia interrupt */
21093 + rc = request_irq(BCM47XX_PCMCIA_IRQ, init->handler, SA_INTERRUPT,
21094 + "PCMCIA Interrupt", &bcm47xx_pcmcia_dev_id);
21095 +#endif
21096 +
21097 + attrsp = (uint16 *)ioremap_nocache(EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF), 0x1000);
21098 + tmp = readw(&attrsp[0]);
21099 + DEBUG(2, "\tattr[0] = 0x%04x\n", tmp);
21100 + if ((tmp == 0x7fff) || (tmp == 0x7f00)) {
21101 + bcm47xx_pcmcia_present = 0;
21102 + } else {
21103 + bcm47xx_pcmcia_present = 1;
21104 + }
21105 +
21106 + /* There's only one socket */
21107 + return 1;
21108 +}
21109 +
21110 +static int bcm4710_pcmcia_shutdown(void)
21111 +{
21112 + extifregs_t *eir;
21113 + uint32 intm;
21114 +
21115 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
21116 +
21117 + /* Disable the pcmcia i/f */
21118 + writel(0, &eir->pcmcia_config);
21119 +
21120 + /* Reset gpio's */
21121 + intm = readl(&eir->gpiointmask);
21122 + writel(intm & ~BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Disable it */
21123 +
21124 + free_irq(BCM47XX_PCMCIA_IRQ, &bcm47xx_pcmcia_dev_id);
21125 +
21126 + return 0;
21127 +}
21128 +
21129 +static int
21130 +bcm4710_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
21131 +{
21132 + extifregs_t *eir;
21133 +
21134 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
21135 +
21136 +
21137 + if (sock != 0) {
21138 + printk(KERN_ERR "bcm4710 socket_state bad sock %d\n", sock);
21139 + return -1;
21140 + }
21141 +
21142 + if (bcm47xx_pcmcia_present) {
21143 + state->detect = 1;
21144 + state->ready = 1;
21145 + state->bvd1 = 1;
21146 + state->bvd2 = 1;
21147 + state->wrprot = (readl(&eir->gpioin) & BCM47XX_PCMCIA_WP) == BCM47XX_PCMCIA_WP;
21148 + state->vs_3v = 0;
21149 + state->vs_Xv = 0;
21150 + } else {
21151 + state->detect = 0;
21152 + state->ready = 0;
21153 + }
21154 +
21155 + return 1;
21156 +}
21157 +
21158 +
21159 +static int bcm4710_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
21160 +{
21161 + if (info->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
21162 +
21163 + info->irq = BCM47XX_PCMCIA_IRQ;
21164 +
21165 + return 0;
21166 +}
21167 +
21168 +
21169 +static int
21170 +bcm4710_pcmcia_configure_socket(const struct pcmcia_configure *configure)
21171 +{
21172 + if (configure->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
21173 +
21174 +
21175 + DEBUG(2, "Vcc %dV Vpp %dV output %d speaker %d reset %d\n", configure->vcc,
21176 + configure->vpp, configure->output, configure->speaker, configure->reset);
21177 +
21178 + if ((configure->vcc != 50) || (configure->vpp != 50)) {
21179 + printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc,
21180 + configure->vpp);
21181 + }
21182 +
21183 + if (configure->reset) {
21184 + /* Issue a reset to the pcmcia socket */
21185 + DEBUG(1, "%s: Reseting socket\n", __FUNCTION__);
21186 + bcm4710_pcmcia_reset();
21187 + }
21188 +
21189 +
21190 + return 0;
21191 +}
21192 +
21193 +struct pcmcia_low_level bcm4710_pcmcia_ops = {
21194 + bcm4710_pcmcia_init,
21195 + bcm4710_pcmcia_shutdown,
21196 + bcm4710_pcmcia_socket_state,
21197 + bcm4710_pcmcia_get_irq_info,
21198 + bcm4710_pcmcia_configure_socket
21199 +};
21200 +
21201 diff -Nur linux-2.4.30/drivers/pcmcia/bcm4710pcmcia.h linux-2.4.30-brcm/drivers/pcmcia/bcm4710pcmcia.h
21202 --- linux-2.4.30/drivers/pcmcia/bcm4710pcmcia.h 1970-01-01 01:00:00.000000000 +0100
21203 +++ linux-2.4.30-brcm/drivers/pcmcia/bcm4710pcmcia.h 2005-05-22 22:55:52.000000000 +0200
21204 @@ -0,0 +1,118 @@
21205 +/*
21206 + *
21207 + * bcm47xx pcmcia driver
21208 + *
21209 + * Copyright 2004, Broadcom Corporation
21210 + * All Rights Reserved.
21211 + *
21212 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
21213 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
21214 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
21215 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
21216 + *
21217 + * Based on sa1100.h and include/asm-arm/arch-sa1100/pcmica.h
21218 + * from www.handhelds.org,
21219 + * and au1000_generic.c from oss.sgi.com.
21220 + *
21221 + * $Id: bcm4710pcmcia.h,v 1.1 2005/03/16 13:50:00 wbx Exp $
21222 + */
21223 +
21224 +#if !defined(_BCM4710PCMCIA_H)
21225 +#define _BCM4710PCMCIA_H
21226 +
21227 +#include <pcmcia/cs_types.h>
21228 +#include <pcmcia/ss.h>
21229 +#include <pcmcia/bulkmem.h>
21230 +#include <pcmcia/cistpl.h>
21231 +#include "cs_internal.h"
21232 +
21233 +
21234 +/* The 47xx can only support one socket */
21235 +#define BCM47XX_PCMCIA_MAX_SOCK 1
21236 +
21237 +/* In the bcm947xx gpio's are used for some pcmcia functions */
21238 +#define BCM47XX_PCMCIA_WP 0x01 /* Bit 0 is WP input */
21239 +#define BCM47XX_PCMCIA_STSCHG 0x20 /* Bit 5 is STSCHG input/interrupt */
21240 +#define BCM47XX_PCMCIA_RESET 0x80 /* Bit 7 is RESET */
21241 +
21242 +#define BCM47XX_PCMCIA_IRQ 2
21243 +
21244 +/* The socket driver actually works nicely in interrupt-driven form,
21245 + * so the (relatively infrequent) polling is "just to be sure."
21246 + */
21247 +#define BCM47XX_PCMCIA_POLL_PERIOD (2 * HZ)
21248 +
21249 +#define BCM47XX_PCMCIA_IO_SPEED (255)
21250 +#define BCM47XX_PCMCIA_MEM_SPEED (300)
21251 +
21252 +
21253 +struct pcmcia_state {
21254 + unsigned detect: 1,
21255 + ready: 1,
21256 + bvd1: 1,
21257 + bvd2: 1,
21258 + wrprot: 1,
21259 + vs_3v: 1,
21260 + vs_Xv: 1;
21261 +};
21262 +
21263 +
21264 +struct pcmcia_configure {
21265 + unsigned sock: 8,
21266 + vcc: 8,
21267 + vpp: 8,
21268 + output: 1,
21269 + speaker: 1,
21270 + reset: 1;
21271 +};
21272 +
21273 +struct pcmcia_irq_info {
21274 + unsigned int sock;
21275 + unsigned int irq;
21276 +};
21277 +
21278 +/* This structure encapsulates per-socket state which we might need to
21279 + * use when responding to a Card Services query of some kind.
21280 + */
21281 +struct bcm47xx_pcmcia_socket {
21282 + socket_state_t cs_state;
21283 + struct pcmcia_state k_state;
21284 + unsigned int irq;
21285 + void (*handler)(void *, unsigned int);
21286 + void *handler_info;
21287 + pccard_io_map io_map[MAX_IO_WIN];
21288 + pccard_mem_map mem_map[MAX_WIN];
21289 + ioaddr_t virt_io, phys_attr, phys_mem;
21290 + unsigned short speed_io, speed_attr, speed_mem;
21291 +};
21292 +
21293 +struct pcmcia_init {
21294 + void (*handler)(int irq, void *dev, struct pt_regs *regs);
21295 +};
21296 +
21297 +struct pcmcia_low_level {
21298 + int (*init)(struct pcmcia_init *);
21299 + int (*shutdown)(void);
21300 + int (*socket_state)(unsigned sock, struct pcmcia_state *);
21301 + int (*get_irq_info)(struct pcmcia_irq_info *);
21302 + int (*configure_socket)(const struct pcmcia_configure *);
21303 +};
21304 +
21305 +extern struct pcmcia_low_level bcm47xx_pcmcia_ops;
21306 +
21307 +/* I/O pins replacing memory pins
21308 + * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75)
21309 + *
21310 + * These signals change meaning when going from memory-only to
21311 + * memory-or-I/O interface:
21312 + */
21313 +#define iostschg bvd1
21314 +#define iospkr bvd2
21315 +
21316 +
21317 +/*
21318 + * Declaration for implementation specific low_level operations.
21319 + */
21320 +extern struct pcmcia_low_level bcm4710_pcmcia_ops;
21321 +
21322 +#endif /* !defined(_BCM4710PCMCIA_H) */
21323 diff -Nur linux-2.4.30/drivers/pcmcia/Makefile linux-2.4.30-brcm/drivers/pcmcia/Makefile
21324 --- linux-2.4.30/drivers/pcmcia/Makefile 2004-02-18 14:36:31.000000000 +0100
21325 +++ linux-2.4.30-brcm/drivers/pcmcia/Makefile 2005-05-22 22:55:52.000000000 +0200
21326 @@ -65,6 +65,10 @@
21327 au1000_ss-objs-$(CONFIG_PCMCIA_DB1X00) += au1000_db1x00.o
21328 au1000_ss-objs-$(CONFIG_PCMCIA_XXS1500) += au1000_xxs1500.o
21329
21330 +obj-$(CONFIG_PCMCIA_BCM4710) += bcm4710_ss.o
21331 +bcm4710_ss-objs := bcm4710_generic.o
21332 +bcm4710_ss-objs += bcm4710_pcmcia.o
21333 +
21334 obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o
21335 obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o
21336 obj-$(CONFIG_PCMCIA_SIBYTE) += sibyte_generic.o
21337 @@ -102,5 +106,8 @@
21338 au1x00_ss.o: $(au1000_ss-objs-y)
21339 $(LD) -r -o $@ $(au1000_ss-objs-y)
21340
21341 +bcm4710_ss.o: $(bcm4710_ss-objs)
21342 + $(LD) -r -o $@ $(bcm4710_ss-objs)
21343 +
21344 yenta_socket.o: $(yenta_socket-objs)
21345 $(LD) $(LD_RFLAG) -r -o $@ $(yenta_socket-objs)
21346 diff -Nur linux-2.4.30/include/asm-mips/bootinfo.h linux-2.4.30-brcm/include/asm-mips/bootinfo.h
21347 --- linux-2.4.30/include/asm-mips/bootinfo.h 2004-02-18 14:36:32.000000000 +0100
21348 +++ linux-2.4.30-brcm/include/asm-mips/bootinfo.h 2005-05-22 22:55:53.000000000 +0200
21349 @@ -37,6 +37,7 @@
21350 #define MACH_GROUP_HP_LJ 20 /* Hewlett Packard LaserJet */
21351 #define MACH_GROUP_LASAT 21
21352 #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
21353 +#define MACH_GROUP_BRCM 23 /* Broadcom */
21354
21355 /*
21356 * Valid machtype values for group unknown (low order halfword of mips_machtype)
21357 @@ -194,6 +195,15 @@
21358 #define MACH_TANBAC_TB0229 7 /* TANBAC TB0229 (VR4131DIMM) */
21359
21360 /*
21361 + * Valid machtypes for group Broadcom
21362 + */
21363 +#define MACH_BCM93725 0
21364 +#define MACH_BCM93725_VJ 1
21365 +#define MACH_BCM93730 2
21366 +#define MACH_BCM947XX 3
21367 +#define MACH_BCM933XX 4
21368 +
21369 +/*
21370 * Valid machtype for group TITAN
21371 */
21372 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
21373 diff -Nur linux-2.4.30/include/asm-mips/cpu.h linux-2.4.30-brcm/include/asm-mips/cpu.h
21374 --- linux-2.4.30/include/asm-mips/cpu.h 2005-01-19 15:10:11.000000000 +0100
21375 +++ linux-2.4.30-brcm/include/asm-mips/cpu.h 2005-05-22 22:55:53.000000000 +0200
21376 @@ -22,6 +22,11 @@
21377 spec.
21378 */
21379
21380 +#define PRID_COPT_MASK 0xff000000
21381 +#define PRID_COMP_MASK 0x00ff0000
21382 +#define PRID_IMP_MASK 0x0000ff00
21383 +#define PRID_REV_MASK 0x000000ff
21384 +
21385 #define PRID_COMP_LEGACY 0x000000
21386 #define PRID_COMP_MIPS 0x010000
21387 #define PRID_COMP_BROADCOM 0x020000
21388 @@ -58,6 +63,7 @@
21389 #define PRID_IMP_RM7000 0x2700
21390 #define PRID_IMP_NEVADA 0x2800 /* RM5260 ??? */
21391 #define PRID_IMP_RM9000 0x3400
21392 +#define PRID_IMP_BCM4710 0x4000
21393 #define PRID_IMP_R5432 0x5400
21394 #define PRID_IMP_R5500 0x5500
21395 #define PRID_IMP_4KC 0x8000
21396 @@ -66,10 +72,16 @@
21397 #define PRID_IMP_4KEC 0x8400
21398 #define PRID_IMP_4KSC 0x8600
21399 #define PRID_IMP_25KF 0x8800
21400 +#define PRID_IMP_BCM3302 0x9000
21401 +#define PRID_IMP_BCM3303 0x9100
21402 #define PRID_IMP_24K 0x9300
21403
21404 #define PRID_IMP_UNKNOWN 0xff00
21405
21406 +#define BCM330X(id) \
21407 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
21408 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
21409 +
21410 /*
21411 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
21412 */
21413 @@ -174,7 +186,9 @@
21414 #define CPU_AU1550 57
21415 #define CPU_24K 58
21416 #define CPU_AU1200 59
21417 -#define CPU_LAST 59
21418 +#define CPU_BCM4710 60
21419 +#define CPU_BCM3302 61
21420 +#define CPU_LAST 61
21421
21422 /*
21423 * ISA Level encodings
21424 diff -Nur linux-2.4.30/include/asm-mips/r4kcache.h linux-2.4.30-brcm/include/asm-mips/r4kcache.h
21425 --- linux-2.4.30/include/asm-mips/r4kcache.h 2004-02-18 14:36:32.000000000 +0100
21426 +++ linux-2.4.30-brcm/include/asm-mips/r4kcache.h 2005-05-25 18:01:08.000000000 +0200
21427 @@ -567,4 +567,17 @@
21428 cache128_unroll32(addr|ws,Index_Writeback_Inv_SD);
21429 }
21430
21431 +extern inline void fill_icache_line(unsigned long addr)
21432 +{
21433 + __asm__ __volatile__(
21434 + ".set noreorder\n\t"
21435 + ".set mips3\n\t"
21436 + "cache %1, (%0)\n\t"
21437 + ".set mips0\n\t"
21438 + ".set reorder"
21439 + :
21440 + : "r" (addr),
21441 + "i" (Fill));
21442 +}
21443 +
21444 #endif /* __ASM_R4KCACHE_H */
21445 diff -Nur linux-2.4.30/include/asm-mips/serial.h linux-2.4.30-brcm/include/asm-mips/serial.h
21446 --- linux-2.4.30/include/asm-mips/serial.h 2005-01-19 15:10:12.000000000 +0100
21447 +++ linux-2.4.30-brcm/include/asm-mips/serial.h 2005-05-22 22:55:53.000000000 +0200
21448 @@ -223,6 +223,13 @@
21449 #define TXX927_SERIAL_PORT_DEFNS
21450 #endif
21451
21452 +#ifdef CONFIG_BCM947XX
21453 +/* reserve 4 ports to be configured at runtime */
21454 +#define BCM947XX_SERIAL_PORT_DEFNS { 0, }, { 0, }, { 0, }, { 0, },
21455 +#else
21456 +#define BCM947XX_SERIAL_PORT_DEFNS
21457 +#endif
21458 +
21459 #ifdef CONFIG_HAVE_STD_PC_SERIAL_PORT
21460 #define STD_SERIAL_PORT_DEFNS \
21461 /* UART CLK PORT IRQ FLAGS */ \
21462 @@ -470,6 +477,7 @@
21463 #define SERIAL_PORT_DFNS \
21464 ATLAS_SERIAL_PORT_DEFNS \
21465 AU1000_SERIAL_PORT_DEFNS \
21466 + BCM947XX_SERIAL_PORT_DEFNS \
21467 COBALT_SERIAL_PORT_DEFNS \
21468 DDB5477_SERIAL_PORT_DEFNS \
21469 EV96100_SERIAL_PORT_DEFNS \
21470 diff -Nur linux-2.4.30/init/do_mounts.c linux-2.4.30-brcm/init/do_mounts.c
21471 --- linux-2.4.30/init/do_mounts.c 2003-11-28 19:26:21.000000000 +0100
21472 +++ linux-2.4.30-brcm/init/do_mounts.c 2005-05-22 22:55:53.000000000 +0200
21473 @@ -253,7 +253,13 @@
21474 { "ftlb", 0x2c08 },
21475 { "ftlc", 0x2c10 },
21476 { "ftld", 0x2c18 },
21477 +#if defined(CONFIG_MTD_BLOCK) || defined(CONFIG_MTD_BLOCK_RO)
21478 { "mtdblock", 0x1f00 },
21479 + { "mtdblock0",0x1f00 },
21480 + { "mtdblock1",0x1f01 },
21481 + { "mtdblock2",0x1f02 },
21482 + { "mtdblock3",0x1f03 },
21483 +#endif
21484 { "nb", 0x2b00 },
21485 { NULL, 0 }
21486 };
21487 diff -Nur linux-2.4.30/Makefile linux-2.4.30-brcm/Makefile
21488 --- linux-2.4.30/Makefile 2005-04-04 03:42:20.000000000 +0200
21489 +++ linux-2.4.30-brcm/Makefile 2005-05-22 22:55:53.000000000 +0200
21490 @@ -17,9 +17,9 @@
21491 FINDHPATH = $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net $(HPATH)/math-emu
21492
21493 HOSTCC = gcc
21494 -HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
21495 +HOSTCFLAGS = -Wall -Wstrict-prototypes -Os -fomit-frame-pointer
21496
21497 -CROSS_COMPILE =
21498 +CROSS_COMPILE=
21499
21500 #
21501 # Include the make variables (CC, etc...)
21502 @@ -91,8 +91,10 @@
21503
21504 CPPFLAGS := -D__KERNEL__ -I$(HPATH)
21505
21506 -CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
21507 +CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
21508 -fno-strict-aliasing -fno-common
21509 +
21510 +
21511 ifndef CONFIG_FRAME_POINTER
21512 CFLAGS += -fomit-frame-pointer
21513 endif
21514 @@ -354,7 +356,7 @@
21515 @rm -f .ver1
21516
21517 include/linux/version.h: ./Makefile
21518 - @expr length "$(KERNELRELEASE)" \<= $(uts_len) > /dev/null || \
21519 + @-expr length "$(KERNELRELEASE)" \<= $(uts_len) > /dev/null || \
21520 (echo KERNELRELEASE \"$(KERNELRELEASE)\" exceeds $(uts_len) characters >&2; false)
21521 @echo \#define UTS_RELEASE \"$(KERNELRELEASE)\" > .ver
21522 @echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver
21523 @@ -500,7 +502,7 @@
21524 ifdef CONFIG_MODVERSIONS
21525 $(MAKE) update-modverfile
21526 endif
21527 - scripts/mkdep -- `find $(FINDHPATH) \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print` > .hdepend
21528 + (find $(FINDHPATH) \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print | xargs -r scripts/mkdep -- ) > .hdepend
21529 scripts/mkdep -- init/*.c > .depend
21530
21531 ifdef CONFIG_MODVERSIONS
21532 diff -Nur linux-2.4.30/Rules.make linux-2.4.30-brcm/Rules.make
21533 --- linux-2.4.30/Rules.make 2004-02-18 14:36:30.000000000 +0100
21534 +++ linux-2.4.30-brcm/Rules.make 2005-05-26 17:11:14.000000000 +0200
21535 @@ -176,7 +176,14 @@
21536 _modinst__: dummy
21537 ifneq "$(strip $(ALL_MOBJS))" ""
21538 mkdir -p $(MODLIB)/kernel/$(MOD_DESTDIR)
21539 - cp $(sort $(ALL_MOBJS)) $(MODLIB)/kernel/$(MOD_DESTDIR)
21540 + #@cp $(sort $(ALL_MOBJS)) $(MODLIB)/kernel/$(MOD_DESTDIR)
21541 + for f in $(ALL_MOBJS) ; do \
21542 + $(OBJCOPY) -R __ksymtab -R .comment -R .note -x \
21543 + `$(NM) $$f | cut -f3- -d' ' | sed -n \
21544 + -e 's/__module_parm_\(.*\)/-K \1/p' \
21545 + -e 's/__ks..tab_\(.*\)/-K \1/p'` \
21546 + $$f $(MODLIB)/kernel/$(MOD_DESTDIR)$(MOD_TARGET)$$f; \
21547 + done
21548 endif
21549
21550 .PHONY: modules_install
This page took 0.9419 seconds and 5 git commands to generate.