add wrt54g v4 support
[openwrt.git] / target / linux / linux-2.4 / patches / brcm / 001-bcm47xx.patch
1 diff -urN linux-2.4.30/Makefile linux-2.4.30.dev/Makefile
2 --- linux-2.4.30/Makefile 2005-08-22 01:29:09.268391576 +0200
3 +++ linux-2.4.30.dev/Makefile 2005-08-22 01:34:46.669098872 +0200
4 @@ -17,9 +17,9 @@
5 FINDHPATH = $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net $(HPATH)/math-emu
6
7 HOSTCC = gcc
8 -HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
9 +HOSTCFLAGS = -Wall -Wstrict-prototypes -Os -fomit-frame-pointer
10
11 -CROSS_COMPILE =
12 +CROSS_COMPILE=
13
14 #
15 # Include the make variables (CC, etc...)
16 @@ -91,8 +91,10 @@
17
18 CPPFLAGS := -D__KERNEL__ -I$(HPATH)
19
20 -CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
21 +CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
22 -fno-strict-aliasing -fno-common
23 +
24 +
25 ifndef CONFIG_FRAME_POINTER
26 CFLAGS += -fomit-frame-pointer
27 endif
28 @@ -354,7 +356,7 @@
29 @rm -f .ver1
30
31 include/linux/version.h: ./Makefile
32 - @expr length "$(KERNELRELEASE)" \<= $(uts_len) > /dev/null || \
33 + @-expr length "$(KERNELRELEASE)" \<= $(uts_len) > /dev/null || \
34 (echo KERNELRELEASE \"$(KERNELRELEASE)\" exceeds $(uts_len) characters >&2; false)
35 @echo \#define UTS_RELEASE \"$(KERNELRELEASE)\" > .ver
36 @echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver
37 @@ -501,7 +503,7 @@
38 ifdef CONFIG_MODVERSIONS
39 $(MAKE) update-modverfile
40 endif
41 - scripts/mkdep -- `find $(FINDHPATH) \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print` > .hdepend
42 + (find $(FINDHPATH) \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print | xargs -r scripts/mkdep -- ) > .hdepend
43 scripts/mkdep -- init/*.c > .depend
44
45 ifdef CONFIG_MODVERSIONS
46 diff -urN linux-2.4.30/Rules.make linux-2.4.30.dev/Rules.make
47 --- linux-2.4.30/Rules.make 2004-02-18 14:36:30.000000000 +0100
48 +++ linux-2.4.30.dev/Rules.make 2005-08-22 01:34:46.683096744 +0200
49 @@ -176,7 +176,14 @@
50 _modinst__: dummy
51 ifneq "$(strip $(ALL_MOBJS))" ""
52 mkdir -p $(MODLIB)/kernel/$(MOD_DESTDIR)
53 - cp $(sort $(ALL_MOBJS)) $(MODLIB)/kernel/$(MOD_DESTDIR)
54 + #@cp $(sort $(ALL_MOBJS)) $(MODLIB)/kernel/$(MOD_DESTDIR)
55 + for f in $(ALL_MOBJS) ; do \
56 + $(OBJCOPY) -R __ksymtab -R .comment -R .note -x \
57 + `$(NM) $$f | cut -f3- -d' ' | sed -n \
58 + -e 's/__module_parm_\(.*\)/-K \1/p' \
59 + -e 's/__ks..tab_\(.*\)/-K \1/p'` \
60 + $$f $(MODLIB)/kernel/$(MOD_DESTDIR)$(MOD_TARGET)$$f; \
61 + done
62 endif
63
64 .PHONY: modules_install
65 diff -urN linux-2.4.30/arch/mips/Makefile linux-2.4.30.dev/arch/mips/Makefile
66 --- linux-2.4.30/arch/mips/Makefile 2005-08-22 01:29:09.270391272 +0200
67 +++ linux-2.4.30.dev/arch/mips/Makefile 2005-08-22 01:34:46.370144320 +0200
68 @@ -46,10 +46,10 @@
69 GCCFLAGS := -I $(TOPDIR)/include/asm/gcc
70 GCCFLAGS += -G 0 -mno-abicalls -fno-pic -pipe
71 GCCFLAGS += $(call check_gcc, -finline-limit=100000,)
72 -LINKFLAGS += -G 0 -static -n
73 -MODFLAGS += -mlong-calls
74 +LINKFLAGS += -G 0 -static -n -nostdlib
75 +MODFLAGS += -mlong-calls -fno-common
76
77 -ifdef CONFIG_DEBUG_INFO
78 +ifdef CONFIG_REMOTE_DEBUG
79 GCCFLAGS += -g
80 ifdef CONFIG_SB1XXX_CORELIS
81 GCCFLAGS += -mno-sched-prolog -fno-omit-frame-pointer
82 @@ -71,13 +71,13 @@
83 set_gccflags = $(shell \
84 while :; do \
85 cpu=$(1); isa=-$(2); \
86 - for gcc_opt in -march= -mcpu=; do \
87 + for gcc_opt in -march= -mtune=; do \
88 $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \
89 -xc /dev/null > /dev/null 2>&1 && \
90 break 2; \
91 done; \
92 cpu=$(3); isa=-$(4); \
93 - for gcc_opt in -march= -mcpu=; do \
94 + for gcc_opt in -march= -mtune=; do \
95 $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \
96 -xc /dev/null > /dev/null 2>&1 && \
97 break 2; \
98 @@ -92,7 +92,7 @@
99 fi; \
100 gas_abi=-Wa,-32; gas_cpu=$$cpu; gas_isa=-Wa,$$isa; \
101 while :; do \
102 - for gas_opt in -Wa,-march= -Wa,-mcpu=; do \
103 + for gas_opt in -Wa,-march= -Wa,-mtune=; do \
104 $(CC) $$gas_abi $$gas_opt$$cpu $$gas_isa -Wa,-Z -c \
105 -o /dev/null -xassembler /dev/null > /dev/null 2>&1 && \
106 break 2; \
107 @@ -174,6 +174,7 @@
108 endif
109
110 AFLAGS += $(GCCFLAGS)
111 +ASFLAGS += $(GCCFLAGS)
112 CFLAGS += $(GCCFLAGS)
113
114 LD += -m $(ld-emul)
115 @@ -727,6 +728,19 @@
116 endif
117
118 #
119 +# Broadcom BCM947XX variants
120 +#
121 +ifdef CONFIG_BCM947XX
122 +LIBS += arch/mips/bcm947xx/generic/brcm.o arch/mips/bcm947xx/bcm947xx.o
123 +SUBDIRS += arch/mips/bcm947xx/generic arch/mips/bcm947xx
124 +LOADADDR := 0x80001000
125 +
126 +zImage: vmlinux
127 + $(MAKE) -C arch/$(ARCH)/bcm947xx/compressed
128 +export LOADADDR
129 +endif
130 +
131 +#
132 # Choosing incompatible machines durings configuration will result in
133 # error messages during linking. Select a default linkscript if
134 # none has been choosen above.
135 @@ -779,6 +793,7 @@
136 $(MAKE) -C arch/$(ARCH)/tools clean
137 $(MAKE) -C arch/mips/baget clean
138 $(MAKE) -C arch/mips/lasat clean
139 + $(MAKE) -C arch/mips/bcm947xx/compressed clean
140
141 archmrproper:
142 @$(MAKEBOOT) mrproper
143 diff -urN linux-2.4.30/arch/mips/bcm947xx/Makefile linux-2.4.30.dev/arch/mips/bcm947xx/Makefile
144 --- linux-2.4.30/arch/mips/bcm947xx/Makefile 1970-01-01 01:00:00.000000000 +0100
145 +++ linux-2.4.30.dev/arch/mips/bcm947xx/Makefile 2005-08-22 01:34:46.340148880 +0200
146 @@ -0,0 +1,15 @@
147 +#
148 +# Makefile for the BCM947xx specific kernel interface routines
149 +# under Linux.
150 +#
151 +
152 +EXTRA_CFLAGS+=-I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
153 +
154 +O_TARGET := bcm947xx.o
155 +
156 +export-objs := nvram_linux.o setup.o
157 +obj-y := prom.o setup.o time.o sbmips.o gpio.o
158 +obj-y += nvram.o nvram_linux.o
159 +obj-$(CONFIG_PCI) += sbpci.o pcibios.o
160 +
161 +include $(TOPDIR)/Rules.make
162 diff -urN linux-2.4.30/arch/mips/bcm947xx/compressed/Makefile linux-2.4.30.dev/arch/mips/bcm947xx/compressed/Makefile
163 --- linux-2.4.30/arch/mips/bcm947xx/compressed/Makefile 1970-01-01 01:00:00.000000000 +0100
164 +++ linux-2.4.30.dev/arch/mips/bcm947xx/compressed/Makefile 2005-08-22 01:34:46.261160888 +0200
165 @@ -0,0 +1,33 @@
166 +#
167 +# Makefile for Broadcom BCM947XX boards
168 +#
169 +# Copyright 2001-2003, Broadcom Corporation
170 +# All Rights Reserved.
171 +#
172 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
173 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
174 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
175 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
176 +#
177 +# $Id: Makefile,v 1.2 2005/04/02 12:12:57 wbx Exp $
178 +#
179 +
180 +OBJCOPY_ARGS = -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
181 +SYSTEM ?= $(TOPDIR)/vmlinux
182 +
183 +all: vmlinuz
184 +
185 +# Don't build dependencies, this may die if $(CC) isn't gcc
186 +dep:
187 +
188 +# Create a gzipped version named vmlinuz for compatibility
189 +vmlinuz: piggy
190 + gzip -c9 $< > $@
191 +
192 +piggy: $(SYSTEM)
193 + $(OBJCOPY) $(OBJCOPY_ARGS) $< $@
194 +
195 +mrproper: clean
196 +
197 +clean:
198 + rm -f vmlinuz piggy
199 diff -urN linux-2.4.30/arch/mips/bcm947xx/generic/Makefile linux-2.4.30.dev/arch/mips/bcm947xx/generic/Makefile
200 --- linux-2.4.30/arch/mips/bcm947xx/generic/Makefile 1970-01-01 01:00:00.000000000 +0100
201 +++ linux-2.4.30.dev/arch/mips/bcm947xx/generic/Makefile 2005-08-22 01:34:46.280158000 +0200
202 @@ -0,0 +1,15 @@
203 +#
204 +# Makefile for the BCM947xx specific kernel interface routines
205 +# under Linux.
206 +#
207 +
208 +.S.s:
209 + $(CPP) $(AFLAGS) $< -o $*.s
210 +.S.o:
211 + $(CC) $(AFLAGS) -c $< -o $*.o
212 +
213 +O_TARGET := brcm.o
214 +
215 +obj-y := int-handler.o irq.o
216 +
217 +include $(TOPDIR)/Rules.make
218 diff -urN linux-2.4.30/arch/mips/bcm947xx/generic/int-handler.S linux-2.4.30.dev/arch/mips/bcm947xx/generic/int-handler.S
219 --- linux-2.4.30/arch/mips/bcm947xx/generic/int-handler.S 1970-01-01 01:00:00.000000000 +0100
220 +++ linux-2.4.30.dev/arch/mips/bcm947xx/generic/int-handler.S 2005-08-22 01:34:46.280158000 +0200
221 @@ -0,0 +1,51 @@
222 +/*
223 + * Generic interrupt handler for Broadcom MIPS boards
224 + *
225 + * Copyright 2004, Broadcom Corporation
226 + * All Rights Reserved.
227 + *
228 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
229 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
230 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
231 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
232 + *
233 + * $Id: int-handler.S,v 1.1 2005/03/16 13:50:00 wbx Exp $
234 + */
235 +
236 +#include <linux/config.h>
237 +
238 +#include <asm/asm.h>
239 +#include <asm/mipsregs.h>
240 +#include <asm/regdef.h>
241 +#include <asm/stackframe.h>
242 +
243 +/*
244 + * MIPS IRQ Source
245 + * -------- ------
246 + * 0 Software (ignored)
247 + * 1 Software (ignored)
248 + * 2 Combined hardware interrupt (hw0)
249 + * 3 Hardware
250 + * 4 Hardware
251 + * 5 Hardware
252 + * 6 Hardware
253 + * 7 R4k timer
254 + */
255 +
256 + .text
257 + .set noreorder
258 + .set noat
259 + .align 5
260 + NESTED(brcmIRQ, PT_SIZE, sp)
261 + SAVE_ALL
262 + CLI
263 + .set at
264 + .set noreorder
265 +
266 + jal brcm_irq_dispatch
267 + move a0, sp
268 +
269 + j ret_from_irq
270 + nop
271 +
272 + END(brcmIRQ)
273 diff -urN linux-2.4.30/arch/mips/bcm947xx/generic/irq.c linux-2.4.30.dev/arch/mips/bcm947xx/generic/irq.c
274 --- linux-2.4.30/arch/mips/bcm947xx/generic/irq.c 1970-01-01 01:00:00.000000000 +0100
275 +++ linux-2.4.30.dev/arch/mips/bcm947xx/generic/irq.c 2005-08-22 01:34:46.280158000 +0200
276 @@ -0,0 +1,130 @@
277 +/*
278 + * Generic interrupt control functions for Broadcom MIPS boards
279 + *
280 + * Copyright 2004, Broadcom Corporation
281 + * All Rights Reserved.
282 + *
283 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
284 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
285 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
286 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
287 + *
288 + * $Id: irq.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
289 + */
290 +
291 +#include <linux/config.h>
292 +#include <linux/init.h>
293 +#include <linux/kernel.h>
294 +#include <linux/types.h>
295 +#include <linux/interrupt.h>
296 +#include <linux/irq.h>
297 +
298 +#include <asm/irq.h>
299 +#include <asm/mipsregs.h>
300 +#include <asm/gdb-stub.h>
301 +
302 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
303 +
304 +extern asmlinkage void brcmIRQ(void);
305 +extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs);
306 +
307 +void
308 +brcm_irq_dispatch(struct pt_regs *regs)
309 +{
310 + u32 cause;
311 +
312 + cause = read_c0_cause() &
313 + read_c0_status() &
314 + CAUSEF_IP;
315 +
316 +#ifdef CONFIG_KERNPROF
317 + change_c0_status(cause | 1, 1);
318 +#else
319 + clear_c0_status(cause);
320 +#endif
321 +
322 + if (cause & CAUSEF_IP7)
323 + do_IRQ(7, regs);
324 + if (cause & CAUSEF_IP2)
325 + do_IRQ(2, regs);
326 + if (cause & CAUSEF_IP3)
327 + do_IRQ(3, regs);
328 + if (cause & CAUSEF_IP4)
329 + do_IRQ(4, regs);
330 + if (cause & CAUSEF_IP5)
331 + do_IRQ(5, regs);
332 + if (cause & CAUSEF_IP6)
333 + do_IRQ(6, regs);
334 +}
335 +
336 +static void
337 +enable_brcm_irq(unsigned int irq)
338 +{
339 + if (irq < 8)
340 + set_c0_status(1 << (irq + 8));
341 + else
342 + set_c0_status(IE_IRQ0);
343 +}
344 +
345 +static void
346 +disable_brcm_irq(unsigned int irq)
347 +{
348 + if (irq < 8)
349 + clear_c0_status(1 << (irq + 8));
350 + else
351 + clear_c0_status(IE_IRQ0);
352 +}
353 +
354 +static void
355 +ack_brcm_irq(unsigned int irq)
356 +{
357 + /* Already done in brcm_irq_dispatch */
358 +}
359 +
360 +static unsigned int
361 +startup_brcm_irq(unsigned int irq)
362 +{
363 + enable_brcm_irq(irq);
364 +
365 + return 0; /* never anything pending */
366 +}
367 +
368 +static void
369 +end_brcm_irq(unsigned int irq)
370 +{
371 + if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
372 + enable_brcm_irq(irq);
373 +}
374 +
375 +static struct hw_interrupt_type brcm_irq_type = {
376 + typename: "MIPS",
377 + startup: startup_brcm_irq,
378 + shutdown: disable_brcm_irq,
379 + enable: enable_brcm_irq,
380 + disable: disable_brcm_irq,
381 + ack: ack_brcm_irq,
382 + end: end_brcm_irq,
383 + NULL
384 +};
385 +
386 +void __init
387 +init_IRQ(void)
388 +{
389 + int i;
390 +
391 + for (i = 0; i < NR_IRQS; i++) {
392 + irq_desc[i].status = IRQ_DISABLED;
393 + irq_desc[i].action = 0;
394 + irq_desc[i].depth = 1;
395 + irq_desc[i].handler = &brcm_irq_type;
396 + }
397 +
398 + set_except_vector(0, brcmIRQ);
399 + change_c0_status(ST0_IM, ALLINTS);
400 +
401 +#ifdef CONFIG_REMOTE_DEBUG
402 + printk("Breaking into debugger...\n");
403 + set_debug_traps();
404 + breakpoint();
405 +#endif
406 +}
407 diff -urN linux-2.4.30/arch/mips/bcm947xx/gpio.c linux-2.4.30.dev/arch/mips/bcm947xx/gpio.c
408 --- linux-2.4.30/arch/mips/bcm947xx/gpio.c 1970-01-01 01:00:00.000000000 +0100
409 +++ linux-2.4.30.dev/arch/mips/bcm947xx/gpio.c 2005-08-22 01:34:46.281157848 +0200
410 @@ -0,0 +1,158 @@
411 +/*
412 + * GPIO char driver
413 + *
414 + * Copyright 2004, Broadcom Corporation
415 + * All Rights Reserved.
416 + *
417 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
418 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
419 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
420 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
421 + *
422 + * $Id: gpio.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
423 + */
424 +
425 +#include <linux/module.h>
426 +#include <linux/init.h>
427 +#include <linux/fs.h>
428 +#include <linux/miscdevice.h>
429 +#include <asm/uaccess.h>
430 +
431 +#include <typedefs.h>
432 +#include <bcmutils.h>
433 +#include <sbutils.h>
434 +#include <bcmdevs.h>
435 +
436 +static void *gpio_sbh;
437 +static int gpio_major;
438 +static devfs_handle_t gpio_dir;
439 +static struct {
440 + char *name;
441 + devfs_handle_t handle;
442 +} gpio_file[] = {
443 + { "in", NULL },
444 + { "out", NULL },
445 + { "outen", NULL },
446 + { "control", NULL }
447 +};
448 +
449 +static int
450 +gpio_open(struct inode *inode, struct file * file)
451 +{
452 + if (MINOR(inode->i_rdev) > ARRAYSIZE(gpio_file))
453 + return -ENODEV;
454 +
455 + MOD_INC_USE_COUNT;
456 + return 0;
457 +}
458 +
459 +static int
460 +gpio_release(struct inode *inode, struct file * file)
461 +{
462 + MOD_DEC_USE_COUNT;
463 + return 0;
464 +}
465 +
466 +static ssize_t
467 +gpio_read(struct file *file, char *buf, size_t count, loff_t *ppos)
468 +{
469 + u32 val;
470 +
471 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
472 + case 0:
473 + val = sb_gpioin(gpio_sbh);
474 + break;
475 + case 1:
476 + val = sb_gpioout(gpio_sbh, 0, 0);
477 + break;
478 + case 2:
479 + val = sb_gpioouten(gpio_sbh, 0, 0);
480 + break;
481 + case 3:
482 + val = sb_gpiocontrol(gpio_sbh, 0, 0);
483 + break;
484 + default:
485 + return -ENODEV;
486 + }
487 +
488 + if (put_user(val, (u32 *) buf))
489 + return -EFAULT;
490 +
491 + return sizeof(val);
492 +}
493 +
494 +static ssize_t
495 +gpio_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
496 +{
497 + u32 val;
498 +
499 + if (get_user(val, (u32 *) buf))
500 + return -EFAULT;
501 +
502 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
503 + case 0:
504 + return -EACCES;
505 + case 1:
506 + sb_gpioout(gpio_sbh, ~0, val);
507 + break;
508 + case 2:
509 + sb_gpioouten(gpio_sbh, ~0, val);
510 + break;
511 + case 3:
512 + sb_gpiocontrol(gpio_sbh, ~0, val);
513 + break;
514 + default:
515 + return -ENODEV;
516 + }
517 +
518 + return sizeof(val);
519 +}
520 +
521 +static struct file_operations gpio_fops = {
522 + owner: THIS_MODULE,
523 + open: gpio_open,
524 + release: gpio_release,
525 + read: gpio_read,
526 + write: gpio_write,
527 +};
528 +
529 +static int __init
530 +gpio_init(void)
531 +{
532 + int i;
533 +
534 + if (!(gpio_sbh = sb_kattach()))
535 + return -ENODEV;
536 +
537 + sb_gpiosetcore(gpio_sbh);
538 +
539 + if ((gpio_major = devfs_register_chrdev(0, "gpio", &gpio_fops)) < 0)
540 + return gpio_major;
541 +
542 + gpio_dir = devfs_mk_dir(NULL, "gpio", NULL);
543 +
544 + for (i = 0; i < ARRAYSIZE(gpio_file); i++) {
545 + gpio_file[i].handle = devfs_register(gpio_dir,
546 + gpio_file[i].name,
547 + DEVFS_FL_DEFAULT, gpio_major, i,
548 + S_IFCHR | S_IRUGO | S_IWUGO,
549 + &gpio_fops, NULL);
550 + }
551 +
552 + return 0;
553 +}
554 +
555 +static void __exit
556 +gpio_exit(void)
557 +{
558 + int i;
559 +
560 + for (i = 0; i < ARRAYSIZE(gpio_file); i++)
561 + devfs_unregister(gpio_file[i].handle);
562 + devfs_unregister(gpio_dir);
563 + devfs_unregister_chrdev(gpio_major, "gpio");
564 + sb_detach(gpio_sbh);
565 +}
566 +
567 +module_init(gpio_init);
568 +module_exit(gpio_exit);
569 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmdevs.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmdevs.h
570 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmdevs.h 1970-01-01 01:00:00.000000000 +0100
571 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmdevs.h 2005-08-22 01:34:46.282157696 +0200
572 @@ -0,0 +1,369 @@
573 +/*
574 + * Broadcom device-specific manifest constants.
575 + *
576 + * Copyright 2005, Broadcom Corporation
577 + * All Rights Reserved.
578 + *
579 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
580 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
581 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
582 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
583 + * $Id$
584 + */
585 +
586 +#ifndef _BCMDEVS_H
587 +#define _BCMDEVS_H
588 +
589 +
590 +/* Known PCI vendor Id's */
591 +#define VENDOR_EPIGRAM 0xfeda
592 +#define VENDOR_BROADCOM 0x14e4
593 +#define VENDOR_3COM 0x10b7
594 +#define VENDOR_NETGEAR 0x1385
595 +#define VENDOR_DIAMOND 0x1092
596 +#define VENDOR_DELL 0x1028
597 +#define VENDOR_HP 0x0e11
598 +#define VENDOR_APPLE 0x106b
599 +
600 +/* PCI Device Id's */
601 +#define BCM4210_DEVICE_ID 0x1072 /* never used */
602 +#define BCM4211_DEVICE_ID 0x4211
603 +#define BCM4230_DEVICE_ID 0x1086 /* never used */
604 +#define BCM4231_DEVICE_ID 0x4231
605 +
606 +#define BCM4410_DEVICE_ID 0x4410 /* bcm44xx family pci iline */
607 +#define BCM4430_DEVICE_ID 0x4430 /* bcm44xx family cardbus iline */
608 +#define BCM4412_DEVICE_ID 0x4412 /* bcm44xx family pci enet */
609 +#define BCM4432_DEVICE_ID 0x4432 /* bcm44xx family cardbus enet */
610 +
611 +#define BCM3352_DEVICE_ID 0x3352 /* bcm3352 device id */
612 +#define BCM3360_DEVICE_ID 0x3360 /* bcm3360 device id */
613 +
614 +#define EPI41210_DEVICE_ID 0xa0fa /* bcm4210 */
615 +#define EPI41230_DEVICE_ID 0xa10e /* bcm4230 */
616 +
617 +#define BCM47XX_ILINE_ID 0x4711 /* 47xx iline20 */
618 +#define BCM47XX_V90_ID 0x4712 /* 47xx v90 codec */
619 +#define BCM47XX_ENET_ID 0x4713 /* 47xx enet */
620 +#define BCM47XX_EXT_ID 0x4714 /* 47xx external i/f */
621 +#define BCM47XX_USB_ID 0x4715 /* 47xx usb */
622 +#define BCM47XX_USBH_ID 0x4716 /* 47xx usb host */
623 +#define BCM47XX_USBD_ID 0x4717 /* 47xx usb device */
624 +#define BCM47XX_IPSEC_ID 0x4718 /* 47xx ipsec */
625 +#define BCM47XX_ROBO_ID 0x4719 /* 47xx/53xx roboswitch core */
626 +#define BCM47XX_USB20H_ID 0x471a /* 47xx usb 2.0 host */
627 +#define BCM47XX_USB20D_ID 0x471b /* 47xx usb 2.0 device */
628 +
629 +#define BCM4710_DEVICE_ID 0x4710 /* 4710 primary function 0 */
630 +
631 +#define BCM4610_DEVICE_ID 0x4610 /* 4610 primary function 0 */
632 +#define BCM4610_ILINE_ID 0x4611 /* 4610 iline100 */
633 +#define BCM4610_V90_ID 0x4612 /* 4610 v90 codec */
634 +#define BCM4610_ENET_ID 0x4613 /* 4610 enet */
635 +#define BCM4610_EXT_ID 0x4614 /* 4610 external i/f */
636 +#define BCM4610_USB_ID 0x4615 /* 4610 usb */
637 +
638 +#define BCM4402_DEVICE_ID 0x4402 /* 4402 primary function 0 */
639 +#define BCM4402_ENET_ID 0x4402 /* 4402 enet */
640 +#define BCM4402_V90_ID 0x4403 /* 4402 v90 codec */
641 +#define BCM4401_ENET_ID 0x170c /* 4401b0 production enet cards */
642 +
643 +#define BCM4301_DEVICE_ID 0x4301 /* 4301 primary function 0 */
644 +#define BCM4301_D11B_ID 0x4301 /* 4301 802.11b */
645 +
646 +#define BCM4307_DEVICE_ID 0x4307 /* 4307 primary function 0 */
647 +#define BCM4307_V90_ID 0x4305 /* 4307 v90 codec */
648 +#define BCM4307_ENET_ID 0x4306 /* 4307 enet */
649 +#define BCM4307_D11B_ID 0x4307 /* 4307 802.11b */
650 +
651 +#define BCM4306_DEVICE_ID 0x4306 /* 4306 chipcommon chipid */
652 +#define BCM4306_D11G_ID 0x4320 /* 4306 802.11g */
653 +#define BCM4306_D11G_ID2 0x4325
654 +#define BCM4306_D11A_ID 0x4321 /* 4306 802.11a */
655 +#define BCM4306_UART_ID 0x4322 /* 4306 uart */
656 +#define BCM4306_V90_ID 0x4323 /* 4306 v90 codec */
657 +#define BCM4306_D11DUAL_ID 0x4324 /* 4306 dual A+B */
658 +
659 +#define BCM4309_PKG_ID 1 /* 4309 package id */
660 +
661 +#define BCM4303_D11B_ID 0x4303 /* 4303 802.11b */
662 +#define BCM4303_PKG_ID 2 /* 4303 package id */
663 +
664 +#define BCM4310_DEVICE_ID 0x4310 /* 4310 chipcommon chipid */
665 +#define BCM4310_D11B_ID 0x4311 /* 4310 802.11b */
666 +#define BCM4310_UART_ID 0x4312 /* 4310 uart */
667 +#define BCM4310_ENET_ID 0x4313 /* 4310 enet */
668 +#define BCM4310_USB_ID 0x4315 /* 4310 usb */
669 +
670 +#define BCMGPRS_UART_ID 0x4333 /* Uart id used by 4306/gprs card */
671 +
672 +#define BCM4704_DEVICE_ID 0x4704 /* 4704 chipcommon chipid */
673 +#define BCM4704_ENET_ID 0x4706 /* 4704 enet (Use 47XX_ENET_ID instead!) */
674 +
675 +#define BCM4317_DEVICE_ID 0x4317 /* 4317 chip common chipid */
676 +
677 +#define BCM4318_DEVICE_ID 0x4318 /* 4318 chip common chipid */
678 +#define BCM4318_D11G_ID 0x4318 /* 4318 801.11b/g id */
679 +#define BCM4318_D11DUAL_ID 0x4319 /* 4318 801.11a/b/g id */
680 +#define BCM4318_JTAGM_ID 0x4331 /* 4318 jtagm device id */
681 +
682 +#define FPGA_JTAGM_ID 0x4330 /* ??? */
683 +
684 +/* Address map */
685 +#define BCM4710_SDRAM 0x00000000 /* Physical SDRAM */
686 +#define BCM4710_PCI_MEM 0x08000000 /* Host Mode PCI memory access space (64 MB) */
687 +#define BCM4710_PCI_CFG 0x0c000000 /* Host Mode PCI configuration space (64 MB) */
688 +#define BCM4710_PCI_DMA 0x40000000 /* Client Mode PCI memory access space (1 GB) */
689 +#define BCM4710_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
690 +#define BCM4710_ENUM 0x18000000 /* Beginning of core enumeration space */
691 +
692 +/* Core register space */
693 +#define BCM4710_REG_SDRAM 0x18000000 /* SDRAM core registers */
694 +#define BCM4710_REG_ILINE20 0x18001000 /* InsideLine20 core registers */
695 +#define BCM4710_REG_EMAC0 0x18002000 /* Ethernet MAC 0 core registers */
696 +#define BCM4710_REG_CODEC 0x18003000 /* Codec core registers */
697 +#define BCM4710_REG_USB 0x18004000 /* USB core registers */
698 +#define BCM4710_REG_PCI 0x18005000 /* PCI core registers */
699 +#define BCM4710_REG_MIPS 0x18006000 /* MIPS core registers */
700 +#define BCM4710_REG_EXTIF 0x18007000 /* External Interface core registers */
701 +#define BCM4710_REG_EMAC1 0x18008000 /* Ethernet MAC 1 core registers */
702 +
703 +#define BCM4710_EXTIF 0x1f000000 /* External Interface base address */
704 +#define BCM4710_PCMCIA_MEM 0x1f000000 /* External Interface PCMCIA memory access */
705 +#define BCM4710_PCMCIA_IO 0x1f100000 /* PCMCIA I/O access */
706 +#define BCM4710_PCMCIA_CONF 0x1f200000 /* PCMCIA configuration */
707 +#define BCM4710_PROG 0x1f800000 /* Programable interface */
708 +#define BCM4710_FLASH 0x1fc00000 /* Flash */
709 +
710 +#define BCM4710_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
711 +
712 +#define BCM4710_UART (BCM4710_REG_EXTIF + 0x00000300)
713 +
714 +#define BCM4710_EUART (BCM4710_EXTIF + 0x00800000)
715 +#define BCM4710_LED (BCM4710_EXTIF + 0x00900000)
716 +
717 +#define BCM4712_DEVICE_ID 0x4712 /* 4712 chipcommon chipid */
718 +#define BCM4712_MIPS_ID 0x4720 /* 4712 base devid */
719 +#define BCM4712LARGE_PKG_ID 0 /* 340pin 4712 package id */
720 +#define BCM4712SMALL_PKG_ID 1 /* 200pin 4712 package id */
721 +#define BCM4712MID_PKG_ID 2 /* 225pin 4712 package id */
722 +
723 +#define SDIOH_FPGA_ID 0x4380 /* sdio host fpga */
724 +
725 +#define BCM5365_DEVICE_ID 0x5365 /* 5365 chipcommon chipid */
726 +#define BCM5350_DEVICE_ID 0x5350 /* bcm5350 chipcommon chipid */
727 +#define BCM5352_DEVICE_ID 0x5352 /* bcm5352 chipcommon chipid */
728 +
729 +#define BCM4320_DEVICE_ID 0x4320 /* bcm4320 chipcommon chipid */
730 +
731 +/* PCMCIA vendor Id's */
732 +
733 +#define VENDOR_BROADCOM_PCMCIA 0x02d0
734 +
735 +/* SDIO vendor Id's */
736 +#define VENDOR_BROADCOM_SDIO 0x00BF
737 +
738 +
739 +/* boardflags */
740 +#define BFL_BTCOEXIST 0x0001 /* This board implements Bluetooth coexistance */
741 +#define BFL_PACTRL 0x0002 /* This board has gpio 9 controlling the PA */
742 +#define BFL_AIRLINEMODE 0x0004 /* This board implements gpio13 radio disable indication */
743 +#define BFL_ENETROBO 0x0010 /* This board has robo switch or core */
744 +#define BFL_CCKHIPWR 0x0040 /* Can do high-power CCK transmission */
745 +#define BFL_ENETADM 0x0080 /* This board has ADMtek switch */
746 +#define BFL_ENETVLAN 0x0100 /* This board has vlan capability */
747 +#define BFL_AFTERBURNER 0x0200 /* This board supports Afterburner mode */
748 +#define BFL_NOPCI 0x0400 /* This board leaves PCI floating */
749 +#define BFL_FEM 0x0800 /* This board supports the Front End Module */
750 +#define BFL_EXTLNA 0x1000 /* This board has an external LNA */
751 +#define BFL_HGPA 0x2000 /* This board has a high gain PA */
752 +#define BFL_BTCMOD 0x4000 /* This board' BTCOEXIST is in the alternate gpios */
753 +
754 +/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */
755 +#define BOARD_GPIO_HWRAD_B 0x010 /* bit 4 is HWRAD input on 4301 */
756 +#define BOARD_GPIO_BTCMOD_IN 0x010 /* bit 4 is the alternate BT Coexistance Input */
757 +#define BOARD_GPIO_BTCMOD_OUT 0x020 /* bit 5 is the alternate BT Coexistance Out */
758 +#define BOARD_GPIO_BTC_IN 0x080 /* bit 7 is BT Coexistance Input */
759 +#define BOARD_GPIO_BTC_OUT 0x100 /* bit 8 is BT Coexistance Out */
760 +#define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */
761 +#define PCI_CFG_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */
762 +#define PCI_CFG_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */
763 +#define PCI_CFG_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
764 +#define PCI_CFG_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
765 +
766 +/* Bus types */
767 +#define SB_BUS 0 /* Silicon Backplane */
768 +#define PCI_BUS 1 /* PCI target */
769 +#define PCMCIA_BUS 2 /* PCMCIA target */
770 +#define SDIO_BUS 3 /* SDIO target */
771 +#define JTAG_BUS 4 /* JTAG */
772 +
773 +/* Allows optimization for single-bus support */
774 +#ifdef BCMBUSTYPE
775 +#define BUSTYPE(bus) (BCMBUSTYPE)
776 +#else
777 +#define BUSTYPE(bus) (bus)
778 +#endif
779 +
780 +/* power control defines */
781 +#define PLL_DELAY 150 /* 150us pll on delay */
782 +#define FREF_DELAY 200 /* 200us fref change delay */
783 +#define MIN_SLOW_CLK 32 /* 32us Slow clock period */
784 +
785 +/* Reference Board Types */
786 +
787 +#define BU4710_BOARD 0x0400
788 +#define VSIM4710_BOARD 0x0401
789 +#define QT4710_BOARD 0x0402
790 +
791 +#define BU4610_BOARD 0x0403
792 +#define VSIM4610_BOARD 0x0404
793 +
794 +#define BU4307_BOARD 0x0405
795 +#define BCM94301CB_BOARD 0x0406
796 +#define BCM94301PC_BOARD 0x0406 /* Pcmcia 5v card */
797 +#define BCM94301MP_BOARD 0x0407
798 +#define BCM94307MP_BOARD 0x0408
799 +#define BCMAP4307_BOARD 0x0409
800 +
801 +#define BU4309_BOARD 0x040a
802 +#define BCM94309CB_BOARD 0x040b
803 +#define BCM94309MP_BOARD 0x040c
804 +#define BCM4309AP_BOARD 0x040d
805 +
806 +#define BCM94302MP_BOARD 0x040e
807 +
808 +#define VSIM4310_BOARD 0x040f
809 +#define BU4711_BOARD 0x0410
810 +#define BCM94310U_BOARD 0x0411
811 +#define BCM94310AP_BOARD 0x0412
812 +#define BCM94310MP_BOARD 0x0414
813 +
814 +#define BU4306_BOARD 0x0416
815 +#define BCM94306CB_BOARD 0x0417
816 +#define BCM94306MP_BOARD 0x0418
817 +
818 +#define BCM94710D_BOARD 0x041a
819 +#define BCM94710R1_BOARD 0x041b
820 +#define BCM94710R4_BOARD 0x041c
821 +#define BCM94710AP_BOARD 0x041d
822 +
823 +
824 +#define BU2050_BOARD 0x041f
825 +
826 +
827 +#define BCM94309G_BOARD 0x0421
828 +
829 +#define BCM94301PC3_BOARD 0x0422 /* Pcmcia 3.3v card */
830 +
831 +#define BU4704_BOARD 0x0423
832 +#define BU4702_BOARD 0x0424
833 +
834 +#define BCM94306PC_BOARD 0x0425 /* pcmcia 3.3v 4306 card */
835 +
836 +#define BU4317_BOARD 0x0426
837 +
838 +
839 +#define BCM94702MN_BOARD 0x0428
840 +
841 +/* BCM4702 1U CompactPCI Board */
842 +#define BCM94702CPCI_BOARD 0x0429
843 +
844 +/* BCM4702 with BCM95380 VLAN Router */
845 +#define BCM95380RR_BOARD 0x042a
846 +
847 +/* cb4306 with SiGe PA */
848 +#define BCM94306CBSG_BOARD 0x042b
849 +
850 +/* mp4301 with 2050 radio */
851 +#define BCM94301MPL_BOARD 0x042c
852 +
853 +/* cb4306 with SiGe PA */
854 +#define PCSG94306_BOARD 0x042d
855 +
856 +/* bu4704 with sdram */
857 +#define BU4704SD_BOARD 0x042e
858 +
859 +/* Dual 11a/11g Router */
860 +#define BCM94704AGR_BOARD 0x042f
861 +
862 +/* 11a-only minipci */
863 +#define BCM94308MP_BOARD 0x0430
864 +
865 +
866 +
867 +/* BCM94317 boards */
868 +#define BCM94317CB_BOARD 0x0440
869 +#define BCM94317MP_BOARD 0x0441
870 +#define BCM94317PCMCIA_BOARD 0x0442
871 +#define BCM94317SDIO_BOARD 0x0443
872 +
873 +#define BU4712_BOARD 0x0444
874 +#define BU4712SD_BOARD 0x045d
875 +#define BU4712L_BOARD 0x045f
876 +
877 +/* BCM4712 boards */
878 +#define BCM94712AP_BOARD 0x0445
879 +#define BCM94712P_BOARD 0x0446
880 +
881 +/* BCM4318 boards */
882 +#define BU4318_BOARD 0x0447
883 +#define CB4318_BOARD 0x0448
884 +#define MPG4318_BOARD 0x0449
885 +#define MP4318_BOARD 0x044a
886 +#define SD4318_BOARD 0x044b
887 +
888 +/* Another mp4306 with SiGe */
889 +#define BCM94306P_BOARD 0x044c
890 +
891 +/* CF-like 4317 modules */
892 +#define BCM94317CF_BOARD 0x044d
893 +
894 +/* mp4303 */
895 +#define BCM94303MP_BOARD 0x044e
896 +
897 +/* mpsgh4306 */
898 +#define BCM94306MPSGH_BOARD 0x044f
899 +
900 +/* BRCM 4306 w/ Front End Modules */
901 +#define BCM94306MPM 0x0450
902 +#define BCM94306MPL 0x0453
903 +
904 +/* 4712agr */
905 +#define BCM94712AGR_BOARD 0x0451
906 +
907 +/* The real CF 4317 board */
908 +#define CFI4317_BOARD 0x0452
909 +
910 +/* pcmcia 4303 */
911 +#define PC4303_BOARD 0x0454
912 +
913 +/* 5350K */
914 +#define BCM95350K_BOARD 0x0455
915 +
916 +/* 5350R */
917 +#define BCM95350R_BOARD 0x0456
918 +
919 +/* 4306mplna */
920 +#define BCM94306MPLNA_BOARD 0x0457
921 +
922 +
923 +/* 4306mph */
924 +#define BCM94306MPH_BOARD 0x045b
925 +
926 +/* 4306pciv */
927 +#define BCM94306PCIV_BOARD 0x045c
928 +
929 +#define BU4712SD_BOARD 0x045d
930 +
931 +
932 +#define BU4712L_BOARD 0x045f
933 +#define BCM94712LGR_BOARD 0x0460
934 +
935 +#define BU5352_BOARD 0x0462
936 +#define BCM95352GR_BOARD 0x0467
937 +
938 +/* # of GPIO pins */
939 +#define GPIO_NUMPINS 16
940 +
941 +#endif /* _BCMDEVS_H */
942 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmendian.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmendian.h
943 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmendian.h 1970-01-01 01:00:00.000000000 +0100
944 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmendian.h 2005-08-22 01:34:46.282157696 +0200
945 @@ -0,0 +1,168 @@
946 +/*
947 + * local version of endian.h - byte order defines
948 + *
949 + * Copyright 2005, Broadcom Corporation
950 + * All Rights Reserved.
951 + *
952 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
953 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
954 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
955 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
956 + *
957 + * $Id$
958 +*/
959 +
960 +#ifndef _BCMENDIAN_H_
961 +#define _BCMENDIAN_H_
962 +
963 +#include <typedefs.h>
964 +
965 +/* Byte swap a 16 bit value */
966 +#define BCMSWAP16(val) \
967 + ((uint16)( \
968 + (((uint16)(val) & (uint16)0x00ffU) << 8) | \
969 + (((uint16)(val) & (uint16)0xff00U) >> 8) ))
970 +
971 +/* Byte swap a 32 bit value */
972 +#define BCMSWAP32(val) \
973 + ((uint32)( \
974 + (((uint32)(val) & (uint32)0x000000ffUL) << 24) | \
975 + (((uint32)(val) & (uint32)0x0000ff00UL) << 8) | \
976 + (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) | \
977 + (((uint32)(val) & (uint32)0xff000000UL) >> 24) ))
978 +
979 +static INLINE uint16
980 +bcmswap16(uint16 val)
981 +{
982 + return BCMSWAP16(val);
983 +}
984 +
985 +static INLINE uint32
986 +bcmswap32(uint32 val)
987 +{
988 + return BCMSWAP32(val);
989 +}
990 +
991 +/* buf - start of buffer of shorts to swap */
992 +/* len - byte length of buffer */
993 +static INLINE void
994 +bcmswap16_buf(uint16 *buf, uint len)
995 +{
996 + len = len/2;
997 +
998 + while(len--){
999 + *buf = bcmswap16(*buf);
1000 + buf++;
1001 + }
1002 +}
1003 +
1004 +#ifndef hton16
1005 +#ifndef IL_BIGENDIAN
1006 +#define HTON16(i) BCMSWAP16(i)
1007 +#define hton16(i) bcmswap16(i)
1008 +#define hton32(i) bcmswap32(i)
1009 +#define ntoh16(i) bcmswap16(i)
1010 +#define ntoh32(i) bcmswap32(i)
1011 +#define ltoh16(i) (i)
1012 +#define ltoh32(i) (i)
1013 +#define htol16(i) (i)
1014 +#define htol32(i) (i)
1015 +#else
1016 +#define HTON16(i) (i)
1017 +#define hton16(i) (i)
1018 +#define hton32(i) (i)
1019 +#define ntoh16(i) (i)
1020 +#define ntoh32(i) (i)
1021 +#define ltoh16(i) bcmswap16(i)
1022 +#define ltoh32(i) bcmswap32(i)
1023 +#define htol16(i) bcmswap16(i)
1024 +#define htol32(i) bcmswap32(i)
1025 +#endif
1026 +#endif
1027 +
1028 +#ifndef IL_BIGENDIAN
1029 +#define ltoh16_buf(buf, i)
1030 +#define htol16_buf(buf, i)
1031 +#else
1032 +#define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
1033 +#define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
1034 +#endif
1035 +
1036 +/*
1037 +* load 16-bit value from unaligned little endian byte array.
1038 +*/
1039 +static INLINE uint16
1040 +ltoh16_ua(uint8 *bytes)
1041 +{
1042 + return (bytes[1]<<8)+bytes[0];
1043 +}
1044 +
1045 +/*
1046 +* load 32-bit value from unaligned little endian byte array.
1047 +*/
1048 +static INLINE uint32
1049 +ltoh32_ua(uint8 *bytes)
1050 +{
1051 + return (bytes[3]<<24)+(bytes[2]<<16)+(bytes[1]<<8)+bytes[0];
1052 +}
1053 +
1054 +/*
1055 +* load 16-bit value from unaligned big(network) endian byte array.
1056 +*/
1057 +static INLINE uint16
1058 +ntoh16_ua(uint8 *bytes)
1059 +{
1060 + return (bytes[0]<<8)+bytes[1];
1061 +}
1062 +
1063 +/*
1064 +* load 32-bit value from unaligned big(network) endian byte array.
1065 +*/
1066 +static INLINE uint32
1067 +ntoh32_ua(uint8 *bytes)
1068 +{
1069 + return (bytes[0]<<24)+(bytes[1]<<16)+(bytes[2]<<8)+bytes[3];
1070 +}
1071 +
1072 +/* get_ua adapted from Linux asm-mips/unaligned.h */
1073 +#ifdef IL_BIGENDIAN
1074 +#define get_ua(ptr) \
1075 +({ \
1076 + __typeof__(*(ptr)) __val; \
1077 + \
1078 + switch (sizeof(*(ptr))) { \
1079 + case 1: \
1080 + __val = *(uint8 *)ptr; \
1081 + break; \
1082 + case 2: \
1083 + __val = ntoh16_ua((uint8 *)ptr); \
1084 + break; \
1085 + case 4: \
1086 + __val = ntoh32_ua((uint8 *)ptr); \
1087 + break; \
1088 + } \
1089 + \
1090 + __val; \
1091 +})
1092 +#else
1093 +#define get_ua(ptr) \
1094 +({ \
1095 + __typeof__(*(ptr)) __val; \
1096 + \
1097 + switch (sizeof(*(ptr))) { \
1098 + case 1: \
1099 + __val = *(uint8 *)ptr; \
1100 + break; \
1101 + case 2: \
1102 + __val = ltoh16_ua((uint8 *)ptr); \
1103 + break; \
1104 + case 4: \
1105 + __val = ltoh32_ua((uint8 *)ptr); \
1106 + break; \
1107 + } \
1108 + \
1109 + __val; \
1110 +})
1111 +#endif
1112 +
1113 +#endif /* _BCMENDIAN_H_ */
1114 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmenet47xx.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmenet47xx.h
1115 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmenet47xx.h 1970-01-01 01:00:00.000000000 +0100
1116 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmenet47xx.h 2005-08-22 01:34:46.284157392 +0200
1117 @@ -0,0 +1,229 @@
1118 +/*
1119 + * Hardware-specific definitions for
1120 + * Broadcom BCM47XX 10/100 Mbps Ethernet cores.
1121 + *
1122 + * Copyright 2005, Broadcom Corporation
1123 + * All Rights Reserved.
1124 + *
1125 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1126 + * the contents of this file may not be disclosed to third parties, copied
1127 + * or duplicated in any form, in whole or in part, without the prior
1128 + * written permission of Broadcom Corporation.
1129 + * $Id$
1130 + */
1131 +
1132 +#ifndef _bcmenet_47xx_h_
1133 +#define _bcmenet_47xx_h_
1134 +
1135 +#include <bcmenetmib.h>
1136 +#include <bcmenetrxh.h>
1137 +#include <bcmenetphy.h>
1138 +
1139 +#define BCMENET_NFILTERS 64 /* # ethernet address filter entries */
1140 +#define BCMENET_MCHASHBASE 0x200 /* multicast hash filter base address */
1141 +#define BCMENET_MCHASHSIZE 256 /* multicast hash filter size in bytes */
1142 +#define BCMENET_MAX_DMA 4096 /* chip has 12 bits of DMA addressing */
1143 +
1144 +/* power management event wakeup pattern constants */
1145 +#define BCMENET_NPMP 4 /* chip supports 4 wakeup patterns */
1146 +#define BCMENET_PMPBASE 0x400 /* wakeup pattern base address */
1147 +#define BCMENET_PMPSIZE 0x80 /* 128bytes each pattern */
1148 +#define BCMENET_PMMBASE 0x600 /* wakeup mask base address */
1149 +#define BCMENET_PMMSIZE 0x10 /* 128bits each mask */
1150 +
1151 +/* cpp contortions to concatenate w/arg prescan */
1152 +#ifndef PAD
1153 +#define _PADLINE(line) pad ## line
1154 +#define _XSTR(line) _PADLINE(line)
1155 +#define PAD _XSTR(__LINE__)
1156 +#endif /* PAD */
1157 +
1158 +/*
1159 + * Host Interface Registers
1160 + */
1161 +typedef volatile struct _bcmenettregs {
1162 + /* Device and Power Control */
1163 + uint32 devcontrol;
1164 + uint32 PAD[2];
1165 + uint32 biststatus;
1166 + uint32 wakeuplength;
1167 + uint32 PAD[3];
1168 +
1169 + /* Interrupt Control */
1170 + uint32 intstatus;
1171 + uint32 intmask;
1172 + uint32 gptimer;
1173 + uint32 PAD[23];
1174 +
1175 + /* Ethernet MAC Address Filtering Control */
1176 + uint32 PAD[2];
1177 + uint32 enetftaddr;
1178 + uint32 enetftdata;
1179 + uint32 PAD[2];
1180 +
1181 + /* Ethernet MAC Control */
1182 + uint32 emactxmaxburstlen;
1183 + uint32 emacrxmaxburstlen;
1184 + uint32 emaccontrol;
1185 + uint32 emacflowcontrol;
1186 +
1187 + uint32 PAD[20];
1188 +
1189 + /* DMA Lazy Interrupt Control */
1190 + uint32 intrecvlazy;
1191 + uint32 PAD[63];
1192 +
1193 + /* DMA engine */
1194 + dmaregs_t dmaregs;
1195 + dmafifo_t dmafifo;
1196 + uint32 PAD[116];
1197 +
1198 + /* EMAC Registers */
1199 + uint32 rxconfig;
1200 + uint32 rxmaxlength;
1201 + uint32 txmaxlength;
1202 + uint32 PAD;
1203 + uint32 mdiocontrol;
1204 + uint32 mdiodata;
1205 + uint32 emacintmask;
1206 + uint32 emacintstatus;
1207 + uint32 camdatalo;
1208 + uint32 camdatahi;
1209 + uint32 camcontrol;
1210 + uint32 enetcontrol;
1211 + uint32 txcontrol;
1212 + uint32 txwatermark;
1213 + uint32 mibcontrol;
1214 + uint32 PAD[49];
1215 +
1216 + /* EMAC MIB counters */
1217 + bcmenetmib_t mib;
1218 +
1219 + uint32 PAD[585];
1220 +
1221 + /* Sonics SiliconBackplane config registers */
1222 + sbconfig_t sbconfig;
1223 +} bcmenetregs_t;
1224 +
1225 +/* device control */
1226 +#define DC_PM ((uint32)1 << 7) /* pattern filtering enable */
1227 +#define DC_IP ((uint32)1 << 10) /* internal ephy present (rev >= 1) */
1228 +#define DC_ER ((uint32)1 << 15) /* ephy reset */
1229 +#define DC_MP ((uint32)1 << 16) /* mii phy mode enable */
1230 +#define DC_CO ((uint32)1 << 17) /* mii phy mode: enable clocks */
1231 +#define DC_PA_MASK 0x7c0000 /* mii phy mode: mdc/mdio phy address */
1232 +#define DC_PA_SHIFT 18
1233 +#define DC_FS_MASK 0x03800000 /* fifo size (rev >= 8) */
1234 +#define DC_FS_SHIFT 23
1235 +#define DC_FS_4K 0 /* 4Kbytes */
1236 +#define DC_FS_512 1 /* 512bytes */
1237 +
1238 +/* wakeup length */
1239 +#define WL_P0_MASK 0x7f /* pattern 0 */
1240 +#define WL_D0 ((uint32)1 << 7)
1241 +#define WL_P1_MASK 0x7f00 /* pattern 1 */
1242 +#define WL_P1_SHIFT 8
1243 +#define WL_D1 ((uint32)1 << 15)
1244 +#define WL_P2_MASK 0x7f0000 /* pattern 2 */
1245 +#define WL_P2_SHIFT 16
1246 +#define WL_D2 ((uint32)1 << 23)
1247 +#define WL_P3_MASK 0x7f000000 /* pattern 3 */
1248 +#define WL_P3_SHIFT 24
1249 +#define WL_D3 ((uint32)1 << 31)
1250 +
1251 +/* intstatus and intmask */
1252 +#define I_PME ((uint32)1 << 6) /* power management event */
1253 +#define I_TO ((uint32)1 << 7) /* general purpose timeout */
1254 +#define I_PC ((uint32)1 << 10) /* descriptor error */
1255 +#define I_PD ((uint32)1 << 11) /* data error */
1256 +#define I_DE ((uint32)1 << 12) /* descriptor protocol error */
1257 +#define I_RU ((uint32)1 << 13) /* receive descriptor underflow */
1258 +#define I_RO ((uint32)1 << 14) /* receive fifo overflow */
1259 +#define I_XU ((uint32)1 << 15) /* transmit fifo underflow */
1260 +#define I_RI ((uint32)1 << 16) /* receive interrupt */
1261 +#define I_XI ((uint32)1 << 24) /* transmit interrupt */
1262 +#define I_EM ((uint32)1 << 26) /* emac interrupt */
1263 +#define I_MW ((uint32)1 << 27) /* mii write */
1264 +#define I_MR ((uint32)1 << 28) /* mii read */
1265 +
1266 +/* emaccontrol */
1267 +#define EMC_CG ((uint32)1 << 0) /* crc32 generation enable */
1268 +#define EMC_EP ((uint32)1 << 2) /* onchip ephy: powerdown (rev >= 1) */
1269 +#define EMC_ED ((uint32)1 << 3) /* onchip ephy: energy detected (rev >= 1) */
1270 +#define EMC_LC_MASK 0xe0 /* onchip ephy: led control (rev >= 1) */
1271 +#define EMC_LC_SHIFT 5
1272 +
1273 +/* emacflowcontrol */
1274 +#define EMF_RFH_MASK 0xff /* rx fifo hi water mark */
1275 +#define EMF_PG ((uint32)1 << 15) /* enable pause frame generation */
1276 +
1277 +/* interrupt receive lazy */
1278 +#define IRL_TO_MASK 0x00ffffff /* timeout */
1279 +#define IRL_FC_MASK 0xff000000 /* frame count */
1280 +#define IRL_FC_SHIFT 24 /* frame count */
1281 +
1282 +/* emac receive config */
1283 +#define ERC_DB ((uint32)1 << 0) /* disable broadcast */
1284 +#define ERC_AM ((uint32)1 << 1) /* accept all multicast */
1285 +#define ERC_RDT ((uint32)1 << 2) /* receive disable while transmitting */
1286 +#define ERC_PE ((uint32)1 << 3) /* promiscuous enable */
1287 +#define ERC_LE ((uint32)1 << 4) /* loopback enable */
1288 +#define ERC_FE ((uint32)1 << 5) /* enable flow control */
1289 +#define ERC_UF ((uint32)1 << 6) /* accept unicast flow control frame */
1290 +#define ERC_RF ((uint32)1 << 7) /* reject filter */
1291 +#define ERC_CA ((uint32)1 << 8) /* cam absent */
1292 +
1293 +/* emac mdio control */
1294 +#define MC_MF_MASK 0x7f /* mdc frequency */
1295 +#define MC_PE ((uint32)1 << 7) /* mii preamble enable */
1296 +
1297 +/* emac mdio data */
1298 +#define MD_DATA_MASK 0xffff /* r/w data */
1299 +#define MD_TA_MASK 0x30000 /* turnaround value */
1300 +#define MD_TA_SHIFT 16
1301 +#define MD_TA_VALID (2 << MD_TA_SHIFT) /* valid ta */
1302 +#define MD_RA_MASK 0x7c0000 /* register address */
1303 +#define MD_RA_SHIFT 18
1304 +#define MD_PMD_MASK 0xf800000 /* physical media device */
1305 +#define MD_PMD_SHIFT 23
1306 +#define MD_OP_MASK 0x30000000 /* opcode */
1307 +#define MD_OP_SHIFT 28
1308 +#define MD_OP_WRITE (1 << MD_OP_SHIFT) /* write op */
1309 +#define MD_OP_READ (2 << MD_OP_SHIFT) /* read op */
1310 +#define MD_SB_MASK 0xc0000000 /* start bits */
1311 +#define MD_SB_SHIFT 30
1312 +#define MD_SB_START (0x1 << MD_SB_SHIFT) /* start of frame */
1313 +
1314 +/* emac intstatus and intmask */
1315 +#define EI_MII ((uint32)1 << 0) /* mii mdio interrupt */
1316 +#define EI_MIB ((uint32)1 << 1) /* mib interrupt */
1317 +#define EI_FLOW ((uint32)1 << 2) /* flow control interrupt */
1318 +
1319 +/* emac cam data high */
1320 +#define CD_V ((uint32)1 << 16) /* valid bit */
1321 +
1322 +/* emac cam control */
1323 +#define CC_CE ((uint32)1 << 0) /* cam enable */
1324 +#define CC_MS ((uint32)1 << 1) /* mask select */
1325 +#define CC_RD ((uint32)1 << 2) /* read */
1326 +#define CC_WR ((uint32)1 << 3) /* write */
1327 +#define CC_INDEX_MASK 0x3f0000 /* index */
1328 +#define CC_INDEX_SHIFT 16
1329 +#define CC_CB ((uint32)1 << 31) /* cam busy */
1330 +
1331 +/* emac ethernet control */
1332 +#define EC_EE ((uint32)1 << 0) /* emac enable */
1333 +#define EC_ED ((uint32)1 << 1) /* emac disable */
1334 +#define EC_ES ((uint32)1 << 2) /* emac soft reset */
1335 +#define EC_EP ((uint32)1 << 3) /* external phy select */
1336 +
1337 +/* emac transmit control */
1338 +#define EXC_FD ((uint32)1 << 0) /* full duplex */
1339 +#define EXC_FM ((uint32)1 << 1) /* flowmode */
1340 +#define EXC_SB ((uint32)1 << 2) /* single backoff enable */
1341 +#define EXC_SS ((uint32)1 << 3) /* small slottime */
1342 +
1343 +/* emac mib control */
1344 +#define EMC_RZ ((uint32)1 << 0) /* autoclear on read */
1345 +
1346 +#endif /* _bcmenet_47xx_h_ */
1347 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmenetmib.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmenetmib.h
1348 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmenetmib.h 1970-01-01 01:00:00.000000000 +0100
1349 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmenetmib.h 2005-08-22 01:34:46.284157392 +0200
1350 @@ -0,0 +1,81 @@
1351 +/*
1352 + * Hardware-specific MIB definition for
1353 + * Broadcom Home Networking Division
1354 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1355 + *
1356 + * Copyright 2005, Broadcom Corporation
1357 + * All Rights Reserved.
1358 + *
1359 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1360 + * the contents of this file may not be disclosed to third parties, copied
1361 + * or duplicated in any form, in whole or in part, without the prior
1362 + * written permission of Broadcom Corporation.
1363 + * $Id$
1364 + */
1365 +
1366 +#ifndef _bcmenetmib_h_
1367 +#define _bcmenetmib_h_
1368 +
1369 +/* cpp contortions to concatenate w/arg prescan */
1370 +#ifndef PAD
1371 +#define _PADLINE(line) pad ## line
1372 +#define _XSTR(line) _PADLINE(line)
1373 +#define PAD _XSTR(__LINE__)
1374 +#endif /* PAD */
1375 +
1376 +/*
1377 + * EMAC MIB Registers
1378 + */
1379 +typedef volatile struct {
1380 + uint32 tx_good_octets;
1381 + uint32 tx_good_pkts;
1382 + uint32 tx_octets;
1383 + uint32 tx_pkts;
1384 + uint32 tx_broadcast_pkts;
1385 + uint32 tx_multicast_pkts;
1386 + uint32 tx_len_64;
1387 + uint32 tx_len_65_to_127;
1388 + uint32 tx_len_128_to_255;
1389 + uint32 tx_len_256_to_511;
1390 + uint32 tx_len_512_to_1023;
1391 + uint32 tx_len_1024_to_max;
1392 + uint32 tx_jabber_pkts;
1393 + uint32 tx_oversize_pkts;
1394 + uint32 tx_fragment_pkts;
1395 + uint32 tx_underruns;
1396 + uint32 tx_total_cols;
1397 + uint32 tx_single_cols;
1398 + uint32 tx_multiple_cols;
1399 + uint32 tx_excessive_cols;
1400 + uint32 tx_late_cols;
1401 + uint32 tx_defered;
1402 + uint32 tx_carrier_lost;
1403 + uint32 tx_pause_pkts;
1404 + uint32 PAD[8];
1405 +
1406 + uint32 rx_good_octets;
1407 + uint32 rx_good_pkts;
1408 + uint32 rx_octets;
1409 + uint32 rx_pkts;
1410 + uint32 rx_broadcast_pkts;
1411 + uint32 rx_multicast_pkts;
1412 + uint32 rx_len_64;
1413 + uint32 rx_len_65_to_127;
1414 + uint32 rx_len_128_to_255;
1415 + uint32 rx_len_256_to_511;
1416 + uint32 rx_len_512_to_1023;
1417 + uint32 rx_len_1024_to_max;
1418 + uint32 rx_jabber_pkts;
1419 + uint32 rx_oversize_pkts;
1420 + uint32 rx_fragment_pkts;
1421 + uint32 rx_missed_pkts;
1422 + uint32 rx_crc_align_errs;
1423 + uint32 rx_undersize;
1424 + uint32 rx_crc_errs;
1425 + uint32 rx_align_errs;
1426 + uint32 rx_symbol_errs;
1427 + uint32 rx_pause_pkts;
1428 + uint32 rx_nonpause_pkts;
1429 +} bcmenetmib_t;
1430 +
1431 +#endif /* _bcmenetmib_h_ */
1432 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmenetphy.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmenetphy.h
1433 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmenetphy.h 1970-01-01 01:00:00.000000000 +0100
1434 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmenetphy.h 2005-08-22 01:34:46.284157392 +0200
1435 @@ -0,0 +1,58 @@
1436 +/*
1437 + * Misc Broadcom BCM47XX MDC/MDIO enet phy definitions.
1438 + *
1439 + * Copyright 2005, Broadcom Corporation
1440 + * All Rights Reserved.
1441 + *
1442 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1443 + * the contents of this file may not be disclosed to third parties, copied
1444 + * or duplicated in any form, in whole or in part, without the prior
1445 + * written permission of Broadcom Corporation.
1446 + * $Id$
1447 + */
1448 +
1449 +#ifndef _bcmenetphy_h_
1450 +#define _bcmenetphy_h_
1451 +
1452 +/* phy address */
1453 +#define MAXEPHY 32 /* mdio phy addresses are 5bit quantities */
1454 +#define EPHY_MASK 0x1f
1455 +#define EPHY_NONE 31 /* nvram: no phy present at all */
1456 +#define EPHY_NOREG 30 /* nvram: no local phy regs */
1457 +
1458 +/* just a few phy registers */
1459 +#define CTL_RESET (1 << 15) /* reset */
1460 +#define CTL_LOOP (1 << 14) /* loopback */
1461 +#define CTL_SPEED (1 << 13) /* speed selection 0=10, 1=100 */
1462 +#define CTL_ANENAB (1 << 12) /* autonegotiation enable */
1463 +#define CTL_RESTART (1 << 9) /* restart autonegotiation */
1464 +#define CTL_DUPLEX (1 << 8) /* duplex mode 0=half, 1=full */
1465 +
1466 +#define ADV_10FULL (1 << 6) /* autonegotiate advertise 10full */
1467 +#define ADV_10HALF (1 << 5) /* autonegotiate advertise 10half */
1468 +#define ADV_100FULL (1 << 8) /* autonegotiate advertise 100full */
1469 +#define ADV_100HALF (1 << 7) /* autonegotiate advertise 100half */
1470 +
1471 +/* link partner ability register */
1472 +#define LPA_SLCT 0x001f /* same as advertise selector */
1473 +#define LPA_10HALF 0x0020 /* can do 10mbps half-duplex */
1474 +#define LPA_10FULL 0x0040 /* can do 10mbps full-duplex */
1475 +#define LPA_100HALF 0x0080 /* can do 100mbps half-duplex */
1476 +#define LPA_100FULL 0x0100 /* can do 100mbps full-duplex */
1477 +#define LPA_100BASE4 0x0200 /* can do 100mbps 4k packets */
1478 +#define LPA_RESV 0x1c00 /* unused */
1479 +#define LPA_RFAULT 0x2000 /* link partner faulted */
1480 +#define LPA_LPACK 0x4000 /* link partner acked us */
1481 +#define LPA_NPAGE 0x8000 /* next page bit */
1482 +
1483 +#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
1484 +#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
1485 +
1486 +#define STAT_REMFAULT (1 << 4) /* remote fault */
1487 +#define STAT_LINK (1 << 2) /* link status */
1488 +#define STAT_JAB (1 << 1) /* jabber detected */
1489 +#define AUX_FORCED (1 << 2) /* forced 10/100 */
1490 +#define AUX_SPEED (1 << 1) /* speed 0=10mbps 1=100mbps */
1491 +#define AUX_DUPLEX (1 << 0) /* duplex 0=half 1=full */
1492 +
1493 +#endif /* _bcmenetphy_h_ */
1494 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmenetrxh.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmenetrxh.h
1495 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmenetrxh.h 1970-01-01 01:00:00.000000000 +0100
1496 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmenetrxh.h 2005-08-22 01:34:46.285157240 +0200
1497 @@ -0,0 +1,43 @@
1498 +/*
1499 + * Hardware-specific Receive Data Header for the
1500 + * Broadcom Home Networking Division
1501 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1502 + *
1503 + * Copyright 2005, Broadcom Corporation
1504 + * All Rights Reserved.
1505 + *
1506 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1507 + * the contents of this file may not be disclosed to third parties, copied
1508 + * or duplicated in any form, in whole or in part, without the prior
1509 + * written permission of Broadcom Corporation.
1510 + * $Id$
1511 + */
1512 +
1513 +#ifndef _bcmenetrxh_h_
1514 +#define _bcmenetrxh_h_
1515 +
1516 +/*
1517 + * The Ethernet MAC core returns an 8-byte Receive Frame Data Header
1518 + * with every frame consisting of
1519 + * 16bits of frame length, followed by
1520 + * 16bits of EMAC rx descriptor info, followed by 32bits of undefined.
1521 + */
1522 +typedef volatile struct {
1523 + uint16 len;
1524 + uint16 flags;
1525 + uint16 pad[12];
1526 +} bcmenetrxh_t;
1527 +
1528 +#define RXHDR_LEN 28
1529 +
1530 +#define RXF_L ((uint16)1 << 11) /* last buffer in a frame */
1531 +#define RXF_MISS ((uint16)1 << 7) /* received due to promisc mode */
1532 +#define RXF_BRDCAST ((uint16)1 << 6) /* dest is broadcast address */
1533 +#define RXF_MULT ((uint16)1 << 5) /* dest is multicast address */
1534 +#define RXF_LG ((uint16)1 << 4) /* frame length > rxmaxlength */
1535 +#define RXF_NO ((uint16)1 << 3) /* odd number of nibbles */
1536 +#define RXF_RXER ((uint16)1 << 2) /* receive symbol error */
1537 +#define RXF_CRC ((uint16)1 << 1) /* crc error */
1538 +#define RXF_OV ((uint16)1 << 0) /* fifo overflow */
1539 +
1540 +#endif /* _bcmenetrxh_h_ */
1541 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmnvram.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmnvram.h
1542 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmnvram.h 1970-01-01 01:00:00.000000000 +0100
1543 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmnvram.h 2005-08-22 01:34:46.285157240 +0200
1544 @@ -0,0 +1,132 @@
1545 +/*
1546 + * NVRAM variable manipulation
1547 + *
1548 + * Copyright 2005, Broadcom Corporation
1549 + * All Rights Reserved.
1550 + *
1551 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1552 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1553 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1554 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1555 + *
1556 + * $Id$
1557 + */
1558 +
1559 +#ifndef _bcmnvram_h_
1560 +#define _bcmnvram_h_
1561 +
1562 +#ifndef _LANGUAGE_ASSEMBLY
1563 +
1564 +#include <typedefs.h>
1565 +
1566 +struct nvram_header {
1567 + uint32 magic;
1568 + uint32 len;
1569 + uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:27 init, mem. test 28, 29-31 reserved */
1570 + uint32 config_refresh; /* 0:15 config, 16:31 refresh */
1571 + uint32 config_ncdl; /* ncdl values for memc */
1572 +};
1573 +
1574 +struct nvram_tuple {
1575 + char *name;
1576 + char *value;
1577 + struct nvram_tuple *next;
1578 +};
1579 +
1580 +/*
1581 + * Initialize NVRAM access. May be unnecessary or undefined on certain
1582 + * platforms.
1583 + */
1584 +extern int BCMINIT(nvram_init)(void *sbh);
1585 +
1586 +/*
1587 + * Disable NVRAM access. May be unnecessary or undefined on certain
1588 + * platforms.
1589 + */
1590 +extern void BCMINIT(nvram_exit)(void);
1591 +
1592 +/*
1593 + * Get the value of an NVRAM variable. The pointer returned may be
1594 + * invalid after a set.
1595 + * @param name name of variable to get
1596 + * @return value of variable or NULL if undefined
1597 + */
1598 +extern char * BCMINIT(nvram_get)(const char *name);
1599 +
1600 +/*
1601 + * Get the value of an NVRAM variable.
1602 + * @param name name of variable to get
1603 + * @return value of variable or NUL if undefined
1604 + */
1605 +#define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "")
1606 +
1607 +/*
1608 + * Match an NVRAM variable.
1609 + * @param name name of variable to match
1610 + * @param match value to compare against value of variable
1611 + * @return TRUE if variable is defined and its value is string equal
1612 + * to match or FALSE otherwise
1613 + */
1614 +static INLINE int
1615 +nvram_match(char *name, char *match) {
1616 + const char *value = BCMINIT(nvram_get)(name);
1617 + return (value && !strcmp(value, match));
1618 +}
1619 +
1620 +/*
1621 + * Inversely match an NVRAM variable.
1622 + * @param name name of variable to match
1623 + * @param match value to compare against value of variable
1624 + * @return TRUE if variable is defined and its value is not string
1625 + * equal to invmatch or FALSE otherwise
1626 + */
1627 +static INLINE int
1628 +nvram_invmatch(char *name, char *invmatch) {
1629 + const char *value = BCMINIT(nvram_get)(name);
1630 + return (value && strcmp(value, invmatch));
1631 +}
1632 +
1633 +/*
1634 + * Set the value of an NVRAM variable. The name and value strings are
1635 + * copied into private storage. Pointers to previously set values
1636 + * may become invalid. The new value may be immediately
1637 + * retrieved but will not be permanently stored until a commit.
1638 + * @param name name of variable to set
1639 + * @param value value of variable
1640 + * @return 0 on success and errno on failure
1641 + */
1642 +extern int BCMINIT(nvram_set)(const char *name, const char *value);
1643 +
1644 +/*
1645 + * Unset an NVRAM variable. Pointers to previously set values
1646 + * remain valid until a set.
1647 + * @param name name of variable to unset
1648 + * @return 0 on success and errno on failure
1649 + * NOTE: use nvram_commit to commit this change to flash.
1650 + */
1651 +extern int BCMINIT(nvram_unset)(const char *name);
1652 +
1653 +/*
1654 + * Commit NVRAM variables to permanent storage. All pointers to values
1655 + * may be invalid after a commit.
1656 + * NVRAM values are undefined after a commit.
1657 + * @return 0 on success and errno on failure
1658 + */
1659 +extern int BCMINIT(nvram_commit)(void);
1660 +
1661 +/*
1662 + * Get all NVRAM variables (format name=value\0 ... \0\0).
1663 + * @param buf buffer to store variables
1664 + * @param count size of buffer in bytes
1665 + * @return 0 on success and errno on failure
1666 + */
1667 +extern int BCMINIT(nvram_getall)(char *buf, int count);
1668 +
1669 +#endif /* _LANGUAGE_ASSEMBLY */
1670 +
1671 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
1672 +#define NVRAM_VERSION 1
1673 +#define NVRAM_HEADER_SIZE 20
1674 +#define NVRAM_SPACE 0x8000
1675 +
1676 +#endif /* _bcmnvram_h_ */
1677 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmparams.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmparams.h
1678 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmparams.h 1970-01-01 01:00:00.000000000 +0100
1679 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmparams.h 2005-08-22 01:34:46.286157088 +0200
1680 @@ -0,0 +1,23 @@
1681 +/*
1682 + * Misc system wide parameters.
1683 + *
1684 + * Copyright 2005, Broadcom Corporation
1685 + * All Rights Reserved.
1686 + *
1687 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1688 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1689 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1690 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1691 + * $Id$
1692 + */
1693 +
1694 +#ifndef _bcmparams_h_
1695 +#define _bcmparams_h_
1696 +
1697 +#define VLAN_MAXVID 15 /* Max. VLAN ID supported/allowed */
1698 +
1699 +#define VLAN_NUMPRIS 8 /* # of prio, start from 0 */
1700 +
1701 +#define DEV_NUMIFS 16 /* Max. # of devices/interfaces supported */
1702 +
1703 +#endif
1704 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmsrom.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmsrom.h
1705 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmsrom.h 1970-01-01 01:00:00.000000000 +0100
1706 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmsrom.h 2005-08-22 01:34:46.286157088 +0200
1707 @@ -0,0 +1,22 @@
1708 +/*
1709 + * Misc useful routines to access NIC local SROM/OTP .
1710 + *
1711 + * Copyright 2005, Broadcom Corporation
1712 + * All Rights Reserved.
1713 + *
1714 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1715 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1716 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1717 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1718 + *
1719 + * $Id$
1720 + */
1721 +
1722 +#ifndef _bcmsrom_h_
1723 +#define _bcmsrom_h_
1724 +
1725 +extern int srom_var_init(void *sbh, uint bus, void *curmap, void *osh, char **vars, int *count);
1726 +extern int srom_read(uint bus, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf);
1727 +extern int srom_write(uint bus, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf);
1728 +
1729 +#endif /* _bcmsrom_h_ */
1730 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bcmutils.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmutils.h
1731 --- linux-2.4.30/arch/mips/bcm947xx/include/bcmutils.h 1970-01-01 01:00:00.000000000 +0100
1732 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bcmutils.h 2005-08-22 01:34:46.314152832 +0200
1733 @@ -0,0 +1,239 @@
1734 +/*
1735 + * Misc useful os-independent macros and functions.
1736 + *
1737 + * Copyright 2005, Broadcom Corporation
1738 + * All Rights Reserved.
1739 + *
1740 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1741 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1742 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1743 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1744 + * $Id$
1745 + */
1746 +
1747 +#ifndef _bcmutils_h_
1748 +#define _bcmutils_h_
1749 +
1750 +/*** driver-only section ***/
1751 +#ifdef BCMDRIVER
1752 +#include <osl.h>
1753 +
1754 +#define _BCM_U 0x01 /* upper */
1755 +#define _BCM_L 0x02 /* lower */
1756 +#define _BCM_D 0x04 /* digit */
1757 +#define _BCM_C 0x08 /* cntrl */
1758 +#define _BCM_P 0x10 /* punct */
1759 +#define _BCM_S 0x20 /* white space (space/lf/tab) */
1760 +#define _BCM_X 0x40 /* hex digit */
1761 +#define _BCM_SP 0x80 /* hard space (0x20) */
1762 +
1763 +extern unsigned char bcm_ctype[];
1764 +#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
1765 +
1766 +#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
1767 +#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
1768 +#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0)
1769 +#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0)
1770 +#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
1771 +#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0)
1772 +#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
1773 +#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0)
1774 +#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0)
1775 +#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0)
1776 +#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
1777 +
1778 +/*
1779 + * Spin at most 'us' microseconds while 'exp' is true.
1780 + * Caller should explicitly test 'exp' when this completes
1781 + * and take appropriate error action if 'exp' is still true.
1782 + */
1783 +#define SPINWAIT(exp, us) { \
1784 + uint countdown = (us) + 9; \
1785 + while ((exp) && (countdown >= 10)) {\
1786 + OSL_DELAY(10); \
1787 + countdown -= 10; \
1788 + } \
1789 +}
1790 +
1791 +/* generic osl packet queue */
1792 +struct pktq {
1793 + void *head; /* first packet to dequeue */
1794 + void *tail; /* last packet to dequeue */
1795 + uint len; /* number of queued packets */
1796 + uint maxlen; /* maximum number of queued packets */
1797 + bool priority; /* enqueue by packet priority */
1798 + uint8 prio_map[MAXPRIO+1]; /* user priority to packet enqueue policy map */
1799 +};
1800 +#define DEFAULT_QLEN 128
1801 +
1802 +#define pktq_len(q) ((q)->len)
1803 +#define pktq_avail(q) ((q)->maxlen - (q)->len)
1804 +#define pktq_head(q) ((q)->head)
1805 +#define pktq_full(q) ((q)->len >= (q)->maxlen)
1806 +#define _pktq_pri(q, pri) ((q)->prio_map[pri])
1807 +#define pktq_tailpri(q) ((q)->tail ? _pktq_pri(q, PKTPRIO((q)->tail)) : _pktq_pri(q, 0))
1808 +
1809 +/* externs */
1810 +/* packet */
1811 +extern uint pktcopy(void *drv, void *p, uint offset, int len, uchar *buf);
1812 +extern uint pkttotlen(void *drv, void *);
1813 +extern void pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[]);
1814 +extern void pktenq(struct pktq *q, void *p, bool lifo);
1815 +extern void *pktdeq(struct pktq *q);
1816 +extern void *pktdeqtail(struct pktq *q);
1817 +/* string */
1818 +extern uint bcm_atoi(char *s);
1819 +extern uchar bcm_toupper(uchar c);
1820 +extern ulong bcm_strtoul(char *cp, char **endp, uint base);
1821 +extern char *bcmstrstr(char *haystack, char *needle);
1822 +extern char *bcmstrcat(char *dest, const char *src);
1823 +extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen);
1824 +/* ethernet address */
1825 +extern char *bcm_ether_ntoa(char *ea, char *buf);
1826 +extern int bcm_ether_atoe(char *p, char *ea);
1827 +/* delay */
1828 +extern void bcm_mdelay(uint ms);
1829 +/* variable access */
1830 +extern char *getvar(char *vars, char *name);
1831 +extern int getintvar(char *vars, char *name);
1832 +extern uint getgpiopin(char *vars, char *pin_name, uint def_pin);
1833 +#define bcmlog(fmt, a1, a2)
1834 +#define bcmdumplog(buf, size) *buf = '\0'
1835 +#define bcmdumplogent(buf, idx) -1
1836 +#endif /* #ifdef BCMDRIVER */
1837 +
1838 +/*** driver/apps-shared section ***/
1839 +#ifndef MIN
1840 +#define MIN(a, b) (((a)<(b))?(a):(b))
1841 +#endif
1842 +
1843 +#ifndef MAX
1844 +#define MAX(a, b) (((a)>(b))?(a):(b))
1845 +#endif
1846 +
1847 +#define CEIL(x, y) (((x) + ((y)-1)) / (y))
1848 +#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
1849 +#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0)
1850 +#define ISPOWEROF2(x) ((((x)-1)&(x))==0)
1851 +#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member)
1852 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
1853 +
1854 +/* bit map related macros */
1855 +#ifndef setbit
1856 +#define NBBY 8 /* 8 bits per byte */
1857 +#define setbit(a,i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
1858 +#define clrbit(a,i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1859 +#define isset(a,i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY)))
1860 +#define isclr(a,i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1861 +#endif
1862 +
1863 +#define NBITS(type) (sizeof (type) * 8)
1864 +
1865 +/* crc defines */
1866 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
1867 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
1868 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
1869 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
1870 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
1871 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
1872 +
1873 +/* bcm_format_flags() bit description structure */
1874 +typedef struct bcm_bit_desc {
1875 + uint32 bit;
1876 + char* name;
1877 +} bcm_bit_desc_t;
1878 +
1879 +/* tag_ID/length/value_buffer tuple */
1880 +typedef struct bcm_tlv {
1881 + uint8 id;
1882 + uint8 len;
1883 + uint8 data[1];
1884 +} bcm_tlv_t;
1885 +
1886 +/* Check that bcm_tlv_t fits into the given buflen */
1887 +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (buflen) >= 2 + (elt)->len)
1888 +
1889 +/* buffer length for ethernet address from bcm_ether_ntoa() */
1890 +#define ETHER_ADDR_STR_LEN 18
1891 +
1892 +/* unaligned load and store macros */
1893 +#ifdef IL_BIGENDIAN
1894 +static INLINE uint32
1895 +load32_ua(uint8 *a)
1896 +{
1897 + return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
1898 +}
1899 +
1900 +static INLINE void
1901 +store32_ua(uint8 *a, uint32 v)
1902 +{
1903 + a[0] = (v >> 24) & 0xff;
1904 + a[1] = (v >> 16) & 0xff;
1905 + a[2] = (v >> 8) & 0xff;
1906 + a[3] = v & 0xff;
1907 +}
1908 +
1909 +static INLINE uint16
1910 +load16_ua(uint8 *a)
1911 +{
1912 + return ((a[0] << 8) | a[1]);
1913 +}
1914 +
1915 +static INLINE void
1916 +store16_ua(uint8 *a, uint16 v)
1917 +{
1918 + a[0] = (v >> 8) & 0xff;
1919 + a[1] = v & 0xff;
1920 +}
1921 +
1922 +#else
1923 +
1924 +static INLINE uint32
1925 +load32_ua(uint8 *a)
1926 +{
1927 + return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
1928 +}
1929 +
1930 +static INLINE void
1931 +store32_ua(uint8 *a, uint32 v)
1932 +{
1933 + a[3] = (v >> 24) & 0xff;
1934 + a[2] = (v >> 16) & 0xff;
1935 + a[1] = (v >> 8) & 0xff;
1936 + a[0] = v & 0xff;
1937 +}
1938 +
1939 +static INLINE uint16
1940 +load16_ua(uint8 *a)
1941 +{
1942 + return ((a[1] << 8) | a[0]);
1943 +}
1944 +
1945 +static INLINE void
1946 +store16_ua(uint8 *a, uint16 v)
1947 +{
1948 + a[1] = (v >> 8) & 0xff;
1949 + a[0] = v & 0xff;
1950 +}
1951 +
1952 +#endif
1953 +
1954 +/* externs */
1955 +/* crc */
1956 +extern uint8 hndcrc8(uint8 *p, uint nbytes, uint8 crc);
1957 +extern uint16 hndcrc16(uint8 *p, uint nbytes, uint16 crc);
1958 +extern uint32 hndcrc32(uint8 *p, uint nbytes, uint32 crc);
1959 +/* format/print */
1960 +/* IE parsing */
1961 +extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
1962 +extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
1963 +extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
1964 +
1965 +/* multi-bool data type: set of bools, mbool is true if any is set */
1966 +typedef uint32 mbool;
1967 +#define mboolset(mb, bit) (mb |= bit) /* set one bool */
1968 +#define mboolclr(mb, bit) (mb &= ~bit) /* clear one bool */
1969 +#define mboolisset(mb, bit) ((mb & bit) != 0) /* TRUE if one bool is set */
1970 +#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val)))
1971 +
1972 +#endif /* _bcmutils_h_ */
1973 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/bitfuncs.h linux-2.4.30.dev/arch/mips/bcm947xx/include/bitfuncs.h
1974 --- linux-2.4.30/arch/mips/bcm947xx/include/bitfuncs.h 1970-01-01 01:00:00.000000000 +0100
1975 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/bitfuncs.h 2005-08-22 01:34:46.314152832 +0200
1976 @@ -0,0 +1,85 @@
1977 +/*
1978 + * bit manipulation utility functions
1979 + *
1980 + * Copyright 2005, Broadcom Corporation
1981 + * All Rights Reserved.
1982 + *
1983 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1984 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1985 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1986 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1987 + * $Id$
1988 + */
1989 +
1990 +#ifndef _BITFUNCS_H
1991 +#define _BITFUNCS_H
1992 +
1993 +#include <typedefs.h>
1994 +
1995 +/* local prototypes */
1996 +static INLINE uint32 find_msbit(uint32 x);
1997 +
1998 +
1999 +/*
2000 + * find_msbit: returns index of most significant set bit in x, with index
2001 + * range defined as 0-31. NOTE: returns zero if input is zero.
2002 + */
2003 +
2004 +#if defined(USE_PENTIUM_BSR) && defined(__GNUC__)
2005 +
2006 +/*
2007 + * Implementation for Pentium processors and gcc. Note that this
2008 + * instruction is actually very slow on some processors (e.g., family 5,
2009 + * model 2, stepping 12, "Pentium 75 - 200"), so we use the generic
2010 + * implementation instead.
2011 + */
2012 +static INLINE uint32 find_msbit(uint32 x)
2013 +{
2014 + uint msbit;
2015 + __asm__("bsrl %1,%0"
2016 + :"=r" (msbit)
2017 + :"r" (x));
2018 + return msbit;
2019 +}
2020 +
2021 +#else
2022 +
2023 +/*
2024 + * Generic Implementation
2025 + */
2026 +
2027 +#define DB_POW_MASK16 0xffff0000
2028 +#define DB_POW_MASK8 0x0000ff00
2029 +#define DB_POW_MASK4 0x000000f0
2030 +#define DB_POW_MASK2 0x0000000c
2031 +#define DB_POW_MASK1 0x00000002
2032 +
2033 +static INLINE uint32 find_msbit(uint32 x)
2034 +{
2035 + uint32 temp_x = x;
2036 + uint msbit = 0;
2037 + if (temp_x & DB_POW_MASK16) {
2038 + temp_x >>= 16;
2039 + msbit = 16;
2040 + }
2041 + if (temp_x & DB_POW_MASK8) {
2042 + temp_x >>= 8;
2043 + msbit += 8;
2044 + }
2045 + if (temp_x & DB_POW_MASK4) {
2046 + temp_x >>= 4;
2047 + msbit += 4;
2048 + }
2049 + if (temp_x & DB_POW_MASK2) {
2050 + temp_x >>= 2;
2051 + msbit += 2;
2052 + }
2053 + if (temp_x & DB_POW_MASK1) {
2054 + msbit += 1;
2055 + }
2056 + return(msbit);
2057 +}
2058 +
2059 +#endif
2060 +
2061 +#endif /* _BITFUNCS_H */
2062 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/cfe_osl.h linux-2.4.30.dev/arch/mips/bcm947xx/include/cfe_osl.h
2063 --- linux-2.4.30/arch/mips/bcm947xx/include/cfe_osl.h 1970-01-01 01:00:00.000000000 +0100
2064 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/cfe_osl.h 2005-08-22 01:34:46.315152680 +0200
2065 @@ -0,0 +1,184 @@
2066 +/*
2067 + * CFE boot loader OS Abstraction Layer.
2068 + *
2069 + * Copyright 2005, Broadcom Corporation
2070 + * All Rights Reserved.
2071 + *
2072 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
2073 + * the contents of this file may not be disclosed to third parties, copied
2074 + * or duplicated in any form, in whole or in part, without the prior
2075 + * written permission of Broadcom Corporation.
2076 + *
2077 + * $Id$
2078 + */
2079 +
2080 +#ifndef _cfe_osl_h_
2081 +#define _cfe_osl_h_
2082 +
2083 +#include <lib_types.h>
2084 +#include <lib_string.h>
2085 +#include <lib_printf.h>
2086 +#include <lib_malloc.h>
2087 +#include <cpu_config.h>
2088 +#include <cfe_timer.h>
2089 +#include <cfe_iocb.h>
2090 +#include <cfe_devfuncs.h>
2091 +#include <addrspace.h>
2092 +
2093 +#include <typedefs.h>
2094 +
2095 +/* dump string */
2096 +extern int (*xprinthook)(const char *str);
2097 +#define puts(str) do { if (xprinthook) xprinthook(str); } while (0)
2098 +
2099 +/* assert and panic */
2100 +#define ASSERT(exp) do {} while (0)
2101 +
2102 +/* PCMCIA attribute space access macros */
2103 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
2104 + bzero(buf, size)
2105 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
2106 + do {} while (0)
2107 +
2108 +/* PCI configuration space access macros */
2109 +#define OSL_PCI_READ_CONFIG(loc, offset, size) \
2110 + (offset == 8 ? 0 : 0xffffffff)
2111 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) \
2112 + do {} while (0)
2113 +
2114 +/* register access macros */
2115 +#define wreg32(r, v) (*(volatile uint32*)(r) = (uint32)(v))
2116 +#define rreg32(r) (*(volatile uint32*)(r))
2117 +#ifdef IL_BIGENDIAN
2118 +#define wreg16(r, v) (*(volatile uint16*)((ulong)(r)^2) = (uint16)(v))
2119 +#define rreg16(r) (*(volatile uint16*)((ulong)(r)^2))
2120 +#define wreg8(r, v) (*(volatile uint8*)((ulong)(r)^3) = (uint8)(v))
2121 +#define rreg8(r) (*(volatile uint8*)((ulong)(r)^3))
2122 +#else
2123 +#define wreg16(r, v) (*(volatile uint16*)(r) = (uint16)(v))
2124 +#define rreg16(r) (*(volatile uint16*)(r))
2125 +#define wreg8(r, v) (*(volatile uint8*)(r) = (uint8)(v))
2126 +#define rreg8(r) (*(volatile uint8*)(r))
2127 +#endif
2128 +#define R_REG(r) ({ \
2129 + __typeof(*(r)) __osl_v; \
2130 + switch (sizeof(*(r))) { \
2131 + case sizeof(uint8): __osl_v = rreg8((r)); break; \
2132 + case sizeof(uint16): __osl_v = rreg16((r)); break; \
2133 + case sizeof(uint32): __osl_v = rreg32((r)); break; \
2134 + } \
2135 + __osl_v; \
2136 +})
2137 +#define W_REG(r, v) do { \
2138 + switch (sizeof(*(r))) { \
2139 + case sizeof(uint8): wreg8((r), (v)); break; \
2140 + case sizeof(uint16): wreg16((r), (v)); break; \
2141 + case sizeof(uint32): wreg32((r), (v)); break; \
2142 + } \
2143 +} while (0)
2144 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
2145 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
2146 +
2147 +/* bcopy, bcmp, and bzero */
2148 +#define bcmp(b1, b2, len) lib_memcmp((b1), (b2), (len))
2149 +
2150 +#define osl_attach(pdev) (pdev)
2151 +#define osl_detach(osh)
2152 +
2153 +/* general purpose memory allocation */
2154 +#define MALLOC(osh, size) KMALLOC((size),0)
2155 +#define MFREE(osh, addr, size) KFREE((addr))
2156 +#define MALLOCED(osh) (0)
2157 +#define MALLOC_DUMP(osh, buf, sz)
2158 +#define MALLOC_FAILED(osh) (0)
2159 +
2160 +/* uncached virtual address */
2161 +#define OSL_UNCACHED(va) ((void*)UNCADDR((ulong)(va)))
2162 +
2163 +/* host/bus architecture-specific address byte swap */
2164 +#define BUS_SWAP32(v) (v)
2165 +
2166 +/* get processor cycle count */
2167 +#define OSL_GETCYCLES(x) ((x) = 0)
2168 +
2169 +/* microsecond delay */
2170 +#define OSL_DELAY(usec) cfe_usleep((cfe_cpu_speed/CPUCFG_CYCLESPERCPUTICK/1000000*(usec)))
2171 +
2172 +/* map/unmap physical to virtual I/O */
2173 +#define REG_MAP(pa, size) ((void*)UNCADDR((ulong)(pa)))
2174 +#define REG_UNMAP(va) do {} while (0)
2175 +
2176 +/* dereference an address that may cause a bus exception */
2177 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (uint32)(addr))
2178 +extern int osl_busprobe(uint32 *val, uint32 addr);
2179 +
2180 +/* allocate/free shared (dma-able) consistent (uncached) memory */
2181 +#define DMA_CONSISTENT_ALIGN 4096
2182 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
2183 + osl_dma_alloc_consistent((size), (pap))
2184 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
2185 + osl_dma_free_consistent((void*)(va))
2186 +extern void *osl_dma_alloc_consistent(uint size, ulong *pap);
2187 +extern void osl_dma_free_consistent(void *va);
2188 +
2189 +/* map/unmap direction */
2190 +#define DMA_TX 1
2191 +#define DMA_RX 2
2192 +
2193 +/* map/unmap shared (dma-able) memory */
2194 +#define DMA_MAP(osh, va, size, direction, lb) ({ \
2195 + cfe_flushcache(CFE_CACHE_FLUSH_D); \
2196 + PHYSADDR((ulong)(va)); \
2197 +})
2198 +#define DMA_UNMAP(osh, pa, size, direction, p) \
2199 + do {} while (0)
2200 +
2201 +/* shared (dma-able) memory access macros */
2202 +#define R_SM(r) *(r)
2203 +#define W_SM(r, v) (*(r) = (v))
2204 +#define BZERO_SM(r, len) lib_memset((r), '\0', (len))
2205 +
2206 +/* generic packet structure */
2207 +#define LBUFSZ 4096
2208 +#define LBDATASZ (LBUFSZ - sizeof(struct lbuf))
2209 +struct lbuf {
2210 + struct lbuf *next; /* pointer to next lbuf if in a chain */
2211 + struct lbuf *link; /* pointer to next lbuf if in a list */
2212 + uchar *head; /* start of buffer */
2213 + uchar *end; /* end of buffer */
2214 + uchar *data; /* start of data */
2215 + uchar *tail; /* end of data */
2216 + uint len; /* nbytes of data */
2217 + void *cookie; /* generic cookie */
2218 +};
2219 +
2220 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
2221 +#define PKTBUFSZ 2048
2222 +
2223 +/* packet primitives */
2224 +#define PKTGET(drv, len, send) ((void*)osl_pktget((len)))
2225 +#define PKTFREE(drv, lb, send) osl_pktfree((struct lbuf*)(lb))
2226 +#define PKTDATA(drv, lb) (((struct lbuf*)(lb))->data)
2227 +#define PKTLEN(drv, lb) (((struct lbuf*)(lb))->len)
2228 +#define PKTHEADROOM(drv, lb) (PKTDATA(drv,lb)-(((struct lbuf*)(lb))->head))
2229 +#define PKTTAILROOM(drv, lb) ((((struct lbuf*)(lb))->end)-(((struct lbuf*)(lb))->tail))
2230 +#define PKTNEXT(drv, lb) (((struct lbuf*)(lb))->next)
2231 +#define PKTSETNEXT(lb, x) (((struct lbuf*)(lb))->next = (struct lbuf*)(x))
2232 +#define PKTSETLEN(drv, lb, len) osl_pktsetlen((struct lbuf*)(lb), (len))
2233 +#define PKTPUSH(drv, lb, bytes) osl_pktpush((struct lbuf*)(lb), (bytes))
2234 +#define PKTPULL(drv, lb, bytes) osl_pktpull((struct lbuf*)(lb), (bytes))
2235 +#define PKTDUP(drv, lb) osl_pktdup((struct lbuf*)(lb))
2236 +#define PKTCOOKIE(lb) (((struct lbuf*)(lb))->cookie)
2237 +#define PKTSETCOOKIE(lb, x) (((struct lbuf*)(lb))->cookie = (void*)(x))
2238 +#define PKTLINK(lb) (((struct lbuf*)(lb))->link)
2239 +#define PKTSETLINK(lb, x) (((struct lbuf*)(lb))->link = (struct lbuf*)(x))
2240 +#define PKTPRIO(lb) (0)
2241 +#define PKTSETPRIO(lb, x) do {} while (0)
2242 +extern struct lbuf *osl_pktget(uint len);
2243 +extern void osl_pktfree(struct lbuf *lb);
2244 +extern void osl_pktsetlen(struct lbuf *lb, uint len);
2245 +extern uchar *osl_pktpush(struct lbuf *lb, uint bytes);
2246 +extern uchar *osl_pktpull(struct lbuf *lb, uint bytes);
2247 +extern struct lbuf *osl_pktdup(struct lbuf *lb);
2248 +
2249 +#endif /* _cfe_osl_h_ */
2250 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/epivers.h linux-2.4.30.dev/arch/mips/bcm947xx/include/epivers.h
2251 --- linux-2.4.30/arch/mips/bcm947xx/include/epivers.h 1970-01-01 01:00:00.000000000 +0100
2252 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/epivers.h 2005-08-22 01:34:46.315152680 +0200
2253 @@ -0,0 +1,69 @@
2254 +/*
2255 + * Copyright 2005, Broadcom Corporation
2256 + * All Rights Reserved.
2257 + *
2258 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2259 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2260 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2261 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2262 + *
2263 + * $Id$
2264 + *
2265 +*/
2266 +
2267 +#ifndef _epivers_h_
2268 +#define _epivers_h_
2269 +
2270 +#ifdef linux
2271 +#include <linux/config.h>
2272 +#endif
2273 +
2274 +/* Vendor Name, ASCII, 32 chars max */
2275 +#ifdef COMPANYNAME
2276 +#define HPNA_VENDOR COMPANYNAME
2277 +#else
2278 +#define HPNA_VENDOR "Broadcom Corporation"
2279 +#endif
2280 +
2281 +/* Driver Date, ASCII, 32 chars max */
2282 +#define HPNA_DRV_BUILD_DATE __DATE__
2283 +
2284 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2285 +#define HPNA_HW_MFG_DATE "Not Specified"
2286 +
2287 +/* See documentation for Device Type values, 32 values max */
2288 +#ifndef HPNA_DEV_TYPE
2289 +
2290 +#if defined(CONFIG_BRCM_VJ)
2291 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2292 +
2293 +#elif defined(CONFIG_BCRM_93725)
2294 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2295 +
2296 +#else
2297 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2298 +
2299 +#endif
2300 +
2301 +#endif /* !HPNA_DEV_TYPE */
2302 +
2303 +
2304 +#define EPI_MAJOR_VERSION 3
2305 +
2306 +#define EPI_MINOR_VERSION 90
2307 +
2308 +#define EPI_RC_NUMBER 23
2309 +
2310 +#define EPI_INCREMENTAL_NUMBER 0
2311 +
2312 +#define EPI_BUILD_NUMBER 0
2313 +
2314 +#define EPI_VERSION 3,90,23,0
2315 +
2316 +#define EPI_VERSION_NUM 0x035a1700
2317 +
2318 +/* Driver Version String, ASCII, 32 chars max */
2319 +#define EPI_VERSION_STR "3.90.23.0"
2320 +#define EPI_ROUTER_VERSION_STR "3.91.23.0"
2321 +
2322 +#endif /* _epivers_h_ */
2323 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/epivers.h.in linux-2.4.30.dev/arch/mips/bcm947xx/include/epivers.h.in
2324 --- linux-2.4.30/arch/mips/bcm947xx/include/epivers.h.in 1970-01-01 01:00:00.000000000 +0100
2325 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/epivers.h.in 2005-08-22 01:34:46.316152528 +0200
2326 @@ -0,0 +1,69 @@
2327 +/*
2328 + * Copyright 2005, Broadcom Corporation
2329 + * All Rights Reserved.
2330 + *
2331 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2332 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2333 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2334 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2335 + *
2336 + * $Id$
2337 + *
2338 +*/
2339 +
2340 +#ifndef _epivers_h_
2341 +#define _epivers_h_
2342 +
2343 +#ifdef linux
2344 +#include <linux/config.h>
2345 +#endif
2346 +
2347 +/* Vendor Name, ASCII, 32 chars max */
2348 +#ifdef COMPANYNAME
2349 +#define HPNA_VENDOR COMPANYNAME
2350 +#else
2351 +#define HPNA_VENDOR "Broadcom Corporation"
2352 +#endif
2353 +
2354 +/* Driver Date, ASCII, 32 chars max */
2355 +#define HPNA_DRV_BUILD_DATE __DATE__
2356 +
2357 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2358 +#define HPNA_HW_MFG_DATE "Not Specified"
2359 +
2360 +/* See documentation for Device Type values, 32 values max */
2361 +#ifndef HPNA_DEV_TYPE
2362 +
2363 +#if defined(CONFIG_BRCM_VJ)
2364 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2365 +
2366 +#elif defined(CONFIG_BCRM_93725)
2367 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2368 +
2369 +#else
2370 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2371 +
2372 +#endif
2373 +
2374 +#endif /* !HPNA_DEV_TYPE */
2375 +
2376 +
2377 +#define EPI_MAJOR_VERSION @EPI_MAJOR_VERSION@
2378 +
2379 +#define EPI_MINOR_VERSION @EPI_MINOR_VERSION@
2380 +
2381 +#define EPI_RC_NUMBER @EPI_RC_NUMBER@
2382 +
2383 +#define EPI_INCREMENTAL_NUMBER @EPI_INCREMENTAL_NUMBER@
2384 +
2385 +#define EPI_BUILD_NUMBER @EPI_BUILD_NUMBER@
2386 +
2387 +#define EPI_VERSION @EPI_VERSION@
2388 +
2389 +#define EPI_VERSION_NUM @EPI_VERSION_NUM@
2390 +
2391 +/* Driver Version String, ASCII, 32 chars max */
2392 +#define EPI_VERSION_STR "@EPI_VERSION_STR@"
2393 +#define EPI_ROUTER_VERSION_STR "@EPI_ROUTER_VERSION_STR@"
2394 +
2395 +#endif /* _epivers_h_ */
2396 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/etsockio.h linux-2.4.30.dev/arch/mips/bcm947xx/include/etsockio.h
2397 --- linux-2.4.30/arch/mips/bcm947xx/include/etsockio.h 1970-01-01 01:00:00.000000000 +0100
2398 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/etsockio.h 2005-08-22 01:34:46.316152528 +0200
2399 @@ -0,0 +1,59 @@
2400 +/*
2401 + * Driver-specific socket ioctls
2402 + * used by BSD, Linux, and PSOS
2403 + * Broadcom BCM44XX 10/100Mbps Ethernet Device Driver
2404 + *
2405 + * Copyright 2005, Broadcom Corporation
2406 + * All Rights Reserved.
2407 + *
2408 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2409 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2410 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2411 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2412 + *
2413 + * $Id$
2414 + */
2415 +
2416 +#ifndef _etsockio_h_
2417 +#define _etsockio_h_
2418 +
2419 +/* THESE MUST BE CONTIGUOUS AND CONSISTENT WITH VALUES IN ETC.H */
2420 +
2421 +
2422 +#if defined(linux)
2423 +#define SIOCSETCUP (SIOCDEVPRIVATE + 0)
2424 +#define SIOCSETCDOWN (SIOCDEVPRIVATE + 1)
2425 +#define SIOCSETCLOOP (SIOCDEVPRIVATE + 2)
2426 +#define SIOCGETCDUMP (SIOCDEVPRIVATE + 3)
2427 +#define SIOCSETCSETMSGLEVEL (SIOCDEVPRIVATE + 4)
2428 +#define SIOCSETCPROMISC (SIOCDEVPRIVATE + 5)
2429 +#define SIOCSETCTXDOWN (SIOCDEVPRIVATE + 6) /* obsolete */
2430 +#define SIOCSETCSPEED (SIOCDEVPRIVATE + 7)
2431 +#define SIOCTXGEN (SIOCDEVPRIVATE + 8)
2432 +#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
2433 +#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
2434 +#define SIOCSETCQOS (SIOCDEVPRIVATE + 11)
2435 +
2436 +#else /* !linux */
2437 +
2438 +#define SIOCSETCUP _IOWR('e', 130 + 0, struct ifreq)
2439 +#define SIOCSETCDOWN _IOWR('e', 130 + 1, struct ifreq)
2440 +#define SIOCSETCLOOP _IOWR('e', 130 + 2, struct ifreq)
2441 +#define SIOCGETCDUMP _IOWR('e', 130 + 3, struct ifreq)
2442 +#define SIOCSETCSETMSGLEVEL _IOWR('e', 130 + 4, struct ifreq)
2443 +#define SIOCSETCPROMISC _IOWR('e', 130 + 5, struct ifreq)
2444 +#define SIOCSETCTXDOWN _IOWR('e', 130 + 6, struct ifreq) /* obsolete */
2445 +#define SIOCSETCSPEED _IOWR('e', 130 + 7, struct ifreq)
2446 +#define SIOCTXGEN _IOWR('e', 130 + 8, struct ifreq)
2447 +
2448 +#endif
2449 +
2450 +/* arg to SIOCTXGEN */
2451 +struct txg {
2452 + uint32 num; /* number of frames to send */
2453 + uint32 delay; /* delay in microseconds between sending each */
2454 + uint32 size; /* size of ether frame to send */
2455 + uchar buf[1514]; /* starting ether frame data */
2456 +};
2457 +
2458 +#endif
2459 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/flash.h linux-2.4.30.dev/arch/mips/bcm947xx/include/flash.h
2460 --- linux-2.4.30/arch/mips/bcm947xx/include/flash.h 1970-01-01 01:00:00.000000000 +0100
2461 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/flash.h 2005-08-22 01:34:46.317152376 +0200
2462 @@ -0,0 +1,188 @@
2463 +/*
2464 + * flash.h: Common definitions for flash access.
2465 + *
2466 + * Copyright 2005, Broadcom Corporation
2467 + * All Rights Reserved.
2468 + *
2469 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2470 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2471 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2472 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2473 + *
2474 + * $Id$
2475 + */
2476 +
2477 +/* Types of flashes we know about */
2478 +typedef enum _flash_type {OLD, BSC, SCS, AMD, SST, SFLASH} flash_type_t;
2479 +
2480 +/* Commands to write/erase the flases */
2481 +typedef struct _flash_cmds{
2482 + flash_type_t type;
2483 + bool need_unlock;
2484 + uint16 pre_erase;
2485 + uint16 erase_block;
2486 + uint16 erase_chip;
2487 + uint16 write_word;
2488 + uint16 write_buf;
2489 + uint16 clear_csr;
2490 + uint16 read_csr;
2491 + uint16 read_id;
2492 + uint16 confirm;
2493 + uint16 read_array;
2494 +} flash_cmds_t;
2495 +
2496 +#define UNLOCK_CMD_WORDS 2
2497 +
2498 +typedef struct _unlock_cmd {
2499 + uint addr[UNLOCK_CMD_WORDS];
2500 + uint16 cmd[UNLOCK_CMD_WORDS];
2501 +} unlock_cmd_t;
2502 +
2503 +/* Flash descriptors */
2504 +typedef struct _flash_desc {
2505 + uint16 mfgid; /* Manufacturer Id */
2506 + uint16 devid; /* Device Id */
2507 + uint size; /* Total size in bytes */
2508 + uint width; /* Device width in bytes */
2509 + flash_type_t type; /* Device type old, S, J */
2510 + uint bsize; /* Block size */
2511 + uint nb; /* Number of blocks */
2512 + uint ff; /* First full block */
2513 + uint lf; /* Last full block */
2514 + uint nsub; /* Number of subblocks */
2515 + uint *subblocks; /* Offsets for subblocks */
2516 + char *desc; /* Description */
2517 +} flash_desc_t;
2518 +
2519 +
2520 +#ifdef DECLARE_FLASHES
2521 +flash_cmds_t sflash_cmd_t =
2522 + { SFLASH, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2523 +
2524 +flash_cmds_t flash_cmds[] = {
2525 +/* type needu preera eraseb erasech write wbuf clcsr rdcsr rdid confrm read */
2526 + { BSC, 0, 0x00, 0x20, 0x00, 0x40, 0x00, 0x50, 0x70, 0x90, 0xd0, 0xff },
2527 + { SCS, 0, 0x00, 0x20, 0x00, 0x40, 0xe8, 0x50, 0x70, 0x90, 0xd0, 0xff },
2528 + { AMD, 1, 0x80, 0x30, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
2529 + { SST, 1, 0x80, 0x50, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
2530 + { 0 }
2531 +};
2532 +
2533 +unlock_cmd_t unlock_cmd_amd = {
2534 +#ifdef MIPSEB
2535 +/* addr: */ { 0x0aa8, 0x0556},
2536 +#else
2537 +/* addr: */ { 0x0aaa, 0x0554},
2538 +#endif
2539 +/* data: */ { 0xaa, 0x55}
2540 +};
2541 +
2542 +unlock_cmd_t unlock_cmd_sst = {
2543 +#ifdef MIPSEB
2544 +/* addr: */ { 0xaaa8, 0x5556},
2545 +#else
2546 +/* addr: */ { 0xaaaa, 0x5554},
2547 +#endif
2548 +/* data: */ { 0xaa, 0x55}
2549 +};
2550 +
2551 +#define AMD_CMD 0xaaa
2552 +#define SST_CMD 0xaaaa
2553 +
2554 +/* intel unlock block cmds */
2555 +#define INTEL_UNLOCK1 0x60
2556 +#define INTEL_UNLOCK2 0xD0
2557 +
2558 +/* Just eight blocks of 8KB byte each */
2559 +
2560 +uint blk8x8k[] = { 0x00000000,
2561 + 0x00002000,
2562 + 0x00004000,
2563 + 0x00006000,
2564 + 0x00008000,
2565 + 0x0000a000,
2566 + 0x0000c000,
2567 + 0x0000e000,
2568 + 0x00010000
2569 +};
2570 +
2571 +/* Funky AMD arrangement for 29xx800's */
2572 +uint amd800[] = { 0x00000000, /* 16KB */
2573 + 0x00004000, /* 32KB */
2574 + 0x0000c000, /* 8KB */
2575 + 0x0000e000, /* 8KB */
2576 + 0x00010000, /* 8KB */
2577 + 0x00012000, /* 8KB */
2578 + 0x00014000, /* 32KB */
2579 + 0x0001c000, /* 16KB */
2580 + 0x00020000
2581 +};
2582 +
2583 +/* AMD arrangement for 29xx160's */
2584 +uint amd4112[] = { 0x00000000, /* 32KB */
2585 + 0x00008000, /* 8KB */
2586 + 0x0000a000, /* 8KB */
2587 + 0x0000c000, /* 16KB */
2588 + 0x00010000
2589 +};
2590 +uint amd2114[] = { 0x00000000, /* 16KB */
2591 + 0x00004000, /* 8KB */
2592 + 0x00006000, /* 8KB */
2593 + 0x00008000, /* 32KB */
2594 + 0x00010000
2595 +};
2596 +
2597 +
2598 +flash_desc_t sflash_desc =
2599 + { 0, 0, 0, 0, SFLASH, 0, 0, 0, 0, 0, NULL, "SFLASH" };
2600 +
2601 +flash_desc_t flashes[] = {
2602 + { 0x00b0, 0x00d0, 0x0200000, 2, SCS, 0x10000, 32, 0, 31, 0, NULL, "Intel 28F160S3/5 1Mx16" },
2603 + { 0x00b0, 0x00d4, 0x0400000, 2, SCS, 0x10000, 64, 0, 63, 0, NULL, "Intel 28F320S3/5 2Mx16" },
2604 + { 0x0089, 0x8890, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160B3 1Mx16 TopB" },
2605 + { 0x0089, 0x8891, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160B3 1Mx16 BotB" },
2606 + { 0x0089, 0x8896, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320B3 2Mx16 TopB" },
2607 + { 0x0089, 0x8897, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320B3 2Mx16 BotB" },
2608 + { 0x0089, 0x8898, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640B3 4Mx16 TopB" },
2609 + { 0x0089, 0x8899, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640B3 4Mx16 BotB" },
2610 + { 0x0089, 0x88C2, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160C3 1Mx16 TopB" },
2611 + { 0x0089, 0x88C3, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160C3 1Mx16 BotB" },
2612 + { 0x0089, 0x88C4, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320C3 2Mx16 TopB" },
2613 + { 0x0089, 0x88C5, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320C3 2Mx16 BotB" },
2614 + { 0x0089, 0x88CC, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640C3 4Mx16 TopB" },
2615 + { 0x0089, 0x88CD, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640C3 4Mx16 BotB" },
2616 + { 0x0089, 0x0014, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J5 2Mx16" },
2617 + { 0x0089, 0x0015, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J5 4Mx16" },
2618 + { 0x0089, 0x0016, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J3 2Mx16" },
2619 + { 0x0089, 0x0017, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J3 4Mx16" },
2620 + { 0x0089, 0x0018, 0x1000000, 2, SCS, 0x20000, 128, 0, 127, 0, NULL, "Intel 28F128J3 8Mx16" },
2621 + { 0x00b0, 0x00e3, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Sharp 28F320BJE 2Mx16 BotB" },
2622 + { 0x0001, 0x224a, 0x0100000, 2, AMD, 0x10000, 16, 0, 13, 8, amd800, "AMD 29DL800BT 512Kx16 TopB" },
2623 + { 0x0001, 0x22cb, 0x0100000, 2, AMD, 0x10000, 16, 2, 15, 8, amd800, "AMD 29DL800BB 512Kx16 BotB" },
2624 + { 0x0001, 0x22c4, 0x0200000, 2, AMD, 0x10000, 32, 0, 30, 4, amd2114, "AMD 29lv160DT 1Mx16 TopB" },
2625 + { 0x0001, 0x2249, 0x0200000, 2, AMD, 0x10000, 32, 1, 31, 4, amd4112, "AMD 29lv160DB 1Mx16 BotB" },
2626 + { 0x0001, 0x22f6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320DT 2Mx16 TopB" },
2627 + { 0x0001, 0x22f9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320DB 2Mx16 BotB" },
2628 + { 0x0001, 0x2201, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320MT 2Mx16 TopB" },
2629 + { 0x0001, 0x2200, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320MB 2Mx16 BotB" },
2630 + { 0x0020, 0x22CA, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "ST 29w320DT 2Mx16 TopB" },
2631 + { 0x0020, 0x22CB, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "ST 29w320DB 2Mx16 BotB" },
2632 + { 0x00C2, 0x00A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
2633 + { 0x00C2, 0x00A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
2634 + { 0x0004, 0x22F6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MBM29LV320TE 2Mx16 TopB" },
2635 + { 0x0004, 0x22F9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MBM29LV320BE 2Mx16 BotB" },
2636 + { 0x0098, 0x009A, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "TC58FVT321 2Mx16 TopB" },
2637 + { 0x0098, 0x009C, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "TC58FVB321 2Mx16 BotB" },
2638 + { 0x00C2, 0x22A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
2639 + { 0x00C2, 0x22A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
2640 + { 0x00BF, 0x2783, 0x0400000, 2, SST, 0x10000, 64, 0, 63, 0, NULL, "SST39VF320 2Mx16" },
2641 + { 0, 0, 0, 0, OLD, 0, 0, 0, 0, 0, NULL, NULL },
2642 +};
2643 +
2644 +#else
2645 +
2646 +extern flash_cmds_t flash_cmds[];
2647 +extern unlock_cmd_t unlock_cmd;
2648 +extern flash_desc_t flashes[];
2649 +
2650 +#endif
2651 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/flashutl.h linux-2.4.30.dev/arch/mips/bcm947xx/include/flashutl.h
2652 --- linux-2.4.30/arch/mips/bcm947xx/include/flashutl.h 1970-01-01 01:00:00.000000000 +0100
2653 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/flashutl.h 2005-08-22 01:34:46.317152376 +0200
2654 @@ -0,0 +1,27 @@
2655 +/*
2656 + * BCM47XX FLASH driver interface
2657 + *
2658 + * Copyright 2005, Broadcom Corporation
2659 + * All Rights Reserved.
2660 + *
2661 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2662 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2663 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2664 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2665 + * $Id$
2666 + */
2667 +
2668 +#ifndef _flashutl_h_
2669 +#define _flashutl_h_
2670 +
2671 +
2672 +#ifndef _LANGUAGE_ASSEMBLY
2673 +
2674 +int sysFlashInit(char *flash_str);
2675 +int sysFlashRead(uint off, uchar *dst, uint bytes);
2676 +int sysFlashWrite(uint off, uchar *src, uint bytes);
2677 +void nvWrite(unsigned short *data, unsigned int len);
2678 +
2679 +#endif /* _LANGUAGE_ASSEMBLY */
2680 +
2681 +#endif /* _flashutl_h_ */
2682 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/hnddma.h linux-2.4.30.dev/arch/mips/bcm947xx/include/hnddma.h
2683 --- linux-2.4.30/arch/mips/bcm947xx/include/hnddma.h 1970-01-01 01:00:00.000000000 +0100
2684 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/hnddma.h 2005-08-22 01:34:46.318152224 +0200
2685 @@ -0,0 +1,184 @@
2686 +/*
2687 + * Generic Broadcom Home Networking Division (HND) DMA engine definitions.
2688 + * This supports the following chips: BCM42xx, 44xx, 47xx .
2689 + *
2690 + * Copyright 2005, Broadcom Corporation
2691 + * All Rights Reserved.
2692 + *
2693 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2694 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2695 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2696 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2697 + * $Id$
2698 + */
2699 +
2700 +#ifndef _hnddma_h_
2701 +#define _hnddma_h_
2702 +
2703 +/*
2704 + * Each DMA processor consists of a transmit channel and a receive channel.
2705 + */
2706 +typedef volatile struct {
2707 + /* transmit channel */
2708 + uint32 xmtcontrol; /* enable, et al */
2709 + uint32 xmtaddr; /* descriptor ring base address (4K aligned) */
2710 + uint32 xmtptr; /* last descriptor posted to chip */
2711 + uint32 xmtstatus; /* current active descriptor, et al */
2712 +
2713 + /* receive channel */
2714 + uint32 rcvcontrol; /* enable, et al */
2715 + uint32 rcvaddr; /* descriptor ring base address (4K aligned) */
2716 + uint32 rcvptr; /* last descriptor posted to chip */
2717 + uint32 rcvstatus; /* current active descriptor, et al */
2718 +} dmaregs_t;
2719 +
2720 +typedef volatile struct {
2721 + /* diag access */
2722 + uint32 fifoaddr; /* diag address */
2723 + uint32 fifodatalow; /* low 32bits of data */
2724 + uint32 fifodatahigh; /* high 32bits of data */
2725 + uint32 pad; /* reserved */
2726 +} dmafifo_t;
2727 +
2728 +/* transmit channel control */
2729 +#define XC_XE ((uint32)1 << 0) /* transmit enable */
2730 +#define XC_SE ((uint32)1 << 1) /* transmit suspend request */
2731 +#define XC_LE ((uint32)1 << 2) /* loopback enable */
2732 +#define XC_FL ((uint32)1 << 4) /* flush request */
2733 +
2734 +/* transmit descriptor table pointer */
2735 +#define XP_LD_MASK 0xfff /* last valid descriptor */
2736 +
2737 +/* transmit channel status */
2738 +#define XS_CD_MASK 0x0fff /* current descriptor pointer */
2739 +#define XS_XS_MASK 0xf000 /* transmit state */
2740 +#define XS_XS_SHIFT 12
2741 +#define XS_XS_DISABLED 0x0000 /* disabled */
2742 +#define XS_XS_ACTIVE 0x1000 /* active */
2743 +#define XS_XS_IDLE 0x2000 /* idle wait */
2744 +#define XS_XS_STOPPED 0x3000 /* stopped */
2745 +#define XS_XS_SUSP 0x4000 /* suspend pending */
2746 +#define XS_XE_MASK 0xf0000 /* transmit errors */
2747 +#define XS_XE_SHIFT 16
2748 +#define XS_XE_NOERR 0x00000 /* no error */
2749 +#define XS_XE_DPE 0x10000 /* descriptor protocol error */
2750 +#define XS_XE_DFU 0x20000 /* data fifo underrun */
2751 +#define XS_XE_BEBR 0x30000 /* bus error on buffer read */
2752 +#define XS_XE_BEDA 0x40000 /* bus error on descriptor access */
2753 +#define XS_AD_MASK 0xfff00000 /* active descriptor */
2754 +#define XS_AD_SHIFT 20
2755 +
2756 +/* receive channel control */
2757 +#define RC_RE ((uint32)1 << 0) /* receive enable */
2758 +#define RC_RO_MASK 0xfe /* receive frame offset */
2759 +#define RC_RO_SHIFT 1
2760 +#define RC_FM ((uint32)1 << 8) /* direct fifo receive (pio) mode */
2761 +
2762 +/* receive descriptor table pointer */
2763 +#define RP_LD_MASK 0xfff /* last valid descriptor */
2764 +
2765 +/* receive channel status */
2766 +#define RS_CD_MASK 0x0fff /* current descriptor pointer */
2767 +#define RS_RS_MASK 0xf000 /* receive state */
2768 +#define RS_RS_SHIFT 12
2769 +#define RS_RS_DISABLED 0x0000 /* disabled */
2770 +#define RS_RS_ACTIVE 0x1000 /* active */
2771 +#define RS_RS_IDLE 0x2000 /* idle wait */
2772 +#define RS_RS_STOPPED 0x3000 /* reserved */
2773 +#define RS_RE_MASK 0xf0000 /* receive errors */
2774 +#define RS_RE_SHIFT 16
2775 +#define RS_RE_NOERR 0x00000 /* no error */
2776 +#define RS_RE_DPE 0x10000 /* descriptor protocol error */
2777 +#define RS_RE_DFO 0x20000 /* data fifo overflow */
2778 +#define RS_RE_BEBW 0x30000 /* bus error on buffer write */
2779 +#define RS_RE_BEDA 0x40000 /* bus error on descriptor access */
2780 +#define RS_AD_MASK 0xfff00000 /* active descriptor */
2781 +#define RS_AD_SHIFT 20
2782 +
2783 +/* fifoaddr */
2784 +#define FA_OFF_MASK 0xffff /* offset */
2785 +#define FA_SEL_MASK 0xf0000 /* select */
2786 +#define FA_SEL_SHIFT 16
2787 +#define FA_SEL_XDD 0x00000 /* transmit dma data */
2788 +#define FA_SEL_XDP 0x10000 /* transmit dma pointers */
2789 +#define FA_SEL_RDD 0x40000 /* receive dma data */
2790 +#define FA_SEL_RDP 0x50000 /* receive dma pointers */
2791 +#define FA_SEL_XFD 0x80000 /* transmit fifo data */
2792 +#define FA_SEL_XFP 0x90000 /* transmit fifo pointers */
2793 +#define FA_SEL_RFD 0xc0000 /* receive fifo data */
2794 +#define FA_SEL_RFP 0xd0000 /* receive fifo pointers */
2795 +
2796 +/*
2797 + * DMA Descriptor
2798 + * Descriptors are only read by the hardware, never written back.
2799 + */
2800 +typedef volatile struct {
2801 + uint32 ctrl; /* misc control bits & bufcount */
2802 + uint32 addr; /* data buffer address */
2803 +} dmadd_t;
2804 +
2805 +/*
2806 + * Each descriptor ring must be 4096byte aligned
2807 + * and fit within a single 4096byte page.
2808 + */
2809 +#define DMAMAXRINGSZ 4096
2810 +#define DMARINGALIGN 4096
2811 +
2812 +/* control flags */
2813 +#define CTRL_BC_MASK 0x1fff /* buffer byte count */
2814 +#define CTRL_EOT ((uint32)1 << 28) /* end of descriptor table */
2815 +#define CTRL_IOC ((uint32)1 << 29) /* interrupt on completion */
2816 +#define CTRL_EOF ((uint32)1 << 30) /* end of frame */
2817 +#define CTRL_SOF ((uint32)1 << 31) /* start of frame */
2818 +
2819 +/* control flags in the range [27:20] are core-specific and not defined here */
2820 +#define CTRL_CORE_MASK 0x0ff00000
2821 +
2822 +/* export structure */
2823 +typedef volatile struct {
2824 + /* rx error counters */
2825 + uint rxgiants; /* rx giant frames */
2826 + uint rxnobuf; /* rx out of dma descriptors */
2827 + /* tx error counters */
2828 + uint txnobuf; /* tx out of dma descriptors */
2829 +} hnddma_t;
2830 +
2831 +#ifndef di_t
2832 +#define di_t void
2833 +#endif
2834 +
2835 +/* externs */
2836 +extern void * dma_attach(void *drv, void *dev, char *name, dmaregs_t *dmaregs,
2837 + uint ntxd, uint nrxd, uint rxbufsize, uint nrxpost, uint rxoffset,
2838 + uint ddoffset, uint dataoffset, uint *msg_level);
2839 +extern void dma_detach(di_t *di);
2840 +extern void dma_txreset(di_t *di);
2841 +extern void dma_rxreset(di_t *di);
2842 +extern void dma_txinit(di_t *di);
2843 +extern bool dma_txenabled(di_t *di);
2844 +extern void dma_rxinit(di_t *di);
2845 +extern void dma_rxenable(di_t *di);
2846 +extern bool dma_rxenabled(di_t *di);
2847 +extern void dma_txsuspend(di_t *di);
2848 +extern void dma_txresume(di_t *di);
2849 +extern bool dma_txsuspended(di_t *di);
2850 +extern bool dma_txstopped(di_t *di);
2851 +extern bool dma_rxstopped(di_t *di);
2852 +extern int dma_txfast(di_t *di, void *p, uint32 coreflags);
2853 +extern int dma_tx(di_t *di, void *p, uint32 coreflags);
2854 +extern void dma_fifoloopbackenable(di_t *di);
2855 +extern void *dma_rx(di_t *di);
2856 +extern void dma_rxfill(di_t *di);
2857 +extern void dma_txreclaim(di_t *di, bool forceall);
2858 +extern void dma_rxreclaim(di_t *di);
2859 +extern uintptr dma_getvar(di_t *di, char *name);
2860 +extern void *dma_getnexttxp(di_t *di, bool forceall);
2861 +extern void *dma_peeknexttxp(di_t *di);
2862 +extern void *dma_getnextrxp(di_t *di, bool forceall);
2863 +extern void dma_txblock(di_t *di);
2864 +extern void dma_txunblock(di_t *di);
2865 +extern uint dma_txactive(di_t *di);
2866 +extern void dma_txrotate(di_t *di);
2867 +
2868 +
2869 +#endif /* _hnddma_h_ */
2870 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/hndmips.h linux-2.4.30.dev/arch/mips/bcm947xx/include/hndmips.h
2871 --- linux-2.4.30/arch/mips/bcm947xx/include/hndmips.h 1970-01-01 01:00:00.000000000 +0100
2872 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/hndmips.h 2005-08-22 01:34:46.318152224 +0200
2873 @@ -0,0 +1,16 @@
2874 +/*
2875 + * Alternate include file for HND sbmips.h since CFE also ships with
2876 + * a sbmips.h.
2877 + *
2878 + * Copyright 2005, Broadcom Corporation
2879 + * All Rights Reserved.
2880 + *
2881 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2882 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2883 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2884 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2885 + *
2886 + * $Id$
2887 + */
2888 +
2889 +#include "sbmips.h"
2890 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/linux_osl.h linux-2.4.30.dev/arch/mips/bcm947xx/include/linux_osl.h
2891 --- linux-2.4.30/arch/mips/bcm947xx/include/linux_osl.h 1970-01-01 01:00:00.000000000 +0100
2892 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/linux_osl.h 2005-08-22 01:34:46.319152072 +0200
2893 @@ -0,0 +1,341 @@
2894 +/*
2895 + * Linux OS Independent Layer
2896 + *
2897 + * Copyright 2005, Broadcom Corporation
2898 + * All Rights Reserved.
2899 + *
2900 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2901 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2902 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2903 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2904 + *
2905 + * $Id$
2906 + */
2907 +
2908 +#ifndef _linux_osl_h_
2909 +#define _linux_osl_h_
2910 +
2911 +#include <typedefs.h>
2912 +
2913 +/* use current 2.4.x calling conventions */
2914 +#include <linuxver.h>
2915 +
2916 +/* assert and panic */
2917 +#define ASSERT(exp) do {} while (0)
2918 +
2919 +/* PCMCIA attribute space access macros */
2920 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
2921 +struct pcmcia_dev {
2922 + dev_link_t link; /* PCMCIA device pointer */
2923 + dev_node_t node; /* PCMCIA node structure */
2924 + void *base; /* Mapped attribute memory window */
2925 + size_t size; /* Size of window */
2926 + void *drv; /* Driver data */
2927 +};
2928 +#endif
2929 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
2930 + osl_pcmcia_read_attr((osh), (offset), (buf), (size))
2931 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
2932 + osl_pcmcia_write_attr((osh), (offset), (buf), (size))
2933 +extern void osl_pcmcia_read_attr(void *osh, uint offset, void *buf, int size);
2934 +extern void osl_pcmcia_write_attr(void *osh, uint offset, void *buf, int size);
2935 +
2936 +/* PCI configuration space access macros */
2937 +#define OSL_PCI_READ_CONFIG(osh, offset, size) \
2938 + osl_pci_read_config((osh), (offset), (size))
2939 +#define OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
2940 + osl_pci_write_config((osh), (offset), (size), (val))
2941 +extern uint32 osl_pci_read_config(void *osh, uint size, uint offset);
2942 +extern void osl_pci_write_config(void *osh, uint offset, uint size, uint val);
2943 +
2944 +/* OSL initialization */
2945 +extern void *osl_attach(void *pdev);
2946 +extern void osl_detach(void *osh);
2947 +
2948 +/* host/bus architecture-specific byte swap */
2949 +#define BUS_SWAP32(v) (v)
2950 +
2951 +/* general purpose memory allocation */
2952 +
2953 +#if defined(BCMDBG_MEM)
2954 +
2955 +#define MALLOC(osh, size) osl_debug_malloc((osh), (size), __LINE__, __FILE__)
2956 +#define MFREE(osh, addr, size) osl_debug_mfree((osh), (addr), (size), __LINE__, __FILE__)
2957 +#define MALLOCED(osh) osl_malloced((osh))
2958 +#define MALLOC_DUMP(osh, buf, sz) osl_debug_memdump((osh), (buf), (sz))
2959 +extern void *osl_debug_malloc(void *osh, uint size, int line, char* file);
2960 +extern void osl_debug_mfree(void *osh, void *addr, uint size, int line, char* file);
2961 +extern char *osl_debug_memdump(void *osh, char *buf, uint sz);
2962 +
2963 +#else
2964 +
2965 +#define MALLOC(osh, size) osl_malloc((osh), (size))
2966 +#define MFREE(osh, addr, size) osl_mfree((osh), (addr), (size))
2967 +#define MALLOCED(osh) osl_malloced((osh))
2968 +
2969 +#endif /* BCMDBG_MEM */
2970 +
2971 +#define MALLOC_FAILED(osh) osl_malloc_failed((osh))
2972 +
2973 +extern void *osl_malloc(void *osh, uint size);
2974 +extern void osl_mfree(void *osh, void *addr, uint size);
2975 +extern uint osl_malloced(void *osh);
2976 +extern uint osl_malloc_failed(void *osh);
2977 +
2978 +/* allocate/free shared (dma-able) consistent memory */
2979 +#define DMA_CONSISTENT_ALIGN PAGE_SIZE
2980 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
2981 + osl_dma_alloc_consistent((osh), (size), (pap))
2982 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
2983 + osl_dma_free_consistent((osh), (void*)(va), (size), (pa))
2984 +extern void *osl_dma_alloc_consistent(void *osh, uint size, ulong *pap);
2985 +extern void osl_dma_free_consistent(void *osh, void *va, uint size, ulong pa);
2986 +
2987 +/* map/unmap direction */
2988 +#define DMA_TX 1
2989 +#define DMA_RX 2
2990 +
2991 +/* map/unmap shared (dma-able) memory */
2992 +#define DMA_MAP(osh, va, size, direction, p) \
2993 + osl_dma_map((osh), (va), (size), (direction))
2994 +#define DMA_UNMAP(osh, pa, size, direction, p) \
2995 + osl_dma_unmap((osh), (pa), (size), (direction))
2996 +extern uint osl_dma_map(void *osh, void *va, uint size, int direction);
2997 +extern void osl_dma_unmap(void *osh, uint pa, uint size, int direction);
2998 +
2999 +/* register access macros */
3000 +#if defined(BCMJTAG)
3001 +struct bcmjtag_info;
3002 +extern uint32 bcmjtag_read(struct bcmjtag_info *ejh, uint32 addr, uint size);
3003 +extern void bcmjtag_write(struct bcmjtag_info *ejh, uint32 addr, uint32 val, uint size);
3004 +#define R_REG(r) bcmjtag_read(NULL, (uint32)(r), sizeof (*(r)))
3005 +#define W_REG(r, v) bcmjtag_write(NULL, (uint32)(r), (uint32)(v), sizeof (*(r)))
3006 +#endif
3007 +
3008 +/*
3009 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
3010 + * Macros expand to calls to functions defined in linux_osl.c .
3011 + */
3012 +#ifndef BINOSL
3013 +
3014 +/* string library, kernel mode */
3015 +#define printf(fmt, args...) printk(fmt, ## args)
3016 +#include <linux/kernel.h>
3017 +#include <linux/string.h>
3018 +
3019 +/* register access macros */
3020 +#if !defined(BCMJTAG)
3021 +#define R_REG(r) ( \
3022 + sizeof(*(r)) == sizeof(uint8) ? readb((volatile uint8*)(r)) : \
3023 + sizeof(*(r)) == sizeof(uint16) ? readw((volatile uint16*)(r)) : \
3024 + readl((volatile uint32*)(r)) \
3025 +)
3026 +#define W_REG(r, v) do { \
3027 + switch (sizeof(*(r))) { \
3028 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)(r)); break; \
3029 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)(r)); break; \
3030 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
3031 + } \
3032 +} while (0)
3033 +#endif
3034 +
3035 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3036 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3037 +
3038 +/* bcopy, bcmp, and bzero */
3039 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
3040 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
3041 +#define bzero(b, len) memset((b), '\0', (len))
3042 +
3043 +/* uncached virtual address */
3044 +#ifdef mips
3045 +#define OSL_UNCACHED(va) KSEG1ADDR((va))
3046 +#include <asm/addrspace.h>
3047 +#else
3048 +#define OSL_UNCACHED(va) (va)
3049 +#endif
3050 +
3051 +/* get processor cycle count */
3052 +#if defined(mips)
3053 +#define OSL_GETCYCLES(x) ((x) = read_c0_count() * 2)
3054 +#elif defined(__i386__)
3055 +#define OSL_GETCYCLES(x) rdtscl((x))
3056 +#else
3057 +#define OSL_GETCYCLES(x) ((x) = 0)
3058 +#endif
3059 +
3060 +/* dereference an address that may cause a bus exception */
3061 +#ifdef mips
3062 +#if defined(MODULE) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17))
3063 +#define BUSPROBE(val, addr) panic("get_dbe() will not fixup a bus exception when compiled into a module")
3064 +#else
3065 +#define BUSPROBE(val, addr) get_dbe((val), (addr))
3066 +#include <asm/paccess.h>
3067 +#endif
3068 +#else
3069 +#define BUSPROBE(val, addr) ({ (val) = R_REG((addr)); 0; })
3070 +#endif
3071 +
3072 +/* map/unmap physical to virtual I/O */
3073 +#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), (unsigned long)(size))
3074 +#define REG_UNMAP(va) iounmap((void *)(va))
3075 +
3076 +/* microsecond delay */
3077 +#define OSL_DELAY(usec) udelay(usec)
3078 +#include <linux/delay.h>
3079 +
3080 +/* shared (dma-able) memory access macros */
3081 +#define R_SM(r) *(r)
3082 +#define W_SM(r, v) (*(r) = (v))
3083 +#define BZERO_SM(r, len) memset((r), '\0', (len))
3084 +
3085 +/* packet primitives */
3086 +#define PKTGET(drv, len, send) osl_pktget((drv), (len), (send))
3087 +#define PKTFREE(drv, skb, send) osl_pktfree((skb))
3088 +#define PKTDATA(drv, skb) (((struct sk_buff*)(skb))->data)
3089 +#define PKTLEN(drv, skb) (((struct sk_buff*)(skb))->len)
3090 +#define PKTHEADROOM(drv, skb) (PKTDATA(drv,skb)-(((struct sk_buff*)(skb))->head))
3091 +#define PKTTAILROOM(drv, skb) ((((struct sk_buff*)(skb))->end)-(((struct sk_buff*)(skb))->tail))
3092 +#define PKTNEXT(drv, skb) (((struct sk_buff*)(skb))->next)
3093 +#define PKTSETNEXT(skb, x) (((struct sk_buff*)(skb))->next = (struct sk_buff*)(x))
3094 +#define PKTSETLEN(drv, skb, len) __skb_trim((struct sk_buff*)(skb), (len))
3095 +#define PKTPUSH(drv, skb, bytes) skb_push((struct sk_buff*)(skb), (bytes))
3096 +#define PKTPULL(drv, skb, bytes) skb_pull((struct sk_buff*)(skb), (bytes))
3097 +#define PKTDUP(drv, skb) skb_clone((struct sk_buff*)(skb), GFP_ATOMIC)
3098 +#define PKTCOOKIE(skb) ((void*)((struct sk_buff*)(skb))->csum)
3099 +#define PKTSETCOOKIE(skb, x) (((struct sk_buff*)(skb))->csum = (uint)(x))
3100 +#define PKTLINK(skb) (((struct sk_buff*)(skb))->prev)
3101 +#define PKTSETLINK(skb, x) (((struct sk_buff*)(skb))->prev = (struct sk_buff*)(x))
3102 +#define PKTPRIO(skb) (((struct sk_buff*)(skb))->priority)
3103 +#define PKTSETPRIO(skb, x) (((struct sk_buff*)(skb))->priority = (x))
3104 +extern void *osl_pktget(void *drv, uint len, bool send);
3105 +extern void osl_pktfree(void *skb);
3106 +
3107 +#else /* BINOSL */
3108 +
3109 +/* string library */
3110 +#ifndef LINUX_OSL
3111 +#undef printf
3112 +#define printf(fmt, args...) osl_printf((fmt), ## args)
3113 +#undef sprintf
3114 +#define sprintf(buf, fmt, args...) osl_sprintf((buf), (fmt), ## args)
3115 +#undef strcmp
3116 +#define strcmp(s1, s2) osl_strcmp((s1), (s2))
3117 +#undef strncmp
3118 +#define strncmp(s1, s2, n) osl_strncmp((s1), (s2), (n))
3119 +#undef strlen
3120 +#define strlen(s) osl_strlen((s))
3121 +#undef strcpy
3122 +#define strcpy(d, s) osl_strcpy((d), (s))
3123 +#undef strncpy
3124 +#define strncpy(d, s, n) osl_strncpy((d), (s), (n))
3125 +#endif
3126 +extern int osl_printf(const char *format, ...);
3127 +extern int osl_sprintf(char *buf, const char *format, ...);
3128 +extern int osl_strcmp(const char *s1, const char *s2);
3129 +extern int osl_strncmp(const char *s1, const char *s2, uint n);
3130 +extern int osl_strlen(char *s);
3131 +extern char* osl_strcpy(char *d, const char *s);
3132 +extern char* osl_strncpy(char *d, const char *s, uint n);
3133 +
3134 +/* register access macros */
3135 +#if !defined(BCMJTAG)
3136 +#define R_REG(r) ( \
3137 + sizeof(*(r)) == sizeof(uint8) ? osl_readb((volatile uint8*)(r)) : \
3138 + sizeof(*(r)) == sizeof(uint16) ? osl_readw((volatile uint16*)(r)) : \
3139 + osl_readl((volatile uint32*)(r)) \
3140 +)
3141 +#define W_REG(r, v) do { \
3142 + switch (sizeof(*(r))) { \
3143 + case sizeof(uint8): osl_writeb((uint8)(v), (volatile uint8*)(r)); break; \
3144 + case sizeof(uint16): osl_writew((uint16)(v), (volatile uint16*)(r)); break; \
3145 + case sizeof(uint32): osl_writel((uint32)(v), (volatile uint32*)(r)); break; \
3146 + } \
3147 +} while (0)
3148 +#endif
3149 +
3150 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3151 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3152 +extern uint8 osl_readb(volatile uint8 *r);
3153 +extern uint16 osl_readw(volatile uint16 *r);
3154 +extern uint32 osl_readl(volatile uint32 *r);
3155 +extern void osl_writeb(uint8 v, volatile uint8 *r);
3156 +extern void osl_writew(uint16 v, volatile uint16 *r);
3157 +extern void osl_writel(uint32 v, volatile uint32 *r);
3158 +
3159 +/* bcopy, bcmp, and bzero */
3160 +extern void bcopy(const void *src, void *dst, int len);
3161 +extern int bcmp(const void *b1, const void *b2, int len);
3162 +extern void bzero(void *b, int len);
3163 +
3164 +/* uncached virtual address */
3165 +#define OSL_UNCACHED(va) osl_uncached((va))
3166 +extern void *osl_uncached(void *va);
3167 +
3168 +/* get processor cycle count */
3169 +#define OSL_GETCYCLES(x) ((x) = osl_getcycles())
3170 +extern uint osl_getcycles(void);
3171 +
3172 +/* dereference an address that may target abort */
3173 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (addr))
3174 +extern int osl_busprobe(uint32 *val, uint32 addr);
3175 +
3176 +/* map/unmap physical to virtual */
3177 +#define REG_MAP(pa, size) osl_reg_map((pa), (size))
3178 +#define REG_UNMAP(va) osl_reg_unmap((va))
3179 +extern void *osl_reg_map(uint32 pa, uint size);
3180 +extern void osl_reg_unmap(void *va);
3181 +
3182 +/* microsecond delay */
3183 +#define OSL_DELAY(usec) osl_delay((usec))
3184 +extern void osl_delay(uint usec);
3185 +
3186 +/* shared (dma-able) memory access macros */
3187 +#define R_SM(r) *(r)
3188 +#define W_SM(r, v) (*(r) = (v))
3189 +#define BZERO_SM(r, len) bzero((r), (len))
3190 +
3191 +/* packet primitives */
3192 +#define PKTGET(drv, len, send) osl_pktget((drv), (len), (send))
3193 +#define PKTFREE(drv, skb, send) osl_pktfree((skb))
3194 +#define PKTDATA(drv, skb) osl_pktdata((drv), (skb))
3195 +#define PKTLEN(drv, skb) osl_pktlen((drv), (skb))
3196 +#define PKTHEADROOM(drv, skb) osl_pktheadroom((drv), (skb))
3197 +#define PKTTAILROOM(drv, skb) osl_pkttailroom((drv), (skb))
3198 +#define PKTNEXT(drv, skb) osl_pktnext((drv), (skb))
3199 +#define PKTSETNEXT(skb, x) osl_pktsetnext((skb), (x))
3200 +#define PKTSETLEN(drv, skb, len) osl_pktsetlen((drv), (skb), (len))
3201 +#define PKTPUSH(drv, skb, bytes) osl_pktpush((drv), (skb), (bytes))
3202 +#define PKTPULL(drv, skb, bytes) osl_pktpull((drv), (skb), (bytes))
3203 +#define PKTDUP(drv, skb) osl_pktdup((drv), (skb))
3204 +#define PKTCOOKIE(skb) osl_pktcookie((skb))
3205 +#define PKTSETCOOKIE(skb, x) osl_pktsetcookie((skb), (x))
3206 +#define PKTLINK(skb) osl_pktlink((skb))
3207 +#define PKTSETLINK(skb, x) osl_pktsetlink((skb), (x))
3208 +#define PKTPRIO(skb) osl_pktprio((skb))
3209 +#define PKTSETPRIO(skb, x) osl_pktsetprio((skb), (x))
3210 +extern void *osl_pktget(void *drv, uint len, bool send);
3211 +extern void osl_pktfree(void *skb);
3212 +extern uchar *osl_pktdata(void *drv, void *skb);
3213 +extern uint osl_pktlen(void *drv, void *skb);
3214 +extern uint osl_pktheadroom(void *drv, void *skb);
3215 +extern uint osl_pkttailroom(void *drv, void *skb);
3216 +extern void *osl_pktnext(void *drv, void *skb);
3217 +extern void osl_pktsetnext(void *skb, void *x);
3218 +extern void osl_pktsetlen(void *drv, void *skb, uint len);
3219 +extern uchar *osl_pktpush(void *drv, void *skb, int bytes);
3220 +extern uchar *osl_pktpull(void *drv, void *skb, int bytes);
3221 +extern void *osl_pktdup(void *drv, void *skb);
3222 +extern void *osl_pktcookie(void *skb);
3223 +extern void osl_pktsetcookie(void *skb, void *x);
3224 +extern void *osl_pktlink(void *skb);
3225 +extern void osl_pktsetlink(void *skb, void *x);
3226 +extern uint osl_pktprio(void *skb);
3227 +extern void osl_pktsetprio(void *skb, uint x);
3228 +
3229 +#endif /* BINOSL */
3230 +
3231 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
3232 +#define PKTBUFSZ 2048
3233 +
3234 +#endif /* _linux_osl_h_ */
3235 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/linuxver.h linux-2.4.30.dev/arch/mips/bcm947xx/include/linuxver.h
3236 --- linux-2.4.30/arch/mips/bcm947xx/include/linuxver.h 1970-01-01 01:00:00.000000000 +0100
3237 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/linuxver.h 2005-08-22 01:34:46.320151920 +0200
3238 @@ -0,0 +1,399 @@
3239 +/*
3240 + * Linux-specific abstractions to gain some independence from linux kernel versions.
3241 + * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
3242 + *
3243 + * Copyright 2005, Broadcom Corporation
3244 + * All Rights Reserved.
3245 + *
3246 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3247 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3248 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3249 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3250 + *
3251 + * $Id$
3252 + */
3253 +
3254 +#ifndef _linuxver_h_
3255 +#define _linuxver_h_
3256 +
3257 +#include <linux/config.h>
3258 +#include <linux/version.h>
3259 +
3260 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
3261 +/* __NO_VERSION__ must be defined for all linkables except one in 2.2 */
3262 +#ifdef __UNDEF_NO_VERSION__
3263 +#undef __NO_VERSION__
3264 +#else
3265 +#define __NO_VERSION__
3266 +#endif
3267 +#endif
3268 +
3269 +#if defined(MODULE) && defined(MODVERSIONS)
3270 +#include <linux/modversions.h>
3271 +#endif
3272 +
3273 +/* linux/malloc.h is deprecated, use linux/slab.h instead. */
3274 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9))
3275 +#include <linux/malloc.h>
3276 +#else
3277 +#include <linux/slab.h>
3278 +#endif
3279 +
3280 +#include <linux/types.h>
3281 +#include <linux/init.h>
3282 +#include <linux/mm.h>
3283 +#include <linux/string.h>
3284 +#include <linux/pci.h>
3285 +#include <linux/interrupt.h>
3286 +#include <linux/netdevice.h>
3287 +#include <asm/io.h>
3288 +
3289 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41))
3290 +#include <linux/workqueue.h>
3291 +#else
3292 +#include <linux/tqueue.h>
3293 +#ifndef work_struct
3294 +#define work_struct tq_struct
3295 +#endif
3296 +#ifndef INIT_WORK
3297 +#define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
3298 +#endif
3299 +#ifndef schedule_work
3300 +#define schedule_work(_work) schedule_task((_work))
3301 +#endif
3302 +#ifndef flush_scheduled_work
3303 +#define flush_scheduled_work() flush_scheduled_tasks()
3304 +#endif
3305 +#endif
3306 +
3307 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
3308 +/* Some distributions have their own 2.6.x compatibility layers */
3309 +#ifndef IRQ_NONE
3310 +typedef void irqreturn_t;
3311 +#define IRQ_NONE
3312 +#define IRQ_HANDLED
3313 +#define IRQ_RETVAL(x)
3314 +#endif
3315 +#endif
3316 +
3317 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
3318 +
3319 +#include <pcmcia/version.h>
3320 +#include <pcmcia/cs_types.h>
3321 +#include <pcmcia/cs.h>
3322 +#include <pcmcia/cistpl.h>
3323 +#include <pcmcia/cisreg.h>
3324 +#include <pcmcia/ds.h>
3325 +
3326 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,69))
3327 +/* In 2.5 (as of 2.5.69 at least) there is a cs_error exported which
3328 + * does this, but it's not in 2.4 so we do our own for now. */
3329 +static inline void
3330 +cs_error(client_handle_t handle, int func, int ret)
3331 +{
3332 + error_info_t err = { func, ret };
3333 + CardServices(ReportError, handle, &err);
3334 +}
3335 +#endif
3336 +
3337 +#endif /* CONFIG_PCMCIA */
3338 +
3339 +#ifndef __exit
3340 +#define __exit
3341 +#endif
3342 +#ifndef __devexit
3343 +#define __devexit
3344 +#endif
3345 +#ifndef __devinit
3346 +#define __devinit __init
3347 +#endif
3348 +#ifndef __devinitdata
3349 +#define __devinitdata
3350 +#endif
3351 +#ifndef __devexit_p
3352 +#define __devexit_p(x) x
3353 +#endif
3354 +
3355 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
3356 +
3357 +#define pci_get_drvdata(dev) (dev)->sysdata
3358 +#define pci_set_drvdata(dev, value) (dev)->sysdata=(value)
3359 +
3360 +/*
3361 + * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
3362 + */
3363 +
3364 +struct pci_device_id {
3365 + unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
3366 + unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
3367 + unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
3368 + unsigned long driver_data; /* Data private to the driver */
3369 +};
3370 +
3371 +struct pci_driver {
3372 + struct list_head node;
3373 + char *name;
3374 + const struct pci_device_id *id_table; /* NULL if wants all devices */
3375 + int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
3376 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
3377 + void (*suspend)(struct pci_dev *dev); /* Device suspended */
3378 + void (*resume)(struct pci_dev *dev); /* Device woken up */
3379 +};
3380 +
3381 +#define MODULE_DEVICE_TABLE(type, name)
3382 +#define PCI_ANY_ID (~0)
3383 +
3384 +/* compatpci.c */
3385 +#define pci_module_init pci_register_driver
3386 +extern int pci_register_driver(struct pci_driver *drv);
3387 +extern void pci_unregister_driver(struct pci_driver *drv);
3388 +
3389 +#endif /* PCI registration */
3390 +
3391 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
3392 +#ifdef MODULE
3393 +#define module_init(x) int init_module(void) { return x(); }
3394 +#define module_exit(x) void cleanup_module(void) { x(); }
3395 +#else
3396 +#define module_init(x) __initcall(x);
3397 +#define module_exit(x) __exitcall(x);
3398 +#endif
3399 +#endif
3400 +
3401 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,48))
3402 +#define list_for_each(pos, head) \
3403 + for (pos = (head)->next; pos != (head); pos = pos->next)
3404 +#endif
3405 +
3406 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,13))
3407 +#define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
3408 +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,44))
3409 +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
3410 +#endif
3411 +
3412 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,23))
3413 +#define pci_enable_device(dev) do { } while (0)
3414 +#endif
3415 +
3416 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,14))
3417 +#define net_device device
3418 +#endif
3419 +
3420 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,42))
3421 +
3422 +/*
3423 + * DMA mapping
3424 + *
3425 + * See linux/Documentation/DMA-mapping.txt
3426 + */
3427 +
3428 +#ifndef PCI_DMA_TODEVICE
3429 +#define PCI_DMA_TODEVICE 1
3430 +#define PCI_DMA_FROMDEVICE 2
3431 +#endif
3432 +
3433 +typedef u32 dma_addr_t;
3434 +
3435 +/* Pure 2^n version of get_order */
3436 +static inline int get_order(unsigned long size)
3437 +{
3438 + int order;
3439 +
3440 + size = (size-1) >> (PAGE_SHIFT-1);
3441 + order = -1;
3442 + do {
3443 + size >>= 1;
3444 + order++;
3445 + } while (size);
3446 + return order;
3447 +}
3448 +
3449 +static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
3450 + dma_addr_t *dma_handle)
3451 +{
3452 + void *ret;
3453 + int gfp = GFP_ATOMIC | GFP_DMA;
3454 +
3455 + ret = (void *)__get_free_pages(gfp, get_order(size));
3456 +
3457 + if (ret != NULL) {
3458 + memset(ret, 0, size);
3459 + *dma_handle = virt_to_bus(ret);
3460 + }
3461 + return ret;
3462 +}
3463 +static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
3464 + void *vaddr, dma_addr_t dma_handle)
3465 +{
3466 + free_pages((unsigned long)vaddr, get_order(size));
3467 +}
3468 +#ifdef ILSIM
3469 +extern uint pci_map_single(void *dev, void *va, uint size, int direction);
3470 +extern void pci_unmap_single(void *dev, uint pa, uint size, int direction);
3471 +#else
3472 +#define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
3473 +#define pci_unmap_single(cookie, address, size, dir)
3474 +#endif
3475 +
3476 +#endif /* DMA mapping */
3477 +
3478 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43))
3479 +
3480 +#define dev_kfree_skb_any(a) dev_kfree_skb(a)
3481 +#define netif_down(dev) do { (dev)->start = 0; } while(0)
3482 +
3483 +/* pcmcia-cs provides its own netdevice compatibility layer */
3484 +#ifndef _COMPAT_NETDEVICE_H
3485 +
3486 +/*
3487 + * SoftNet
3488 + *
3489 + * For pre-softnet kernels we need to tell the upper layer not to
3490 + * re-enter start_xmit() while we are in there. However softnet
3491 + * guarantees not to enter while we are in there so there is no need
3492 + * to do the netif_stop_queue() dance unless the transmit queue really
3493 + * gets stuck. This should also improve performance according to tests
3494 + * done by Aman Singla.
3495 + */
3496 +
3497 +#define dev_kfree_skb_irq(a) dev_kfree_skb(a)
3498 +#define netif_wake_queue(dev) do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while(0)
3499 +#define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy)
3500 +
3501 +static inline void netif_start_queue(struct net_device *dev)
3502 +{
3503 + dev->tbusy = 0;
3504 + dev->interrupt = 0;
3505 + dev->start = 1;
3506 +}
3507 +
3508 +#define netif_queue_stopped(dev) (dev)->tbusy
3509 +#define netif_running(dev) (dev)->start
3510 +
3511 +#endif /* _COMPAT_NETDEVICE_H */
3512 +
3513 +#define netif_device_attach(dev) netif_start_queue(dev)
3514 +#define netif_device_detach(dev) netif_stop_queue(dev)
3515 +
3516 +/* 2.4.x renamed bottom halves to tasklets */
3517 +#define tasklet_struct tq_struct
3518 +static inline void tasklet_schedule(struct tasklet_struct *tasklet)
3519 +{
3520 + queue_task(tasklet, &tq_immediate);
3521 + mark_bh(IMMEDIATE_BH);
3522 +}
3523 +
3524 +static inline void tasklet_init(struct tasklet_struct *tasklet,
3525 + void (*func)(unsigned long),
3526 + unsigned long data)
3527 +{
3528 + tasklet->next = NULL;
3529 + tasklet->sync = 0;
3530 + tasklet->routine = (void (*)(void *))func;
3531 + tasklet->data = (void *)data;
3532 +}
3533 +#define tasklet_kill(tasklet) {do{} while(0);}
3534 +
3535 +/* 2.4.x introduced del_timer_sync() */
3536 +#define del_timer_sync(timer) del_timer(timer)
3537 +
3538 +#else
3539 +
3540 +#define netif_down(dev)
3541 +
3542 +#endif /* SoftNet */
3543 +
3544 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3))
3545 +
3546 +/*
3547 + * Emit code to initialise a tq_struct's routine and data pointers
3548 + */
3549 +#define PREPARE_TQUEUE(_tq, _routine, _data) \
3550 + do { \
3551 + (_tq)->routine = _routine; \
3552 + (_tq)->data = _data; \
3553 + } while (0)
3554 +
3555 +/*
3556 + * Emit code to initialise all of a tq_struct
3557 + */
3558 +#define INIT_TQUEUE(_tq, _routine, _data) \
3559 + do { \
3560 + INIT_LIST_HEAD(&(_tq)->list); \
3561 + (_tq)->sync = 0; \
3562 + PREPARE_TQUEUE((_tq), (_routine), (_data)); \
3563 + } while (0)
3564 +
3565 +#endif
3566 +
3567 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6))
3568 +
3569 +/* Power management related routines */
3570 +
3571 +static inline int
3572 +pci_save_state(struct pci_dev *dev, u32 *buffer)
3573 +{
3574 + int i;
3575 + if (buffer) {
3576 + for (i = 0; i < 16; i++)
3577 + pci_read_config_dword(dev, i * 4,&buffer[i]);
3578 + }
3579 + return 0;
3580 +}
3581 +
3582 +static inline int
3583 +pci_restore_state(struct pci_dev *dev, u32 *buffer)
3584 +{
3585 + int i;
3586 +
3587 + if (buffer) {
3588 + for (i = 0; i < 16; i++)
3589 + pci_write_config_dword(dev,i * 4, buffer[i]);
3590 + }
3591 + /*
3592 + * otherwise, write the context information we know from bootup.
3593 + * This works around a problem where warm-booting from Windows
3594 + * combined with a D3(hot)->D0 transition causes PCI config
3595 + * header data to be forgotten.
3596 + */
3597 + else {
3598 + for (i = 0; i < 6; i ++)
3599 + pci_write_config_dword(dev,
3600 + PCI_BASE_ADDRESS_0 + (i * 4),
3601 + pci_resource_start(dev, i));
3602 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
3603 + }
3604 + return 0;
3605 +}
3606 +
3607 +#endif /* PCI power management */
3608 +
3609 +/* Old cp0 access macros deprecated in 2.4.19 */
3610 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19))
3611 +#define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
3612 +#endif
3613 +
3614 +/* Module refcount handled internally in 2.6.x */
3615 +#ifndef SET_MODULE_OWNER
3616 +#define SET_MODULE_OWNER(dev) do {} while (0)
3617 +#define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
3618 +#define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
3619 +#else
3620 +#define OLD_MOD_INC_USE_COUNT do {} while (0)
3621 +#define OLD_MOD_DEC_USE_COUNT do {} while (0)
3622 +#endif
3623 +
3624 +#ifndef SET_NETDEV_DEV
3625 +#define SET_NETDEV_DEV(net, pdev) do {} while (0)
3626 +#endif
3627 +
3628 +#ifndef HAVE_FREE_NETDEV
3629 +#define free_netdev(dev) kfree(dev)
3630 +#endif
3631 +
3632 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
3633 +/* struct packet_type redefined in 2.6.x */
3634 +#define af_packet_priv data
3635 +#endif
3636 +
3637 +#endif /* _linuxver_h_ */
3638 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/min_osl.h linux-2.4.30.dev/arch/mips/bcm947xx/include/min_osl.h
3639 --- linux-2.4.30/arch/mips/bcm947xx/include/min_osl.h 1970-01-01 01:00:00.000000000 +0100
3640 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/min_osl.h 2005-08-22 01:34:46.321151768 +0200
3641 @@ -0,0 +1,120 @@
3642 +/*
3643 + * HND Minimal OS Abstraction Layer.
3644 + *
3645 + * Copyright 2005, Broadcom Corporation
3646 + * All Rights Reserved.
3647 + *
3648 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3649 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3650 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3651 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3652 + *
3653 + * $Id$
3654 + */
3655 +
3656 +#ifndef _min_osl_h_
3657 +#define _min_osl_h_
3658 +
3659 +#include <typedefs.h>
3660 +#include <sbconfig.h>
3661 +
3662 +/* Cache support */
3663 +extern void caches_on(void);
3664 +extern void blast_dcache(void);
3665 +extern void blast_icache(void);
3666 +
3667 +/* uart output */
3668 +extern void putc(int c);
3669 +
3670 +/* lib functions */
3671 +extern int printf(const char *fmt, ...);
3672 +extern int sprintf(char *buf, const char *fmt, ...);
3673 +extern int strcmp(const char *s1, const char *s2);
3674 +extern int strncmp(const char *s1, const char *s2, uint n);
3675 +extern char *strcpy(char *dest, const char *src);
3676 +extern char *strncpy(char *dest, const char *src, uint n);
3677 +extern uint strlen(const char *s);
3678 +extern char *strchr(const char *str,int c);
3679 +extern char *strrchr(const char *str, int c);
3680 +extern char *strcat(char *d, const char *s);
3681 +extern void *memset(void *dest, int c, uint n);
3682 +extern void *memcpy(void *dest, const void *src, uint n);
3683 +extern int memcmp(const void *s1, const void *s2, uint n);
3684 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
3685 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
3686 +#define bzero(b, len) memset((b), '\0', (len))
3687 +
3688 +/* assert & debugging */
3689 +#define ASSERT(exp) do {} while (0)
3690 +
3691 +/* PCMCIA attribute space access macros */
3692 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
3693 + ASSERT(0)
3694 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
3695 + ASSERT(0)
3696 +
3697 +/* PCI configuration space access macros */
3698 +#define OSL_PCI_READ_CONFIG(loc, offset, size) \
3699 + (offset == 8 ? 0 : 0xffffffff)
3700 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) \
3701 + do {} while (0)
3702 +
3703 +/* register access macros */
3704 +#define wreg32(r, v) (*(volatile uint32*)(r) = (uint32)(v))
3705 +#define rreg32(r) (*(volatile uint32*)(r))
3706 +#define wreg16(r, v) (*(volatile uint16*)(r) = (uint16)(v))
3707 +#define rreg16(r) (*(volatile uint16*)(r))
3708 +#define wreg8(r, v) (*(volatile uint8*)(r) = (uint8)(v))
3709 +#define rreg8(r) (*(volatile uint8*)(r))
3710 +#define R_REG(r) ({ \
3711 + __typeof(*(r)) __osl_v; \
3712 + switch (sizeof(*(r))) { \
3713 + case sizeof(uint8): __osl_v = rreg8((r)); break; \
3714 + case sizeof(uint16): __osl_v = rreg16((r)); break; \
3715 + case sizeof(uint32): __osl_v = rreg32((r)); break; \
3716 + } \
3717 + __osl_v; \
3718 +})
3719 +#define W_REG(r, v) do { \
3720 + switch (sizeof(*(r))) { \
3721 + case sizeof(uint8): wreg8((r), (v)); break; \
3722 + case sizeof(uint16): wreg16((r), (v)); break; \
3723 + case sizeof(uint32): wreg32((r), (v)); break; \
3724 + } \
3725 +} while (0)
3726 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3727 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3728 +
3729 +/* general purpose memory allocation */
3730 +#define MALLOC(osh, size) malloc(size)
3731 +#define MFREE(osh, addr, size) free(addr)
3732 +#define MALLOCED(osh) 0
3733 +#define MALLOC_FAILED(osh) 0
3734 +#define MALLOC_DUMP(osh, buf, sz)
3735 +extern int free(void *ptr);
3736 +extern void *malloc(uint size);
3737 +
3738 +/* uncached virtual address */
3739 +#define OSL_UNCACHED(va) ((void*)KSEG1ADDR((ulong)(va)))
3740 +
3741 +/* host/bus architecture-specific address byte swap */
3742 +#define BUS_SWAP32(v) (v)
3743 +
3744 +/* microsecond delay */
3745 +#define OSL_DELAY(usec) udelay(usec)
3746 +extern void udelay(uint32 usec);
3747 +
3748 +/* map/unmap physical to virtual I/O */
3749 +#define REG_MAP(pa, size) ((void*)KSEG1ADDR((ulong)(pa)))
3750 +#define REG_UNMAP(va) do {} while (0)
3751 +
3752 +/* dereference an address that may cause a bus exception */
3753 +#define BUSPROBE(val, addr) (uint32 *)(addr) = (val)
3754 +
3755 +/* Misc stubs */
3756 +#define osl_attach(pdev) (pdev)
3757 +#define osl_detach(osh)
3758 +extern void *osl_init(void);
3759 +extern int getintvar(char *vars, char *name);
3760 +
3761 +#endif /* _min_osl_h_ */
3762 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/mipsinc.h linux-2.4.30.dev/arch/mips/bcm947xx/include/mipsinc.h
3763 --- linux-2.4.30/arch/mips/bcm947xx/include/mipsinc.h 1970-01-01 01:00:00.000000000 +0100
3764 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/mipsinc.h 2005-08-22 01:34:46.322151616 +0200
3765 @@ -0,0 +1,524 @@
3766 +/*
3767 + * HND Run Time Environment for standalone MIPS programs.
3768 + *
3769 + * Copyright 2005, Broadcom Corporation
3770 + * All Rights Reserved.
3771 + *
3772 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3773 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3774 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3775 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3776 + *
3777 + * $Id$
3778 + */
3779 +
3780 +#ifndef _MISPINC_H
3781 +#define _MISPINC_H
3782 +
3783 +
3784 +/* MIPS defines */
3785 +
3786 +#ifdef _LANGUAGE_ASSEMBLY
3787 +
3788 +/*
3789 + * Symbolic register names for 32 bit ABI
3790 + */
3791 +#define zero $0 /* wired zero */
3792 +#define AT $1 /* assembler temp - uppercase because of ".set at" */
3793 +#define v0 $2 /* return value */
3794 +#define v1 $3
3795 +#define a0 $4 /* argument registers */
3796 +#define a1 $5
3797 +#define a2 $6
3798 +#define a3 $7
3799 +#define t0 $8 /* caller saved */
3800 +#define t1 $9
3801 +#define t2 $10
3802 +#define t3 $11
3803 +#define t4 $12
3804 +#define t5 $13
3805 +#define t6 $14
3806 +#define t7 $15
3807 +#define s0 $16 /* callee saved */
3808 +#define s1 $17
3809 +#define s2 $18
3810 +#define s3 $19
3811 +#define s4 $20
3812 +#define s5 $21
3813 +#define s6 $22
3814 +#define s7 $23
3815 +#define t8 $24 /* caller saved */
3816 +#define t9 $25
3817 +#define jp $25 /* PIC jump register */
3818 +#define k0 $26 /* kernel scratch */
3819 +#define k1 $27
3820 +#define gp $28 /* global pointer */
3821 +#define sp $29 /* stack pointer */
3822 +#define fp $30 /* frame pointer */
3823 +#define s8 $30 /* same like fp! */
3824 +#define ra $31 /* return address */
3825 +
3826 +
3827 +/* *********************************************************************
3828 + * CP0 Registers
3829 + ********************************************************************* */
3830 +
3831 +#define C0_INX $0
3832 +#define C0_RAND $1
3833 +#define C0_TLBLO0 $2
3834 +#define C0_TLBLO C0_TLBLO0
3835 +#define C0_TLBLO1 $3
3836 +#define C0_CTEXT $4
3837 +#define C0_PGMASK $5
3838 +#define C0_WIRED $6
3839 +#define C0_BADVADDR $8
3840 +#define C0_COUNT $9
3841 +#define C0_TLBHI $10
3842 +#define C0_COMPARE $11
3843 +#define C0_SR $12
3844 +#define C0_STATUS C0_SR
3845 +#define C0_CAUSE $13
3846 +#define C0_EPC $14
3847 +#define C0_PRID $15
3848 +#define C0_CONFIG $16
3849 +#define C0_LLADDR $17
3850 +#define C0_WATCHLO $18
3851 +#define C0_WATCHHI $19
3852 +#define C0_XCTEXT $20
3853 +#define C0_DIAGNOSTIC $22
3854 +#define C0_BROADCOM C0_DIAGNOSTIC
3855 +#define C0_ECC $26
3856 +#define C0_CACHEERR $27
3857 +#define C0_TAGLO $28
3858 +#define C0_TAGHI $29
3859 +#define C0_ERREPC $30
3860 +#define C0_DESAVE $31
3861 +
3862 +/*
3863 + * LEAF - declare leaf routine
3864 + */
3865 +#define LEAF(symbol) \
3866 + .globl symbol; \
3867 + .align 2; \
3868 + .type symbol,@function; \
3869 + .ent symbol,0; \
3870 +symbol: .frame sp,0,ra
3871 +
3872 +/*
3873 + * END - mark end of function
3874 + */
3875 +#define END(function) \
3876 + .end function; \
3877 + .size function,.-function
3878 +
3879 +#define _ULCAST_
3880 +
3881 +#else
3882 +
3883 +/*
3884 + * The following macros are especially useful for __asm__
3885 + * inline assembler.
3886 + */
3887 +#ifndef __STR
3888 +#define __STR(x) #x
3889 +#endif
3890 +#ifndef STR
3891 +#define STR(x) __STR(x)
3892 +#endif
3893 +
3894 +#define _ULCAST_ (unsigned long)
3895 +
3896 +
3897 +/* *********************************************************************
3898 + * CP0 Registers
3899 + ********************************************************************* */
3900 +
3901 +#define C0_INX 0 /* CP0: TLB Index */
3902 +#define C0_RAND 1 /* CP0: TLB Random */
3903 +#define C0_TLBLO0 2 /* CP0: TLB EntryLo0 */
3904 +#define C0_TLBLO C0_TLBLO0 /* CP0: TLB EntryLo0 */
3905 +#define C0_TLBLO1 3 /* CP0: TLB EntryLo1 */
3906 +#define C0_CTEXT 4 /* CP0: Context */
3907 +#define C0_PGMASK 5 /* CP0: TLB PageMask */
3908 +#define C0_WIRED 6 /* CP0: TLB Wired */
3909 +#define C0_BADVADDR 8 /* CP0: Bad Virtual Address */
3910 +#define C0_COUNT 9 /* CP0: Count */
3911 +#define C0_TLBHI 10 /* CP0: TLB EntryHi */
3912 +#define C0_COMPARE 11 /* CP0: Compare */
3913 +#define C0_SR 12 /* CP0: Processor Status */
3914 +#define C0_STATUS C0_SR /* CP0: Processor Status */
3915 +#define C0_CAUSE 13 /* CP0: Exception Cause */
3916 +#define C0_EPC 14 /* CP0: Exception PC */
3917 +#define C0_PRID 15 /* CP0: Processor Revision Indentifier */
3918 +#define C0_CONFIG 16 /* CP0: Config */
3919 +#define C0_LLADDR 17 /* CP0: LLAddr */
3920 +#define C0_WATCHLO 18 /* CP0: WatchpointLo */
3921 +#define C0_WATCHHI 19 /* CP0: WatchpointHi */
3922 +#define C0_XCTEXT 20 /* CP0: XContext */
3923 +#define C0_DIAGNOSTIC 22 /* CP0: Diagnostic */
3924 +#define C0_BROADCOM C0_DIAGNOSTIC /* CP0: Broadcom Register */
3925 +#define C0_ECC 26 /* CP0: ECC */
3926 +#define C0_CACHEERR 27 /* CP0: CacheErr */
3927 +#define C0_TAGLO 28 /* CP0: TagLo */
3928 +#define C0_TAGHI 29 /* CP0: TagHi */
3929 +#define C0_ERREPC 30 /* CP0: ErrorEPC */
3930 +#define C0_DESAVE 31 /* CP0: DebugSave */
3931 +
3932 +#endif /* _LANGUAGE_ASSEMBLY */
3933 +
3934 +/*
3935 + * Memory segments (32bit kernel mode addresses)
3936 + */
3937 +#undef KUSEG
3938 +#undef KSEG0
3939 +#undef KSEG1
3940 +#undef KSEG2
3941 +#undef KSEG3
3942 +#define KUSEG 0x00000000
3943 +#define KSEG0 0x80000000
3944 +#define KSEG1 0xa0000000
3945 +#define KSEG2 0xc0000000
3946 +#define KSEG3 0xe0000000
3947 +#define PHYSADDR_MASK 0x1fffffff
3948 +
3949 +/*
3950 + * Map an address to a certain kernel segment
3951 + */
3952 +#undef PHYSADDR
3953 +#undef KSEG0ADDR
3954 +#undef KSEG1ADDR
3955 +#undef KSEG2ADDR
3956 +#undef KSEG3ADDR
3957 +
3958 +#define PHYSADDR(a) (_ULCAST_(a) & PHYSADDR_MASK)
3959 +#define KSEG0ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG0)
3960 +#define KSEG1ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG1)
3961 +#define KSEG2ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG2)
3962 +#define KSEG3ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG3)
3963 +
3964 +
3965 +#ifndef Index_Invalidate_I
3966 +/*
3967 + * Cache Operations
3968 + */
3969 +#define Index_Invalidate_I 0x00
3970 +#define Index_Writeback_Inv_D 0x01
3971 +#define Index_Invalidate_SI 0x02
3972 +#define Index_Writeback_Inv_SD 0x03
3973 +#define Index_Load_Tag_I 0x04
3974 +#define Index_Load_Tag_D 0x05
3975 +#define Index_Load_Tag_SI 0x06
3976 +#define Index_Load_Tag_SD 0x07
3977 +#define Index_Store_Tag_I 0x08
3978 +#define Index_Store_Tag_D 0x09
3979 +#define Index_Store_Tag_SI 0x0A
3980 +#define Index_Store_Tag_SD 0x0B
3981 +#define Create_Dirty_Excl_D 0x0d
3982 +#define Create_Dirty_Excl_SD 0x0f
3983 +#define Hit_Invalidate_I 0x10
3984 +#define Hit_Invalidate_D 0x11
3985 +#define Hit_Invalidate_SI 0x12
3986 +#define Hit_Invalidate_SD 0x13
3987 +#define Fill_I 0x14
3988 +#define Hit_Writeback_Inv_D 0x15
3989 + /* 0x16 is unused */
3990 +#define Hit_Writeback_Inv_SD 0x17
3991 +#define R5K_Page_Invalidate_S 0x17
3992 +#define Hit_Writeback_I 0x18
3993 +#define Hit_Writeback_D 0x19
3994 + /* 0x1a is unused */
3995 +#define Hit_Writeback_SD 0x1b
3996 + /* 0x1c is unused */
3997 + /* 0x1e is unused */
3998 +#define Hit_Set_Virtual_SI 0x1e
3999 +#define Hit_Set_Virtual_SD 0x1f
4000 +#endif
4001 +
4002 +#ifndef _LANGUAGE_ASSEMBLY
4003 +
4004 +/*
4005 + * Macros to access the system control coprocessor
4006 + */
4007 +
4008 +#define MFC0(source, sel) \
4009 +({ \
4010 + int __res; \
4011 + __asm__ __volatile__( \
4012 + ".set\tnoreorder\n\t" \
4013 + ".set\tnoat\n\t" \
4014 + ".word\t"STR(0x40010000 | ((source)<<11) | (sel))"\n\t" \
4015 + "move\t%0,$1\n\t" \
4016 + ".set\tat\n\t" \
4017 + ".set\treorder" \
4018 + :"=r" (__res) \
4019 + : \
4020 + :"$1"); \
4021 + __res; \
4022 +})
4023 +
4024 +#define MTC0(source, sel, value) \
4025 +do { \
4026 + __asm__ __volatile__( \
4027 + ".set\tnoreorder\n\t" \
4028 + ".set\tnoat\n\t" \
4029 + "move\t$1,%z0\n\t" \
4030 + ".word\t"STR(0x40810000 | ((source)<<11) | (sel))"\n\t" \
4031 + ".set\tat\n\t" \
4032 + ".set\treorder" \
4033 + : \
4034 + :"jr" (value) \
4035 + :"$1"); \
4036 +} while (0)
4037 +
4038 +#define get_c0_count() \
4039 +({ \
4040 + int __res; \
4041 + __asm__ __volatile__( \
4042 + ".set\tnoreorder\n\t" \
4043 + ".set\tnoat\n\t" \
4044 + "mfc0\t%0,$9\n\t" \
4045 + ".set\tat\n\t" \
4046 + ".set\treorder" \
4047 + :"=r" (__res)); \
4048 + __res; \
4049 +})
4050 +
4051 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize)
4052 +{
4053 + uint lsz, sets, ways;
4054 +
4055 + /* Instruction Cache Size = Associativity * Line Size * Sets Per Way */
4056 + if ((lsz = ((config1 >> 19) & 7)))
4057 + lsz = 2 << lsz;
4058 + sets = 64 << ((config1 >> 22) & 7);
4059 + ways = 1 + ((config1 >> 16) & 7);
4060 + *size = lsz * sets * ways;
4061 + *lsize = lsz;
4062 +}
4063 +
4064 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize)
4065 +{
4066 + uint lsz, sets, ways;
4067 +
4068 + /* Data Cache Size = Associativity * Line Size * Sets Per Way */
4069 + if ((lsz = ((config1 >> 10) & 7)))
4070 + lsz = 2 << lsz;
4071 + sets = 64 << ((config1 >> 13) & 7);
4072 + ways = 1 + ((config1 >> 7) & 7);
4073 + *size = lsz * sets * ways;
4074 + *lsize = lsz;
4075 +}
4076 +
4077 +#define cache_unroll(base,op) \
4078 + __asm__ __volatile__(" \
4079 + .set noreorder; \
4080 + .set mips3; \
4081 + cache %1, (%0); \
4082 + .set mips0; \
4083 + .set reorder" \
4084 + : \
4085 + : "r" (base), \
4086 + "i" (op));
4087 +
4088 +#endif /* !_LANGUAGE_ASSEMBLY */
4089 +
4090 +
4091 +/*
4092 + * R4x00 interrupt enable / cause bits
4093 + */
4094 +#undef IE_SW0
4095 +#undef IE_SW1
4096 +#undef IE_IRQ0
4097 +#undef IE_IRQ1
4098 +#undef IE_IRQ2
4099 +#undef IE_IRQ3
4100 +#undef IE_IRQ4
4101 +#undef IE_IRQ5
4102 +#define IE_SW0 (1<< 8)
4103 +#define IE_SW1 (1<< 9)
4104 +#define IE_IRQ0 (1<<10)
4105 +#define IE_IRQ1 (1<<11)
4106 +#define IE_IRQ2 (1<<12)
4107 +#define IE_IRQ3 (1<<13)
4108 +#define IE_IRQ4 (1<<14)
4109 +#define IE_IRQ5 (1<<15)
4110 +
4111 +/*
4112 + * Bitfields in the mips32 cp0 status register
4113 + */
4114 +#define ST0_IE 0x00000001
4115 +#define ST0_EXL 0x00000002
4116 +#define ST0_ERL 0x00000004
4117 +/* already defined
4118 +#define ST0_UM 0x00000010
4119 +#define ST0_SWINT0 0x00000100
4120 +#define ST0_SWINT1 0x00000200
4121 +*/
4122 +#define ST0_HWINT0 0x00000400
4123 +#define ST0_HWINT1 0x00000800
4124 +#define ST0_HWINT2 0x00001000
4125 +#define ST0_HWINT3 0x00002000
4126 +#define ST0_HWINT4 0x00004000
4127 +#define ST0_HWINT5 0x00008000
4128 +#define ST0_IM 0x0000ff00
4129 +#define ST0_NMI 0x00080000
4130 +#define ST0_SR 0x00100000
4131 +#define ST0_TS 0x00200000
4132 +#define ST0_BEV 0x00400000
4133 +#define ST0_RE 0x02000000
4134 +#define ST0_RP 0x08000000
4135 +#define ST0_CU 0xf0000000
4136 +#define ST0_CU0 0x10000000
4137 +#define ST0_CU1 0x20000000
4138 +#define ST0_CU2 0x40000000
4139 +#define ST0_CU3 0x80000000
4140 +
4141 +
4142 +/*
4143 + * Bitfields in the mips32 cp0 cause register
4144 + */
4145 +#define C_EXC 0x0000007c
4146 +#define C_EXC_SHIFT 2
4147 +#define C_INT 0x0000ff00
4148 +#define C_INT_SHIFT 8
4149 +/* already defined
4150 +#define C_SW0 0x00000100
4151 +#define C_SW1 0x00000200
4152 +#define C_IRQ0 0x00000400
4153 +#define C_IRQ1 0x00000800
4154 +#define C_IRQ2 0x00001000
4155 +#define C_IRQ3 0x00002000
4156 +#define C_IRQ4 0x00004000
4157 +#define C_IRQ5 0x00008000
4158 +*/
4159 +#define C_WP 0x00400000
4160 +#define C_IV 0x00800000
4161 +#define C_CE 0x30000000
4162 +#define C_CE_SHIFT 28
4163 +#define C_BD 0x80000000
4164 +
4165 +/* Values in C_EXC */
4166 +#define EXC_INT 0
4167 +#define EXC_TLBM 1
4168 +#define EXC_TLBL 2
4169 +#define EXC_TLBS 3
4170 +#define EXC_AEL 4
4171 +#define EXC_AES 5
4172 +#define EXC_IBE 6
4173 +#define EXC_DBE 7
4174 +#define EXC_SYS 8
4175 +#define EXC_BPT 9
4176 +#define EXC_RI 10
4177 +#define EXC_CU 11
4178 +#define EXC_OV 12
4179 +#define EXC_TR 13
4180 +#define EXC_WATCH 23
4181 +#define EXC_MCHK 24
4182 +
4183 +
4184 +/*
4185 + * Bits in the cp0 config register.
4186 + */
4187 +#define CONF_CM_CACHABLE_NO_WA 0
4188 +#define CONF_CM_CACHABLE_WA 1
4189 +#define CONF_CM_UNCACHED 2
4190 +#define CONF_CM_CACHABLE_NONCOHERENT 3
4191 +#define CONF_CM_CACHABLE_CE 4
4192 +#define CONF_CM_CACHABLE_COW 5
4193 +#define CONF_CM_CACHABLE_CUW 6
4194 +#define CONF_CM_CACHABLE_ACCELERATED 7
4195 +#define CONF_CM_CMASK 7
4196 +#define CONF_CU (_ULCAST_(1) << 3)
4197 +#define CONF_DB (_ULCAST_(1) << 4)
4198 +#define CONF_IB (_ULCAST_(1) << 5)
4199 +#define CONF_SE (_ULCAST_(1) << 12)
4200 +#define CONF_SC (_ULCAST_(1) << 17)
4201 +#define CONF_AC (_ULCAST_(1) << 23)
4202 +#define CONF_HALT (_ULCAST_(1) << 25)
4203 +
4204 +
4205 +/*
4206 + * Bits in the cp0 config register select 1.
4207 + */
4208 +#define CONF1_FP 0x00000001 /* FPU present */
4209 +#define CONF1_EP 0x00000002 /* EJTAG present */
4210 +#define CONF1_CA 0x00000004 /* mips16 implemented */
4211 +#define CONF1_WR 0x00000008 /* Watch registers present */
4212 +#define CONF1_PC 0x00000010 /* Performance counters present */
4213 +#define CONF1_DA_SHIFT 7 /* D$ associativity */
4214 +#define CONF1_DA_MASK 0x00000380
4215 +#define CONF1_DA_BASE 1
4216 +#define CONF1_DL_SHIFT 10 /* D$ line size */
4217 +#define CONF1_DL_MASK 0x00001c00
4218 +#define CONF1_DL_BASE 2
4219 +#define CONF1_DS_SHIFT 13 /* D$ sets/way */
4220 +#define CONF1_DS_MASK 0x0000e000
4221 +#define CONF1_DS_BASE 64
4222 +#define CONF1_IA_SHIFT 16 /* I$ associativity */
4223 +#define CONF1_IA_MASK 0x00070000
4224 +#define CONF1_IA_BASE 1
4225 +#define CONF1_IL_SHIFT 19 /* I$ line size */
4226 +#define CONF1_IL_MASK 0x00380000
4227 +#define CONF1_IL_BASE 2
4228 +#define CONF1_IS_SHIFT 22 /* Instruction cache sets/way */
4229 +#define CONF1_IS_MASK 0x01c00000
4230 +#define CONF1_IS_BASE 64
4231 +#define CONF1_MS_MASK 0x7e000000 /* Number of tlb entries */
4232 +#define CONF1_MS_SHIFT 25
4233 +
4234 +/* PRID register */
4235 +#define PRID_COPT_MASK 0xff000000
4236 +#define PRID_COMP_MASK 0x00ff0000
4237 +#define PRID_IMP_MASK 0x0000ff00
4238 +#define PRID_REV_MASK 0x000000ff
4239 +
4240 +#define PRID_COMP_LEGACY 0x000000
4241 +#define PRID_COMP_MIPS 0x010000
4242 +#define PRID_COMP_BROADCOM 0x020000
4243 +#define PRID_COMP_ALCHEMY 0x030000
4244 +#define PRID_COMP_SIBYTE 0x040000
4245 +#define PRID_IMP_BCM4710 0x4000
4246 +#define PRID_IMP_BCM3302 0x9000
4247 +#define PRID_IMP_BCM3303 0x9100
4248 +#define PRID_IMP_BCM3303 0x9100
4249 +
4250 +#define PRID_IMP_UNKNOWN 0xff00
4251 +
4252 +#define BCM330X(id) \
4253 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
4254 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
4255 +
4256 +/* Bits in C0_BROADCOM */
4257 +#define BRCM_PFC_AVAIL 0x20000000 /* PFC is available */
4258 +#define BRCM_DC_ENABLE 0x40000000 /* Enable Data $ */
4259 +#define BRCM_IC_ENABLE 0x80000000 /* Enable Instruction $ */
4260 +#define BRCM_PFC_ENABLE 0x00400000 /* Obsolete? Enable PFC (at least on 4310) */
4261 +
4262 +/* PreFetch Cache aka Read Ahead Cache */
4263 +
4264 +#define PFC_CR0 0xff400000 /* control reg 0 */
4265 +#define PFC_CR1 0xff400004 /* control reg 1 */
4266 +
4267 +/*
4268 + * These are the UART port assignments, expressed as offsets from the base
4269 + * register. These assignments should hold for any serial port based on
4270 + * a 8250, 16450, or 16550(A).
4271 + */
4272 +
4273 +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */
4274 +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
4275 +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
4276 +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */
4277 +#define UART_LCR 3 /* Out: Line Control Register */
4278 +#define UART_MCR 4 /* Out: Modem Control Register */
4279 +#define UART_LSR 5 /* In: Line Status Register */
4280 +#define UART_MSR 6 /* In: Modem Status Register */
4281 +#define UART_SCR 7 /* I/O: Scratch Register */
4282 +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
4283 +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
4284 +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
4285 +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
4286 +#define UART_LSR_RXRDY 0x01 /* Receiver ready */
4287 +
4288 +
4289 +#endif /* _MISPINC_H */
4290 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/nvports.h linux-2.4.30.dev/arch/mips/bcm947xx/include/nvports.h
4291 --- linux-2.4.30/arch/mips/bcm947xx/include/nvports.h 1970-01-01 01:00:00.000000000 +0100
4292 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/nvports.h 2005-08-22 01:34:46.322151616 +0200
4293 @@ -0,0 +1,55 @@
4294 +/*
4295 + * BCM53xx RoboSwitch utility functions
4296 + *
4297 + * Copyright (C) 2002 Broadcom Corporation
4298 + * $Id$
4299 + */
4300 +
4301 +#ifndef _nvports_h_
4302 +#define _nvports_h_
4303 +
4304 +#define uint32 unsigned long
4305 +#define uint16 unsigned short
4306 +#define uint unsigned int
4307 +#define uint8 unsigned char
4308 +#define uint64 unsigned long long
4309 +
4310 +enum FORCE_PORT {
4311 + FORCE_OFF,
4312 + FORCE_10H,
4313 + FORCE_10F,
4314 + FORCE_100H,
4315 + FORCE_100F,
4316 + FORCE_DOWN,
4317 + POWER_OFF
4318 +};
4319 +
4320 +typedef struct _PORT_ATTRIBS
4321 +{
4322 + uint autoneg;
4323 + uint force;
4324 + uint native;
4325 +} PORT_ATTRIBS;
4326 +
4327 +extern uint
4328 +nvExistsPortAttrib(char *attrib, uint portno);
4329 +
4330 +extern int
4331 +nvExistsAnyForcePortAttrib(uint portno);
4332 +
4333 +extern void
4334 +nvSetPortAttrib(char *attrib, uint portno);
4335 +
4336 +extern void
4337 +nvUnsetPortAttrib(char *attrib, uint portno);
4338 +
4339 +extern void
4340 +nvUnsetAllForcePortAttrib(uint portno);
4341 +
4342 +extern PORT_ATTRIBS
4343 +nvGetSwitchPortAttribs(uint portno);
4344 +
4345 +#endif /* _nvports_h_ */
4346 +
4347 +
4348 +
4349 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/osl.h linux-2.4.30.dev/arch/mips/bcm947xx/include/osl.h
4350 --- linux-2.4.30/arch/mips/bcm947xx/include/osl.h 1970-01-01 01:00:00.000000000 +0100
4351 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/osl.h 2005-08-22 01:34:46.323151464 +0200
4352 @@ -0,0 +1,39 @@
4353 +/*
4354 + * OS Independent Layer
4355 + *
4356 + * Copyright 2005, Broadcom Corporation
4357 + * All Rights Reserved.
4358 + *
4359 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4360 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4361 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4362 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4363 + * $Id$
4364 + */
4365 +
4366 +#ifndef _osl_h_
4367 +#define _osl_h_
4368 +
4369 +#if defined(linux)
4370 +#include <linux_osl.h>
4371 +#elif defined(NDIS)
4372 +#include <ndis_osl.h>
4373 +#elif defined(_CFE_)
4374 +#include <cfe_osl.h>
4375 +#elif defined(_HNDRTE_)
4376 +#include <hndrte_osl.h>
4377 +#elif defined(_MINOSL_)
4378 +#include <min_osl.h>
4379 +#elif PMON
4380 +#include <pmon_osl.h>
4381 +#elif defined(MACOSX)
4382 +#include <macosx_osl.h>
4383 +#else
4384 +#error "Unsupported OSL requested"
4385 +#endif
4386 +
4387 +/* handy */
4388 +#define SET_REG(r, mask, val) W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
4389 +#define MAXPRIO 7 /* 0-7 */
4390 +
4391 +#endif /* _osl_h_ */
4392 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/pcicfg.h linux-2.4.30.dev/arch/mips/bcm947xx/include/pcicfg.h
4393 --- linux-2.4.30/arch/mips/bcm947xx/include/pcicfg.h 1970-01-01 01:00:00.000000000 +0100
4394 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/pcicfg.h 2005-08-22 01:34:46.323151464 +0200
4395 @@ -0,0 +1,369 @@
4396 +/*
4397 + * pcicfg.h: PCI configuration constants and structures.
4398 + *
4399 + * Copyright 2005, Broadcom Corporation
4400 + * All Rights Reserved.
4401 + *
4402 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4403 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4404 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4405 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4406 + *
4407 + * $Id$
4408 + */
4409 +
4410 +#ifndef _h_pci_
4411 +#define _h_pci_
4412 +
4413 +/* The following inside ifndef's so we don't collide with NTDDK.H */
4414 +#ifndef PCI_MAX_BUS
4415 +#define PCI_MAX_BUS 0x100
4416 +#endif
4417 +#ifndef PCI_MAX_DEVICES
4418 +#define PCI_MAX_DEVICES 0x20
4419 +#endif
4420 +#ifndef PCI_MAX_FUNCTION
4421 +#define PCI_MAX_FUNCTION 0x8
4422 +#endif
4423 +
4424 +#ifndef PCI_INVALID_VENDORID
4425 +#define PCI_INVALID_VENDORID 0xffff
4426 +#endif
4427 +#ifndef PCI_INVALID_DEVICEID
4428 +#define PCI_INVALID_DEVICEID 0xffff
4429 +#endif
4430 +
4431 +
4432 +/* Convert between bus-slot-function-register and config addresses */
4433 +
4434 +#define PCICFG_BUS_SHIFT 16 /* Bus shift */
4435 +#define PCICFG_SLOT_SHIFT 11 /* Slot shift */
4436 +#define PCICFG_FUN_SHIFT 8 /* Function shift */
4437 +#define PCICFG_OFF_SHIFT 0 /* Bus shift */
4438 +
4439 +#define PCICFG_BUS_MASK 0xff /* Bus mask */
4440 +#define PCICFG_SLOT_MASK 0x1f /* Slot mask */
4441 +#define PCICFG_FUN_MASK 7 /* Function mask */
4442 +#define PCICFG_OFF_MASK 0xff /* Bus mask */
4443 +
4444 +#define PCI_CONFIG_ADDR(b, s, f, o) \
4445 + ((((b) & PCICFG_BUS_MASK) << PCICFG_BUS_SHIFT) \
4446 + | (((s) & PCICFG_SLOT_MASK) << PCICFG_SLOT_SHIFT) \
4447 + | (((f) & PCICFG_FUN_MASK) << PCICFG_FUN_SHIFT) \
4448 + | (((o) & PCICFG_OFF_MASK) << PCICFG_OFF_SHIFT))
4449 +
4450 +#define PCI_CONFIG_BUS(a) (((a) >> PCICFG_BUS_SHIFT) & PCICFG_BUS_MASK)
4451 +#define PCI_CONFIG_SLOT(a) (((a) >> PCICFG_SLOT_SHIFT) & PCICFG_SLOT_MASK)
4452 +#define PCI_CONFIG_FUN(a) (((a) >> PCICFG_FUN_SHIFT) & PCICFG_FUN_MASK)
4453 +#define PCI_CONFIG_OFF(a) (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK)
4454 +
4455 +
4456 +/* The actual config space */
4457 +
4458 +#define PCI_BAR_MAX 6
4459 +
4460 +#define PCI_ROM_BAR 8
4461 +
4462 +#define PCR_RSVDA_MAX 2
4463 +
4464 +typedef struct _pci_config_regs {
4465 + unsigned short vendor;
4466 + unsigned short device;
4467 + unsigned short command;
4468 + unsigned short status;
4469 + unsigned char rev_id;
4470 + unsigned char prog_if;
4471 + unsigned char sub_class;
4472 + unsigned char base_class;
4473 + unsigned char cache_line_size;
4474 + unsigned char latency_timer;
4475 + unsigned char header_type;
4476 + unsigned char bist;
4477 + unsigned long base[PCI_BAR_MAX];
4478 + unsigned long cardbus_cis;
4479 + unsigned short subsys_vendor;
4480 + unsigned short subsys_id;
4481 + unsigned long baserom;
4482 + unsigned long rsvd_a[PCR_RSVDA_MAX];
4483 + unsigned char int_line;
4484 + unsigned char int_pin;
4485 + unsigned char min_gnt;
4486 + unsigned char max_lat;
4487 + unsigned char dev_dep[192];
4488 +} pci_config_regs;
4489 +
4490 +#define SZPCR (sizeof (pci_config_regs))
4491 +#define MINSZPCR 64 /* offsetof (dev_dep[0] */
4492 +
4493 +/* A structure for the config registers is nice, but in most
4494 + * systems the config space is not memory mapped, so we need
4495 + * filed offsetts. :-(
4496 + */
4497 +#define PCI_CFG_VID 0
4498 +#define PCI_CFG_DID 2
4499 +#define PCI_CFG_CMD 4
4500 +#define PCI_CFG_STAT 6
4501 +#define PCI_CFG_REV 8
4502 +#define PCI_CFG_PROGIF 9
4503 +#define PCI_CFG_SUBCL 0xa
4504 +#define PCI_CFG_BASECL 0xb
4505 +#define PCI_CFG_CLSZ 0xc
4506 +#define PCI_CFG_LATTIM 0xd
4507 +#define PCI_CFG_HDR 0xe
4508 +#define PCI_CFG_BIST 0xf
4509 +#define PCI_CFG_BAR0 0x10
4510 +#define PCI_CFG_BAR1 0x14
4511 +#define PCI_CFG_BAR2 0x18
4512 +#define PCI_CFG_BAR3 0x1c
4513 +#define PCI_CFG_BAR4 0x20
4514 +#define PCI_CFG_BAR5 0x24
4515 +#define PCI_CFG_CIS 0x28
4516 +#define PCI_CFG_SVID 0x2c
4517 +#define PCI_CFG_SSID 0x2e
4518 +#define PCI_CFG_ROMBAR 0x30
4519 +#define PCI_CFG_INT 0x3c
4520 +#define PCI_CFG_PIN 0x3d
4521 +#define PCI_CFG_MINGNT 0x3e
4522 +#define PCI_CFG_MAXLAT 0x3f
4523 +
4524 +/* Classes and subclasses */
4525 +
4526 +typedef enum {
4527 + PCI_CLASS_OLD = 0,
4528 + PCI_CLASS_DASDI,
4529 + PCI_CLASS_NET,
4530 + PCI_CLASS_DISPLAY,
4531 + PCI_CLASS_MMEDIA,
4532 + PCI_CLASS_MEMORY,
4533 + PCI_CLASS_BRIDGE,
4534 + PCI_CLASS_COMM,
4535 + PCI_CLASS_BASE,
4536 + PCI_CLASS_INPUT,
4537 + PCI_CLASS_DOCK,
4538 + PCI_CLASS_CPU,
4539 + PCI_CLASS_SERIAL,
4540 + PCI_CLASS_INTELLIGENT = 0xe,
4541 + PCI_CLASS_SATELLITE,
4542 + PCI_CLASS_CRYPT,
4543 + PCI_CLASS_DSP,
4544 + PCI_CLASS_MAX
4545 +} pci_classes;
4546 +
4547 +typedef enum {
4548 + PCI_DASDI_SCSI,
4549 + PCI_DASDI_IDE,
4550 + PCI_DASDI_FLOPPY,
4551 + PCI_DASDI_IPI,
4552 + PCI_DASDI_RAID,
4553 + PCI_DASDI_OTHER = 0x80
4554 +} pci_dasdi_subclasses;
4555 +
4556 +typedef enum {
4557 + PCI_NET_ETHER,
4558 + PCI_NET_TOKEN,
4559 + PCI_NET_FDDI,
4560 + PCI_NET_ATM,
4561 + PCI_NET_OTHER = 0x80
4562 +} pci_net_subclasses;
4563 +
4564 +typedef enum {
4565 + PCI_DISPLAY_VGA,
4566 + PCI_DISPLAY_XGA,
4567 + PCI_DISPLAY_3D,
4568 + PCI_DISPLAY_OTHER = 0x80
4569 +} pci_display_subclasses;
4570 +
4571 +typedef enum {
4572 + PCI_MMEDIA_VIDEO,
4573 + PCI_MMEDIA_AUDIO,
4574 + PCI_MMEDIA_PHONE,
4575 + PCI_MEDIA_OTHER = 0x80
4576 +} pci_mmedia_subclasses;
4577 +
4578 +typedef enum {
4579 + PCI_MEMORY_RAM,
4580 + PCI_MEMORY_FLASH,
4581 + PCI_MEMORY_OTHER = 0x80
4582 +} pci_memory_subclasses;
4583 +
4584 +typedef enum {
4585 + PCI_BRIDGE_HOST,
4586 + PCI_BRIDGE_ISA,
4587 + PCI_BRIDGE_EISA,
4588 + PCI_BRIDGE_MC,
4589 + PCI_BRIDGE_PCI,
4590 + PCI_BRIDGE_PCMCIA,
4591 + PCI_BRIDGE_NUBUS,
4592 + PCI_BRIDGE_CARDBUS,
4593 + PCI_BRIDGE_RACEWAY,
4594 + PCI_BRIDGE_OTHER = 0x80
4595 +} pci_bridge_subclasses;
4596 +
4597 +typedef enum {
4598 + PCI_COMM_UART,
4599 + PCI_COMM_PARALLEL,
4600 + PCI_COMM_MULTIUART,
4601 + PCI_COMM_MODEM,
4602 + PCI_COMM_OTHER = 0x80
4603 +} pci_comm_subclasses;
4604 +
4605 +typedef enum {
4606 + PCI_BASE_PIC,
4607 + PCI_BASE_DMA,
4608 + PCI_BASE_TIMER,
4609 + PCI_BASE_RTC,
4610 + PCI_BASE_PCI_HOTPLUG,
4611 + PCI_BASE_OTHER = 0x80
4612 +} pci_base_subclasses;
4613 +
4614 +typedef enum {
4615 + PCI_INPUT_KBD,
4616 + PCI_INPUT_PEN,
4617 + PCI_INPUT_MOUSE,
4618 + PCI_INPUT_SCANNER,
4619 + PCI_INPUT_GAMEPORT,
4620 + PCI_INPUT_OTHER = 0x80
4621 +} pci_input_subclasses;
4622 +
4623 +typedef enum {
4624 + PCI_DOCK_GENERIC,
4625 + PCI_DOCK_OTHER = 0x80
4626 +} pci_dock_subclasses;
4627 +
4628 +typedef enum {
4629 + PCI_CPU_386,
4630 + PCI_CPU_486,
4631 + PCI_CPU_PENTIUM,
4632 + PCI_CPU_ALPHA = 0x10,
4633 + PCI_CPU_POWERPC = 0x20,
4634 + PCI_CPU_MIPS = 0x30,
4635 + PCI_CPU_COPROC = 0x40,
4636 + PCI_CPU_OTHER = 0x80
4637 +} pci_cpu_subclasses;
4638 +
4639 +typedef enum {
4640 + PCI_SERIAL_IEEE1394,
4641 + PCI_SERIAL_ACCESS,
4642 + PCI_SERIAL_SSA,
4643 + PCI_SERIAL_USB,
4644 + PCI_SERIAL_FIBER,
4645 + PCI_SERIAL_SMBUS,
4646 + PCI_SERIAL_OTHER = 0x80
4647 +} pci_serial_subclasses;
4648 +
4649 +typedef enum {
4650 + PCI_INTELLIGENT_I2O,
4651 +} pci_intelligent_subclasses;
4652 +
4653 +typedef enum {
4654 + PCI_SATELLITE_TV,
4655 + PCI_SATELLITE_AUDIO,
4656 + PCI_SATELLITE_VOICE,
4657 + PCI_SATELLITE_DATA,
4658 + PCI_SATELLITE_OTHER = 0x80
4659 +} pci_satellite_subclasses;
4660 +
4661 +typedef enum {
4662 + PCI_CRYPT_NETWORK,
4663 + PCI_CRYPT_ENTERTAINMENT,
4664 + PCI_CRYPT_OTHER = 0x80
4665 +} pci_crypt_subclasses;
4666 +
4667 +typedef enum {
4668 + PCI_DSP_DPIO,
4669 + PCI_DSP_OTHER = 0x80
4670 +} pci_dsp_subclasses;
4671 +
4672 +/* Header types */
4673 +typedef enum {
4674 + PCI_HEADER_NORMAL,
4675 + PCI_HEADER_BRIDGE,
4676 + PCI_HEADER_CARDBUS
4677 +} pci_header_types;
4678 +
4679 +
4680 +/* Overlay for a PCI-to-PCI bridge */
4681 +
4682 +#define PPB_RSVDA_MAX 2
4683 +#define PPB_RSVDD_MAX 8
4684 +
4685 +typedef struct _ppb_config_regs {
4686 + unsigned short vendor;
4687 + unsigned short device;
4688 + unsigned short command;
4689 + unsigned short status;
4690 + unsigned char rev_id;
4691 + unsigned char prog_if;
4692 + unsigned char sub_class;
4693 + unsigned char base_class;
4694 + unsigned char cache_line_size;
4695 + unsigned char latency_timer;
4696 + unsigned char header_type;
4697 + unsigned char bist;
4698 + unsigned long rsvd_a[PPB_RSVDA_MAX];
4699 + unsigned char prim_bus;
4700 + unsigned char sec_bus;
4701 + unsigned char sub_bus;
4702 + unsigned char sec_lat;
4703 + unsigned char io_base;
4704 + unsigned char io_lim;
4705 + unsigned short sec_status;
4706 + unsigned short mem_base;
4707 + unsigned short mem_lim;
4708 + unsigned short pf_mem_base;
4709 + unsigned short pf_mem_lim;
4710 + unsigned long pf_mem_base_hi;
4711 + unsigned long pf_mem_lim_hi;
4712 + unsigned short io_base_hi;
4713 + unsigned short io_lim_hi;
4714 + unsigned short subsys_vendor;
4715 + unsigned short subsys_id;
4716 + unsigned long rsvd_b;
4717 + unsigned char rsvd_c;
4718 + unsigned char int_pin;
4719 + unsigned short bridge_ctrl;
4720 + unsigned char chip_ctrl;
4721 + unsigned char diag_ctrl;
4722 + unsigned short arb_ctrl;
4723 + unsigned long rsvd_d[PPB_RSVDD_MAX];
4724 + unsigned char dev_dep[192];
4725 +} ppb_config_regs;
4726 +
4727 +/* Eveything below is BRCM HND proprietary */
4728 +
4729 +#define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */
4730 +#define PCI_BAR1_WIN 0x84 /* backplane addres space accessed by BAR1 */
4731 +#define PCI_SPROM_CONTROL 0x88 /* sprom property control */
4732 +#define PCI_BAR1_CONTROL 0x8c /* BAR1 region burst control */
4733 +#define PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */
4734 +#define PCI_INT_MASK 0x94 /* mask of PCI and other cores interrupts */
4735 +#define PCI_TO_SB_MB 0x98 /* signal backplane interrupts */
4736 +#define PCI_BACKPLANE_ADDR 0xA0 /* address an arbitrary location on the system backplane */
4737 +#define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address register */
4738 +#define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */
4739 +#define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */
4740 +#define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */
4741 +
4742 +#define PCI_BAR0_SPROM_OFFSET (4 * 1024) /* bar0 + 4K accesses external sprom */
4743 +#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) /* bar0 + 6K accesses pci core registers */
4744 +
4745 +/* PCI_INT_STATUS */
4746 +#define PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */
4747 +
4748 +/* PCI_INT_MASK */
4749 +#define PCI_SBIM_SHIFT 8 /* backplane core interrupt mask bits offset */
4750 +#define PCI_SBIM_MASK 0xff00 /* backplane core interrupt mask */
4751 +#define PCI_SBIM_MASK_SERR 0x4 /* backplane SBErr interrupt mask */
4752 +
4753 +/* PCI_SPROM_CONTROL */
4754 +#define SPROM_BLANK 0x04 /* indicating a blank sprom */
4755 +#define SPROM_WRITEEN 0x10 /* sprom write enable */
4756 +#define SPROM_BOOTROM_WE 0x20 /* external bootrom write enable */
4757 +
4758 +#define SPROM_SIZE 256 /* sprom size in 16-bit */
4759 +#define SPROM_CRC_RANGE 64 /* crc cover range in 16-bit */
4760 +
4761 +/* PCI_CFG_CMD_STAT */
4762 +#define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */
4763 +
4764 +#endif
4765 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/pmon_osl.h linux-2.4.30.dev/arch/mips/bcm947xx/include/pmon_osl.h
4766 --- linux-2.4.30/arch/mips/bcm947xx/include/pmon_osl.h 1970-01-01 01:00:00.000000000 +0100
4767 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/pmon_osl.h 2005-08-22 01:34:46.324151312 +0200
4768 @@ -0,0 +1,126 @@
4769 +/*
4770 + * MIPS PMON boot loader OS Abstraction Layer.
4771 + *
4772 + * Copyright 2005, Broadcom Corporation
4773 + * All Rights Reserved.
4774 + *
4775 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
4776 + * the contents of this file may not be disclosed to third parties, copied
4777 + * or duplicated in any form, in whole or in part, without the prior
4778 + * written permission of Broadcom Corporation.
4779 + * $Id$
4780 + */
4781 +
4782 +#ifndef _pmon_osl_h_
4783 +#define _pmon_osl_h_
4784 +
4785 +#include <typedefs.h>
4786 +#include <mips.h>
4787 +#include <string.h>
4788 +#include <utypes.h>
4789 +
4790 +extern int printf(char *fmt,...);
4791 +extern int sprintf(char *dst,char *fmt,...);
4792 +
4793 +#define OSL_UNCACHED(va) phy2k1(log2phy((va)))
4794 +#define REG_MAP(pa, size) phy2k1((pa))
4795 +#define REG_UNMAP(va) /* nop */
4796 +
4797 +/* Common macros */
4798 +
4799 +#define BUSPROBE(val, addr) ((val) = *(addr))
4800 +
4801 +#define ASSERT(exp)
4802 +
4803 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) bzero(buf, size)
4804 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size)
4805 +
4806 +/* kludge */
4807 +#define OSL_PCI_READ_CONFIG(loc, offset, size) ((offset == 8)? 0: 0xffffffff)
4808 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) ASSERT(0)
4809 +
4810 +#define wreg32(r,v) (*(volatile uint32 *)(r) = (v))
4811 +#define rreg32(r) (*(volatile uint32 *)(r))
4812 +#ifdef IL_BIGENDIAN
4813 +#define wreg16(r,v) (*(volatile uint16 *)((uint32)r^2) = (v))
4814 +#define rreg16(r) (*(volatile uint16 *)((uint32)r^2))
4815 +#else
4816 +#define wreg16(r,v) (*(volatile uint16 *)(r) = (v))
4817 +#define rreg16(r) (*(volatile uint16 *)(r))
4818 +#endif
4819 +
4820 +#include <memory.h>
4821 +#define bcopy(src, dst, len) memcpy(dst, src, len)
4822 +#define bcmp(b1, b2, len) memcmp(b1, b2, len)
4823 +#define bzero(b, len) memset(b, '\0', len)
4824 +
4825 +/* register access macros */
4826 +#define R_REG(r) ((sizeof *(r) == sizeof (uint32))? rreg32(r): rreg16(r))
4827 +#define W_REG(r,v) ((sizeof *(r) == sizeof (uint32))? wreg32(r,(uint32)v): wreg16(r,(uint16)v))
4828 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
4829 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
4830 +
4831 +#define R_SM(r) *(r)
4832 +#define W_SM(r, v) (*(r) = (v))
4833 +#define BZERO_SM(r, len) memset(r, '\0', len)
4834 +
4835 +/* Host/Bus architecture specific swap. Noop for little endian systems, possible swap on big endian */
4836 +#define BUS_SWAP32(v) (v)
4837 +
4838 +#define OSL_DELAY(usec) delay_us(usec)
4839 +extern void delay_us(uint usec);
4840 +
4841 +#define OSL_GETCYCLES(x) ((x) = 0)
4842 +
4843 +#define osl_attach(pdev) (pdev)
4844 +#define osl_detach(osh)
4845 +
4846 +#define MALLOC(osh, size) malloc(size)
4847 +#define MFREE(osh, addr, size) free(addr)
4848 +#define MALLOCED(osh) (0)
4849 +#define MALLOC_DUMP(osh, buf, sz)
4850 +#define MALLOC_FAILED(osh)
4851 +extern void *malloc();
4852 +extern void free(void *addr);
4853 +
4854 +#define DMA_CONSISTENT_ALIGN sizeof (int)
4855 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) et_dma_alloc_consistent(osh, size, pap)
4856 +#define DMA_FREE_CONSISTENT(osh, va, size, pa)
4857 +extern void* et_dma_alloc_consistent(void *osh, uint size, ulong *pap);
4858 +#define DMA_TX 0
4859 +#define DMA_RX 1
4860 +
4861 +#define DMA_MAP(osh, va, size, direction, p) osl_dma_map(osh, (void*)va, size, direction)
4862 +#define DMA_UNMAP(osh, pa, size, direction, p) /* nop */
4863 +extern void* osl_dma_map(void *osh, void *va, uint size, uint direction);
4864 +
4865 +struct lbuf {
4866 + struct lbuf *next; /* pointer to next lbuf on freelist */
4867 + uchar *buf; /* pointer to buffer */
4868 + uint len; /* nbytes of data */
4869 +};
4870 +
4871 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
4872 +#define PKTBUFSZ 2048
4873 +
4874 +/* packet primitives */
4875 +#define PKTGET(drv, len, send) et_pktget(drv, len, send)
4876 +#define PKTFREE(drv, lb, send) et_pktfree(drv, (struct lbuf*)lb, send)
4877 +#define PKTDATA(drv, lb) ((uchar*)OSL_UNCACHED(((struct lbuf*)lb)->buf))
4878 +#define PKTLEN(drv, lb) ((struct lbuf*)lb)->len
4879 +#define PKTHEADROOM(drv, lb) (0)
4880 +#define PKTTAILROOM(drv, lb) (0)
4881 +#define PKTNEXT(drv, lb) NULL
4882 +#define PKTSETNEXT(lb, x) ASSERT(0)
4883 +#define PKTSETLEN(drv, lb, bytes) ((struct lbuf*)lb)->len = bytes
4884 +#define PKTPUSH(drv, lb, bytes) ASSERT(0)
4885 +#define PKTPULL(drv, lb, bytes) ASSERT(0)
4886 +#define PKTDUP(drv, lb) ASSERT(0)
4887 +#define PKTLINK(lb) ((struct lbuf*)lb)->next
4888 +#define PKTSETLINK(lb, x) ((struct lbuf*)lb)->next = (struct lbuf*)x
4889 +#define PKTPRIO(lb) (0)
4890 +#define PKTSETPRIO(lb, x) do {} while (0)
4891 +extern void *et_pktget(void *drv, uint len, bool send);
4892 +extern void et_pktfree(void *drv, struct lbuf *lb, bool send);
4893 +
4894 +#endif /* _pmon_osl_h_ */
4895 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/proto/802.11.h linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/802.11.h
4896 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/802.11.h 1970-01-01 01:00:00.000000000 +0100
4897 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/802.11.h 2005-08-22 01:34:46.326151008 +0200
4898 @@ -0,0 +1,897 @@
4899 +/*
4900 + * Copyright 2005, Broadcom Corporation
4901 + * All Rights Reserved.
4902 + *
4903 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4904 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4905 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4906 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4907 + *
4908 + * Fundamental types and constants relating to 802.11
4909 + *
4910 + * $Id$
4911 + */
4912 +
4913 +#ifndef _802_11_H_
4914 +#define _802_11_H_
4915 +
4916 +#ifndef _TYPEDEFS_H_
4917 +#include <typedefs.h>
4918 +#endif
4919 +
4920 +#ifndef _NET_ETHERNET_H_
4921 +#include <proto/ethernet.h>
4922 +#endif
4923 +
4924 +#include <proto/wpa.h>
4925 +
4926 +
4927 +/* enable structure packing */
4928 +#if defined(__GNUC__)
4929 +#define PACKED __attribute__((packed))
4930 +#else
4931 +#pragma pack(1)
4932 +#define PACKED
4933 +#endif
4934 +
4935 +#define DOT11_TU_TO_US 1024 /* 802.11 Time Unit is 1024 microseconds */
4936 +
4937 +/* Generic 802.11 frame constants */
4938 +#define DOT11_A3_HDR_LEN 24
4939 +#define DOT11_A4_HDR_LEN 30
4940 +#define DOT11_MAC_HDR_LEN DOT11_A3_HDR_LEN
4941 +#define DOT11_FCS_LEN 4
4942 +#define DOT11_ICV_LEN 4
4943 +#define DOT11_ICV_AES_LEN 8
4944 +#define DOT11_QOS_LEN 2
4945 +
4946 +#define DOT11_KEY_INDEX_SHIFT 6
4947 +#define DOT11_IV_LEN 4
4948 +#define DOT11_IV_TKIP_LEN 8
4949 +#define DOT11_IV_AES_OCB_LEN 4
4950 +#define DOT11_IV_AES_CCM_LEN 8
4951 +
4952 +/* Includes MIC */
4953 +#define DOT11_MAX_MPDU_BODY_LEN 2304
4954 +/* A4 header + QoS + CCMP + PDU + ICV + FCS = 2352 */
4955 +#define DOT11_MAX_MPDU_LEN (DOT11_A4_HDR_LEN + \
4956 + DOT11_QOS_LEN + \
4957 + DOT11_IV_AES_CCM_LEN + \
4958 + DOT11_MAX_MPDU_BODY_LEN + \
4959 + DOT11_ICV_LEN + \
4960 + DOT11_FCS_LEN)
4961 +
4962 +#define DOT11_MAX_SSID_LEN 32
4963 +
4964 +/* dot11RTSThreshold */
4965 +#define DOT11_DEFAULT_RTS_LEN 2347
4966 +#define DOT11_MAX_RTS_LEN 2347
4967 +
4968 +/* dot11FragmentationThreshold */
4969 +#define DOT11_MIN_FRAG_LEN 256
4970 +#define DOT11_MAX_FRAG_LEN 2346 /* Max frag is also limited by aMPDUMaxLength of the attached PHY */
4971 +#define DOT11_DEFAULT_FRAG_LEN 2346
4972 +
4973 +/* dot11BeaconPeriod */
4974 +#define DOT11_MIN_BEACON_PERIOD 1
4975 +#define DOT11_MAX_BEACON_PERIOD 0xFFFF
4976 +
4977 +/* dot11DTIMPeriod */
4978 +#define DOT11_MIN_DTIM_PERIOD 1
4979 +#define DOT11_MAX_DTIM_PERIOD 0xFF
4980 +
4981 +/* 802.2 LLC/SNAP header used by 802.11 per 802.1H */
4982 +#define DOT11_LLC_SNAP_HDR_LEN 8
4983 +#define DOT11_OUI_LEN 3
4984 +struct dot11_llc_snap_header {
4985 + uint8 dsap; /* always 0xAA */
4986 + uint8 ssap; /* always 0xAA */
4987 + uint8 ctl; /* always 0x03 */
4988 + uint8 oui[DOT11_OUI_LEN]; /* RFC1042: 0x00 0x00 0x00
4989 + Bridge-Tunnel: 0x00 0x00 0xF8 */
4990 + uint16 type; /* ethertype */
4991 +} PACKED;
4992 +
4993 +/* RFC1042 header used by 802.11 per 802.1H */
4994 +#define RFC1042_HDR_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN)
4995 +
4996 +/* Generic 802.11 MAC header */
4997 +/*
4998 + * N.B.: This struct reflects the full 4 address 802.11 MAC header.
4999 + * The fields are defined such that the shorter 1, 2, and 3
5000 + * address headers just use the first k fields.
5001 + */
5002 +struct dot11_header {
5003 + uint16 fc; /* frame control */
5004 + uint16 durid; /* duration/ID */
5005 + struct ether_addr a1; /* address 1 */
5006 + struct ether_addr a2; /* address 2 */
5007 + struct ether_addr a3; /* address 3 */
5008 + uint16 seq; /* sequence control */
5009 + struct ether_addr a4; /* address 4 */
5010 +} PACKED;
5011 +
5012 +/* Control frames */
5013 +
5014 +struct dot11_rts_frame {
5015 + uint16 fc; /* frame control */
5016 + uint16 durid; /* duration/ID */
5017 + struct ether_addr ra; /* receiver address */
5018 + struct ether_addr ta; /* transmitter address */
5019 +} PACKED;
5020 +#define DOT11_RTS_LEN 16
5021 +
5022 +struct dot11_cts_frame {
5023 + uint16 fc; /* frame control */
5024 + uint16 durid; /* duration/ID */
5025 + struct ether_addr ra; /* receiver address */
5026 +} PACKED;
5027 +#define DOT11_CTS_LEN 10
5028 +
5029 +struct dot11_ack_frame {
5030 + uint16 fc; /* frame control */
5031 + uint16 durid; /* duration/ID */
5032 + struct ether_addr ra; /* receiver address */
5033 +} PACKED;
5034 +#define DOT11_ACK_LEN 10
5035 +
5036 +struct dot11_ps_poll_frame {
5037 + uint16 fc; /* frame control */
5038 + uint16 durid; /* AID */
5039 + struct ether_addr bssid; /* receiver address, STA in AP */
5040 + struct ether_addr ta; /* transmitter address */
5041 +} PACKED;
5042 +#define DOT11_PS_POLL_LEN 16
5043 +
5044 +struct dot11_cf_end_frame {
5045 + uint16 fc; /* frame control */
5046 + uint16 durid; /* duration/ID */
5047 + struct ether_addr ra; /* receiver address */
5048 + struct ether_addr bssid; /* transmitter address, STA in AP */
5049 +} PACKED;
5050 +#define DOT11_CS_END_LEN 16
5051 +
5052 +/* Management frame header */
5053 +struct dot11_management_header {
5054 + uint16 fc; /* frame control */
5055 + uint16 durid; /* duration/ID */
5056 + struct ether_addr da; /* receiver address */
5057 + struct ether_addr sa; /* transmitter address */
5058 + struct ether_addr bssid; /* BSS ID */
5059 + uint16 seq; /* sequence control */
5060 +} PACKED;
5061 +#define DOT11_MGMT_HDR_LEN 24
5062 +
5063 +/* Management frame payloads */
5064 +
5065 +struct dot11_bcn_prb {
5066 + uint32 timestamp[2];
5067 + uint16 beacon_interval;
5068 + uint16 capability;
5069 +} PACKED;
5070 +#define DOT11_BCN_PRB_LEN 12
5071 +
5072 +struct dot11_auth {
5073 + uint16 alg; /* algorithm */
5074 + uint16 seq; /* sequence control */
5075 + uint16 status; /* status code */
5076 +} PACKED;
5077 +#define DOT11_AUTH_FIXED_LEN 6 /* length of auth frame without challenge info elt */
5078 +
5079 +struct dot11_assoc_req {
5080 + uint16 capability; /* capability information */
5081 + uint16 listen; /* listen interval */
5082 +} PACKED;
5083 +
5084 +struct dot11_assoc_resp {
5085 + uint16 capability; /* capability information */
5086 + uint16 status; /* status code */
5087 + uint16 aid; /* association ID */
5088 +} PACKED;
5089 +
5090 +struct dot11_action_measure {
5091 + uint8 category;
5092 + uint8 action;
5093 + uint8 token;
5094 + uint8 data[1];
5095 +} PACKED;
5096 +#define DOT11_ACTION_MEASURE_LEN 3
5097 +
5098 +/**************
5099 + 802.11h related definitions.
5100 +**************/
5101 +typedef struct {
5102 + uint8 id;
5103 + uint8 len;
5104 + uint8 power;
5105 +} dot11_power_cnst_t;
5106 +
5107 +typedef struct {
5108 + uint8 min;
5109 + uint8 max;
5110 +} dot11_power_cap_t;
5111 +
5112 +typedef struct {
5113 + uint8 id;
5114 + uint8 len;
5115 + uint8 tx_pwr;
5116 + uint8 margin;
5117 +} dot11_tpc_rep_t;
5118 +#define DOT11_MNG_IE_TPC_REPORT_LEN 2 /* length of IE data, not including 2 byte header */
5119 +
5120 +typedef struct {
5121 + uint8 id;
5122 + uint8 len;
5123 + uint8 first_channel;
5124 + uint8 num_channels;
5125 +} dot11_supp_channels_t;
5126 +
5127 +struct dot11_channel_switch {
5128 + uint8 id;
5129 + uint8 len;
5130 + uint8 mode;
5131 + uint8 channel;
5132 + uint8 count;
5133 +} PACKED;
5134 +typedef struct dot11_channel_switch dot11_channel_switch_t;
5135 +
5136 +/* 802.11h Measurement Request/Report IEs */
5137 +/* Measurement Type field */
5138 +#define DOT11_MEASURE_TYPE_BASIC 0
5139 +#define DOT11_MEASURE_TYPE_CCA 1
5140 +#define DOT11_MEASURE_TYPE_RPI 2
5141 +
5142 +/* Measurement Mode field */
5143 +
5144 +/* Measurement Request Modes */
5145 +#define DOT11_MEASURE_MODE_ENABLE (1<<1)
5146 +#define DOT11_MEASURE_MODE_REQUEST (1<<2)
5147 +#define DOT11_MEASURE_MODE_REPORT (1<<3)
5148 +/* Measurement Report Modes */
5149 +#define DOT11_MEASURE_MODE_LATE (1<<0)
5150 +#define DOT11_MEASURE_MODE_INCAPABLE (1<<1)
5151 +#define DOT11_MEASURE_MODE_REFUSED (1<<2)
5152 +/* Basic Measurement Map bits */
5153 +#define DOT11_MEASURE_BASIC_MAP_BSS ((uint8)(1<<0))
5154 +#define DOT11_MEASURE_BASIC_MAP_OFDM ((uint8)(1<<1))
5155 +#define DOT11_MEASURE_BASIC_MAP_UKNOWN ((uint8)(1<<2))
5156 +#define DOT11_MEASURE_BASIC_MAP_RADAR ((uint8)(1<<3))
5157 +#define DOT11_MEASURE_BASIC_MAP_UNMEAS ((uint8)(1<<4))
5158 +
5159 +typedef struct {
5160 + uint8 id;
5161 + uint8 len;
5162 + uint8 token;
5163 + uint8 mode;
5164 + uint8 type;
5165 + uint8 channel;
5166 + uint8 start_time[8];
5167 + uint16 duration;
5168 +} dot11_meas_req_t;
5169 +#define DOT11_MNG_IE_MREQ_LEN 14
5170 +/* length of Measure Request IE data not including variable len */
5171 +#define DOT11_MNG_IE_MREQ_FIXED_LEN 3
5172 +
5173 +struct dot11_meas_rep {
5174 + uint8 id;
5175 + uint8 len;
5176 + uint8 token;
5177 + uint8 mode;
5178 + uint8 type;
5179 + union
5180 + {
5181 + struct {
5182 + uint8 channel;
5183 + uint8 start_time[8];
5184 + uint16 duration;
5185 + uint8 map;
5186 + } PACKED basic;
5187 + uint8 data[1];
5188 + } PACKED rep;
5189 +} PACKED;
5190 +typedef struct dot11_meas_rep dot11_meas_rep_t;
5191 +
5192 +/* length of Measure Report IE data not including variable len */
5193 +#define DOT11_MNG_IE_MREP_FIXED_LEN 3
5194 +
5195 +struct dot11_meas_rep_basic {
5196 + uint8 channel;
5197 + uint8 start_time[8];
5198 + uint16 duration;
5199 + uint8 map;
5200 +} PACKED;
5201 +typedef struct dot11_meas_rep_basic dot11_meas_rep_basic_t;
5202 +#define DOT11_MEASURE_BASIC_REP_LEN 12
5203 +
5204 +struct dot11_quiet {
5205 + uint8 id;
5206 + uint8 len;
5207 + uint8 count; /* TBTTs until beacon interval in quiet starts */
5208 + uint8 period; /* Beacon intervals between periodic quiet periods ? */
5209 + uint16 duration;/* Length of quiet period, in TU's */
5210 + uint16 offset; /* TU's offset from TBTT in Count field */
5211 +} PACKED;
5212 +typedef struct dot11_quiet dot11_quiet_t;
5213 +
5214 +typedef struct {
5215 + uint8 channel;
5216 + uint8 map;
5217 +} chan_map_tuple_t;
5218 +
5219 +typedef struct {
5220 + uint8 id;
5221 + uint8 len;
5222 + uint8 eaddr[ETHER_ADDR_LEN];
5223 + uint8 interval;
5224 + chan_map_tuple_t map[1];
5225 +} dot11_ibss_dfs_t;
5226 +
5227 +/* WME Elements */
5228 +#define WME_OUI "\x00\x50\xf2"
5229 +#define WME_VER 1
5230 +#define WME_TYPE 2
5231 +#define WME_SUBTYPE_IE 0 /* Information Element */
5232 +#define WME_SUBTYPE_PARAM_IE 1 /* Parameter Element */
5233 +#define WME_SUBTYPE_TSPEC 2 /* Traffic Specification */
5234 +
5235 +/* WME Access Category Indices (ACIs) */
5236 +#define AC_BE 0 /* Best Effort */
5237 +#define AC_BK 1 /* Background */
5238 +#define AC_VI 2 /* Video */
5239 +#define AC_VO 3 /* Voice */
5240 +#define AC_MAX 4
5241 +
5242 +/* WME Information Element (IE) */
5243 +struct wme_ie {
5244 + uint8 oui[3];
5245 + uint8 type;
5246 + uint8 subtype;
5247 + uint8 version;
5248 + uint8 acinfo;
5249 +} PACKED;
5250 +typedef struct wme_ie wme_ie_t;
5251 +#define WME_IE_LEN 7
5252 +
5253 +struct wme_acparam {
5254 + uint8 ACI;
5255 + uint8 ECW;
5256 + uint16 TXOP; /* stored in network order (ls octet first) */
5257 +} PACKED;
5258 +typedef struct wme_acparam wme_acparam_t;
5259 +
5260 +/* WME Parameter Element (PE) */
5261 +struct wme_params {
5262 + uint8 oui[3];
5263 + uint8 type;
5264 + uint8 subtype;
5265 + uint8 version;
5266 + uint8 acinfo;
5267 + uint8 rsvd;
5268 + wme_acparam_t acparam[4];
5269 +} PACKED;
5270 +typedef struct wme_params wme_params_t;
5271 +#define WME_PARAMS_IE_LEN 24
5272 +
5273 +/* acinfo */
5274 +#define WME_COUNT_MASK 0x0f
5275 +/* ACI */
5276 +#define WME_AIFS_MASK 0x0f
5277 +#define WME_ACM_MASK 0x10
5278 +#define WME_ACI_MASK 0x60
5279 +#define WME_ACI_SHIFT 5
5280 +/* ECW */
5281 +#define WME_CWMIN_MASK 0x0f
5282 +#define WME_CWMAX_MASK 0xf0
5283 +#define WME_CWMAX_SHIFT 4
5284 +
5285 +#define WME_TXOP_UNITS 32
5286 +
5287 +/* AP: default params to be announced in the Beacon Frames/Probe Responses Table 12 WME Draft*/
5288 +/* AP: default params to be Used in the AP Side Table 14 WME Draft January 2004 802.11-03-504r5 */
5289 +#define WME_AC_BK_ACI_STA 0x27
5290 +#define WME_AC_BK_ECW_STA 0xA4
5291 +#define WME_AC_BK_TXOP_STA 0x0000
5292 +#define WME_AC_BE_ACI_STA 0x03
5293 +#define WME_AC_BE_ECW_STA 0xA4
5294 +#define WME_AC_BE_TXOP_STA 0x0000
5295 +#define WME_AC_VI_ACI_STA 0x42
5296 +#define WME_AC_VI_ECW_STA 0x43
5297 +#define WME_AC_VI_TXOP_STA 0x005e
5298 +#define WME_AC_VO_ACI_STA 0x62
5299 +#define WME_AC_VO_ECW_STA 0x32
5300 +#define WME_AC_VO_TXOP_STA 0x002f
5301 +
5302 +#define WME_AC_BK_ACI_AP 0x27
5303 +#define WME_AC_BK_ECW_AP 0xA4
5304 +#define WME_AC_BK_TXOP_AP 0x0000
5305 +#define WME_AC_BE_ACI_AP 0x03
5306 +#define WME_AC_BE_ECW_AP 0x64
5307 +#define WME_AC_BE_TXOP_AP 0x0000
5308 +#define WME_AC_VI_ACI_AP 0x41
5309 +#define WME_AC_VI_ECW_AP 0x43
5310 +#define WME_AC_VI_TXOP_AP 0x005e
5311 +#define WME_AC_VO_ACI_AP 0x61
5312 +#define WME_AC_VO_ECW_AP 0x32
5313 +#define WME_AC_VO_TXOP_AP 0x002f
5314 +
5315 +/* WME Traffic Specification (TSPEC) element */
5316 +#define WME_SUBTYPE_TSPEC 2
5317 +#define WME_TSPEC_HDR_LEN 2
5318 +#define WME_TSPEC_BODY_OFF 2
5319 +struct wme_tspec {
5320 + uint8 oui[DOT11_OUI_LEN]; /* WME_OUI */
5321 + uint8 type; /* WME_TYPE */
5322 + uint8 subtype; /* WME_SUBTYPE_TSPEC */
5323 + uint8 version; /* WME_VERSION */
5324 + uint16 ts_info; /* TS Info */
5325 + uint16 nom_msdu_size; /* (Nominal or fixed) MSDU Size (bytes) */
5326 + uint16 max_msdu_size; /* Maximum MSDU Size (bytes) */
5327 + uint32 min_service_interval; /* Minimum Service Interval (us) */
5328 + uint32 max_service_interval; /* Maximum Service Interval (us) */
5329 + uint32 inactivity_interval; /* Inactivity Interval (us) */
5330 + uint32 service_start; /* Service Start Time (us) */
5331 + uint32 min_rate; /* Minimum Data Rate (bps) */
5332 + uint32 mean_rate; /* Mean Data Rate (bps) */
5333 + uint32 max_burst_size; /* Maximum Burst Size (bytes) */
5334 + uint32 min_phy_rate; /* Minimum PHY Rate (bps) */
5335 + uint32 peak_rate; /* Peak Data Rate (bps) */
5336 + uint32 delay_bound; /* Delay Bound (us) */
5337 + uint16 surplus_bandwidth; /* Surplus Bandwidth Allowance Factor */
5338 + uint16 medium_time; /* Medium Time (32 us/s periods) */
5339 +} PACKED;
5340 +typedef struct wme_tspec wme_tspec_t;
5341 +#define WME_TSPEC_LEN 56 /* not including 2-byte header */
5342 +
5343 +/* ts_info */
5344 +/* 802.1D priority is duplicated - bits 13-11 AND bits 3-1 */
5345 +#define TS_INFO_PRIO_SHIFT_HI 11
5346 +#define TS_INFO_PRIO_MASK_HI (0x7 << TS_INFO_PRIO_SHIFT_HI)
5347 +#define TS_INFO_PRIO_SHIFT_LO 1
5348 +#define TS_INFO_PRIO_MASK_LO (0x7 << TS_INFO_PRIO_SHIFT_LO)
5349 +#define TS_INFO_CONTENTION_SHIFT 7
5350 +#define TS_INFO_CONTENTION_MASK (0x1 << TS_INFO_CONTENTION_SHIFT)
5351 +#define TS_INFO_DIRECTION_SHIFT 5
5352 +#define TS_INFO_DIRECTION_MASK (0x3 << TS_INFO_DIRECTION_SHIFT)
5353 +#define TS_INFO_UPLINK (0 << TS_INFO_DIRECTION_SHIFT)
5354 +#define TS_INFO_DOWNLINK (1 << TS_INFO_DIRECTION_SHIFT)
5355 +#define TS_INFO_BIDIRECTIONAL (3 << TS_INFO_DIRECTION_SHIFT)
5356 +
5357 +/* nom_msdu_size */
5358 +#define FIXED_MSDU_SIZE 0x8000 /* MSDU size is fixed */
5359 +#define MSDU_SIZE_MASK 0x7fff /* (Nominal or fixed) MSDU size */
5360 +
5361 +/* surplus_bandwidth */
5362 +/* Represented as 3 bits of integer, binary point, 13 bits fraction */
5363 +#define INTEGER_SHIFT 13
5364 +#define FRACTION_MASK 0x1FFF
5365 +
5366 +/* Management Notification Frame */
5367 +struct dot11_management_notification {
5368 + uint8 category; /* DOT11_ACTION_NOTIFICATION */
5369 + uint8 action;
5370 + uint8 token;
5371 + uint8 status;
5372 + uint8 data[1]; /* Elements */
5373 +} PACKED;
5374 +#define DOT11_MGMT_NOTIFICATION_LEN 4 /* Fixed length */
5375 +
5376 +/* WME Action Codes */
5377 +#define WME_SETUP_REQUEST 0
5378 +#define WME_SETUP_RESPONSE 1
5379 +#define WME_TEARDOWN 2
5380 +
5381 +/* WME Setup Response Status Codes */
5382 +#define WME_ADMISSION_ACCEPTED 0
5383 +#define WME_INVALID_PARAMETERS 1
5384 +#define WME_ADMISSION_REFUSED 3
5385 +
5386 +/* Macro to take a pointer to a beacon or probe response
5387 + * header and return the char* pointer to the SSID info element
5388 + */
5389 +#define BCN_PRB_SSID(hdr) ((char*)(hdr) + DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_LEN)
5390 +
5391 +/* Authentication frame payload constants */
5392 +#define DOT11_OPEN_SYSTEM 0
5393 +#define DOT11_SHARED_KEY 1
5394 +#define DOT11_CHALLENGE_LEN 128
5395 +
5396 +/* Frame control macros */
5397 +#define FC_PVER_MASK 0x3
5398 +#define FC_PVER_SHIFT 0
5399 +#define FC_TYPE_MASK 0xC
5400 +#define FC_TYPE_SHIFT 2
5401 +#define FC_SUBTYPE_MASK 0xF0
5402 +#define FC_SUBTYPE_SHIFT 4
5403 +#define FC_TODS 0x100
5404 +#define FC_TODS_SHIFT 8
5405 +#define FC_FROMDS 0x200
5406 +#define FC_FROMDS_SHIFT 9
5407 +#define FC_MOREFRAG 0x400
5408 +#define FC_MOREFRAG_SHIFT 10
5409 +#define FC_RETRY 0x800
5410 +#define FC_RETRY_SHIFT 11
5411 +#define FC_PM 0x1000
5412 +#define FC_PM_SHIFT 12
5413 +#define FC_MOREDATA 0x2000
5414 +#define FC_MOREDATA_SHIFT 13
5415 +#define FC_WEP 0x4000
5416 +#define FC_WEP_SHIFT 14
5417 +#define FC_ORDER 0x8000
5418 +#define FC_ORDER_SHIFT 15
5419 +
5420 +/* sequence control macros */
5421 +#define SEQNUM_SHIFT 4
5422 +#define FRAGNUM_MASK 0xF
5423 +
5424 +/* Frame Control type/subtype defs */
5425 +
5426 +/* FC Types */
5427 +#define FC_TYPE_MNG 0
5428 +#define FC_TYPE_CTL 1
5429 +#define FC_TYPE_DATA 2
5430 +
5431 +/* Management Subtypes */
5432 +#define FC_SUBTYPE_ASSOC_REQ 0
5433 +#define FC_SUBTYPE_ASSOC_RESP 1
5434 +#define FC_SUBTYPE_REASSOC_REQ 2
5435 +#define FC_SUBTYPE_REASSOC_RESP 3
5436 +#define FC_SUBTYPE_PROBE_REQ 4
5437 +#define FC_SUBTYPE_PROBE_RESP 5
5438 +#define FC_SUBTYPE_BEACON 8
5439 +#define FC_SUBTYPE_ATIM 9
5440 +#define FC_SUBTYPE_DISASSOC 10
5441 +#define FC_SUBTYPE_AUTH 11
5442 +#define FC_SUBTYPE_DEAUTH 12
5443 +#define FC_SUBTYPE_ACTION 13
5444 +
5445 +/* Control Subtypes */
5446 +#define FC_SUBTYPE_PS_POLL 10
5447 +#define FC_SUBTYPE_RTS 11
5448 +#define FC_SUBTYPE_CTS 12
5449 +#define FC_SUBTYPE_ACK 13
5450 +#define FC_SUBTYPE_CF_END 14
5451 +#define FC_SUBTYPE_CF_END_ACK 15
5452 +
5453 +/* Data Subtypes */
5454 +#define FC_SUBTYPE_DATA 0
5455 +#define FC_SUBTYPE_DATA_CF_ACK 1
5456 +#define FC_SUBTYPE_DATA_CF_POLL 2
5457 +#define FC_SUBTYPE_DATA_CF_ACK_POLL 3
5458 +#define FC_SUBTYPE_NULL 4
5459 +#define FC_SUBTYPE_CF_ACK 5
5460 +#define FC_SUBTYPE_CF_POLL 6
5461 +#define FC_SUBTYPE_CF_ACK_POLL 7
5462 +#define FC_SUBTYPE_QOS_DATA 8
5463 +#define FC_SUBTYPE_QOS_NULL 12
5464 +
5465 +/* type-subtype combos */
5466 +#define FC_KIND_MASK (FC_TYPE_MASK | FC_SUBTYPE_MASK)
5467 +
5468 +#define FC_KIND(t, s) (((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT))
5469 +
5470 +#define FC_ASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_REQ)
5471 +#define FC_ASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_RESP)
5472 +#define FC_REASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_REQ)
5473 +#define FC_REASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_RESP)
5474 +#define FC_PROBE_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_REQ)
5475 +#define FC_PROBE_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_RESP)
5476 +#define FC_BEACON FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_BEACON)
5477 +#define FC_DISASSOC FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DISASSOC)
5478 +#define FC_AUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_AUTH)
5479 +#define FC_DEAUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DEAUTH)
5480 +#define FC_ACTION FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ACTION)
5481 +
5482 +#define FC_PS_POLL FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_PS_POLL)
5483 +#define FC_RTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_RTS)
5484 +#define FC_CTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTS)
5485 +#define FC_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_ACK)
5486 +#define FC_CF_END FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END)
5487 +#define FC_CF_END_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END_ACK)
5488 +
5489 +#define FC_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA)
5490 +#define FC_NULL_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_NULL)
5491 +#define FC_DATA_CF_ACK FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA_CF_ACK)
5492 +#define FC_QOS_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_DATA)
5493 +#define FC_QOS_NULL FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_NULL)
5494 +
5495 +/* QoS Control Field */
5496 +
5497 +/* 802.1D Tag */
5498 +#define QOS_PRIO_SHIFT 0
5499 +#define QOS_PRIO_MASK 0x0007
5500 +#define QOS_PRIO(qos) (((qos) & QOS_PRIO_MASK) >> QOS_PRIO_SHIFT)
5501 +
5502 +/* Ack Policy (0 means Acknowledge) */
5503 +#define QOS_ACK_SHIFT 5
5504 +#define QOS_ACK_MASK 0x0060
5505 +#define QOS_ACK(qos) (((qos) & QOS_ACK_MASK) >> QOS_ACK_SHIFT)
5506 +
5507 +/* Management Frames */
5508 +
5509 +/* Management Frame Constants */
5510 +
5511 +/* Fixed fields */
5512 +#define DOT11_MNG_AUTH_ALGO_LEN 2
5513 +#define DOT11_MNG_AUTH_SEQ_LEN 2
5514 +#define DOT11_MNG_BEACON_INT_LEN 2
5515 +#define DOT11_MNG_CAP_LEN 2
5516 +#define DOT11_MNG_AP_ADDR_LEN 6
5517 +#define DOT11_MNG_LISTEN_INT_LEN 2
5518 +#define DOT11_MNG_REASON_LEN 2
5519 +#define DOT11_MNG_AID_LEN 2
5520 +#define DOT11_MNG_STATUS_LEN 2
5521 +#define DOT11_MNG_TIMESTAMP_LEN 8
5522 +
5523 +/* DUR/ID field in assoc resp is 0xc000 | AID */
5524 +#define DOT11_AID_MASK 0x3fff
5525 +
5526 +/* Reason Codes */
5527 +#define DOT11_RC_RESERVED 0
5528 +#define DOT11_RC_UNSPECIFIED 1 /* Unspecified reason */
5529 +#define DOT11_RC_AUTH_INVAL 2 /* Previous authentication no longer valid */
5530 +#define DOT11_RC_DEAUTH_LEAVING 3 /* Deauthenticated because sending station is
5531 + leaving (or has left) IBSS or ESS */
5532 +#define DOT11_RC_INACTIVITY 4 /* Disassociated due to inactivity */
5533 +#define DOT11_RC_BUSY 5 /* Disassociated because AP is unable to handle
5534 + all currently associated stations */
5535 +#define DOT11_RC_INVAL_CLASS_2 6 /* Class 2 frame received from
5536 + nonauthenticated station */
5537 +#define DOT11_RC_INVAL_CLASS_3 7 /* Class 3 frame received from
5538 + nonassociated station */
5539 +#define DOT11_RC_DISASSOC_LEAVING 8 /* Disassociated because sending station is
5540 + leaving (or has left) BSS */
5541 +#define DOT11_RC_NOT_AUTH 9 /* Station requesting (re)association is
5542 + not authenticated with responding station */
5543 +#define DOT11_RC_MAX 23 /* Reason codes > 23 are reserved */
5544 +
5545 +/* Status Codes */
5546 +#define DOT11_STATUS_SUCCESS 0 /* Successful */
5547 +#define DOT11_STATUS_FAILURE 1 /* Unspecified failure */
5548 +#define DOT11_STATUS_CAP_MISMATCH 10 /* Cannot support all requested capabilities
5549 + in the Capability Information field */
5550 +#define DOT11_STATUS_REASSOC_FAIL 11 /* Reassociation denied due to inability to
5551 + confirm that association exists */
5552 +#define DOT11_STATUS_ASSOC_FAIL 12 /* Association denied due to reason outside
5553 + the scope of this standard */
5554 +#define DOT11_STATUS_AUTH_MISMATCH 13 /* Responding station does not support the
5555 + specified authentication algorithm */
5556 +#define DOT11_STATUS_AUTH_SEQ 14 /* Received an Authentication frame with
5557 + authentication transaction sequence number
5558 + out of expected sequence */
5559 +#define DOT11_STATUS_AUTH_CHALLENGE_FAIL 15 /* Authentication rejected because of challenge failure */
5560 +#define DOT11_STATUS_AUTH_TIMEOUT 16 /* Authentication rejected due to timeout waiting
5561 + for next frame in sequence */
5562 +#define DOT11_STATUS_ASSOC_BUSY_FAIL 17 /* Association denied because AP is unable to
5563 + handle additional associated stations */
5564 +#define DOT11_STATUS_ASSOC_RATE_MISMATCH 18 /* Association denied due to requesting station
5565 + not supporting all of the data rates in the
5566 + BSSBasicRateSet parameter */
5567 +#define DOT11_STATUS_ASSOC_SHORT_REQUIRED 19 /* Association denied due to requesting station
5568 + not supporting the Short Preamble option */
5569 +#define DOT11_STATUS_ASSOC_PBCC_REQUIRED 20 /* Association denied due to requesting station
5570 + not supporting the PBCC Modulation option */
5571 +#define DOT11_STATUS_ASSOC_AGILITY_REQUIRED 21 /* Association denied due to requesting station
5572 + not supporting the Channel Agility option */
5573 +#define DOT11_STATUS_ASSOC_SPECTRUM_REQUIRED 22 /* Association denied because Spectrum Management
5574 + capability is required. */
5575 +#define DOT11_STATUS_ASSOC_BAD_POWER_CAP 23 /* Association denied because the info in the
5576 + Power Cap element is unacceptable. */
5577 +#define DOT11_STATUS_ASSOC_BAD_SUP_CHANNELS 24 /* Association denied because the info in the
5578 + Supported Channel element is unacceptable */
5579 +#define DOT11_STATUS_ASSOC_SHORTSLOT_REQUIRED 25 /* Association denied due to requesting station
5580 + not supporting the Short Slot Time option */
5581 +#define DOT11_STATUS_ASSOC_ERPBCC_REQUIRED 26 /* Association denied due to requesting station
5582 + not supporting the ER-PBCC Modulation option */
5583 +#define DOT11_STATUS_ASSOC_DSSOFDM_REQUIRED 27 /* Association denied due to requesting station
5584 + not supporting the DSS-OFDM option */
5585 +
5586 +/* Info Elts, length of INFORMATION portion of Info Elts */
5587 +#define DOT11_MNG_DS_PARAM_LEN 1
5588 +#define DOT11_MNG_IBSS_PARAM_LEN 2
5589 +
5590 +/* TIM Info element has 3 bytes fixed info in INFORMATION field,
5591 + * followed by 1 to 251 bytes of Partial Virtual Bitmap */
5592 +#define DOT11_MNG_TIM_FIXED_LEN 3
5593 +#define DOT11_MNG_TIM_DTIM_COUNT 0
5594 +#define DOT11_MNG_TIM_DTIM_PERIOD 1
5595 +#define DOT11_MNG_TIM_BITMAP_CTL 2
5596 +#define DOT11_MNG_TIM_PVB 3
5597 +
5598 +/* TLV defines */
5599 +#define TLV_TAG_OFF 0
5600 +#define TLV_LEN_OFF 1
5601 +#define TLV_HDR_LEN 2
5602 +#define TLV_BODY_OFF 2
5603 +
5604 +/* Management Frame Information Element IDs */
5605 +#define DOT11_MNG_SSID_ID 0
5606 +#define DOT11_MNG_RATES_ID 1
5607 +#define DOT11_MNG_FH_PARMS_ID 2
5608 +#define DOT11_MNG_DS_PARMS_ID 3
5609 +#define DOT11_MNG_CF_PARMS_ID 4
5610 +#define DOT11_MNG_TIM_ID 5
5611 +#define DOT11_MNG_IBSS_PARMS_ID 6
5612 +#define DOT11_MNG_COUNTRY_ID 7
5613 +#define DOT11_MNG_HOPPING_PARMS_ID 8
5614 +#define DOT11_MNG_HOPPING_TABLE_ID 9
5615 +#define DOT11_MNG_REQUEST_ID 10
5616 +#define DOT11_MNG_CHALLENGE_ID 16
5617 +#define DOT11_MNG_PWR_CONSTRAINT_ID 32 /* 11H PowerConstraint */
5618 +#define DOT11_MNG_PWR_CAP_ID 33 /* 11H PowerCapability */
5619 +#define DOT11_MNG_TPC_REQUEST_ID 34 /* 11H TPC Request */
5620 +#define DOT11_MNG_TPC_REPORT_ID 35 /* 11H TPC Report */
5621 +#define DOT11_MNG_SUPP_CHANNELS_ID 36 /* 11H Supported Channels */
5622 +#define DOT11_MNG_CHANNEL_SWITCH_ID 37 /* 11H ChannelSwitch Announcement*/
5623 +#define DOT11_MNG_MEASURE_REQUEST_ID 38 /* 11H MeasurementRequest */
5624 +#define DOT11_MNG_MEASURE_REPORT_ID 39 /* 11H MeasurementReport */
5625 +#define DOT11_MNG_QUIET_ID 40 /* 11H Quiet */
5626 +#define DOT11_MNG_IBSS_DFS_ID 41 /* 11H IBSS_DFS */
5627 +#define DOT11_MNG_ERP_ID 42
5628 +#define DOT11_MNG_NONERP_ID 47
5629 +#define DOT11_MNG_RSN_ID 48
5630 +#define DOT11_MNG_EXT_RATES_ID 50
5631 +#define DOT11_MNG_WPA_ID 221
5632 +#define DOT11_MNG_PROPR_ID 221
5633 +
5634 +/* ERP info element bit values */
5635 +#define DOT11_MNG_ERP_LEN 1 /* ERP is currently 1 byte long */
5636 +#define DOT11_MNG_NONERP_PRESENT 0x01 /* NonERP (802.11b) STAs are present in the BSS */
5637 +#define DOT11_MNG_USE_PROTECTION 0x02 /* Use protection mechanisms for ERP-OFDM frames */
5638 +#define DOT11_MNG_BARKER_PREAMBLE 0x04 /* Short Preambles: 0 == allowed, 1 == not allowed */
5639 +
5640 +/* Capability Information Field */
5641 +#define DOT11_CAP_ESS 0x0001
5642 +#define DOT11_CAP_IBSS 0x0002
5643 +#define DOT11_CAP_POLLABLE 0x0004
5644 +#define DOT11_CAP_POLL_RQ 0x0008
5645 +#define DOT11_CAP_PRIVACY 0x0010
5646 +#define DOT11_CAP_SHORT 0x0020
5647 +#define DOT11_CAP_PBCC 0x0040
5648 +#define DOT11_CAP_AGILITY 0x0080
5649 +#define DOT11_CAP_SPECTRUM 0x0100
5650 +#define DOT11_CAP_SHORTSLOT 0x0400
5651 +#define DOT11_CAP_CCK_OFDM 0x2000
5652 +
5653 +/* Action Frame Constants */
5654 +#define DOT11_ACTION_CAT_ERR_MASK 0x80
5655 +#define DOT11_ACTION_CAT_SPECT_MNG 0x00
5656 +#define DOT11_ACTION_NOTIFICATION 0x11 /* 17 */
5657 +
5658 +#define DOT11_ACTION_ID_M_REQ 0
5659 +#define DOT11_ACTION_ID_M_REP 1
5660 +#define DOT11_ACTION_ID_TPC_REQ 2
5661 +#define DOT11_ACTION_ID_TPC_REP 3
5662 +#define DOT11_ACTION_ID_CHANNEL_SWITCH 4
5663 +
5664 +/* MLME Enumerations */
5665 +#define DOT11_BSSTYPE_INFRASTRUCTURE 0
5666 +#define DOT11_BSSTYPE_INDEPENDENT 1
5667 +#define DOT11_BSSTYPE_ANY 2
5668 +#define DOT11_SCANTYPE_ACTIVE 0
5669 +#define DOT11_SCANTYPE_PASSIVE 1
5670 +
5671 +/* 802.11 A PHY constants */
5672 +#define APHY_SLOT_TIME 9
5673 +#define APHY_SIFS_TIME 16
5674 +#define APHY_DIFS_TIME (APHY_SIFS_TIME + (2 * APHY_SLOT_TIME))
5675 +#define APHY_PREAMBLE_TIME 16
5676 +#define APHY_SIGNAL_TIME 4
5677 +#define APHY_SYMBOL_TIME 4
5678 +#define APHY_SERVICE_NBITS 16
5679 +#define APHY_TAIL_NBITS 6
5680 +#define APHY_CWMIN 15
5681 +
5682 +/* 802.11 B PHY constants */
5683 +#define BPHY_SLOT_TIME 20
5684 +#define BPHY_SIFS_TIME 10
5685 +#define BPHY_DIFS_TIME 50
5686 +#define BPHY_PLCP_TIME 192
5687 +#define BPHY_PLCP_SHORT_TIME 96
5688 +#define BPHY_CWMIN 31
5689 +
5690 +/* 802.11 G constants */
5691 +#define DOT11_OFDM_SIGNAL_EXTENSION 6
5692 +
5693 +#define PHY_CWMAX 1023
5694 +
5695 +#define DOT11_MAXNUMFRAGS 16 /* max # fragments per MSDU */
5696 +
5697 +/* dot11Counters Table - 802.11 spec., Annex D */
5698 +typedef struct d11cnt {
5699 + uint32 txfrag; /* dot11TransmittedFragmentCount */
5700 + uint32 txmulti; /* dot11MulticastTransmittedFrameCount */
5701 + uint32 txfail; /* dot11FailedCount */
5702 + uint32 txretry; /* dot11RetryCount */
5703 + uint32 txretrie; /* dot11MultipleRetryCount */
5704 + uint32 rxdup; /* dot11FrameduplicateCount */
5705 + uint32 txrts; /* dot11RTSSuccessCount */
5706 + uint32 txnocts; /* dot11RTSFailureCount */
5707 + uint32 txnoack; /* dot11ACKFailureCount */
5708 + uint32 rxfrag; /* dot11ReceivedFragmentCount */
5709 + uint32 rxmulti; /* dot11MulticastReceivedFrameCount */
5710 + uint32 rxcrc; /* dot11FCSErrorCount */
5711 + uint32 txfrmsnt; /* dot11TransmittedFrameCount */
5712 + uint32 rxundec; /* dot11WEPUndecryptableCount */
5713 +} d11cnt_t;
5714 +
5715 +/* BRCM OUI */
5716 +#define BRCM_OUI "\x00\x10\x18"
5717 +
5718 +/* BRCM info element */
5719 +struct brcm_ie {
5720 + uchar id; /* 221, DOT11_MNG_PROPR_ID */
5721 + uchar len;
5722 + uchar oui[3];
5723 + uchar ver;
5724 + uchar assoc; /* # of assoc STAs */
5725 + uchar flags; /* misc flags */
5726 +} PACKED;
5727 +#define BRCM_IE_LEN 8
5728 +typedef struct brcm_ie brcm_ie_t;
5729 +#define BRCM_IE_VER 2
5730 +#define BRCM_IE_LEGACY_AES_VER 1
5731 +
5732 +/* brcm_ie flags */
5733 +#define BRF_ABCAP 0x1 /* afterburner capable */
5734 +#define BRF_ABRQRD 0x2 /* afterburner requested */
5735 +#define BRF_LZWDS 0x4 /* lazy wds enabled */
5736 +
5737 +
5738 +/* OUI for BRCM proprietary IE */
5739 +#define BRCM_PROP_OUI "\x00\x90\x4C"
5740 +
5741 +/* Vendor IE structure */
5742 +struct vndr_ie {
5743 + uchar id;
5744 + uchar len;
5745 + uchar oui [3];
5746 + uchar data [1]; /* Variable size data */
5747 +}PACKED;
5748 +typedef struct vndr_ie vndr_ie_t;
5749 +
5750 +#define VNDR_IE_HDR_LEN 2 /* id + len field */
5751 +#define VNDR_IE_MIN_LEN 3 /* size of the oui field */
5752 +#define VNDR_IE_MAX_LEN 256
5753 +
5754 +/* WPA definitions */
5755 +#define WPA_VERSION 1
5756 +#define WPA_OUI "\x00\x50\xF2"
5757 +
5758 +#define WPA2_VERSION 1
5759 +#define WPA2_VERSION_LEN 2
5760 +#define WPA2_OUI "\x00\x0F\xAC"
5761 +
5762 +#define WPA_OUI_LEN 3
5763 +
5764 +/* RSN authenticated key managment suite */
5765 +#define RSN_AKM_NONE 0 /* None (IBSS) */
5766 +#define RSN_AKM_UNSPECIFIED 1 /* Over 802.1x */
5767 +#define RSN_AKM_PSK 2 /* Pre-shared Key */
5768 +
5769 +
5770 +/* Key related defines */
5771 +#define DOT11_MAX_DEFAULT_KEYS 4 /* number of default keys */
5772 +#define DOT11_MAX_KEY_SIZE 32 /* max size of any key */
5773 +#define DOT11_MAX_IV_SIZE 16 /* max size of any IV */
5774 +#define DOT11_EXT_IV_FLAG (1<<5) /* flag to indicate IV is > 4 bytes */
5775 +
5776 +#define WEP1_KEY_SIZE 5 /* max size of any WEP key */
5777 +#define WEP1_KEY_HEX_SIZE 10 /* size of WEP key in hex. */
5778 +#define WEP128_KEY_SIZE 13 /* max size of any WEP key */
5779 +#define WEP128_KEY_HEX_SIZE 26 /* size of WEP key in hex. */
5780 +#define TKIP_MIC_SIZE 8 /* size of TKIP MIC */
5781 +#define TKIP_EOM_SIZE 7 /* max size of TKIP EOM */
5782 +#define TKIP_EOM_FLAG 0x5a /* TKIP EOM flag byte */
5783 +#define TKIP_KEY_SIZE 32 /* size of any TKIP key */
5784 +#define TKIP_MIC_AUTH_TX 16 /* offset to Authenticator MIC TX key */
5785 +#define TKIP_MIC_AUTH_RX 24 /* offset to Authenticator MIC RX key */
5786 +#define TKIP_MIC_SUP_RX 16 /* offset to Supplicant MIC RX key */
5787 +#define TKIP_MIC_SUP_TX 24 /* offset to Supplicant MIC TX key */
5788 +#define AES_KEY_SIZE 16 /* size of AES key */
5789 +
5790 +#undef PACKED
5791 +#if !defined(__GNUC__)
5792 +#pragma pack()
5793 +#endif
5794 +
5795 +#endif /* _802_11_H_ */
5796 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/proto/bcmeth.h linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/bcmeth.h
5797 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/bcmeth.h 1970-01-01 01:00:00.000000000 +0100
5798 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/bcmeth.h 2005-08-22 01:34:46.327150856 +0200
5799 @@ -0,0 +1,97 @@
5800 +/*
5801 + * Broadcom Ethernettype protocol definitions
5802 + *
5803 + * Copyright 2005, Broadcom Corporation
5804 + * All Rights Reserved.
5805 + *
5806 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5807 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5808 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5809 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5810 + *
5811 + */
5812 +
5813 +/*
5814 + * Broadcom Ethernet protocol defines
5815 + *
5816 + */
5817 +
5818 +#ifndef _BCMETH_H_
5819 +#define _BCMETH_H_
5820 +
5821 +/* enable structure packing */
5822 +#if defined(__GNUC__)
5823 +#define PACKED __attribute__((packed))
5824 +#else
5825 +#pragma pack(1)
5826 +#define PACKED
5827 +#endif
5828 +
5829 +/* ETHER_TYPE_BRCM is defined in ethernet.h */
5830 +
5831 +/*
5832 + * Following the 2byte BRCM ether_type is a 16bit BRCM subtype field
5833 + * in one of two formats: (only subtypes 32768-65535 are in use now)
5834 + *
5835 + * subtypes 0-32767:
5836 + * 8 bit subtype (0-127)
5837 + * 8 bit length in bytes (0-255)
5838 + *
5839 + * subtypes 32768-65535:
5840 + * 16 bit big-endian subtype
5841 + * 16 bit big-endian length in bytes (0-65535)
5842 + *
5843 + * length is the number of additional bytes beyond the 4 or 6 byte header
5844 + *
5845 + * Reserved values:
5846 + * 0 reserved
5847 + * 5-15 reserved for iLine protocol assignments
5848 + * 17-126 reserved, assignable
5849 + * 127 reserved
5850 + * 32768 reserved
5851 + * 32769-65534 reserved, assignable
5852 + * 65535 reserved
5853 + */
5854 +
5855 +/*
5856 + * While adding the subtypes and their specific processing code make sure
5857 + * bcmeth_bcm_hdr_t is the first data structure in the user specific data structure definition
5858 + */
5859 +
5860 +#define BCMILCP_SUBTYPE_RATE 1
5861 +#define BCMILCP_SUBTYPE_LINK 2
5862 +#define BCMILCP_SUBTYPE_CSA 3
5863 +#define BCMILCP_SUBTYPE_LARQ 4
5864 +#define BCMILCP_SUBTYPE_VENDOR 5
5865 +#define BCMILCP_SUBTYPE_FLH 17
5866 +
5867 +#define BCMILCP_SUBTYPE_VENDOR_LONG 32769
5868 +#define BCMILCP_SUBTYPE_CERT 32770
5869 +#define BCMILCP_SUBTYPE_SES 32771
5870 +
5871 +
5872 +#define BCMILCP_BCM_SUBTYPE_RESERVED 0
5873 +#define BCMILCP_BCM_SUBTYPE_WPA 1
5874 +#define BCMILCP_BCM_SUBTYPE_EAPOL 2
5875 +#define BCMILCP_BCM_SUBTYPE_SES 3
5876 +
5877 +#define BCMILCP_BCM_SUBTYPEHDR_MINLENGTH 8
5878 +#define BCMILCP_BCM_SUBTYPEHDR_VERSION 0
5879 +
5880 +typedef struct bcmeth_bcm_hdr
5881 +{
5882 + uint16 subtype; /* Vendor specific..32769*/
5883 + uint16 length;
5884 + uint8 version; /* Version is 0*/
5885 + uint8 oui[3]; /* Broadcom OUI*/
5886 + /* user specific Data */
5887 + uint16 usr_subtype;
5888 +} PACKED bcmeth_bcm_hdr_t;
5889 +
5890 +
5891 +#undef PACKED
5892 +#if !defined(__GNUC__)
5893 +#pragma pack()
5894 +#endif
5895 +
5896 +#endif
5897 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/proto/ethernet.h linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/ethernet.h
5898 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/ethernet.h 1970-01-01 01:00:00.000000000 +0100
5899 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/ethernet.h 2005-08-22 01:34:46.328150704 +0200
5900 @@ -0,0 +1,161 @@
5901 +/*******************************************************************************
5902 + * $Id$
5903 + * Copyright 2005, Broadcom Corporation
5904 + * All Rights Reserved.
5905 + *
5906 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5907 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5908 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5909 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5910 + * From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
5911 + ******************************************************************************/
5912 +
5913 +#ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
5914 +#define _NET_ETHERNET_H_
5915 +
5916 +#ifndef _TYPEDEFS_H_
5917 +#include "typedefs.h"
5918 +#endif
5919 +
5920 +/* enable structure packing */
5921 +#if defined(__GNUC__)
5922 +#define PACKED __attribute__((packed))
5923 +#else
5924 +#pragma pack(1)
5925 +#define PACKED
5926 +#endif
5927 +
5928 +/*
5929 + * The number of bytes in an ethernet (MAC) address.
5930 + */
5931 +#define ETHER_ADDR_LEN 6
5932 +
5933 +/*
5934 + * The number of bytes in the type field.
5935 + */
5936 +#define ETHER_TYPE_LEN 2
5937 +
5938 +/*
5939 + * The number of bytes in the trailing CRC field.
5940 + */
5941 +#define ETHER_CRC_LEN 4
5942 +
5943 +/*
5944 + * The length of the combined header.
5945 + */
5946 +#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
5947 +
5948 +/*
5949 + * The minimum packet length.
5950 + */
5951 +#define ETHER_MIN_LEN 64
5952 +
5953 +/*
5954 + * The minimum packet user data length.
5955 + */
5956 +#define ETHER_MIN_DATA 46
5957 +
5958 +/*
5959 + * The maximum packet length.
5960 + */
5961 +#define ETHER_MAX_LEN 1518
5962 +
5963 +/*
5964 + * The maximum packet user data length.
5965 + */
5966 +#define ETHER_MAX_DATA 1500
5967 +
5968 +/* ether types */
5969 +#define ETHER_TYPE_IP 0x0800 /* IP */
5970 +#define ETHER_TYPE_ARP 0x0806 /* ARP */
5971 +#define ETHER_TYPE_8021Q 0x8100 /* 802.1Q */
5972 +#define ETHER_TYPE_BRCM 0x886c /* Broadcom Corp. */
5973 +#define ETHER_TYPE_802_1X 0x888e /* 802.1x */
5974 +#define ETHER_TYPE_802_1X_PREAUTH 0x88c7 /* 802.1x preauthentication*/
5975 +
5976 +/* Broadcom subtype follows ethertype; First 2 bytes are reserved; Next 2 are subtype; */
5977 +#define ETHER_BRCM_SUBTYPE_LEN 4 /* Broadcom 4 byte subtype */
5978 +#define ETHER_BRCM_CRAM 0x1 /* Broadcom subtype cram protocol */
5979 +
5980 +/* ether header */
5981 +#define ETHER_DEST_OFFSET 0 /* dest address offset */
5982 +#define ETHER_SRC_OFFSET 6 /* src address offset */
5983 +#define ETHER_TYPE_OFFSET 12 /* ether type offset */
5984 +
5985 +/*
5986 + * A macro to validate a length with
5987 + */
5988 +#define ETHER_IS_VALID_LEN(foo) \
5989 + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
5990 +
5991 +
5992 +#ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
5993 +/*
5994 + * Structure of a 10Mb/s Ethernet header.
5995 + */
5996 +struct ether_header {
5997 + uint8 ether_dhost[ETHER_ADDR_LEN];
5998 + uint8 ether_shost[ETHER_ADDR_LEN];
5999 + uint16 ether_type;
6000 +} PACKED;
6001 +
6002 +/*
6003 + * Structure of a 48-bit Ethernet address.
6004 + */
6005 +struct ether_addr {
6006 + uint8 octet[ETHER_ADDR_LEN];
6007 +} PACKED;
6008 +#endif
6009 +
6010 +/*
6011 + * Takes a pointer, returns true if a 48-bit multicast address
6012 + * (including broadcast, since it is all ones)
6013 + */
6014 +#define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
6015 +
6016 +/* compare two ethernet addresses - assumes the pointers can be referenced as shorts */
6017 +#define ether_cmp(a, b) ( \
6018 + !(((short*)a)[0] == ((short*)b)[0]) | \
6019 + !(((short*)a)[1] == ((short*)b)[1]) | \
6020 + !(((short*)a)[2] == ((short*)b)[2]))
6021 +
6022 +/* copy an ethernet address - assumes the pointers can be referenced as shorts */
6023 +#define ether_copy(s, d) { \
6024 + ((short*)d)[0] = ((short*)s)[0]; \
6025 + ((short*)d)[1] = ((short*)s)[1]; \
6026 + ((short*)d)[2] = ((short*)s)[2]; }
6027 +
6028 +/*
6029 + * Takes a pointer, returns true if a 48-bit broadcast (all ones)
6030 + */
6031 +#define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \
6032 + ((uint8 *)(ea))[1] & \
6033 + ((uint8 *)(ea))[2] & \
6034 + ((uint8 *)(ea))[3] & \
6035 + ((uint8 *)(ea))[4] & \
6036 + ((uint8 *)(ea))[5]) == 0xff)
6037 +
6038 +static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
6039 +
6040 +/*
6041 + * Takes a pointer, returns true if a 48-bit null address (all zeros)
6042 + */
6043 +#define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \
6044 + ((uint8 *)(ea))[1] | \
6045 + ((uint8 *)(ea))[2] | \
6046 + ((uint8 *)(ea))[3] | \
6047 + ((uint8 *)(ea))[4] | \
6048 + ((uint8 *)(ea))[5]) == 0)
6049 +
6050 +/* Differentiated Services Codepoint - upper 6 bits of tos in iphdr */
6051 +#define DSCP_MASK 0xFC /* upper 6 bits */
6052 +#define DSCP_SHIFT 2
6053 +#define DSCP_WME_PRI_MASK 0xE0 /* upper 3 bits */
6054 +#define DSCP_WME_PRI_SHIFT 5
6055 +
6056 +#undef PACKED
6057 +#if !defined(__GNUC__)
6058 +#pragma pack()
6059 +#endif
6060 +
6061 +#endif /* _NET_ETHERNET_H_ */
6062 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/proto/vlan.h linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/vlan.h
6063 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/vlan.h 1970-01-01 01:00:00.000000000 +0100
6064 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/vlan.h 2005-08-22 01:34:46.328150704 +0200
6065 @@ -0,0 +1,50 @@
6066 +/*
6067 + * 802.1Q VLAN protocol definitions
6068 + *
6069 + * Copyright 2005, Broadcom Corporation
6070 + * All Rights Reserved.
6071 + *
6072 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6073 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6074 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6075 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6076 + *
6077 + * $Id$
6078 + */
6079 +
6080 +#ifndef _vlan_h_
6081 +#define _vlan_h_
6082 +
6083 +/* enable structure packing */
6084 +#if defined(__GNUC__)
6085 +#define PACKED __attribute__((packed))
6086 +#else
6087 +#pragma pack(1)
6088 +#define PACKED
6089 +#endif
6090 +
6091 +#define VLAN_VID_MASK 0xfff /* low 12 bits are vlan id */
6092 +#define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */
6093 +#define VLAN_PRI_SHIFT 13 /* user priority */
6094 +
6095 +#define VLAN_PRI_MASK 7 /* 3 bits of priority */
6096 +
6097 +#define VLAN_TAG_LEN 4
6098 +#define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN)
6099 +
6100 +struct ethervlan_header {
6101 + uint8 ether_dhost[ETHER_ADDR_LEN];
6102 + uint8 ether_shost[ETHER_ADDR_LEN];
6103 + uint16 vlan_type; /* 0x8100 */
6104 + uint16 vlan_tag; /* priority, cfi and vid */
6105 + uint16 ether_type;
6106 +};
6107 +
6108 +#define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN)
6109 +
6110 +#undef PACKED
6111 +#if !defined(__GNUC__)
6112 +#pragma pack()
6113 +#endif
6114 +
6115 +#endif /* _vlan_h_ */
6116 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/proto/wpa.h linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/wpa.h
6117 --- linux-2.4.30/arch/mips/bcm947xx/include/proto/wpa.h 1970-01-01 01:00:00.000000000 +0100
6118 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/proto/wpa.h 2005-08-22 01:34:46.329150552 +0200
6119 @@ -0,0 +1,140 @@
6120 +/*
6121 + * Fundamental types and constants relating to WPA
6122 + *
6123 + * Copyright 2005, Broadcom Corporation
6124 + * All Rights Reserved.
6125 + *
6126 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6127 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6128 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6129 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6130 + *
6131 + * $Id$
6132 + */
6133 +
6134 +#ifndef _proto_wpa_h_
6135 +#define _proto_wpa_h_
6136 +
6137 +#include <typedefs.h>
6138 +#include <proto/ethernet.h>
6139 +
6140 +/* enable structure packing */
6141 +#if defined(__GNUC__)
6142 +#define PACKED __attribute__((packed))
6143 +#else
6144 +#pragma pack(1)
6145 +#define PACKED
6146 +#endif
6147 +
6148 +/* Reason Codes */
6149 +
6150 +/* 10 and 11 are from TGh. */
6151 +#define DOT11_RC_BAD_PC 10 /* Unacceptable power capability element */
6152 +#define DOT11_RC_BAD_CHANNELS 11 /* Unacceptable supported channels element */
6153 +/* 12 is unused */
6154 +/* 13 through 23 taken from P802.11i/D3.0, November 2002 */
6155 +#define DOT11_RC_INVALID_WPA_IE 13 /* Invalid info. element */
6156 +#define DOT11_RC_MIC_FAILURE 14 /* Michael failure */
6157 +#define DOT11_RC_4WH_TIMEOUT 15 /* 4-way handshake timeout */
6158 +#define DOT11_RC_GTK_UPDATE_TIMEOUT 16 /* Group key update timeout */
6159 +#define DOT11_RC_WPA_IE_MISMATCH 17 /* WPA IE in 4-way handshake differs from (re-)assoc. request/probe response */
6160 +#define DOT11_RC_INVALID_MC_CIPHER 18 /* Invalid multicast cipher */
6161 +#define DOT11_RC_INVALID_UC_CIPHER 19 /* Invalid unicast cipher */
6162 +#define DOT11_RC_INVALID_AKMP 20 /* Invalid authenticated key management protocol */
6163 +#define DOT11_RC_BAD_WPA_VERSION 21 /* Unsupported WPA version */
6164 +#define DOT11_RC_INVALID_WPA_CAP 22 /* Invalid WPA IE capabilities */
6165 +#define DOT11_RC_8021X_AUTH_FAIL 23 /* 802.1X authentication failure */
6166 +
6167 +#define WPA2_PMKID_LEN 16
6168 +
6169 +/* WPA IE fixed portion */
6170 +typedef struct
6171 +{
6172 + uint8 tag; /* TAG */
6173 + uint8 length; /* TAG length */
6174 + uint8 oui[3]; /* IE OUI */
6175 + uint8 oui_type; /* OUI type */
6176 + struct {
6177 + uint8 low;
6178 + uint8 high;
6179 + } PACKED version; /* IE version */
6180 +} PACKED wpa_ie_fixed_t;
6181 +#define WPA_IE_OUITYPE_LEN 4
6182 +#define WPA_IE_FIXED_LEN 8
6183 +#define WPA_IE_TAG_FIXED_LEN 6
6184 +
6185 +typedef struct {
6186 + uint8 tag; /* TAG */
6187 + uint8 length; /* TAG length */
6188 + struct {
6189 + uint8 low;
6190 + uint8 high;
6191 + } PACKED version; /* IE version */
6192 +} PACKED wpa_rsn_ie_fixed_t;
6193 +#define WPA_RSN_IE_FIXED_LEN 4
6194 +#define WPA_RSN_IE_TAG_FIXED_LEN 2
6195 +typedef uint8 wpa_pmkid_t[WPA2_PMKID_LEN];
6196 +
6197 +/* WPA suite/multicast suite */
6198 +typedef struct
6199 +{
6200 + uint8 oui[3];
6201 + uint8 type;
6202 +} PACKED wpa_suite_t, wpa_suite_mcast_t;
6203 +#define WPA_SUITE_LEN 4
6204 +
6205 +/* WPA unicast suite list/key management suite list */
6206 +typedef struct
6207 +{
6208 + struct {
6209 + uint8 low;
6210 + uint8 high;
6211 + } PACKED count;
6212 + wpa_suite_t list[1];
6213 +} PACKED wpa_suite_ucast_t, wpa_suite_auth_key_mgmt_t;
6214 +#define WPA_IE_SUITE_COUNT_LEN 2
6215 +typedef struct
6216 +{
6217 + struct {
6218 + uint8 low;
6219 + uint8 high;
6220 + } PACKED count;
6221 + wpa_pmkid_t list[1];
6222 +} PACKED wpa_pmkid_list_t;
6223 +
6224 +/* WPA cipher suites */
6225 +#define WPA_CIPHER_NONE 0 /* None */
6226 +#define WPA_CIPHER_WEP_40 1 /* WEP (40-bit) */
6227 +#define WPA_CIPHER_TKIP 2 /* TKIP: default for WPA */
6228 +#define WPA_CIPHER_AES_OCB 3 /* AES (OCB) */
6229 +#define WPA_CIPHER_AES_CCM 4 /* AES (CCM) */
6230 +#define WPA_CIPHER_WEP_104 5 /* WEP (104-bit) */
6231 +
6232 +#define IS_WPA_CIPHER(cipher) ((cipher) == WPA_CIPHER_NONE || \
6233 + (cipher) == WPA_CIPHER_WEP_40 || \
6234 + (cipher) == WPA_CIPHER_WEP_104 || \
6235 + (cipher) == WPA_CIPHER_TKIP || \
6236 + (cipher) == WPA_CIPHER_AES_OCB || \
6237 + (cipher) == WPA_CIPHER_AES_CCM)
6238 +
6239 +/* WPA TKIP countermeasures parameters */
6240 +#define WPA_TKIP_CM_DETECT 60 /* multiple MIC failure window (seconds) */
6241 +#define WPA_TKIP_CM_BLOCK 60 /* countermeasures active window (seconds) */
6242 +
6243 +/* WPA capabilities defined in 802.11i */
6244 +#define WPA_CAP_4_REPLAY_CNTRS 2
6245 +#define WPA_CAP_16_REPLAY_CNTRS 3
6246 +#define WPA_CAP_REPLAY_CNTR_SHIFT 2
6247 +#define WPA_CAP_REPLAY_CNTR_MASK 0x000c
6248 +
6249 +/* WPA Specific defines */
6250 +#define WPA_CAP_LEN 2
6251 +
6252 +#define WPA_CAP_WPA2_PREAUTH 1
6253 +
6254 +#undef PACKED
6255 +#if !defined(__GNUC__)
6256 +#pragma pack()
6257 +#endif
6258 +
6259 +#endif /* _proto_wpa_h_ */
6260 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/rts/crc.h linux-2.4.30.dev/arch/mips/bcm947xx/include/rts/crc.h
6261 --- linux-2.4.30/arch/mips/bcm947xx/include/rts/crc.h 1970-01-01 01:00:00.000000000 +0100
6262 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/rts/crc.h 2005-08-22 01:34:46.329150552 +0200
6263 @@ -0,0 +1,69 @@
6264 +/*******************************************************************************
6265 + * $Id$
6266 + * Copyright 2005, Broadcom Corporation
6267 + * All Rights Reserved.
6268 + *
6269 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6270 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6271 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6272 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6273 + * crc.h - a function to compute crc for iLine10 headers
6274 + ******************************************************************************/
6275 +
6276 +#ifndef _RTS_CRC_H_
6277 +#define _RTS_CRC_H_ 1
6278 +
6279 +#include "typedefs.h"
6280 +
6281 +#ifdef __cplusplus
6282 +extern "C" {
6283 +#endif
6284 +
6285 +
6286 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
6287 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
6288 +#define HCS_GOOD_VALUE 0x39 /* Good final header checksum value */
6289 +
6290 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
6291 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
6292 +
6293 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
6294 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
6295 +
6296 +void hcs(uint8 *, uint);
6297 +uint8 crc8(uint8 *, uint, uint8);
6298 +uint16 crc16(uint8 *, uint, uint16);
6299 +uint32 crc32(uint8 *, uint, uint32);
6300 +
6301 +/* macros for common usage */
6302 +
6303 +#define APPEND_CRC8(pbytes, nbytes) \
6304 +do { \
6305 + uint8 tmp = crc8(pbytes, nbytes, CRC8_INIT_VALUE) ^ 0xff; \
6306 + (pbytes)[(nbytes)] = tmp; \
6307 + (nbytes) += 1; \
6308 +} while (0)
6309 +
6310 +#define APPEND_CRC16(pbytes, nbytes) \
6311 +do { \
6312 + uint16 tmp = crc16(pbytes, nbytes, CRC16_INIT_VALUE) ^ 0xffff; \
6313 + (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
6314 + (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
6315 + (nbytes) += 2; \
6316 +} while (0)
6317 +
6318 +#define APPEND_CRC32(pbytes, nbytes) \
6319 +do { \
6320 + uint32 tmp = crc32(pbytes, nbytes, CRC32_INIT_VALUE) ^ 0xffffffff; \
6321 + (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
6322 + (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
6323 + (pbytes)[(nbytes) + 2] = (tmp >> 16) & 0xff; \
6324 + (pbytes)[(nbytes) + 3] = (tmp >> 24) & 0xff; \
6325 + (nbytes) += 4; \
6326 +} while (0)
6327 +
6328 +#ifdef __cplusplus
6329 +}
6330 +#endif
6331 +
6332 +#endif /* _RTS_CRC_H_ */
6333 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbchipc.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbchipc.h
6334 --- linux-2.4.30/arch/mips/bcm947xx/include/sbchipc.h 1970-01-01 01:00:00.000000000 +0100
6335 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbchipc.h 2005-08-22 01:34:46.330150400 +0200
6336 @@ -0,0 +1,394 @@
6337 +/*
6338 + * SiliconBackplane Chipcommon core hardware definitions.
6339 + *
6340 + * The chipcommon core provides chip identification, SB control,
6341 + * jtag, 0/1/2 uarts, clock frequency control, a watchdog interrupt timer,
6342 + * gpio interface, extbus, and support for serial and parallel flashes.
6343 + *
6344 + * $Id$
6345 + * Copyright 2005, Broadcom Corporation
6346 + * All Rights Reserved.
6347 + *
6348 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6349 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6350 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6351 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6352 + *
6353 + */
6354 +
6355 +#ifndef _SBCHIPC_H
6356 +#define _SBCHIPC_H
6357 +
6358 +
6359 +#ifndef _LANGUAGE_ASSEMBLY
6360 +
6361 +/* cpp contortions to concatenate w/arg prescan */
6362 +#ifndef PAD
6363 +#define _PADLINE(line) pad ## line
6364 +#define _XSTR(line) _PADLINE(line)
6365 +#define PAD _XSTR(__LINE__)
6366 +#endif /* PAD */
6367 +
6368 +typedef volatile struct {
6369 + uint32 chipid; /* 0x0 */
6370 + uint32 capabilities;
6371 + uint32 corecontrol; /* corerev >= 1 */
6372 + uint32 bist;
6373 +
6374 + /* OTP */
6375 + uint32 otpstatus; /* 0x10, corerev >= 10 */
6376 + uint32 otpcontrol;
6377 + uint32 otpprog;
6378 + uint32 PAD;
6379 +
6380 + /* Interrupt control */
6381 + uint32 intstatus; /* 0x20 */
6382 + uint32 intmask;
6383 + uint32 chipcontrol; /* 0x28, rev >= 11 */
6384 + uint32 chipstatus; /* 0x2c, rev >= 11 */
6385 +
6386 + /* Jtag Master */
6387 + uint32 jtagcmd; /* 0x30, rev >= 10 */
6388 + uint32 jtagir;
6389 + uint32 jtagdr;
6390 + uint32 jtagctrl;
6391 +
6392 + /* serial flash interface registers */
6393 + uint32 flashcontrol; /* 0x40 */
6394 + uint32 flashaddress;
6395 + uint32 flashdata;
6396 + uint32 PAD[1];
6397 +
6398 + /* Silicon backplane configuration broadcast control */
6399 + uint32 broadcastaddress; /* 0x50 */
6400 + uint32 broadcastdata;
6401 + uint32 PAD[2];
6402 +
6403 + /* gpio - cleared only by power-on-reset */
6404 + uint32 gpioin; /* 0x60 */
6405 + uint32 gpioout;
6406 + uint32 gpioouten;
6407 + uint32 gpiocontrol;
6408 + uint32 gpiointpolarity;
6409 + uint32 gpiointmask;
6410 + uint32 PAD[2];
6411 +
6412 + /* Watchdog timer */
6413 + uint32 watchdog; /* 0x80 */
6414 + uint32 PAD[3];
6415 +
6416 + /* clock control */
6417 + uint32 clockcontrol_n; /* 0x90 */
6418 + uint32 clockcontrol_sb; /* aka m0 */
6419 + uint32 clockcontrol_pci; /* aka m1 */
6420 + uint32 clockcontrol_m2; /* mii/uart/mipsref */
6421 + uint32 clockcontrol_mips; /* aka m3 */
6422 + uint32 clkdiv; /* corerev >= 3 */
6423 + uint32 PAD[2];
6424 +
6425 + /* pll delay registers (corerev >= 4) */
6426 + uint32 pll_on_delay; /* 0xb0 */
6427 + uint32 fref_sel_delay;
6428 + uint32 slow_clk_ctl; /* 5 < corerev < 10 */
6429 + uint32 PAD[1];
6430 +
6431 + /* Instaclock registers (corerev >= 10) */
6432 + uint32 system_clk_ctl; /* 0xc0 */
6433 + uint32 clkstatestretch;
6434 + uint32 PAD[14];
6435 +
6436 + /* ExtBus control registers (corerev >= 3) */
6437 + uint32 pcmcia_config; /* 0x100 */
6438 + uint32 pcmcia_memwait;
6439 + uint32 pcmcia_attrwait;
6440 + uint32 pcmcia_iowait;
6441 + uint32 ide_config;
6442 + uint32 ide_memwait;
6443 + uint32 ide_attrwait;
6444 + uint32 ide_iowait;
6445 + uint32 prog_config;
6446 + uint32 prog_waitcount;
6447 + uint32 flash_config;
6448 + uint32 flash_waitcount;
6449 + uint32 PAD[116];
6450 +
6451 + /* uarts */
6452 + uint8 uart0data; /* 0x300 */
6453 + uint8 uart0imr;
6454 + uint8 uart0fcr;
6455 + uint8 uart0lcr;
6456 + uint8 uart0mcr;
6457 + uint8 uart0lsr;
6458 + uint8 uart0msr;
6459 + uint8 uart0scratch;
6460 + uint8 PAD[248]; /* corerev >= 1 */
6461 +
6462 + uint8 uart1data; /* 0x400 */
6463 + uint8 uart1imr;
6464 + uint8 uart1fcr;
6465 + uint8 uart1lcr;
6466 + uint8 uart1mcr;
6467 + uint8 uart1lsr;
6468 + uint8 uart1msr;
6469 + uint8 uart1scratch;
6470 +} chipcregs_t;
6471 +
6472 +#endif /* _LANGUAGE_ASSEMBLY */
6473 +
6474 +#define CC_CHIPID 0
6475 +#define CC_CAPABILITIES 4
6476 +#define CC_JTAGCMD 0x30
6477 +#define CC_JTAGIR 0x34
6478 +#define CC_JTAGDR 0x38
6479 +#define CC_JTAGCTRL 0x3c
6480 +#define CC_CLKDIV 0xa4
6481 +#define CC_OTP 0x800
6482 +
6483 +/* chipid */
6484 +#define CID_ID_MASK 0x0000ffff /* Chip Id mask */
6485 +#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */
6486 +#define CID_REV_SHIFT 16 /* Chip Revision shift */
6487 +#define CID_PKG_MASK 0x00f00000 /* Package Option mask */
6488 +#define CID_PKG_SHIFT 20 /* Package Option shift */
6489 +#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */
6490 +#define CID_CC_SHIFT 24
6491 +
6492 +/* capabilities */
6493 +#define CAP_UARTS_MASK 0x00000003 /* Number of uarts */
6494 +#define CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */
6495 +#define CAP_UCLKSEL 0x00000018 /* UARTs clock select */
6496 +#define CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */
6497 +#define CAP_UARTGPIO 0x00000020 /* UARTs own Gpio's 15:12 */
6498 +#define CAP_EXTBUS 0x00000040 /* External bus present */
6499 +#define CAP_FLASH_MASK 0x00000700 /* Type of flash */
6500 +#define CAP_PLL_MASK 0x00038000 /* Type of PLL */
6501 +#define CAP_PWR_CTL 0x00040000 /* Power control */
6502 +#define CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */
6503 +#define CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */
6504 +#define CAP_JTAGP 0x00400000 /* JTAG Master Present */
6505 +#define CAP_ROM 0x00800000 /* Internal boot rom active */
6506 +
6507 +/* PLL type */
6508 +#define PLL_NONE 0x00000000
6509 +#define PLL_TYPE1 0x00010000 /* 48Mhz base, 3 dividers */
6510 +#define PLL_TYPE2 0x00020000 /* 48Mhz, 4 dividers */
6511 +#define PLL_TYPE3 0x00030000 /* 25Mhz, 2 dividers */
6512 +#define PLL_TYPE4 0x00008000 /* 48Mhz, 4 dividers */
6513 +#define PLL_TYPE5 0x00018000 /* 25Mhz, 4 dividers */
6514 +#define PLL_TYPE6 0x00028000 /* 100/200 or 120/240 only */
6515 +#define PLL_TYPE7 0x00038000 /* 25Mhz, 4 dividers */
6516 +
6517 +/* corecontrol */
6518 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */
6519 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
6520 +
6521 +/* jtagcmd */
6522 +#define JCMD_START 0x80000000
6523 +#define JCMD_BUSY 0x80000000
6524 +#define JCMD_PAUSE 0x40000000
6525 +#define JCMD0_ACC_MASK 0x0000f000
6526 +#define JCMD0_ACC_IRDR 0x00000000
6527 +#define JCMD0_ACC_DR 0x00001000
6528 +#define JCMD0_ACC_IR 0x00002000
6529 +#define JCMD0_ACC_RESET 0x00003000
6530 +#define JCMD0_ACC_IRPDR 0x00004000
6531 +#define JCMD0_ACC_PDR 0x00005000
6532 +#define JCMD0_IRW_MASK 0x00000f00
6533 +#define JCMD_ACC_MASK 0x000f0000 /* Changes for corerev 11 */
6534 +#define JCMD_ACC_IRDR 0x00000000
6535 +#define JCMD_ACC_DR 0x00010000
6536 +#define JCMD_ACC_IR 0x00020000
6537 +#define JCMD_ACC_RESET 0x00030000
6538 +#define JCMD_ACC_IRPDR 0x00040000
6539 +#define JCMD_ACC_PDR 0x00050000
6540 +#define JCMD_IRW_MASK 0x00001f00
6541 +#define JCMD_IRW_SHIFT 8
6542 +#define JCMD_DRW_MASK 0x0000003f
6543 +
6544 +/* jtagctrl */
6545 +#define JCTRL_FORCE_CLK 4 /* Force clock */
6546 +#define JCTRL_EXT_EN 2 /* Enable external targets */
6547 +#define JCTRL_EN 1 /* Enable Jtag master */
6548 +
6549 +/* Fields in clkdiv */
6550 +#define CLKD_SFLASH 0x0f000000
6551 +#define CLKD_SFLASH_SHIFT 24
6552 +#define CLKD_OTP 0x000f0000
6553 +#define CLKD_OTP_SHIFT 16
6554 +#define CLKD_JTAG 0x00000f00
6555 +#define CLKD_JTAG_SHIFT 8
6556 +#define CLKD_UART 0x000000ff
6557 +
6558 +/* intstatus/intmask */
6559 +#define CI_GPIO 0x00000001 /* gpio intr */
6560 +#define CI_EI 0x00000002 /* ro: ext intr pin (corerev >= 3) */
6561 +#define CI_WDRESET 0x80000000 /* watchdog reset occurred */
6562 +
6563 +/* slow_clk_ctl */
6564 +#define SCC_SS_MASK 0x00000007 /* slow clock source mask */
6565 +#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */
6566 +#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */
6567 +#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */
6568 +#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */
6569 +#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */
6570 +#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */
6571 +#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */
6572 +#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */
6573 +#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */
6574 +#define SCC_CD_MASK 0xffff0000 /* ClockDivider mask, SlowClk = 1/(4+divisor) * crystal/PCI clock */
6575 +#define SCC_CD_SHF 16 /* CLockDivider shift */
6576 +
6577 +/* sys_clk_ctl */
6578 +#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */
6579 +#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */
6580 +#define SYCC_FP 0x00000004 /* ForcePLLOn */
6581 +#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */
6582 +#define SYCC_HR 0x00000010 /* Force HT */
6583 +#define SYCC_CD_MASK 0xffff0000 /* ClockDivider mask, SlowClk = 1/(4+divisor) * crystal/PCI clock */
6584 +#define SYCC_CD_SHF 16 /* CLockDivider shift */
6585 +
6586 +/* clockcontrol_n */
6587 +#define CN_N1_MASK 0x3f /* n1 control */
6588 +#define CN_N2_MASK 0x3f00 /* n2 control */
6589 +#define CN_N2_SHIFT 8
6590 +#define CN_PLLC_MASK 0xf0000 /* pll control */
6591 +#define CN_PLLC_SHIFT 16
6592 +
6593 +/* clockcontrol_sb/pci/uart */
6594 +#define CC_M1_MASK 0x3f /* m1 control */
6595 +#define CC_M2_MASK 0x3f00 /* m2 control */
6596 +#define CC_M2_SHIFT 8
6597 +#define CC_M3_MASK 0x3f0000 /* m3 control */
6598 +#define CC_M3_SHIFT 16
6599 +#define CC_MC_MASK 0x1f000000 /* mux control */
6600 +#define CC_MC_SHIFT 24
6601 +
6602 +/* N3M Clock control values for 125Mhz */
6603 +#define CC_125_N 0x0802 /* Default values for bcm4310 */
6604 +#define CC_125_M 0x04020009
6605 +#define CC_125_M25 0x11090009
6606 +#define CC_125_M33 0x11090005
6607 +
6608 +/* N3M Clock control magic field values */
6609 +#define CC_F6_2 0x02 /* A factor of 2 in */
6610 +#define CC_F6_3 0x03 /* 6-bit fields like */
6611 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
6612 +#define CC_F6_5 0x09
6613 +#define CC_F6_6 0x11
6614 +#define CC_F6_7 0x21
6615 +
6616 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
6617 +
6618 +#define CC_MC_BYPASS 0x08
6619 +#define CC_MC_M1 0x04
6620 +#define CC_MC_M1M2 0x02
6621 +#define CC_MC_M1M2M3 0x01
6622 +#define CC_MC_M1M3 0x11
6623 +
6624 +/* Type 2 Clock control magic field values */
6625 +#define CC_T2_BIAS 2 /* n1, n2, m1 & m3 bias */
6626 +#define CC_T2M2_BIAS 3 /* m2 bias */
6627 +
6628 +#define CC_T2MC_M1BYP 1
6629 +#define CC_T2MC_M2BYP 2
6630 +#define CC_T2MC_M3BYP 4
6631 +
6632 +/* Type 6 Clock control magic field values */
6633 +#define CC_T6_MMASK 1 /* bits of interest in m */
6634 +#define CC_T6_M0 120000000 /* sb clock for m = 0 */
6635 +#define CC_T6_M1 100000000 /* sb clock for m = 1 */
6636 +#define SB2MIPS_T6(sb) (2 * (sb))
6637 +
6638 +/* Common clock base */
6639 +#define CC_CLOCK_BASE1 24000000 /* Half the clock freq */
6640 +#define CC_CLOCK_BASE2 12500000 /* Alternate crystal on some PLL's */
6641 +
6642 +/* Flash types in the chipcommon capabilities register */
6643 +#define FLASH_NONE 0x000 /* No flash */
6644 +#define SFLASH_ST 0x100 /* ST serial flash */
6645 +#define SFLASH_AT 0x200 /* Atmel serial flash */
6646 +#define PFLASH 0x700 /* Parallel flash */
6647 +
6648 +/* Bits in the config registers */
6649 +#define CC_CFG_EN 0x0001 /* Enable */
6650 +#define CC_CFG_EM_MASK 0x000e /* Extif Mode */
6651 +#define CC_CFG_EM_ASYNC 0x0002 /* Async/Parallel flash */
6652 +#define CC_CFG_EM_SYNC 0x0004 /* Synchronous */
6653 +#define CC_CFG_EM_PCMCIA 0x0008 /* PCMCIA */
6654 +#define CC_CFG_EM_IDE 0x000a /* IDE */
6655 +#define CC_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
6656 +#define CC_CFG_CD_MASK 0x0060 /* Sync: Clock divisor */
6657 +#define CC_CFG_CE 0x0080 /* Sync: Clock enable */
6658 +#define CC_CFG_SB 0x0100 /* Sync: Size/Bytestrobe */
6659 +
6660 +/* Start/busy bit in flashcontrol */
6661 +#define SFLASH_START 0x80000000
6662 +#define SFLASH_BUSY SFLASH_START
6663 +
6664 +/* flashcontrol opcodes for ST flashes */
6665 +#define SFLASH_ST_WREN 0x0006 /* Write Enable */
6666 +#define SFLASH_ST_WRDIS 0x0004 /* Write Disable */
6667 +#define SFLASH_ST_RDSR 0x0105 /* Read Status Register */
6668 +#define SFLASH_ST_WRSR 0x0101 /* Write Status Register */
6669 +#define SFLASH_ST_READ 0x0303 /* Read Data Bytes */
6670 +#define SFLASH_ST_PP 0x0302 /* Page Program */
6671 +#define SFLASH_ST_SE 0x02d8 /* Sector Erase */
6672 +#define SFLASH_ST_BE 0x00c7 /* Bulk Erase */
6673 +#define SFLASH_ST_DP 0x00b9 /* Deep Power-down */
6674 +#define SFLASH_ST_RES 0x03ab /* Read Electronic Signature */
6675 +
6676 +/* Status register bits for ST flashes */
6677 +#define SFLASH_ST_WIP 0x01 /* Write In Progress */
6678 +#define SFLASH_ST_WEL 0x02 /* Write Enable Latch */
6679 +#define SFLASH_ST_BP_MASK 0x1c /* Block Protect */
6680 +#define SFLASH_ST_BP_SHIFT 2
6681 +#define SFLASH_ST_SRWD 0x80 /* Status Register Write Disable */
6682 +
6683 +/* flashcontrol opcodes for Atmel flashes */
6684 +#define SFLASH_AT_READ 0x07e8
6685 +#define SFLASH_AT_PAGE_READ 0x07d2
6686 +#define SFLASH_AT_BUF1_READ
6687 +#define SFLASH_AT_BUF2_READ
6688 +#define SFLASH_AT_STATUS 0x01d7
6689 +#define SFLASH_AT_BUF1_WRITE 0x0384
6690 +#define SFLASH_AT_BUF2_WRITE 0x0387
6691 +#define SFLASH_AT_BUF1_ERASE_PROGRAM 0x0283
6692 +#define SFLASH_AT_BUF2_ERASE_PROGRAM 0x0286
6693 +#define SFLASH_AT_BUF1_PROGRAM 0x0288
6694 +#define SFLASH_AT_BUF2_PROGRAM 0x0289
6695 +#define SFLASH_AT_PAGE_ERASE 0x0281
6696 +#define SFLASH_AT_BLOCK_ERASE 0x0250
6697 +#define SFLASH_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382
6698 +#define SFLASH_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385
6699 +#define SFLASH_AT_BUF1_LOAD 0x0253
6700 +#define SFLASH_AT_BUF2_LOAD 0x0255
6701 +#define SFLASH_AT_BUF1_COMPARE 0x0260
6702 +#define SFLASH_AT_BUF2_COMPARE 0x0261
6703 +#define SFLASH_AT_BUF1_REPROGRAM 0x0258
6704 +#define SFLASH_AT_BUF2_REPROGRAM 0x0259
6705 +
6706 +/* Status register bits for Atmel flashes */
6707 +#define SFLASH_AT_READY 0x80
6708 +#define SFLASH_AT_MISMATCH 0x40
6709 +#define SFLASH_AT_ID_MASK 0x38
6710 +#define SFLASH_AT_ID_SHIFT 3
6711 +
6712 +/* OTP conventions */
6713 +#define OTP_HWBASE 0
6714 +#define OTP_SWLIM 256
6715 +#define OTP_CIDBASE 256
6716 +#define OTP_CIDLIM 260
6717 +
6718 +#define OTP_BOUNDARY 252
6719 +#define OTP_HWSIGN 253
6720 +#define OTP_SWSIGN 254
6721 +#define OTP_CIDSIGN 255
6722 +
6723 +#define OTP_CID 256
6724 +#define OTP_PKG 257
6725 +#define OTP_FID 258
6726 +
6727 +#define OTP_SIGNATURE 0x578a
6728 +#define OTP_MAGIC 0x4e56
6729 +
6730 +#endif /* _SBCHIPC_H */
6731 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbconfig.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbconfig.h
6732 --- linux-2.4.30/arch/mips/bcm947xx/include/sbconfig.h 1970-01-01 01:00:00.000000000 +0100
6733 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbconfig.h 2005-08-22 01:34:46.331150248 +0200
6734 @@ -0,0 +1,324 @@
6735 +/*
6736 + * Broadcom SiliconBackplane hardware register definitions.
6737 + *
6738 + * Copyright 2005, Broadcom Corporation
6739 + * All Rights Reserved.
6740 + *
6741 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6742 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6743 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6744 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6745 + * $Id$
6746 + */
6747 +
6748 +#ifndef _SBCONFIG_H
6749 +#define _SBCONFIG_H
6750 +
6751 +/* cpp contortions to concatenate w/arg prescan */
6752 +#ifndef PAD
6753 +#define _PADLINE(line) pad ## line
6754 +#define _XSTR(line) _PADLINE(line)
6755 +#define PAD _XSTR(__LINE__)
6756 +#endif
6757 +
6758 +/*
6759 + * SiliconBackplane Address Map.
6760 + * All regions may not exist on all chips.
6761 + */
6762 +#define SB_SDRAM_BASE 0x00000000 /* Physical SDRAM */
6763 +#define SB_PCI_MEM 0x08000000 /* Host Mode sb2pcitranslation0 (64 MB) */
6764 +#define SB_PCI_CFG 0x0c000000 /* Host Mode sb2pcitranslation1 (64 MB) */
6765 +#define SB_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
6766 +#define SB_ENUM_BASE 0x18000000 /* Enumeration space base */
6767 +#define SB_ENUM_LIM 0x18010000 /* Enumeration space limit */
6768 +
6769 +#define SB_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
6770 +#define SB_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
6771 +
6772 +#define SB_EXTIF_BASE 0x1f000000 /* External Interface region base address */
6773 +#define SB_FLASH1 0x1fc00000 /* Flash Region 1 */
6774 +#define SB_FLASH1_SZ 0x00400000 /* Size of Flash Region 1 */
6775 +
6776 +#define SB_PCI_DMA 0x40000000 /* Client Mode sb2pcitranslation2 (1 GB) */
6777 +#define SB_PCI_DMA_SZ 0x40000000 /* Client Mode sb2pcitranslation2 size in bytes */
6778 +#define SB_EUART (SB_EXTIF_BASE + 0x00800000)
6779 +#define SB_LED (SB_EXTIF_BASE + 0x00900000)
6780 +
6781 +/* enumeration space related defs */
6782 +#define SB_CORE_SIZE 0x1000 /* each core gets 4Kbytes for registers */
6783 +#define SB_MAXCORES ((SB_ENUM_LIM - SB_ENUM_BASE)/SB_CORE_SIZE)
6784 +#define SBCONFIGOFF 0xf00 /* core sbconfig regs are top 256bytes of regs */
6785 +#define SBCONFIGSIZE 256 /* sizeof (sbconfig_t) */
6786 +
6787 +/* mips address */
6788 +#define SB_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
6789 +
6790 +/*
6791 + * Sonics Configuration Space Registers.
6792 + */
6793 +#define SBIPSFLAG 0x08
6794 +#define SBTPSFLAG 0x18
6795 +#define SBTMERRLOGA 0x48 /* sonics >= 2.3 */
6796 +#define SBTMERRLOG 0x50 /* sonics >= 2.3 */
6797 +#define SBADMATCH3 0x60
6798 +#define SBADMATCH2 0x68
6799 +#define SBADMATCH1 0x70
6800 +#define SBIMSTATE 0x90
6801 +#define SBINTVEC 0x94
6802 +#define SBTMSTATELOW 0x98
6803 +#define SBTMSTATEHIGH 0x9c
6804 +#define SBBWA0 0xa0
6805 +#define SBIMCONFIGLOW 0xa8
6806 +#define SBIMCONFIGHIGH 0xac
6807 +#define SBADMATCH0 0xb0
6808 +#define SBTMCONFIGLOW 0xb8
6809 +#define SBTMCONFIGHIGH 0xbc
6810 +#define SBBCONFIG 0xc0
6811 +#define SBBSTATE 0xc8
6812 +#define SBACTCNFG 0xd8
6813 +#define SBFLAGST 0xe8
6814 +#define SBIDLOW 0xf8
6815 +#define SBIDHIGH 0xfc
6816 +
6817 +#ifndef _LANGUAGE_ASSEMBLY
6818 +
6819 +typedef volatile struct _sbconfig {
6820 + uint32 PAD[2];
6821 + uint32 sbipsflag; /* initiator port ocp slave flag */
6822 + uint32 PAD[3];
6823 + uint32 sbtpsflag; /* target port ocp slave flag */
6824 + uint32 PAD[11];
6825 + uint32 sbtmerrloga; /* (sonics >= 2.3) */
6826 + uint32 PAD;
6827 + uint32 sbtmerrlog; /* (sonics >= 2.3) */
6828 + uint32 PAD[3];
6829 + uint32 sbadmatch3; /* address match3 */
6830 + uint32 PAD;
6831 + uint32 sbadmatch2; /* address match2 */
6832 + uint32 PAD;
6833 + uint32 sbadmatch1; /* address match1 */
6834 + uint32 PAD[7];
6835 + uint32 sbimstate; /* initiator agent state */
6836 + uint32 sbintvec; /* interrupt mask */
6837 + uint32 sbtmstatelow; /* target state */
6838 + uint32 sbtmstatehigh; /* target state */
6839 + uint32 sbbwa0; /* bandwidth allocation table0 */
6840 + uint32 PAD;
6841 + uint32 sbimconfiglow; /* initiator configuration */
6842 + uint32 sbimconfighigh; /* initiator configuration */
6843 + uint32 sbadmatch0; /* address match0 */
6844 + uint32 PAD;
6845 + uint32 sbtmconfiglow; /* target configuration */
6846 + uint32 sbtmconfighigh; /* target configuration */
6847 + uint32 sbbconfig; /* broadcast configuration */
6848 + uint32 PAD;
6849 + uint32 sbbstate; /* broadcast state */
6850 + uint32 PAD[3];
6851 + uint32 sbactcnfg; /* activate configuration */
6852 + uint32 PAD[3];
6853 + uint32 sbflagst; /* current sbflags */
6854 + uint32 PAD[3];
6855 + uint32 sbidlow; /* identification */
6856 + uint32 sbidhigh; /* identification */
6857 +} sbconfig_t;
6858 +
6859 +#endif /* _LANGUAGE_ASSEMBLY */
6860 +
6861 +/* sbipsflag */
6862 +#define SBIPS_INT1_MASK 0x3f /* which sbflags get routed to mips interrupt 1 */
6863 +#define SBIPS_INT1_SHIFT 0
6864 +#define SBIPS_INT2_MASK 0x3f00 /* which sbflags get routed to mips interrupt 2 */
6865 +#define SBIPS_INT2_SHIFT 8
6866 +#define SBIPS_INT3_MASK 0x3f0000 /* which sbflags get routed to mips interrupt 3 */
6867 +#define SBIPS_INT3_SHIFT 16
6868 +#define SBIPS_INT4_MASK 0x3f000000 /* which sbflags get routed to mips interrupt 4 */
6869 +#define SBIPS_INT4_SHIFT 24
6870 +
6871 +/* sbtpsflag */
6872 +#define SBTPS_NUM0_MASK 0x3f /* interrupt sbFlag # generated by this core */
6873 +#define SBTPS_F0EN0 0x40 /* interrupt is always sent on the backplane */
6874 +
6875 +/* sbtmerrlog */
6876 +#define SBTMEL_CM 0x00000007 /* command */
6877 +#define SBTMEL_CI 0x0000ff00 /* connection id */
6878 +#define SBTMEL_EC 0x0f000000 /* error code */
6879 +#define SBTMEL_ME 0x80000000 /* multiple error */
6880 +
6881 +/* sbimstate */
6882 +#define SBIM_PC 0xf /* pipecount */
6883 +#define SBIM_AP_MASK 0x30 /* arbitration policy */
6884 +#define SBIM_AP_BOTH 0x00 /* use both timeslaces and token */
6885 +#define SBIM_AP_TS 0x10 /* use timesliaces only */
6886 +#define SBIM_AP_TK 0x20 /* use token only */
6887 +#define SBIM_AP_RSV 0x30 /* reserved */
6888 +#define SBIM_IBE 0x20000 /* inbanderror */
6889 +#define SBIM_TO 0x40000 /* timeout */
6890 +#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */
6891 +#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */
6892 +
6893 +/* sbtmstatelow */
6894 +#define SBTML_RESET 0x1 /* reset */
6895 +#define SBTML_REJ 0x2 /* reject */
6896 +#define SBTML_CLK 0x10000 /* clock enable */
6897 +#define SBTML_FGC 0x20000 /* force gated clocks on */
6898 +#define SBTML_FL_MASK 0x3ffc0000 /* core-specific flags */
6899 +#define SBTML_PE 0x40000000 /* pme enable */
6900 +#define SBTML_BE 0x80000000 /* bist enable */
6901 +
6902 +/* sbtmstatehigh */
6903 +#define SBTMH_SERR 0x1 /* serror */
6904 +#define SBTMH_INT 0x2 /* interrupt */
6905 +#define SBTMH_BUSY 0x4 /* busy */
6906 +#define SBTMH_TO 0x00000020 /* timeout (sonics >= 2.3) */
6907 +#define SBTMH_FL_MASK 0x1fff0000 /* core-specific flags */
6908 +#define SBTMH_GCR 0x20000000 /* gated clock request */
6909 +#define SBTMH_BISTF 0x40000000 /* bist failed */
6910 +#define SBTMH_BISTD 0x80000000 /* bist done */
6911 +
6912 +/* sbbwa0 */
6913 +#define SBBWA_TAB0_MASK 0xffff /* lookup table 0 */
6914 +#define SBBWA_TAB1_MASK 0xffff /* lookup table 1 */
6915 +#define SBBWA_TAB1_SHIFT 16
6916 +
6917 +/* sbimconfiglow */
6918 +#define SBIMCL_STO_MASK 0x7 /* service timeout */
6919 +#define SBIMCL_RTO_MASK 0x70 /* request timeout */
6920 +#define SBIMCL_RTO_SHIFT 4
6921 +#define SBIMCL_CID_MASK 0xff0000 /* connection id */
6922 +#define SBIMCL_CID_SHIFT 16
6923 +
6924 +/* sbimconfighigh */
6925 +#define SBIMCH_IEM_MASK 0xc /* inband error mode */
6926 +#define SBIMCH_TEM_MASK 0x30 /* timeout error mode */
6927 +#define SBIMCH_TEM_SHIFT 4
6928 +#define SBIMCH_BEM_MASK 0xc0 /* bus error mode */
6929 +#define SBIMCH_BEM_SHIFT 6
6930 +
6931 +/* sbadmatch0 */
6932 +#define SBAM_TYPE_MASK 0x3 /* address type */
6933 +#define SBAM_AD64 0x4 /* reserved */
6934 +#define SBAM_ADINT0_MASK 0xf8 /* type0 size */
6935 +#define SBAM_ADINT0_SHIFT 3
6936 +#define SBAM_ADINT1_MASK 0x1f8 /* type1 size */
6937 +#define SBAM_ADINT1_SHIFT 3
6938 +#define SBAM_ADINT2_MASK 0x1f8 /* type2 size */
6939 +#define SBAM_ADINT2_SHIFT 3
6940 +#define SBAM_ADEN 0x400 /* enable */
6941 +#define SBAM_ADNEG 0x800 /* negative decode */
6942 +#define SBAM_BASE0_MASK 0xffffff00 /* type0 base address */
6943 +#define SBAM_BASE0_SHIFT 8
6944 +#define SBAM_BASE1_MASK 0xfffff000 /* type1 base address for the core */
6945 +#define SBAM_BASE1_SHIFT 12
6946 +#define SBAM_BASE2_MASK 0xffff0000 /* type2 base address for the core */
6947 +#define SBAM_BASE2_SHIFT 16
6948 +
6949 +/* sbtmconfiglow */
6950 +#define SBTMCL_CD_MASK 0xff /* clock divide */
6951 +#define SBTMCL_CO_MASK 0xf800 /* clock offset */
6952 +#define SBTMCL_CO_SHIFT 11
6953 +#define SBTMCL_IF_MASK 0xfc0000 /* interrupt flags */
6954 +#define SBTMCL_IF_SHIFT 18
6955 +#define SBTMCL_IM_MASK 0x3000000 /* interrupt mode */
6956 +#define SBTMCL_IM_SHIFT 24
6957 +
6958 +/* sbtmconfighigh */
6959 +#define SBTMCH_BM_MASK 0x3 /* busy mode */
6960 +#define SBTMCH_RM_MASK 0x3 /* retry mode */
6961 +#define SBTMCH_RM_SHIFT 2
6962 +#define SBTMCH_SM_MASK 0x30 /* stop mode */
6963 +#define SBTMCH_SM_SHIFT 4
6964 +#define SBTMCH_EM_MASK 0x300 /* sb error mode */
6965 +#define SBTMCH_EM_SHIFT 8
6966 +#define SBTMCH_IM_MASK 0xc00 /* int mode */
6967 +#define SBTMCH_IM_SHIFT 10
6968 +
6969 +/* sbbconfig */
6970 +#define SBBC_LAT_MASK 0x3 /* sb latency */
6971 +#define SBBC_MAX0_MASK 0xf0000 /* maxccntr0 */
6972 +#define SBBC_MAX0_SHIFT 16
6973 +#define SBBC_MAX1_MASK 0xf00000 /* maxccntr1 */
6974 +#define SBBC_MAX1_SHIFT 20
6975 +
6976 +/* sbbstate */
6977 +#define SBBS_SRD 0x1 /* st reg disable */
6978 +#define SBBS_HRD 0x2 /* hold reg disable */
6979 +
6980 +/* sbidlow */
6981 +#define SBIDL_CS_MASK 0x3 /* config space */
6982 +#define SBIDL_AR_MASK 0x38 /* # address ranges supported */
6983 +#define SBIDL_AR_SHIFT 3
6984 +#define SBIDL_SYNCH 0x40 /* sync */
6985 +#define SBIDL_INIT 0x80 /* initiator */
6986 +#define SBIDL_MINLAT_MASK 0xf00 /* minimum backplane latency */
6987 +#define SBIDL_MINLAT_SHIFT 8
6988 +#define SBIDL_MAXLAT 0xf000 /* maximum backplane latency */
6989 +#define SBIDL_MAXLAT_SHIFT 12
6990 +#define SBIDL_FIRST 0x10000 /* this initiator is first */
6991 +#define SBIDL_CW_MASK 0xc0000 /* cycle counter width */
6992 +#define SBIDL_CW_SHIFT 18
6993 +#define SBIDL_TP_MASK 0xf00000 /* target ports */
6994 +#define SBIDL_TP_SHIFT 20
6995 +#define SBIDL_IP_MASK 0xf000000 /* initiator ports */
6996 +#define SBIDL_IP_SHIFT 24
6997 +#define SBIDL_RV_MASK 0xf0000000 /* sonics backplane revision code */
6998 +#define SBIDL_RV_SHIFT 28
6999 +
7000 +/* sbidhigh */
7001 +#define SBIDH_RC_MASK 0xf /* revision code*/
7002 +#define SBIDH_CC_MASK 0xfff0 /* core code */
7003 +#define SBIDH_CC_SHIFT 4
7004 +#define SBIDH_VC_MASK 0xffff0000 /* vendor code */
7005 +#define SBIDH_VC_SHIFT 16
7006 +
7007 +#define SB_COMMIT 0xfd8 /* update buffered registers value */
7008 +
7009 +/* vendor codes */
7010 +#define SB_VEND_BCM 0x4243 /* Broadcom's SB vendor code */
7011 +
7012 +/* core codes */
7013 +#define SB_CC 0x800 /* chipcommon core */
7014 +#define SB_ILINE20 0x801 /* iline20 core */
7015 +#define SB_SDRAM 0x803 /* sdram core */
7016 +#define SB_PCI 0x804 /* pci core */
7017 +#define SB_MIPS 0x805 /* mips core */
7018 +#define SB_ENET 0x806 /* enet mac core */
7019 +#define SB_CODEC 0x807 /* v90 codec core */
7020 +#define SB_USB 0x808 /* usb 1.1 host/device core */
7021 +#define SB_ADSL 0x809 /* ADSL core */
7022 +#define SB_ILINE100 0x80a /* iline100 core */
7023 +#define SB_IPSEC 0x80b /* ipsec core */
7024 +#define SB_PCMCIA 0x80d /* pcmcia core */
7025 +#define SB_SOCRAM 0x80e /* internal memory core */
7026 +#define SB_MEMC 0x80f /* memc sdram core */
7027 +#define SB_EXTIF 0x811 /* external interface core */
7028 +#define SB_D11 0x812 /* 802.11 MAC core */
7029 +#define SB_MIPS33 0x816 /* mips3302 core */
7030 +#define SB_USB11H 0x817 /* usb 1.1 host core */
7031 +#define SB_USB11D 0x818 /* usb 1.1 device core */
7032 +#define SB_USB20H 0x819 /* usb 2.0 host core */
7033 +#define SB_USB20D 0x81a /* usb 2.0 device core */
7034 +#define SB_SDIOH 0x81b /* sdio host core */
7035 +#define SB_ROBO 0x81c /* roboswitch core */
7036 +#define SB_ATA100 0x81d /* parallel ATA core */
7037 +#define SB_SATAXOR 0x81e /* serial ATA & XOR DMA core */
7038 +#define SB_GIGETH 0x81f /* gigabit ethernet core */
7039 +
7040 +/* Not really related to Silicon Backplane, but a couple of software
7041 + * conventions for the use the flash space:
7042 + */
7043 +
7044 +/* Minumum amount of flash we support */
7045 +#define FLASH_MIN 0x00020000 /* Minimum flash size */
7046 +
7047 +/* A boot/binary may have an embedded block that describes its size */
7048 +#define BISZ_OFFSET 0x3e0 /* At this offset into the binary */
7049 +#define BISZ_MAGIC 0x4249535a /* Marked with this value: 'BISZ' */
7050 +#define BISZ_MAGIC_IDX 0 /* Word 0: magic */
7051 +#define BISZ_TXTST_IDX 1 /* 1: text start */
7052 +#define BISZ_TXTEND_IDX 2 /* 2: text start */
7053 +#define BISZ_DATAST_IDX 3 /* 3: text start */
7054 +#define BISZ_DATAEND_IDX 4 /* 4: text start */
7055 +#define BISZ_BSSST_IDX 5 /* 5: text start */
7056 +#define BISZ_BSSEND_IDX 6 /* 6: text start */
7057 +
7058 +#endif /* _SBCONFIG_H */
7059 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbextif.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbextif.h
7060 --- linux-2.4.30/arch/mips/bcm947xx/include/sbextif.h 1970-01-01 01:00:00.000000000 +0100
7061 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbextif.h 2005-08-22 01:34:46.332150096 +0200
7062 @@ -0,0 +1,242 @@
7063 +/*
7064 + * Hardware-specific External Interface I/O core definitions
7065 + * for the BCM47xx family of SiliconBackplane-based chips.
7066 + *
7067 + * The External Interface core supports a total of three external chip selects
7068 + * supporting external interfaces. One of the external chip selects is
7069 + * used for Flash, one is used for PCMCIA, and the other may be
7070 + * programmed to support either a synchronous interface or an
7071 + * asynchronous interface. The asynchronous interface can be used to
7072 + * support external devices such as UARTs and the BCM2019 Bluetooth
7073 + * baseband processor.
7074 + * The external interface core also contains 2 on-chip 16550 UARTs, clock
7075 + * frequency control, a watchdog interrupt timer, and a GPIO interface.
7076 + *
7077 + * Copyright 2005, Broadcom Corporation
7078 + * All Rights Reserved.
7079 + *
7080 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7081 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7082 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7083 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7084 + * $Id$
7085 + */
7086 +
7087 +#ifndef _SBEXTIF_H
7088 +#define _SBEXTIF_H
7089 +
7090 +/* external interface address space */
7091 +#define EXTIF_PCMCIA_MEMBASE(x) (x)
7092 +#define EXTIF_PCMCIA_IOBASE(x) ((x) + 0x100000)
7093 +#define EXTIF_PCMCIA_CFGBASE(x) ((x) + 0x200000)
7094 +#define EXTIF_CFGIF_BASE(x) ((x) + 0x800000)
7095 +#define EXTIF_FLASH_BASE(x) ((x) + 0xc00000)
7096 +
7097 +/* cpp contortions to concatenate w/arg prescan */
7098 +#ifndef PAD
7099 +#define _PADLINE(line) pad ## line
7100 +#define _XSTR(line) _PADLINE(line)
7101 +#define PAD _XSTR(__LINE__)
7102 +#endif /* PAD */
7103 +
7104 +/*
7105 + * The multiple instances of output and output enable registers
7106 + * are present to allow driver software for multiple cores to control
7107 + * gpio outputs without needing to share a single register pair.
7108 + */
7109 +struct gpiouser {
7110 + uint32 out;
7111 + uint32 outen;
7112 +};
7113 +#define NGPIOUSER 5
7114 +
7115 +typedef volatile struct {
7116 + uint32 corecontrol;
7117 + uint32 extstatus;
7118 + uint32 PAD[2];
7119 +
7120 + /* pcmcia control registers */
7121 + uint32 pcmcia_config;
7122 + uint32 pcmcia_memwait;
7123 + uint32 pcmcia_attrwait;
7124 + uint32 pcmcia_iowait;
7125 +
7126 + /* programmable interface control registers */
7127 + uint32 prog_config;
7128 + uint32 prog_waitcount;
7129 +
7130 + /* flash control registers */
7131 + uint32 flash_config;
7132 + uint32 flash_waitcount;
7133 + uint32 PAD[4];
7134 +
7135 + uint32 watchdog;
7136 +
7137 + /* clock control */
7138 + uint32 clockcontrol_n;
7139 + uint32 clockcontrol_sb;
7140 + uint32 clockcontrol_pci;
7141 + uint32 clockcontrol_mii;
7142 + uint32 PAD[3];
7143 +
7144 + /* gpio */
7145 + uint32 gpioin;
7146 + struct gpiouser gpio[NGPIOUSER];
7147 + uint32 PAD;
7148 + uint32 ejtagouten;
7149 + uint32 gpiointpolarity;
7150 + uint32 gpiointmask;
7151 + uint32 PAD[153];
7152 +
7153 + uint8 uartdata;
7154 + uint8 PAD[3];
7155 + uint8 uartimer;
7156 + uint8 PAD[3];
7157 + uint8 uartfcr;
7158 + uint8 PAD[3];
7159 + uint8 uartlcr;
7160 + uint8 PAD[3];
7161 + uint8 uartmcr;
7162 + uint8 PAD[3];
7163 + uint8 uartlsr;
7164 + uint8 PAD[3];
7165 + uint8 uartmsr;
7166 + uint8 PAD[3];
7167 + uint8 uartscratch;
7168 + uint8 PAD[3];
7169 +} extifregs_t;
7170 +
7171 +/* corecontrol */
7172 +#define CC_UE (1 << 0) /* uart enable */
7173 +
7174 +/* extstatus */
7175 +#define ES_EM (1 << 0) /* endian mode (ro) */
7176 +#define ES_EI (1 << 1) /* external interrupt pin (ro) */
7177 +#define ES_GI (1 << 2) /* gpio interrupt pin (ro) */
7178 +
7179 +/* gpio bit mask */
7180 +#define GPIO_BIT0 (1 << 0)
7181 +#define GPIO_BIT1 (1 << 1)
7182 +#define GPIO_BIT2 (1 << 2)
7183 +#define GPIO_BIT3 (1 << 3)
7184 +#define GPIO_BIT4 (1 << 4)
7185 +#define GPIO_BIT5 (1 << 5)
7186 +#define GPIO_BIT6 (1 << 6)
7187 +#define GPIO_BIT7 (1 << 7)
7188 +
7189 +
7190 +/* pcmcia/prog/flash_config */
7191 +#define CF_EN (1 << 0) /* enable */
7192 +#define CF_EM_MASK 0xe /* mode */
7193 +#define CF_EM_SHIFT 1
7194 +#define CF_EM_FLASH 0x0 /* flash/asynchronous mode */
7195 +#define CF_EM_SYNC 0x2 /* synchronous mode */
7196 +#define CF_EM_PCMCIA 0x4 /* pcmcia mode */
7197 +#define CF_DS (1 << 4) /* destsize: 0=8bit, 1=16bit */
7198 +#define CF_BS (1 << 5) /* byteswap */
7199 +#define CF_CD_MASK 0xc0 /* clock divider */
7200 +#define CF_CD_SHIFT 6
7201 +#define CF_CD_DIV2 0x0 /* backplane/2 */
7202 +#define CF_CD_DIV3 0x40 /* backplane/3 */
7203 +#define CF_CD_DIV4 0x80 /* backplane/4 */
7204 +#define CF_CE (1 << 8) /* clock enable */
7205 +#define CF_SB (1 << 9) /* size/bytestrobe (synch only) */
7206 +
7207 +/* pcmcia_memwait */
7208 +#define PM_W0_MASK 0x3f /* waitcount0 */
7209 +#define PM_W1_MASK 0x1f00 /* waitcount1 */
7210 +#define PM_W1_SHIFT 8
7211 +#define PM_W2_MASK 0x1f0000 /* waitcount2 */
7212 +#define PM_W2_SHIFT 16
7213 +#define PM_W3_MASK 0x1f000000 /* waitcount3 */
7214 +#define PM_W3_SHIFT 24
7215 +
7216 +/* pcmcia_attrwait */
7217 +#define PA_W0_MASK 0x3f /* waitcount0 */
7218 +#define PA_W1_MASK 0x1f00 /* waitcount1 */
7219 +#define PA_W1_SHIFT 8
7220 +#define PA_W2_MASK 0x1f0000 /* waitcount2 */
7221 +#define PA_W2_SHIFT 16
7222 +#define PA_W3_MASK 0x1f000000 /* waitcount3 */
7223 +#define PA_W3_SHIFT 24
7224 +
7225 +/* pcmcia_iowait */
7226 +#define PI_W0_MASK 0x3f /* waitcount0 */
7227 +#define PI_W1_MASK 0x1f00 /* waitcount1 */
7228 +#define PI_W1_SHIFT 8
7229 +#define PI_W2_MASK 0x1f0000 /* waitcount2 */
7230 +#define PI_W2_SHIFT 16
7231 +#define PI_W3_MASK 0x1f000000 /* waitcount3 */
7232 +#define PI_W3_SHIFT 24
7233 +
7234 +/* prog_waitcount */
7235 +#define PW_W0_MASK 0x0000001f /* waitcount0 */
7236 +#define PW_W1_MASK 0x00001f00 /* waitcount1 */
7237 +#define PW_W1_SHIFT 8
7238 +#define PW_W2_MASK 0x001f0000 /* waitcount2 */
7239 +#define PW_W2_SHIFT 16
7240 +#define PW_W3_MASK 0x1f000000 /* waitcount3 */
7241 +#define PW_W3_SHIFT 24
7242 +
7243 +#define PW_W0 0x0000000c
7244 +#define PW_W1 0x00000a00
7245 +#define PW_W2 0x00020000
7246 +#define PW_W3 0x01000000
7247 +
7248 +/* flash_waitcount */
7249 +#define FW_W0_MASK 0x1f /* waitcount0 */
7250 +#define FW_W1_MASK 0x1f00 /* waitcount1 */
7251 +#define FW_W1_SHIFT 8
7252 +#define FW_W2_MASK 0x1f0000 /* waitcount2 */
7253 +#define FW_W2_SHIFT 16
7254 +#define FW_W3_MASK 0x1f000000 /* waitcount3 */
7255 +#define FW_W3_SHIFT 24
7256 +
7257 +/* watchdog */
7258 +#define WATCHDOG_CLOCK 48000000 /* Hz */
7259 +
7260 +/* clockcontrol_n */
7261 +#define CN_N1_MASK 0x3f /* n1 control */
7262 +#define CN_N2_MASK 0x3f00 /* n2 control */
7263 +#define CN_N2_SHIFT 8
7264 +
7265 +/* clockcontrol_sb/pci/mii */
7266 +#define CC_M1_MASK 0x3f /* m1 control */
7267 +#define CC_M2_MASK 0x3f00 /* m2 control */
7268 +#define CC_M2_SHIFT 8
7269 +#define CC_M3_MASK 0x3f0000 /* m3 control */
7270 +#define CC_M3_SHIFT 16
7271 +#define CC_MC_MASK 0x1f000000 /* mux control */
7272 +#define CC_MC_SHIFT 24
7273 +
7274 +/* Clock control default values */
7275 +#define CC_DEF_N 0x0009 /* Default values for bcm4710 */
7276 +#define CC_DEF_100 0x04020011
7277 +#define CC_DEF_33 0x11030011
7278 +#define CC_DEF_25 0x11050011
7279 +
7280 +/* Clock control values for 125Mhz */
7281 +#define CC_125_N 0x0802
7282 +#define CC_125_M 0x04020009
7283 +#define CC_125_M25 0x11090009
7284 +#define CC_125_M33 0x11090005
7285 +
7286 +/* Clock control magic field values */
7287 +#define CC_F6_2 0x02 /* A factor of 2 in */
7288 +#define CC_F6_3 0x03 /* 6-bit fields like */
7289 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
7290 +#define CC_F6_5 0x09
7291 +#define CC_F6_6 0x11
7292 +#define CC_F6_7 0x21
7293 +
7294 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
7295 +
7296 +#define CC_MC_BYPASS 0x08
7297 +#define CC_MC_M1 0x04
7298 +#define CC_MC_M1M2 0x02
7299 +#define CC_MC_M1M2M3 0x01
7300 +#define CC_MC_M1M3 0x11
7301 +
7302 +#define CC_CLOCK_BASE 24000000 /* Half the clock freq. in the 4710 */
7303 +
7304 +#endif /* _SBEXTIF_H */
7305 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbmemc.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbmemc.h
7306 --- linux-2.4.30/arch/mips/bcm947xx/include/sbmemc.h 1970-01-01 01:00:00.000000000 +0100
7307 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbmemc.h 2005-08-22 01:34:46.333149944 +0200
7308 @@ -0,0 +1,147 @@
7309 +/*
7310 + * BCM47XX Sonics SiliconBackplane DDR/SDRAM controller core hardware definitions.
7311 + *
7312 + * Copyright 2005, Broadcom Corporation
7313 + * All Rights Reserved.
7314 + *
7315 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7316 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7317 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7318 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7319 + *
7320 + * $Id$
7321 + */
7322 +
7323 +#ifndef _SBMEMC_H
7324 +#define _SBMEMC_H
7325 +
7326 +#ifdef _LANGUAGE_ASSEMBLY
7327 +
7328 +#define MEMC_CONTROL 0x00
7329 +#define MEMC_CONFIG 0x04
7330 +#define MEMC_REFRESH 0x08
7331 +#define MEMC_BISTSTAT 0x0c
7332 +#define MEMC_MODEBUF 0x10
7333 +#define MEMC_BKCLS 0x14
7334 +#define MEMC_PRIORINV 0x18
7335 +#define MEMC_DRAMTIM 0x1c
7336 +#define MEMC_INTSTAT 0x20
7337 +#define MEMC_INTMASK 0x24
7338 +#define MEMC_INTINFO 0x28
7339 +#define MEMC_NCDLCTL 0x30
7340 +#define MEMC_RDNCDLCOR 0x34
7341 +#define MEMC_WRNCDLCOR 0x38
7342 +#define MEMC_MISCDLYCTL 0x3c
7343 +#define MEMC_DQSGATENCDL 0x40
7344 +#define MEMC_SPARE 0x44
7345 +#define MEMC_TPADDR 0x48
7346 +#define MEMC_TPDATA 0x4c
7347 +#define MEMC_BARRIER 0x50
7348 +#define MEMC_CORE 0x54
7349 +
7350 +
7351 +#else
7352 +
7353 +/* Sonics side: MEMC core registers */
7354 +typedef volatile struct sbmemcregs {
7355 + uint32 control;
7356 + uint32 config;
7357 + uint32 refresh;
7358 + uint32 biststat;
7359 + uint32 modebuf;
7360 + uint32 bkcls;
7361 + uint32 priorinv;
7362 + uint32 dramtim;
7363 + uint32 intstat;
7364 + uint32 intmask;
7365 + uint32 intinfo;
7366 + uint32 reserved1;
7367 + uint32 ncdlctl;
7368 + uint32 rdncdlcor;
7369 + uint32 wrncdlcor;
7370 + uint32 miscdlyctl;
7371 + uint32 dqsgatencdl;
7372 + uint32 spare;
7373 + uint32 tpaddr;
7374 + uint32 tpdata;
7375 + uint32 barrier;
7376 + uint32 core;
7377 +} sbmemcregs_t;
7378 +
7379 +#endif
7380 +
7381 +/* MEMC Core Init values (OCP ID 0x80f) */
7382 +
7383 +/* For sdr: */
7384 +#define MEMC_SD_CONFIG_INIT 0x00048000
7385 +#define MEMC_SD_DRAMTIM2_INIT 0x000754d8
7386 +#define MEMC_SD_DRAMTIM3_INIT 0x000754da
7387 +#define MEMC_SD_RDNCDLCOR_INIT 0x00000000
7388 +#define MEMC_SD_WRNCDLCOR_INIT 0x49351200
7389 +#define MEMC_SD1_WRNCDLCOR_INIT 0x14500200 /* For corerev 1 (4712) */
7390 +#define MEMC_SD_MISCDLYCTL_INIT 0x00061c1b
7391 +#define MEMC_SD1_MISCDLYCTL_INIT 0x00021416 /* For corerev 1 (4712) */
7392 +#define MEMC_SD_CONTROL_INIT0 0x00000002
7393 +#define MEMC_SD_CONTROL_INIT1 0x00000008
7394 +#define MEMC_SD_CONTROL_INIT2 0x00000004
7395 +#define MEMC_SD_CONTROL_INIT3 0x00000010
7396 +#define MEMC_SD_CONTROL_INIT4 0x00000001
7397 +#define MEMC_SD_MODEBUF_INIT 0x00000000
7398 +#define MEMC_SD_REFRESH_INIT 0x0000840f
7399 +
7400 +
7401 +/* This is for SDRM8X8X4 */
7402 +#define MEMC_SDR_INIT 0x0008
7403 +#define MEMC_SDR_MODE 0x32
7404 +#define MEMC_SDR_NCDL 0x00020032
7405 +#define MEMC_SDR1_NCDL 0x0002020f /* For corerev 1 (4712) */
7406 +
7407 +/* For ddr: */
7408 +#define MEMC_CONFIG_INIT 0x00048000
7409 +#define MEMC_DRAMTIM2_INIT 0x000754d8
7410 +#define MEMC_DRAMTIM25_INIT 0x000754d9
7411 +#define MEMC_RDNCDLCOR_INIT 0x00000000
7412 +#define MEMC_WRNCDLCOR_INIT 0x49351200
7413 +#define MEMC_1_WRNCDLCOR_INIT 0x14500200
7414 +#define MEMC_DQSGATENCDL_INIT 0x00030000
7415 +#define MEMC_MISCDLYCTL_INIT 0x21061c1b
7416 +#define MEMC_1_MISCDLYCTL_INIT 0x21021400
7417 +#define MEMC_NCDLCTL_INIT 0x00002001
7418 +#define MEMC_CONTROL_INIT0 0x00000002
7419 +#define MEMC_CONTROL_INIT1 0x00000008
7420 +#define MEMC_MODEBUF_INIT0 0x00004000
7421 +#define MEMC_CONTROL_INIT2 0x00000010
7422 +#define MEMC_MODEBUF_INIT1 0x00000100
7423 +#define MEMC_CONTROL_INIT3 0x00000010
7424 +#define MEMC_CONTROL_INIT4 0x00000008
7425 +#define MEMC_REFRESH_INIT 0x0000840f
7426 +#define MEMC_CONTROL_INIT5 0x00000004
7427 +#define MEMC_MODEBUF_INIT2 0x00000000
7428 +#define MEMC_CONTROL_INIT6 0x00000010
7429 +#define MEMC_CONTROL_INIT7 0x00000001
7430 +
7431 +
7432 +/* This is for DDRM16X16X2 */
7433 +#define MEMC_DDR_INIT 0x0009
7434 +#define MEMC_DDR_MODE 0x62
7435 +#define MEMC_DDR_NCDL 0x0005050a
7436 +#define MEMC_DDR1_NCDL 0x00000a0a /* For corerev 1 (4712) */
7437 +
7438 +/* mask for sdr/ddr calibration registers */
7439 +#define MEMC_RDNCDLCOR_RD_MASK 0x000000ff
7440 +#define MEMC_WRNCDLCOR_WR_MASK 0x000000ff
7441 +#define MEMC_DQSGATENCDL_G_MASK 0x000000ff
7442 +
7443 +/* masks for miscdlyctl registers */
7444 +#define MEMC_MISC_SM_MASK 0x30000000
7445 +#define MEMC_MISC_SM_SHIFT 28
7446 +#define MEMC_MISC_SD_MASK 0x0f000000
7447 +#define MEMC_MISC_SD_SHIFT 24
7448 +
7449 +/* hw threshhold for calculating wr/rd for sdr memc */
7450 +#define MEMC_CD_THRESHOLD 128
7451 +
7452 +/* Low bit of init register says if memc is ddr or sdr */
7453 +#define MEMC_CONFIG_DDR 0x00000001
7454 +
7455 +#endif /* _SBMEMC_H */
7456 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbmips.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbmips.h
7457 --- linux-2.4.30/arch/mips/bcm947xx/include/sbmips.h 1970-01-01 01:00:00.000000000 +0100
7458 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbmips.h 2005-08-22 01:34:46.333149944 +0200
7459 @@ -0,0 +1,60 @@
7460 +/*
7461 + * Broadcom SiliconBackplane MIPS definitions
7462 + *
7463 + * SB MIPS cores are custom MIPS32 processors with SiliconBackplane
7464 + * OCP interfaces. The CP0 processor ID is 0x00024000, where bits
7465 + * 23:16 mean Broadcom and bits 15:8 mean a MIPS core with an OCP
7466 + * interface. The core revision is stored in the SB ID register in SB
7467 + * configuration space.
7468 + *
7469 + * Copyright 2005, Broadcom Corporation
7470 + * All Rights Reserved.
7471 + *
7472 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7473 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7474 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7475 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7476 + *
7477 + * $Id$
7478 + */
7479 +
7480 +#ifndef _SBMIPS_H
7481 +#define _SBMIPS_H
7482 +
7483 +#ifndef _LANGUAGE_ASSEMBLY
7484 +
7485 +/* cpp contortions to concatenate w/arg prescan */
7486 +#ifndef PAD
7487 +#define _PADLINE(line) pad ## line
7488 +#define _XSTR(line) _PADLINE(line)
7489 +#define PAD _XSTR(__LINE__)
7490 +#endif /* PAD */
7491 +
7492 +typedef volatile struct {
7493 + uint32 corecontrol;
7494 + uint32 PAD[2];
7495 + uint32 biststatus;
7496 + uint32 PAD[4];
7497 + uint32 intstatus;
7498 + uint32 intmask;
7499 + uint32 timer;
7500 +} mipsregs_t;
7501 +
7502 +extern uint32 sb_flag(void *sbh);
7503 +extern uint sb_irq(void *sbh);
7504 +
7505 +extern void BCMINIT(sb_serial_init)(void *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift));
7506 +
7507 +extern void *sb_jtagm_init(void *sbh, uint clkd, bool exttap);
7508 +extern void sb_jtagm_disable(void *h);
7509 +extern uint32 jtag_rwreg(void *h, uint32 ir, uint32 dr);
7510 +extern void BCMINIT(sb_mips_init)(void *sbh);
7511 +extern uint32 BCMINIT(sb_mips_clock)(void *sbh);
7512 +extern bool BCMINIT(sb_mips_setclock)(void *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock);
7513 +
7514 +extern uint32 BCMINIT(sb_memc_get_ncdl)(void *sbh);
7515 +extern uint32 BCMINIT(sb_mips_get_pfc)(void *sbh);
7516 +
7517 +#endif /* _LANGUAGE_ASSEMBLY */
7518 +
7519 +#endif /* _SBMIPS_H */
7520 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbpci.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbpci.h
7521 --- linux-2.4.30/arch/mips/bcm947xx/include/sbpci.h 1970-01-01 01:00:00.000000000 +0100
7522 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbpci.h 2005-08-22 01:34:46.334149792 +0200
7523 @@ -0,0 +1,117 @@
7524 +/*
7525 + * BCM47XX Sonics SiliconBackplane PCI core hardware definitions.
7526 + *
7527 + * $Id$
7528 + * Copyright 2005, Broadcom Corporation
7529 + * All Rights Reserved.
7530 + *
7531 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7532 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7533 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7534 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7535 + */
7536 +
7537 +#ifndef _SBPCI_H
7538 +#define _SBPCI_H
7539 +
7540 +/* cpp contortions to concatenate w/arg prescan */
7541 +#ifndef PAD
7542 +#define _PADLINE(line) pad ## line
7543 +#define _XSTR(line) _PADLINE(line)
7544 +#define PAD _XSTR(__LINE__)
7545 +#endif
7546 +
7547 +/* Sonics side: PCI core and host control registers */
7548 +typedef struct sbpciregs {
7549 + uint32 control; /* PCI control */
7550 + uint32 PAD[3];
7551 + uint32 arbcontrol; /* PCI arbiter control */
7552 + uint32 PAD[3];
7553 + uint32 intstatus; /* Interrupt status */
7554 + uint32 intmask; /* Interrupt mask */
7555 + uint32 sbtopcimailbox; /* Sonics to PCI mailbox */
7556 + uint32 PAD[9];
7557 + uint32 bcastaddr; /* Sonics broadcast address */
7558 + uint32 bcastdata; /* Sonics broadcast data */
7559 + uint32 PAD[2];
7560 + uint32 gpioin; /* ro: gpio input (>=rev2) */
7561 + uint32 gpioout; /* rw: gpio output (>=rev2) */
7562 + uint32 gpioouten; /* rw: gpio output enable (>= rev2) */
7563 + uint32 gpiocontrol; /* rw: gpio control (>= rev2) */
7564 + uint32 PAD[36];
7565 + uint32 sbtopci0; /* Sonics to PCI translation 0 */
7566 + uint32 sbtopci1; /* Sonics to PCI translation 1 */
7567 + uint32 sbtopci2; /* Sonics to PCI translation 2 */
7568 + uint32 PAD[445];
7569 + uint16 sprom[36]; /* SPROM shadow Area */
7570 + uint32 PAD[46];
7571 +} sbpciregs_t;
7572 +
7573 +/* PCI control */
7574 +#define PCI_RST_OE 0x01 /* When set, drives PCI_RESET out to pin */
7575 +#define PCI_RST 0x02 /* Value driven out to pin */
7576 +#define PCI_CLK_OE 0x04 /* When set, drives clock as gated by PCI_CLK out to pin */
7577 +#define PCI_CLK 0x08 /* Gate for clock driven out to pin */
7578 +
7579 +/* PCI arbiter control */
7580 +#define PCI_INT_ARB 0x01 /* When set, use an internal arbiter */
7581 +#define PCI_EXT_ARB 0x02 /* When set, use an external arbiter */
7582 +#define PCI_PARKID_MASK 0x06 /* Selects which agent is parked on an idle bus */
7583 +#define PCI_PARKID_SHIFT 1
7584 +#define PCI_PARKID_LAST 0 /* Last requestor */
7585 +#define PCI_PARKID_4710 1 /* 4710 */
7586 +#define PCI_PARKID_EXTREQ0 2 /* External requestor 0 */
7587 +#define PCI_PARKID_EXTREQ1 3 /* External requestor 1 */
7588 +
7589 +/* Interrupt status/mask */
7590 +#define PCI_INTA 0x01 /* PCI INTA# is asserted */
7591 +#define PCI_INTB 0x02 /* PCI INTB# is asserted */
7592 +#define PCI_SERR 0x04 /* PCI SERR# has been asserted (write one to clear) */
7593 +#define PCI_PERR 0x08 /* PCI PERR# has been asserted (write one to clear) */
7594 +#define PCI_PME 0x10 /* PCI PME# is asserted */
7595 +
7596 +/* (General) PCI/SB mailbox interrupts, two bits per pci function */
7597 +#define MAILBOX_F0_0 0x100 /* function 0, int 0 */
7598 +#define MAILBOX_F0_1 0x200 /* function 0, int 1 */
7599 +#define MAILBOX_F1_0 0x400 /* function 1, int 0 */
7600 +#define MAILBOX_F1_1 0x800 /* function 1, int 1 */
7601 +#define MAILBOX_F2_0 0x1000 /* function 2, int 0 */
7602 +#define MAILBOX_F2_1 0x2000 /* function 2, int 1 */
7603 +#define MAILBOX_F3_0 0x4000 /* function 3, int 0 */
7604 +#define MAILBOX_F3_1 0x8000 /* function 3, int 1 */
7605 +
7606 +/* Sonics broadcast address */
7607 +#define BCAST_ADDR_MASK 0xff /* Broadcast register address */
7608 +
7609 +/* Sonics to PCI translation types */
7610 +#define SBTOPCI0_MASK 0xfc000000
7611 +#define SBTOPCI1_MASK 0xfc000000
7612 +#define SBTOPCI2_MASK 0xc0000000
7613 +#define SBTOPCI_MEM 0
7614 +#define SBTOPCI_IO 1
7615 +#define SBTOPCI_CFG0 2
7616 +#define SBTOPCI_CFG1 3
7617 +#define SBTOPCI_PREF 0x4 /* prefetch enable */
7618 +#define SBTOPCI_BURST 0x8 /* burst enable */
7619 +#define SBTOPCI_RC_MASK 0x30 /* read command (>= rev11) */
7620 +#define SBTOPCI_RC_READ 0x00 /* memory read */
7621 +#define SBTOPCI_RC_READLINE 0x10 /* memory read line */
7622 +#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */
7623 +
7624 +/* PCI side: Reserved PCI configuration registers (see pcicfg.h) */
7625 +#define cap_list rsvd_a[0]
7626 +#define bar0_window dev_dep[0x80 - 0x40]
7627 +#define bar1_window dev_dep[0x84 - 0x40]
7628 +#define sprom_control dev_dep[0x88 - 0x40]
7629 +
7630 +#ifndef _LANGUAGE_ASSEMBLY
7631 +
7632 +extern int sbpci_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
7633 +extern int sbpci_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
7634 +extern void sbpci_ban(uint16 core);
7635 +extern int sbpci_init(void *sbh);
7636 +extern void sbpci_check(void *sbh);
7637 +
7638 +#endif /* !_LANGUAGE_ASSEMBLY */
7639 +
7640 +#endif /* _SBPCI_H */
7641 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbpcmcia.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbpcmcia.h
7642 --- linux-2.4.30/arch/mips/bcm947xx/include/sbpcmcia.h 1970-01-01 01:00:00.000000000 +0100
7643 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbpcmcia.h 2005-08-22 01:34:46.334149792 +0200
7644 @@ -0,0 +1,139 @@
7645 +/*
7646 + * BCM43XX Sonics SiliconBackplane PCMCIA core hardware definitions.
7647 + *
7648 + * $Id$
7649 + * Copyright 2005, Broadcom Corporation
7650 + * All Rights Reserved.
7651 + *
7652 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7653 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7654 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7655 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7656 + */
7657 +
7658 +#ifndef _SBPCMCIA_H
7659 +#define _SBPCMCIA_H
7660 +
7661 +
7662 +/* All the addresses that are offsets in attribute space are divided
7663 + * by two to account for the fact that odd bytes are invalid in
7664 + * attribute space and our read/write routines make the space appear
7665 + * as if they didn't exist. Still we want to show the original numbers
7666 + * as documented in the hnd_pcmcia core manual.
7667 + */
7668 +
7669 +/* PCMCIA Function Configuration Registers */
7670 +#define PCMCIA_FCR (0x700 / 2)
7671 +
7672 +#define FCR0_OFF 0
7673 +#define FCR1_OFF (0x40 / 2)
7674 +#define FCR2_OFF (0x80 / 2)
7675 +#define FCR3_OFF (0xc0 / 2)
7676 +
7677 +#define PCMCIA_FCR0 (0x700 / 2)
7678 +#define PCMCIA_FCR1 (0x740 / 2)
7679 +#define PCMCIA_FCR2 (0x780 / 2)
7680 +#define PCMCIA_FCR3 (0x7c0 / 2)
7681 +
7682 +/* Standard PCMCIA FCR registers */
7683 +
7684 +#define PCMCIA_COR 0
7685 +
7686 +#define COR_RST 0x80
7687 +#define COR_LEV 0x40
7688 +#define COR_IRQEN 0x04
7689 +#define COR_BLREN 0x01
7690 +#define COR_FUNEN 0x01
7691 +
7692 +
7693 +#define PCICIA_FCSR (2 / 2)
7694 +#define PCICIA_PRR (4 / 2)
7695 +#define PCICIA_SCR (6 / 2)
7696 +#define PCICIA_ESR (8 / 2)
7697 +
7698 +
7699 +#define PCM_MEMOFF 0x0000
7700 +#define F0_MEMOFF 0x1000
7701 +#define F1_MEMOFF 0x2000
7702 +#define F2_MEMOFF 0x3000
7703 +#define F3_MEMOFF 0x4000
7704 +
7705 +/* Memory base in the function fcr's */
7706 +#define MEM_ADDR0 (0x728 / 2)
7707 +#define MEM_ADDR1 (0x72a / 2)
7708 +#define MEM_ADDR2 (0x72c / 2)
7709 +
7710 +/* PCMCIA base plus Srom access in fcr0: */
7711 +#define PCMCIA_ADDR0 (0x072e / 2)
7712 +#define PCMCIA_ADDR1 (0x0730 / 2)
7713 +#define PCMCIA_ADDR2 (0x0732 / 2)
7714 +
7715 +#define MEM_SEG (0x0734 / 2)
7716 +#define SROM_CS (0x0736 / 2)
7717 +#define SROM_DATAL (0x0738 / 2)
7718 +#define SROM_DATAH (0x073a / 2)
7719 +#define SROM_ADDRL (0x073c / 2)
7720 +#define SROM_ADDRH (0x073e / 2)
7721 +
7722 +/* Values for srom_cs: */
7723 +#define SROM_IDLE 0
7724 +#define SROM_WRITE 1
7725 +#define SROM_READ 2
7726 +#define SROM_WEN 4
7727 +#define SROM_WDS 7
7728 +#define SROM_DONE 8
7729 +
7730 +/* CIS stuff */
7731 +
7732 +/* The CIS stops where the FCRs start */
7733 +#define CIS_SIZE PCMCIA_FCR
7734 +
7735 +/* Standard tuples we know about */
7736 +
7737 +#define CISTPL_MANFID 0x20 /* Manufacturer and device id */
7738 +#define CISTPL_FUNCE 0x22 /* Function extensions */
7739 +#define CISTPL_CFTABLE 0x1b /* Config table entry */
7740 +
7741 +/* Function extensions for LANs */
7742 +
7743 +#define LAN_TECH 1 /* Technology type */
7744 +#define LAN_SPEED 2 /* Raw bit rate */
7745 +#define LAN_MEDIA 3 /* Transmission media */
7746 +#define LAN_NID 4 /* Node identification (aka MAC addr) */
7747 +#define LAN_CONN 5 /* Connector standard */
7748 +
7749 +
7750 +/* CFTable */
7751 +#define CFTABLE_REGWIN_2K 0x08 /* 2k reg windows size */
7752 +#define CFTABLE_REGWIN_4K 0x10 /* 4k reg windows size */
7753 +#define CFTABLE_REGWIN_8K 0x20 /* 8k reg windows size */
7754 +
7755 +/* Vendor unique tuples are 0x80-0x8f. Within Broadcom we'll
7756 + * take one for HNBU, and use "extensions" (a la FUNCE) within it.
7757 + */
7758 +
7759 +#define CISTPL_BRCM_HNBU 0x80
7760 +
7761 +/* Subtypes of BRCM_HNBU: */
7762 +
7763 +#define HNBU_CHIPID 0x01 /* Six bytes with PCI vendor &
7764 + * device id and chiprev
7765 + */
7766 +#define HNBU_BOARDREV 0x02 /* Two bytes board revision */
7767 +#define HNBU_PAPARMS 0x03 /* Eleven bytes PA parameters */
7768 +#define HNBU_OEM 0x04 /* Eight bytes OEM data */
7769 +#define HNBU_CC 0x05 /* Default country code */
7770 +#define HNBU_AA 0x06 /* Antennas available */
7771 +#define HNBU_AG 0x07 /* Antenna gain */
7772 +#define HNBU_BOARDFLAGS 0x08 /* board flags */
7773 +#define HNBU_LED 0x09 /* LED set */
7774 +
7775 +
7776 +/* sbtmstatelow */
7777 +#define SBTML_INT_ACK 0x40000 /* ack the sb interrupt */
7778 +#define SBTML_INT_EN 0x20000 /* enable sb interrupt */
7779 +
7780 +/* sbtmstatehigh */
7781 +#define SBTMH_INT_STATUS 0x40000 /* sb interrupt status */
7782 +
7783 +#endif /* _SBPCMCIA_H */
7784 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbsdram.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbsdram.h
7785 --- linux-2.4.30/arch/mips/bcm947xx/include/sbsdram.h 1970-01-01 01:00:00.000000000 +0100
7786 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbsdram.h 2005-08-22 01:34:46.335149640 +0200
7787 @@ -0,0 +1,75 @@
7788 +/*
7789 + * BCM47XX Sonics SiliconBackplane SDRAM controller core hardware definitions.
7790 + *
7791 + * Copyright 2005, Broadcom Corporation
7792 + * All Rights Reserved.
7793 + *
7794 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7795 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7796 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7797 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7798 + * $Id$
7799 + */
7800 +
7801 +#ifndef _SBSDRAM_H
7802 +#define _SBSDRAM_H
7803 +
7804 +#ifndef _LANGUAGE_ASSEMBLY
7805 +
7806 +/* Sonics side: SDRAM core registers */
7807 +typedef volatile struct sbsdramregs {
7808 + uint32 initcontrol; /* Generates external SDRAM initialization sequence */
7809 + uint32 config; /* Initializes external SDRAM mode register */
7810 + uint32 refresh; /* Controls external SDRAM refresh rate */
7811 + uint32 pad1;
7812 + uint32 pad2;
7813 +} sbsdramregs_t;
7814 +
7815 +#endif
7816 +
7817 +/* SDRAM initialization control (initcontrol) register bits */
7818 +#define SDRAM_CBR 0x0001 /* Writing 1 generates refresh cycle and toggles bit */
7819 +#define SDRAM_PRE 0x0002 /* Writing 1 generates precharge cycle and toggles bit */
7820 +#define SDRAM_MRS 0x0004 /* Writing 1 generates mode register select cycle and toggles bit */
7821 +#define SDRAM_EN 0x0008 /* When set, enables access to SDRAM */
7822 +#define SDRAM_16Mb 0x0000 /* Use 16 Megabit SDRAM */
7823 +#define SDRAM_64Mb 0x0010 /* Use 64 Megabit SDRAM */
7824 +#define SDRAM_128Mb 0x0020 /* Use 128 Megabit SDRAM */
7825 +#define SDRAM_RSVMb 0x0030 /* Use special SDRAM */
7826 +#define SDRAM_RST 0x0080 /* Writing 1 causes soft reset of controller */
7827 +#define SDRAM_SELFREF 0x0100 /* Writing 1 enables self refresh mode */
7828 +#define SDRAM_PWRDOWN 0x0200 /* Writing 1 causes controller to power down */
7829 +#define SDRAM_32BIT 0x0400 /* When set, indicates 32 bit SDRAM interface */
7830 +#define SDRAM_9BITCOL 0x0800 /* When set, indicates 9 bit column */
7831 +
7832 +/* SDRAM configuration (config) register bits */
7833 +#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
7834 +#define SDRAM_BURST8 0x0001 /* Use burst of 8 */
7835 +#define SDRAM_BURST4 0x0002 /* Use burst of 4 */
7836 +#define SDRAM_BURST2 0x0003 /* Use burst of 2 */
7837 +#define SDRAM_CAS3 0x0000 /* Use CAS latency of 3 */
7838 +#define SDRAM_CAS2 0x0004 /* Use CAS latency of 2 */
7839 +
7840 +/* SDRAM refresh control (refresh) register bits */
7841 +#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
7842 +#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
7843 +
7844 +/* SDRAM Core default Init values (OCP ID 0x803) */
7845 +#define SDRAM_INIT MEM4MX16X2
7846 +#define SDRAM_CONFIG SDRAM_BURSTFULL
7847 +#define SDRAM_REFRESH SDRAM_REF(0x40)
7848 +
7849 +#define MEM1MX16 0x009 /* 2 MB */
7850 +#define MEM1MX16X2 0x409 /* 4 MB */
7851 +#define MEM2MX8X2 0x809 /* 4 MB */
7852 +#define MEM2MX8X4 0xc09 /* 8 MB */
7853 +#define MEM2MX32 0x439 /* 8 MB */
7854 +#define MEM4MX16 0x019 /* 8 MB */
7855 +#define MEM4MX16X2 0x419 /* 16 MB */
7856 +#define MEM8MX8X2 0x819 /* 16 MB */
7857 +#define MEM8MX16 0x829 /* 16 MB */
7858 +#define MEM4MX32 0x429 /* 16 MB */
7859 +#define MEM8MX8X4 0xc19 /* 32 MB */
7860 +#define MEM8MX16X2 0xc29 /* 32 MB */
7861 +
7862 +#endif /* _SBSDRAM_H */
7863 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbsocram.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbsocram.h
7864 --- linux-2.4.30/arch/mips/bcm947xx/include/sbsocram.h 1970-01-01 01:00:00.000000000 +0100
7865 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbsocram.h 2005-08-22 01:34:46.335149640 +0200
7866 @@ -0,0 +1,37 @@
7867 +/*
7868 + * BCM47XX Sonics SiliconBackplane embedded ram core
7869 + *
7870 + * Copyright 2005, Broadcom Corporation
7871 + * All Rights Reserved.
7872 + *
7873 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7874 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7875 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7876 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7877 + *
7878 + * $Id$
7879 + */
7880 +
7881 +#ifndef _SBSOCRAM_H
7882 +#define _SBSOCRAM_H
7883 +
7884 +#define SOCRAM_MEMSIZE 0x00
7885 +#define SOCRAM_BISTSTAT 0x0c
7886 +
7887 +
7888 +#ifndef _LANGUAGE_ASSEMBLY
7889 +
7890 +/* Memcsocram core registers */
7891 +typedef volatile struct sbsocramregs {
7892 + uint32 memsize;
7893 + uint32 biststat;
7894 +} sbsocramregs_t;
7895 +
7896 +#endif
7897 +
7898 +/* Them memory size is 2 to the power of the following
7899 + * base added to the contents of the memsize register.
7900 + */
7901 +#define SOCRAM_MEMSIZE_BASESHIFT 16
7902 +
7903 +#endif /* _SBSOCRAM_H */
7904 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sbutils.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sbutils.h
7905 --- linux-2.4.30/arch/mips/bcm947xx/include/sbutils.h 1970-01-01 01:00:00.000000000 +0100
7906 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sbutils.h 2005-08-22 01:34:46.336149488 +0200
7907 @@ -0,0 +1,87 @@
7908 +/*
7909 + * Misc utility routines for accessing chip-specific features
7910 + * of Broadcom HNBU SiliconBackplane-based chips.
7911 + *
7912 + * Copyright 2005, Broadcom Corporation
7913 + * All Rights Reserved.
7914 + *
7915 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7916 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7917 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7918 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7919 + *
7920 + * $Id$
7921 + */
7922 +
7923 +#ifndef _sbutils_h_
7924 +#define _sbutils_h_
7925 +
7926 +/*
7927 + * Many of the routines below take an 'sbh' handle as their first arg.
7928 + * Allocate this by calling sb_attach(). Free it by calling sb_detach().
7929 + * At any one time, the sbh is logically focused on one particular sb core
7930 + * (the "current core").
7931 + * Use sb_setcore() or sb_setcoreidx() to change the association to another core.
7932 + */
7933 +
7934 +/* exported externs */
7935 +extern void * BCMINIT(sb_attach)(uint pcidev, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz);
7936 +extern void * BCMINIT(sb_kattach)(void);
7937 +extern void sb_detach(void *sbh);
7938 +extern uint BCMINIT(sb_chip)(void *sbh);
7939 +extern uint BCMINIT(sb_chiprev)(void *sbh);
7940 +extern uint BCMINIT(sb_chipcrev)(void *sbh);
7941 +extern uint BCMINIT(sb_chippkg)(void *sbh);
7942 +extern uint BCMINIT(sb_pcirev)(void *sbh);
7943 +extern uint BCMINIT(sb_pcmciarev)(void *sbh);
7944 +extern uint BCMINIT(sb_boardvendor)(void *sbh);
7945 +extern uint BCMINIT(sb_boardtype)(void *sbh);
7946 +extern uint sb_bus(void *sbh);
7947 +extern uint sb_corelist(void *sbh, uint coreid[]);
7948 +extern uint sb_coreid(void *sbh);
7949 +extern uint sb_coreidx(void *sbh);
7950 +extern uint sb_coreunit(void *sbh);
7951 +extern uint sb_corevendor(void *sbh);
7952 +extern uint sb_corerev(void *sbh);
7953 +extern void *sb_osh(void *sbh);
7954 +extern void *sb_coreregs(void *sbh);
7955 +extern uint32 sb_coreflags(void *sbh, uint32 mask, uint32 val);
7956 +extern uint32 sb_coreflagshi(void *sbh, uint32 mask, uint32 val);
7957 +extern bool sb_iscoreup(void *sbh);
7958 +extern void *sb_setcoreidx(void *sbh, uint coreidx);
7959 +extern void *sb_setcore(void *sbh, uint coreid, uint coreunit);
7960 +extern void sb_commit(void *sbh);
7961 +extern uint32 sb_base(uint32 admatch);
7962 +extern uint32 sb_size(uint32 admatch);
7963 +extern void sb_core_reset(void *sbh, uint32 bits);
7964 +extern void sb_core_tofixup(void *sbh);
7965 +extern void sb_core_disable(void *sbh, uint32 bits);
7966 +extern uint32 sb_clock_rate(uint32 pll_type, uint32 n, uint32 m);
7967 +extern uint32 sb_clock(void *sbh);
7968 +extern void sb_pci_setup(void *sbh, uint32 *dmaoffset, uint coremask);
7969 +extern void sb_pcmcia_init(void *sbh);
7970 +extern void sb_watchdog(void *sbh, uint ticks);
7971 +extern void *sb_gpiosetcore(void *sbh);
7972 +extern uint32 sb_gpiocontrol(void *sbh, uint32 mask, uint32 val);
7973 +extern uint32 sb_gpioouten(void *sbh, uint32 mask, uint32 val);
7974 +extern uint32 sb_gpioout(void *sbh, uint32 mask, uint32 val);
7975 +extern uint32 sb_gpioin(void *sbh);
7976 +extern uint32 sb_gpiointpolarity(void *sbh, uint32 mask, uint32 val);
7977 +extern uint32 sb_gpiointmask(void *sbh, uint32 mask, uint32 val);
7978 +extern void sb_pwrctl_init(void *sbh);
7979 +extern uint16 sb_pwrctl_fast_pwrup_delay(void *sbh);
7980 +extern bool sb_pwrctl_clk(void *sbh, uint mode);
7981 +extern int sb_pwrctl_xtal(void *sbh, uint what, bool on);
7982 +extern int sb_pwrctl_slowclk(void *sbh, bool set, uint *div);
7983 +extern void sb_register_intr_callback(void *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg);
7984 +
7985 +/* pwrctl xtal what flags */
7986 +#define XTAL 0x1 /* primary crystal oscillator (2050) */
7987 +#define PLL 0x2 /* main chip pll */
7988 +
7989 +/* pwrctl clk mode */
7990 +#define CLK_FAST 0 /* force fast (pll) clock */
7991 +#define CLK_SLOW 1 /* force slow clock */
7992 +#define CLK_DYNAMIC 2 /* enable dynamic power control */
7993 +
7994 +#endif /* _sbutils_h_ */
7995 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/sflash.h linux-2.4.30.dev/arch/mips/bcm947xx/include/sflash.h
7996 --- linux-2.4.30/arch/mips/bcm947xx/include/sflash.h 1970-01-01 01:00:00.000000000 +0100
7997 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/sflash.h 2005-08-22 01:34:46.336149488 +0200
7998 @@ -0,0 +1,36 @@
7999 +/*
8000 + * Broadcom SiliconBackplane chipcommon serial flash interface
8001 + *
8002 + * Copyright 2005, Broadcom Corporation
8003 + * All Rights Reserved.
8004 + *
8005 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8006 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8007 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8008 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8009 + *
8010 + * $Id$
8011 + */
8012 +
8013 +#ifndef _sflash_h_
8014 +#define _sflash_h_
8015 +
8016 +#include <typedefs.h>
8017 +#include <sbchipc.h>
8018 +
8019 +struct sflash {
8020 + uint blocksize; /* Block size */
8021 + uint numblocks; /* Number of blocks */
8022 + uint32 type; /* Type */
8023 + uint size; /* Total size in bytes */
8024 +};
8025 +
8026 +/* Utility functions */
8027 +extern int sflash_poll(chipcregs_t *cc, uint offset);
8028 +extern int sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf);
8029 +extern int sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
8030 +extern int sflash_erase(chipcregs_t *cc, uint offset);
8031 +extern int sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
8032 +extern struct sflash * sflash_init(chipcregs_t *cc);
8033 +
8034 +#endif /* _sflash_h_ */
8035 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/trxhdr.h linux-2.4.30.dev/arch/mips/bcm947xx/include/trxhdr.h
8036 --- linux-2.4.30/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +0100
8037 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/trxhdr.h 2005-08-22 01:34:46.337149336 +0200
8038 @@ -0,0 +1,33 @@
8039 +/*
8040 + * TRX image file header format.
8041 + *
8042 + * Copyright 2005, Broadcom Corporation
8043 + * All Rights Reserved.
8044 + *
8045 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8046 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8047 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8048 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8049 + *
8050 + * $Id$
8051 + */
8052 +
8053 +#include <typedefs.h>
8054 +
8055 +#define TRX_MAGIC 0x30524448 /* "HDR0" */
8056 +#define TRX_VERSION 1
8057 +#define TRX_MAX_LEN 0x3A0000
8058 +#define TRX_NO_HEADER 1 /* Do not write TRX header */
8059 +#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
8060 +#define TRX_MAX_OFFSET 3
8061 +
8062 +struct trx_header {
8063 + uint32 magic; /* "HDR0" */
8064 + uint32 len; /* Length of file including header */
8065 + uint32 crc32; /* 32-bit CRC from flag_version to end of file */
8066 + uint32 flag_version; /* 0:15 flags, 16:31 version */
8067 + uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
8068 +};
8069 +
8070 +/* Compatibility */
8071 +typedef struct trx_header TRXHDR, *PTRXHDR;
8072 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/typedefs.h linux-2.4.30.dev/arch/mips/bcm947xx/include/typedefs.h
8073 --- linux-2.4.30/arch/mips/bcm947xx/include/typedefs.h 1970-01-01 01:00:00.000000000 +0100
8074 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/typedefs.h 2005-08-22 01:34:46.338149184 +0200
8075 @@ -0,0 +1,322 @@
8076 +/*
8077 + * Copyright 2005, Broadcom Corporation
8078 + * All Rights Reserved.
8079 + *
8080 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8081 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8082 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8083 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8084 + * $Id$
8085 + */
8086 +
8087 +#ifndef _TYPEDEFS_H_
8088 +#define _TYPEDEFS_H_
8089 +
8090 +
8091 +/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
8092 + * typedef file "site_typedefs.h".
8093 + *
8094 + * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
8095 + * section of this file makes inferences about the compile environment
8096 + * based on defined symbols and possibly compiler pragmas.
8097 + *
8098 + * Following these two sections is the "Default Typedefs"
8099 + * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
8100 + * defined. This section has a default set of typedefs and a few
8101 + * proprocessor symbols (TRUE, FALSE, NULL, ...).
8102 + */
8103 +
8104 +#ifdef SITE_TYPEDEFS
8105 +
8106 +/*******************************************************************************
8107 + * Site Specific Typedefs
8108 + *******************************************************************************/
8109 +
8110 +#include "site_typedefs.h"
8111 +
8112 +#else
8113 +
8114 +/*******************************************************************************
8115 + * Inferred Typedefs
8116 + *******************************************************************************/
8117 +
8118 +/* Infer the compile environment based on preprocessor symbols and pramas.
8119 + * Override type definitions as needed, and include configuration dependent
8120 + * header files to define types.
8121 + */
8122 +
8123 +#ifdef __cplusplus
8124 +
8125 +#define TYPEDEF_BOOL
8126 +#ifndef FALSE
8127 +#define FALSE false
8128 +#endif
8129 +#ifndef TRUE
8130 +#define TRUE true
8131 +#endif
8132 +
8133 +#else /* ! __cplusplus */
8134 +
8135 +#if defined(_WIN32)
8136 +
8137 +#define TYPEDEF_BOOL
8138 +typedef unsigned char bool; /* consistent w/BOOL */
8139 +
8140 +#endif /* _WIN32 */
8141 +
8142 +#endif /* ! __cplusplus */
8143 +
8144 +/* use the Windows ULONG_PTR type when compiling for 64 bit */
8145 +#if defined(_WIN64)
8146 +#include <basetsd.h>
8147 +#define TYPEDEF_UINTPTR
8148 +typedef ULONG_PTR uintptr;
8149 +#endif
8150 +
8151 +#ifdef _MSC_VER /* Microsoft C */
8152 +#define TYPEDEF_INT64
8153 +#define TYPEDEF_UINT64
8154 +typedef signed __int64 int64;
8155 +typedef unsigned __int64 uint64;
8156 +#endif
8157 +
8158 +#if defined(MACOSX) && defined(KERNEL)
8159 +#define TYPEDEF_BOOL
8160 +#endif
8161 +
8162 +
8163 +#if defined(linux)
8164 +#define TYPEDEF_UINT
8165 +#define TYPEDEF_USHORT
8166 +#define TYPEDEF_ULONG
8167 +#endif
8168 +
8169 +#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
8170 +#define TYPEDEF_UINT
8171 +#define TYPEDEF_USHORT
8172 +#endif
8173 +
8174 +
8175 +/* Do not support the (u)int64 types with strict ansi for GNU C */
8176 +#if defined(__GNUC__) && defined(__STRICT_ANSI__)
8177 +#define TYPEDEF_INT64
8178 +#define TYPEDEF_UINT64
8179 +#endif
8180 +
8181 +/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
8182 + * for singned or unsigned */
8183 +#if defined(__ICL)
8184 +
8185 +#define TYPEDEF_INT64
8186 +
8187 +#if defined(__STDC__)
8188 +#define TYPEDEF_UINT64
8189 +#endif
8190 +
8191 +#endif /* __ICL */
8192 +
8193 +
8194 +#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
8195 +
8196 +/* pick up ushort & uint from standard types.h */
8197 +#if defined(linux) && defined(__KERNEL__)
8198 +
8199 +#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
8200 +
8201 +#else
8202 +
8203 +#include <sys/types.h>
8204 +
8205 +#endif
8206 +
8207 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */
8208 +
8209 +#if defined(MACOSX) && defined(KERNEL)
8210 +#include <IOKit/IOTypes.h>
8211 +#endif
8212 +
8213 +
8214 +/* use the default typedefs in the next section of this file */
8215 +#define USE_TYPEDEF_DEFAULTS
8216 +
8217 +#endif /* SITE_TYPEDEFS */
8218 +
8219 +
8220 +/*******************************************************************************
8221 + * Default Typedefs
8222 + *******************************************************************************/
8223 +
8224 +#ifdef USE_TYPEDEF_DEFAULTS
8225 +#undef USE_TYPEDEF_DEFAULTS
8226 +
8227 +#ifndef TYPEDEF_BOOL
8228 +typedef /*@abstract@*/ unsigned char bool;
8229 +#endif
8230 +
8231 +/*----------------------- define uchar, ushort, uint, ulong ------------------*/
8232 +
8233 +#ifndef TYPEDEF_UCHAR
8234 +typedef unsigned char uchar;
8235 +#endif
8236 +
8237 +#ifndef TYPEDEF_USHORT
8238 +typedef unsigned short ushort;
8239 +#endif
8240 +
8241 +#ifndef TYPEDEF_UINT
8242 +typedef unsigned int uint;
8243 +#endif
8244 +
8245 +#ifndef TYPEDEF_ULONG
8246 +typedef unsigned long ulong;
8247 +#endif
8248 +
8249 +/*----------------------- define [u]int8/16/32/64, uintptr --------------------*/
8250 +
8251 +#ifndef TYPEDEF_UINT8
8252 +typedef unsigned char uint8;
8253 +#endif
8254 +
8255 +#ifndef TYPEDEF_UINT16
8256 +typedef unsigned short uint16;
8257 +#endif
8258 +
8259 +#ifndef TYPEDEF_UINT32
8260 +typedef unsigned int uint32;
8261 +#endif
8262 +
8263 +#ifndef TYPEDEF_UINT64
8264 +typedef unsigned long long uint64;
8265 +#endif
8266 +
8267 +#ifndef TYPEDEF_UINTPTR
8268 +typedef unsigned int uintptr;
8269 +#endif
8270 +
8271 +#ifndef TYPEDEF_INT8
8272 +typedef signed char int8;
8273 +#endif
8274 +
8275 +#ifndef TYPEDEF_INT16
8276 +typedef signed short int16;
8277 +#endif
8278 +
8279 +#ifndef TYPEDEF_INT32
8280 +typedef signed int int32;
8281 +#endif
8282 +
8283 +#ifndef TYPEDEF_INT64
8284 +typedef signed long long int64;
8285 +#endif
8286 +
8287 +/*----------------------- define float32/64, float_t -----------------------*/
8288 +
8289 +#ifndef TYPEDEF_FLOAT32
8290 +typedef float float32;
8291 +#endif
8292 +
8293 +#ifndef TYPEDEF_FLOAT64
8294 +typedef double float64;
8295 +#endif
8296 +
8297 +/*
8298 + * abstracted floating point type allows for compile time selection of
8299 + * single or double precision arithmetic. Compiling with -DFLOAT32
8300 + * selects single precision; the default is double precision.
8301 + */
8302 +
8303 +#ifndef TYPEDEF_FLOAT_T
8304 +
8305 +#if defined(FLOAT32)
8306 +typedef float32 float_t;
8307 +#else /* default to double precision floating point */
8308 +typedef float64 float_t;
8309 +#endif
8310 +
8311 +#endif /* TYPEDEF_FLOAT_T */
8312 +
8313 +/*----------------------- define macro values -----------------------------*/
8314 +
8315 +#ifndef FALSE
8316 +#define FALSE 0
8317 +#endif
8318 +
8319 +#ifndef TRUE
8320 +#define TRUE 1
8321 +#endif
8322 +
8323 +#ifndef NULL
8324 +#define NULL 0
8325 +#endif
8326 +
8327 +#ifndef OFF
8328 +#define OFF 0
8329 +#endif
8330 +
8331 +#ifndef ON
8332 +#define ON 1
8333 +#endif
8334 +
8335 +#define AUTO (-1)
8336 +
8337 +/* Reclaiming text and data :
8338 + The following macros specify special linker sections that can be reclaimed
8339 + after a system is considered 'up'.
8340 + */
8341 +#if defined(__GNUC__) && defined(BCMRECLAIM)
8342 +extern bool bcmreclaimed;
8343 +#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data##_ini
8344 +#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn##_ini
8345 +#define BCMINIT(_id) _id##_ini
8346 +#else
8347 +#define BCMINITDATA(_data) _data
8348 +#define BCMINITFN(_fn) _fn
8349 +#define BCMINIT(_id) _id
8350 +#define bcmreclaimed 0
8351 +#endif
8352 +
8353 +/*----------------------- define PTRSZ, INLINE ----------------------------*/
8354 +
8355 +#ifndef PTRSZ
8356 +#define PTRSZ sizeof (char*)
8357 +#endif
8358 +
8359 +#ifndef INLINE
8360 +
8361 +#ifdef _MSC_VER
8362 +
8363 +#define INLINE __inline
8364 +
8365 +#elif __GNUC__
8366 +
8367 +#define INLINE __inline__
8368 +
8369 +#else
8370 +
8371 +#define INLINE
8372 +
8373 +#endif /* _MSC_VER */
8374 +
8375 +#endif /* INLINE */
8376 +
8377 +#undef TYPEDEF_BOOL
8378 +#undef TYPEDEF_UCHAR
8379 +#undef TYPEDEF_USHORT
8380 +#undef TYPEDEF_UINT
8381 +#undef TYPEDEF_ULONG
8382 +#undef TYPEDEF_UINT8
8383 +#undef TYPEDEF_UINT16
8384 +#undef TYPEDEF_UINT32
8385 +#undef TYPEDEF_UINT64
8386 +#undef TYPEDEF_UINTPTR
8387 +#undef TYPEDEF_INT8
8388 +#undef TYPEDEF_INT16
8389 +#undef TYPEDEF_INT32
8390 +#undef TYPEDEF_INT64
8391 +#undef TYPEDEF_FLOAT32
8392 +#undef TYPEDEF_FLOAT64
8393 +#undef TYPEDEF_FLOAT_T
8394 +
8395 +#endif /* USE_TYPEDEF_DEFAULTS */
8396 +
8397 +#endif /* _TYPEDEFS_H_ */
8398 diff -urN linux-2.4.30/arch/mips/bcm947xx/include/wlioctl.h linux-2.4.30.dev/arch/mips/bcm947xx/include/wlioctl.h
8399 --- linux-2.4.30/arch/mips/bcm947xx/include/wlioctl.h 1970-01-01 01:00:00.000000000 +0100
8400 +++ linux-2.4.30.dev/arch/mips/bcm947xx/include/wlioctl.h 2005-08-22 01:34:46.339149032 +0200
8401 @@ -0,0 +1,825 @@
8402 +/*
8403 + * Custom OID/ioctl definitions for
8404 + * Broadcom 802.11abg Networking Device Driver
8405 + *
8406 + * Definitions subject to change without notice.
8407 + *
8408 + * Copyright 2005, Broadcom Corporation
8409 + * All Rights Reserved.
8410 + *
8411 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8412 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8413 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8414 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8415 + *
8416 + * $Id$
8417 + */
8418 +
8419 +#ifndef _wlioctl_h_
8420 +#define _wlioctl_h_
8421 +
8422 +#include <typedefs.h>
8423 +#include <proto/ethernet.h>
8424 +#include <proto/802.11.h>
8425 +
8426 +/* require default structure packing */
8427 +#if !defined(__GNUC__)
8428 +#pragma pack(push,8)
8429 +#endif
8430 +
8431 +#define WL_NUMRATES 255 /* max # of rates in a rateset */
8432 +
8433 +typedef struct wl_rateset {
8434 + uint32 count; /* # rates in this set */
8435 + uint8 rates[WL_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */
8436 +} wl_rateset_t;
8437 +
8438 +#define WL_CHANSPEC_CHAN_MASK 0x0fff
8439 +#define WL_CHANSPEC_BAND_MASK 0xf000
8440 +#define WL_CHANSPEC_BAND_SHIFT 12
8441 +#define WL_CHANSPEC_BAND_A 0x1000
8442 +#define WL_CHANSPEC_BAND_B 0x2000
8443 +
8444 +/*
8445 + * Per-bss information structure.
8446 + */
8447 +
8448 +#define WL_BSS_INFO_VERSION 107 /* current version of wl_bss_info struct */
8449 +
8450 +typedef struct wl_bss_info {
8451 + uint32 version; /* version field */
8452 + uint32 length; /* byte length of data in this record, starting at version and including IEs */
8453 + struct ether_addr BSSID;
8454 + uint16 beacon_period; /* units are Kusec */
8455 + uint16 capability; /* Capability information */
8456 + uint8 SSID_len;
8457 + uint8 SSID[32];
8458 + struct {
8459 + uint count; /* # rates in this set */
8460 + uint8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */
8461 + } rateset; /* supported rates */
8462 + uint8 channel; /* Channel no. */
8463 + uint16 atim_window; /* units are Kusec */
8464 + uint8 dtim_period; /* DTIM period */
8465 + int16 RSSI; /* receive signal strength (in dBm) */
8466 + int8 phy_noise; /* noise (in dBm) */
8467 + uint32 ie_length; /* byte length of Information Elements */
8468 + /* variable length Information Elements */
8469 +} wl_bss_info_t;
8470 +
8471 +typedef struct wlc_ssid {
8472 + uint32 SSID_len;
8473 + uchar SSID[32];
8474 +} wlc_ssid_t;
8475 +
8476 +typedef struct wl_scan_params {
8477 + wlc_ssid_t ssid; /* default is {0, ""} */
8478 + struct ether_addr bssid;/* default is bcast */
8479 + int8 bss_type; /* default is any, DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT */
8480 + int8 scan_type; /* -1 use default, DOT11_SCANTYPE_ACTIVE/PASSIVE */
8481 + int32 nprobes; /* -1 use default, number of probes per channel */
8482 + int32 active_time; /* -1 use default, dwell time per channel for active scanning */
8483 + int32 passive_time; /* -1 use default, dwell time per channel for passive scanning */
8484 + int32 home_time; /* -1 use default, dwell time for the home channel between channel scans */
8485 + int32 channel_num; /* 0 use default (all available channels), count of channels in channel_list */
8486 + uint16 channel_list[1]; /* list of chanspecs */
8487 +} wl_scan_params_t;
8488 +/* size of wl_scan_params not including variable length array */
8489 +#define WL_SCAN_PARAMS_FIXED_SIZE 64
8490 +
8491 +typedef struct wl_scan_results {
8492 + uint32 buflen;
8493 + uint32 version;
8494 + uint32 count;
8495 + wl_bss_info_t bss_info[1];
8496 +} wl_scan_results_t;
8497 +/* size of wl_scan_results not including variable length array */
8498 +#define WL_SCAN_RESULTS_FIXED_SIZE 12
8499 +
8500 +/* uint32 list */
8501 +typedef struct wl_uint32_list {
8502 + /* in - # of elements, out - # of entries */
8503 + uint32 count;
8504 + /* variable length uint32 list */
8505 + uint32 element[1];
8506 +} wl_uint32_list_t;
8507 +
8508 +#define WLC_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NULL */
8509 +
8510 +typedef struct wl_channels_in_country {
8511 + uint32 buflen;
8512 + uint32 band;
8513 + char country_abbrev[WLC_CNTRY_BUF_SZ];
8514 + uint32 count;
8515 + uint32 channel[1];
8516 +} wl_channels_in_country_t;
8517 +
8518 +typedef struct wl_country_list {
8519 + uint32 buflen;
8520 + uint32 band_set;
8521 + uint32 band;
8522 + uint32 count;
8523 + char country_abbrev[1];
8524 +} wl_country_list_t;
8525 +
8526 +#define WL_RM_TYPE_BASIC 1
8527 +#define WL_RM_TYPE_CCA 2
8528 +#define WL_RM_TYPE_RPI 3
8529 +
8530 +#define WL_RM_FLAG_PARALLEL (1<<0)
8531 +
8532 +#define WL_RM_FLAG_LATE (1<<1)
8533 +#define WL_RM_FLAG_INCAPABLE (1<<2)
8534 +#define WL_RM_FLAG_REFUSED (1<<3)
8535 +
8536 +typedef struct wl_rm_req_elt {
8537 + int8 type;
8538 + int8 flags;
8539 + uint16 chanspec;
8540 + uint32 token; /* token for this measurement */
8541 + uint32 tsf_h; /* TSF high 32-bits of Measurement start time */
8542 + uint32 tsf_l; /* TSF low 32-bits */
8543 + uint32 dur; /* TUs */
8544 +} wl_rm_req_elt_t;
8545 +
8546 +typedef struct wl_rm_req {
8547 + uint32 token; /* overall measurement set token */
8548 + uint32 count; /* number of measurement reqests */
8549 + wl_rm_req_elt_t req[1]; /* variable length block of requests */
8550 +} wl_rm_req_t;
8551 +#define WL_RM_REQ_FIXED_LEN 8
8552 +
8553 +typedef struct wl_rm_rep_elt {
8554 + int8 type;
8555 + int8 flags;
8556 + uint16 chanspec;
8557 + uint32 token; /* token for this measurement */
8558 + uint32 tsf_h; /* TSF high 32-bits of Measurement start time */
8559 + uint32 tsf_l; /* TSF low 32-bits */
8560 + uint32 dur; /* TUs */
8561 + uint32 len; /* byte length of data block */
8562 + uint8 data[1]; /* variable length data block */
8563 +} wl_rm_rep_elt_t;
8564 +#define WL_RM_REP_ELT_FIXED_LEN 24 /* length excluding data block */
8565 +
8566 +#define WL_RPI_REP_BIN_NUM 8
8567 +typedef struct wl_rm_rpi_rep {
8568 + uint8 rpi[WL_RPI_REP_BIN_NUM];
8569 + int8 rpi_max[WL_RPI_REP_BIN_NUM];
8570 +} wl_rm_rpi_rep_t;
8571 +
8572 +typedef struct wl_rm_rep {
8573 + uint32 token; /* overall measurement set token */
8574 + uint32 len; /* length of measurement report block */
8575 + wl_rm_rep_elt_t rep[1]; /* variable length block of reports */
8576 +} wl_rm_rep_t;
8577 +#define WL_RM_REP_FIXED_LEN 8
8578 +
8579 +
8580 +#if defined(BCMSUP_PSK)
8581 +typedef enum sup_auth_status {
8582 + WLC_SUP_DISCONNECTED = 0,
8583 + WLC_SUP_CONNECTING,
8584 + WLC_SUP_IDREQUIRED,
8585 + WLC_SUP_AUTHENTICATING,
8586 + WLC_SUP_AUTHENTICATED,
8587 + WLC_SUP_KEYXCHANGE,
8588 + WLC_SUP_KEYED
8589 +} sup_auth_status_t;
8590 +#endif /* BCMCCX | BCMSUP_PSK */
8591 +
8592 +/* Enumerate crypto algorithms */
8593 +#define CRYPTO_ALGO_OFF 0
8594 +#define CRYPTO_ALGO_WEP1 1
8595 +#define CRYPTO_ALGO_TKIP 2
8596 +#define CRYPTO_ALGO_WEP128 3
8597 +#define CRYPTO_ALGO_AES_CCM 4
8598 +#define CRYPTO_ALGO_AES_OCB_MSDU 5
8599 +#define CRYPTO_ALGO_AES_OCB_MPDU 6
8600 +#define CRYPTO_ALGO_NALG 7
8601 +
8602 +#define WSEC_GEN_MIC_ERROR 0x0001
8603 +#define WSEC_GEN_REPLAY 0x0002
8604 +
8605 +#define WL_SOFT_KEY (1 << 0) /* Indicates this key is using soft encrypt */
8606 +#define WL_PRIMARY_KEY (1 << 1) /* Indicates this key is the primary (ie tx) key */
8607 +#define WL_KF_RES_4 (1 << 4) /* Reserved for backward compat */
8608 +#define WL_KF_RES_5 (1 << 5) /* Reserved for backward compat */
8609 +
8610 +typedef struct wl_wsec_key {
8611 + uint32 index; /* key index */
8612 + uint32 len; /* key length */
8613 + uint8 data[DOT11_MAX_KEY_SIZE]; /* key data */
8614 + uint32 pad_1[18];
8615 + uint32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
8616 + uint32 flags; /* misc flags */
8617 + uint32 pad_2[2];
8618 + int pad_3;
8619 + int iv_initialized; /* has IV been initialized already? */
8620 + int pad_4;
8621 + /* Rx IV */
8622 + struct {
8623 + uint32 hi; /* upper 32 bits of IV */
8624 + uint16 lo; /* lower 16 bits of IV */
8625 + } rxiv;
8626 + uint32 pad_5[2];
8627 + struct ether_addr ea; /* per station */
8628 +} wl_wsec_key_t;
8629 +
8630 +
8631 +#define WSEC_MIN_PSK_LEN 8
8632 +#define WSEC_MAX_PSK_LEN 64
8633 +
8634 +/* Flag for key material needing passhash'ing */
8635 +#define WSEC_PASSPHRASE (1<<0)
8636 +
8637 +/* recepticle for WLC_SET_WSEC_PMK parameter */
8638 +typedef struct {
8639 + ushort key_len; /* octets in key material */
8640 + ushort flags; /* key handling qualification */
8641 + uint8 key[WSEC_MAX_PSK_LEN]; /* PMK material */
8642 +} wsec_pmk_t;
8643 +
8644 +/* wireless security bitvec */
8645 +#define WEP_ENABLED 1
8646 +#define TKIP_ENABLED 2
8647 +#define AES_ENABLED 4
8648 +#define WSEC_SWFLAG 8
8649 +
8650 +/* WPA authentication mode bitvec */
8651 +#define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */
8652 +#define WPA_AUTH_NONE 0x0001 /* none (IBSS) */
8653 +#define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */
8654 +#define WPA_AUTH_PSK 0x0004 /* Pre-shared key */
8655 +/*#define WPA_AUTH_8021X 0x0020*/ /* 802.1x, reserved */
8656 +#define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
8657 +#define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
8658 +
8659 +typedef struct wl_led_info {
8660 + uint32 index; /* led index */
8661 + uint32 behavior;
8662 + bool activehi;
8663 +} wl_led_info_t;
8664 +
8665 +/*
8666 + * definitions for driver messages passed from WL to NAS.
8667 + */
8668 +/* Use this to recognize wpa and 802.1x driver messages. */
8669 +static const uint8 wl_wpa_snap_template[] =
8670 + { 0xaa, 0xaa, 0x03, 0x00, 0x90, 0x4c };
8671 +
8672 +#define WL_WPA_MSG_IFNAME_MAX 16
8673 +
8674 +/* WPA driver message */
8675 +typedef struct wl_wpa_header {
8676 + struct ether_header eth;
8677 + struct dot11_llc_snap_header snap;
8678 + uint8 version;
8679 + uint8 type;
8680 + /* version 2 additions */
8681 + char ifname[WL_WPA_MSG_IFNAME_MAX];
8682 + /* version specific data */
8683 + /* uint8 data[1]; */
8684 +} wl_wpa_header_t;
8685 +
8686 +#define WL_WPA_HEADER_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN + 2 + WL_WPA_MSG_IFNAME_MAX)
8687 +
8688 +/* WPA driver message ethertype - private between wlc and nas */
8689 +#define WL_WPA_ETHER_TYPE 0x9999
8690 +
8691 +/* WPA driver message current version */
8692 +#define WL_WPA_MSG_VERSION 2
8693 +
8694 +/* Type field values for the 802.2 driver messages for WPA. */
8695 +#define WLC_ASSOC_MSG 1
8696 +#define WLC_DISASSOC_MSG 2
8697 +#define WLC_PTK_MIC_MSG 3
8698 +#define WLC_GTK_MIC_MSG 4
8699 +
8700 +/* 802.1x driver message */
8701 +typedef struct wl_eapol_header {
8702 + struct ether_header eth;
8703 + struct dot11_llc_snap_header snap;
8704 + uint8 version;
8705 + uint8 reserved;
8706 + char ifname[WL_WPA_MSG_IFNAME_MAX];
8707 + /* version specific data */
8708 + /* uint8 802_1x_msg[1]; */
8709 +} wl_eapol_header_t;
8710 +
8711 +#define WL_EAPOL_HEADER_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN + 2 + WL_WPA_MSG_IFNAME_MAX)
8712 +
8713 +/* 802.1x driver message ethertype - private between wlc and nas */
8714 +#define WL_EAPOL_ETHER_TYPE 0x999A
8715 +
8716 +/* 802.1x driver message current version */
8717 +#define WL_EAPOL_MSG_VERSION 1
8718 +
8719 +#define WL_SECPVT_DATA_LEN (ETHER_HDR_LEN + 4 + WL_WPA_MSG_IFNAME_MAX)
8720 +
8721 +/* message header for the private data exchange between nas and wl*/
8722 +typedef struct wl_secpvt_data {
8723 + struct ether_header eth; /* use the Type field in the eth header with the private type*/
8724 + uint8 version;
8725 + uint8 sub_type;
8726 + uint16 data_len;
8727 + char ifname[WL_WPA_MSG_IFNAME_MAX];
8728 + /* version specific data */
8729 + /* uint8 802_1x_msg[1]; */
8730 +}wl_secpvt_data_t;
8731 +
8732 +
8733 +/* srom read/write struct passed through ioctl */
8734 +typedef struct {
8735 + uint byteoff; /* byte offset */
8736 + uint nbytes; /* number of bytes */
8737 + uint16 buf[1];
8738 +} srom_rw_t;
8739 +
8740 +/* R_REG and W_REG struct passed through ioctl */
8741 +typedef struct {
8742 + uint32 byteoff; /* byte offset of the field in d11regs_t */
8743 + uint32 val; /* read/write value of the field */
8744 + uint32 size; /* sizeof the field */
8745 +} rw_reg_t;
8746 +
8747 +/* Structure used by GET/SET_ATTEN ioctls */
8748 +typedef struct {
8749 + uint16 auto_ctrl; /* 1: Automatic control, 0: overriden */
8750 + uint16 bb; /* Baseband attenuation */
8751 + uint16 radio; /* Radio attenuation */
8752 + uint16 txctl1; /* Radio TX_CTL1 value */
8753 +} atten_t;
8754 +
8755 +/* Used to get specific STA parameters */
8756 +typedef struct {
8757 + uint32 val;
8758 + struct ether_addr ea;
8759 +} scb_val_t;
8760 +
8761 +/* Event data type */
8762 +typedef struct {
8763 + uint msg; /* Message (see below) */
8764 + struct ether_addr *addr; /* Station address (if applicable) */
8765 + uint status; /* Status code (see below) */
8766 + uint reason; /* Reason code (if applicable) */
8767 + uint auth_type; /* WLC_E_AUTH */
8768 + bool link; /* WLC_E_LINK */
8769 + bool group; /* WLC_E_MIC_ERROR */
8770 + bool flush_txq; /* WLC_E_MIC_ERROR */
8771 +} wlc_event_t;
8772 +
8773 +typedef struct {
8774 + uint16 ver; /* version of this struct */
8775 + uint16 len; /* length in bytes of this structure */
8776 + uint16 cap; /* sta's advertized capabilities */
8777 + uint32 flags; /* flags defined below */
8778 + uint32 idle; /* time since data pkt rx'd from sta */
8779 + struct ether_addr ea; /* Station address */
8780 + wl_rateset_t rateset; /* rateset in use */
8781 + uint32 in; /* seconds elapsed since associated */
8782 + uint32 listen_interval_inms; /* Min Listen interval in ms for this STA*/
8783 +} sta_info_t;
8784 +
8785 +#define WL_STA_VER 2
8786 +
8787 +/* flags fields */
8788 +#define WL_STA_BRCM 0x01
8789 +#define WL_STA_WME 0x02
8790 +#define WL_STA_ABCAP 0x04
8791 +#define WL_STA_AUTHE 0x08
8792 +#define WL_STA_ASSOC 0x10
8793 +#define WL_STA_AUTHO 0x20
8794 +#define WL_STA_WDS 0x40
8795 +#define WL_WDS_LINKUP 0x80
8796 +
8797 +/* Event messages */
8798 +#define WLC_E_SET_SSID 1
8799 +#define WLC_E_JOIN 2
8800 +#define WLC_E_START 3
8801 +#define WLC_E_AUTH 4
8802 +#define WLC_E_AUTH_IND 5
8803 +#define WLC_E_DEAUTH 6
8804 +#define WLC_E_DEAUTH_IND 7
8805 +#define WLC_E_ASSOC 8
8806 +#define WLC_E_ASSOC_IND 9
8807 +#define WLC_E_REASSOC 10
8808 +#define WLC_E_REASSOC_IND 11
8809 +#define WLC_E_DISASSOC 12
8810 +#define WLC_E_DISASSOC_IND 13
8811 +#define WLC_E_QUIET_START 14 /* 802.11h Quiet period started */
8812 +#define WLC_E_QUIET_END 15 /* 802.11h Quiet period ended */
8813 +#define WLC_E_GOT_BEACONS 16
8814 +#define WLC_E_LINK 17 /* Link indication */
8815 +#define WLC_E_MIC_ERROR 18 /* TKIP MIC error occurred */
8816 +#define WLC_E_NDIS_LINK 19 /* NDIS style link indication */
8817 +#define WLC_E_ROAM 20
8818 +#define WLC_E_TXFAIL 21 /* dot11FailedCount (txfail) */
8819 +#define WLC_E_LAST 22
8820 +
8821 +/* Event status codes */
8822 +#define WLC_E_STATUS_SUCCESS 0
8823 +#define WLC_E_STATUS_FAIL 1
8824 +#define WLC_E_STATUS_TIMEOUT 2
8825 +#define WLC_E_STATUS_NO_NETWORKS 3
8826 +#define WLC_E_STATUS_ABORT 4
8827 +
8828 +typedef struct wlc_event_cb {
8829 + uint msg; /* Event message or 0 for all */
8830 + void (*fn)(void *, wlc_event_t *); /* Callback function */
8831 + void *context; /* Passed to callback function */
8832 + struct wlc_event_cb *next; /* Next in the chain */
8833 +} wlc_event_cb_t;
8834 +
8835 +/*
8836 + * Country locale determines which channels are available to us.
8837 + */
8838 +typedef enum _wlc_locale {
8839 + WLC_WW = 0, /* Worldwide */
8840 + WLC_THA, /* Thailand */
8841 + WLC_ISR, /* Israel */
8842 + WLC_JDN, /* Jordan */
8843 + WLC_PRC, /* China */
8844 + WLC_JPN, /* Japan */
8845 + WLC_FCC, /* USA */
8846 + WLC_EUR, /* Europe */
8847 + WLC_USL, /* US Low Band only */
8848 + WLC_JPH, /* Japan High Band only */
8849 + WLC_ALL, /* All the channels in this band */
8850 + WLC_11D, /* Represents locale recieved by 11d beacons */
8851 + WLC_LAST_LOCALE,
8852 + WLC_UNDEFINED_LOCALE = 0xf
8853 +} wlc_locale_t;
8854 +
8855 +/* channel encoding */
8856 +typedef struct channel_info {
8857 + int hw_channel;
8858 + int target_channel;
8859 + int scan_channel;
8860 +} channel_info_t;
8861 +
8862 +/* For ioctls that take a list of MAC addresses */
8863 +struct maclist {
8864 + uint count; /* number of MAC addresses */
8865 + struct ether_addr ea[1]; /* variable length array of MAC addresses */
8866 +};
8867 +
8868 +/* get pkt count struct passed through ioctl */
8869 +typedef struct get_pktcnt {
8870 + uint rx_good_pkt;
8871 + uint rx_bad_pkt;
8872 + uint tx_good_pkt;
8873 + uint tx_bad_pkt;
8874 +} get_pktcnt_t;
8875 +
8876 +/* Linux network driver ioctl encoding */
8877 +typedef struct wl_ioctl {
8878 + uint cmd; /* common ioctl definition */
8879 + void *buf; /* pointer to user buffer */
8880 + uint len; /* length of user buffer */
8881 + bool set; /* get or set request (optional) */
8882 + uint used; /* bytes read or written (optional) */
8883 + uint needed; /* bytes needed (optional) */
8884 +} wl_ioctl_t;
8885 +
8886 +/*
8887 + * Structure for passing hardware and software
8888 + * revision info up from the driver.
8889 + */
8890 +typedef struct wlc_rev_info {
8891 + uint vendorid; /* PCI vendor id */
8892 + uint deviceid; /* device id of chip */
8893 + uint radiorev; /* radio revision */
8894 + uint chiprev; /* chip revision */
8895 + uint corerev; /* core revision */
8896 + uint boardid; /* board identifier (usu. PCI sub-device id) */
8897 + uint boardvendor; /* board vendor (usu. PCI sub-vendor id) */
8898 + uint boardrev; /* board revision */
8899 + uint driverrev; /* driver version */
8900 + uint ucoderev; /* microcode version */
8901 + uint bus; /* bus type */
8902 + uint chipnum; /* chip number */
8903 +} wlc_rev_info_t;
8904 +
8905 +/* check this magic number */
8906 +#define WLC_IOCTL_MAGIC 0x14e46c77
8907 +
8908 +/* bump this number if you change the ioctl interface */
8909 +#define WLC_IOCTL_VERSION 1
8910 +
8911 +#define WLC_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */
8912 +#define WLC_IOCTL_SMLEN 256 /* "small" length ioctl buffer required */
8913 +
8914 +/* common ioctl definitions */
8915 +#define WLC_GET_MAGIC 0
8916 +#define WLC_GET_VERSION 1
8917 +#define WLC_UP 2
8918 +#define WLC_DOWN 3
8919 +#define WLC_DUMP 6
8920 +#define WLC_GET_MSGLEVEL 7
8921 +#define WLC_SET_MSGLEVEL 8
8922 +#define WLC_GET_PROMISC 9
8923 +#define WLC_SET_PROMISC 10
8924 +#define WLC_GET_RATE 12
8925 +#define WLC_SET_RATE 13
8926 +#define WLC_GET_INSTANCE 14
8927 +#define WLC_GET_FRAG 15
8928 +#define WLC_SET_FRAG 16
8929 +#define WLC_GET_RTS 17
8930 +#define WLC_SET_RTS 18
8931 +#define WLC_GET_INFRA 19
8932 +#define WLC_SET_INFRA 20
8933 +#define WLC_GET_AUTH 21
8934 +#define WLC_SET_AUTH 22
8935 +#define WLC_GET_BSSID 23
8936 +#define WLC_SET_BSSID 24
8937 +#define WLC_GET_SSID 25
8938 +#define WLC_SET_SSID 26
8939 +#define WLC_RESTART 27
8940 +#define WLC_GET_CHANNEL 29
8941 +#define WLC_SET_CHANNEL 30
8942 +#define WLC_GET_SRL 31
8943 +#define WLC_SET_SRL 32
8944 +#define WLC_GET_LRL 33
8945 +#define WLC_SET_LRL 34
8946 +#define WLC_GET_PLCPHDR 35
8947 +#define WLC_SET_PLCPHDR 36
8948 +#define WLC_GET_RADIO 37
8949 +#define WLC_SET_RADIO 38
8950 +#define WLC_GET_PHYTYPE 39
8951 +#define WLC_GET_WEP 42
8952 +#define WLC_SET_WEP 43
8953 +#define WLC_GET_KEY 44
8954 +#define WLC_SET_KEY 45
8955 +#define WLC_SCAN 50
8956 +#define WLC_SCAN_RESULTS 51
8957 +#define WLC_DISASSOC 52
8958 +#define WLC_REASSOC 53
8959 +#define WLC_GET_ROAM_TRIGGER 54
8960 +#define WLC_SET_ROAM_TRIGGER 55
8961 +#define WLC_GET_TXANT 61
8962 +#define WLC_SET_TXANT 62
8963 +#define WLC_GET_ANTDIV 63
8964 +#define WLC_SET_ANTDIV 64
8965 +#define WLC_GET_TXPWR 65
8966 +#define WLC_SET_TXPWR 66
8967 +#define WLC_GET_CLOSED 67
8968 +#define WLC_SET_CLOSED 68
8969 +#define WLC_GET_MACLIST 69
8970 +#define WLC_SET_MACLIST 70
8971 +#define WLC_GET_RATESET 71
8972 +#define WLC_SET_RATESET 72
8973 +#define WLC_GET_LOCALE 73
8974 +#define WLC_SET_LOCALE 74
8975 +#define WLC_GET_BCNPRD 75
8976 +#define WLC_SET_BCNPRD 76
8977 +#define WLC_GET_DTIMPRD 77
8978 +#define WLC_SET_DTIMPRD 78
8979 +#define WLC_GET_SROM 79
8980 +#define WLC_SET_SROM 80
8981 +#define WLC_GET_WEP_RESTRICT 81
8982 +#define WLC_SET_WEP_RESTRICT 82
8983 +#define WLC_GET_COUNTRY 83
8984 +#define WLC_SET_COUNTRY 84
8985 +#define WLC_GET_REVINFO 98
8986 +#define WLC_GET_MACMODE 105
8987 +#define WLC_SET_MACMODE 106
8988 +#define WLC_GET_GMODE 109
8989 +#define WLC_SET_GMODE 110
8990 +#define WLC_GET_CURR_RATESET 114 /* current rateset */
8991 +#define WLC_GET_SCANSUPPRESS 115
8992 +#define WLC_SET_SCANSUPPRESS 116
8993 +#define WLC_GET_AP 117
8994 +#define WLC_SET_AP 118
8995 +#define WLC_GET_EAP_RESTRICT 119
8996 +#define WLC_SET_EAP_RESTRICT 120
8997 +#define WLC_GET_WDSLIST 123
8998 +#define WLC_SET_WDSLIST 124
8999 +#define WLC_GET_RSSI 127
9000 +#define WLC_GET_WSEC 133
9001 +#define WLC_SET_WSEC 134
9002 +#define WLC_GET_BSS_INFO 136
9003 +#define WLC_GET_LAZYWDS 138
9004 +#define WLC_SET_LAZYWDS 139
9005 +#define WLC_GET_BANDLIST 140
9006 +#define WLC_GET_BAND 141
9007 +#define WLC_SET_BAND 142
9008 +#define WLC_GET_SHORTSLOT 144
9009 +#define WLC_GET_SHORTSLOT_OVERRIDE 145
9010 +#define WLC_SET_SHORTSLOT_OVERRIDE 146
9011 +#define WLC_GET_SHORTSLOT_RESTRICT 147
9012 +#define WLC_SET_SHORTSLOT_RESTRICT 148
9013 +#define WLC_GET_GMODE_PROTECTION 149
9014 +#define WLC_GET_GMODE_PROTECTION_OVERRIDE 150
9015 +#define WLC_SET_GMODE_PROTECTION_OVERRIDE 151
9016 +#define WLC_UPGRADE 152
9017 +#define WLC_GET_MRATE 153
9018 +#define WLC_SET_MRATE 154
9019 +#define WLC_GET_ASSOCLIST 159
9020 +#define WLC_GET_CLK 160
9021 +#define WLC_SET_CLK 161
9022 +#define WLC_GET_UP 162
9023 +#define WLC_OUT 163
9024 +#define WLC_GET_WPA_AUTH 164
9025 +#define WLC_SET_WPA_AUTH 165
9026 +#define WLC_GET_GMODE_PROTECTION_CONTROL 178
9027 +#define WLC_SET_GMODE_PROTECTION_CONTROL 179
9028 +#define WLC_GET_PHYLIST 180
9029 +#define WLC_GET_KEY_SEQ 183
9030 +#define WLC_GET_GMODE_PROTECTION_CTS 198
9031 +#define WLC_SET_GMODE_PROTECTION_CTS 199
9032 +#define WLC_GET_PIOMODE 203
9033 +#define WLC_SET_PIOMODE 204
9034 +#define WLC_SET_LED 209
9035 +#define WLC_GET_LED 210
9036 +#define WLC_GET_CHANNEL_SEL 215
9037 +#define WLC_START_CHANNEL_SEL 216
9038 +#define WLC_GET_VALID_CHANNELS 217
9039 +#define WLC_GET_FAKEFRAG 218
9040 +#define WLC_SET_FAKEFRAG 219
9041 +#define WLC_GET_WET 230
9042 +#define WLC_SET_WET 231
9043 +#define WLC_GET_KEY_PRIMARY 235
9044 +#define WLC_SET_KEY_PRIMARY 236
9045 +#define WLC_WDS_GET_REMOTE_HWADDR 246 /* currently handled in wl_linux.c/wl_vx.c */
9046 +#define WLC_SET_CS_SCAN_TIMER 248
9047 +#define WLC_GET_CS_SCAN_TIMER 249
9048 +#define WLC_CURRENT_PWR 256
9049 +#define WLC_GET_CHANNELS_IN_COUNTRY 260
9050 +#define WLC_GET_COUNTRY_LIST 261
9051 +#define WLC_GET_VAR 262 /* get value of named variable */
9052 +#define WLC_SET_VAR 263 /* set named variable to value */
9053 +#define WLC_NVRAM_GET 264
9054 +#define WLC_NVRAM_SET 265
9055 +#define WLC_SET_WSEC_PMK 268
9056 +#define WLC_GET_AUTH_MODE 269
9057 +#define WLC_SET_AUTH_MODE 270
9058 +#define WLC_LAST 273 /* do not change - use get_var/set_var */
9059 +
9060 +/*
9061 + * Minor kludge alert:
9062 + * Duplicate a few definitions that irelay requires from epiioctl.h here
9063 + * so caller doesn't have to include this file and epiioctl.h .
9064 + * If this grows any more, it would be time to move these irelay-specific
9065 + * definitions out of the epiioctl.h and into a separate driver common file.
9066 + */
9067 +#ifndef EPICTRL_COOKIE
9068 +#define EPICTRL_COOKIE 0xABADCEDE
9069 +#endif
9070 +
9071 +/* vx wlc ioctl's offset */
9072 +#define CMN_IOCTL_OFF 0x180
9073 +
9074 +/*
9075 + * custom OID support
9076 + *
9077 + * 0xFF - implementation specific OID
9078 + * 0xE4 - first byte of Broadcom PCI vendor ID
9079 + * 0x14 - second byte of Broadcom PCI vendor ID
9080 + * 0xXX - the custom OID number
9081 + */
9082 +
9083 +/* begin 0x1f values beyond the start of the ET driver range. */
9084 +#define WL_OID_BASE 0xFFE41420
9085 +
9086 +/* NDIS overrides */
9087 +#define OID_WL_GETINSTANCE (WL_OID_BASE + WLC_GET_INSTANCE)
9088 +
9089 +#define WL_DECRYPT_STATUS_SUCCESS 1
9090 +#define WL_DECRYPT_STATUS_FAILURE 2
9091 +#define WL_DECRYPT_STATUS_UNKNOWN 3
9092 +
9093 +/* allows user-mode app to poll the status of USB image upgrade */
9094 +#define WLC_UPGRADE_SUCCESS 0
9095 +#define WLC_UPGRADE_PENDING 1
9096 +
9097 +/* Bit masks for radio disabled status - returned by WL_GET_RADIO */
9098 +#define WL_RADIO_SW_DISABLE (1<<0)
9099 +#define WL_RADIO_HW_DISABLE (1<<1)
9100 +#define WL_RADIO_UNASSOC_DISABLE (1<<2)
9101 +
9102 +/* Override bit for WLC_SET_TXPWR. if set, ignore other level limits */
9103 +#define WL_TXPWR_OVERRIDE (1<<31)
9104 +
9105 +
9106 +/* Bus types */
9107 +#define WL_SB_BUS 0 /* Silicon Backplane */
9108 +#define WL_PCI_BUS 1 /* PCI target */
9109 +#define WL_PCMCIA_BUS 2 /* PCMCIA target */
9110 +
9111 +/* band types */
9112 +#define WLC_BAND_AUTO 0 /* auto-select */
9113 +#define WLC_BAND_A 1 /* "a" band (5 Ghz) */
9114 +#define WLC_BAND_B 2 /* "b" band (2.4 Ghz) */
9115 +
9116 +/* MAC list modes */
9117 +#define WLC_MACMODE_DISABLED 0 /* MAC list disabled */
9118 +#define WLC_MACMODE_DENY 1 /* Deny specified (i.e. allow unspecified) */
9119 +#define WLC_MACMODE_ALLOW 2 /* Allow specified (i.e. deny unspecified) */
9120 +
9121 +/*
9122 + *
9123 + */
9124 +#define GMODE_LEGACY_B 0
9125 +#define GMODE_AUTO 1
9126 +#define GMODE_ONLY 2
9127 +#define GMODE_B_DEFERRED 3
9128 +#define GMODE_PERFORMANCE 4
9129 +#define GMODE_LRS 5
9130 +#define GMODE_MAX 6
9131 +
9132 +/* values for PLCPHdr_override */
9133 +#define WLC_PLCP_AUTO -1
9134 +#define WLC_PLCP_SHORT 0
9135 +#define WLC_PLCP_LONG 1
9136 +
9137 +/* values for g_protection_override */
9138 +#define WLC_G_PROTECTION_AUTO -1
9139 +#define WLC_G_PROTECTION_OFF 0
9140 +#define WLC_G_PROTECTION_ON 1
9141 +
9142 +/* values for g_protection_control */
9143 +#define WLC_G_PROTECTION_CTL_OFF 0
9144 +#define WLC_G_PROTECTION_CTL_LOCAL 1
9145 +#define WLC_G_PROTECTION_CTL_OVERLAP 2
9146 +
9147 +/* Values for PM */
9148 +#define PM_OFF 0
9149 +#define PM_MAX 1
9150 +#define PM_FAST 2
9151 +
9152 +
9153 +
9154 +
9155 +
9156 +/* 802.11h enforcement levels */
9157 +#define SPECT_MNGMT_OFF 0 /* 11h disabled */
9158 +#define SPECT_MNGMT_LOOSE 1 /* qllow scan lists to contain non-11h AP */
9159 +#define SPECT_MNGMT_STRICT 2 /* prune out non-11h APs from scan list */
9160 +
9161 +
9162 +#define WL_CHAN_VALID_HW (1 << 0) /* valid with current HW */
9163 +#define WL_CHAN_VALID_SW (1 << 1) /* valid with current country setting */
9164 +#define WL_CHAN_BAND_A (1 << 2) /* A-band channel */
9165 +#define WL_CHAN_RADAR (1 << 3) /* radar sensitive channel */
9166 +#define WL_CHAN_INACTIVE (1 << 4) /* temporarily out of service due to radar */
9167 +#define WL_CHAN_RADAR_PASSIVE (1 << 5) /* radar channel is in passive mode */
9168 +
9169 +
9170 +/* max # of leds supported by GPIO (gpio pin# == led index#) */
9171 +#define WL_LED_NUMGPIO 16 /* gpio 0-15 */
9172 +
9173 +/* led per-pin behaviors */
9174 +#define WL_LED_OFF 0 /* always off */
9175 +#define WL_LED_ON 1 /* always on */
9176 +#define WL_LED_ACTIVITY 2 /* activity */
9177 +#define WL_LED_RADIO 3 /* radio enabled */
9178 +#define WL_LED_ARADIO 4 /* 5 Ghz radio enabled */
9179 +#define WL_LED_BRADIO 5 /* 2.4Ghz radio enabled */
9180 +#define WL_LED_BGMODE 6 /* on if gmode, off if bmode */
9181 +#define WL_LED_WI1 7
9182 +#define WL_LED_WI2 8
9183 +#define WL_LED_WI3 9
9184 +#define WL_LED_ASSOC 10 /* associated state indicator */
9185 +#define WL_LED_INACTIVE 11 /* null behavior (clears default behavior) */
9186 +#define WL_LED_NUMBEHAVIOR 12
9187 +
9188 +/* led behavior numeric value format */
9189 +#define WL_LED_BEH_MASK 0x7f /* behavior mask */
9190 +#define WL_LED_AL_MASK 0x80 /* activelow (polarity) bit */
9191 +
9192 +
9193 +/* WDS link local endpoint WPA role */
9194 +#define WL_WDS_WPA_ROLE_AUTH 0 /* authenticator */
9195 +#define WL_WDS_WPA_ROLE_SUP 1 /* supplicant */
9196 +#define WL_WDS_WPA_ROLE_AUTO 255 /* auto, based on mac addr value */
9197 +
9198 +/* Structures and constants used for "vndr_ie" IOVar interface */
9199 +#define VNDR_IE_CMD_LEN 4 /* length of the set command string: "add", "del" (+ NULL) */
9200 +
9201 +/* 802.11 Mgmt Packet flags */
9202 +#define VNDR_IE_BEACON_FLAG 0x1
9203 +#define VNDR_IE_PRBRSP_FLAG 0x2
9204 +#define VNDR_IE_ASSOCRSP_FLAG 0x4
9205 +#define VNDR_IE_AUTHRSP_FLAG 0x8
9206 +
9207 +typedef struct vndr_ie_info {
9208 + uint32 pktflag; /* bitmask indicating which packet(s) contain this IE */
9209 + vndr_ie_t vndr_ie_data; /* vendor IE data */
9210 +} vndr_ie_info_t;
9211 +
9212 +typedef struct vndr_ie_buf {
9213 + int iecount; /* number of entries in the vndr_ie_list[] array */
9214 + vndr_ie_info_t vndr_ie_list[1]; /* variable size list of vndr_ie_info_t structs */
9215 +} vndr_ie_buf_t;
9216 +
9217 +typedef struct vndr_ie_setbuf {
9218 + char cmd[VNDR_IE_CMD_LEN]; /* vndr_ie IOVar set command : "add", "del" + NULL */
9219 + vndr_ie_buf_t vndr_ie_buffer; /* buffer containing Vendor IE list information */
9220 +} vndr_ie_setbuf_t;
9221 +
9222 +#if !defined(__GNUC__)
9223 +#pragma pack(pop)
9224 +#endif
9225 +
9226 +#endif /* _wlioctl_h_ */
9227 diff -urN linux-2.4.30/arch/mips/bcm947xx/nvram.c linux-2.4.30.dev/arch/mips/bcm947xx/nvram.c
9228 --- linux-2.4.30/arch/mips/bcm947xx/nvram.c 1970-01-01 01:00:00.000000000 +0100
9229 +++ linux-2.4.30.dev/arch/mips/bcm947xx/nvram.c 2005-08-22 01:34:46.341148728 +0200
9230 @@ -0,0 +1,321 @@
9231 +/*
9232 + * NVRAM variable manipulation (common)
9233 + *
9234 + * Copyright 2004, Broadcom Corporation
9235 + * All Rights Reserved.
9236 + *
9237 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9238 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9239 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9240 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9241 + *
9242 + * $Id$
9243 + */
9244 +
9245 +#include <typedefs.h>
9246 +#include <osl.h>
9247 +#include <bcmendian.h>
9248 +#include <bcmnvram.h>
9249 +#include <bcmutils.h>
9250 +#include <sbsdram.h>
9251 +
9252 +extern struct nvram_tuple * BCMINIT(_nvram_realloc)(struct nvram_tuple *t, const char *name, const char *value);
9253 +extern void BCMINIT(_nvram_free)(struct nvram_tuple *t);
9254 +extern int BCMINIT(_nvram_read)(void *buf);
9255 +
9256 +char * BCMINIT(_nvram_get)(const char *name);
9257 +int BCMINIT(_nvram_set)(const char *name, const char *value);
9258 +int BCMINIT(_nvram_unset)(const char *name);
9259 +int BCMINIT(_nvram_getall)(char *buf, int count);
9260 +int BCMINIT(_nvram_commit)(struct nvram_header *header);
9261 +int BCMINIT(_nvram_init)(void);
9262 +void BCMINIT(_nvram_exit)(void);
9263 +
9264 +static struct nvram_tuple * BCMINITDATA(nvram_hash)[257];
9265 +static struct nvram_tuple * nvram_dead;
9266 +
9267 +/* Free all tuples. Should be locked. */
9268 +static void
9269 +BCMINITFN(nvram_free)(void)
9270 +{
9271 + uint i;
9272 + struct nvram_tuple *t, *next;
9273 +
9274 + /* Free hash table */
9275 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
9276 + for (t = BCMINIT(nvram_hash)[i]; t; t = next) {
9277 + next = t->next;
9278 + BCMINIT(_nvram_free)(t);
9279 + }
9280 + BCMINIT(nvram_hash)[i] = NULL;
9281 + }
9282 +
9283 + /* Free dead table */
9284 + for (t = nvram_dead; t; t = next) {
9285 + next = t->next;
9286 + BCMINIT(_nvram_free)(t);
9287 + }
9288 + nvram_dead = NULL;
9289 +
9290 + /* Indicate to per-port code that all tuples have been freed */
9291 + BCMINIT(_nvram_free)(NULL);
9292 +}
9293 +
9294 +/* String hash */
9295 +static INLINE uint
9296 +hash(const char *s)
9297 +{
9298 + uint hash = 0;
9299 +
9300 + while (*s)
9301 + hash = 31 * hash + *s++;
9302 +
9303 + return hash;
9304 +}
9305 +
9306 +/* (Re)initialize the hash table. Should be locked. */
9307 +static int
9308 +BCMINITFN(nvram_rehash)(struct nvram_header *header)
9309 +{
9310 + char buf[] = "0xXXXXXXXX", *name, *value, *end, *eq;
9311 +
9312 + /* (Re)initialize hash table */
9313 + BCMINIT(nvram_free)();
9314 +
9315 + /* Parse and set "name=value\0 ... \0\0" */
9316 + name = (char *) &header[1];
9317 + end = (char *) header + NVRAM_SPACE - 2;
9318 + end[0] = end[1] = '\0';
9319 + for (; *name; name = value + strlen(value) + 1) {
9320 + if (!(eq = strchr(name, '=')))
9321 + break;
9322 + *eq = '\0';
9323 + value = eq + 1;
9324 + BCMINIT(_nvram_set)(name, value);
9325 + *eq = '=';
9326 + }
9327 +
9328 + /* Set special SDRAM parameters */
9329 + if (!BCMINIT(_nvram_get)("sdram_init")) {
9330 + sprintf(buf, "0x%04X", (uint16)(header->crc_ver_init >> 16));
9331 + BCMINIT(_nvram_set)("sdram_init", buf);
9332 + }
9333 + if (!BCMINIT(_nvram_get)("sdram_config")) {
9334 + sprintf(buf, "0x%04X", (uint16)(header->config_refresh & 0xffff));
9335 + BCMINIT(_nvram_set)("sdram_config", buf);
9336 + }
9337 + if (!BCMINIT(_nvram_get)("sdram_refresh")) {
9338 + sprintf(buf, "0x%04X", (uint16)((header->config_refresh >> 16) & 0xffff));
9339 + BCMINIT(_nvram_set)("sdram_refresh", buf);
9340 + }
9341 + if (!BCMINIT(_nvram_get)("sdram_ncdl")) {
9342 + sprintf(buf, "0x%08X", header->config_ncdl);
9343 + BCMINIT(_nvram_set)("sdram_ncdl", buf);
9344 + }
9345 +
9346 + return 0;
9347 +}
9348 +
9349 +/* Get the value of an NVRAM variable. Should be locked. */
9350 +char *
9351 +BCMINITFN(_nvram_get)(const char *name)
9352 +{
9353 + uint i;
9354 + struct nvram_tuple *t;
9355 + char *value;
9356 +
9357 + if (!name)
9358 + return NULL;
9359 +
9360 + /* Hash the name */
9361 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
9362 +
9363 + /* Find the associated tuple in the hash table */
9364 + for (t = BCMINIT(nvram_hash)[i]; t && strcmp(t->name, name); t = t->next);
9365 +
9366 + value = t ? t->value : NULL;
9367 +
9368 + return value;
9369 +}
9370 +
9371 +/* Get the value of an NVRAM variable. Should be locked. */
9372 +int
9373 +BCMINITFN(_nvram_set)(const char *name, const char *value)
9374 +{
9375 + uint i;
9376 + struct nvram_tuple *t, *u, **prev;
9377 +
9378 + /* Hash the name */
9379 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
9380 +
9381 + /* Find the associated tuple in the hash table */
9382 + for (prev = &BCMINIT(nvram_hash)[i], t = *prev; t && strcmp(t->name, name); prev = &t->next, t = *prev);
9383 +
9384 + /* (Re)allocate tuple */
9385 + if (!(u = BCMINIT(_nvram_realloc)(t, name, value)))
9386 + return -12; /* -ENOMEM */
9387 +
9388 + /* Value reallocated */
9389 + if (t && t == u)
9390 + return 0;
9391 +
9392 + /* Move old tuple to the dead table */
9393 + if (t) {
9394 + *prev = t->next;
9395 + t->next = nvram_dead;
9396 + nvram_dead = t;
9397 + }
9398 +
9399 + /* Add new tuple to the hash table */
9400 + u->next = BCMINIT(nvram_hash)[i];
9401 + BCMINIT(nvram_hash)[i] = u;
9402 +
9403 + return 0;
9404 +}
9405 +
9406 +/* Unset the value of an NVRAM variable. Should be locked. */
9407 +int
9408 +BCMINITFN(_nvram_unset)(const char *name)
9409 +{
9410 + uint i;
9411 + struct nvram_tuple *t, **prev;
9412 +
9413 + if (!name)
9414 + return 0;
9415 +
9416 + /* Hash the name */
9417 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
9418 +
9419 + /* Find the associated tuple in the hash table */
9420 + for (prev = &BCMINIT(nvram_hash)[i], t = *prev; t && strcmp(t->name, name); prev = &t->next, t = *prev);
9421 +
9422 + /* Move it to the dead table */
9423 + if (t) {
9424 + *prev = t->next;
9425 + t->next = nvram_dead;
9426 + nvram_dead = t;
9427 + }
9428 +
9429 + return 0;
9430 +}
9431 +
9432 +/* Get all NVRAM variables. Should be locked. */
9433 +int
9434 +BCMINITFN(_nvram_getall)(char *buf, int count)
9435 +{
9436 + uint i;
9437 + struct nvram_tuple *t;
9438 + int len = 0;
9439 +
9440 + bzero(buf, count);
9441 +
9442 + /* Write name=value\0 ... \0\0 */
9443 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
9444 + for (t = BCMINIT(nvram_hash)[i]; t; t = t->next) {
9445 + if ((count - len) > (strlen(t->name) + 1 + strlen(t->value) + 1))
9446 + len += sprintf(buf + len, "%s=%s", t->name, t->value) + 1;
9447 + else
9448 + break;
9449 + }
9450 + }
9451 +
9452 + return 0;
9453 +}
9454 +
9455 +/* Regenerate NVRAM. Should be locked. */
9456 +int
9457 +BCMINITFN(_nvram_commit)(struct nvram_header *header)
9458 +{
9459 + char *init, *config, *refresh, *ncdl;
9460 + char *ptr, *end;
9461 + int i;
9462 + struct nvram_tuple *t;
9463 + struct nvram_header tmp;
9464 + uint8 crc;
9465 +
9466 + /* Regenerate header */
9467 + header->magic = NVRAM_MAGIC;
9468 + header->crc_ver_init = (NVRAM_VERSION << 8);
9469 + if (!(init = BCMINIT(_nvram_get)("sdram_init")) ||
9470 + !(config = BCMINIT(_nvram_get)("sdram_config")) ||
9471 + !(refresh = BCMINIT(_nvram_get)("sdram_refresh")) ||
9472 + !(ncdl = BCMINIT(_nvram_get)("sdram_ncdl"))) {
9473 + header->crc_ver_init |= SDRAM_INIT << 16;
9474 + header->config_refresh = SDRAM_CONFIG;
9475 + header->config_refresh |= SDRAM_REFRESH << 16;
9476 + header->config_ncdl = 0;
9477 + } else {
9478 + header->crc_ver_init |= (bcm_strtoul(init, NULL, 0) & 0xffff) << 16;
9479 + header->config_refresh = bcm_strtoul(config, NULL, 0) & 0xffff;
9480 + header->config_refresh |= (bcm_strtoul(refresh, NULL, 0) & 0xffff) << 16;
9481 + header->config_ncdl = bcm_strtoul(ncdl, NULL, 0);
9482 + }
9483 +
9484 + /* Clear data area */
9485 + ptr = (char *) header + sizeof(struct nvram_header);
9486 + bzero(ptr, NVRAM_SPACE - sizeof(struct nvram_header));
9487 +
9488 + /* Leave space for a double NUL at the end */
9489 + end = (char *) header + NVRAM_SPACE - 2;
9490 +
9491 + /* Write out all tuples */
9492 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
9493 + for (t = BCMINIT(nvram_hash)[i]; t; t = t->next) {
9494 + if ((ptr + strlen(t->name) + 1 + strlen(t->value) + 1) > end)
9495 + break;
9496 + ptr += sprintf(ptr, "%s=%s", t->name, t->value) + 1;
9497 + }
9498 + }
9499 +
9500 + /* End with a double NUL */
9501 + ptr += 2;
9502 +
9503 + /* Set new length */
9504 + header->len = ROUNDUP(ptr - (char *) header, 4);
9505 +
9506 + /* Little-endian CRC8 over the last 11 bytes of the header */
9507 + tmp.crc_ver_init = htol32(header->crc_ver_init);
9508 + tmp.config_refresh = htol32(header->config_refresh);
9509 + tmp.config_ncdl = htol32(header->config_ncdl);
9510 + crc = hndcrc8((char *) &tmp + 9, sizeof(struct nvram_header) - 9, CRC8_INIT_VALUE);
9511 +
9512 + /* Continue CRC8 over data bytes */
9513 + crc = hndcrc8((char *) &header[1], header->len - sizeof(struct nvram_header), crc);
9514 +
9515 + /* Set new CRC8 */
9516 + header->crc_ver_init |= crc;
9517 +
9518 + /* Reinitialize hash table */
9519 + return BCMINIT(nvram_rehash)(header);
9520 +}
9521 +
9522 +/* Initialize hash table. Should be locked. */
9523 +int
9524 +BCMINITFN(_nvram_init)(void)
9525 +{
9526 + struct nvram_header *header;
9527 + int ret;
9528 + void *osh;
9529 +
9530 + /* get kernel osl handler */
9531 + osh = osl_attach(NULL);
9532 +
9533 + if (!(header = (struct nvram_header *) MALLOC(osh, NVRAM_SPACE))) {
9534 + printf("nvram_init: out of memory, malloced %d bytes\n", MALLOCED(osh));
9535 + return -12; /* -ENOMEM */
9536 + }
9537 +
9538 + if ((ret = BCMINIT(_nvram_read)(header)) == 0 &&
9539 + header->magic == NVRAM_MAGIC)
9540 + BCMINIT(nvram_rehash)(header);
9541 +
9542 + MFREE(osh, header, NVRAM_SPACE);
9543 + return ret;
9544 +}
9545 +
9546 +/* Free hash table. Should be locked. */
9547 +void
9548 +BCMINITFN(_nvram_exit)(void)
9549 +{
9550 + BCMINIT(nvram_free)();
9551 +}
9552 diff -urN linux-2.4.30/arch/mips/bcm947xx/nvram_linux.c linux-2.4.30.dev/arch/mips/bcm947xx/nvram_linux.c
9553 --- linux-2.4.30/arch/mips/bcm947xx/nvram_linux.c 1970-01-01 01:00:00.000000000 +0100
9554 +++ linux-2.4.30.dev/arch/mips/bcm947xx/nvram_linux.c 2005-08-22 01:34:46.342148576 +0200
9555 @@ -0,0 +1,617 @@
9556 +/*
9557 + * NVRAM variable manipulation (Linux kernel half)
9558 + *
9559 + * Copyright 2004, Broadcom Corporation
9560 + * All Rights Reserved.
9561 + *
9562 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9563 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9564 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9565 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9566 + *
9567 + * $Id$
9568 + */
9569 +
9570 +#include <linux/config.h>
9571 +#include <linux/init.h>
9572 +#include <linux/module.h>
9573 +#include <linux/kernel.h>
9574 +#include <linux/string.h>
9575 +#include <linux/interrupt.h>
9576 +#include <linux/spinlock.h>
9577 +#include <linux/slab.h>
9578 +#include <linux/bootmem.h>
9579 +#include <linux/wrapper.h>
9580 +#include <linux/fs.h>
9581 +#include <linux/miscdevice.h>
9582 +#include <linux/mtd/mtd.h>
9583 +#include <asm/addrspace.h>
9584 +#include <asm/io.h>
9585 +#include <asm/uaccess.h>
9586 +
9587 +#include <typedefs.h>
9588 +#include <bcmendian.h>
9589 +#include <bcmnvram.h>
9590 +#include <bcmutils.h>
9591 +#include <sbconfig.h>
9592 +#include <sbchipc.h>
9593 +#include <sbutils.h>
9594 +#include <sbmips.h>
9595 +
9596 +/* In BSS to minimize text size and page aligned so it can be mmap()-ed */
9597 +static char nvram_buf[NVRAM_SPACE] __attribute__((aligned(PAGE_SIZE)));
9598 +
9599 +#ifdef MODULE
9600 +
9601 +#define early_nvram_get(name) nvram_get(name)
9602 +
9603 +#else /* !MODULE */
9604 +
9605 +/* Global SB handle */
9606 +extern void *bcm947xx_sbh;
9607 +extern spinlock_t bcm947xx_sbh_lock;
9608 +
9609 +/* Convenience */
9610 +#define sbh bcm947xx_sbh
9611 +#define sbh_lock bcm947xx_sbh_lock
9612 +#define KB * 1024
9613 +#define MB * 1024 * 1024
9614 +
9615 +/* Probe for NVRAM header */
9616 +static void __init
9617 +early_nvram_init(void)
9618 +{
9619 + struct nvram_header *header;
9620 + chipcregs_t *cc;
9621 + int i;
9622 + uint32 base, off, lim;
9623 +
9624 + if ((cc = sb_setcore(sbh, SB_CC, 0)) != NULL) {
9625 + base = KSEG1ADDR(SB_FLASH2);
9626 + switch (readl(&cc->capabilities) & CAP_FLASH_MASK) {
9627 + case PFLASH:
9628 + lim = SB_FLASH2_SZ;
9629 + break;
9630 +
9631 + case SFLASH_ST:
9632 + case SFLASH_AT:
9633 + case FLASH_NONE:
9634 + default:
9635 + return;
9636 + }
9637 + } else {
9638 + /* extif assumed, Stop at 4 MB */
9639 + base = KSEG1ADDR(SB_FLASH1);
9640 + lim = SB_FLASH1_SZ;
9641 + }
9642 +
9643 + off = FLASH_MIN;
9644 + while (off <= lim) {
9645 + /* Windowed flash access */
9646 + header = (struct nvram_header *) KSEG1ADDR(base + off - NVRAM_SPACE);
9647 + if (header->magic == NVRAM_MAGIC) {
9648 + u32 *src = (u32 *) header;
9649 + u32 *dst = (u32 *) nvram_buf;
9650 + for (i = 0; i < sizeof(struct nvram_header); i += 4)
9651 + *dst++ = *src++;
9652 + for (; i < header->len && i < NVRAM_SPACE; i += 4)
9653 + *dst++ = ltoh32(*src++);
9654 + return;
9655 + }
9656 +
9657 + /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
9658 + if (off == 1 KB)
9659 + break;
9660 + else if (off == 4 KB)
9661 + off = 1 KB;
9662 + else if (off == lim)
9663 + off = 4 KB;
9664 + else
9665 + off <<= 1;
9666 + }
9667 +}
9668 +
9669 +/* Early (before mm or mtd) read-only access to NVRAM */
9670 +static char * __init
9671 +early_nvram_get(const char *name)
9672 +{
9673 + char *var, *value, *end, *eq;
9674 +
9675 + if (!name)
9676 + return NULL;
9677 +
9678 + if (!nvram_buf[0])
9679 + early_nvram_init();
9680 +
9681 + /* Look for name=value and return value */
9682 + var = &nvram_buf[sizeof(struct nvram_header)];
9683 + end = nvram_buf + sizeof(nvram_buf) - 2;
9684 + end[0] = end[1] = '\0';
9685 + for (; *var; var = value + strlen(value) + 1) {
9686 + if (!(eq = strchr(var, '=')))
9687 + break;
9688 + value = eq + 1;
9689 + if ((eq - var) == strlen(name) && strncmp(var, name, (eq - var)) == 0)
9690 + return value;
9691 + }
9692 +
9693 + return NULL;
9694 +}
9695 +
9696 +#endif /* !MODULE */
9697 +
9698 +extern char * _nvram_get(const char *name);
9699 +extern int _nvram_set(const char *name, const char *value);
9700 +extern int _nvram_unset(const char *name);
9701 +extern int _nvram_getall(char *buf, int count);
9702 +extern int _nvram_commit(struct nvram_header *header);
9703 +extern int _nvram_init(void);
9704 +extern void _nvram_exit(void);
9705 +
9706 +/* Globals */
9707 +static spinlock_t nvram_lock = SPIN_LOCK_UNLOCKED;
9708 +static struct semaphore nvram_sem;
9709 +static unsigned long nvram_offset = 0;
9710 +static int nvram_major = -1;
9711 +static devfs_handle_t nvram_handle = NULL;
9712 +static struct mtd_info *nvram_mtd = NULL;
9713 +
9714 +int
9715 +_nvram_read(char *buf)
9716 +{
9717 + struct nvram_header *header = (struct nvram_header *) buf;
9718 + size_t len;
9719 +
9720 + if (!nvram_mtd ||
9721 + MTD_READ(nvram_mtd, nvram_mtd->size - NVRAM_SPACE, NVRAM_SPACE, &len, buf) ||
9722 + len != NVRAM_SPACE ||
9723 + header->magic != NVRAM_MAGIC) {
9724 + /* Maybe we can recover some data from early initialization */
9725 + memcpy(buf, nvram_buf, NVRAM_SPACE);
9726 + }
9727 +
9728 + return 0;
9729 +}
9730 +
9731 +struct nvram_tuple *
9732 +_nvram_realloc(struct nvram_tuple *t, const char *name, const char *value)
9733 +{
9734 + if ((nvram_offset + strlen(value) + 1) > NVRAM_SPACE)
9735 + return NULL;
9736 +
9737 + if (!t) {
9738 + if (!(t = kmalloc(sizeof(struct nvram_tuple) + strlen(name) + 1, GFP_ATOMIC)))
9739 + return NULL;
9740 +
9741 + /* Copy name */
9742 + t->name = (char *) &t[1];
9743 + strcpy(t->name, name);
9744 +
9745 + t->value = NULL;
9746 + }
9747 +
9748 + /* Copy value */
9749 + if (!t->value || strcmp(t->value, value)) {
9750 + t->value = &nvram_buf[nvram_offset];
9751 + strcpy(t->value, value);
9752 + nvram_offset += strlen(value) + 1;
9753 + }
9754 +
9755 + return t;
9756 +}
9757 +
9758 +void
9759 +_nvram_free(struct nvram_tuple *t)
9760 +{
9761 + if (!t)
9762 + nvram_offset = 0;
9763 + else
9764 + kfree(t);
9765 +}
9766 +
9767 +int
9768 +nvram_set(const char *name, const char *value)
9769 +{
9770 + unsigned long flags;
9771 + int ret;
9772 + struct nvram_header *header;
9773 +
9774 + spin_lock_irqsave(&nvram_lock, flags);
9775 + if ((ret = _nvram_set(name, value))) {
9776 + /* Consolidate space and try again */
9777 + if ((header = kmalloc(NVRAM_SPACE, GFP_ATOMIC))) {
9778 + if (_nvram_commit(header) == 0)
9779 + ret = _nvram_set(name, value);
9780 + kfree(header);
9781 + }
9782 + }
9783 + spin_unlock_irqrestore(&nvram_lock, flags);
9784 +
9785 + return ret;
9786 +}
9787 +
9788 +char *
9789 +real_nvram_get(const char *name)
9790 +{
9791 + unsigned long flags;
9792 + char *value;
9793 +
9794 + spin_lock_irqsave(&nvram_lock, flags);
9795 + value = _nvram_get(name);
9796 + spin_unlock_irqrestore(&nvram_lock, flags);
9797 +
9798 + return value;
9799 +}
9800 +
9801 +char *
9802 +nvram_get(const char *name)
9803 +{
9804 + if (nvram_major >= 0)
9805 + return real_nvram_get(name);
9806 + else
9807 + return early_nvram_get(name);
9808 +}
9809 +
9810 +int
9811 +nvram_unset(const char *name)
9812 +{
9813 + unsigned long flags;
9814 + int ret;
9815 +
9816 + spin_lock_irqsave(&nvram_lock, flags);
9817 + ret = _nvram_unset(name);
9818 + spin_unlock_irqrestore(&nvram_lock, flags);
9819 +
9820 + return ret;
9821 +}
9822 +
9823 +static void
9824 +erase_callback(struct erase_info *done)
9825 +{
9826 + wait_queue_head_t *wait_q = (wait_queue_head_t *) done->priv;
9827 + wake_up(wait_q);
9828 +}
9829 +
9830 +int
9831 +nvram_commit(void)
9832 +{
9833 + char *buf;
9834 + size_t erasesize, len;
9835 + unsigned int i;
9836 + int ret;
9837 + struct nvram_header *header;
9838 + unsigned long flags;
9839 + u_int32_t offset;
9840 + DECLARE_WAITQUEUE(wait, current);
9841 + wait_queue_head_t wait_q;
9842 + struct erase_info erase;
9843 +
9844 + if (!nvram_mtd) {
9845 + printk("nvram_commit: NVRAM not found\n");
9846 + return -ENODEV;
9847 + }
9848 +
9849 + if (in_interrupt()) {
9850 + printk("nvram_commit: not committing in interrupt\n");
9851 + return -EINVAL;
9852 + }
9853 +
9854 + /* Backup sector blocks to be erased */
9855 + erasesize = ROUNDUP(NVRAM_SPACE, nvram_mtd->erasesize);
9856 + if (!(buf = kmalloc(erasesize, GFP_KERNEL))) {
9857 + printk("nvram_commit: out of memory\n");
9858 + return -ENOMEM;
9859 + }
9860 +
9861 + down(&nvram_sem);
9862 +
9863 + if ((i = erasesize - NVRAM_SPACE) > 0) {
9864 + offset = nvram_mtd->size - erasesize;
9865 + len = 0;
9866 + ret = MTD_READ(nvram_mtd, offset, i, &len, buf);
9867 + if (ret || len != i) {
9868 + printk("nvram_commit: read error ret = %d, len = %d/%d\n", ret, len, i);
9869 + ret = -EIO;
9870 + goto done;
9871 + }
9872 + header = (struct nvram_header *)(buf + i);
9873 + } else {
9874 + offset = nvram_mtd->size - NVRAM_SPACE;
9875 + header = (struct nvram_header *)buf;
9876 + }
9877 +
9878 + /* Regenerate NVRAM */
9879 + spin_lock_irqsave(&nvram_lock, flags);
9880 + ret = _nvram_commit(header);
9881 + spin_unlock_irqrestore(&nvram_lock, flags);
9882 + if (ret)
9883 + goto done;
9884 +
9885 + /* Erase sector blocks */
9886 + init_waitqueue_head(&wait_q);
9887 + for (; offset < nvram_mtd->size - NVRAM_SPACE + header->len; offset += nvram_mtd->erasesize) {
9888 + erase.mtd = nvram_mtd;
9889 + erase.addr = offset;
9890 + erase.len = nvram_mtd->erasesize;
9891 + erase.callback = erase_callback;
9892 + erase.priv = (u_long) &wait_q;
9893 +
9894 + set_current_state(TASK_INTERRUPTIBLE);
9895 + add_wait_queue(&wait_q, &wait);
9896 +
9897 + /* Unlock sector blocks */
9898 + if (nvram_mtd->unlock)
9899 + nvram_mtd->unlock(nvram_mtd, offset, nvram_mtd->erasesize);
9900 +
9901 + if ((ret = MTD_ERASE(nvram_mtd, &erase))) {
9902 + set_current_state(TASK_RUNNING);
9903 + remove_wait_queue(&wait_q, &wait);
9904 + printk("nvram_commit: erase error\n");
9905 + goto done;
9906 + }
9907 +
9908 + /* Wait for erase to finish */
9909 + schedule();
9910 + remove_wait_queue(&wait_q, &wait);
9911 + }
9912 +
9913 + /* Write partition up to end of data area */
9914 + offset = nvram_mtd->size - erasesize;
9915 + i = erasesize - NVRAM_SPACE + header->len;
9916 + ret = MTD_WRITE(nvram_mtd, offset, i, &len, buf);
9917 + if (ret || len != i) {
9918 + printk("nvram_commit: write error\n");
9919 + ret = -EIO;
9920 + goto done;
9921 + }
9922 +
9923 + offset = nvram_mtd->size - erasesize;
9924 + ret = MTD_READ(nvram_mtd, offset, 4, &len, buf);
9925 +
9926 + done:
9927 + up(&nvram_sem);
9928 + kfree(buf);
9929 + return ret;
9930 +}
9931 +
9932 +int
9933 +nvram_getall(char *buf, int count)
9934 +{
9935 + unsigned long flags;
9936 + int ret;
9937 +
9938 + spin_lock_irqsave(&nvram_lock, flags);
9939 + ret = _nvram_getall(buf, count);
9940 + spin_unlock_irqrestore(&nvram_lock, flags);
9941 +
9942 + return ret;
9943 +}
9944 +
9945 +EXPORT_SYMBOL(nvram_get);
9946 +EXPORT_SYMBOL(nvram_getall);
9947 +EXPORT_SYMBOL(nvram_set);
9948 +EXPORT_SYMBOL(nvram_unset);
9949 +EXPORT_SYMBOL(nvram_commit);
9950 +
9951 +/* User mode interface below */
9952 +
9953 +static ssize_t
9954 +dev_nvram_read(struct file *file, char *buf, size_t count, loff_t *ppos)
9955 +{
9956 + char tmp[100], *name = tmp, *value;
9957 + ssize_t ret;
9958 + unsigned long off;
9959 +
9960 + if (count > sizeof(tmp)) {
9961 + if (!(name = kmalloc(count, GFP_KERNEL)))
9962 + return -ENOMEM;
9963 + }
9964 +
9965 + if (copy_from_user(name, buf, count)) {
9966 + ret = -EFAULT;
9967 + goto done;
9968 + }
9969 +
9970 + if (*name == '\0') {
9971 + /* Get all variables */
9972 + ret = nvram_getall(name, count);
9973 + if (ret == 0) {
9974 + if (copy_to_user(buf, name, count)) {
9975 + ret = -EFAULT;
9976 + goto done;
9977 + }
9978 + ret = count;
9979 + }
9980 + } else {
9981 + if (!(value = nvram_get(name))) {
9982 + ret = 0;
9983 + goto done;
9984 + }
9985 +
9986 + /* Provide the offset into mmap() space */
9987 + off = (unsigned long) value - (unsigned long) nvram_buf;
9988 +
9989 + if (put_user(off, (unsigned long *) buf)) {
9990 + ret = -EFAULT;
9991 + goto done;
9992 + }
9993 +
9994 + ret = sizeof(unsigned long);
9995 + }
9996 +
9997 + flush_cache_all();
9998 +
9999 +done:
10000 + if (name != tmp)
10001 + kfree(name);
10002 +
10003 + return ret;
10004 +}
10005 +
10006 +static ssize_t
10007 +dev_nvram_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
10008 +{
10009 + char tmp[100], *name = tmp, *value;
10010 + ssize_t ret;
10011 +
10012 + if (count > sizeof(tmp)) {
10013 + if (!(name = kmalloc(count, GFP_KERNEL)))
10014 + return -ENOMEM;
10015 + }
10016 +
10017 + if (copy_from_user(name, buf, count)) {
10018 + ret = -EFAULT;
10019 + goto done;
10020 + }
10021 +
10022 + value = name;
10023 + name = strsep(&value, "=");
10024 + if (value)
10025 + ret = nvram_set(name, value) ? : count;
10026 + else
10027 + ret = nvram_unset(name) ? : count;
10028 +
10029 + done:
10030 + if (name != tmp)
10031 + kfree(name);
10032 +
10033 + return ret;
10034 +}
10035 +
10036 +static int
10037 +dev_nvram_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
10038 +{
10039 + if (cmd != NVRAM_MAGIC)
10040 + return -EINVAL;
10041 + return nvram_commit();
10042 +}
10043 +
10044 +static int
10045 +dev_nvram_mmap(struct file *file, struct vm_area_struct *vma)
10046 +{
10047 + unsigned long offset = virt_to_phys(nvram_buf);
10048 +
10049 + if (remap_page_range(vma->vm_start, offset, vma->vm_end-vma->vm_start,
10050 + vma->vm_page_prot))
10051 + return -EAGAIN;
10052 +
10053 + return 0;
10054 +}
10055 +
10056 +static int
10057 +dev_nvram_open(struct inode *inode, struct file * file)
10058 +{
10059 + MOD_INC_USE_COUNT;
10060 + return 0;
10061 +}
10062 +
10063 +static int
10064 +dev_nvram_release(struct inode *inode, struct file * file)
10065 +{
10066 + MOD_DEC_USE_COUNT;
10067 + return 0;
10068 +}
10069 +
10070 +static struct file_operations dev_nvram_fops = {
10071 + owner: THIS_MODULE,
10072 + open: dev_nvram_open,
10073 + release: dev_nvram_release,
10074 + read: dev_nvram_read,
10075 + write: dev_nvram_write,
10076 + ioctl: dev_nvram_ioctl,
10077 + mmap: dev_nvram_mmap,
10078 +};
10079 +
10080 +static void
10081 +dev_nvram_exit(void)
10082 +{
10083 + int order = 0;
10084 + struct page *page, *end;
10085 +
10086 + if (nvram_handle)
10087 + devfs_unregister(nvram_handle);
10088 +
10089 + if (nvram_major >= 0)
10090 + devfs_unregister_chrdev(nvram_major, "nvram");
10091 +
10092 + if (nvram_mtd)
10093 + put_mtd_device(nvram_mtd);
10094 +
10095 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
10096 + order++;
10097 + end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
10098 + for (page = virt_to_page(nvram_buf); page <= end; page++)
10099 + mem_map_unreserve(page);
10100 +
10101 + _nvram_exit();
10102 +}
10103 +
10104 +static int __init
10105 +dev_nvram_init(void)
10106 +{
10107 + int order = 0, ret = 0;
10108 + struct page *page, *end;
10109 + unsigned int i;
10110 +
10111 + /* Allocate and reserve memory to mmap() */
10112 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
10113 + order++;
10114 + end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
10115 + for (page = virt_to_page(nvram_buf); page <= end; page++)
10116 + mem_map_reserve(page);
10117 +
10118 +#ifdef CONFIG_MTD
10119 + /* Find associated MTD device */
10120 + for (i = 0; i < MAX_MTD_DEVICES; i++) {
10121 + nvram_mtd = get_mtd_device(NULL, i);
10122 + if (nvram_mtd) {
10123 + if (!strcmp(nvram_mtd->name, "nvram") &&
10124 + nvram_mtd->size >= NVRAM_SPACE)
10125 + break;
10126 + put_mtd_device(nvram_mtd);
10127 + }
10128 + }
10129 + if (i >= MAX_MTD_DEVICES)
10130 + nvram_mtd = NULL;
10131 +#endif
10132 +
10133 + /* Initialize hash table lock */
10134 + spin_lock_init(&nvram_lock);
10135 +
10136 + /* Initialize commit semaphore */
10137 + init_MUTEX(&nvram_sem);
10138 +
10139 + /* Register char device */
10140 + if ((nvram_major = devfs_register_chrdev(0, "nvram", &dev_nvram_fops)) < 0) {
10141 + ret = nvram_major;
10142 + goto err;
10143 + }
10144 +
10145 + /* Initialize hash table */
10146 + _nvram_init();
10147 +
10148 + /* Create /dev/nvram handle */
10149 + nvram_handle = devfs_register(NULL, "nvram", DEVFS_FL_NONE, nvram_major, 0,
10150 + S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, &dev_nvram_fops, NULL);
10151 +
10152 + /* Set the SDRAM NCDL value into NVRAM if not already done */
10153 + if (getintvar(NULL, "sdram_ncdl") == 0) {
10154 + unsigned int ncdl;
10155 + char buf[] = "0x00000000";
10156 +
10157 + if ((ncdl = sb_memc_get_ncdl(sbh))) {
10158 + sprintf(buf, "0x%08x", ncdl);
10159 + nvram_set("sdram_ncdl", buf);
10160 + nvram_commit();
10161 + }
10162 + }
10163 +
10164 + return 0;
10165 +
10166 + err:
10167 + dev_nvram_exit();
10168 + return ret;
10169 +}
10170 +
10171 +module_init(dev_nvram_init);
10172 +module_exit(dev_nvram_exit);
10173 diff -urN linux-2.4.30/arch/mips/bcm947xx/pcibios.c linux-2.4.30.dev/arch/mips/bcm947xx/pcibios.c
10174 --- linux-2.4.30/arch/mips/bcm947xx/pcibios.c 1970-01-01 01:00:00.000000000 +0100
10175 +++ linux-2.4.30.dev/arch/mips/bcm947xx/pcibios.c 2005-08-22 01:34:46.343148424 +0200
10176 @@ -0,0 +1,355 @@
10177 +/*
10178 + * Low-Level PCI and SB support for BCM47xx (Linux support code)
10179 + *
10180 + * Copyright 2004, Broadcom Corporation
10181 + * All Rights Reserved.
10182 + *
10183 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10184 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10185 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10186 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10187 + *
10188 + * $Id$
10189 + */
10190 +
10191 +#include <linux/config.h>
10192 +#include <linux/types.h>
10193 +#include <linux/kernel.h>
10194 +#include <linux/sched.h>
10195 +#include <linux/pci.h>
10196 +#include <linux/init.h>
10197 +#include <linux/delay.h>
10198 +#include <asm/io.h>
10199 +#include <asm/irq.h>
10200 +#include <asm/paccess.h>
10201 +
10202 +#include <typedefs.h>
10203 +#include <bcmutils.h>
10204 +#include <sbconfig.h>
10205 +#include <sbpci.h>
10206 +#include <pcicfg.h>
10207 +#include <sbutils.h>
10208 +#include <bcmdevs.h>
10209 +#include <bcmnvram.h>
10210 +
10211 +/* Global SB handle */
10212 +extern void *bcm947xx_sbh;
10213 +extern spinlock_t bcm947xx_sbh_lock;
10214 +
10215 +/* Convenience */
10216 +#define sbh bcm947xx_sbh
10217 +#define sbh_lock bcm947xx_sbh_lock
10218 +
10219 +static int
10220 +sbpci_read_config_byte(struct pci_dev *dev, int where, u8 *value)
10221 +{
10222 + unsigned long flags;
10223 + int ret;
10224 +
10225 + spin_lock_irqsave(&sbh_lock, flags);
10226 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
10227 + spin_unlock_irqrestore(&sbh_lock, flags);
10228 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10229 +}
10230 +
10231 +static int
10232 +sbpci_read_config_word(struct pci_dev *dev, int where, u16 *value)
10233 +{
10234 + unsigned long flags;
10235 + int ret;
10236 +
10237 + spin_lock_irqsave(&sbh_lock, flags);
10238 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
10239 + spin_unlock_irqrestore(&sbh_lock, flags);
10240 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10241 +}
10242 +
10243 +static int
10244 +sbpci_read_config_dword(struct pci_dev *dev, int where, u32 *value)
10245 +{
10246 + unsigned long flags;
10247 + int ret;
10248 +
10249 + spin_lock_irqsave(&sbh_lock, flags);
10250 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
10251 + spin_unlock_irqrestore(&sbh_lock, flags);
10252 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10253 +}
10254 +
10255 +static int
10256 +sbpci_write_config_byte(struct pci_dev *dev, int where, u8 value)
10257 +{
10258 + unsigned long flags;
10259 + int ret;
10260 +
10261 + spin_lock_irqsave(&sbh_lock, flags);
10262 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
10263 + spin_unlock_irqrestore(&sbh_lock, flags);
10264 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10265 +}
10266 +
10267 +static int
10268 +sbpci_write_config_word(struct pci_dev *dev, int where, u16 value)
10269 +{
10270 + unsigned long flags;
10271 + int ret;
10272 +
10273 + spin_lock_irqsave(&sbh_lock, flags);
10274 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
10275 + spin_unlock_irqrestore(&sbh_lock, flags);
10276 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10277 +}
10278 +
10279 +static int
10280 +sbpci_write_config_dword(struct pci_dev *dev, int where, u32 value)
10281 +{
10282 + unsigned long flags;
10283 + int ret;
10284 +
10285 + spin_lock_irqsave(&sbh_lock, flags);
10286 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
10287 + spin_unlock_irqrestore(&sbh_lock, flags);
10288 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
10289 +}
10290 +
10291 +static struct pci_ops pcibios_ops = {
10292 + sbpci_read_config_byte,
10293 + sbpci_read_config_word,
10294 + sbpci_read_config_dword,
10295 + sbpci_write_config_byte,
10296 + sbpci_write_config_word,
10297 + sbpci_write_config_dword
10298 +};
10299 +
10300 +
10301 +void __init
10302 +pcibios_init(void)
10303 +{
10304 + ulong flags;
10305 +
10306 + if (!(sbh = sb_kattach()))
10307 + panic("sb_kattach failed");
10308 + spin_lock_init(&sbh_lock);
10309 +
10310 + spin_lock_irqsave(&sbh_lock, flags);
10311 + sbpci_init(sbh);
10312 + spin_unlock_irqrestore(&sbh_lock, flags);
10313 +
10314 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
10315 +
10316 + mdelay(300); //By Joey for Atheros Card
10317 +
10318 + /* Scan the SB bus */
10319 + pci_scan_bus(0, &pcibios_ops, NULL);
10320 +
10321 +}
10322 +
10323 +char * __init
10324 +pcibios_setup(char *str)
10325 +{
10326 + if (!strncmp(str, "ban=", 4)) {
10327 + sbpci_ban(simple_strtoul(str + 4, NULL, 0));
10328 + return NULL;
10329 + }
10330 +
10331 + return (str);
10332 +}
10333 +
10334 +static u32 pci_iobase = 0x100;
10335 +static u32 pci_membase = SB_PCI_DMA;
10336 +
10337 +void __init
10338 +pcibios_fixup_bus(struct pci_bus *b)
10339 +{
10340 + struct list_head *ln;
10341 + struct pci_dev *d;
10342 + struct resource *res;
10343 + int pos, size;
10344 + u32 *base;
10345 + u8 irq;
10346 +
10347 + printk("PCI: Fixing up bus %d\n", b->number);
10348 +
10349 + /* Fix up SB */
10350 + if (b->number == 0) {
10351 + for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
10352 + d = pci_dev_b(ln);
10353 + /* Fix up interrupt lines */
10354 + pci_read_config_byte(d, PCI_INTERRUPT_LINE, &irq);
10355 + d->irq = irq + 2;
10356 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
10357 + }
10358 + }
10359 +
10360 + /* Fix up external PCI */
10361 + else {
10362 + for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
10363 + d = pci_dev_b(ln);
10364 + /* Fix up resource bases */
10365 + for (pos = 0; pos < 6; pos++) {
10366 + res = &d->resource[pos];
10367 + base = (res->flags & IORESOURCE_IO) ? &pci_iobase : &pci_membase;
10368 + if (res->end) {
10369 + size = res->end - res->start + 1;
10370 + if (*base & (size - 1))
10371 + *base = (*base + size) & ~(size - 1);
10372 + res->start = *base;
10373 + res->end = res->start + size - 1;
10374 + *base += size;
10375 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
10376 + }
10377 + /* Fix up PCI bridge BAR0 only */
10378 + if (b->number == 1 && PCI_SLOT(d->devfn) == 0)
10379 + break;
10380 + }
10381 + /* Fix up interrupt lines */
10382 + if (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))
10383 + d->irq = (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))->irq;
10384 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
10385 + }
10386 + }
10387 +}
10388 +
10389 +unsigned int
10390 +pcibios_assign_all_busses(void)
10391 +{
10392 + return 1;
10393 +}
10394 +
10395 +void
10396 +pcibios_align_resource(void *data, struct resource *res,
10397 + unsigned long size, unsigned long align)
10398 +{
10399 +}
10400 +
10401 +int
10402 +pcibios_enable_resources(struct pci_dev *dev)
10403 +{
10404 + u16 cmd, old_cmd;
10405 + int idx;
10406 + struct resource *r;
10407 +
10408 + /* External PCI only */
10409 + if (dev->bus->number == 0)
10410 + return 0;
10411 +
10412 + pci_read_config_word(dev, PCI_COMMAND, &cmd);
10413 + old_cmd = cmd;
10414 + for(idx=0; idx<6; idx++) {
10415 + r = &dev->resource[idx];
10416 + if (r->flags & IORESOURCE_IO)
10417 + cmd |= PCI_COMMAND_IO;
10418 + if (r->flags & IORESOURCE_MEM)
10419 + cmd |= PCI_COMMAND_MEMORY;
10420 + }
10421 + if (dev->resource[PCI_ROM_RESOURCE].start)
10422 + cmd |= PCI_COMMAND_MEMORY;
10423 + if (cmd != old_cmd) {
10424 + printk("PCI: Enabling device %s (%04x -> %04x)\n", dev->slot_name, old_cmd, cmd);
10425 + pci_write_config_word(dev, PCI_COMMAND, cmd);
10426 + }
10427 + return 0;
10428 +}
10429 +
10430 +int
10431 +pcibios_enable_device(struct pci_dev *dev, int mask)
10432 +{
10433 + ulong flags;
10434 + uint coreidx;
10435 +
10436 + /* External PCI device enable */
10437 + if (dev->bus->number != 0)
10438 + return pcibios_enable_resources(dev);
10439 +
10440 + /* These cores come out of reset enabled */
10441 + if (dev->device == SB_MIPS ||
10442 + dev->device == SB_MIPS33 ||
10443 + dev->device == SB_EXTIF ||
10444 + dev->device == SB_CC)
10445 + return 0;
10446 +
10447 + spin_lock_irqsave(&sbh_lock, flags);
10448 + coreidx = sb_coreidx(sbh);
10449 + if (!sb_setcoreidx(sbh, PCI_SLOT(dev->devfn)))
10450 + return PCIBIOS_DEVICE_NOT_FOUND;
10451 +
10452 + /*
10453 + * The USB core requires a special bit to be set during core
10454 + * reset to enable host (OHCI) mode. Resetting the SB core in
10455 + * pcibios_enable_device() is a hack for compatibility with
10456 + * vanilla usb-ohci so that it does not have to know about
10457 + * SB. A driver that wants to use the USB core in device mode
10458 + * should know about SB and should reset the bit back to 0
10459 + * after calling pcibios_enable_device().
10460 + */
10461 + if (sb_coreid(sbh) == SB_USB) {
10462 + sb_core_disable(sbh, sb_coreflags(sbh, 0, 0));
10463 + sb_core_reset(sbh, 1 << 29);
10464 + } else
10465 + sb_core_reset(sbh, 0);
10466 +
10467 + sb_setcoreidx(sbh, coreidx);
10468 + spin_unlock_irqrestore(&sbh_lock, flags);
10469 +
10470 + return 0;
10471 +}
10472 +
10473 +void
10474 +pcibios_update_resource(struct pci_dev *dev, struct resource *root,
10475 + struct resource *res, int resource)
10476 +{
10477 + unsigned long where, size;
10478 + u32 reg;
10479 +
10480 + /* External PCI only */
10481 + if (dev->bus->number == 0)
10482 + return;
10483 +
10484 + where = PCI_BASE_ADDRESS_0 + (resource * 4);
10485 + size = res->end - res->start;
10486 + pci_read_config_dword(dev, where, &reg);
10487 + reg = (reg & size) | (((u32)(res->start - root->start)) & ~size);
10488 + pci_write_config_dword(dev, where, reg);
10489 +}
10490 +
10491 +static void __init
10492 +quirk_sbpci_bridge(struct pci_dev *dev)
10493 +{
10494 + if (dev->bus->number != 1 || PCI_SLOT(dev->devfn) != 0)
10495 + return;
10496 +
10497 + printk("PCI: Fixing up bridge\n");
10498 +
10499 + /* Enable PCI bridge bus mastering and memory space */
10500 + pci_set_master(dev);
10501 + pcibios_enable_resources(dev);
10502 +
10503 + /* Enable PCI bridge BAR1 prefetch and burst */
10504 + pci_write_config_dword(dev, PCI_BAR1_CONTROL, 3);
10505 +}
10506 +
10507 +struct pci_fixup pcibios_fixups[] = {
10508 + { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, quirk_sbpci_bridge },
10509 + { 0 }
10510 +};
10511 +
10512 +/*
10513 + * If we set up a device for bus mastering, we need to check the latency
10514 + * timer as certain crappy BIOSes forget to set it properly.
10515 + */
10516 +unsigned int pcibios_max_latency = 255;
10517 +
10518 +void pcibios_set_master(struct pci_dev *dev)
10519 +{
10520 + u8 lat;
10521 + pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
10522 + if (lat < 16)
10523 + lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
10524 + else if (lat > pcibios_max_latency)
10525 + lat = pcibios_max_latency;
10526 + else
10527 + return;
10528 + printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", dev->slot_name, lat);
10529 + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
10530 +}
10531 +
10532 diff -urN linux-2.4.30/arch/mips/bcm947xx/prom.c linux-2.4.30.dev/arch/mips/bcm947xx/prom.c
10533 --- linux-2.4.30/arch/mips/bcm947xx/prom.c 1970-01-01 01:00:00.000000000 +0100
10534 +++ linux-2.4.30.dev/arch/mips/bcm947xx/prom.c 2005-08-22 01:34:46.343148424 +0200
10535 @@ -0,0 +1,41 @@
10536 +/*
10537 + * Early initialization code for BCM94710 boards
10538 + *
10539 + * Copyright 2004, Broadcom Corporation
10540 + * All Rights Reserved.
10541 + *
10542 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10543 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10544 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10545 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10546 + *
10547 + * $Id: prom.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
10548 + */
10549 +
10550 +#include <linux/config.h>
10551 +#include <linux/init.h>
10552 +#include <linux/kernel.h>
10553 +#include <linux/types.h>
10554 +#include <asm/bootinfo.h>
10555 +
10556 +void __init
10557 +prom_init(int argc, const char **argv)
10558 +{
10559 + unsigned long mem;
10560 +
10561 + mips_machgroup = MACH_GROUP_BRCM;
10562 + mips_machtype = MACH_BCM947XX;
10563 +
10564 + /* Figure out memory size by finding aliases */
10565 + for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
10566 + if (*(unsigned long *)((unsigned long)(prom_init) + mem) ==
10567 + *(unsigned long *)(prom_init))
10568 + break;
10569 + }
10570 + add_memory_region(0, mem, BOOT_MEM_RAM);
10571 +}
10572 +
10573 +void __init
10574 +prom_free_prom_memory(void)
10575 +{
10576 +}
10577 diff -urN linux-2.4.30/arch/mips/bcm947xx/sbmips.c linux-2.4.30.dev/arch/mips/bcm947xx/sbmips.c
10578 --- linux-2.4.30/arch/mips/bcm947xx/sbmips.c 1970-01-01 01:00:00.000000000 +0100
10579 +++ linux-2.4.30.dev/arch/mips/bcm947xx/sbmips.c 2005-08-22 01:34:46.345148120 +0200
10580 @@ -0,0 +1,982 @@
10581 +/*
10582 + * BCM47XX Sonics SiliconBackplane MIPS core routines
10583 + *
10584 + * Copyright 2004, Broadcom Corporation
10585 + * All Rights Reserved.
10586 + *
10587 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10588 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10589 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10590 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10591 + *
10592 + * $Id$
10593 + */
10594 +
10595 +#include <typedefs.h>
10596 +#include <osl.h>
10597 +#include <sbutils.h>
10598 +#include <bcmdevs.h>
10599 +#include <bcmnvram.h>
10600 +#include <bcmutils.h>
10601 +#include <hndmips.h>
10602 +#include <sbconfig.h>
10603 +#include <sbextif.h>
10604 +#include <sbchipc.h>
10605 +#include <sbmemc.h>
10606 +#include <mipsinc.h>
10607 +
10608 +/*
10609 + * Returns TRUE if an external UART exists at the given base
10610 + * register.
10611 + */
10612 +static bool
10613 +BCMINITFN(serial_exists)(uint8 *regs)
10614 +{
10615 + uint8 save_mcr, status1;
10616 +
10617 + save_mcr = R_REG(&regs[UART_MCR]);
10618 + W_REG(&regs[UART_MCR], UART_MCR_LOOP | 0x0a);
10619 + status1 = R_REG(&regs[UART_MSR]) & 0xf0;
10620 + W_REG(&regs[UART_MCR], save_mcr);
10621 +
10622 + return (status1 == 0x90);
10623 +}
10624 +
10625 +/*
10626 + * Initializes UART access. The callback function will be called once
10627 + * per found UART.
10628 + */
10629 +void
10630 +BCMINITFN(sb_serial_init)(void *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift))
10631 +{
10632 + void *regs;
10633 + ulong base;
10634 + uint irq;
10635 + int i, n;
10636 +
10637 + if ((regs = sb_setcore(sbh, SB_EXTIF, 0))) {
10638 + extifregs_t *eir = (extifregs_t *) regs;
10639 + sbconfig_t *sb;
10640 +
10641 + /* Determine external UART register base */
10642 + sb = (sbconfig_t *)((ulong) eir + SBCONFIGOFF);
10643 + base = EXTIF_CFGIF_BASE(sb_base(R_REG(&sb->sbadmatch1)));
10644 +
10645 + /* Determine IRQ */
10646 + irq = sb_irq(sbh);
10647 +
10648 + /* Disable GPIO interrupt initially */
10649 + W_REG(&eir->gpiointpolarity, 0);
10650 + W_REG(&eir->gpiointmask, 0);
10651 +
10652 + /* Search for external UARTs */
10653 + n = 2;
10654 + for (i = 0; i < 2; i++) {
10655 + regs = (void *) REG_MAP(base + (i * 8), 8);
10656 + if (BCMINIT(serial_exists)(regs)) {
10657 + /* Set GPIO 1 to be the external UART IRQ */
10658 + W_REG(&eir->gpiointmask, 2);
10659 + if (add)
10660 + add(regs, irq, 13500000, 0);
10661 + }
10662 + }
10663 +
10664 + /* Add internal UART if enabled */
10665 + if (R_REG(&eir->corecontrol) & CC_UE)
10666 + if (add)
10667 + add((void *) &eir->uartdata, irq, sb_clock(sbh), 2);
10668 + } else if ((regs = sb_setcore(sbh, SB_CC, 0))) {
10669 + chipcregs_t *cc = (chipcregs_t *) regs;
10670 + uint32 rev, cap, pll, baud_base, div;
10671 +
10672 + /* Determine core revision and capabilities */
10673 + rev = sb_corerev(sbh);
10674 + cap = R_REG(&cc->capabilities);
10675 + pll = cap & CAP_PLL_MASK;
10676 +
10677 + /* Determine IRQ */
10678 + irq = sb_irq(sbh);
10679 +
10680 + if (pll == PLL_TYPE1) {
10681 + /* PLL clock */
10682 + baud_base = sb_clock_rate(pll,
10683 + R_REG(&cc->clockcontrol_n),
10684 + R_REG(&cc->clockcontrol_m2));
10685 + div = 1;
10686 + } else if (rev >= 3) {
10687 + if (pll == PLL_TYPE6) {
10688 + /* Fixed ALP clock on 4320 */
10689 + baud_base = 20000000;
10690 + /* Set the override bit so we don't divide it */
10691 + W_REG(&cc->corecontrol, CC_UARTCLKO);
10692 + } else {
10693 + /* Internal backplane clock */
10694 + baud_base = sb_clock(sbh);
10695 + }
10696 + div = 2; /* Minimum divisor */
10697 + W_REG(&cc->clkdiv, ((R_REG(&cc->clkdiv) & ~CLKD_UART) | div));
10698 + } else {
10699 + /* Fixed internal backplane clock */
10700 + baud_base = 88000000;
10701 + div = 48;
10702 + }
10703 +
10704 + /* Clock source depends on strapping if UartClkOverride is unset */
10705 + if ((rev > 0) && ((R_REG(&cc->corecontrol) & CC_UARTCLKO) == 0)) {
10706 + if ((cap & CAP_UCLKSEL) == CAP_UINTCLK) {
10707 + /* Internal divided backplane clock */
10708 + baud_base /= div;
10709 + } else {
10710 + /* Assume external clock of 1.8432 MHz */
10711 + baud_base = 1843200;
10712 + }
10713 + }
10714 +
10715 + /* Add internal UARTs */
10716 + n = cap & CAP_UARTS_MASK;
10717 + for (i = 0; i < n; i++) {
10718 + /* Register offset changed after revision 0 */
10719 + if (rev)
10720 + regs = (void *)((ulong) &cc->uart0data + (i * 256));
10721 + else
10722 + regs = (void *)((ulong) &cc->uart0data + (i * 8));
10723 +
10724 + if (add)
10725 + add(regs, irq, baud_base, 0);
10726 + }
10727 + }
10728 +}
10729 +
10730 +/*
10731 + * Initialize jtag master and return handle for
10732 + * jtag_rwreg. Returns NULL on failure.
10733 + */
10734 +void *
10735 +sb_jtagm_init(void *sbh, uint clkd, bool exttap)
10736 +{
10737 + void *regs;
10738 +
10739 + if ((regs = sb_setcore(sbh, SB_CC, 0)) != NULL) {
10740 + chipcregs_t *cc = (chipcregs_t *) regs;
10741 + uint32 tmp;
10742 +
10743 + /*
10744 + * Determine jtagm availability from
10745 + * core revision and capabilities.
10746 + */
10747 + tmp = sb_corerev(sbh);
10748 + /*
10749 + * Corerev 10 has jtagm, but the only chip
10750 + * with it does not have a mips, and
10751 + * the layout of the jtagcmd register is
10752 + * different. We'll only accept >= 11.
10753 + */
10754 + if (tmp < 11)
10755 + return (NULL);
10756 +
10757 + tmp = R_REG(&cc->capabilities);
10758 + if ((tmp & CAP_JTAGP) == 0)
10759 + return (NULL);
10760 +
10761 + /* Set clock divider if requested */
10762 + if (clkd != 0) {
10763 + tmp = R_REG(&cc->clkdiv);
10764 + tmp = (tmp & ~CLKD_JTAG) |
10765 + ((clkd << CLKD_JTAG_SHIFT) & CLKD_JTAG);
10766 + W_REG(&cc->clkdiv, tmp);
10767 + }
10768 +
10769 + /* Enable jtagm */
10770 + tmp = JCTRL_EN | (exttap ? JCTRL_EXT_EN : 0);
10771 + W_REG(&cc->jtagctrl, tmp);
10772 + }
10773 +
10774 + return (regs);
10775 +}
10776 +
10777 +void
10778 +sb_jtagm_disable(void *h)
10779 +{
10780 + chipcregs_t *cc = (chipcregs_t *)h;
10781 +
10782 + W_REG(&cc->jtagctrl, R_REG(&cc->jtagctrl) & ~JCTRL_EN);
10783 +}
10784 +
10785 +/*
10786 + * Read/write a jtag register. Assumes a target with
10787 + * 8 bit IR and 32 bit DR.
10788 + */
10789 +#define IRWIDTH 8
10790 +#define DRWIDTH 32
10791 +uint32
10792 +jtag_rwreg(void *h, uint32 ir, uint32 dr)
10793 +{
10794 + chipcregs_t *cc = (chipcregs_t *) h;
10795 + uint32 tmp;
10796 +
10797 + W_REG(&cc->jtagir, ir);
10798 + W_REG(&cc->jtagdr, dr);
10799 + tmp = JCMD_START | JCMD_ACC_IRDR |
10800 + ((IRWIDTH - 1) << JCMD_IRW_SHIFT) |
10801 + (DRWIDTH - 1);
10802 + W_REG(&cc->jtagcmd, tmp);
10803 + while (((tmp = R_REG(&cc->jtagcmd)) & JCMD_BUSY) == JCMD_BUSY) {
10804 + /* OSL_DELAY(1); */
10805 + }
10806 +
10807 + tmp = R_REG(&cc->jtagdr);
10808 + return (tmp);
10809 +}
10810 +
10811 +/* Returns the SB interrupt flag of the current core. */
10812 +uint32
10813 +sb_flag(void *sbh)
10814 +{
10815 + void *regs;
10816 + sbconfig_t *sb;
10817 +
10818 + regs = sb_coreregs(sbh);
10819 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
10820 +
10821 + return (R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK);
10822 +}
10823 +
10824 +static const uint32 sbips_int_mask[] = {
10825 + 0,
10826 + SBIPS_INT1_MASK,
10827 + SBIPS_INT2_MASK,
10828 + SBIPS_INT3_MASK,
10829 + SBIPS_INT4_MASK
10830 +};
10831 +
10832 +static const uint32 sbips_int_shift[] = {
10833 + 0,
10834 + 0,
10835 + SBIPS_INT2_SHIFT,
10836 + SBIPS_INT3_SHIFT,
10837 + SBIPS_INT4_SHIFT
10838 +};
10839 +
10840 +/*
10841 + * Returns the MIPS IRQ assignment of the current core. If unassigned,
10842 + * 0 is returned.
10843 + */
10844 +uint
10845 +sb_irq(void *sbh)
10846 +{
10847 + uint idx;
10848 + void *regs;
10849 + sbconfig_t *sb;
10850 + uint32 flag, sbipsflag;
10851 + uint irq = 0;
10852 +
10853 + flag = sb_flag(sbh);
10854 +
10855 + idx = sb_coreidx(sbh);
10856 +
10857 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
10858 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
10859 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
10860 +
10861 + /* sbipsflag specifies which core is routed to interrupts 1 to 4 */
10862 + sbipsflag = R_REG(&sb->sbipsflag);
10863 + for (irq = 1; irq <= 4; irq++) {
10864 + if (((sbipsflag & sbips_int_mask[irq]) >> sbips_int_shift[irq]) == flag)
10865 + break;
10866 + }
10867 + if (irq == 5)
10868 + irq = 0;
10869 + }
10870 +
10871 + sb_setcoreidx(sbh, idx);
10872 +
10873 + return irq;
10874 +}
10875 +
10876 +/* Clears the specified MIPS IRQ. */
10877 +static void
10878 +BCMINITFN(sb_clearirq)(void *sbh, uint irq)
10879 +{
10880 + void *regs;
10881 + sbconfig_t *sb;
10882 +
10883 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
10884 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
10885 + ASSERT(regs);
10886 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
10887 +
10888 + if (irq == 0)
10889 + W_REG(&sb->sbintvec, 0);
10890 + else
10891 + OR_REG(&sb->sbipsflag, sbips_int_mask[irq]);
10892 +}
10893 +
10894 +/*
10895 + * Assigns the specified MIPS IRQ to the specified core. Shared MIPS
10896 + * IRQ 0 may be assigned more than once.
10897 + */
10898 +static void
10899 +BCMINITFN(sb_setirq)(void *sbh, uint irq, uint coreid, uint coreunit)
10900 +{
10901 + void *regs;
10902 + sbconfig_t *sb;
10903 + uint32 flag;
10904 +
10905 + regs = sb_setcore(sbh, coreid, coreunit);
10906 + ASSERT(regs);
10907 + flag = sb_flag(sbh);
10908 +
10909 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
10910 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
10911 + ASSERT(regs);
10912 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
10913 +
10914 + if (irq == 0)
10915 + OR_REG(&sb->sbintvec, 1 << flag);
10916 + else {
10917 + flag <<= sbips_int_shift[irq];
10918 + ASSERT(!(flag & ~sbips_int_mask[irq]));
10919 + flag |= R_REG(&sb->sbipsflag) & ~sbips_int_mask[irq];
10920 + W_REG(&sb->sbipsflag, flag);
10921 + }
10922 +}
10923 +
10924 +/*
10925 + * Initializes clocks and interrupts. SB and NVRAM access must be
10926 + * initialized prior to calling.
10927 + */
10928 +void
10929 +BCMINITFN(sb_mips_init)(void *sbh)
10930 +{
10931 + ulong hz, ns, tmp;
10932 + extifregs_t *eir;
10933 + chipcregs_t *cc;
10934 + char *value;
10935 + uint irq;
10936 +
10937 + /* Figure out current SB clock speed */
10938 + if ((hz = sb_clock(sbh)) == 0)
10939 + hz = 100000000;
10940 + ns = 1000000000 / hz;
10941 +
10942 + /* Setup external interface timing */
10943 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
10944 + /* Initialize extif so we can get to the LEDs and external UART */
10945 + W_REG(&eir->prog_config, CF_EN);
10946 +
10947 + /* Set timing for the flash */
10948 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
10949 + tmp = tmp | (CEIL(40, ns) << FW_W1_SHIFT); /* W1 = 40nS */
10950 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
10951 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
10952 +
10953 + /* Set programmable interface timing for external uart */
10954 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
10955 + tmp = tmp | (CEIL(20, ns) << FW_W2_SHIFT); /* W2 = 20nS */
10956 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */
10957 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
10958 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
10959 + } else if ((cc = sb_setcore(sbh, SB_CC, 0))) {
10960 + /* Set timing for the flash */
10961 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
10962 + tmp |= CEIL(10, ns) << FW_W1_SHIFT; /* W1 = 10nS */
10963 + tmp |= CEIL(120, ns); /* W0 = 120nS */
10964 +
10965 + // Added by Chen-I for 5365
10966 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
10967 + {
10968 + W_REG(&cc->flash_waitcount, tmp);
10969 + W_REG(&cc->pcmcia_memwait, tmp);
10970 + }
10971 + else
10972 + {
10973 + if (sb_corerev(sbh) < 9)
10974 + W_REG(&cc->flash_waitcount, tmp);
10975 +
10976 + if ( (sb_corerev(sbh) < 9) ||
10977 + ((BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID) && BCMINIT(sb_chiprev)(sbh) == 0) ) {
10978 + W_REG(&cc->pcmcia_memwait, tmp);
10979 + }
10980 + }
10981 +
10982 + // Added by Chen-I & Yen for enabling 5350 EXTIF
10983 + if (BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID)
10984 + {
10985 + /* Set programmable interface timing for external uart */
10986 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
10987 + tmp = tmp | (CEIL(20, ns) << FW_W2_SHIFT); /* W2 = 20nS */
10988 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */
10989 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
10990 + W_REG(&cc->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
10991 + //printf("===========config_REG=%d\n", R_REG(&cc->prog_config));
10992 + //printf("-----------config_REG_addr=%x\n", &cc->prog_config);
10993 + //printf("===========waitcount_REG=%d\n", R_REG(&cc->prog_waitcount));
10994 + //printf("-----------waitcount_REG=%x\n", &cc->prog_waitcount);
10995 + }
10996 + }
10997 +
10998 + /* Chip specific initialization */
10999 + switch (BCMINIT(sb_chip)(sbh)) {
11000 + case BCM4710_DEVICE_ID:
11001 + /* Clear interrupt map */
11002 + for (irq = 0; irq <= 4; irq++)
11003 + BCMINIT(sb_clearirq)(sbh, irq);
11004 + BCMINIT(sb_setirq)(sbh, 0, SB_CODEC, 0);
11005 + BCMINIT(sb_setirq)(sbh, 0, SB_EXTIF, 0);
11006 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 1);
11007 + BCMINIT(sb_setirq)(sbh, 3, SB_ILINE20, 0);
11008 + BCMINIT(sb_setirq)(sbh, 4, SB_PCI, 0);
11009 + ASSERT(eir);
11010 + value = BCMINIT(nvram_get)("et0phyaddr");
11011 + if (value && !strcmp(value, "31")) {
11012 + /* Enable internal UART */
11013 + W_REG(&eir->corecontrol, CC_UE);
11014 + /* Give USB its own interrupt */
11015 + BCMINIT(sb_setirq)(sbh, 1, SB_USB, 0);
11016 + } else {
11017 + /* Disable internal UART */
11018 + W_REG(&eir->corecontrol, 0);
11019 + /* Give Ethernet its own interrupt */
11020 + BCMINIT(sb_setirq)(sbh, 1, SB_ENET, 0);
11021 + BCMINIT(sb_setirq)(sbh, 0, SB_USB, 0);
11022 + }
11023 + break;
11024 + case BCM4310_DEVICE_ID:
11025 + MTC0(C0_BROADCOM, 0, MFC0(C0_BROADCOM, 0) & ~(1 << 22));
11026 + break;
11027 + case BCM5350_DEVICE_ID:
11028 + /* Clear interrupt map */
11029 + for (irq = 0; irq <= 4; irq++)
11030 + BCMINIT(sb_clearirq)(sbh, irq);
11031 + BCMINIT(sb_setirq)(sbh, 0, SB_CC, 0);
11032 + BCMINIT(sb_setirq)(sbh, 1, SB_D11, 0);
11033 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 0);
11034 + BCMINIT(sb_setirq)(sbh, 3, SB_IPSEC, 0);
11035 + BCMINIT(sb_setirq)(sbh, 4, SB_USB, 0);
11036 + break;
11037 + }
11038 +}
11039 +
11040 +uint32
11041 +BCMINITFN(sb_mips_clock)(void *sbh)
11042 +{
11043 + extifregs_t *eir;
11044 + chipcregs_t *cc;
11045 + uint32 n, m;
11046 + uint idx;
11047 + uint32 pll_type, rate = 0;
11048 +
11049 + /* get index of the current core */
11050 + idx = sb_coreidx(sbh);
11051 + pll_type = PLL_TYPE1;
11052 +
11053 + /* switch to extif or chipc core */
11054 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
11055 + n = R_REG(&eir->clockcontrol_n);
11056 + m = R_REG(&eir->clockcontrol_sb);
11057 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
11058 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
11059 + n = R_REG(&cc->clockcontrol_n);
11060 + if ((pll_type == PLL_TYPE2) ||
11061 + (pll_type == PLL_TYPE4) ||
11062 + (pll_type == PLL_TYPE6))
11063 + m = R_REG(&cc->clockcontrol_mips);
11064 + else if (pll_type == PLL_TYPE5) {
11065 + rate = 200000000;
11066 + goto out;
11067 + }
11068 + else if (pll_type == PLL_TYPE3) {
11069 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) { /* 5365 is also type3 */
11070 + rate = 200000000;
11071 + goto out;
11072 + } else
11073 + m = R_REG(&cc->clockcontrol_m2); /* 5350 uses m2 to control mips */
11074 + } else
11075 + m = R_REG(&cc->clockcontrol_sb);
11076 + } else
11077 + goto out;
11078 +
11079 + // Added by Chen-I for 5365
11080 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
11081 + rate = 100000000;
11082 + else
11083 + /* calculate rate */
11084 + rate = sb_clock_rate(pll_type, n, m);
11085 +
11086 + if (pll_type == PLL_TYPE6)
11087 + rate = SB2MIPS_T6(rate);
11088 +
11089 +out:
11090 + /* switch back to previous core */
11091 + sb_setcoreidx(sbh, idx);
11092 +
11093 + return rate;
11094 +}
11095 +
11096 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
11097 +
11098 +static void
11099 +BCMINITFN(handler)(void)
11100 +{
11101 + /* Step 11 */
11102 + __asm__ (
11103 + ".set\tmips32\n\t"
11104 + "ssnop\n\t"
11105 + "ssnop\n\t"
11106 + /* Disable interrupts */
11107 + /* MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~(ALLINTS | STO_IE)); */
11108 + "mfc0 $15, $12\n\t"
11109 + /* Just a Hack to not to use reg 'at' which was causing problems on 4704 A2 */
11110 + "li $14, -31746\n\t"
11111 + "and $15, $15, $14\n\t"
11112 + "mtc0 $15, $12\n\t"
11113 + "eret\n\t"
11114 + "nop\n\t"
11115 + "nop\n\t"
11116 + ".set\tmips0"
11117 + );
11118 +}
11119 +
11120 +/* The following MUST come right after handler() */
11121 +static void
11122 +BCMINITFN(afterhandler)(void)
11123 +{
11124 +}
11125 +
11126 +/*
11127 + * Set the MIPS, backplane and PCI clocks as closely as possible.
11128 + */
11129 +bool
11130 +BCMINITFN(sb_mips_setclock)(void *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock)
11131 +{
11132 + extifregs_t *eir = NULL;
11133 + chipcregs_t *cc = NULL;
11134 + mipsregs_t *mipsr = NULL;
11135 + volatile uint32 *clockcontrol_n, *clockcontrol_sb, *clockcontrol_pci, *clockcontrol_m2;
11136 + uint32 orig_n, orig_sb, orig_pci, orig_m2, orig_mips, orig_ratio_parm, new_ratio;
11137 + uint32 pll_type, sync_mode;
11138 + uint ic_size, ic_lsize;
11139 + uint idx, i;
11140 + typedef struct {
11141 + uint32 mipsclock;
11142 + uint16 n;
11143 + uint32 sb;
11144 + uint32 pci33;
11145 + uint32 pci25;
11146 + } n3m_table_t;
11147 + static n3m_table_t BCMINITDATA(type1_table)[] = {
11148 + { 96000000, 0x0303, 0x04020011, 0x11030011, 0x11050011 }, /* 96.000 32.000 24.000 */
11149 + { 100000000, 0x0009, 0x04020011, 0x11030011, 0x11050011 }, /* 100.000 33.333 25.000 */
11150 + { 104000000, 0x0802, 0x04020011, 0x11050009, 0x11090009 }, /* 104.000 31.200 24.960 */
11151 + { 108000000, 0x0403, 0x04020011, 0x11050009, 0x02000802 }, /* 108.000 32.400 24.923 */
11152 + { 112000000, 0x0205, 0x04020011, 0x11030021, 0x02000403 }, /* 112.000 32.000 24.889 */
11153 + { 115200000, 0x0303, 0x04020009, 0x11030011, 0x11050011 }, /* 115.200 32.000 24.000 */
11154 + { 120000000, 0x0011, 0x04020011, 0x11050011, 0x11090011 }, /* 120.000 30.000 24.000 */
11155 + { 124800000, 0x0802, 0x04020009, 0x11050009, 0x11090009 }, /* 124.800 31.200 24.960 */
11156 + { 128000000, 0x0305, 0x04020011, 0x11050011, 0x02000305 }, /* 128.000 32.000 24.000 */
11157 + { 132000000, 0x0603, 0x04020011, 0x11050011, 0x02000305 }, /* 132.000 33.000 24.750 */
11158 + { 136000000, 0x0c02, 0x04020011, 0x11090009, 0x02000603 }, /* 136.000 32.640 24.727 */
11159 + { 140000000, 0x0021, 0x04020011, 0x11050021, 0x02000c02 }, /* 140.000 30.000 24.706 */
11160 + { 144000000, 0x0405, 0x04020011, 0x01020202, 0x11090021 }, /* 144.000 30.857 24.686 */
11161 + { 150857142, 0x0605, 0x04020021, 0x02000305, 0x02000605 }, /* 150.857 33.000 24.000 */
11162 + { 152000000, 0x0e02, 0x04020011, 0x11050021, 0x02000e02 }, /* 152.000 32.571 24.000 */
11163 + { 156000000, 0x0802, 0x04020005, 0x11050009, 0x11090009 }, /* 156.000 31.200 24.960 */
11164 + { 160000000, 0x0309, 0x04020011, 0x11090011, 0x02000309 }, /* 160.000 32.000 24.000 */
11165 + { 163200000, 0x0c02, 0x04020009, 0x11090009, 0x02000603 }, /* 163.200 32.640 24.727 */
11166 + { 168000000, 0x0205, 0x04020005, 0x11030021, 0x02000403 }, /* 168.000 32.000 24.889 */
11167 + { 176000000, 0x0602, 0x04020003, 0x11050005, 0x02000602 }, /* 176.000 33.000 24.000 */
11168 + };
11169 + typedef struct {
11170 + uint32 mipsclock;
11171 + uint16 n;
11172 + uint32 m2; /* that is the clockcontrol_m2 */
11173 + } type3_table_t;
11174 + static type3_table_t type3_table[] = { /* for 5350, mips clock is always double sb clock */
11175 + { 150000000, 0x311, 0x4020005 },
11176 +// { 180000000, 0x, 0x }, /* later we may want this frequency */
11177 + { 200000000, 0x311, 0x4020003 },
11178 + };
11179 + typedef struct {
11180 + uint32 mipsclock;
11181 + uint32 sbclock;
11182 + uint16 n;
11183 + uint32 sb;
11184 + uint32 pci33;
11185 + uint32 m2;
11186 + uint32 m3;
11187 + uint32 ratio;
11188 + uint32 ratio_parm;
11189 + } n4m_table_t;
11190 +
11191 + static n4m_table_t BCMINITDATA(type2_table)[] = {
11192 + { 180000000, 80000000, 0x0403, 0x01010000, 0x01020300, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11193 + { 180000000, 90000000, 0x0403, 0x01000100, 0x01020300, 0x01000100, 0x05000100, 0x21, 0x0aaa0555 },
11194 + { 200000000, 100000000, 0x0303, 0x01000000, 0x01000600, 0x01000000, 0x05000000, 0x21, 0x0aaa0555 },
11195 + { 211200000, 105600000, 0x0902, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11196 + { 220800000, 110400000, 0x1500, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11197 + { 230400000, 115200000, 0x0604, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11198 + { 234000000, 104000000, 0x0b01, 0x01010000, 0x01010700, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11199 + { 240000000, 120000000, 0x0803, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11200 + { 252000000, 126000000, 0x0504, 0x01000100, 0x01020500, 0x01000100, 0x05000100, 0x21, 0x0aaa0555 },
11201 + { 264000000, 132000000, 0x0903, 0x01000200, 0x01020700, 0x01000200, 0x05000200, 0x21, 0x0aaa0555 },
11202 + { 270000000, 120000000, 0x0703, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11203 + { 276000000, 122666666, 0x1500, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11204 + { 280000000, 140000000, 0x0503, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 0x21, 0x0aaa0555 },
11205 + { 288000000, 128000000, 0x0604, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11206 + { 288000000, 144000000, 0x0404, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 0x21, 0x0aaa0555 },
11207 + { 300000000, 133333333, 0x0803, 0x01010000, 0x01020600, 0x01020600, 0x05000100, 0x94, 0x012a00a9 },
11208 + { 300000000, 150000000, 0x0803, 0x01000100, 0x01020600, 0x01000100, 0x05000100, 0x21, 0x0aaa0555 }
11209 + };
11210 +
11211 + static n4m_table_t BCMINITDATA(type4_table)[] = {
11212 + { 192000000, 96000000, 0x0702, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 0x21, 0x0aaa0555 },
11213 + { 200000000, 100000000, 0x0009, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 0x21, 0x0aaa0555 },
11214 + { 216000000, 108000000, 0x0111, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 0x21, 0x0aaa0555 },
11215 + { 228000000, 101333333, 0x0e02, 0x11030003, 0x11210005, 0x11030305, 0x04000005, 0x94, 0x012a00a9 },
11216 + { 228000000, 114000000, 0x0e02, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 0x21, 0x0aaa0555 },
11217 + { 240000000, 120000000, 0x0109, 0x11030002, 0x01050203, 0x11030002, 0x04000003, 0x21, 0x0aaa0555 },
11218 + { 252000000, 126000000, 0x0203, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 0x21, 0x0aaa0555 },
11219 + { 264000000, 132000000, 0x0602, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 0x21, 0x0aaa0555 },
11220 + { 272000000, 116571428, 0x0c02, 0x04000021, 0x02000909, 0x02000221, 0x04000003, 0x73, 0x254a14a9 },
11221 + { 280000000, 120000000, 0x0209, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 0x73, 0x254a14a9 },
11222 + { 288000000, 123428571, 0x0111, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 0x73, 0x254a14a9 },
11223 + { 300000000, 120000000, 0x0009, 0x04000009, 0x01030203, 0x02000902, 0x04000002, 0x52, 0x02520129 }
11224 + };
11225 + ulong start, end, dst;
11226 + bool ret = FALSE;
11227 +
11228 + /* get index of the current core */
11229 + idx = sb_coreidx(sbh);
11230 + clockcontrol_m2 = NULL;
11231 +
11232 + /* switch to extif or chipc core */
11233 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
11234 + pll_type = PLL_TYPE1;
11235 + clockcontrol_n = &eir->clockcontrol_n;
11236 + clockcontrol_sb = &eir->clockcontrol_sb;
11237 + clockcontrol_pci = &eir->clockcontrol_pci;
11238 + clockcontrol_m2 = &cc->clockcontrol_m2;
11239 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
11240 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
11241 + if (pll_type == PLL_TYPE6) {
11242 + clockcontrol_n = NULL;
11243 + clockcontrol_sb = NULL;
11244 + clockcontrol_pci = NULL;
11245 + } else {
11246 + clockcontrol_n = &cc->clockcontrol_n;
11247 + clockcontrol_sb = &cc->clockcontrol_sb;
11248 + clockcontrol_pci = &cc->clockcontrol_pci;
11249 + clockcontrol_m2 = &cc->clockcontrol_m2;
11250 + }
11251 + } else
11252 + goto done;
11253 +
11254 + if (pll_type == PLL_TYPE6) {
11255 + /* Silence compilers */
11256 + orig_n = orig_sb = orig_pci = 0;
11257 + } else {
11258 + /* Store the current clock register values */
11259 + orig_n = R_REG(clockcontrol_n);
11260 + orig_sb = R_REG(clockcontrol_sb);
11261 + orig_pci = R_REG(clockcontrol_pci);
11262 + }
11263 +
11264 + if (pll_type == PLL_TYPE1) {
11265 + /* Keep the current PCI clock if not specified */
11266 + if (pciclock == 0) {
11267 + pciclock = sb_clock_rate(pll_type, R_REG(clockcontrol_n), R_REG(clockcontrol_pci));
11268 + pciclock = (pciclock <= 25000000) ? 25000000 : 33000000;
11269 + }
11270 +
11271 + /* Search for the closest MIPS clock less than or equal to a preferred value */
11272 + for (i = 0; i < ARRAYSIZE(BCMINIT(type1_table)); i++) {
11273 + ASSERT(BCMINIT(type1_table)[i].mipsclock ==
11274 + sb_clock_rate(pll_type, BCMINIT(type1_table)[i].n, BCMINIT(type1_table)[i].sb));
11275 + if (BCMINIT(type1_table)[i].mipsclock > mipsclock)
11276 + break;
11277 + }
11278 + if (i == 0) {
11279 + ret = FALSE;
11280 + goto done;
11281 + } else {
11282 + ret = TRUE;
11283 + i--;
11284 + }
11285 + ASSERT(BCMINIT(type1_table)[i].mipsclock <= mipsclock);
11286 +
11287 + /* No PLL change */
11288 + if ((orig_n == BCMINIT(type1_table)[i].n) &&
11289 + (orig_sb == BCMINIT(type1_table)[i].sb) &&
11290 + (orig_pci == BCMINIT(type1_table)[i].pci33))
11291 + goto done;
11292 +
11293 + /* Set the PLL controls */
11294 + W_REG(clockcontrol_n, BCMINIT(type1_table)[i].n);
11295 + W_REG(clockcontrol_sb, BCMINIT(type1_table)[i].sb);
11296 + if (pciclock == 25000000)
11297 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci25);
11298 + else
11299 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci33);
11300 +
11301 + /* Reset */
11302 + sb_watchdog(sbh, 1);
11303 +
11304 + while (1);
11305 + } else if ((pll_type == PLL_TYPE3) &&
11306 + (BCMINIT(sb_chip)(sbh) != BCM5365_DEVICE_ID)) {
11307 + /* 5350 */
11308 + /* Search for the closest MIPS clock less than or equal to a preferred value */
11309 +
11310 + for (i = 0; i < ARRAYSIZE(type3_table); i++) {
11311 + if (type3_table[i].mipsclock > mipsclock)
11312 + break;
11313 + }
11314 + if (i == 0) {
11315 + ret = FALSE;
11316 + goto done;
11317 + } else {
11318 + ret = TRUE;
11319 + i--;
11320 + }
11321 + ASSERT(type3_table[i].mipsclock <= mipsclock);
11322 +
11323 + /* No PLL change */
11324 + orig_m2 = R_REG(&cc->clockcontrol_m2);
11325 + if ((orig_n == type3_table[i].n) &&
11326 + (orig_m2 == type3_table[i].m2)) {
11327 + goto done;
11328 + }
11329 +
11330 + /* Set the PLL controls */
11331 + W_REG(clockcontrol_n, type3_table[i].n);
11332 + W_REG(clockcontrol_m2, type3_table[i].m2);
11333 +
11334 + /* Reset */
11335 + sb_watchdog(sbh, 1);
11336 + while (1);
11337 + } else if ((pll_type == PLL_TYPE2) ||
11338 + (pll_type == PLL_TYPE4) ||
11339 + (pll_type == PLL_TYPE6)) {
11340 + n4m_table_t *table = NULL;
11341 + uint tabsz = 0;
11342 +
11343 + ASSERT(cc);
11344 +
11345 + orig_mips = R_REG(&cc->clockcontrol_mips);
11346 +
11347 + if (pll_type == PLL_TYPE6) {
11348 + uint32 new_mips = 0;
11349 +
11350 + ret = TRUE;
11351 + if (mipsclock <= SB2MIPS_T6(CC_T6_M1))
11352 + new_mips = CC_T6_MMASK;
11353 +
11354 + if (orig_mips == new_mips)
11355 + goto done;
11356 +
11357 + W_REG(&cc->clockcontrol_mips, new_mips);
11358 + goto end_fill;
11359 + }
11360 +
11361 + table = (pll_type == PLL_TYPE2) ? BCMINIT(type2_table) : BCMINIT(type4_table);
11362 + tabsz = (pll_type == PLL_TYPE2) ? ARRAYSIZE(BCMINIT(type2_table)) :
11363 + ARRAYSIZE(BCMINIT(type4_table));
11364 +
11365 + /* Store the current clock register values */
11366 + orig_m2 = R_REG(&cc->clockcontrol_m2);
11367 + orig_ratio_parm = 0;
11368 +
11369 + /* Look up current ratio */
11370 + for (i = 0; i < tabsz; i++) {
11371 + if ((orig_n == table[i].n) &&
11372 + (orig_sb == table[i].sb) &&
11373 + (orig_pci == table[i].pci33) &&
11374 + (orig_m2 == table[i].m2) &&
11375 + (orig_mips == table[i].m3)) {
11376 + orig_ratio_parm = table[i].ratio_parm;
11377 + break;
11378 + }
11379 + }
11380 +
11381 + /* Search for the closest MIPS clock greater or equal to a preferred value */
11382 + for (i = 0; i < tabsz; i++) {
11383 + ASSERT(table[i].mipsclock ==
11384 + sb_clock_rate(pll_type, table[i].n, table[i].m3));
11385 + if ((mipsclock <= table[i].mipsclock) &&
11386 + ((sbclock == 0) || (sbclock <= table[i].sbclock)))
11387 + break;
11388 + }
11389 + if (i == tabsz) {
11390 + ret = FALSE;
11391 + goto done;
11392 + } else {
11393 + ret = TRUE;
11394 + }
11395 +
11396 + /* No PLL change */
11397 + if ((orig_n == table[i].n) &&
11398 + (orig_sb == table[i].sb) &&
11399 + (orig_pci == table[i].pci33) &&
11400 + (orig_m2 == table[i].m2) &&
11401 + (orig_mips == table[i].m3))
11402 + goto done;
11403 +
11404 + /* Set the PLL controls */
11405 + W_REG(clockcontrol_n, table[i].n);
11406 + W_REG(clockcontrol_sb, table[i].sb);
11407 + W_REG(clockcontrol_pci, table[i].pci33);
11408 + W_REG(&cc->clockcontrol_m2, table[i].m2);
11409 + W_REG(&cc->clockcontrol_mips, table[i].m3);
11410 +
11411 + /* No ratio change */
11412 + if (orig_ratio_parm == table[i].ratio_parm)
11413 + goto end_fill;
11414 +
11415 + new_ratio = table[i].ratio_parm;
11416 +
11417 + icache_probe(MFC0(C0_CONFIG, 1), &ic_size, &ic_lsize);
11418 +
11419 + /* Preload the code into the cache */
11420 + start = ((ulong) &&start_fill) & ~(ic_lsize - 1);
11421 + end = ((ulong) &&end_fill + (ic_lsize - 1)) & ~(ic_lsize - 1);
11422 + while (start < end) {
11423 + cache_unroll(start, Fill_I);
11424 + start += ic_lsize;
11425 + }
11426 +
11427 + /* Copy the handler */
11428 + start = (ulong) &BCMINIT(handler);
11429 + end = (ulong) &BCMINIT(afterhandler);
11430 + dst = KSEG1ADDR(0x180);
11431 + for (i = 0; i < (end - start); i += 4)
11432 + *((ulong *)(dst + i)) = *((ulong *)(start + i));
11433 +
11434 + /* Preload handler into the cache one line at a time */
11435 + for (i = 0; i < (end - start); i += 4)
11436 + cache_unroll(dst + i, Fill_I);
11437 +
11438 + /* Clear BEV bit */
11439 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~ST0_BEV);
11440 +
11441 + /* Enable interrupts */
11442 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) | (ALLINTS | ST0_IE));
11443 +
11444 + /* Enable MIPS timer interrupt */
11445 + if (!(mipsr = sb_setcore(sbh, SB_MIPS, 0)) &&
11446 + !(mipsr = sb_setcore(sbh, SB_MIPS33, 0)))
11447 + ASSERT(mipsr);
11448 + W_REG(&mipsr->intmask, 1);
11449 +
11450 + start_fill:
11451 + /* step 1, set clock ratios */
11452 + MTC0(C0_BROADCOM, 3, new_ratio);
11453 + MTC0(C0_BROADCOM, 1, 8);
11454 +
11455 + /* step 2: program timer intr */
11456 + W_REG(&mipsr->timer, 100);
11457 + (void) R_REG(&mipsr->timer);
11458 +
11459 + /* step 3, switch to async */
11460 + sync_mode = MFC0(C0_BROADCOM, 4);
11461 + MTC0(C0_BROADCOM, 4, 1 << 22);
11462 +
11463 + /* step 4, set cfg active */
11464 + MTC0(C0_BROADCOM, 2, 0x9);
11465 +
11466 +
11467 + /* steps 5 & 6 */
11468 + __asm__ __volatile__ (
11469 + ".set\tmips3\n\t"
11470 + "wait\n\t"
11471 + ".set\tmips0"
11472 + );
11473 +
11474 + /* step 7, clear cfg_active */
11475 + MTC0(C0_BROADCOM, 2, 0);
11476 +
11477 + /* Additional Step: set back to orig sync mode */
11478 + MTC0(C0_BROADCOM, 4, sync_mode);
11479 +
11480 + /* step 8, fake soft reset */
11481 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | 4);
11482 +
11483 + end_fill:
11484 + /* step 9 set watchdog timer */
11485 + sb_watchdog(sbh, 20);
11486 + (void) R_REG(&cc->chipid);
11487 +
11488 + /* step 11 */
11489 + __asm__ __volatile__ (
11490 + ".set\tmips3\n\t"
11491 + "sync\n\t"
11492 + "wait\n\t"
11493 + ".set\tmips0"
11494 + );
11495 + while (1);
11496 + }
11497 +
11498 +done:
11499 + /* switch back to previous core */
11500 + sb_setcoreidx(sbh, idx);
11501 +
11502 + return ret;
11503 +}
11504 +
11505 +
11506 +/* returns the ncdl value to be programmed into sdram_ncdl for calibration */
11507 +uint32
11508 +BCMINITFN(sb_memc_get_ncdl)(void *sbh)
11509 +{
11510 + sbmemcregs_t *memc;
11511 + uint32 ret = 0;
11512 + uint32 config, rd, wr, misc, dqsg, cd, sm, sd;
11513 + uint idx, rev;
11514 +
11515 + idx = sb_coreidx(sbh);
11516 +
11517 + memc = (sbmemcregs_t *)sb_setcore(sbh, SB_MEMC, 0);
11518 + if (memc == 0)
11519 + goto out;
11520 +
11521 + rev = sb_corerev(sbh);
11522 +
11523 + config = R_REG(&memc->config);
11524 + wr = R_REG(&memc->wrncdlcor);
11525 + rd = R_REG(&memc->rdncdlcor);
11526 + misc = R_REG(&memc->miscdlyctl);
11527 + dqsg = R_REG(&memc->dqsgatencdl);
11528 +
11529 + rd &= MEMC_RDNCDLCOR_RD_MASK;
11530 + wr &= MEMC_WRNCDLCOR_WR_MASK;
11531 + dqsg &= MEMC_DQSGATENCDL_G_MASK;
11532 +
11533 + if (config & MEMC_CONFIG_DDR) {
11534 + ret = (wr << 16) | (rd << 8) | dqsg;
11535 + } else {
11536 + if ( (rev > 0) || (sb_chip(sbh) == BCM5365_DEVICE_ID))
11537 +
11538 + cd = rd;
11539 + else
11540 + cd = (rd == MEMC_CD_THRESHOLD) ? rd : (wr + MEMC_CD_THRESHOLD);
11541 + sm = (misc & MEMC_MISC_SM_MASK) >> MEMC_MISC_SM_SHIFT;
11542 + sd = (misc & MEMC_MISC_SD_MASK) >> MEMC_MISC_SD_SHIFT;
11543 + ret = (sm << 16) | (sd << 8) | cd;
11544 + }
11545 +
11546 +out:
11547 + /* switch back to previous core */
11548 + sb_setcoreidx(sbh, idx);
11549 +
11550 + return ret;
11551 +}
11552 +
11553 +/* returns the PFC values to be used based on the chip ID*/
11554 +
11555 +uint32
11556 +BCMINITFN(sb_mips_get_pfc)(void *sbh)
11557 +{
11558 + if (BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID)
11559 + return 0x11;
11560 + else
11561 + return 0x15;
11562 +}
11563 diff -urN linux-2.4.30/arch/mips/bcm947xx/sbpci.c linux-2.4.30.dev/arch/mips/bcm947xx/sbpci.c
11564 --- linux-2.4.30/arch/mips/bcm947xx/sbpci.c 1970-01-01 01:00:00.000000000 +0100
11565 +++ linux-2.4.30.dev/arch/mips/bcm947xx/sbpci.c 2005-08-22 01:35:16.403578544 +0200
11566 @@ -0,0 +1,588 @@
11567 +/*
11568 + * Low-Level PCI and SB support for BCM47xx
11569 + *
11570 + * Copyright 2005, Broadcom Corporation
11571 + * All Rights Reserved.
11572 + *
11573 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
11574 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11575 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11576 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11577 + *
11578 + * $Id: sbpci.c,v 1.7 2005/03/07 08:35:32 kanki Exp $
11579 + */
11580 +
11581 +#include <typedefs.h>
11582 +#include <pcicfg.h>
11583 +#include <bcmdevs.h>
11584 +#include <sbconfig.h>
11585 +#include <sbpci.h>
11586 +#include <osl.h>
11587 +#include <bcmendian.h>
11588 +#include <bcmutils.h>
11589 +#include <sbutils.h>
11590 +#include <bcmnvram.h>
11591 +#include <hndmips.h>
11592 +
11593 +/* Can free sbpci_init() memory after boot */
11594 +#ifndef linux
11595 +#define __init
11596 +#endif
11597 +
11598 +/* Emulated configuration space */
11599 +static pci_config_regs sb_config_regs[SB_MAXCORES];
11600 +
11601 +/* Banned cores */
11602 +static uint16 pci_ban[32] = { 0 };
11603 +static uint pci_banned = 0;
11604 +
11605 +/* CardBus mode */
11606 +static bool cardbus = FALSE;
11607 +
11608 +/* Disable PCI host core */
11609 +static bool pci_disabled = FALSE;
11610 +
11611 +/*
11612 + * Functions for accessing external PCI configuration space
11613 + */
11614 +
11615 +/* Assume one-hot slot wiring */
11616 +#define PCI_SLOT_MAX 16
11617 +
11618 +static uint32
11619 +config_cmd(void *sbh, uint bus, uint dev, uint func, uint off)
11620 +{
11621 + uint coreidx;
11622 + sbpciregs_t *regs;
11623 + uint32 addr = 0;
11624 +
11625 + /* CardBusMode supports only one device */
11626 + if (cardbus && dev > 1)
11627 + return 0;
11628 +
11629 + coreidx = sb_coreidx(sbh);
11630 + regs = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
11631 +
11632 + /* Type 0 transaction */
11633 + if (bus == 1) {
11634 + /* Skip unwired slots */
11635 + if (dev < PCI_SLOT_MAX) {
11636 + /* Slide the PCI window to the appropriate slot */
11637 + W_REG(&regs->sbtopci1, SBTOPCI_CFG0 | ((1 << (dev + 16)) & SBTOPCI1_MASK));
11638 + addr = SB_PCI_CFG | ((1 << (dev + 16)) & ~SBTOPCI1_MASK) |
11639 + (func << 8) | (off & ~3);
11640 + }
11641 + }
11642 +
11643 + /* Type 1 transaction */
11644 + else {
11645 + W_REG(&regs->sbtopci1, SBTOPCI_CFG1);
11646 + addr = SB_PCI_CFG | (bus << 16) | (dev << 11) | (func << 8) | (off & ~3);
11647 + }
11648 +
11649 + sb_setcoreidx(sbh, coreidx);
11650 +
11651 + return addr;
11652 +}
11653 +
11654 +static int
11655 +extpci_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11656 +{
11657 + uint32 addr, *reg = NULL, val;
11658 + int ret = 0;
11659 +
11660 + if (pci_disabled ||
11661 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
11662 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
11663 + BUSPROBE(val, reg))
11664 + val = 0xffffffff;
11665 +
11666 + val >>= 8 * (off & 3);
11667 + if (len == 4)
11668 + *((uint32 *) buf) = val;
11669 + else if (len == 2)
11670 + *((uint16 *) buf) = (uint16) val;
11671 + else if (len == 1)
11672 + *((uint8 *) buf) = (uint8) val;
11673 + else
11674 + ret = -1;
11675 +
11676 + if (reg)
11677 + REG_UNMAP(reg);
11678 +
11679 + return ret;
11680 +}
11681 +
11682 +static int
11683 +extpci_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11684 +{
11685 + uint32 addr, *reg = NULL, val;
11686 + int ret = 0;
11687 +
11688 + if (pci_disabled ||
11689 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
11690 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
11691 + BUSPROBE(val, reg))
11692 + goto done;
11693 +
11694 + if (len == 4)
11695 + val = *((uint32 *) buf);
11696 + else if (len == 2) {
11697 + val &= ~(0xffff << (8 * (off & 3)));
11698 + val |= *((uint16 *) buf) << (8 * (off & 3));
11699 + } else if (len == 1) {
11700 + val &= ~(0xff << (8 * (off & 3)));
11701 + val |= *((uint8 *) buf) << (8 * (off & 3));
11702 + } else
11703 + ret = -1;
11704 +
11705 + W_REG(reg, val);
11706 +
11707 + done:
11708 + if (reg)
11709 + REG_UNMAP(reg);
11710 +
11711 + return ret;
11712 +}
11713 +
11714 +/*
11715 + * Functions for accessing translated SB configuration space
11716 + */
11717 +
11718 +static int
11719 +sb_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11720 +{
11721 + pci_config_regs *cfg;
11722 +
11723 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
11724 + return -1;
11725 + cfg = &sb_config_regs[dev];
11726 +
11727 + ASSERT(ISALIGNED(off, len));
11728 + ASSERT(ISALIGNED((uintptr)buf, len));
11729 +
11730 + if (len == 4)
11731 + *((uint32 *) buf) = ltoh32(*((uint32 *)((ulong) cfg + off)));
11732 + else if (len == 2)
11733 + *((uint16 *) buf) = ltoh16(*((uint16 *)((ulong) cfg + off)));
11734 + else if (len == 1)
11735 + *((uint8 *) buf) = *((uint8 *)((ulong) cfg + off));
11736 + else
11737 + return -1;
11738 +
11739 + return 0;
11740 +}
11741 +
11742 +static int
11743 +sb_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11744 +{
11745 + uint coreidx, n;
11746 + void *regs;
11747 + sbconfig_t *sb;
11748 + pci_config_regs *cfg;
11749 +
11750 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
11751 + return -1;
11752 + cfg = &sb_config_regs[dev];
11753 +
11754 + ASSERT(ISALIGNED(off, len));
11755 + ASSERT(ISALIGNED((uintptr)buf, len));
11756 +
11757 + /* Emulate BAR sizing */
11758 + if (off >= OFFSETOF(pci_config_regs, base[0]) && off <= OFFSETOF(pci_config_regs, base[3]) &&
11759 + len == 4 && *((uint32 *) buf) == ~0) {
11760 + coreidx = sb_coreidx(sbh);
11761 + if ((regs = sb_setcoreidx(sbh, dev))) {
11762 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
11763 + /* Highest numbered address match register */
11764 + n = (R_REG(&sb->sbidlow) & SBIDL_AR_MASK) >> SBIDL_AR_SHIFT;
11765 + if (off == OFFSETOF(pci_config_regs, base[0]))
11766 + cfg->base[0] = ~(sb_size(R_REG(&sb->sbadmatch0)) - 1);
11767 + else if (off == OFFSETOF(pci_config_regs, base[1]) && n >= 1)
11768 + cfg->base[1] = ~(sb_size(R_REG(&sb->sbadmatch1)) - 1);
11769 + else if (off == OFFSETOF(pci_config_regs, base[2]) && n >= 2)
11770 + cfg->base[2] = ~(sb_size(R_REG(&sb->sbadmatch2)) - 1);
11771 + else if (off == OFFSETOF(pci_config_regs, base[3]) && n >= 3)
11772 + cfg->base[3] = ~(sb_size(R_REG(&sb->sbadmatch3)) - 1);
11773 + }
11774 + sb_setcoreidx(sbh, coreidx);
11775 + return 0;
11776 + }
11777 +
11778 + if (len == 4)
11779 + *((uint32 *)((ulong) cfg + off)) = htol32(*((uint32 *) buf));
11780 + else if (len == 2)
11781 + *((uint16 *)((ulong) cfg + off)) = htol16(*((uint16 *) buf));
11782 + else if (len == 1)
11783 + *((uint8 *)((ulong) cfg + off)) = *((uint8 *) buf);
11784 + else
11785 + return -1;
11786 +
11787 + return 0;
11788 +}
11789 +
11790 +int
11791 +sbpci_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11792 +{
11793 + if (bus == 0)
11794 + return sb_read_config(sbh, bus, dev, func, off, buf, len);
11795 + else
11796 + return extpci_read_config(sbh, bus, dev, func, off, buf, len);
11797 +}
11798 +
11799 +int
11800 +sbpci_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
11801 +{
11802 + if (bus == 0)
11803 + return sb_write_config(sbh, bus, dev, func, off, buf, len);
11804 + else
11805 + return extpci_write_config(sbh, bus, dev, func, off, buf, len);
11806 +}
11807 +
11808 +void
11809 +sbpci_ban(uint16 core)
11810 +{
11811 + if (pci_banned < ARRAYSIZE(pci_ban))
11812 + pci_ban[pci_banned++] = core;
11813 +}
11814 +
11815 +static int
11816 +sbpci_init_pci(void *sbh)
11817 +{
11818 + uint chip, chiprev, chippkg, host;
11819 + uint32 boardflags;
11820 + sbpciregs_t *pci;
11821 + sbconfig_t *sb;
11822 + int CT4712_WR;
11823 + uint32 val;
11824 +
11825 + chip = sb_chip(sbh);
11826 + chiprev = sb_chiprev(sbh);
11827 + chippkg = sb_chippkg(sbh);
11828 +
11829 + if (!(pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0))) {
11830 + printf("PCI: no core\n");
11831 + pci_disabled = TRUE;
11832 + return -1;
11833 + }
11834 + sb_core_reset(sbh, 0);
11835 +
11836 + boardflags = (uint32) getintvar(NULL, "boardflags");
11837 +
11838 + if ((chip == BCM4310_DEVICE_ID) && (chiprev == 0))
11839 + pci_disabled = TRUE;
11840 +
11841 + /*
11842 + * The 200-pin BCM4712 package does not bond out PCI. Even when
11843 + * PCI is bonded out, some boards may leave the pins
11844 + * floating.
11845 + */
11846 + if (((chip == BCM4712_DEVICE_ID) &&
11847 + ((chippkg == BCM4712SMALL_PKG_ID) ||
11848 + (chippkg == BCM4712MID_PKG_ID))) ||
11849 + (boardflags & BFL_NOPCI))
11850 + pci_disabled = TRUE;
11851 +
11852 + /*
11853 + * If the PCI core should not be touched (disabled, not bonded
11854 + * out, or pins floating), do not even attempt to access core
11855 + * registers. Otherwise, try to determine if it is in host
11856 + * mode.
11857 + */
11858 + if (pci_disabled)
11859 + host = 0;
11860 + else
11861 + host = !BUSPROBE(val, &pci->control);
11862 +
11863 + if (!host) {
11864 + /* Disable PCI interrupts in client mode */
11865 + sb = (sbconfig_t *)((ulong) pci + SBCONFIGOFF);
11866 + W_REG(&sb->sbintvec, 0);
11867 +
11868 + /* Disable the PCI bridge in client mode */
11869 + sbpci_ban(SB_PCI);
11870 + printf("PCI: Disabled\n");
11871 + } else {
11872 + /* Reset the external PCI bus and enable the clock */
11873 + W_REG(&pci->control, 0x5); /* enable the tristate drivers */
11874 + W_REG(&pci->control, 0xd); /* enable the PCI clock */
11875 + OSL_DELAY(150); /* delay > 100 us */
11876 + W_REG(&pci->control, 0xf); /* deassert PCI reset */
11877 + W_REG(&pci->arbcontrol, PCI_INT_ARB); /* use internal arbiter */
11878 + OSL_DELAY(1); /* delay 1 us */
11879 +
11880 + /* Enable CardBusMode */
11881 + cardbus = nvram_match("cardbus", "1");
11882 + if (cardbus) {
11883 + printf("PCI: Enabling CardBus\n");
11884 + /* GPIO 1 resets the CardBus device on bcm94710ap */
11885 + sb_gpioout(sbh, 1, 1);
11886 + sb_gpioouten(sbh, 1, 1);
11887 + W_REG(&pci->sprom[0], R_REG(&pci->sprom[0]) | 0x400);
11888 + }
11889 +
11890 + /* 64 MB I/O access window */
11891 + W_REG(&pci->sbtopci0, SBTOPCI_IO);
11892 + /* 64 MB configuration access window */
11893 + W_REG(&pci->sbtopci1, SBTOPCI_CFG0);
11894 + /* 1 GB memory access window */
11895 + W_REG(&pci->sbtopci2, SBTOPCI_MEM | SB_PCI_DMA);
11896 +
11897 + /* Enable PCI bridge BAR0 prefetch and burst */
11898 + val = 6;
11899 + sbpci_write_config(sbh, 1, 0, 0, PCI_CFG_CMD, &val, sizeof(val));
11900 +
11901 + /* Enable PCI interrupts */
11902 + W_REG(&pci->intmask, PCI_INTA);
11903 + }
11904 +
11905 + return 0;
11906 +}
11907 +
11908 +static int
11909 +sbpci_init_cores(void *sbh)
11910 +{
11911 + uint chip, chiprev, chippkg, coreidx, i;
11912 + sbconfig_t *sb;
11913 + pci_config_regs *cfg;
11914 + void *regs;
11915 + char varname[8];
11916 + uint wlidx = 0;
11917 + uint16 vendor, core;
11918 + uint8 class, subclass, progif;
11919 + uint32 val;
11920 + uint32 sbips_int_mask[] = { 0, SBIPS_INT1_MASK, SBIPS_INT2_MASK, SBIPS_INT3_MASK, SBIPS_INT4_MASK };
11921 + uint32 sbips_int_shift[] = { 0, 0, SBIPS_INT2_SHIFT, SBIPS_INT3_SHIFT, SBIPS_INT4_SHIFT };
11922 +
11923 + chip = sb_chip(sbh);
11924 + chiprev = sb_chiprev(sbh);
11925 + chippkg = sb_chippkg(sbh);
11926 + coreidx = sb_coreidx(sbh);
11927 +
11928 + /* Scan the SB bus */
11929 + bzero(sb_config_regs, sizeof(sb_config_regs));
11930 + for (cfg = sb_config_regs; cfg < &sb_config_regs[SB_MAXCORES]; cfg++) {
11931 + cfg->vendor = 0xffff;
11932 + if (!(regs = sb_setcoreidx(sbh, cfg - sb_config_regs)))
11933 + continue;
11934 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
11935 +
11936 + /* Read ID register and parse vendor and core */
11937 + val = R_REG(&sb->sbidhigh);
11938 + vendor = (val & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT;
11939 + core = (val & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;
11940 + progif = 0;
11941 +
11942 + /* Check if this core is banned */
11943 + for (i = 0; i < pci_banned; i++)
11944 + if (core == pci_ban[i])
11945 + break;
11946 + if (i < pci_banned)
11947 + continue;
11948 +
11949 + /* Known vendor translations */
11950 + switch (vendor) {
11951 + case SB_VEND_BCM:
11952 + vendor = VENDOR_BROADCOM;
11953 + break;
11954 + }
11955 +
11956 + /* Determine class based on known core codes */
11957 + switch (core) {
11958 + case SB_ILINE20:
11959 + class = PCI_CLASS_NET;
11960 + subclass = PCI_NET_ETHER;
11961 + core = BCM47XX_ILINE_ID;
11962 + break;
11963 + case SB_ILINE100:
11964 + class = PCI_CLASS_NET;
11965 + subclass = PCI_NET_ETHER;
11966 + core = BCM4610_ILINE_ID;
11967 + break;
11968 + case SB_ENET:
11969 + class = PCI_CLASS_NET;
11970 + subclass = PCI_NET_ETHER;
11971 + core = BCM47XX_ENET_ID;
11972 + break;
11973 + case SB_SDRAM:
11974 + case SB_MEMC:
11975 + class = PCI_CLASS_MEMORY;
11976 + subclass = PCI_MEMORY_RAM;
11977 + break;
11978 + case SB_PCI:
11979 + class = PCI_CLASS_BRIDGE;
11980 + subclass = PCI_BRIDGE_PCI;
11981 + break;
11982 + case SB_MIPS:
11983 + case SB_MIPS33:
11984 + class = PCI_CLASS_CPU;
11985 + subclass = PCI_CPU_MIPS;
11986 + break;
11987 + case SB_CODEC:
11988 + class = PCI_CLASS_COMM;
11989 + subclass = PCI_COMM_MODEM;
11990 + core = BCM47XX_V90_ID;
11991 + break;
11992 + case SB_USB:
11993 + class = PCI_CLASS_SERIAL;
11994 + subclass = PCI_SERIAL_USB;
11995 + progif = 0x10; /* OHCI */
11996 + core = BCM47XX_USB_ID;
11997 + break;
11998 + case SB_USB11H:
11999 + class = PCI_CLASS_SERIAL;
12000 + subclass = PCI_SERIAL_USB;
12001 + progif = 0x10; /* OHCI */
12002 + core = BCM47XX_USBH_ID;
12003 + break;
12004 + case SB_USB11D:
12005 + class = PCI_CLASS_SERIAL;
12006 + subclass = PCI_SERIAL_USB;
12007 + core = BCM47XX_USBD_ID;
12008 + break;
12009 + case SB_IPSEC:
12010 + class = PCI_CLASS_CRYPT;
12011 + subclass = PCI_CRYPT_NETWORK;
12012 + core = BCM47XX_IPSEC_ID;
12013 + break;
12014 + case SB_ROBO:
12015 + class = PCI_CLASS_NET;
12016 + subclass = PCI_NET_OTHER;
12017 + core = BCM47XX_ROBO_ID;
12018 + break;
12019 + case SB_EXTIF:
12020 + case SB_CC:
12021 + class = PCI_CLASS_MEMORY;
12022 + subclass = PCI_MEMORY_FLASH;
12023 + break;
12024 + case SB_D11:
12025 + class = PCI_CLASS_NET;
12026 + subclass = PCI_NET_OTHER;
12027 + /* Let an nvram variable override this */
12028 + sprintf(varname, "wl%did", wlidx);
12029 + wlidx++;
12030 + if ((core = getintvar(NULL, varname)) == 0) {
12031 + if (chip == BCM4712_DEVICE_ID) {
12032 + if (chippkg == BCM4712SMALL_PKG_ID)
12033 + core = BCM4306_D11G_ID;
12034 + else
12035 + core = BCM4306_D11DUAL_ID;
12036 + } else {
12037 + /* 4310 */
12038 + core = BCM4310_D11B_ID;
12039 + }
12040 + }
12041 + break;
12042 +
12043 + default:
12044 + class = subclass = progif = 0xff;
12045 + break;
12046 + }
12047 +
12048 + /* Supported translations */
12049 + cfg->vendor = htol16(vendor);
12050 + cfg->device = htol16(core);
12051 + cfg->rev_id = chiprev;
12052 + cfg->prog_if = progif;
12053 + cfg->sub_class = subclass;
12054 + cfg->base_class = class;
12055 + cfg->base[0] = htol32(sb_base(R_REG(&sb->sbadmatch0)));
12056 + cfg->base[1] = htol32(sb_base(R_REG(&sb->sbadmatch1)));
12057 + cfg->base[2] = htol32(sb_base(R_REG(&sb->sbadmatch2)));
12058 + cfg->base[3] = htol32(sb_base(R_REG(&sb->sbadmatch3)));
12059 + cfg->base[4] = 0;
12060 + cfg->base[5] = 0;
12061 + if (class == PCI_CLASS_BRIDGE && subclass == PCI_BRIDGE_PCI)
12062 + cfg->header_type = PCI_HEADER_BRIDGE;
12063 + else
12064 + cfg->header_type = PCI_HEADER_NORMAL;
12065 + /* Save core interrupt flag */
12066 + cfg->int_pin = R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK;
12067 + /* Default to MIPS shared interrupt 0 */
12068 + cfg->int_line = 0;
12069 + /* MIPS sbipsflag maps core interrupt flags to interrupts 1 through 4 */
12070 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
12071 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
12072 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12073 + val = R_REG(&sb->sbipsflag);
12074 + for (cfg->int_line = 1; cfg->int_line <= 4; cfg->int_line++) {
12075 + if (((val & sbips_int_mask[cfg->int_line]) >> sbips_int_shift[cfg->int_line]) == cfg->int_pin)
12076 + break;
12077 + }
12078 + if (cfg->int_line > 4)
12079 + cfg->int_line = 0;
12080 + }
12081 + /* Emulated core */
12082 + *((uint32 *) &cfg->sprom_control) = 0xffffffff;
12083 + }
12084 +
12085 + sb_setcoreidx(sbh, coreidx);
12086 + return 0;
12087 +}
12088 +
12089 +int __init
12090 +sbpci_init(void *sbh)
12091 +{
12092 + sbpci_init_pci(sbh);
12093 + sbpci_init_cores(sbh);
12094 + return 0;
12095 +}
12096 +
12097 +void
12098 +sbpci_check(void *sbh)
12099 +{
12100 + uint coreidx;
12101 + sbpciregs_t *pci;
12102 + uint32 sbtopci1;
12103 + uint32 buf[64], *ptr, i;
12104 + ulong pa;
12105 + volatile uint j;
12106 +
12107 + coreidx = sb_coreidx(sbh);
12108 + pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
12109 +
12110 + /* Clear the test array */
12111 + pa = (ulong) DMA_MAP(NULL, buf, sizeof(buf), DMA_RX, NULL);
12112 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]);
12113 + memset(ptr, 0, sizeof(buf));
12114 +
12115 + /* Point PCI window 1 to memory */
12116 + sbtopci1 = R_REG(&pci->sbtopci1);
12117 + W_REG(&pci->sbtopci1, SBTOPCI_MEM | (pa & SBTOPCI1_MASK));
12118 +
12119 + /* Fill the test array via PCI window 1 */
12120 + ptr = (uint32 *) REG_MAP(SB_PCI_CFG + (pa & ~SBTOPCI1_MASK), sizeof(buf));
12121 + for (i = 0; i < ARRAYSIZE(buf); i++) {
12122 + for (j = 0; j < 2; j++);
12123 + W_REG(&ptr[i], i);
12124 + }
12125 + REG_UNMAP(ptr);
12126 +
12127 + /* Restore PCI window 1 */
12128 + W_REG(&pci->sbtopci1, sbtopci1);
12129 +
12130 + /* Check the test array */
12131 + DMA_UNMAP(NULL, pa, sizeof(buf), DMA_RX, NULL);
12132 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]);
12133 + for (i = 0; i < ARRAYSIZE(buf); i++) {
12134 + if (ptr[i] != i)
12135 + break;
12136 + }
12137 +
12138 + /* Change the clock if the test fails */
12139 + if (i < ARRAYSIZE(buf)) {
12140 + uint32 req, cur;
12141 +
12142 + cur = sb_clock(sbh);
12143 + printf("PCI: Test failed at %d MHz\n", (cur + 500000) / 1000000);
12144 + for (req = 104000000; req < 176000000; req += 4000000) {
12145 + printf("PCI: Resetting to %d MHz\n", (req + 500000) / 1000000);
12146 + /* This will only reset if the clocks are valid and have changed */
12147 + sb_mips_setclock(sbh, req, 0, 0);
12148 + }
12149 + /* Should not reach here */
12150 + ASSERT(0);
12151 + }
12152 +
12153 + sb_setcoreidx(sbh, coreidx);
12154 +}
12155 diff -urN linux-2.4.30/arch/mips/bcm947xx/setup.c linux-2.4.30.dev/arch/mips/bcm947xx/setup.c
12156 --- linux-2.4.30/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100
12157 +++ linux-2.4.30.dev/arch/mips/bcm947xx/setup.c 2005-08-22 01:34:46.347147816 +0200
12158 @@ -0,0 +1,261 @@
12159 +/*
12160 + * Generic setup routines for Broadcom MIPS boards
12161 + *
12162 + * Copyright 2004, Broadcom Corporation
12163 + * All Rights Reserved.
12164 + *
12165 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
12166 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
12167 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
12168 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
12169 + *
12170 + * $Id: setup.c,v 1.2 2005/04/02 12:12:57 wbx Exp $
12171 + */
12172 +
12173 +#include <linux/config.h>
12174 +#include <linux/init.h>
12175 +#include <linux/kernel.h>
12176 +#include <linux/serialP.h>
12177 +#include <linux/ide.h>
12178 +#include <asm/bootinfo.h>
12179 +#include <asm/time.h>
12180 +#include <asm/reboot.h>
12181 +
12182 +#ifdef CONFIG_MTD_PARTITIONS
12183 +#include <linux/mtd/mtd.h>
12184 +#include <linux/mtd/partitions.h>
12185 +#endif
12186 +
12187 +#include <typedefs.h>
12188 +#include <bcmutils.h>
12189 +#include <bcmnvram.h>
12190 +#include <sbmips.h>
12191 +#include <sbutils.h>
12192 +#include <trxhdr.h>
12193 +
12194 +extern void bcm947xx_time_init(void);
12195 +extern void bcm947xx_timer_setup(struct irqaction *irq);
12196 +extern void check_enable_mips_pfc(int val);
12197 +
12198 +#ifdef CONFIG_REMOTE_DEBUG
12199 +extern void set_debug_traps(void);
12200 +extern void rs_kgdb_hook(struct serial_state *);
12201 +extern void breakpoint(void);
12202 +#endif
12203 +
12204 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
12205 +extern struct ide_ops std_ide_ops;
12206 +#endif
12207 +
12208 +/* Global SB handle */
12209 +void *bcm947xx_sbh = NULL;
12210 +spinlock_t bcm947xx_sbh_lock = SPIN_LOCK_UNLOCKED;
12211 +EXPORT_SYMBOL(bcm947xx_sbh);
12212 +EXPORT_SYMBOL(bcm947xx_sbh_lock);
12213 +
12214 +/* Convenience */
12215 +#define sbh bcm947xx_sbh
12216 +#define sbh_lock bcm947xx_sbh_lock
12217 +
12218 +/* Kernel command line */
12219 +char arcs_cmdline[CL_SIZE] __initdata = CONFIG_CMDLINE;
12220 +
12221 +void
12222 +bcm947xx_machine_restart(char *command)
12223 +{
12224 + printk("Please stand by while rebooting the system...\n");
12225 +
12226 + /* Set the watchdog timer to reset immediately */
12227 + __cli();
12228 + sb_watchdog(sbh, 1);
12229 + while (1);
12230 +}
12231 +
12232 +void
12233 +bcm947xx_machine_halt(void)
12234 +{
12235 + printk("System halted\n");
12236 +
12237 + /* Disable interrupts and watchdog and spin forever */
12238 + __cli();
12239 + sb_watchdog(sbh, 0);
12240 + while (1);
12241 +}
12242 +
12243 +#ifdef CONFIG_SERIAL
12244 +
12245 +static struct serial_struct rs = {
12246 + line: 0,
12247 + flags: ASYNC_BOOT_AUTOCONF,
12248 + io_type: SERIAL_IO_MEM,
12249 +};
12250 +
12251 +static void __init
12252 +serial_add(void *regs, uint irq, uint baud_base, uint reg_shift)
12253 +{
12254 + rs.iomem_base = regs;
12255 + rs.irq = irq + 2;
12256 + rs.baud_base = baud_base / 16;
12257 + rs.iomem_reg_shift = reg_shift;
12258 +
12259 + early_serial_setup(&rs);
12260 +
12261 + rs.line++;
12262 +}
12263 +
12264 +static void __init
12265 +serial_setup(void *sbh)
12266 +{
12267 + sb_serial_init(sbh, serial_add);
12268 +
12269 +#ifdef CONFIG_REMOTE_DEBUG
12270 + /* Use the last port for kernel debugging */
12271 + if (rs.iomem_base)
12272 + rs_kgdb_hook(&rs);
12273 +#endif
12274 +}
12275 +
12276 +#endif /* CONFIG_SERIAL */
12277 +
12278 +void __init
12279 +brcm_setup(void)
12280 +{
12281 + char *value;
12282 + uint pfc_val;
12283 +
12284 + /* Get global SB handle */
12285 + sbh = sb_kattach();
12286 +
12287 + /* Initialize clocks and interrupts */
12288 + sb_mips_init(sbh);
12289 +
12290 + /*
12291 + * Now that the sbh is inited set the proper PFC value
12292 + */
12293 + pfc_val = sb_mips_get_pfc(sbh);
12294 + printk("Setting the PFC value as 0x%x\n", pfc_val);
12295 + check_enable_mips_pfc(pfc_val);
12296 +
12297 +#ifdef CONFIG_SERIAL
12298 + /* Initialize UARTs */
12299 + serial_setup(sbh);
12300 +#endif
12301 +
12302 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
12303 + ide_ops = &std_ide_ops;
12304 +#endif
12305 +
12306 + /* Override default command line arguments */
12307 + value = nvram_get("kernel_cmdline");
12308 + if (value && strlen(value) && strncmp(value, "empty", 5))
12309 + strncpy(arcs_cmdline, value, sizeof(arcs_cmdline));
12310 +
12311 +
12312 + /* Generic setup */
12313 + _machine_restart = bcm947xx_machine_restart;
12314 + _machine_halt = bcm947xx_machine_halt;
12315 + _machine_power_off = bcm947xx_machine_halt;
12316 +
12317 + board_time_init = bcm947xx_time_init;
12318 + board_timer_setup = bcm947xx_timer_setup;
12319 +}
12320 +
12321 +const char *
12322 +get_system_type(void)
12323 +{
12324 + return "Broadcom BCM947XX";
12325 +}
12326 +
12327 +void __init
12328 +bus_error_init(void)
12329 +{
12330 +}
12331 +
12332 +#ifdef CONFIG_MTD_PARTITIONS
12333 +
12334 +static struct mtd_partition bcm947xx_parts[] = {
12335 + { name: "pmon", offset: 0, size: 0, mask_flags: MTD_WRITEABLE, },
12336 + { name: "linux", offset: 0, size: 0, },
12337 + { name: "rootfs", offset: 0, size: 0, },
12338 + { name: "nvram", offset: 0, size: 0, },
12339 + { name: "OpenWrt", offset: 0, size: 0, },
12340 + { name: NULL, },
12341 +};
12342 +
12343 +static int __init
12344 +find_root(struct mtd_info *mtd, size_t size, struct mtd_partition *part)
12345 +{
12346 + struct trx_header *trx;
12347 + unsigned char buf[512];
12348 + int off;
12349 + size_t len;
12350 +
12351 + trx = (struct trx_header *) buf;
12352 +
12353 + for (off = (256*1024); off < size; off += mtd->erasesize) {
12354 + memset(buf, 0xe5, sizeof(buf));
12355 +
12356 + /*
12357 + * Read into buffer
12358 + */
12359 + if (MTD_READ(mtd, off, sizeof(buf), &len, buf) ||
12360 + len != sizeof(buf))
12361 + continue;
12362 +
12363 + /* found a TRX header */
12364 + if (le32_to_cpu(trx->magic) == TRX_MAGIC) {
12365 + part->offset = le32_to_cpu(trx->offsets[2]) ? :
12366 + le32_to_cpu(trx->offsets[1]);
12367 + part->size = le32_to_cpu(trx->len);
12368 +
12369 + part->size -= part->offset;
12370 + part->offset += off;
12371 +
12372 + goto done;
12373 + }
12374 + }
12375 +
12376 + printk(KERN_NOTICE
12377 + "%s: Couldn't find root filesystem\n",
12378 + mtd->name);
12379 + return -1;
12380 +
12381 + done:
12382 + return part->size;
12383 +}
12384 +
12385 +struct mtd_partition * __init
12386 +init_mtd_partitions(struct mtd_info *mtd, size_t size)
12387 +{
12388 +
12389 + /* boot loader */
12390 + bcm947xx_parts[0].offset=0;
12391 + bcm947xx_parts[0].size=256*1024;
12392 +
12393 + /* nvram */
12394 + bcm947xx_parts[3].offset = size - ROUNDUP(NVRAM_SPACE, mtd->erasesize);
12395 + bcm947xx_parts[3].size = size - bcm947xx_parts[3].offset;
12396 +
12397 + /* Size linux (kernel and rootfs) */
12398 + bcm947xx_parts[1].offset = bcm947xx_parts[0].size;
12399 + bcm947xx_parts[1].size = bcm947xx_parts[3].offset - bcm947xx_parts[1].offset;
12400 +
12401 + /* Find and size rootfs */
12402 + if (find_root(mtd,size,&bcm947xx_parts[2])==0) {
12403 + /* entirely jffs2 */
12404 + bcm947xx_parts[2].size = bcm947xx_parts[3].offset - bcm947xx_parts[2].offset;
12405 + bcm947xx_parts[4].name = NULL;
12406 + } else {
12407 + /* legacy setup */
12408 + /* calculate leftover flash, and assign it to the jffs2 partition */
12409 + bcm947xx_parts[4].offset = bcm947xx_parts[2].offset + bcm947xx_parts[2].size;
12410 + bcm947xx_parts[4].offset = ROUNDUP(bcm947xx_parts[4].offset, mtd->erasesize);
12411 + bcm947xx_parts[4].size = bcm947xx_parts[3].offset - bcm947xx_parts[4].offset;
12412 + }
12413 +
12414 + return bcm947xx_parts;
12415 +}
12416 +
12417 +EXPORT_SYMBOL(init_mtd_partitions);
12418 +
12419 +#endif
12420 diff -urN linux-2.4.30/arch/mips/bcm947xx/time.c linux-2.4.30.dev/arch/mips/bcm947xx/time.c
12421 --- linux-2.4.30/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +0100
12422 +++ linux-2.4.30.dev/arch/mips/bcm947xx/time.c 2005-08-22 01:34:46.347147816 +0200
12423 @@ -0,0 +1,117 @@
12424 +/*
12425 + * Copyright 2004, Broadcom Corporation
12426 + * All Rights Reserved.
12427 + *
12428 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
12429 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
12430 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
12431 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
12432 + *
12433 + * $Id: time.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
12434 + */
12435 +#include <linux/config.h>
12436 +#include <linux/init.h>
12437 +#include <linux/kernel.h>
12438 +#include <linux/sched.h>
12439 +#include <linux/serial_reg.h>
12440 +#include <linux/interrupt.h>
12441 +#include <asm/addrspace.h>
12442 +#include <asm/io.h>
12443 +#include <asm/time.h>
12444 +
12445 +#include <typedefs.h>
12446 +#include <bcmnvram.h>
12447 +#include <sbconfig.h>
12448 +#include <sbextif.h>
12449 +#include <sbutils.h>
12450 +#include <sbmips.h>
12451 +
12452 +/* Global SB handle */
12453 +extern void *bcm947xx_sbh;
12454 +extern spinlock_t bcm947xx_sbh_lock;
12455 +
12456 +/* Convenience */
12457 +#define sbh bcm947xx_sbh
12458 +#define sbh_lock bcm947xx_sbh_lock
12459 +
12460 +extern int panic_timeout;
12461 +static int watchdog = 0;
12462 +static u8 *mcr = NULL;
12463 +
12464 +void __init
12465 +bcm947xx_time_init(void)
12466 +{
12467 + unsigned int hz;
12468 + extifregs_t *eir;
12469 +
12470 + /*
12471 + * Use deterministic values for initial counter interrupt
12472 + * so that calibrate delay avoids encountering a counter wrap.
12473 + */
12474 + write_c0_count(0);
12475 + write_c0_compare(0xffff);
12476 +
12477 + if (!(hz = sb_mips_clock(sbh)))
12478 + hz = 100000000;
12479 +
12480 + printk("CPU: BCM%04x rev %d at %d MHz\n", sb_chip(sbh), sb_chiprev(sbh),
12481 + (hz + 500000) / 1000000);
12482 +
12483 + /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
12484 + mips_hpt_frequency = hz / 2;
12485 +
12486 + /* Set watchdog interval in ms */
12487 + watchdog = simple_strtoul(nvram_safe_get("watchdog"), NULL, 0);
12488 +
12489 + /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */
12490 + if (watchdog > 0) {
12491 + if (watchdog < 3000)
12492 + watchdog = 3000;
12493 + }
12494 +
12495 +
12496 + /* Set panic timeout in seconds */
12497 + panic_timeout = watchdog / 1000;
12498 +
12499 + /* Setup blink */
12500 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
12501 + sbconfig_t *sb = (sbconfig_t *)((unsigned int) eir + SBCONFIGOFF);
12502 + unsigned long base = EXTIF_CFGIF_BASE(sb_base(readl(&sb->sbadmatch1)));
12503 + mcr = (u8 *) ioremap_nocache(base + UART_MCR, 1);
12504 + }
12505 +}
12506 +
12507 +static void
12508 +bcm947xx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
12509 +{
12510 + /* Generic MIPS timer code */
12511 + timer_interrupt(irq, dev_id, regs);
12512 +
12513 + /* Set the watchdog timer to reset after the specified number of ms */
12514 + if (watchdog > 0)
12515 + sb_watchdog(sbh, WATCHDOG_CLOCK / 1000 * watchdog);
12516 +
12517 +#ifdef CONFIG_HWSIM
12518 + (*((int *)0xa0000f1c))++;
12519 +#else
12520 + /* Blink one of the LEDs in the external UART */
12521 + if (mcr && !(jiffies % (HZ/2)))
12522 + writeb(readb(mcr) ^ UART_MCR_OUT2, mcr);
12523 +#endif
12524 +}
12525 +
12526 +static struct irqaction bcm947xx_timer_irqaction = {
12527 + bcm947xx_timer_interrupt,
12528 + SA_INTERRUPT,
12529 + 0,
12530 + "timer",
12531 + NULL,
12532 + NULL
12533 +};
12534 +
12535 +void __init
12536 +bcm947xx_timer_setup(struct irqaction *irq)
12537 +{
12538 + /* Enable the timer interrupt */
12539 + setup_irq(7, &bcm947xx_timer_irqaction);
12540 +}
12541 diff -urN linux-2.4.30/arch/mips/config-shared.in linux-2.4.30.dev/arch/mips/config-shared.in
12542 --- linux-2.4.30/arch/mips/config-shared.in 2005-08-22 01:29:11.665027232 +0200
12543 +++ linux-2.4.30.dev/arch/mips/config-shared.in 2005-08-22 01:34:46.362145536 +0200
12544 @@ -208,6 +208,14 @@
12545 fi
12546 define_bool CONFIG_MIPS_RTC y
12547 fi
12548 +dep_bool 'Support for Broadcom MIPS-based boards' CONFIG_MIPS_BRCM $CONFIG_EXPERIMENTAL
12549 +dep_bool 'Support for Broadcom BCM947XX' CONFIG_BCM947XX $CONFIG_MIPS_BRCM
12550 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
12551 + bool ' Support for Broadcom BCM4710' CONFIG_BCM4710
12552 + bool ' Support for Broadcom BCM4310' CONFIG_BCM4310
12553 + bool ' Support for Broadcom BCM4704' CONFIG_BCM4704
12554 + bool ' Support for Broadcom BCM5365' CONFIG_BCM5365
12555 +fi
12556 bool 'Support for SNI RM200 PCI' CONFIG_SNI_RM200_PCI
12557 bool 'Support for TANBAC TB0226 (Mbase)' CONFIG_TANBAC_TB0226
12558 bool 'Support for TANBAC TB0229 (VR4131DIMM)' CONFIG_TANBAC_TB0229
12559 @@ -229,6 +237,11 @@
12560 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
12561
12562 #
12563 +# Provide an option for a default kernel command line
12564 +#
12565 +string 'Default kernel command string' CONFIG_CMDLINE ""
12566 +
12567 +#
12568 # Select some configuration options automatically based on user selections.
12569 #
12570 if [ "$CONFIG_ACER_PICA_61" = "y" ]; then
12571 @@ -554,6 +567,13 @@
12572 define_bool CONFIG_SWAP_IO_SPACE_L y
12573 define_bool CONFIG_BOOT_ELF32 y
12574 fi
12575 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
12576 + define_bool CONFIG_PCI y
12577 + define_bool CONFIG_NONCOHERENT_IO y
12578 + define_bool CONFIG_NEW_TIME_C y
12579 + define_bool CONFIG_NEW_IRQ y
12580 + define_bool CONFIG_HND y
12581 +fi
12582 if [ "$CONFIG_SNI_RM200_PCI" = "y" ]; then
12583 define_bool CONFIG_ARC32 y
12584 define_bool CONFIG_ARC_MEMORY y
12585 @@ -1042,7 +1062,11 @@
12586
12587 bool 'Are you using a crosscompiler' CONFIG_CROSSCOMPILE
12588 bool 'Enable run-time debugging' CONFIG_RUNTIME_DEBUG
12589 -bool 'Remote GDB kernel debugging' CONFIG_KGDB
12590 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
12591 + bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG
12592 +else
12593 + bool 'Remote GDB kernel debugging' CONFIG_KGDB
12594 +fi
12595 dep_bool ' Console output to GDB' CONFIG_GDB_CONSOLE $CONFIG_KGDB
12596 if [ "$CONFIG_KGDB" = "y" ]; then
12597 define_bool CONFIG_DEBUG_INFO y
12598 diff -urN linux-2.4.30/arch/mips/kernel/cpu-probe.c linux-2.4.30.dev/arch/mips/kernel/cpu-probe.c
12599 --- linux-2.4.30/arch/mips/kernel/cpu-probe.c 2005-08-22 01:29:09.347379568 +0200
12600 +++ linux-2.4.30.dev/arch/mips/kernel/cpu-probe.c 2005-08-22 01:34:46.365145080 +0200
12601 @@ -163,7 +163,7 @@
12602
12603 static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
12604 {
12605 - switch (c->processor_id & 0xff00) {
12606 + switch (c->processor_id & PRID_IMP_MASK) {
12607 case PRID_IMP_R2000:
12608 c->cputype = CPU_R2000;
12609 c->isa_level = MIPS_CPU_ISA_I;
12610 @@ -173,7 +173,7 @@
12611 c->tlbsize = 64;
12612 break;
12613 case PRID_IMP_R3000:
12614 - if ((c->processor_id & 0xff) == PRID_REV_R3000A)
12615 + if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A)
12616 if (cpu_has_confreg())
12617 c->cputype = CPU_R3081E;
12618 else
12619 @@ -188,12 +188,12 @@
12620 break;
12621 case PRID_IMP_R4000:
12622 if (read_c0_config() & CONF_SC) {
12623 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
12624 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
12625 c->cputype = CPU_R4400PC;
12626 else
12627 c->cputype = CPU_R4000PC;
12628 } else {
12629 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
12630 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
12631 c->cputype = CPU_R4400SC;
12632 else
12633 c->cputype = CPU_R4000SC;
12634 @@ -439,7 +439,7 @@
12635 static inline void cpu_probe_mips(struct cpuinfo_mips *c)
12636 {
12637 decode_config1(c);
12638 - switch (c->processor_id & 0xff00) {
12639 + switch (c->processor_id & PRID_IMP_MASK) {
12640 case PRID_IMP_4KC:
12641 c->cputype = CPU_4KC;
12642 c->isa_level = MIPS_CPU_ISA_M32;
12643 @@ -480,10 +480,10 @@
12644 {
12645 decode_config1(c);
12646 c->options |= MIPS_CPU_PREFETCH;
12647 - switch (c->processor_id & 0xff00) {
12648 + switch (c->processor_id & PRID_IMP_MASK) {
12649 case PRID_IMP_AU1_REV1:
12650 case PRID_IMP_AU1_REV2:
12651 - switch ((c->processor_id >> 24) & 0xff) {
12652 + switch ((c->processor_id >> 24) & PRID_REV_MASK) {
12653 case 0:
12654 c->cputype = CPU_AU1000;
12655 break;
12656 @@ -511,10 +511,34 @@
12657 }
12658 }
12659
12660 +static inline void cpu_probe_broadcom(struct cpuinfo_mips *c)
12661 +{
12662 + decode_config1(c);
12663 + c->options |= MIPS_CPU_PREFETCH;
12664 + switch (c->processor_id & PRID_IMP_MASK) {
12665 + case PRID_IMP_BCM4710:
12666 + c->cputype = CPU_BCM4710;
12667 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
12668 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
12669 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
12670 + break;
12671 + case PRID_IMP_4KC:
12672 + case PRID_IMP_BCM3302:
12673 + c->cputype = CPU_BCM3302;
12674 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
12675 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
12676 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
12677 + break;
12678 + default:
12679 + c->cputype = CPU_UNKNOWN;
12680 + break;
12681 + }
12682 +}
12683 +
12684 static inline void cpu_probe_sibyte(struct cpuinfo_mips *c)
12685 {
12686 decode_config1(c);
12687 - switch (c->processor_id & 0xff00) {
12688 + switch (c->processor_id & PRID_IMP_MASK) {
12689 case PRID_IMP_SB1:
12690 c->cputype = CPU_SB1;
12691 c->isa_level = MIPS_CPU_ISA_M64;
12692 @@ -536,7 +560,7 @@
12693 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c)
12694 {
12695 decode_config1(c);
12696 - switch (c->processor_id & 0xff00) {
12697 + switch (c->processor_id & PRID_IMP_MASK) {
12698 case PRID_IMP_SR71000:
12699 c->cputype = CPU_SR71000;
12700 c->isa_level = MIPS_CPU_ISA_M64;
12701 @@ -561,7 +585,7 @@
12702 c->cputype = CPU_UNKNOWN;
12703
12704 c->processor_id = read_c0_prid();
12705 - switch (c->processor_id & 0xff0000) {
12706 + switch (c->processor_id & PRID_COMP_MASK) {
12707
12708 case PRID_COMP_LEGACY:
12709 cpu_probe_legacy(c);
12710 @@ -572,6 +596,9 @@
12711 case PRID_COMP_ALCHEMY:
12712 cpu_probe_alchemy(c);
12713 break;
12714 + case PRID_COMP_BROADCOM:
12715 + cpu_probe_broadcom(c);
12716 + break;
12717 case PRID_COMP_SIBYTE:
12718 cpu_probe_sibyte(c);
12719 break;
12720 diff -urN linux-2.4.30/arch/mips/kernel/head.S linux-2.4.30.dev/arch/mips/kernel/head.S
12721 --- linux-2.4.30/arch/mips/kernel/head.S 2005-08-22 01:29:09.348379416 +0200
12722 +++ linux-2.4.30.dev/arch/mips/kernel/head.S 2005-08-22 01:34:46.366144928 +0200
12723 @@ -28,12 +28,20 @@
12724 #include <asm/mipsregs.h>
12725 #include <asm/stackframe.h>
12726
12727 +#ifdef CONFIG_BCM4710
12728 +#undef eret
12729 +#define eret nop; nop; eret
12730 +#endif
12731 +
12732 .text
12733 + j kernel_entry
12734 + nop
12735 +
12736 /*
12737 * Reserved space for exception handlers.
12738 * Necessary for machines which link their kernels at KSEG0.
12739 */
12740 - .fill 0x400
12741 + .fill 0x3f4
12742
12743 /* The following two symbols are used for kernel profiling. */
12744 EXPORT(stext)
12745 diff -urN linux-2.4.30/arch/mips/kernel/proc.c linux-2.4.30.dev/arch/mips/kernel/proc.c
12746 --- linux-2.4.30/arch/mips/kernel/proc.c 2005-01-19 15:09:29.000000000 +0100
12747 +++ linux-2.4.30.dev/arch/mips/kernel/proc.c 2005-08-22 01:34:46.366144928 +0200
12748 @@ -78,9 +78,10 @@
12749 [CPU_AU1550] "Au1550",
12750 [CPU_24K] "MIPS 24K",
12751 [CPU_AU1200] "Au1200",
12752 + [CPU_BCM4710] "BCM4710",
12753 + [CPU_BCM3302] "BCM3302",
12754 };
12755
12756 -
12757 static int show_cpuinfo(struct seq_file *m, void *v)
12758 {
12759 unsigned int version = current_cpu_data.processor_id;
12760 diff -urN linux-2.4.30/arch/mips/kernel/setup.c linux-2.4.30.dev/arch/mips/kernel/setup.c
12761 --- linux-2.4.30/arch/mips/kernel/setup.c 2005-08-22 01:29:09.349379264 +0200
12762 +++ linux-2.4.30.dev/arch/mips/kernel/setup.c 2005-08-22 01:34:46.367144776 +0200
12763 @@ -493,6 +493,7 @@
12764 void swarm_setup(void);
12765 void hp_setup(void);
12766 void au1x00_setup(void);
12767 + void brcm_setup(void);
12768 void frame_info_init(void);
12769
12770 frame_info_init();
12771 @@ -691,6 +692,11 @@
12772 pmc_yosemite_setup();
12773 break;
12774 #endif
12775 +#if defined(CONFIG_BCM4710) || defined(CONFIG_BCM4310)
12776 + case MACH_GROUP_BRCM:
12777 + brcm_setup();
12778 + break;
12779 +#endif
12780 default:
12781 panic("Unsupported architecture");
12782 }
12783 diff -urN linux-2.4.30/arch/mips/kernel/traps.c linux-2.4.30.dev/arch/mips/kernel/traps.c
12784 --- linux-2.4.30/arch/mips/kernel/traps.c 2005-08-22 01:29:09.350379112 +0200
12785 +++ linux-2.4.30.dev/arch/mips/kernel/traps.c 2005-08-22 01:34:46.369144472 +0200
12786 @@ -920,6 +920,7 @@
12787 void __init trap_init(void)
12788 {
12789 extern char except_vec1_generic;
12790 + extern char except_vec2_generic;
12791 extern char except_vec3_generic, except_vec3_r4000;
12792 extern char except_vec_ejtag_debug;
12793 extern char except_vec4;
12794 @@ -927,6 +928,7 @@
12795
12796 /* Copy the generic exception handler code to it's final destination. */
12797 memcpy((void *)(KSEG0 + 0x80), &except_vec1_generic, 0x80);
12798 + memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80);
12799
12800 /*
12801 * Setup default vectors
12802 @@ -985,6 +987,12 @@
12803 set_except_vector(13, handle_tr);
12804 set_except_vector(22, handle_mdmx);
12805
12806 + if (current_cpu_data.cputype == CPU_SB1) {
12807 + /* Enable timer interrupt and scd mapped interrupt */
12808 + clear_c0_status(0xf000);
12809 + set_c0_status(0xc00);
12810 + }
12811 +
12812 if (cpu_has_fpu && !cpu_has_nofpuex)
12813 set_except_vector(15, handle_fpe);
12814
12815 diff -urN linux-2.4.30/arch/mips/mm/c-r4k.c linux-2.4.30.dev/arch/mips/mm/c-r4k.c
12816 --- linux-2.4.30/arch/mips/mm/c-r4k.c 2005-08-22 01:29:09.353378656 +0200
12817 +++ linux-2.4.30.dev/arch/mips/mm/c-r4k.c 2005-08-22 01:34:46.372144016 +0200
12818 @@ -1118,3 +1118,47 @@
12819 build_clear_page();
12820 build_copy_page();
12821 }
12822 +
12823 +#ifdef CONFIG_BCM4704
12824 +static void __init mips32_icache_fill(unsigned long addr, uint nbytes)
12825 +{
12826 + unsigned long ic_lsize = current_cpu_data.icache.linesz;
12827 + int i;
12828 + for (i = 0; i < nbytes; i += ic_lsize)
12829 + fill_icache_line((addr + i));
12830 +}
12831 +
12832 +/*
12833 + * This must be run from the cache on 4704A0
12834 + * so there are no mips core BIU ops in progress
12835 + * when the PFC is enabled.
12836 + */
12837 +#define PFC_CR0 0xff400000 /* control reg 0 */
12838 +#define PFC_CR1 0xff400004 /* control reg 1 */
12839 +static void __init enable_pfc(u32 mode)
12840 +{
12841 + /* write range */
12842 + *(volatile u32 *)PFC_CR1 = 0xffff0000;
12843 +
12844 + /* enable */
12845 + *(volatile u32 *)PFC_CR0 = mode;
12846 +}
12847 +#endif
12848 +
12849 +
12850 +void check_enable_mips_pfc(int val)
12851 +{
12852 +
12853 +#ifdef CONFIG_BCM4704
12854 + struct cpuinfo_mips *c = &current_cpu_data;
12855 +
12856 + /* enable prefetch cache */
12857 + if (((c->processor_id & (PRID_COMP_MASK | PRID_IMP_MASK)) == PRID_IMP_BCM3302)
12858 + && (read_c0_diag() & (1 << 29))) {
12859 + mips32_icache_fill((unsigned long) &enable_pfc, 64);
12860 + enable_pfc(val);
12861 + }
12862 +#endif
12863 +}
12864 +
12865 +
12866 diff -urN linux-2.4.30/arch/mips/pci/Makefile linux-2.4.30.dev/arch/mips/pci/Makefile
12867 --- linux-2.4.30/arch/mips/pci/Makefile 2005-01-19 15:09:29.000000000 +0100
12868 +++ linux-2.4.30.dev/arch/mips/pci/Makefile 2005-08-22 01:34:46.385142040 +0200
12869 @@ -13,7 +13,9 @@
12870 obj-$(CONFIG_MIPS_MSC) += ops-msc.o
12871 obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o
12872 obj-$(CONFIG_SNI_RM200_PCI) += ops-sni.o
12873 +ifndef CONFIG_BCM947XX
12874 obj-y += pci.o
12875 +endif
12876 obj-$(CONFIG_PCI_AUTO) += pci_auto.o
12877
12878 include $(TOPDIR)/Rules.make
12879 diff -urN linux-2.4.30/drivers/char/serial.c linux-2.4.30.dev/drivers/char/serial.c
12880 --- linux-2.4.30/drivers/char/serial.c 2005-08-22 01:29:09.495357072 +0200
12881 +++ linux-2.4.30.dev/drivers/char/serial.c 2005-08-22 01:34:46.431135048 +0200
12882 @@ -444,6 +444,10 @@
12883 return inb(info->port+1);
12884 #endif
12885 case SERIAL_IO_MEM:
12886 +#ifdef CONFIG_BCM4310
12887 + readb((unsigned long) info->iomem_base +
12888 + (UART_SCR<<info->iomem_reg_shift));
12889 +#endif
12890 return readb((unsigned long) info->iomem_base +
12891 (offset<<info->iomem_reg_shift));
12892 default:
12893 @@ -464,6 +468,9 @@
12894 case SERIAL_IO_MEM:
12895 writeb(value, (unsigned long) info->iomem_base +
12896 (offset<<info->iomem_reg_shift));
12897 +#ifdef CONFIG_BCM4704
12898 + *((volatile unsigned int *) KSEG1ADDR(0x18000000));
12899 +#endif
12900 break;
12901 default:
12902 outb(value, info->port+offset);
12903 @@ -5996,6 +6003,13 @@
12904 * Divisor, bytesize and parity
12905 */
12906 state = rs_table + co->index;
12907 + /*
12908 + * Safe guard: state structure must have been initialized
12909 + */
12910 + if (state->iomem_base == NULL) {
12911 + printk("!unable to setup serial console!\n");
12912 + return -1;
12913 + }
12914 if (doflow)
12915 state->flags |= ASYNC_CONS_FLOW;
12916 info = &async_sercons;
12917 diff -urN linux-2.4.30/drivers/mtd/chips/Config.in linux-2.4.30.dev/drivers/mtd/chips/Config.in
12918 --- linux-2.4.30/drivers/mtd/chips/Config.in 2003-06-13 16:51:34.000000000 +0200
12919 +++ linux-2.4.30.dev/drivers/mtd/chips/Config.in 2005-08-22 01:34:46.435134440 +0200
12920 @@ -45,6 +45,7 @@
12921 dep_tristate ' Support for Intel/Sharp flash chips' CONFIG_MTD_CFI_INTELEXT $CONFIG_MTD_GEN_PROBE
12922 dep_tristate ' Support for AMD/Fujitsu flash chips' CONFIG_MTD_CFI_AMDSTD $CONFIG_MTD_GEN_PROBE
12923 dep_tristate ' Support for ST (Advanced Architecture) flash chips' CONFIG_MTD_CFI_STAA $CONFIG_MTD_GEN_PROBE
12924 +dep_tristate ' Support for SST flash chips' CONFIG_MTD_CFI_SSTSTD $CONFIG_MTD_GEN_PROBE
12925
12926 dep_tristate ' Support for RAM chips in bus mapping' CONFIG_MTD_RAM $CONFIG_MTD
12927 dep_tristate ' Support for ROM chips in bus mapping' CONFIG_MTD_ROM $CONFIG_MTD
12928 diff -urN linux-2.4.30/drivers/mtd/chips/Makefile linux-2.4.30.dev/drivers/mtd/chips/Makefile
12929 --- linux-2.4.30/drivers/mtd/chips/Makefile 2003-06-13 16:51:34.000000000 +0200
12930 +++ linux-2.4.30.dev/drivers/mtd/chips/Makefile 2005-08-22 01:34:46.458130944 +0200
12931 @@ -18,6 +18,7 @@
12932 obj-$(CONFIG_MTD_AMDSTD) += amd_flash.o
12933 obj-$(CONFIG_MTD_CFI) += cfi_probe.o
12934 obj-$(CONFIG_MTD_CFI_STAA) += cfi_cmdset_0020.o
12935 +obj-$(CONFIG_MTD_CFI_SSTSTD) += cfi_cmdset_0701.o
12936 obj-$(CONFIG_MTD_CFI_AMDSTD) += cfi_cmdset_0002.o
12937 obj-$(CONFIG_MTD_CFI_INTELEXT) += cfi_cmdset_0001.o
12938 obj-$(CONFIG_MTD_GEN_PROBE) += gen_probe.o
12939 diff -urN linux-2.4.30/drivers/mtd/chips/cfi_cmdset_0701.c linux-2.4.30.dev/drivers/mtd/chips/cfi_cmdset_0701.c
12940 --- linux-2.4.30/drivers/mtd/chips/cfi_cmdset_0701.c 1970-01-01 01:00:00.000000000 +0100
12941 +++ linux-2.4.30.dev/drivers/mtd/chips/cfi_cmdset_0701.c 2005-08-22 01:34:46.433134744 +0200
12942 @@ -0,0 +1,855 @@
12943 +/*
12944 + * Common Flash Interface support:
12945 + * SST Standard Vendor Command Set (ID 0x0701)
12946 + *
12947 + * Copyright (C) 2000 Crossnet Co. <info@crossnet.co.jp>
12948 + *
12949 + * 2_by_8 routines added by Simon Munton
12950 + *
12951 + * This code is GPL
12952 + *
12953 + * $Id: cfi_cmdset_0701.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
12954 + *
12955 + */
12956 +
12957 +#include <linux/module.h>
12958 +#include <linux/types.h>
12959 +#include <linux/kernel.h>
12960 +#include <linux/sched.h>
12961 +#include <asm/io.h>
12962 +#include <asm/byteorder.h>
12963 +
12964 +#include <linux/errno.h>
12965 +#include <linux/slab.h>
12966 +#include <linux/delay.h>
12967 +#include <linux/interrupt.h>
12968 +#include <linux/mtd/map.h>
12969 +#include <linux/mtd/cfi.h>
12970 +
12971 +static int cfi_sststd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
12972 +static int cfi_sststd_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
12973 +static int cfi_sststd_erase_onesize(struct mtd_info *, struct erase_info *);
12974 +static int cfi_sststd_erase_varsize(struct mtd_info *, struct erase_info *);
12975 +static void cfi_sststd_sync (struct mtd_info *);
12976 +static int cfi_sststd_suspend (struct mtd_info *);
12977 +static void cfi_sststd_resume (struct mtd_info *);
12978 +
12979 +static void cfi_sststd_destroy(struct mtd_info *);
12980 +
12981 +struct mtd_info *cfi_cmdset_0701(struct map_info *, int);
12982 +static struct mtd_info *cfi_sststd_setup (struct map_info *);
12983 +
12984 +
12985 +static struct mtd_chip_driver cfi_sststd_chipdrv = {
12986 + probe: NULL, /* Not usable directly */
12987 + destroy: cfi_sststd_destroy,
12988 + name: "cfi_cmdset_0701",
12989 + module: THIS_MODULE
12990 +};
12991 +
12992 +struct mtd_info *cfi_cmdset_0701(struct map_info *map, int primary)
12993 +{
12994 + struct cfi_private *cfi = map->fldrv_priv;
12995 + int ofs_factor = cfi->interleave * cfi->device_type;
12996 + int i;
12997 + __u8 major, minor;
12998 + __u32 base = cfi->chips[0].start;
12999 +
13000 + if (cfi->cfi_mode==1){
13001 + __u16 adr = primary?cfi->cfiq->P_ADR:cfi->cfiq->A_ADR;
13002 +
13003 + cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
13004 + cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
13005 + cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL);
13006 +
13007 + major = cfi_read_query(map, base + (adr+3)*ofs_factor);
13008 + minor = cfi_read_query(map, base + (adr+4)*ofs_factor);
13009 +
13010 + printk(" SST Query Table v%c.%c at 0x%4.4X\n",
13011 + major, minor, adr);
13012 + cfi_send_gen_cmd(0xf0, 0x5555, base, map, cfi, cfi->device_type, NULL);
13013 +
13014 + cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
13015 + cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
13016 + cfi_send_gen_cmd(0x90, 0x5555, base, map, cfi, cfi->device_type, NULL);
13017 + cfi->mfr = cfi_read_query(map, base);
13018 + cfi->id = cfi_read_query(map, base + ofs_factor);
13019 +
13020 + cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
13021 + cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
13022 + cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL);
13023 +
13024 + switch (cfi->device_type) {
13025 + case CFI_DEVICETYPE_X16:
13026 + cfi->addr_unlock1 = 0x5555;
13027 + cfi->addr_unlock2 = 0x2AAA;
13028 + break;
13029 + default:
13030 + printk(KERN_NOTICE "Eep. Unknown cfi_cmdset_0701 device type %d\n", cfi->device_type);
13031 + return NULL;
13032 + }
13033 + } /* CFI mode */
13034 +
13035 + for (i=0; i< cfi->numchips; i++) {
13036 + cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp;
13037 + cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp;
13038 + cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp;
13039 + }
13040 +
13041 + map->fldrv = &cfi_sststd_chipdrv;
13042 + MOD_INC_USE_COUNT;
13043 +
13044 + cfi_send_gen_cmd(0xf0, 0x5555, base, map, cfi, cfi->device_type, NULL);
13045 + return cfi_sststd_setup(map);
13046 +}
13047 +
13048 +static struct mtd_info *cfi_sststd_setup(struct map_info *map)
13049 +{
13050 + struct cfi_private *cfi = map->fldrv_priv;
13051 + struct mtd_info *mtd;
13052 + unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave;
13053 +
13054 + mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
13055 + printk("number of %s chips: %d\n", (cfi->cfi_mode)?"JEDEC":"CFI",cfi->numchips);
13056 +
13057 + if (!mtd) {
13058 + printk("Failed to allocate memory for MTD device\n");
13059 + kfree(cfi->cmdset_priv);
13060 + return NULL;
13061 + }
13062 +
13063 + memset(mtd, 0, sizeof(*mtd));
13064 + mtd->priv = map;
13065 + mtd->type = MTD_NORFLASH;
13066 + /* Also select the correct geometry setup too */
13067 + mtd->size = devsize * cfi->numchips;
13068 +
13069 + if (cfi->cfiq->NumEraseRegions == 1) {
13070 + /* No need to muck about with multiple erase sizes */
13071 + mtd->erasesize = ((cfi->cfiq->EraseRegionInfo[0] >> 8) & ~0xff) * cfi->interleave;
13072 + } else {
13073 + unsigned long offset = 0;
13074 + int i,j;
13075 +
13076 + mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
13077 + mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) * mtd->numeraseregions, GFP_KERNEL);
13078 + if (!mtd->eraseregions) {
13079 + printk("Failed to allocate memory for MTD erase region info\n");
13080 + kfree(cfi->cmdset_priv);
13081 + return NULL;
13082 + }
13083 +
13084 + for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
13085 + unsigned long ernum, ersize;
13086 + ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
13087 + ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1;
13088 +
13089 + if (mtd->erasesize < ersize) {
13090 + mtd->erasesize = ersize;
13091 + }
13092 + for (j=0; j<cfi->numchips; j++) {
13093 + mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset;
13094 + mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize;
13095 + mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum;
13096 + }
13097 + offset += (ersize * ernum);
13098 + }
13099 +
13100 + // debug
13101 + for (i=0; i<mtd->numeraseregions;i++){
13102 + printk("%d: offset=0x%x,size=0x%x,blocks=%d\n",
13103 + i,mtd->eraseregions[i].offset,
13104 + mtd->eraseregions[i].erasesize,
13105 + mtd->eraseregions[i].numblocks);
13106 + }
13107 + }
13108 +
13109 + switch (CFIDEV_BUSWIDTH)
13110 + {
13111 + case 1:
13112 + case 2:
13113 + case 4:
13114 + if (mtd->numeraseregions > 1)
13115 + mtd->erase = cfi_sststd_erase_varsize;
13116 + else
13117 + mtd->erase = cfi_sststd_erase_onesize;
13118 + mtd->read = cfi_sststd_read;
13119 + mtd->write = cfi_sststd_write;
13120 + break;
13121 +
13122 + default:
13123 + printk("Unsupported buswidth\n");
13124 + kfree(mtd);
13125 + kfree(cfi->cmdset_priv);
13126 + return NULL;
13127 + break;
13128 + }
13129 + mtd->sync = cfi_sststd_sync;
13130 + mtd->suspend = cfi_sststd_suspend;
13131 + mtd->resume = cfi_sststd_resume;
13132 + mtd->flags = MTD_CAP_NORFLASH;
13133 + map->fldrv = &cfi_sststd_chipdrv;
13134 + mtd->name = map->name;
13135 + MOD_INC_USE_COUNT;
13136 + return mtd;
13137 +}
13138 +
13139 +static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf)
13140 +{
13141 + DECLARE_WAITQUEUE(wait, current);
13142 + unsigned long timeo = jiffies + HZ;
13143 +
13144 + retry:
13145 + cfi_spin_lock(chip->mutex);
13146 +
13147 + if (chip->state != FL_READY){
13148 + printk("Waiting for chip to read, status = %d\n", chip->state);
13149 + set_current_state(TASK_UNINTERRUPTIBLE);
13150 + add_wait_queue(&chip->wq, &wait);
13151 +
13152 + cfi_spin_unlock(chip->mutex);
13153 +
13154 + schedule();
13155 + remove_wait_queue(&chip->wq, &wait);
13156 + timeo = jiffies + HZ;
13157 +
13158 + goto retry;
13159 + }
13160 +
13161 + adr += chip->start;
13162 +
13163 + chip->state = FL_READY;
13164 +
13165 + map->copy_from(map, buf, adr, len);
13166 +
13167 + wake_up(&chip->wq);
13168 + cfi_spin_unlock(chip->mutex);
13169 +
13170 + return 0;
13171 +}
13172 +
13173 +static int cfi_sststd_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
13174 +{
13175 + struct map_info *map = mtd->priv;
13176 + struct cfi_private *cfi = map->fldrv_priv;
13177 + unsigned long ofs;
13178 + int chipnum;
13179 + int ret = 0;
13180 +
13181 + /* ofs: offset within the first chip that the first read should start */
13182 +
13183 + chipnum = (from >> cfi->chipshift);
13184 + ofs = from - (chipnum << cfi->chipshift);
13185 +
13186 +
13187 + *retlen = 0;
13188 +
13189 + while (len) {
13190 + unsigned long thislen;
13191 +
13192 + if (chipnum >= cfi->numchips)
13193 + break;
13194 +
13195 + if ((len + ofs -1) >> cfi->chipshift)
13196 + thislen = (1<<cfi->chipshift) - ofs;
13197 + else
13198 + thislen = len;
13199 +
13200 + ret = do_read_onechip(map, &cfi->chips[chipnum], ofs, thislen, buf);
13201 + if (ret)
13202 + break;
13203 +
13204 + *retlen += thislen;
13205 + len -= thislen;
13206 + buf += thislen;
13207 +
13208 + ofs = 0;
13209 + chipnum++;
13210 + }
13211 + return ret;
13212 +}
13213 +
13214 +static int do_write_oneword(struct map_info *map, struct flchip *chip, unsigned long adr, __u32 datum, int fast)
13215 +{
13216 + unsigned long timeo = jiffies + HZ;
13217 + unsigned int Last[4];
13218 + unsigned long Count = 0;
13219 + struct cfi_private *cfi = map->fldrv_priv;
13220 + DECLARE_WAITQUEUE(wait, current);
13221 + int ret = 0;
13222 +
13223 + retry:
13224 + cfi_spin_lock(chip->mutex);
13225 +
13226 + if (chip->state != FL_READY){
13227 + printk("Waiting for chip to write, status = %d\n", chip->state);
13228 + set_current_state(TASK_UNINTERRUPTIBLE);
13229 + add_wait_queue(&chip->wq, &wait);
13230 +
13231 + cfi_spin_unlock(chip->mutex);
13232 +
13233 + schedule();
13234 + remove_wait_queue(&chip->wq, &wait);
13235 + printk("Wake up to write:\n");
13236 + timeo = jiffies + HZ;
13237 +
13238 + goto retry;
13239 + }
13240 +
13241 + chip->state = FL_WRITING;
13242 +
13243 + adr += chip->start;
13244 + ENABLE_VPP(map);
13245 + cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13246 + cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13247 + cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13248 +
13249 + cfi_write(map, datum, adr);
13250 +
13251 + cfi_spin_unlock(chip->mutex);
13252 + cfi_udelay(chip->word_write_time);
13253 + cfi_spin_lock(chip->mutex);
13254 +
13255 + Last[0] = cfi_read(map, adr);
13256 + // printk("Last[0] is %x\n", Last[0]);
13257 + Last[1] = cfi_read(map, adr);
13258 + // printk("Last[1] is %x\n", Last[1]);
13259 + Last[2] = cfi_read(map, adr);
13260 + // printk("Last[2] is %x\n", Last[2]);
13261 +
13262 + for (Count = 3; Last[(Count - 1) % 4] != Last[(Count - 2) % 4] && Count < 10000; Count++){
13263 + cfi_spin_unlock(chip->mutex);
13264 + cfi_udelay(10);
13265 + cfi_spin_lock(chip->mutex);
13266 +
13267 + Last[Count % 4] = cfi_read(map, adr);
13268 + // printk("Last[%d%%4] is %x\n", Count, Last[Count%4]);
13269 + }
13270 +
13271 + if (Last[(Count - 1) % 4] != datum){
13272 + printk("Last[%ld] is %x, datum is %x\n",(Count - 1) % 4,Last[(Count - 1) % 4],datum);
13273 + cfi_send_gen_cmd(0xF0, 0, chip->start, map, cfi, cfi->device_type, NULL);
13274 + DISABLE_VPP(map);
13275 + ret = -EIO;
13276 + }
13277 + DISABLE_VPP(map);
13278 + chip->state = FL_READY;
13279 + wake_up(&chip->wq);
13280 + cfi_spin_unlock(chip->mutex);
13281 +
13282 + return ret;
13283 +}
13284 +
13285 +static int cfi_sststd_write (struct mtd_info *mtd, loff_t to , size_t len, size_t *retlen, const u_char *buf)
13286 +{
13287 + struct map_info *map = mtd->priv;
13288 + struct cfi_private *cfi = map->fldrv_priv;
13289 + int ret = 0;
13290 + int chipnum;
13291 + unsigned long ofs, chipstart;
13292 +
13293 + *retlen = 0;
13294 + if (!len)
13295 + return 0;
13296 +
13297 + chipnum = to >> cfi->chipshift;
13298 + ofs = to - (chipnum << cfi->chipshift);
13299 + chipstart = cfi->chips[chipnum].start;
13300 +
13301 + /* If it's not bus-aligned, do the first byte write */
13302 + if (ofs & (CFIDEV_BUSWIDTH-1)) {
13303 + unsigned long bus_ofs = ofs & ~(CFIDEV_BUSWIDTH-1);
13304 + int i = ofs - bus_ofs;
13305 + int n = 0;
13306 + u_char tmp_buf[4];
13307 + __u32 datum;
13308 +
13309 + map->copy_from(map, tmp_buf, bus_ofs + cfi->chips[chipnum].start, CFIDEV_BUSWIDTH);
13310 + while (len && i < CFIDEV_BUSWIDTH)
13311 + tmp_buf[i++] = buf[n++], len--;
13312 +
13313 + if (cfi_buswidth_is_2()) {
13314 + datum = *(__u16*)tmp_buf;
13315 + } else if (cfi_buswidth_is_4()) {
13316 + datum = *(__u32*)tmp_buf;
13317 + } else {
13318 + return -EINVAL; /* should never happen, but be safe */
13319 + }
13320 +
13321 + ret = do_write_oneword(map, &cfi->chips[chipnum],
13322 + bus_ofs, datum, 0);
13323 + if (ret)
13324 + return ret;
13325 +
13326 + ofs += n;
13327 + buf += n;
13328 + (*retlen) += n;
13329 +
13330 + if (ofs >> cfi->chipshift) {
13331 + chipnum ++;
13332 + ofs = 0;
13333 + if (chipnum == cfi->numchips)
13334 + return 0;
13335 + }
13336 + }
13337 +
13338 + /* We are now aligned, write as much as possible */
13339 + while(len >= CFIDEV_BUSWIDTH) {
13340 + __u32 datum;
13341 +
13342 + if (cfi_buswidth_is_1()) {
13343 + datum = *(__u8*)buf;
13344 + } else if (cfi_buswidth_is_2()) {
13345 + datum = *(__u16*)buf;
13346 + } else if (cfi_buswidth_is_4()) {
13347 + datum = *(__u32*)buf;
13348 + } else {
13349 + return -EINVAL;
13350 + }
13351 + ret = do_write_oneword(map, &cfi->chips[chipnum],
13352 + ofs, datum, cfi->fast_prog);
13353 + if (ret) {
13354 + return ret;
13355 + }
13356 +
13357 + ofs += CFIDEV_BUSWIDTH;
13358 + buf += CFIDEV_BUSWIDTH;
13359 + (*retlen) += CFIDEV_BUSWIDTH;
13360 + len -= CFIDEV_BUSWIDTH;
13361 +
13362 + if (ofs >> cfi->chipshift) {
13363 + chipnum ++;
13364 + ofs = 0;
13365 + if (chipnum == cfi->numchips)
13366 + return 0;
13367 + chipstart = cfi->chips[chipnum].start;
13368 + }
13369 + }
13370 +
13371 + if (len & (CFIDEV_BUSWIDTH-1)) {
13372 + int i = 0, n = 0;
13373 + u_char tmp_buf[4];
13374 + __u32 datum;
13375 +
13376 + map->copy_from(map, tmp_buf, ofs + cfi->chips[chipnum].start, CFIDEV_BUSWIDTH);
13377 + while (len--)
13378 + tmp_buf[i++] = buf[n++];
13379 +
13380 + if (cfi_buswidth_is_2()) {
13381 + datum = *(__u16*)tmp_buf;
13382 + } else if (cfi_buswidth_is_4()) {
13383 + datum = *(__u32*)tmp_buf;
13384 + } else {
13385 + return -EINVAL; /* should never happen, but be safe */
13386 + }
13387 +
13388 + ret = do_write_oneword(map, &cfi->chips[chipnum],
13389 + ofs, datum, 0);
13390 + if (ret)
13391 + return ret;
13392 +
13393 + (*retlen) += n;
13394 + }
13395 +
13396 + return 0;
13397 +}
13398 +
13399 +static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr)
13400 +{
13401 + unsigned int status;
13402 + unsigned long timeo = jiffies + HZ;
13403 + struct cfi_private *cfi = map->fldrv_priv;
13404 + unsigned int rdy_mask;
13405 + DECLARE_WAITQUEUE(wait, current);
13406 +
13407 + retry:
13408 + cfi_spin_lock(chip->mutex);
13409 +
13410 + if (chip->state != FL_READY){
13411 + set_current_state(TASK_UNINTERRUPTIBLE);
13412 + add_wait_queue(&chip->wq, &wait);
13413 +
13414 + cfi_spin_unlock(chip->mutex);
13415 +
13416 + schedule();
13417 + remove_wait_queue(&chip->wq, &wait);
13418 + timeo = jiffies + HZ;
13419 +
13420 + goto retry;
13421 + }
13422 +
13423 + chip->state = FL_ERASING;
13424 +
13425 + adr += chip->start;
13426 + ENABLE_VPP(map);
13427 + cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13428 + cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13429 + cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13430 + cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13431 + cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X16, NULL);
13432 + cfi_write(map, CMD(0x30), adr);
13433 +
13434 + timeo = jiffies + (HZ*20);
13435 +
13436 + cfi_spin_unlock(chip->mutex);
13437 + schedule_timeout(HZ);
13438 + cfi_spin_lock(chip->mutex);
13439 +
13440 + rdy_mask = CMD(0x80);
13441 +
13442 + /* Once the state machine's known to be working I'll do that */
13443 +
13444 + while ( ( (status = cfi_read(map,adr)) & rdy_mask ) != rdy_mask ) {
13445 + static int z=0;
13446 +
13447 + if (chip->state != FL_ERASING) {
13448 + /* Someone's suspended the erase. Sleep */
13449 + set_current_state(TASK_UNINTERRUPTIBLE);
13450 + add_wait_queue(&chip->wq, &wait);
13451 +
13452 + cfi_spin_unlock(chip->mutex);
13453 + printk("erase suspended. Sleeping\n");
13454 +
13455 + schedule();
13456 + remove_wait_queue(&chip->wq, &wait);
13457 + timeo = jiffies + (HZ*2);
13458 + cfi_spin_lock(chip->mutex);
13459 + continue;
13460 + }
13461 +
13462 + /* OK Still waiting */
13463 + if (time_after(jiffies, timeo)) {
13464 + chip->state = FL_READY;
13465 + cfi_spin_unlock(chip->mutex);
13466 + printk("waiting for erase to complete timed out.");
13467 + DISABLE_VPP(map);
13468 + return -EIO;
13469 + }
13470 +
13471 + /* Latency issues. Drop the lock, wait a while and retry */
13472 + cfi_spin_unlock(chip->mutex);
13473 +
13474 + z++;
13475 + if ( 0 && !(z % 100 ))
13476 + printk("chip not ready yet after erase. looping\n");
13477 +
13478 + cfi_udelay(1);
13479 +
13480 + cfi_spin_lock(chip->mutex);
13481 + continue;
13482 + }
13483 +
13484 + /* Done and happy. */
13485 + DISABLE_VPP(map);
13486 + chip->state = FL_READY;
13487 + wake_up(&chip->wq);
13488 + cfi_spin_unlock(chip->mutex);
13489 + return 0;
13490 +}
13491 +
13492 +static int cfi_sststd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
13493 +{
13494 + struct map_info *map = mtd->priv;
13495 + struct cfi_private *cfi = map->fldrv_priv;
13496 + unsigned long adr, len;
13497 + int chipnum, ret = 0;
13498 + int i, first;
13499 + struct mtd_erase_region_info *regions = mtd->eraseregions;
13500 +
13501 + if (instr->addr > mtd->size)
13502 + return -EINVAL;
13503 +
13504 + if ((instr->len + instr->addr) > mtd->size)
13505 + return -EINVAL;
13506 +
13507 + /* Check that both start and end of the requested erase are
13508 + * aligned with the erasesize at the appropriate addresses.
13509 + */
13510 +
13511 + i = 0;
13512 +
13513 + /* Skip all erase regions which are ended before the start of
13514 + the requested erase. Actually, to save on the calculations,
13515 + we skip to the first erase region which starts after the
13516 + start of the requested erase, and then go back one.
13517 + */
13518 +
13519 + while (i < mtd->numeraseregions && instr->addr >= regions[i].offset)
13520 + i++;
13521 + i--;
13522 +
13523 + /* OK, now i is pointing at the erase region in which this
13524 + erase request starts. Check the start of the requested
13525 + erase range is aligned with the erase size which is in
13526 + effect here.
13527 + */
13528 +
13529 + if (instr->addr & (regions[i].erasesize-1))
13530 + return -EINVAL;
13531 +
13532 + /* Remember the erase region we start on */
13533 + first = i;
13534 +
13535 + /* Next, check that the end of the requested erase is aligned
13536 + * with the erase region at that address.
13537 + */
13538 +
13539 + while (i<mtd->numeraseregions && (instr->addr + instr->len) >= regions[i].offset)
13540 + i++;
13541 +
13542 + /* As before, drop back one to point at the region in which
13543 + the address actually falls
13544 + */
13545 + i--;
13546 +
13547 + if ((instr->addr + instr->len) & (regions[i].erasesize-1))
13548 + return -EINVAL;
13549 +
13550 + chipnum = instr->addr >> cfi->chipshift;
13551 + adr = instr->addr - (chipnum << cfi->chipshift);
13552 + len = instr->len;
13553 +
13554 + i=first;
13555 +
13556 + while(len) {
13557 + ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr);
13558 +
13559 + if (ret)
13560 + return ret;
13561 +
13562 + adr += regions[i].erasesize;
13563 + len -= regions[i].erasesize;
13564 +
13565 + if (adr % (1<< cfi->chipshift) == ((regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift)))
13566 + i++;
13567 +
13568 + if (adr >> cfi->chipshift) {
13569 + adr = 0;
13570 + chipnum++;
13571 +
13572 + if (chipnum >= cfi->numchips)
13573 + break;
13574 + }
13575 + }
13576 +
13577 + instr->state = MTD_ERASE_DONE;
13578 + if (instr->callback)
13579 + instr->callback(instr);
13580 +
13581 + return 0;
13582 +}
13583 +
13584 +static int cfi_sststd_erase_onesize(struct mtd_info *mtd, struct erase_info *instr)
13585 +{
13586 + struct map_info *map = mtd->priv;
13587 + struct cfi_private *cfi = map->fldrv_priv;
13588 + unsigned long adr, len;
13589 + int chipnum, ret = 0;
13590 +
13591 + if (instr->addr & (mtd->erasesize - 1))
13592 + return -EINVAL;
13593 +
13594 + if (instr->len & (mtd->erasesize -1))
13595 + return -EINVAL;
13596 +
13597 + if ((instr->len + instr->addr) > mtd->size)
13598 + return -EINVAL;
13599 +
13600 + chipnum = instr->addr >> cfi->chipshift;
13601 + adr = instr->addr - (chipnum << cfi->chipshift);
13602 + len = instr->len;
13603 +
13604 + while(len) {
13605 + ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr);
13606 +
13607 + if (ret)
13608 + return ret;
13609 +
13610 + adr += mtd->erasesize;
13611 + len -= mtd->erasesize;
13612 +
13613 + if (adr >> cfi->chipshift) {
13614 + adr = 0;
13615 + chipnum++;
13616 +
13617 + if (chipnum >= cfi->numchips)
13618 + break;
13619 + }
13620 + }
13621 +
13622 + instr->state = MTD_ERASE_DONE;
13623 + if (instr->callback)
13624 + instr->callback(instr);
13625 +
13626 + return 0;
13627 +}
13628 +
13629 +static void cfi_sststd_sync (struct mtd_info *mtd)
13630 +{
13631 + struct map_info *map = mtd->priv;
13632 + struct cfi_private *cfi = map->fldrv_priv;
13633 + int i;
13634 + struct flchip *chip;
13635 + int ret = 0;
13636 + DECLARE_WAITQUEUE(wait, current);
13637 +
13638 + for (i=0; !ret && i<cfi->numchips; i++) {
13639 + chip = &cfi->chips[i];
13640 +
13641 + retry:
13642 + cfi_spin_lock(chip->mutex);
13643 +
13644 + switch(chip->state) {
13645 + case FL_READY:
13646 + case FL_STATUS:
13647 + case FL_CFI_QUERY:
13648 + case FL_JEDEC_QUERY:
13649 + chip->oldstate = chip->state;
13650 + chip->state = FL_SYNCING;
13651 + /* No need to wake_up() on this state change -
13652 + * as the whole point is that nobody can do anything
13653 + * with the chip now anyway.
13654 + */
13655 + case FL_SYNCING:
13656 + cfi_spin_unlock(chip->mutex);
13657 + break;
13658 +
13659 + default:
13660 + /* Not an idle state */
13661 + add_wait_queue(&chip->wq, &wait);
13662 +
13663 + cfi_spin_unlock(chip->mutex);
13664 +
13665 + schedule();
13666 +
13667 + remove_wait_queue(&chip->wq, &wait);
13668 +
13669 + goto retry;
13670 + }
13671 + }
13672 +
13673 + /* Unlock the chips again */
13674 +
13675 + for (i--; i >=0; i--) {
13676 + chip = &cfi->chips[i];
13677 +
13678 + cfi_spin_lock(chip->mutex);
13679 +
13680 + if (chip->state == FL_SYNCING) {
13681 + chip->state = chip->oldstate;
13682 + wake_up(&chip->wq);
13683 + }
13684 + cfi_spin_unlock(chip->mutex);
13685 + }
13686 +}
13687 +
13688 +
13689 +static int cfi_sststd_suspend(struct mtd_info *mtd)
13690 +{
13691 + struct map_info *map = mtd->priv;
13692 + struct cfi_private *cfi = map->fldrv_priv;
13693 + int i;
13694 + struct flchip *chip;
13695 + int ret = 0;
13696 +//printk("suspend\n");
13697 +
13698 + for (i=0; !ret && i<cfi->numchips; i++) {
13699 + chip = &cfi->chips[i];
13700 +
13701 + cfi_spin_lock(chip->mutex);
13702 +
13703 + switch(chip->state) {
13704 + case FL_READY:
13705 + case FL_STATUS:
13706 + case FL_CFI_QUERY:
13707 + case FL_JEDEC_QUERY:
13708 + chip->oldstate = chip->state;
13709 + chip->state = FL_PM_SUSPENDED;
13710 + /* No need to wake_up() on this state change -
13711 + * as the whole point is that nobody can do anything
13712 + * with the chip now anyway.
13713 + */
13714 + case FL_PM_SUSPENDED:
13715 + break;
13716 +
13717 + default:
13718 + ret = -EAGAIN;
13719 + break;
13720 + }
13721 + cfi_spin_unlock(chip->mutex);
13722 + }
13723 +
13724 + /* Unlock the chips again */
13725 +
13726 + if (ret) {
13727 + for (i--; i >=0; i--) {
13728 + chip = &cfi->chips[i];
13729 +
13730 + cfi_spin_lock(chip->mutex);
13731 +
13732 + if (chip->state == FL_PM_SUSPENDED) {
13733 + chip->state = chip->oldstate;
13734 + wake_up(&chip->wq);
13735 + }
13736 + cfi_spin_unlock(chip->mutex);
13737 + }
13738 + }
13739 +
13740 + return ret;
13741 +}
13742 +
13743 +static void cfi_sststd_resume(struct mtd_info *mtd)
13744 +{
13745 + struct map_info *map = mtd->priv;
13746 + struct cfi_private *cfi = map->fldrv_priv;
13747 + int i;
13748 + struct flchip *chip;
13749 +//printk("resume\n");
13750 +
13751 + for (i=0; i<cfi->numchips; i++) {
13752 +
13753 + chip = &cfi->chips[i];
13754 +
13755 + cfi_spin_lock(chip->mutex);
13756 +
13757 + if (chip->state == FL_PM_SUSPENDED) {
13758 + chip->state = FL_READY;
13759 + cfi_write(map, CMD(0xF0), chip->start);
13760 + wake_up(&chip->wq);
13761 + }
13762 + else
13763 + printk("Argh. Chip not in PM_SUSPENDED state upon resume()\n");
13764 +
13765 + cfi_spin_unlock(chip->mutex);
13766 + }
13767 +}
13768 +
13769 +static void cfi_sststd_destroy(struct mtd_info *mtd)
13770 +{
13771 + struct map_info *map = mtd->priv;
13772 + struct cfi_private *cfi = map->fldrv_priv;
13773 + kfree(cfi->cmdset_priv);
13774 + kfree(cfi);
13775 +}
13776 +
13777 +#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE)
13778 +#define cfi_sststd_init init_module
13779 +#define cfi_sststd_exit cleanup_module
13780 +#endif
13781 +
13782 +static char im_name[]="cfi_cmdset_0701";
13783 +
13784 +mod_init_t cfi_sststd_init(void)
13785 +{
13786 + inter_module_register(im_name, THIS_MODULE, &cfi_cmdset_0701);
13787 + return 0;
13788 +}
13789 +
13790 +mod_exit_t cfi_sststd_exit(void)
13791 +{
13792 + inter_module_unregister(im_name);
13793 +}
13794 +
13795 +module_init(cfi_sststd_init);
13796 +module_exit(cfi_sststd_exit);
13797 +
13798 diff -urN linux-2.4.30/drivers/mtd/chips/cfi_probe.c linux-2.4.30.dev/drivers/mtd/chips/cfi_probe.c
13799 --- linux-2.4.30/drivers/mtd/chips/cfi_probe.c 2003-06-13 16:51:34.000000000 +0200
13800 +++ linux-2.4.30.dev/drivers/mtd/chips/cfi_probe.c 2005-08-22 01:34:46.434134592 +0200
13801 @@ -67,8 +67,15 @@
13802 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
13803 cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
13804
13805 - if (!qry_present(map,base,cfi))
13806 - return 0;
13807 + if (!qry_present(map,base,cfi)) {
13808 + /* rather broken SST cfi probe (requires SST unlock) */
13809 + cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
13810 + cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
13811 + cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
13812 + cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL);
13813 + if (!qry_present(map,base,cfi))
13814 + return 0;
13815 + }
13816
13817 if (!cfi->numchips) {
13818 /* This is the first time we're called. Set up the CFI
13819 diff -urN linux-2.4.30/drivers/mtd/chips/gen_probe.c linux-2.4.30.dev/drivers/mtd/chips/gen_probe.c
13820 --- linux-2.4.30/drivers/mtd/chips/gen_probe.c 2003-08-25 13:44:42.000000000 +0200
13821 +++ linux-2.4.30.dev/drivers/mtd/chips/gen_probe.c 2005-08-22 01:34:46.436134288 +0200
13822 @@ -332,9 +332,13 @@
13823 return cfi_cmdset_0002(map, primary);
13824 #endif
13825 #ifdef CONFIG_MTD_CFI_STAA
13826 - case 0x0020:
13827 + case 0x0020:
13828 return cfi_cmdset_0020(map, primary);
13829 #endif
13830 +#ifdef CONFIG_MTD_CFI_SSTSTD
13831 + case 0x0701:
13832 + return cfi_cmdset_0701(map, primary);
13833 +#endif
13834 }
13835
13836 return cfi_cmdset_unknown(map, primary);
13837 diff -urN linux-2.4.30/drivers/mtd/maps/Config.in linux-2.4.30.dev/drivers/mtd/maps/Config.in
13838 --- linux-2.4.30/drivers/mtd/maps/Config.in 2005-08-22 01:29:09.605340352 +0200
13839 +++ linux-2.4.30.dev/drivers/mtd/maps/Config.in 2005-08-22 01:34:46.460130640 +0200
13840 @@ -48,6 +48,7 @@
13841 fi
13842
13843 if [ "$CONFIG_MIPS" = "y" ]; then
13844 + dep_tristate ' CFI Flash device mapped on Broadcom BCM947XX boards' CONFIG_MTD_BCM947XX $CONFIG_MTD_CFI
13845 dep_tristate ' Pb1000 MTD support' CONFIG_MTD_PB1000 $CONFIG_MIPS_PB1000
13846 dep_tristate ' Pb1500 MTD support' CONFIG_MTD_PB1500 $CONFIG_MIPS_PB1500
13847 dep_tristate ' Pb1100 MTD support' CONFIG_MTD_PB1100 $CONFIG_MIPS_PB1100
13848 diff -urN linux-2.4.30/drivers/mtd/maps/Makefile linux-2.4.30.dev/drivers/mtd/maps/Makefile
13849 --- linux-2.4.30/drivers/mtd/maps/Makefile 2005-08-22 01:29:09.606340200 +0200
13850 +++ linux-2.4.30.dev/drivers/mtd/maps/Makefile 2005-08-22 01:34:46.460130640 +0200
13851 @@ -3,6 +3,8 @@
13852 #
13853 # $Id: Makefile,v 1.37 2003/01/24 14:26:38 dwmw2 Exp $
13854
13855 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include
13856 +
13857 BELOW25 := $(shell echo $(PATCHLEVEL) | sed s/[1234]/y/)
13858
13859 ifeq ($(BELOW25),y)
13860 @@ -10,6 +12,7 @@
13861 endif
13862
13863 # Chip mappings
13864 +obj-$(CONFIG_MTD_BCM947XX) += bcm947xx-flash.o
13865 obj-$(CONFIG_MTD_CDB89712) += cdb89712.o
13866 obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o
13867 obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o
13868 diff -urN linux-2.4.30/drivers/mtd/maps/bcm947xx-flash.c linux-2.4.30.dev/drivers/mtd/maps/bcm947xx-flash.c
13869 --- linux-2.4.30/drivers/mtd/maps/bcm947xx-flash.c 1970-01-01 01:00:00.000000000 +0100
13870 +++ linux-2.4.30.dev/drivers/mtd/maps/bcm947xx-flash.c 2005-08-22 01:34:46.459130792 +0200
13871 @@ -0,0 +1,236 @@
13872 +/*
13873 + * Flash mapping for BCM947XX boards
13874 + *
13875 + * Copyright 2004, Broadcom Corporation
13876 + * All Rights Reserved.
13877 + *
13878 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
13879 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13880 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
13881 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
13882 + *
13883 + * $Id: bcm947xx-flash.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
13884 + */
13885 +
13886 +#include <linux/module.h>
13887 +#include <linux/types.h>
13888 +#include <linux/kernel.h>
13889 +#include <asm/io.h>
13890 +#include <linux/mtd/mtd.h>
13891 +#include <linux/mtd/map.h>
13892 +#include <linux/mtd/partitions.h>
13893 +#include <linux/config.h>
13894 +
13895 +#include <typedefs.h>
13896 +#include <bcmnvram.h>
13897 +#include <bcmutils.h>
13898 +#include <sbconfig.h>
13899 +#include <sbchipc.h>
13900 +#include <sbutils.h>
13901 +#include <trxhdr.h>
13902 +
13903 +/* Global SB handle */
13904 +extern void *bcm947xx_sbh;
13905 +extern spinlock_t bcm947xx_sbh_lock;
13906 +
13907 +/* Convenience */
13908 +#define sbh bcm947xx_sbh
13909 +#define sbh_lock bcm947xx_sbh_lock
13910 +
13911 +#ifdef CONFIG_MTD_PARTITIONS
13912 +extern struct mtd_partition * init_mtd_partitions(struct mtd_info *mtd, size_t size);
13913 +#endif
13914 +
13915 +#define WINDOW_ADDR 0x1fc00000
13916 +#define WINDOW_SIZE 0x400000
13917 +#define BUSWIDTH 2
13918 +
13919 +/* e.g., flash=2M or flash=4M */
13920 +static int flash = 0;
13921 +MODULE_PARM(flash, "i");
13922 +static int __init
13923 +bcm947xx_setup(char *str)
13924 +{
13925 + flash = memparse(str, &str);
13926 + return 1;
13927 +}
13928 +__setup("flash=", bcm947xx_setup);
13929 +
13930 +static struct mtd_info *bcm947xx_mtd;
13931 +
13932 +__u8 bcm947xx_map_read8(struct map_info *map, unsigned long ofs)
13933 +{
13934 + if (map->map_priv_2 == 1)
13935 + return __raw_readb(map->map_priv_1 + ofs);
13936 +
13937 + u16 val = __raw_readw(map->map_priv_1 + (ofs & ~1));
13938 + if (ofs & 1)
13939 + return ((val >> 8) & 0xff);
13940 + else
13941 + return (val & 0xff);
13942 +}
13943 +
13944 +__u16 bcm947xx_map_read16(struct map_info *map, unsigned long ofs)
13945 +{
13946 + return __raw_readw(map->map_priv_1 + ofs);
13947 +}
13948 +
13949 +__u32 bcm947xx_map_read32(struct map_info *map, unsigned long ofs)
13950 +{
13951 + return __raw_readl(map->map_priv_1 + ofs);
13952 +}
13953 +
13954 +void bcm947xx_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
13955 +{
13956 + if (len==1) {
13957 + memcpy_fromio(to, map->map_priv_1 + from, len);
13958 + } else {
13959 + int i;
13960 + u16 *dest = (u16 *) to;
13961 + u16 *src = (u16 *) (map->map_priv_1 + from);
13962 + for (i = 0; i < (len / 2); i++) {
13963 + dest[i] = src[i];
13964 + }
13965 + if (len & 1)
13966 + *((u8 *)dest+len-1) = src[i] & 0xff;
13967 + }
13968 +}
13969 +
13970 +void bcm947xx_map_write8(struct map_info *map, __u8 d, unsigned long adr)
13971 +{
13972 + __raw_writeb(d, map->map_priv_1 + adr);
13973 + mb();
13974 +}
13975 +
13976 +void bcm947xx_map_write16(struct map_info *map, __u16 d, unsigned long adr)
13977 +{
13978 + __raw_writew(d, map->map_priv_1 + adr);
13979 + mb();
13980 +}
13981 +
13982 +void bcm947xx_map_write32(struct map_info *map, __u32 d, unsigned long adr)
13983 +{
13984 + __raw_writel(d, map->map_priv_1 + adr);
13985 + mb();
13986 +}
13987 +
13988 +void bcm947xx_map_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
13989 +{
13990 + memcpy_toio(map->map_priv_1 + to, from, len);
13991 +}
13992 +
13993 +struct map_info bcm947xx_map = {
13994 + name: "Physically mapped flash",
13995 + size: WINDOW_SIZE,
13996 + buswidth: BUSWIDTH,
13997 + read8: bcm947xx_map_read8,
13998 + read16: bcm947xx_map_read16,
13999 + read32: bcm947xx_map_read32,
14000 + copy_from: bcm947xx_map_copy_from,
14001 + write8: bcm947xx_map_write8,
14002 + write16: bcm947xx_map_write16,
14003 + write32: bcm947xx_map_write32,
14004 + copy_to: bcm947xx_map_copy_to
14005 +};
14006 +
14007 +#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE)
14008 +#define init_bcm947xx_map init_module
14009 +#define cleanup_bcm947xx_map cleanup_module
14010 +#endif
14011 +
14012 +mod_init_t init_bcm947xx_map(void)
14013 +{
14014 + ulong flags;
14015 + uint coreidx;
14016 + chipcregs_t *cc;
14017 + uint32 fltype;
14018 + uint window_addr = 0, window_size = 0;
14019 + size_t size;
14020 + int ret = 0;
14021 +#ifdef CONFIG_MTD_PARTITIONS
14022 + struct mtd_partition *parts;
14023 + int i;
14024 +#endif
14025 +
14026 + spin_lock_irqsave(&sbh_lock, flags);
14027 + coreidx = sb_coreidx(sbh);
14028 +
14029 + /* Check strapping option if chipcommon exists */
14030 + if ((cc = sb_setcore(sbh, SB_CC, 0))) {
14031 + fltype = readl(&cc->capabilities) & CAP_FLASH_MASK;
14032 + if (fltype == PFLASH) {
14033 + bcm947xx_map.map_priv_2 = 1;
14034 + window_addr = 0x1c000000;
14035 + bcm947xx_map.size = window_size = 32 * 1024 * 1024;
14036 + if ((readl(&cc->flash_config) & CC_CFG_DS) == 0)
14037 + bcm947xx_map.buswidth = 1;
14038 + }
14039 + } else {
14040 + fltype = PFLASH;
14041 + bcm947xx_map.map_priv_2 = 0;
14042 + window_addr = WINDOW_ADDR;
14043 + window_size = WINDOW_SIZE;
14044 + }
14045 +
14046 + sb_setcoreidx(sbh, coreidx);
14047 + spin_unlock_irqrestore(&sbh_lock, flags);
14048 +
14049 + if (fltype != PFLASH) {
14050 + printk(KERN_ERR "pflash: found no supported devices\n");
14051 + ret = -ENODEV;
14052 + goto fail;
14053 + }
14054 +
14055 + bcm947xx_map.map_priv_1 = (unsigned long) ioremap(window_addr, window_size);
14056 + if (!bcm947xx_map.map_priv_1) {
14057 + printk(KERN_ERR "pflash: ioremap failed\n");
14058 + ret = -EIO;
14059 + goto fail;
14060 + }
14061 +
14062 + if (!(bcm947xx_mtd = do_map_probe("cfi_probe", &bcm947xx_map))) {
14063 + printk(KERN_ERR "pflash: cfi_probe failed\n");
14064 + ret = -ENXIO;
14065 + goto fail;
14066 + }
14067 +
14068 + bcm947xx_mtd->module = THIS_MODULE;
14069 +
14070 + /* Allow size override for testing */
14071 + size = flash ? : bcm947xx_mtd->size;
14072 +
14073 + printk(KERN_NOTICE "Flash device: 0x%x at 0x%x\n", size, window_addr);
14074 +
14075 +#ifdef CONFIG_MTD_PARTITIONS
14076 + parts = init_mtd_partitions(bcm947xx_mtd, size);
14077 + for (i = 0; parts[i].name; i++);
14078 + ret = add_mtd_partitions(bcm947xx_mtd, parts, i);
14079 + if (ret) {
14080 + printk(KERN_ERR "pflash: add_mtd_partitions failed\n");
14081 + goto fail;
14082 + }
14083 +#endif
14084 +
14085 + return 0;
14086 +
14087 + fail:
14088 + if (bcm947xx_mtd)
14089 + map_destroy(bcm947xx_mtd);
14090 + if (bcm947xx_map.map_priv_1)
14091 + iounmap((void *) bcm947xx_map.map_priv_1);
14092 + bcm947xx_map.map_priv_1 = 0;
14093 + return ret;
14094 +}
14095 +
14096 +mod_exit_t cleanup_bcm947xx_map(void)
14097 +{
14098 +#ifdef CONFIG_MTD_PARTITIONS
14099 + del_mtd_partitions(bcm947xx_mtd);
14100 +#endif
14101 + map_destroy(bcm947xx_mtd);
14102 + iounmap((void *) bcm947xx_map.map_priv_1);
14103 + bcm947xx_map.map_priv_1 = 0;
14104 +}
14105 +
14106 +module_init(init_bcm947xx_map);
14107 +module_exit(cleanup_bcm947xx_map);
14108 diff -urN linux-2.4.30/drivers/net/Config.in linux-2.4.30.dev/drivers/net/Config.in
14109 --- linux-2.4.30/drivers/net/Config.in 2005-08-22 01:29:11.903990904 +0200
14110 +++ linux-2.4.30.dev/drivers/net/Config.in 2005-08-22 01:34:46.485126840 +0200
14111 @@ -2,6 +2,8 @@
14112 # Network device configuration
14113 #
14114
14115 +tristate 'Broadcom Home Network Division' CONFIG_HND $CONFIG_PCI
14116 +
14117 source drivers/net/arcnet/Config.in
14118
14119 tristate 'Dummy net driver support' CONFIG_DUMMY
14120 @@ -174,6 +176,7 @@
14121
14122 dep_tristate ' Apricot Xen-II on board Ethernet' CONFIG_APRICOT $CONFIG_ISA
14123 dep_tristate ' Broadcom 4400 ethernet support (EXPERIMENTAL)' CONFIG_B44 $CONFIG_PCI $CONFIG_EXPERIMENTAL
14124 + dep_tristate ' Proprietary Broadcom 10/100 Ethernet support' CONFIG_ET $CONFIG_PCI
14125 dep_tristate ' CS89x0 support' CONFIG_CS89x0 $CONFIG_ISA
14126 dep_tristate ' DECchip Tulip (dc21x4x) PCI support' CONFIG_TULIP $CONFIG_PCI
14127 if [ "$CONFIG_TULIP" = "y" -o "$CONFIG_TULIP" = "m" ]; then
14128 diff -urN linux-2.4.30/drivers/net/Makefile linux-2.4.30.dev/drivers/net/Makefile
14129 --- linux-2.4.30/drivers/net/Makefile 2005-08-22 01:29:11.306081800 +0200
14130 +++ linux-2.4.30.dev/drivers/net/Makefile 2005-08-22 01:41:45.930653216 +0200
14131 @@ -3,6 +3,8 @@
14132 # Makefile for the Linux network (ethercard) device drivers.
14133 #
14134
14135 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include
14136 +
14137 obj-y :=
14138 obj-m :=
14139 obj-n :=
14140 @@ -39,6 +41,9 @@
14141 obj-$(CONFIG_ISDN) += slhc.o
14142 endif
14143
14144 +subdir-$(CONFIG_HND) += hnd
14145 +subdir-$(CONFIG_ET) += et
14146 +subdir-$(CONFIG_WL) += wl
14147 subdir-$(CONFIG_NET_PCMCIA) += pcmcia
14148 subdir-$(CONFIG_NET_WIRELESS) += wireless
14149 subdir-$(CONFIG_TULIP) += tulip
14150 @@ -69,6 +74,16 @@
14151 obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o
14152 obj-$(CONFIG_SUNGEM) += sungem.o
14153
14154 +ifeq ($(CONFIG_HND),y)
14155 + obj-y += hnd/hnd.o
14156 +endif
14157 +ifeq ($(CONFIG_ET),y)
14158 + obj-y += et/et.o
14159 +endif
14160 +ifeq ($(CONFIG_WL),y)
14161 + obj-y += wl/wl.o
14162 +endif
14163 +
14164 obj-$(CONFIG_MACE) += mace.o
14165 obj-$(CONFIG_BMAC) += bmac.o
14166 obj-$(CONFIG_GMAC) += gmac.o
14167 @@ -266,6 +281,7 @@
14168 endif
14169 endif
14170
14171 +
14172 include $(TOPDIR)/Rules.make
14173
14174 clean:
14175 diff -urN linux-2.4.30/drivers/net/et/Makefile linux-2.4.30.dev/drivers/net/et/Makefile
14176 --- linux-2.4.30/drivers/net/et/Makefile 1970-01-01 01:00:00.000000000 +0100
14177 +++ linux-2.4.30.dev/drivers/net/et/Makefile 2005-08-22 01:34:46.505123800 +0200
14178 @@ -0,0 +1,21 @@
14179 +#
14180 +# Makefile for the Broadcom et driver
14181 +#
14182 +# Copyright 2004, Broadcom Corporation
14183 +# All Rights Reserved.
14184 +#
14185 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14186 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14187 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14188 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14189 +#
14190 +# $Id: Makefile,v 1.1 2005/03/16 13:50:00 wbx Exp $
14191 +#
14192 +
14193 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCM47XX_CHOPS -DDMA -DBCMDRIVER
14194 +
14195 +O_TARGET := et.o
14196 +obj-y := et_linux.o etc.o etc47xx.o etc_robo.o etc_adm.o
14197 +obj-m := $(O_TARGET)
14198 +
14199 +include $(TOPDIR)/Rules.make
14200 diff -urN linux-2.4.30/drivers/net/hnd/Makefile linux-2.4.30.dev/drivers/net/hnd/Makefile
14201 --- linux-2.4.30/drivers/net/hnd/Makefile 1970-01-01 01:00:00.000000000 +0100
14202 +++ linux-2.4.30.dev/drivers/net/hnd/Makefile 2005-08-22 01:34:46.511122888 +0200
14203 @@ -0,0 +1,19 @@
14204 +#
14205 +# Makefile for the BCM47xx specific kernel interface routines
14206 +# under Linux.
14207 +#
14208 +
14209 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
14210 +
14211 +O_TARGET := hnd.o
14212 +
14213 +HND_OBJS := bcmutils.o hnddma.o linux_osl.o sbutils.o bcmsrom.o
14214 +
14215 +export-objs := shared_ksyms.o
14216 +obj-y := shared_ksyms.o $(HND_OBJS)
14217 +obj-m := $(O_TARGET)
14218 +
14219 +include $(TOPDIR)/Rules.make
14220 +
14221 +shared_ksyms.c: shared_ksyms.sh $(HND_OBJS)
14222 + sh -e $< $(HND_OBJS) > $@
14223 diff -urN linux-2.4.30/drivers/net/hnd/bcmsrom.c linux-2.4.30.dev/drivers/net/hnd/bcmsrom.c
14224 --- linux-2.4.30/drivers/net/hnd/bcmsrom.c 1970-01-01 01:00:00.000000000 +0100
14225 +++ linux-2.4.30.dev/drivers/net/hnd/bcmsrom.c 2005-08-22 01:34:46.507123496 +0200
14226 @@ -0,0 +1,714 @@
14227 +/*
14228 + * Misc useful routines to access NIC SROM/OTP .
14229 + *
14230 + * Copyright 2004, Broadcom Corporation
14231 + * All Rights Reserved.
14232 + *
14233 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14234 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14235 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14236 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14237 + * $Id$
14238 + */
14239 +
14240 +#include <typedefs.h>
14241 +#include <osl.h>
14242 +#include <bcmutils.h>
14243 +#include <bcmsrom.h>
14244 +#include <bcmdevs.h>
14245 +#include <bcmendian.h>
14246 +#include <sbpcmcia.h>
14247 +#include <pcicfg.h>
14248 +#include <sbutils.h>
14249 +
14250 +#include <proto/ethernet.h> /* for sprom content groking */
14251 +
14252 +#define VARS_MAX 4096 /* should be reduced */
14253 +
14254 +#define WRITE_ENABLE_DELAY 500 /* 500 ms after write enable/disable toggle */
14255 +#define WRITE_WORD_DELAY 20 /* 20 ms between each word write */
14256 +
14257 +static int initvars_srom_pci(void *osh, void *curmap, char **vars, int *count);
14258 +static int initvars_cis_pcmcia(void *sbh, void *curmap, void *osh, char **vars, int *count);
14259 +static int srom_parsecis(void *osh, uint8 *cis, char **vars, int *count);
14260 +static int sprom_cmd_pcmcia(void *osh, uint8 cmd);
14261 +static int sprom_read_pcmcia(void *osh, uint16 addr, uint16 *data);
14262 +static int sprom_write_pcmcia(void *osh, uint16 addr, uint16 data);
14263 +static int sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc);
14264 +
14265 +/*
14266 + * Initialize local vars from the right source for this platform.
14267 + * Return 0 on success, nonzero on error.
14268 + */
14269 +int
14270 +srom_var_init(void *sbh, uint bustype, void *curmap, void *osh, char **vars, int *count)
14271 +{
14272 + ASSERT(bustype == BUSTYPE(bustype));
14273 + if (vars == NULL)
14274 + return (0);
14275 +
14276 + switch (BUSTYPE(bustype)) {
14277 + case SB_BUS:
14278 + /* These two could be asserts ... */
14279 + *vars = NULL;
14280 + *count = 0;
14281 + return(0);
14282 +
14283 + case PCI_BUS:
14284 + ASSERT(curmap); /* can not be NULL */
14285 + return(initvars_srom_pci(osh, curmap, vars, count));
14286 +
14287 + case PCMCIA_BUS:
14288 + return(initvars_cis_pcmcia(sbh, curmap, osh, vars, count));
14289 +
14290 +
14291 + default:
14292 + ASSERT(0);
14293 + }
14294 + return (-1);
14295 +}
14296 +
14297 +/* support only 16-bit word read from srom */
14298 +int
14299 +srom_read(uint bustype, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf)
14300 +{
14301 + void *srom;
14302 + uint i, off, nw;
14303 +
14304 + ASSERT(bustype == BUSTYPE(bustype));
14305 +
14306 + /* check input - 16-bit access only */
14307 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
14308 + return 1;
14309 +
14310 + off = byteoff / 2;
14311 + nw = nbytes / 2;
14312 +
14313 + if (BUSTYPE(bustype) == PCI_BUS) {
14314 + if (!curmap)
14315 + return 1;
14316 + srom = (uchar*)curmap + PCI_BAR0_SPROM_OFFSET;
14317 + if (sprom_read_pci(srom, off, buf, nw, FALSE))
14318 + return 1;
14319 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
14320 + for (i = 0; i < nw; i++) {
14321 + if (sprom_read_pcmcia(osh, (uint16)(off + i), (uint16*)(buf + i)))
14322 + return 1;
14323 + }
14324 + } else {
14325 + return 1;
14326 + }
14327 +
14328 + return 0;
14329 +}
14330 +
14331 +/* support only 16-bit word write into srom */
14332 +int
14333 +srom_write(uint bustype, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf)
14334 +{
14335 + uint16 *srom;
14336 + uint i, off, nw, crc_range;
14337 + uint16 image[SPROM_SIZE], *p;
14338 + uint8 crc;
14339 + volatile uint32 val32;
14340 +
14341 + ASSERT(bustype == BUSTYPE(bustype));
14342 +
14343 + /* check input - 16-bit access only */
14344 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
14345 + return 1;
14346 +
14347 + crc_range = (((BUSTYPE(bustype) == PCMCIA_BUS) || (BUSTYPE(bustype) == SDIO_BUS)) ? SPROM_SIZE : SPROM_CRC_RANGE) * 2;
14348 +
14349 + /* if changes made inside crc cover range */
14350 + if (byteoff < crc_range) {
14351 + nw = (((byteoff + nbytes) > crc_range) ? byteoff + nbytes : crc_range) / 2;
14352 + /* read data including entire first 64 words from srom */
14353 + if (srom_read(bustype, curmap, osh, 0, nw * 2, image))
14354 + return 1;
14355 + /* make changes */
14356 + bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes);
14357 + /* calculate crc */
14358 + htol16_buf(image, crc_range);
14359 + crc = ~hndcrc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE);
14360 + ltoh16_buf(image, crc_range);
14361 + image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff);
14362 + p = image;
14363 + off = 0;
14364 + } else {
14365 + p = buf;
14366 + off = byteoff / 2;
14367 + nw = nbytes / 2;
14368 + }
14369 +
14370 + if (BUSTYPE(bustype) == PCI_BUS) {
14371 + srom = (uint16*)((uchar*)curmap + PCI_BAR0_SPROM_OFFSET);
14372 + /* enable writes to the SPROM */
14373 + val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32));
14374 + val32 |= SPROM_WRITEEN;
14375 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32);
14376 + bcm_mdelay(WRITE_ENABLE_DELAY);
14377 + /* write srom */
14378 + for (i = 0; i < nw; i++) {
14379 + W_REG(&srom[off + i], p[i]);
14380 + bcm_mdelay(WRITE_WORD_DELAY);
14381 + }
14382 + /* disable writes to the SPROM */
14383 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 & ~SPROM_WRITEEN);
14384 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
14385 + /* enable writes to the SPROM */
14386 + if (sprom_cmd_pcmcia(osh, SROM_WEN))
14387 + return 1;
14388 + bcm_mdelay(WRITE_ENABLE_DELAY);
14389 + /* write srom */
14390 + for (i = 0; i < nw; i++) {
14391 + sprom_write_pcmcia(osh, (uint16)(off + i), p[i]);
14392 + bcm_mdelay(WRITE_WORD_DELAY);
14393 + }
14394 + /* disable writes to the SPROM */
14395 + if (sprom_cmd_pcmcia(osh, SROM_WDS))
14396 + return 1;
14397 + } else {
14398 + return 1;
14399 + }
14400 +
14401 + bcm_mdelay(WRITE_ENABLE_DELAY);
14402 + return 0;
14403 +}
14404 +
14405 +
14406 +static int
14407 +srom_parsecis(void *osh, uint8 *cis, char **vars, int *count)
14408 +{
14409 + char eabuf[32];
14410 + char *vp, *base;
14411 + uint8 tup, tlen, sromrev = 1;
14412 + int i, j;
14413 + uint varsize;
14414 + bool ag_init = FALSE;
14415 + uint16 w;
14416 +
14417 + ASSERT(vars);
14418 + ASSERT(count);
14419 +
14420 + base = vp = MALLOC(osh, VARS_MAX);
14421 + ASSERT(vp);
14422 +
14423 + i = 0;
14424 + do {
14425 + tup = cis[i++];
14426 + tlen = cis[i++];
14427 + if ((i + tlen) >= CIS_SIZE)
14428 + break;
14429 +
14430 + switch (tup) {
14431 + case CISTPL_MANFID:
14432 + vp += sprintf(vp, "manfid=%d", (cis[i + 1] << 8) + cis[i]);
14433 + vp++;
14434 + vp += sprintf(vp, "prodid=%d", (cis[i + 3] << 8) + cis[i + 2]);
14435 + vp++;
14436 + break;
14437 +
14438 + case CISTPL_FUNCE:
14439 + if (cis[i] == LAN_NID) {
14440 + ASSERT(cis[i + 1] == ETHER_ADDR_LEN);
14441 + bcm_ether_ntoa((uchar*)&cis[i + 2], eabuf);
14442 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
14443 + vp++;
14444 + }
14445 + break;
14446 +
14447 + case CISTPL_CFTABLE:
14448 + vp += sprintf(vp, "regwindowsz=%d", (cis[i + 7] << 8) | cis[i + 6]);
14449 + vp++;
14450 + break;
14451 +
14452 + case CISTPL_BRCM_HNBU:
14453 + switch (cis[i]) {
14454 + case HNBU_CHIPID:
14455 + vp += sprintf(vp, "vendid=%d", (cis[i + 2] << 8) + cis[i + 1]);
14456 + vp++;
14457 + vp += sprintf(vp, "devid=%d", (cis[i + 4] << 8) + cis[i + 3]);
14458 + vp++;
14459 + if (tlen == 7) {
14460 + vp += sprintf(vp, "chiprev=%d", (cis[i + 6] << 8) + cis[i + 5]);
14461 + vp++;
14462 + }
14463 + break;
14464 +
14465 + case HNBU_BOARDREV:
14466 + vp += sprintf(vp, "boardrev=%d", cis[i + 1]);
14467 + vp++;
14468 + break;
14469 +
14470 + case HNBU_AA:
14471 + vp += sprintf(vp, "aa0=%d", cis[i + 1]);
14472 + vp++;
14473 + break;
14474 +
14475 + case HNBU_AG:
14476 + vp += sprintf(vp, "ag0=%d", cis[i + 1]);
14477 + vp++;
14478 + ag_init = TRUE;
14479 + break;
14480 +
14481 + case HNBU_CC:
14482 + vp += sprintf(vp, "cc=%d", cis[i + 1]);
14483 + vp++;
14484 + break;
14485 +
14486 + case HNBU_PAPARMS:
14487 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + tlen - 1]);
14488 + vp++;
14489 + if (tlen == 9) {
14490 + /* New version */
14491 + for (j = 0; j < 3; j++) {
14492 + vp += sprintf(vp, "pa0b%d=%d", j,
14493 + (cis[i + (j * 2) + 2] << 8) + cis[i + (j * 2) + 1]);
14494 + vp++;
14495 + }
14496 + vp += sprintf(vp, "pa0itssit=%d", cis[i + 7]);
14497 + vp++;
14498 + }
14499 + break;
14500 +
14501 + case HNBU_OEM:
14502 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
14503 + cis[i + 1], cis[i + 2], cis[i + 3], cis[i + 4],
14504 + cis[i + 5], cis[i + 6], cis[i + 7], cis[i + 8]);
14505 + vp++;
14506 + break;
14507 + case HNBU_BOARDFLAGS:
14508 + w = (cis[i + 2] << 8) + cis[i + 1];
14509 + if (w == 0xffff) w = 0;
14510 + vp += sprintf(vp, "boardflags=%d", w);
14511 + vp++;
14512 + break;
14513 + case HNBU_LED:
14514 + if (cis[i + 1] != 0xff) {
14515 + vp += sprintf(vp, "wl0gpio0=%d", cis[i + 1]);
14516 + vp++;
14517 + }
14518 + if (cis[i + 2] != 0xff) {
14519 + vp += sprintf(vp, "wl0gpio1=%d", cis[i + 2]);
14520 + vp++;
14521 + }
14522 + if (cis[i + 3] != 0xff) {
14523 + vp += sprintf(vp, "wl0gpio2=%d", cis[i + 3]);
14524 + vp++;
14525 + }
14526 + if (cis[i + 4] != 0xff) {
14527 + vp += sprintf(vp, "wl0gpio3=%d", cis[i + 4]);
14528 + vp++;
14529 + }
14530 + break;
14531 + }
14532 + break;
14533 +
14534 + }
14535 + i += tlen;
14536 + } while (tup != 0xff);
14537 +
14538 + /* Set the srom version */
14539 + vp += sprintf(vp, "sromrev=%d", sromrev);
14540 + vp++;
14541 +
14542 + /* For now just set boardflags2 to zero */
14543 + vp += sprintf(vp, "boardflags2=0");
14544 + vp++;
14545 +
14546 + /* if there is no antenna gain field, set default */
14547 + if (ag_init == FALSE) {
14548 + vp += sprintf(vp, "ag0=%d", 0xff);
14549 + vp++;
14550 + }
14551 +
14552 + /* final nullbyte terminator */
14553 + *vp++ = '\0';
14554 + varsize = (uint)(vp - base);
14555 +
14556 + ASSERT((vp - base) < VARS_MAX);
14557 +
14558 + if (varsize == VARS_MAX) {
14559 + *vars = base;
14560 + } else {
14561 + vp = MALLOC(osh, varsize);
14562 + ASSERT(vp);
14563 + bcopy(base, vp, varsize);
14564 + MFREE(osh, base, VARS_MAX);
14565 + *vars = vp;
14566 + }
14567 + *count = varsize;
14568 +
14569 + return (0);
14570 +}
14571 +
14572 +
14573 +/* set PCMCIA sprom command register */
14574 +static int
14575 +sprom_cmd_pcmcia(void *osh, uint8 cmd)
14576 +{
14577 + uint8 status = 0;
14578 + uint wait_cnt = 1000;
14579 +
14580 + /* write sprom command register */
14581 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_CS, &cmd, 1);
14582 +
14583 + /* wait status */
14584 + while (wait_cnt--) {
14585 + OSL_PCMCIA_READ_ATTR(osh, SROM_CS, &status, 1);
14586 + if (status & SROM_DONE)
14587 + return 0;
14588 + }
14589 +
14590 + return 1;
14591 +}
14592 +
14593 +/* read a word from the PCMCIA srom */
14594 +static int
14595 +sprom_read_pcmcia(void *osh, uint16 addr, uint16 *data)
14596 +{
14597 + uint8 addr_l, addr_h, data_l, data_h;
14598 +
14599 + addr_l = (uint8)((addr * 2) & 0xff);
14600 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
14601 +
14602 + /* set address */
14603 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
14604 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
14605 +
14606 + /* do read */
14607 + if (sprom_cmd_pcmcia(osh, SROM_READ))
14608 + return 1;
14609 +
14610 + /* read data */
14611 + data_h = data_l = 0;
14612 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAH, &data_h, 1);
14613 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAL, &data_l, 1);
14614 +
14615 + *data = (data_h << 8) | data_l;
14616 + return 0;
14617 +}
14618 +
14619 +/* write a word to the PCMCIA srom */
14620 +static int
14621 +sprom_write_pcmcia(void *osh, uint16 addr, uint16 data)
14622 +{
14623 + uint8 addr_l, addr_h, data_l, data_h;
14624 +
14625 + addr_l = (uint8)((addr * 2) & 0xff);
14626 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
14627 + data_l = (uint8)(data & 0xff);
14628 + data_h = (uint8)((data >> 8) & 0xff);
14629 +
14630 + /* set address */
14631 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
14632 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
14633 +
14634 + /* write data */
14635 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAH, &data_h, 1);
14636 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAL, &data_l, 1);
14637 +
14638 + /* do write */
14639 + return sprom_cmd_pcmcia(osh, SROM_WRITE);
14640 +}
14641 +
14642 +/*
14643 + * Read in and validate sprom.
14644 + * Return 0 on success, nonzero on error.
14645 + */
14646 +static int
14647 +sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc)
14648 +{
14649 + uint8 chk8;
14650 + uint i;
14651 +
14652 + /* read the sprom */
14653 + for (i = 0; i < nwords; i++)
14654 + buf[i] = R_REG(&sprom[wordoff + i]);
14655 +
14656 + if (check_crc) {
14657 + /* fixup the endianness so crc8 will pass */
14658 + htol16_buf(buf, nwords * 2);
14659 + if ((chk8 = hndcrc8((uchar*)buf, nwords * 2, CRC8_INIT_VALUE)) != CRC8_GOOD_VALUE)
14660 + return (1);
14661 + /* now correct the endianness of the byte array */
14662 + ltoh16_buf(buf, nwords * 2);
14663 + }
14664 +
14665 + return (0);
14666 +}
14667 +
14668 +/*
14669 + * Initialize nonvolatile variable table from sprom.
14670 + * Return 0 on success, nonzero on error.
14671 + */
14672 +
14673 +static int
14674 +initvars_srom_pci(void *osh, void *curmap, char **vars, int *count)
14675 +{
14676 + uint16 w, b[64];
14677 + uint8 sromrev;
14678 + struct ether_addr ea;
14679 + char eabuf[32];
14680 + uint32 bfl;
14681 + int c, woff, i;
14682 + char *vp, *base;
14683 +
14684 + if (sprom_read_pci((void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, sizeof(b)/sizeof(b[0]), TRUE))
14685 + return (-1);
14686 +
14687 + /* top word of sprom contains version and crc8 */
14688 + sromrev = b[63] & 0xff;
14689 + /* bcm4401 sroms misprogrammed */
14690 + if (sromrev == 0x10)
14691 + sromrev = 1;
14692 + if ((sromrev != 1) && (sromrev != 2))
14693 + return (-2);
14694 +
14695 + ASSERT(vars);
14696 + ASSERT(count);
14697 +
14698 + base = vp = MALLOC(osh, VARS_MAX);
14699 + ASSERT(vp);
14700 +
14701 + vp += sprintf(vp, "sromrev=%d", sromrev);
14702 + vp++;
14703 +
14704 + if (sromrev >= 2) {
14705 + /* New section takes over the 4th hardware function space */
14706 +
14707 + /* Word 29 is max power 11a high/low */
14708 + w = b[29];
14709 + vp += sprintf(vp, "pa1himaxpwr=%d", w & 0xff);
14710 + vp++;
14711 + vp += sprintf(vp, "pa1lomaxpwr=%d", (w >> 8) & 0xff);
14712 + vp++;
14713 +
14714 + /* Words 30-32 set the 11alow pa settings,
14715 + * 33-35 are the 11ahigh ones.
14716 + */
14717 + for (i = 0; i < 3; i++) {
14718 + vp += sprintf(vp, "pa1lob%d=%d", i, b[30 + i]);
14719 + vp++;
14720 + vp += sprintf(vp, "pa1hib%d=%d", i, b[33 + i]);
14721 + vp++;
14722 + }
14723 + w = b[59];
14724 + if (w == 0)
14725 + vp += sprintf(vp, "ccode=");
14726 + else
14727 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff));
14728 + vp++;
14729 +
14730 + }
14731 +
14732 + /* parameter section of sprom starts at byte offset 72 */
14733 + woff = 72/2;
14734 +
14735 + /* first 6 bytes are il0macaddr */
14736 + ea.octet[0] = (b[woff] >> 8) & 0xff;
14737 + ea.octet[1] = b[woff] & 0xff;
14738 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
14739 + ea.octet[3] = b[woff+1] & 0xff;
14740 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
14741 + ea.octet[5] = b[woff+2] & 0xff;
14742 + woff += ETHER_ADDR_LEN/2 ;
14743 + bcm_ether_ntoa((uchar*)&ea, eabuf);
14744 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
14745 + vp++;
14746 +
14747 + /* next 6 bytes are et0macaddr */
14748 + ea.octet[0] = (b[woff] >> 8) & 0xff;
14749 + ea.octet[1] = b[woff] & 0xff;
14750 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
14751 + ea.octet[3] = b[woff+1] & 0xff;
14752 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
14753 + ea.octet[5] = b[woff+2] & 0xff;
14754 + woff += ETHER_ADDR_LEN/2 ;
14755 + bcm_ether_ntoa((uchar*)&ea, eabuf);
14756 + vp += sprintf(vp, "et0macaddr=%s", eabuf);
14757 + vp++;
14758 +
14759 + /* next 6 bytes are et1macaddr */
14760 + ea.octet[0] = (b[woff] >> 8) & 0xff;
14761 + ea.octet[1] = b[woff] & 0xff;
14762 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
14763 + ea.octet[3] = b[woff+1] & 0xff;
14764 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
14765 + ea.octet[5] = b[woff+2] & 0xff;
14766 + woff += ETHER_ADDR_LEN/2 ;
14767 + bcm_ether_ntoa((uchar*)&ea, eabuf);
14768 + vp += sprintf(vp, "et1macaddr=%s", eabuf);
14769 + vp++;
14770 +
14771 + /*
14772 + * Enet phy settings one or two singles or a dual
14773 + * Bits 4-0 : MII address for enet0 (0x1f for not there)
14774 + * Bits 9-5 : MII address for enet1 (0x1f for not there)
14775 + * Bit 14 : Mdio for enet0
14776 + * Bit 15 : Mdio for enet1
14777 + */
14778 + w = b[woff];
14779 + vp += sprintf(vp, "et0phyaddr=%d", (w & 0x1f));
14780 + vp++;
14781 + vp += sprintf(vp, "et1phyaddr=%d", ((w >> 5) & 0x1f));
14782 + vp++;
14783 + vp += sprintf(vp, "et0mdcport=%d", ((w >> 14) & 0x1));
14784 + vp++;
14785 + vp += sprintf(vp, "et1mdcport=%d", ((w >> 15) & 0x1));
14786 + vp++;
14787 +
14788 + /* Word 46 has board rev, antennas 0/1 & Country code/control */
14789 + w = b[46];
14790 + vp += sprintf(vp, "boardrev=%d", w & 0xff);
14791 + vp++;
14792 +
14793 + if (sromrev > 1)
14794 + vp += sprintf(vp, "cctl=%d", (w >> 8) & 0xf);
14795 + else
14796 + vp += sprintf(vp, "cc=%d", (w >> 8) & 0xf);
14797 + vp++;
14798 +
14799 + vp += sprintf(vp, "aa0=%d", (w >> 12) & 0x3);
14800 + vp++;
14801 +
14802 + vp += sprintf(vp, "aa1=%d", (w >> 14) & 0x3);
14803 + vp++;
14804 +
14805 + /* Words 47-49 set the (wl) pa settings */
14806 + woff = 47;
14807 +
14808 + for (i = 0; i < 3; i++) {
14809 + vp += sprintf(vp, "pa0b%d=%d", i, b[woff+i]);
14810 + vp++;
14811 + vp += sprintf(vp, "pa1b%d=%d", i, b[woff+i+6]);
14812 + vp++;
14813 + }
14814 +
14815 + /*
14816 + * Words 50-51 set the customer-configured wl led behavior.
14817 + * 8 bits/gpio pin. High bit: activehi=0, activelo=1;
14818 + * LED behavior values defined in wlioctl.h .
14819 + */
14820 + w = b[50];
14821 + if ((w != 0) && (w != 0xffff)) {
14822 + /* gpio0 */
14823 + vp += sprintf(vp, "wl0gpio0=%d", (w & 0xff));
14824 + vp++;
14825 +
14826 + /* gpio1 */
14827 + vp += sprintf(vp, "wl0gpio1=%d", (w >> 8) & 0xff);
14828 + vp++;
14829 + }
14830 + w = b[51];
14831 + if ((w != 0) && (w != 0xffff)) {
14832 + /* gpio2 */
14833 + vp += sprintf(vp, "wl0gpio2=%d", w & 0xff);
14834 + vp++;
14835 +
14836 + /* gpio3 */
14837 + vp += sprintf(vp, "wl0gpio3=%d", (w >> 8) & 0xff);
14838 + vp++;
14839 + }
14840 +
14841 + /* Word 52 is max power 0/1 */
14842 + w = b[52];
14843 + vp += sprintf(vp, "pa0maxpwr=%d", w & 0xff);
14844 + vp++;
14845 + vp += sprintf(vp, "pa1maxpwr=%d", (w >> 8) & 0xff);
14846 + vp++;
14847 +
14848 + /* Word 56 is idle tssi target 0/1 */
14849 + w = b[56];
14850 + vp += sprintf(vp, "pa0itssit=%d", w & 0xff);
14851 + vp++;
14852 + vp += sprintf(vp, "pa1itssit=%d", (w >> 8) & 0xff);
14853 + vp++;
14854 +
14855 + /* Word 57 is boardflags, if not programmed make it zero */
14856 + bfl = (uint32)b[57];
14857 + if (bfl == 0xffff) bfl = 0;
14858 + if (sromrev > 1) {
14859 + /* Word 28 is boardflags2 */
14860 + bfl |= (uint32)b[28] << 16;
14861 + }
14862 + vp += sprintf(vp, "boardflags=%d", bfl);
14863 + vp++;
14864 +
14865 + /* Word 58 is antenna gain 0/1 */
14866 + w = b[58];
14867 + vp += sprintf(vp, "ag0=%d", w & 0xff);
14868 + vp++;
14869 +
14870 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff);
14871 + vp++;
14872 +
14873 + if (sromrev == 1) {
14874 + /* set the oem string */
14875 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
14876 + ((b[59] >> 8) & 0xff), (b[59] & 0xff),
14877 + ((b[60] >> 8) & 0xff), (b[60] & 0xff),
14878 + ((b[61] >> 8) & 0xff), (b[61] & 0xff),
14879 + ((b[62] >> 8) & 0xff), (b[62] & 0xff));
14880 + vp++;
14881 + } else {
14882 + /* Word 60 OFDM tx power offset from CCK level */
14883 + /* OFDM Power Offset - opo */
14884 + vp += sprintf(vp, "opo=%d", b[60] & 0xff);
14885 + vp++;
14886 + }
14887 +
14888 + /* final nullbyte terminator */
14889 + *vp++ = '\0';
14890 +
14891 + c = (int)(vp - base);
14892 + ASSERT((vp - base) <= VARS_MAX);
14893 +
14894 + if (c == VARS_MAX) {
14895 + *vars = base;
14896 + } else {
14897 + vp = MALLOC(osh, c);
14898 + ASSERT(vp);
14899 + bcopy(base, vp, c);
14900 + MFREE(osh, base, VARS_MAX);
14901 + *vars = vp;
14902 + }
14903 + *count = c;
14904 +
14905 + return (0);
14906 +}
14907 +
14908 +/*
14909 + * Read the cis and call parsecis to initialize the vars.
14910 + * Return 0 on success, nonzero on error.
14911 + */
14912 +static int
14913 +initvars_cis_pcmcia(void *sbh, void *curmap, void *osh, char **vars, int *count)
14914 +{
14915 + uint8 *cis = NULL;
14916 + int rc;
14917 + uint data_sz;
14918 +
14919 + data_sz = (sb_pcmciarev(sbh) == 1) ? (SPROM_SIZE * 2) : CIS_SIZE;
14920 +
14921 + if ((cis = MALLOC(osh, data_sz)) == NULL)
14922 + return (-2);
14923 +
14924 + if (sb_pcmciarev(sbh) == 1) {
14925 + if (srom_read(PCMCIA_BUS, (void *)NULL, osh, 0, data_sz, (uint16 *)cis)) {
14926 + MFREE(osh, cis, data_sz);
14927 + return (-1);
14928 + }
14929 + /* fix up endianess for 16-bit data vs 8-bit parsing */
14930 + ltoh16_buf((uint16 *)cis, data_sz);
14931 + } else
14932 + OSL_PCMCIA_READ_ATTR(osh, 0, cis, data_sz);
14933 +
14934 + rc = srom_parsecis(osh, cis, vars, count);
14935 +
14936 + MFREE(osh, cis, data_sz);
14937 +
14938 + return (rc);
14939 +}
14940 +
14941 diff -urN linux-2.4.30/drivers/net/hnd/bcmutils.c linux-2.4.30.dev/drivers/net/hnd/bcmutils.c
14942 --- linux-2.4.30/drivers/net/hnd/bcmutils.c 1970-01-01 01:00:00.000000000 +0100
14943 +++ linux-2.4.30.dev/drivers/net/hnd/bcmutils.c 2005-08-22 01:34:46.508123344 +0200
14944 @@ -0,0 +1,862 @@
14945 +/*
14946 + * Misc useful OS-independent routines.
14947 + *
14948 + * Copyright 2004, Broadcom Corporation
14949 + * All Rights Reserved.
14950 + *
14951 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14952 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14953 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14954 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14955 + * $Id$
14956 + */
14957 +
14958 +#include <typedefs.h>
14959 +#include <osl.h>
14960 +#include <bcmnvram.h>
14961 +#include <bcmutils.h>
14962 +#include <bcmendian.h>
14963 +#include <bcmdevs.h>
14964 +
14965 +#ifdef BCMDRIVER
14966 +/* copy a pkt buffer chain into a buffer */
14967 +uint
14968 +pktcopy(void *drv, void *p, uint offset, int len, uchar *buf)
14969 +{
14970 + uint n, ret = 0;
14971 +
14972 + if (len < 0)
14973 + len = 4096; /* "infinite" */
14974 +
14975 + /* skip 'offset' bytes */
14976 + for (; p && offset; p = PKTNEXT(drv, p)) {
14977 + if (offset < (uint)PKTLEN(drv, p))
14978 + break;
14979 + offset -= PKTLEN(drv, p);
14980 + }
14981 +
14982 + if (!p)
14983 + return 0;
14984 +
14985 + /* copy the data */
14986 + for (; p && len; p = PKTNEXT(drv, p)) {
14987 + n = MIN((uint)PKTLEN(drv, p) - offset, (uint)len);
14988 + bcopy(PKTDATA(drv, p) + offset, buf, n);
14989 + buf += n;
14990 + len -= n;
14991 + ret += n;
14992 + offset = 0;
14993 + }
14994 +
14995 + return ret;
14996 +}
14997 +
14998 +/* return total length of buffer chain */
14999 +uint
15000 +pkttotlen(void *drv, void *p)
15001 +{
15002 + uint total;
15003 +
15004 + total = 0;
15005 + for (; p; p = PKTNEXT(drv, p))
15006 + total += PKTLEN(drv, p);
15007 + return (total);
15008 +}
15009 +
15010 +void
15011 +pktq_init(struct pktq *q, uint maxlen, const bool prio_map[])
15012 +{
15013 + q->head = q->tail = NULL;
15014 + q->maxlen = maxlen;
15015 + q->len = 0;
15016 + if (prio_map) {
15017 + q->priority = TRUE;
15018 + bcopy(prio_map, q->prio_map, sizeof(q->prio_map));
15019 + }
15020 + else
15021 + q->priority = FALSE;
15022 +}
15023 +
15024 +/* should always check pktq_full before calling pktenq */
15025 +void
15026 +pktenq(struct pktq *q, void *p, bool lifo)
15027 +{
15028 + void *next, *prev;
15029 +
15030 + /* allow 10 pkts slack */
15031 + ASSERT(q->len < (q->maxlen + 10));
15032 +
15033 + /* Queueing chains not allowed */
15034 + ASSERT(PKTLINK(p) == NULL);
15035 +
15036 + /* Queue is empty */
15037 + if (q->tail == NULL) {
15038 + ASSERT(q->head == NULL);
15039 + q->head = q->tail = p;
15040 + }
15041 +
15042 + /* Insert at head or tail */
15043 + else if (q->priority == FALSE) {
15044 + /* Insert at head (LIFO) */
15045 + if (lifo) {
15046 + PKTSETLINK(p, q->head);
15047 + q->head = p;
15048 + }
15049 + /* Insert at tail (FIFO) */
15050 + else {
15051 + ASSERT(PKTLINK(q->tail) == NULL);
15052 + PKTSETLINK(q->tail, p);
15053 + PKTSETLINK(p, NULL);
15054 + q->tail = p;
15055 + }
15056 + }
15057 +
15058 + /* Insert by priority */
15059 + else {
15060 + /* legal priorities 0-7 */
15061 + ASSERT(PKTPRIO(p) <= MAXPRIO);
15062 +
15063 + ASSERT(q->head);
15064 + ASSERT(q->tail);
15065 + /* Shortcut to insertion at tail */
15066 + if (_pktq_pri(q, PKTPRIO(p)) < _pktq_pri(q, PKTPRIO(q->tail)) ||
15067 + (!lifo && _pktq_pri(q, PKTPRIO(p)) <= _pktq_pri(q, PKTPRIO(q->tail)))) {
15068 + prev = q->tail;
15069 + next = NULL;
15070 + }
15071 + /* Insert at head or in the middle */
15072 + else {
15073 + prev = NULL;
15074 + next = q->head;
15075 + }
15076 + /* Walk the queue */
15077 + for (; next; prev = next, next = PKTLINK(next)) {
15078 + /* Priority queue invariant */
15079 + ASSERT(!prev || _pktq_pri(q, PKTPRIO(prev)) >= _pktq_pri(q, PKTPRIO(next)));
15080 + /* Insert at head of string of packets of same priority (LIFO) */
15081 + if (lifo) {
15082 + if (_pktq_pri(q, PKTPRIO(p)) >= _pktq_pri(q, PKTPRIO(next)))
15083 + break;
15084 + }
15085 + /* Insert at tail of string of packets of same priority (FIFO) */
15086 + else {
15087 + if (_pktq_pri(q, PKTPRIO(p)) > _pktq_pri(q, PKTPRIO(next)))
15088 + break;
15089 + }
15090 + }
15091 + /* Insert at tail */
15092 + if (next == NULL) {
15093 + ASSERT(PKTLINK(q->tail) == NULL);
15094 + PKTSETLINK(q->tail, p);
15095 + PKTSETLINK(p, NULL);
15096 + q->tail = p;
15097 + }
15098 + /* Insert in the middle */
15099 + else if (prev) {
15100 + PKTSETLINK(prev, p);
15101 + PKTSETLINK(p, next);
15102 + }
15103 + /* Insert at head */
15104 + else {
15105 + PKTSETLINK(p, q->head);
15106 + q->head = p;
15107 + }
15108 + }
15109 +
15110 + /* List invariants after insertion */
15111 + ASSERT(q->head);
15112 + ASSERT(PKTLINK(q->tail) == NULL);
15113 +
15114 + q->len++;
15115 +}
15116 +
15117 +/* dequeue packet at head */
15118 +void*
15119 +pktdeq(struct pktq *q)
15120 +{
15121 + void *p;
15122 +
15123 + if ((p = q->head)) {
15124 + ASSERT(q->tail);
15125 + q->head = PKTLINK(p);
15126 + PKTSETLINK(p, NULL);
15127 + q->len--;
15128 + if (q->head == NULL)
15129 + q->tail = NULL;
15130 + }
15131 + else {
15132 + ASSERT(q->tail == NULL);
15133 + }
15134 +
15135 + return (p);
15136 +}
15137 +
15138 +/* dequeue packet at tail */
15139 +void*
15140 +pktdeqtail(struct pktq *q)
15141 +{
15142 + void *p;
15143 + void *next, *prev;
15144 +
15145 + if (q->head == q->tail) { /* last packet on queue or queue empty */
15146 + p = q->head;
15147 + q->head = q->tail = NULL;
15148 + q->len = 0;
15149 + return(p);
15150 + }
15151 +
15152 + /* start walk at head */
15153 + prev = NULL;
15154 + next = q->head;
15155 +
15156 + /* Walk the queue to find prev of q->tail */
15157 + for (; next; prev = next, next = PKTLINK(next)) {
15158 + if (next == q->tail)
15159 + break;
15160 + }
15161 +
15162 + ASSERT(prev);
15163 +
15164 + PKTSETLINK(prev, NULL);
15165 + q->tail = prev;
15166 + q->len--;
15167 + p = next;
15168 +
15169 + return (p);
15170 +}
15171 +
15172 +unsigned char bcm_ctype[] = {
15173 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */
15174 + _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 */
15175 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */
15176 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */
15177 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */
15178 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */
15179 + _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */
15180 + _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */
15181 + _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 */
15182 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */
15183 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */
15184 + _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */
15185 + _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 */
15186 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */
15187 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */
15188 + _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */
15189 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
15190 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
15191 + _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 */
15192 + _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 */
15193 + _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 */
15194 + _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 */
15195 + _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 */
15196 + _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 */
15197 +};
15198 +
15199 +uchar
15200 +bcm_toupper(uchar c)
15201 +{
15202 + if (bcm_islower(c))
15203 + c -= 'a'-'A';
15204 + return (c);
15205 +}
15206 +
15207 +ulong
15208 +bcm_strtoul(char *cp, char **endp, uint base)
15209 +{
15210 + ulong result, value;
15211 + bool minus;
15212 +
15213 + minus = FALSE;
15214 +
15215 + while (bcm_isspace(*cp))
15216 + cp++;
15217 +
15218 + if (cp[0] == '+')
15219 + cp++;
15220 + else if (cp[0] == '-') {
15221 + minus = TRUE;
15222 + cp++;
15223 + }
15224 +
15225 + if (base == 0) {
15226 + if (cp[0] == '0') {
15227 + if ((cp[1] == 'x') || (cp[1] == 'X')) {
15228 + base = 16;
15229 + cp = &cp[2];
15230 + } else {
15231 + base = 8;
15232 + cp = &cp[1];
15233 + }
15234 + } else
15235 + base = 10;
15236 + } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) {
15237 + cp = &cp[2];
15238 + }
15239 +
15240 + result = 0;
15241 +
15242 + while (bcm_isxdigit(*cp) &&
15243 + (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) {
15244 + result = result*base + value;
15245 + cp++;
15246 + }
15247 +
15248 + if (minus)
15249 + result = (ulong)(result * -1);
15250 +
15251 + if (endp)
15252 + *endp = (char *)cp;
15253 +
15254 + return (result);
15255 +}
15256 +
15257 +uint
15258 +bcm_atoi(char *s)
15259 +{
15260 + uint n;
15261 +
15262 + n = 0;
15263 +
15264 + while (bcm_isdigit(*s))
15265 + n = (n * 10) + *s++ - '0';
15266 + return (n);
15267 +}
15268 +
15269 +/* return pointer to location of substring 'needle' in 'haystack' */
15270 +char*
15271 +bcmstrstr(char *haystack, char *needle)
15272 +{
15273 + int len, nlen;
15274 + int i;
15275 +
15276 + if ((haystack == NULL) || (needle == NULL))
15277 + return (haystack);
15278 +
15279 + nlen = strlen(needle);
15280 + len = strlen(haystack) - nlen + 1;
15281 +
15282 + for (i = 0; i < len; i++)
15283 + if (bcmp(needle, &haystack[i], nlen) == 0)
15284 + return (&haystack[i]);
15285 + return (NULL);
15286 +}
15287 +
15288 +char*
15289 +bcmstrcat(char *dest, const char *src)
15290 +{
15291 + strcpy(&dest[strlen(dest)], src);
15292 + return (dest);
15293 +}
15294 +
15295 +#if defined(CONFIG_USBRNDIS_RETAIL) || defined(NDIS_MINIPORT_DRIVER)
15296 +/* registry routine buffer preparation utility functions:
15297 + * parameter order is like strncpy, but returns count
15298 + * of bytes copied. Minimum bytes copied is null char(1)/wchar(2)
15299 + */
15300 +ulong
15301 +wchar2ascii(
15302 + char *abuf,
15303 + ushort *wbuf,
15304 + ushort wbuflen,
15305 + ulong abuflen
15306 +)
15307 +{
15308 + ulong copyct = 1;
15309 + ushort i;
15310 +
15311 + if (abuflen == 0)
15312 + return 0;
15313 +
15314 + /* wbuflen is in bytes */
15315 + wbuflen /= sizeof(ushort);
15316 +
15317 + for (i = 0; i < wbuflen; ++i) {
15318 + if (--abuflen == 0)
15319 + break;
15320 + *abuf++ = (char) *wbuf++;
15321 + ++copyct;
15322 + }
15323 + *abuf = '\0';
15324 +
15325 + return copyct;
15326 +}
15327 +#endif
15328 +
15329 +char*
15330 +bcm_ether_ntoa(char *ea, char *buf)
15331 +{
15332 + sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x",
15333 + (uchar)ea[0]&0xff, (uchar)ea[1]&0xff, (uchar)ea[2]&0xff,
15334 + (uchar)ea[3]&0xff, (uchar)ea[4]&0xff, (uchar)ea[5]&0xff);
15335 + return (buf);
15336 +}
15337 +
15338 +/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
15339 +int
15340 +bcm_ether_atoe(char *p, char *ea)
15341 +{
15342 + int i = 0;
15343 +
15344 + for (;;) {
15345 + ea[i++] = (char) bcm_strtoul(p, &p, 16);
15346 + if (!*p++ || i == 6)
15347 + break;
15348 + }
15349 +
15350 + return (i == 6);
15351 +}
15352 +
15353 +void
15354 +bcm_mdelay(uint ms)
15355 +{
15356 + uint i;
15357 +
15358 + for (i = 0; i < ms; i++) {
15359 + OSL_DELAY(1000);
15360 + }
15361 +}
15362 +
15363 +/*
15364 + * Search the name=value vars for a specific one and return its value.
15365 + * Returns NULL if not found.
15366 + */
15367 +char*
15368 +getvar(char *vars, char *name)
15369 +{
15370 + char *s;
15371 + int len;
15372 +
15373 + len = strlen(name);
15374 +
15375 + /* first look in vars[] */
15376 + for (s = vars; s && *s; ) {
15377 + if ((bcmp(s, name, len) == 0) && (s[len] == '='))
15378 + return (&s[len+1]);
15379 +
15380 + while (*s++)
15381 + ;
15382 + }
15383 +
15384 + /* then query nvram */
15385 + return (BCMINIT(nvram_get)(name));
15386 +}
15387 +
15388 +/*
15389 + * Search the vars for a specific one and return its value as
15390 + * an integer. Returns 0 if not found.
15391 + */
15392 +int
15393 +getintvar(char *vars, char *name)
15394 +{
15395 + char *val;
15396 +
15397 + if ((val = getvar(vars, name)) == NULL)
15398 + return (0);
15399 +
15400 + return (bcm_strtoul(val, NULL, 0));
15401 +}
15402 +
15403 +/* Return gpio pin number assigned to the named pin */
15404 +/*
15405 +* Variable should be in format:
15406 +*
15407 +* gpio<N>=pin_name
15408 +*
15409 +* 'def_pin' is returned if there is no such variable found.
15410 +*/
15411 +uint
15412 +getgpiopin(char *vars, char *pin_name, uint def_pin)
15413 +{
15414 + char name[] = "gpioXXXX";
15415 + char *val;
15416 + uint pin;
15417 +
15418 + /* Go thru all possibilities till a match in pin name */
15419 + for (pin = 0; pin < GPIO_NUMPINS; pin ++) {
15420 + sprintf(name, "gpio%d", pin);
15421 + val = getvar(vars, name);
15422 + if (val && !strcmp(val, pin_name))
15423 + return pin;
15424 + }
15425 + return def_pin;
15426 +}
15427 +
15428 +#endif /* #ifdef BCMDRIVER */
15429 +
15430 +/*******************************************************************************
15431 + * crc8
15432 + *
15433 + * Computes a crc8 over the input data using the polynomial:
15434 + *
15435 + * x^8 + x^7 +x^6 + x^4 + x^2 + 1
15436 + *
15437 + * The caller provides the initial value (either CRC8_INIT_VALUE
15438 + * or the previous returned value) to allow for processing of
15439 + * discontiguous blocks of data. When generating the CRC the
15440 + * caller is responsible for complementing the final return value
15441 + * and inserting it into the byte stream. When checking, a final
15442 + * return value of CRC8_GOOD_VALUE indicates a valid CRC.
15443 + *
15444 + * Reference: Dallas Semiconductor Application Note 27
15445 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
15446 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
15447 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
15448 + *
15449 + ******************************************************************************/
15450 +
15451 +static uint8 crc8_table[256] = {
15452 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
15453 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
15454 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
15455 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
15456 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
15457 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
15458 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
15459 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
15460 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
15461 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
15462 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
15463 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
15464 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
15465 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
15466 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
15467 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
15468 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
15469 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
15470 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
15471 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
15472 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
15473 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
15474 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
15475 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
15476 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
15477 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
15478 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
15479 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
15480 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
15481 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
15482 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
15483 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
15484 +};
15485 +
15486 +#define CRC_INNER_LOOP(n, c, x) \
15487 + (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff]
15488 +
15489 +uint8
15490 +hndcrc8(
15491 + uint8 *pdata, /* pointer to array of data to process */
15492 + uint nbytes, /* number of input data bytes to process */
15493 + uint8 crc /* either CRC8_INIT_VALUE or previous return value */
15494 +)
15495 +{
15496 + /* hard code the crc loop instead of using CRC_INNER_LOOP macro
15497 + * to avoid the undefined and unnecessary (uint8 >> 8) operation. */
15498 + while (nbytes-- > 0)
15499 + crc = crc8_table[(crc ^ *pdata++) & 0xff];
15500 +
15501 + return crc;
15502 +}
15503 +
15504 +/*******************************************************************************
15505 + * crc16
15506 + *
15507 + * Computes a crc16 over the input data using the polynomial:
15508 + *
15509 + * x^16 + x^12 +x^5 + 1
15510 + *
15511 + * The caller provides the initial value (either CRC16_INIT_VALUE
15512 + * or the previous returned value) to allow for processing of
15513 + * discontiguous blocks of data. When generating the CRC the
15514 + * caller is responsible for complementing the final return value
15515 + * and inserting it into the byte stream. When checking, a final
15516 + * return value of CRC16_GOOD_VALUE indicates a valid CRC.
15517 + *
15518 + * Reference: Dallas Semiconductor Application Note 27
15519 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
15520 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
15521 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
15522 + *
15523 + ******************************************************************************/
15524 +
15525 +static uint16 crc16_table[256] = {
15526 + 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
15527 + 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
15528 + 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
15529 + 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
15530 + 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
15531 + 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
15532 + 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
15533 + 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
15534 + 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
15535 + 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
15536 + 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
15537 + 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
15538 + 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
15539 + 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
15540 + 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
15541 + 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
15542 + 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
15543 + 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
15544 + 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
15545 + 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
15546 + 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
15547 + 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
15548 + 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
15549 + 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
15550 + 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
15551 + 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
15552 + 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
15553 + 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
15554 + 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
15555 + 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
15556 + 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
15557 + 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
15558 +};
15559 +
15560 +uint16
15561 +hndcrc16(
15562 + uint8 *pdata, /* pointer to array of data to process */
15563 + uint nbytes, /* number of input data bytes to process */
15564 + uint16 crc /* either CRC16_INIT_VALUE or previous return value */
15565 +)
15566 +{
15567 + while (nbytes-- > 0)
15568 + CRC_INNER_LOOP(16, crc, *pdata++);
15569 + return crc;
15570 +}
15571 +
15572 +static uint32 crc32_table[256] = {
15573 + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
15574 + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
15575 + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
15576 + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
15577 + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
15578 + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
15579 + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
15580 + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
15581 + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
15582 + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
15583 + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
15584 + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
15585 + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
15586 + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
15587 + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
15588 + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
15589 + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
15590 + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
15591 + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
15592 + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
15593 + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
15594 + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
15595 + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
15596 + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
15597 + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
15598 + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
15599 + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
15600 + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
15601 + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
15602 + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
15603 + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
15604 + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
15605 + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
15606 + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
15607 + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
15608 + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
15609 + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
15610 + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
15611 + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
15612 + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
15613 + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
15614 + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
15615 + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
15616 + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
15617 + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
15618 + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
15619 + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
15620 + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
15621 + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
15622 + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
15623 + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
15624 + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
15625 + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
15626 + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
15627 + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
15628 + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
15629 + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
15630 + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
15631 + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
15632 + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
15633 + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
15634 + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
15635 + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
15636 + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
15637 +};
15638 +
15639 +uint32
15640 +hndcrc32(
15641 + uint8 *pdata, /* pointer to array of data to process */
15642 + uint nbytes, /* number of input data bytes to process */
15643 + uint32 crc /* either CRC32_INIT_VALUE or previous return value */
15644 +)
15645 +{
15646 + uint8 *pend;
15647 +#ifdef __mips__
15648 + uint8 tmp[4];
15649 + ulong *tptr = (ulong *)tmp;
15650 +
15651 + /* in case the beginning of the buffer isn't aligned */
15652 + pend = (uint8 *)((uint)(pdata + 3) & 0xfffffffc);
15653 + nbytes -= (pend - pdata);
15654 + while (pdata < pend)
15655 + CRC_INNER_LOOP(32, crc, *pdata++);
15656 +
15657 + /* handle bulk of data as 32-bit words */
15658 + pend = pdata + (nbytes & 0xfffffffc);
15659 + while (pdata < pend) {
15660 + *tptr = *((ulong *)pdata)++;
15661 + CRC_INNER_LOOP(32, crc, tmp[0]);
15662 + CRC_INNER_LOOP(32, crc, tmp[1]);
15663 + CRC_INNER_LOOP(32, crc, tmp[2]);
15664 + CRC_INNER_LOOP(32, crc, tmp[3]);
15665 + }
15666 +
15667 + /* 1-3 bytes at end of buffer */
15668 + pend = pdata + (nbytes & 0x03);
15669 + while (pdata < pend)
15670 + CRC_INNER_LOOP(32, crc, *pdata++);
15671 +#else
15672 + pend = pdata + nbytes;
15673 + while (pdata < pend)
15674 + CRC_INNER_LOOP(32, crc, *pdata++);
15675 +#endif
15676 +
15677 + return crc;
15678 +}
15679 +
15680 +#ifdef notdef
15681 +#define CLEN 1499
15682 +#define CBUFSIZ (CLEN+4)
15683 +#define CNBUFS 5
15684 +
15685 +void testcrc32(void)
15686 +{
15687 + uint j,k,l;
15688 + uint8 *buf;
15689 + uint len[CNBUFS];
15690 + uint32 crcr;
15691 + uint32 crc32tv[CNBUFS] =
15692 + {0xd2cb1faa, 0xd385c8fa, 0xf5b4f3f3, 0x55789e20, 0x00343110};
15693 +
15694 + ASSERT((buf = MALLOC(CBUFSIZ*CNBUFS)) != NULL);
15695 +
15696 + /* step through all possible alignments */
15697 + for (l=0;l<=4;l++) {
15698 + for (j=0; j<CNBUFS; j++) {
15699 + len[j] = CLEN;
15700 + for (k=0; k<len[j]; k++)
15701 + *(buf + j*CBUFSIZ + (k+l)) = (j+k) & 0xff;
15702 + }
15703 +
15704 + for (j=0; j<CNBUFS; j++) {
15705 + crcr = crc32(buf + j*CBUFSIZ + l, len[j], CRC32_INIT_VALUE);
15706 + ASSERT(crcr == crc32tv[j]);
15707 + }
15708 + }
15709 +
15710 + MFREE(buf, CBUFSIZ*CNBUFS);
15711 + return;
15712 +}
15713 +#endif
15714 +
15715 +
15716 +/*
15717 + * Advance from the current 1-byte tag/1-byte length/variable-length value
15718 + * triple, to the next, returning a pointer to the next.
15719 + */
15720 +bcm_tlv_t *
15721 +bcm_next_tlv(bcm_tlv_t *elt, int *buflen)
15722 +{
15723 + int len;
15724 +
15725 + /* validate current elt */
15726 + if (*buflen < 2) {
15727 + return NULL;
15728 + }
15729 +
15730 + len = elt->len;
15731 +
15732 + /* validate remaining buflen */
15733 + if (*buflen >= (2 + len + 2)) {
15734 + elt = (bcm_tlv_t*)(elt->data + len);
15735 + *buflen -= (2 + len);
15736 + } else {
15737 + elt = NULL;
15738 + }
15739 +
15740 + return elt;
15741 +}
15742 +
15743 +/*
15744 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
15745 + * triples, returning a pointer to the substring whose first element
15746 + * matches tag
15747 + */
15748 +bcm_tlv_t *
15749 +bcm_parse_tlvs(void *buf, int buflen, uint key)
15750 +{
15751 + bcm_tlv_t *elt;
15752 + int totlen;
15753 +
15754 + elt = (bcm_tlv_t*)buf;
15755 + totlen = buflen;
15756 +
15757 + /* find tagged parameter */
15758 + while (totlen >= 2) {
15759 + int len = elt->len;
15760 +
15761 + /* validate remaining totlen */
15762 + if ((elt->id == key) && (totlen >= (len + 2)))
15763 + return (elt);
15764 +
15765 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
15766 + totlen -= (len + 2);
15767 + }
15768 +
15769 + return NULL;
15770 +}
15771 +
15772 +/*
15773 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
15774 + * triples, returning a pointer to the substring whose first element
15775 + * matches tag. Stop parsing when we see an element whose ID is greater
15776 + * than the target key.
15777 + */
15778 +bcm_tlv_t *
15779 +bcm_parse_ordered_tlvs(void *buf, int buflen, uint key)
15780 +{
15781 + bcm_tlv_t *elt;
15782 + int totlen;
15783 +
15784 + elt = (bcm_tlv_t*)buf;
15785 + totlen = buflen;
15786 +
15787 + /* find tagged parameter */
15788 + while (totlen >= 2) {
15789 + uint id = elt->id;
15790 + int len = elt->len;
15791 +
15792 + /* Punt if we start seeing IDs > than target key */
15793 + if (id > key)
15794 + return(NULL);
15795 +
15796 + /* validate remaining totlen */
15797 + if ((id == key) && (totlen >= (len + 2)))
15798 + return (elt);
15799 +
15800 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
15801 + totlen -= (len + 2);
15802 + }
15803 + return NULL;
15804 +}
15805 +
15806 +
15807 diff -urN linux-2.4.30/drivers/net/hnd/hnddma.c linux-2.4.30.dev/drivers/net/hnd/hnddma.c
15808 --- linux-2.4.30/drivers/net/hnd/hnddma.c 1970-01-01 01:00:00.000000000 +0100
15809 +++ linux-2.4.30.dev/drivers/net/hnd/hnddma.c 2005-08-22 01:34:46.510123040 +0200
15810 @@ -0,0 +1,865 @@
15811 +/*
15812 + * Generic Broadcom Home Networking Division (HND) DMA module.
15813 + * This supports the following chips: BCM42xx, 44xx, 47xx .
15814 + *
15815 + * Copyright 2004, Broadcom Corporation
15816 + * All Rights Reserved.
15817 + *
15818 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
15819 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
15820 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
15821 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
15822 + *
15823 + * $Id$
15824 + */
15825 +
15826 +#include <typedefs.h>
15827 +#include <osl.h>
15828 +#include <bcmendian.h>
15829 +#include <sbconfig.h>
15830 +#include <bcmutils.h>
15831 +
15832 +struct dma_info; /* forward declaration */
15833 +#define di_t struct dma_info
15834 +#include <hnddma.h>
15835 +
15836 +/* debug/trace */
15837 +#define DMA_ERROR(args)
15838 +#define DMA_TRACE(args)
15839 +
15840 +/* default dma message level(if input msg_level pointer is null in dma_attach()) */
15841 +static uint dma_msg_level = 0;
15842 +
15843 +#define MAXNAMEL 8
15844 +#define MAXDD (DMAMAXRINGSZ / sizeof (dmadd_t))
15845 +
15846 +/* dma engine software state */
15847 +typedef struct dma_info {
15848 + hnddma_t hnddma; /* exported structure */
15849 + uint *msg_level; /* message level pointer */
15850 +
15851 + char name[MAXNAMEL]; /* callers name for diag msgs */
15852 + void *drv; /* driver handle */
15853 + void *osh; /* os handle */
15854 + dmaregs_t *regs; /* dma engine registers */
15855 +
15856 + dmadd_t *txd; /* pointer to chip-specific tx descriptor ring */
15857 + uint txin; /* index of next descriptor to reclaim */
15858 + uint txout; /* index of next descriptor to post */
15859 + uint txavail; /* # free tx descriptors */
15860 + void **txp; /* pointer to parallel array of pointers to packets */
15861 + ulong txdpa; /* physical address of descriptor ring */
15862 + uint txdalign; /* #bytes added to alloc'd mem to align txd */
15863 + uint txdalloc; /* #bytes allocated for the ring */
15864 +
15865 + dmadd_t *rxd; /* pointer to chip-specific rx descriptor ring */
15866 + uint rxin; /* index of next descriptor to reclaim */
15867 + uint rxout; /* index of next descriptor to post */
15868 + void **rxp; /* pointer to parallel array of pointers to packets */
15869 + ulong rxdpa; /* physical address of descriptor ring */
15870 + uint rxdalign; /* #bytes added to alloc'd mem to align rxd */
15871 + uint rxdalloc; /* #bytes allocated for the ring */
15872 +
15873 + /* tunables */
15874 + uint ntxd; /* # tx descriptors */
15875 + uint nrxd; /* # rx descriptors */
15876 + uint rxbufsize; /* rx buffer size in bytes */
15877 + uint nrxpost; /* # rx buffers to keep posted */
15878 + uint rxoffset; /* rxcontrol offset */
15879 + uint ddoffset; /* add to get dma address of descriptor ring */
15880 + uint dataoffset; /* add to get dma address of data buffer */
15881 +} dma_info_t;
15882 +
15883 +/* descriptor bumping macros */
15884 +#define XXD(x, n) ((x) & ((n) - 1))
15885 +#define TXD(x) XXD((x), di->ntxd)
15886 +#define RXD(x) XXD((x), di->nrxd)
15887 +#define NEXTTXD(i) TXD(i + 1)
15888 +#define PREVTXD(i) TXD(i - 1)
15889 +#define NEXTRXD(i) RXD(i + 1)
15890 +#define NTXDACTIVE(h, t) TXD(t - h)
15891 +#define NRXDACTIVE(h, t) RXD(t - h)
15892 +
15893 +/* macros to convert between byte offsets and indexes */
15894 +#define B2I(bytes) ((bytes) / sizeof (dmadd_t))
15895 +#define I2B(index) ((index) * sizeof (dmadd_t))
15896 +
15897 +/*
15898 + * This assume the largest i/o address is, in fact, the pci big window
15899 + * and that the pci core sb2pcitranslation2 register has been left with
15900 + * the default 0x0 pci base address.
15901 + */
15902 +#define MAXDMAADDR SB_PCI_DMA_SZ
15903 +#define DMA_ADDRESSABLE(x) !((x) & ~(MAXDMAADDR - 1))
15904 +
15905 +/* prototypes */
15906 +
15907 +void*
15908 +dma_attach(void *drv, void *osh, char *name, dmaregs_t *regs, uint ntxd, uint nrxd,
15909 + uint rxbufsize, uint nrxpost, uint rxoffset, uint ddoffset, uint dataoffset, uint *msg_level)
15910 +{
15911 + dma_info_t *di;
15912 + uint size;
15913 + void *va;
15914 +
15915 + ASSERT(ntxd <= MAXDD);
15916 + ASSERT(ISPOWEROF2(ntxd));
15917 + ASSERT(nrxd <= MAXDD);
15918 + ASSERT(ISPOWEROF2(nrxd));
15919 +
15920 + /* allocate private info structure */
15921 + if ((di = MALLOC(osh, sizeof (dma_info_t))) == NULL) {
15922 + return (NULL);
15923 + }
15924 + bzero((char*)di, sizeof (dma_info_t));
15925 +
15926 + /* allocate tx packet pointer vector */
15927 + if (ntxd) {
15928 + size = ntxd * sizeof (void*);
15929 + if ((di->txp = MALLOC(osh, size)) == NULL)
15930 + goto fail;
15931 + bzero((char*)di->txp, size);
15932 + }
15933 +
15934 + /* allocate rx packet pointer vector */
15935 + if (nrxd) {
15936 + size = nrxd * sizeof (void*);
15937 + if ((di->rxp = MALLOC(osh, size)) == NULL)
15938 + goto fail;
15939 + bzero((char*)di->rxp, size);
15940 + }
15941 +
15942 + /* set message level */
15943 + di->msg_level = msg_level ? msg_level : &dma_msg_level;
15944 +
15945 + 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));
15946 +
15947 + /* make a private copy of our callers name */
15948 + strncpy(di->name, name, MAXNAMEL);
15949 + di->name[MAXNAMEL-1] = '\0';
15950 +
15951 + di->drv = drv;
15952 + di->osh = osh;
15953 + di->regs = regs;
15954 +
15955 + /* allocate transmit descriptor ring */
15956 + if (ntxd) {
15957 + /* only need ntxd descriptors but it must be DMARINGALIGNed */
15958 + size = ntxd * sizeof (dmadd_t);
15959 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, DMARINGALIGN))
15960 + size += DMARINGALIGN;
15961 + if ((va = DMA_ALLOC_CONSISTENT(osh, size, &di->txdpa)) == NULL)
15962 + goto fail;
15963 + di->txd = (dmadd_t*) ROUNDUP((uintptr)va, DMARINGALIGN);
15964 + di->txdalign = (uint)((int8*)di->txd - (int8*)va);
15965 + di->txdpa += di->txdalign;
15966 + di->txdalloc = size;
15967 + ASSERT(ISALIGNED((uintptr)di->txd, DMARINGALIGN));
15968 + ASSERT(DMA_ADDRESSABLE(di->txdpa));
15969 + }
15970 +
15971 + /* allocate receive descriptor ring */
15972 + if (nrxd) {
15973 + /* only need nrxd descriptors but it must be DMARINGALIGNed */
15974 + size = nrxd * sizeof (dmadd_t);
15975 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, DMARINGALIGN))
15976 + size += DMARINGALIGN;
15977 + if ((va = DMA_ALLOC_CONSISTENT(osh, size, &di->rxdpa)) == NULL)
15978 + goto fail;
15979 + di->rxd = (dmadd_t*) ROUNDUP((uintptr)va, DMARINGALIGN);
15980 + di->rxdalign = (uint)((int8*)di->rxd - (int8*)va);
15981 + di->rxdpa += di->rxdalign;
15982 + di->rxdalloc = size;
15983 + ASSERT(ISALIGNED((uintptr)di->rxd, DMARINGALIGN));
15984 + ASSERT(DMA_ADDRESSABLE(di->rxdpa));
15985 + }
15986 +
15987 + /* save tunables */
15988 + di->ntxd = ntxd;
15989 + di->nrxd = nrxd;
15990 + di->rxbufsize = rxbufsize;
15991 + di->nrxpost = nrxpost;
15992 + di->rxoffset = rxoffset;
15993 + di->ddoffset = ddoffset;
15994 + di->dataoffset = dataoffset;
15995 +
15996 + return ((void*)di);
15997 +
15998 +fail:
15999 + dma_detach((void*)di);
16000 + return (NULL);
16001 +}
16002 +
16003 +/* may be called with core in reset */
16004 +void
16005 +dma_detach(dma_info_t *di)
16006 +{
16007 + if (di == NULL)
16008 + return;
16009 +
16010 + DMA_TRACE(("%s: dma_detach\n", di->name));
16011 +
16012 + /* shouldn't be here if descriptors are unreclaimed */
16013 + ASSERT(di->txin == di->txout);
16014 + ASSERT(di->rxin == di->rxout);
16015 +
16016 + /* free dma descriptor rings */
16017 + if (di->txd)
16018 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->txd - di->txdalign),
16019 + di->txdalloc, (di->txdpa - di->txdalign));
16020 + if (di->rxd)
16021 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->rxd - di->rxdalign),
16022 + di->rxdalloc, (di->rxdpa - di->rxdalign));
16023 +
16024 + /* free packet pointer vectors */
16025 + if (di->txp)
16026 + MFREE(di->osh, (void*)di->txp, (di->ntxd * sizeof (void*)));
16027 + if (di->rxp)
16028 + MFREE(di->osh, (void*)di->rxp, (di->nrxd * sizeof (void*)));
16029 +
16030 + /* free our private info structure */
16031 + MFREE(di->osh, (void*)di, sizeof (dma_info_t));
16032 +}
16033 +
16034 +
16035 +void
16036 +dma_txreset(dma_info_t *di)
16037 +{
16038 + uint32 status;
16039 +
16040 + DMA_TRACE(("%s: dma_txreset\n", di->name));
16041 +
16042 + /* suspend tx DMA first */
16043 + W_REG(&di->regs->xmtcontrol, XC_SE);
16044 + SPINWAIT((status = (R_REG(&di->regs->xmtstatus) & XS_XS_MASK)) != XS_XS_DISABLED &&
16045 + status != XS_XS_IDLE &&
16046 + status != XS_XS_STOPPED,
16047 + 10000);
16048 +
16049 + W_REG(&di->regs->xmtcontrol, 0);
16050 + SPINWAIT((status = (R_REG(&di->regs->xmtstatus) & XS_XS_MASK)) != XS_XS_DISABLED,
16051 + 10000);
16052 +
16053 + if (status != XS_XS_DISABLED) {
16054 + DMA_ERROR(("%s: dma_txreset: dma cannot be stopped\n", di->name));
16055 + }
16056 +
16057 + /* wait for the last transaction to complete */
16058 + OSL_DELAY(300);
16059 +}
16060 +
16061 +void
16062 +dma_rxreset(dma_info_t *di)
16063 +{
16064 + uint32 status;
16065 +
16066 + DMA_TRACE(("%s: dma_rxreset\n", di->name));
16067 +
16068 + W_REG(&di->regs->rcvcontrol, 0);
16069 + SPINWAIT((status = (R_REG(&di->regs->rcvstatus) & RS_RS_MASK)) != RS_RS_DISABLED,
16070 + 10000);
16071 +
16072 + if (status != RS_RS_DISABLED) {
16073 + DMA_ERROR(("%s: dma_rxreset: dma cannot be stopped\n", di->name));
16074 + }
16075 +}
16076 +
16077 +void
16078 +dma_txinit(dma_info_t *di)
16079 +{
16080 + DMA_TRACE(("%s: dma_txinit\n", di->name));
16081 +
16082 + di->txin = di->txout = 0;
16083 + di->txavail = di->ntxd - 1;
16084 +
16085 + /* clear tx descriptor ring */
16086 + BZERO_SM((void*)di->txd, (di->ntxd * sizeof (dmadd_t)));
16087 +
16088 + W_REG(&di->regs->xmtcontrol, XC_XE);
16089 + W_REG(&di->regs->xmtaddr, (di->txdpa + di->ddoffset));
16090 +}
16091 +
16092 +bool
16093 +dma_txenabled(dma_info_t *di)
16094 +{
16095 + uint32 xc;
16096 +
16097 + /* If the chip is dead, it is not enabled :-) */
16098 + xc = R_REG(&di->regs->xmtcontrol);
16099 + return ((xc != 0xffffffff) && (xc & XC_XE));
16100 +}
16101 +
16102 +void
16103 +dma_txsuspend(dma_info_t *di)
16104 +{
16105 + DMA_TRACE(("%s: dma_txsuspend\n", di->name));
16106 + OR_REG(&di->regs->xmtcontrol, XC_SE);
16107 +}
16108 +
16109 +void
16110 +dma_txresume(dma_info_t *di)
16111 +{
16112 + DMA_TRACE(("%s: dma_txresume\n", di->name));
16113 + AND_REG(&di->regs->xmtcontrol, ~XC_SE);
16114 +}
16115 +
16116 +bool
16117 +dma_txsuspended(dma_info_t *di)
16118 +{
16119 + if (!(R_REG(&di->regs->xmtcontrol) & XC_SE))
16120 + return 0;
16121 +
16122 + if ((R_REG(&di->regs->xmtstatus) & XS_XS_MASK) != XS_XS_IDLE)
16123 + return 0;
16124 +
16125 + OSL_DELAY(2);
16126 + return ((R_REG(&di->regs->xmtstatus) & XS_XS_MASK) == XS_XS_IDLE);
16127 +}
16128 +
16129 +bool
16130 +dma_txstopped(dma_info_t *di)
16131 +{
16132 + return ((R_REG(&di->regs->xmtstatus) & XS_XS_MASK) == XS_XS_STOPPED);
16133 +}
16134 +
16135 +bool
16136 +dma_rxstopped(dma_info_t *di)
16137 +{
16138 + return ((R_REG(&di->regs->rcvstatus) & RS_RS_MASK) == RS_RS_STOPPED);
16139 +}
16140 +
16141 +void
16142 +dma_fifoloopbackenable(dma_info_t *di)
16143 +{
16144 + DMA_TRACE(("%s: dma_fifoloopbackenable\n", di->name));
16145 + OR_REG(&di->regs->xmtcontrol, XC_LE);
16146 +}
16147 +
16148 +void
16149 +dma_rxinit(dma_info_t *di)
16150 +{
16151 + DMA_TRACE(("%s: dma_rxinit\n", di->name));
16152 +
16153 + di->rxin = di->rxout = 0;
16154 +
16155 + /* clear rx descriptor ring */
16156 + BZERO_SM((void*)di->rxd, (di->nrxd * sizeof (dmadd_t)));
16157 +
16158 + dma_rxenable(di);
16159 + W_REG(&di->regs->rcvaddr, (di->rxdpa + di->ddoffset));
16160 +}
16161 +
16162 +void
16163 +dma_rxenable(dma_info_t *di)
16164 +{
16165 + DMA_TRACE(("%s: dma_rxenable\n", di->name));
16166 + W_REG(&di->regs->rcvcontrol, ((di->rxoffset << RC_RO_SHIFT) | RC_RE));
16167 +}
16168 +
16169 +bool
16170 +dma_rxenabled(dma_info_t *di)
16171 +{
16172 + uint32 rc;
16173 +
16174 + rc = R_REG(&di->regs->rcvcontrol);
16175 + return ((rc != 0xffffffff) && (rc & RC_RE));
16176 +}
16177 +
16178 +/*
16179 + * The BCM47XX family supports full 32bit dma engine buffer addressing so
16180 + * dma buffers can cross 4 Kbyte page boundaries.
16181 + */
16182 +int
16183 +dma_txfast(dma_info_t *di, void *p0, uint32 coreflags)
16184 +{
16185 + void *p, *next;
16186 + uchar *data;
16187 + uint len;
16188 + uint txout;
16189 + uint32 ctrl;
16190 + uint32 pa;
16191 +
16192 + DMA_TRACE(("%s: dma_txfast\n", di->name));
16193 +
16194 + txout = di->txout;
16195 + ctrl = 0;
16196 +
16197 + /*
16198 + * Walk the chain of packet buffers
16199 + * allocating and initializing transmit descriptor entries.
16200 + */
16201 + for (p = p0; p; p = next) {
16202 + data = PKTDATA(di->drv, p);
16203 + len = PKTLEN(di->drv, p);
16204 + next = PKTNEXT(di->drv, p);
16205 +
16206 + /* return nonzero if out of tx descriptors */
16207 + if (NEXTTXD(txout) == di->txin)
16208 + goto outoftxd;
16209 +
16210 + if (len == 0)
16211 + continue;
16212 +
16213 + /* get physical address of buffer start */
16214 + pa = (uint32) DMA_MAP(di->osh, data, len, DMA_TX, p);
16215 + ASSERT(DMA_ADDRESSABLE(pa));
16216 +
16217 + /* build the descriptor control value */
16218 + ctrl = len & CTRL_BC_MASK;
16219 +
16220 + ctrl |= coreflags;
16221 +
16222 + if (p == p0)
16223 + ctrl |= CTRL_SOF;
16224 + if (next == NULL)
16225 + ctrl |= (CTRL_IOC | CTRL_EOF);
16226 + if (txout == (di->ntxd - 1))
16227 + ctrl |= CTRL_EOT;
16228 +
16229 + /* init the tx descriptor */
16230 + W_SM(&di->txd[txout].ctrl, BUS_SWAP32(ctrl));
16231 + W_SM(&di->txd[txout].addr, BUS_SWAP32(pa + di->dataoffset));
16232 +
16233 + ASSERT(di->txp[txout] == NULL);
16234 +
16235 + txout = NEXTTXD(txout);
16236 + }
16237 +
16238 + /* if last txd eof not set, fix it */
16239 + if (!(ctrl & CTRL_EOF))
16240 + W_SM(&di->txd[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF));
16241 +
16242 + /* save the packet */
16243 + di->txp[PREVTXD(txout)] = p0;
16244 +
16245 + /* bump the tx descriptor index */
16246 + di->txout = txout;
16247 +
16248 + /* kick the chip */
16249 + W_REG(&di->regs->xmtptr, I2B(txout));
16250 +
16251 + /* tx flow control */
16252 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16253 +
16254 + return (0);
16255 +
16256 +outoftxd:
16257 + DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name));
16258 + PKTFREE(di->drv, p0, TRUE);
16259 + di->txavail = 0;
16260 + di->hnddma.txnobuf++;
16261 + return (-1);
16262 +}
16263 +
16264 +#define PAGESZ 4096
16265 +#define PAGEBASE(x) ((uintptr)(x) & ~4095)
16266 +
16267 +/*
16268 + * Just like above except go through the extra effort of splitting
16269 + * buffers that cross 4Kbyte boundaries into multiple tx descriptors.
16270 + */
16271 +int
16272 +dma_tx(dma_info_t *di, void *p0, uint32 coreflags)
16273 +{
16274 + void *p, *next;
16275 + uchar *data;
16276 + uint plen, len;
16277 + uchar *page, *start, *end;
16278 + uint txout;
16279 + uint32 ctrl;
16280 + uint32 pa;
16281 +
16282 + DMA_TRACE(("%s: dma_tx\n", di->name));
16283 +
16284 + txout = di->txout;
16285 + ctrl = 0;
16286 +
16287 + /*
16288 + * Walk the chain of packet buffers
16289 + * splitting those that cross 4 Kbyte boundaries
16290 + * allocating and initializing transmit descriptor entries.
16291 + */
16292 + for (p = p0; p; p = next) {
16293 + data = PKTDATA(di->drv, p);
16294 + plen = PKTLEN(di->drv, p);
16295 + next = PKTNEXT(di->drv, p);
16296 +
16297 + if (plen == 0)
16298 + continue;
16299 +
16300 + for (page = (uchar*)PAGEBASE(data);
16301 + page <= (uchar*)PAGEBASE(data + plen - 1);
16302 + page += PAGESZ) {
16303 +
16304 + /* return nonzero if out of tx descriptors */
16305 + if (NEXTTXD(txout) == di->txin)
16306 + goto outoftxd;
16307 +
16308 + start = (page == (uchar*)PAGEBASE(data))? data: page;
16309 + end = (page == (uchar*)PAGEBASE(data + plen))?
16310 + (data + plen): (page + PAGESZ);
16311 + len = (uint)(end - start);
16312 +
16313 + /* build the descriptor control value */
16314 + ctrl = len & CTRL_BC_MASK;
16315 +
16316 + ctrl |= coreflags;
16317 +
16318 + if ((p == p0) && (start == data))
16319 + ctrl |= CTRL_SOF;
16320 + if ((next == NULL) && (end == (data + plen)))
16321 + ctrl |= (CTRL_IOC | CTRL_EOF);
16322 + if (txout == (di->ntxd - 1))
16323 + ctrl |= CTRL_EOT;
16324 +
16325 + /* get physical address of buffer start */
16326 + pa = (uint32) DMA_MAP(di->osh, start, len, DMA_TX, p);
16327 + ASSERT(DMA_ADDRESSABLE(pa));
16328 +
16329 + /* init the tx descriptor */
16330 + W_SM(&di->txd[txout].ctrl, BUS_SWAP32(ctrl));
16331 + W_SM(&di->txd[txout].addr, BUS_SWAP32(pa + di->dataoffset));
16332 +
16333 + ASSERT(di->txp[txout] == NULL);
16334 +
16335 + txout = NEXTTXD(txout);
16336 + }
16337 + }
16338 +
16339 + /* if last txd eof not set, fix it */
16340 + if (!(ctrl & CTRL_EOF))
16341 + W_SM(&di->txd[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF));
16342 +
16343 + /* save the packet */
16344 + di->txp[PREVTXD(txout)] = p0;
16345 +
16346 + /* bump the tx descriptor index */
16347 + di->txout = txout;
16348 +
16349 + /* kick the chip */
16350 + W_REG(&di->regs->xmtptr, I2B(txout));
16351 +
16352 + /* tx flow control */
16353 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16354 +
16355 + return (0);
16356 +
16357 +outoftxd:
16358 + DMA_ERROR(("%s: dma_tx: out of txds\n", di->name));
16359 + PKTFREE(di->drv, p0, TRUE);
16360 + di->txavail = 0;
16361 + di->hnddma.txnobuf++;
16362 + return (-1);
16363 +}
16364 +
16365 +/* returns a pointer to the next frame received, or NULL if there are no more */
16366 +void*
16367 +dma_rx(dma_info_t *di)
16368 +{
16369 + void *p;
16370 + uint len;
16371 + int skiplen = 0;
16372 +
16373 + while ((p = dma_getnextrxp(di, FALSE))) {
16374 + /* skip giant packets which span multiple rx descriptors */
16375 + if (skiplen > 0) {
16376 + skiplen -= di->rxbufsize;
16377 + if (skiplen < 0)
16378 + skiplen = 0;
16379 + PKTFREE(di->drv, p, FALSE);
16380 + continue;
16381 + }
16382 +
16383 + len = ltoh16(*(uint16*)(PKTDATA(di->drv, p)));
16384 + DMA_TRACE(("%s: dma_rx len %d\n", di->name, len));
16385 +
16386 + /* bad frame length check */
16387 + if (len > (di->rxbufsize - di->rxoffset)) {
16388 + DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len));
16389 + if (len > 0)
16390 + skiplen = len - (di->rxbufsize - di->rxoffset);
16391 + PKTFREE(di->drv, p, FALSE);
16392 + di->hnddma.rxgiants++;
16393 + continue;
16394 + }
16395 +
16396 + /* set actual length */
16397 + PKTSETLEN(di->drv, p, (di->rxoffset + len));
16398 +
16399 + break;
16400 + }
16401 +
16402 + return (p);
16403 +}
16404 +
16405 +/* post receive buffers */
16406 +void
16407 +dma_rxfill(dma_info_t *di)
16408 +{
16409 + void *p;
16410 + uint rxin, rxout;
16411 + uint ctrl;
16412 + uint n;
16413 + uint i;
16414 + uint32 pa;
16415 + uint rxbufsize;
16416 +
16417 + /*
16418 + * Determine how many receive buffers we're lacking
16419 + * from the full complement, allocate, initialize,
16420 + * and post them, then update the chip rx lastdscr.
16421 + */
16422 +
16423 + rxin = di->rxin;
16424 + rxout = di->rxout;
16425 + rxbufsize = di->rxbufsize;
16426 +
16427 + n = di->nrxpost - NRXDACTIVE(rxin, rxout);
16428 +
16429 + DMA_TRACE(("%s: dma_rxfill: post %d\n", di->name, n));
16430 +
16431 + for (i = 0; i < n; i++) {
16432 + if ((p = PKTGET(di->drv, rxbufsize, FALSE)) == NULL) {
16433 + DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", di->name));
16434 + di->hnddma.rxnobuf++;
16435 + break;
16436 + }
16437 +
16438 + *(uint32*)(OSL_UNCACHED(PKTDATA(di->drv, p))) = 0;
16439 +
16440 + pa = (uint32) DMA_MAP(di->osh, PKTDATA(di->drv, p), rxbufsize, DMA_RX, p);
16441 + ASSERT(ISALIGNED(pa, 4));
16442 + ASSERT(DMA_ADDRESSABLE(pa));
16443 +
16444 + /* save the free packet pointer */
16445 + ASSERT(di->rxp[rxout] == NULL);
16446 + di->rxp[rxout] = p;
16447 +
16448 + /* prep the descriptor control value */
16449 + ctrl = rxbufsize;
16450 + if (rxout == (di->nrxd - 1))
16451 + ctrl |= CTRL_EOT;
16452 +
16453 + /* init the rx descriptor */
16454 + W_SM(&di->rxd[rxout].ctrl, BUS_SWAP32(ctrl));
16455 + W_SM(&di->rxd[rxout].addr, BUS_SWAP32(pa + di->dataoffset));
16456 +
16457 + rxout = NEXTRXD(rxout);
16458 + }
16459 +
16460 + di->rxout = rxout;
16461 +
16462 + /* update the chip lastdscr pointer */
16463 + W_REG(&di->regs->rcvptr, I2B(rxout));
16464 +}
16465 +
16466 +void
16467 +dma_txreclaim(dma_info_t *di, bool forceall)
16468 +{
16469 + void *p;
16470 +
16471 + DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, forceall ? "all" : ""));
16472 +
16473 + while ((p = dma_getnexttxp(di, forceall)))
16474 + PKTFREE(di->drv, p, TRUE);
16475 +}
16476 +
16477 +/*
16478 + * Reclaim next completed txd (txds if using chained buffers) and
16479 + * return associated packet.
16480 + * If 'force' is true, reclaim txd(s) and return associated packet
16481 + * regardless of the value of the hardware "curr" pointer.
16482 + */
16483 +void*
16484 +dma_getnexttxp(dma_info_t *di, bool forceall)
16485 +{
16486 + uint start, end, i;
16487 + void *txp;
16488 +
16489 + DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, forceall ? "all" : ""));
16490 +
16491 + txp = NULL;
16492 +
16493 + start = di->txin;
16494 + if (forceall)
16495 + end = di->txout;
16496 + else
16497 + end = B2I(R_REG(&di->regs->xmtstatus) & XS_CD_MASK);
16498 +
16499 + if ((start == 0) && (end > di->txout))
16500 + goto bogus;
16501 +
16502 + for (i = start; i != end && !txp; i = NEXTTXD(i)) {
16503 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->txd[i].addr)) - di->dataoffset),
16504 + (BUS_SWAP32(R_SM(&di->txd[i].ctrl)) & CTRL_BC_MASK), DMA_TX, di->txp[i]);
16505 + W_SM(&di->txd[i].addr, 0xdeadbeef);
16506 + txp = di->txp[i];
16507 + di->txp[i] = NULL;
16508 + }
16509 +
16510 + di->txin = i;
16511 +
16512 + /* tx flow control */
16513 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16514 +
16515 + return (txp);
16516 +
16517 +bogus:
16518 +/*
16519 + DMA_ERROR(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n",
16520 + start, end, di->txout, forceall));
16521 +*/
16522 + return (NULL);
16523 +}
16524 +
16525 +/* like getnexttxp but no reclaim */
16526 +void*
16527 +dma_peeknexttxp(dma_info_t *di)
16528 +{
16529 + uint end, i;
16530 +
16531 + end = B2I(R_REG(&di->regs->xmtstatus) & XS_CD_MASK);
16532 +
16533 + for (i = di->txin; i != end; i = NEXTTXD(i))
16534 + if (di->txp[i])
16535 + return (di->txp[i]);
16536 +
16537 + return (NULL);
16538 +}
16539 +
16540 +void
16541 +dma_rxreclaim(dma_info_t *di)
16542 +{
16543 + void *p;
16544 +
16545 + DMA_TRACE(("%s: dma_rxreclaim\n", di->name));
16546 +
16547 + while ((p = dma_getnextrxp(di, TRUE)))
16548 + PKTFREE(di->drv, p, FALSE);
16549 +}
16550 +
16551 +void *
16552 +dma_getnextrxp(dma_info_t *di, bool forceall)
16553 +{
16554 + uint i;
16555 + void *rxp;
16556 +
16557 + /* if forcing, dma engine must be disabled */
16558 + ASSERT(!forceall || !dma_rxenabled(di));
16559 +
16560 + i = di->rxin;
16561 +
16562 + /* return if no packets posted */
16563 + if (i == di->rxout)
16564 + return (NULL);
16565 +
16566 + /* ignore curr if forceall */
16567 + if (!forceall && (i == B2I(R_REG(&di->regs->rcvstatus) & RS_CD_MASK)))
16568 + return (NULL);
16569 +
16570 + /* get the packet pointer that corresponds to the rx descriptor */
16571 + rxp = di->rxp[i];
16572 + ASSERT(rxp);
16573 + di->rxp[i] = NULL;
16574 +
16575 + /* clear this packet from the descriptor ring */
16576 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->rxd[i].addr)) - di->dataoffset),
16577 + di->rxbufsize, DMA_RX, rxp);
16578 + W_SM(&di->rxd[i].addr, 0xdeadbeef);
16579 +
16580 + di->rxin = NEXTRXD(i);
16581 +
16582 + return (rxp);
16583 +}
16584 +
16585 +
16586 +uintptr
16587 +dma_getvar(dma_info_t *di, char *name)
16588 +{
16589 + if (!strcmp(name, "&txavail"))
16590 + return ((uintptr) &di->txavail);
16591 + else {
16592 + ASSERT(0);
16593 + }
16594 + return (0);
16595 +}
16596 +
16597 +void
16598 +dma_txblock(dma_info_t *di)
16599 +{
16600 + di->txavail = 0;
16601 +}
16602 +
16603 +void
16604 +dma_txunblock(dma_info_t *di)
16605 +{
16606 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16607 +}
16608 +
16609 +uint
16610 +dma_txactive(dma_info_t *di)
16611 +{
16612 + return (NTXDACTIVE(di->txin, di->txout));
16613 +}
16614 +
16615 +/*
16616 + * Rotate all active tx dma ring entries "forward" by (ActiveDescriptor - txin).
16617 + */
16618 +void
16619 +dma_txrotate(di_t *di)
16620 +{
16621 + uint ad;
16622 + uint nactive;
16623 + uint rot;
16624 + uint old, new;
16625 + uint32 w;
16626 + uint first, last;
16627 +
16628 + ASSERT(dma_txsuspended(di));
16629 +
16630 + nactive = dma_txactive(di);
16631 + ad = B2I((R_REG(&di->regs->xmtstatus) & XS_AD_MASK) >> XS_AD_SHIFT);
16632 + rot = TXD(ad - di->txin);
16633 +
16634 + ASSERT(rot < di->ntxd);
16635 +
16636 + /* full-ring case is a lot harder - don't worry about this */
16637 + if (rot >= (di->ntxd - nactive)) {
16638 + DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name));
16639 + return;
16640 + }
16641 +
16642 + first = di->txin;
16643 + last = PREVTXD(di->txout);
16644 +
16645 + /* move entries starting at last and moving backwards to first */
16646 + for (old = last; old != PREVTXD(first); old = PREVTXD(old)) {
16647 + new = TXD(old + rot);
16648 +
16649 + /*
16650 + * Move the tx dma descriptor.
16651 + * EOT is set only in the last entry in the ring.
16652 + */
16653 + w = R_SM(&di->txd[old].ctrl) & ~CTRL_EOT;
16654 + if (new == (di->ntxd - 1))
16655 + w |= CTRL_EOT;
16656 + W_SM(&di->txd[new].ctrl, w);
16657 + W_SM(&di->txd[new].addr, R_SM(&di->txd[old].addr));
16658 +
16659 + /* zap the old tx dma descriptor address field */
16660 + W_SM(&di->txd[old].addr, 0xdeadbeef);
16661 +
16662 + /* move the corresponding txp[] entry */
16663 + ASSERT(di->txp[new] == NULL);
16664 + di->txp[new] = di->txp[old];
16665 + di->txp[old] = NULL;
16666 + }
16667 +
16668 + /* update txin and txout */
16669 + di->txin = ad;
16670 + di->txout = TXD(di->txout + rot);
16671 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
16672 +
16673 + /* kick the chip */
16674 + W_REG(&di->regs->xmtptr, I2B(di->txout));
16675 +}
16676 diff -urN linux-2.4.30/drivers/net/hnd/linux_osl.c linux-2.4.30.dev/drivers/net/hnd/linux_osl.c
16677 --- linux-2.4.30/drivers/net/hnd/linux_osl.c 1970-01-01 01:00:00.000000000 +0100
16678 +++ linux-2.4.30.dev/drivers/net/hnd/linux_osl.c 2005-08-22 01:34:46.511122888 +0200
16679 @@ -0,0 +1,640 @@
16680 +/*
16681 + * Linux OS Independent Layer
16682 + *
16683 + * Copyright 2004, Broadcom Corporation
16684 + * All Rights Reserved.
16685 + *
16686 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
16687 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
16688 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
16689 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
16690 + *
16691 + * $Id$
16692 + */
16693 +
16694 +#define LINUX_OSL
16695 +
16696 +#include <typedefs.h>
16697 +#include <bcmendian.h>
16698 +#include <linux/module.h>
16699 +#include <linuxver.h>
16700 +#include <linux_osl.h>
16701 +#include <bcmutils.h>
16702 +#include <linux/delay.h>
16703 +#ifdef mips
16704 +#include <asm/paccess.h>
16705 +#endif
16706 +#include <pcicfg.h>
16707 +
16708 +#define PCI_CFG_RETRY 10
16709 +
16710 +#define OS_HANDLE_MAGIC 0x1234abcd
16711 +#define BCM_MEM_FILENAME_LEN 24
16712 +
16713 +typedef struct bcm_mem_link {
16714 + struct bcm_mem_link *prev;
16715 + struct bcm_mem_link *next;
16716 + uint size;
16717 + int line;
16718 + char file[BCM_MEM_FILENAME_LEN];
16719 +} bcm_mem_link_t;
16720 +
16721 +typedef struct os_handle {
16722 + uint magic;
16723 + void *pdev;
16724 + uint malloced;
16725 + uint failed;
16726 + bcm_mem_link_t *dbgmem_list;
16727 +} os_handle_t;
16728 +
16729 +void *
16730 +osl_attach(void *pdev)
16731 +{
16732 + os_handle_t *osh;
16733 +
16734 + osh = kmalloc(sizeof(os_handle_t), GFP_ATOMIC);
16735 + ASSERT(osh);
16736 +
16737 + osh->magic = OS_HANDLE_MAGIC;
16738 + osh->malloced = 0;
16739 + osh->failed = 0;
16740 + osh->dbgmem_list = NULL;
16741 + osh->pdev = pdev;
16742 +
16743 + return osh;
16744 +}
16745 +
16746 +void
16747 +osl_detach(void *osh)
16748 +{
16749 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
16750 + kfree(osh);
16751 +}
16752 +
16753 +void*
16754 +osl_pktget(void *drv, uint len, bool send)
16755 +{
16756 + struct sk_buff *skb;
16757 +
16758 + if ((skb = dev_alloc_skb(len)) == NULL)
16759 + return (NULL);
16760 +
16761 + skb_put(skb, len);
16762 +
16763 + /* ensure the cookie field is cleared */
16764 + PKTSETCOOKIE(skb, NULL);
16765 +
16766 + return ((void*) skb);
16767 +}
16768 +
16769 +void
16770 +osl_pktfree(void *p)
16771 +{
16772 + struct sk_buff *skb, *nskb;
16773 +
16774 + skb = (struct sk_buff*) p;
16775 +
16776 + /* perversion: we use skb->next to chain multi-skb packets */
16777 + while (skb) {
16778 + nskb = skb->next;
16779 + skb->next = NULL;
16780 + if (skb->destructor) {
16781 + /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if destructor exists */
16782 + dev_kfree_skb_any(skb);
16783 + } else {
16784 + /* can free immediately (even in_irq()) if destructor does not exist */
16785 + dev_kfree_skb(skb);
16786 + }
16787 + skb = nskb;
16788 + }
16789 +}
16790 +
16791 +uint32
16792 +osl_pci_read_config(void *osh, uint offset, uint size)
16793 +{
16794 + struct pci_dev *pdev;
16795 + uint val;
16796 + uint retry=PCI_CFG_RETRY;
16797 +
16798 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
16799 +
16800 + /* only 4byte access supported */
16801 + ASSERT(size == 4);
16802 +
16803 + pdev = ((os_handle_t *)osh)->pdev;
16804 + do {
16805 + pci_read_config_dword(pdev, offset, &val);
16806 + if (val != 0xffffffff)
16807 + break;
16808 + } while (retry--);
16809 +
16810 +
16811 + return (val);
16812 +}
16813 +
16814 +void
16815 +osl_pci_write_config(void *osh, uint offset, uint size, uint val)
16816 +{
16817 + struct pci_dev *pdev;
16818 + uint retry=PCI_CFG_RETRY;
16819 +
16820 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
16821 +
16822 + /* only 4byte access supported */
16823 + ASSERT(size == 4);
16824 +
16825 + pdev = ((os_handle_t *)osh)->pdev;
16826 +
16827 + do {
16828 + pci_write_config_dword(pdev, offset, val);
16829 + if (offset!=PCI_BAR0_WIN)
16830 + break;
16831 + if (osl_pci_read_config(osh,offset,size) == val)
16832 + break;
16833 + } while (retry--);
16834 +
16835 +}
16836 +
16837 +static void
16838 +osl_pcmcia_attr(void *osh, uint offset, char *buf, int size, bool write)
16839 +{
16840 +}
16841 +
16842 +void
16843 +osl_pcmcia_read_attr(void *osh, uint offset, void *buf, int size)
16844 +{
16845 + osl_pcmcia_attr(osh, offset, (char *) buf, size, FALSE);
16846 +}
16847 +
16848 +void
16849 +osl_pcmcia_write_attr(void *osh, uint offset, void *buf, int size)
16850 +{
16851 + osl_pcmcia_attr(osh, offset, (char *) buf, size, TRUE);
16852 +}
16853 +
16854 +
16855 +#ifdef BCMDBG_MEM
16856 +
16857 +void*
16858 +osl_debug_malloc(void *osh, uint size, int line, char* file)
16859 +{
16860 + bcm_mem_link_t *p;
16861 + char* basename;
16862 + os_handle_t *h = (os_handle_t *)osh;
16863 +
16864 + if (size == 0) {
16865 + return NULL;
16866 + }
16867 +
16868 + p = (bcm_mem_link_t*)osl_malloc(osh, sizeof(bcm_mem_link_t) + size);
16869 + if (p == NULL)
16870 + return p;
16871 +
16872 + p->size = size;
16873 + p->line = line;
16874 +
16875 + basename = strrchr(file, '/');
16876 + /* skip the '/' */
16877 + if (basename)
16878 + basename++;
16879 +
16880 + if (!basename)
16881 + basename = file;
16882 +
16883 + strncpy(p->file, basename, BCM_MEM_FILENAME_LEN);
16884 + p->file[BCM_MEM_FILENAME_LEN - 1] = '\0';
16885 +
16886 + /* link this block */
16887 + p->prev = NULL;
16888 + p->next = h->dbgmem_list;
16889 + if (p->next)
16890 + p->next->prev = p;
16891 + h->dbgmem_list = p;
16892 +
16893 + return p + 1;
16894 +}
16895 +
16896 +void
16897 +osl_debug_mfree(void *osh, void *addr, uint size, int line, char* file)
16898 +{
16899 + bcm_mem_link_t *p = (bcm_mem_link_t *)((int8*)addr - sizeof(bcm_mem_link_t));
16900 + os_handle_t *h = (os_handle_t *)osh;
16901 +
16902 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
16903 +
16904 + if (p->size == 0) {
16905 + printk("osl_debug_mfree: double free on addr 0x%x size %d at line %d file %s\n",
16906 + (uint)addr, size, line, file);
16907 + return;
16908 + }
16909 +
16910 + if (p->size != size) {
16911 + printk("osl_debug_mfree: dealloc size %d does not match alloc size %d on addr 0x%x at line %d file %s\n",
16912 + size, p->size, (uint)addr, line, file);
16913 + return;
16914 + }
16915 +
16916 + /* unlink this block */
16917 + if (p->prev)
16918 + p->prev->next = p->next;
16919 + if (p->next)
16920 + p->next->prev = p->prev;
16921 + if (h->dbgmem_list == p)
16922 + h->dbgmem_list = p->next;
16923 + p->next = p->prev = NULL;
16924 +
16925 + osl_mfree(osh, p, size + sizeof(bcm_mem_link_t));
16926 +}
16927 +
16928 +char*
16929 +osl_debug_memdump(void *osh, char *buf, uint sz)
16930 +{
16931 + bcm_mem_link_t *p;
16932 + char *obuf;
16933 + os_handle_t *h = (os_handle_t *)osh;
16934 +
16935 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
16936 + obuf = buf;
16937 +
16938 + buf += sprintf(buf, " Address\tSize\tFile:line\n");
16939 + for (p = h->dbgmem_list; p && ((buf - obuf) < (sz - 128)); p = p->next)
16940 + buf += sprintf(buf, "0x%08x\t%5d\t%s:%d\n",
16941 + (int)p + sizeof(bcm_mem_link_t), p->size, p->file, p->line);
16942 +
16943 + return (obuf);
16944 +}
16945 +
16946 +#endif /* BCMDBG_MEM */
16947 +
16948 +void*
16949 +osl_malloc(void *osh, uint size)
16950 +{
16951 + os_handle_t *h = (os_handle_t *)osh;
16952 + void *addr;
16953 +
16954 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
16955 + h->malloced += size;
16956 + addr = kmalloc(size, GFP_ATOMIC);
16957 + if (!addr)
16958 + h->failed++;
16959 + return (addr);
16960 +}
16961 +
16962 +void
16963 +osl_mfree(void *osh, void *addr, uint size)
16964 +{
16965 + os_handle_t *h = (os_handle_t *)osh;
16966 +
16967 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
16968 + h->malloced -= size;
16969 + kfree(addr);
16970 +}
16971 +
16972 +uint
16973 +osl_malloced(void *osh)
16974 +{
16975 + os_handle_t *h = (os_handle_t *)osh;
16976 +
16977 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
16978 + return (h->malloced);
16979 +}
16980 +
16981 +uint osl_malloc_failed(void *osh)
16982 +{
16983 + os_handle_t *h = (os_handle_t *)osh;
16984 +
16985 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC)));
16986 + return (h->failed);
16987 +}
16988 +
16989 +void*
16990 +osl_dma_alloc_consistent(void *osh, uint size, ulong *pap)
16991 +{
16992 + struct pci_dev *dev;
16993 +
16994 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
16995 +
16996 + dev = ((os_handle_t *)osh)->pdev;
16997 + return (pci_alloc_consistent(dev, size, (dma_addr_t*)pap));
16998 +}
16999 +
17000 +void
17001 +osl_dma_free_consistent(void *osh, void *va, uint size, ulong pa)
17002 +{
17003 + struct pci_dev *dev;
17004 +
17005 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
17006 +
17007 + dev = ((os_handle_t *)osh)->pdev;
17008 + pci_free_consistent(dev, size, va, (dma_addr_t)pa);
17009 +}
17010 +
17011 +uint
17012 +osl_dma_map(void *osh, void *va, uint size, int direction)
17013 +{
17014 + int dir;
17015 + struct pci_dev *dev;
17016 +
17017 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
17018 +
17019 + dev = ((os_handle_t *)osh)->pdev;
17020 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
17021 + return (pci_map_single(dev, va, size, dir));
17022 +}
17023 +
17024 +void
17025 +osl_dma_unmap(void *osh, uint pa, uint size, int direction)
17026 +{
17027 + int dir;
17028 + struct pci_dev *dev;
17029 +
17030 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC)));
17031 +
17032 + dev = ((os_handle_t *)osh)->pdev;
17033 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
17034 + pci_unmap_single(dev, (uint32)pa, size, dir);
17035 +}
17036 +
17037 +#if defined(BINOSL)
17038 +void
17039 +osl_assert(char *exp, char *file, int line)
17040 +{
17041 + char tempbuf[255];
17042 +
17043 + sprintf(tempbuf, "assertion \"%s\" failed: file \"%s\", line %d\n", exp, file, line);
17044 + panic(tempbuf);
17045 +}
17046 +#endif /* BCMDBG || BINOSL */
17047 +
17048 +/*
17049 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
17050 + */
17051 +#ifdef BINOSL
17052 +
17053 +int
17054 +osl_printf(const char *format, ...)
17055 +{
17056 + va_list args;
17057 + char buf[1024];
17058 + int len;
17059 +
17060 + /* sprintf into a local buffer because there *is* no "vprintk()".. */
17061 + va_start(args, format);
17062 + len = vsprintf(buf, format, args);
17063 + va_end(args);
17064 +
17065 + if (len > sizeof (buf)) {
17066 + printk("osl_printf: buffer overrun\n");
17067 + return (0);
17068 + }
17069 +
17070 + return (printk(buf));
17071 +}
17072 +
17073 +int
17074 +osl_sprintf(char *buf, const char *format, ...)
17075 +{
17076 + va_list args;
17077 + int rc;
17078 +
17079 + va_start(args, format);
17080 + rc = vsprintf(buf, format, args);
17081 + va_end(args);
17082 + return (rc);
17083 +}
17084 +
17085 +int
17086 +osl_strcmp(const char *s1, const char *s2)
17087 +{
17088 + return (strcmp(s1, s2));
17089 +}
17090 +
17091 +int
17092 +osl_strncmp(const char *s1, const char *s2, uint n)
17093 +{
17094 + return (strncmp(s1, s2, n));
17095 +}
17096 +
17097 +int
17098 +osl_strlen(char *s)
17099 +{
17100 + return (strlen(s));
17101 +}
17102 +
17103 +char*
17104 +osl_strcpy(char *d, const char *s)
17105 +{
17106 + return (strcpy(d, s));
17107 +}
17108 +
17109 +char*
17110 +osl_strncpy(char *d, const char *s, uint n)
17111 +{
17112 + return (strncpy(d, s, n));
17113 +}
17114 +
17115 +void
17116 +bcopy(const void *src, void *dst, int len)
17117 +{
17118 + memcpy(dst, src, len);
17119 +}
17120 +
17121 +int
17122 +bcmp(const void *b1, const void *b2, int len)
17123 +{
17124 + return (memcmp(b1, b2, len));
17125 +}
17126 +
17127 +void
17128 +bzero(void *b, int len)
17129 +{
17130 + memset(b, '\0', len);
17131 +}
17132 +
17133 +uint32
17134 +osl_readl(volatile uint32 *r)
17135 +{
17136 + return (readl(r));
17137 +}
17138 +
17139 +uint16
17140 +osl_readw(volatile uint16 *r)
17141 +{
17142 + return (readw(r));
17143 +}
17144 +
17145 +uint8
17146 +osl_readb(volatile uint8 *r)
17147 +{
17148 + return (readb(r));
17149 +}
17150 +
17151 +void
17152 +osl_writel(uint32 v, volatile uint32 *r)
17153 +{
17154 + writel(v, r);
17155 +}
17156 +
17157 +void
17158 +osl_writew(uint16 v, volatile uint16 *r)
17159 +{
17160 + writew(v, r);
17161 +}
17162 +
17163 +void
17164 +osl_writeb(uint8 v, volatile uint8 *r)
17165 +{
17166 + writeb(v, r);
17167 +}
17168 +
17169 +void *
17170 +osl_uncached(void *va)
17171 +{
17172 +#ifdef mips
17173 + return ((void*)KSEG1ADDR(va));
17174 +#else
17175 + return ((void*)va);
17176 +#endif
17177 +}
17178 +
17179 +uint
17180 +osl_getcycles(void)
17181 +{
17182 + uint cycles;
17183 +
17184 +#if defined(mips)
17185 + cycles = read_c0_count() * 2;
17186 +#elif defined(__i386__)
17187 + rdtscl(cycles);
17188 +#else
17189 + cycles = 0;
17190 +#endif
17191 + return cycles;
17192 +}
17193 +
17194 +void *
17195 +osl_reg_map(uint32 pa, uint size)
17196 +{
17197 + return (ioremap_nocache((unsigned long)pa, (unsigned long)size));
17198 +}
17199 +
17200 +void
17201 +osl_reg_unmap(void *va)
17202 +{
17203 + iounmap(va);
17204 +}
17205 +
17206 +int
17207 +osl_busprobe(uint32 *val, uint32 addr)
17208 +{
17209 +#ifdef mips
17210 + return get_dbe(*val, (uint32*)addr);
17211 +#else
17212 + *val = readl(addr);
17213 + return 0;
17214 +#endif
17215 +}
17216 +
17217 +void
17218 +osl_delay(uint usec)
17219 +{
17220 + udelay(usec);
17221 +}
17222 +
17223 +uchar*
17224 +osl_pktdata(void *drv, void *skb)
17225 +{
17226 + return (((struct sk_buff*)skb)->data);
17227 +}
17228 +
17229 +uint
17230 +osl_pktlen(void *drv, void *skb)
17231 +{
17232 + return (((struct sk_buff*)skb)->len);
17233 +}
17234 +
17235 +uint
17236 +osl_pktheadroom(void *drv, void *skb)
17237 +{
17238 + return (uint) skb_headroom((struct sk_buff *) skb);
17239 +}
17240 +
17241 +uint
17242 +osl_pkttailroom(void *drv, void *skb)
17243 +{
17244 + return (uint) skb_tailroom((struct sk_buff *) skb);
17245 +}
17246 +
17247 +void*
17248 +osl_pktnext(void *drv, void *skb)
17249 +{
17250 + return (((struct sk_buff*)skb)->next);
17251 +}
17252 +
17253 +void
17254 +osl_pktsetnext(void *skb, void *x)
17255 +{
17256 + ((struct sk_buff*)skb)->next = (struct sk_buff*)x;
17257 +}
17258 +
17259 +void
17260 +osl_pktsetlen(void *drv, void *skb, uint len)
17261 +{
17262 + __skb_trim((struct sk_buff*)skb, len);
17263 +}
17264 +
17265 +uchar*
17266 +osl_pktpush(void *drv, void *skb, int bytes)
17267 +{
17268 + return (skb_push((struct sk_buff*)skb, bytes));
17269 +}
17270 +
17271 +uchar*
17272 +osl_pktpull(void *drv, void *skb, int bytes)
17273 +{
17274 + return (skb_pull((struct sk_buff*)skb, bytes));
17275 +}
17276 +
17277 +void*
17278 +osl_pktdup(void *drv, void *skb)
17279 +{
17280 + return (skb_clone((struct sk_buff*)skb, GFP_ATOMIC));
17281 +}
17282 +
17283 +void*
17284 +osl_pktcookie(void *skb)
17285 +{
17286 + return ((void*)((struct sk_buff*)skb)->csum);
17287 +}
17288 +
17289 +void
17290 +osl_pktsetcookie(void *skb, void *x)
17291 +{
17292 + ((struct sk_buff*)skb)->csum = (uint)x;
17293 +}
17294 +
17295 +void*
17296 +osl_pktlink(void *skb)
17297 +{
17298 + return (((struct sk_buff*)skb)->prev);
17299 +}
17300 +
17301 +void
17302 +osl_pktsetlink(void *skb, void *x)
17303 +{
17304 + ((struct sk_buff*)skb)->prev = (struct sk_buff*)x;
17305 +}
17306 +
17307 +uint
17308 +osl_pktprio(void *skb)
17309 +{
17310 + return (((struct sk_buff*)skb)->priority);
17311 +}
17312 +
17313 +void
17314 +osl_pktsetprio(void *skb, uint x)
17315 +{
17316 + ((struct sk_buff*)skb)->priority = x;
17317 +}
17318 +
17319 +#endif /* BINOSL */
17320 diff -urN linux-2.4.30/drivers/net/hnd/sbutils.c linux-2.4.30.dev/drivers/net/hnd/sbutils.c
17321 --- linux-2.4.30/drivers/net/hnd/sbutils.c 1970-01-01 01:00:00.000000000 +0100
17322 +++ linux-2.4.30.dev/drivers/net/hnd/sbutils.c 2005-08-22 01:34:46.526120608 +0200
17323 @@ -0,0 +1,2063 @@
17324 +/*
17325 + * Misc utility routines for accessing chip-specific features
17326 + * of the SiliconBackplane-based Broadcom chips.
17327 + *
17328 + * Copyright 2004, Broadcom Corporation
17329 + * All Rights Reserved.
17330 + *
17331 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
17332 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
17333 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
17334 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
17335 + * $Id$
17336 + */
17337 +
17338 +#include <typedefs.h>
17339 +#include <osl.h>
17340 +#include <bcmutils.h>
17341 +#include <bcmdevs.h>
17342 +#include <sbconfig.h>
17343 +#include <sbchipc.h>
17344 +#include <sbpci.h>
17345 +#include <pcicfg.h>
17346 +#include <sbpcmcia.h>
17347 +#include <sbextif.h>
17348 +#include <sbutils.h>
17349 +#include <bcmsrom.h>
17350 +
17351 +/* debug/trace */
17352 +#define SB_ERROR(args)
17353 +
17354 +
17355 +#define CLOCK_BASE_5350 12500000 /* Specific to 5350*/
17356 +
17357 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg);
17358 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg);
17359 +typedef bool (*sb_intrsenabled_t)(void *intr_arg);
17360 +
17361 +/* misc sb info needed by some of the routines */
17362 +typedef struct sb_info {
17363 + uint chip; /* chip number */
17364 + uint chiprev; /* chip revision */
17365 + uint chippkg; /* chip package option */
17366 + uint boardtype; /* board type */
17367 + uint boardvendor; /* board vendor id */
17368 + uint bustype; /* what bus type we are going through */
17369 +
17370 + void *osh; /* osl os handle */
17371 + void *sdh; /* bcmsdh handle */
17372 +
17373 + void *curmap; /* current regs va */
17374 + void *regs[SB_MAXCORES]; /* other regs va */
17375 +
17376 + uint curidx; /* current core index */
17377 + uint dev_coreid; /* the core provides driver functions */
17378 + uint pciidx; /* pci core index */
17379 + uint pcirev; /* pci core rev */
17380 +
17381 + uint pcmciaidx; /* pcmcia core index */
17382 + uint pcmciarev; /* pcmcia core rev */
17383 + bool memseg; /* flag to toggle MEM_SEG register */
17384 +
17385 + uint ccrev; /* chipc core rev */
17386 +
17387 + uint gpioidx; /* gpio control core index */
17388 + uint gpioid; /* gpio control coretype */
17389 +
17390 + uint numcores; /* # discovered cores */
17391 + uint coreid[SB_MAXCORES]; /* id of each core */
17392 +
17393 + void *intr_arg; /* interrupt callback function arg */
17394 + sb_intrsoff_t intrsoff_fn; /* function turns chip interrupts off */
17395 + sb_intrsrestore_t intrsrestore_fn; /* function restore chip interrupts */
17396 + sb_intrsenabled_t intrsenabled_fn; /* function to check if chip interrupts are enabled */
17397 +} sb_info_t;
17398 +
17399 +/* local prototypes */
17400 +static void* BCMINIT(sb_doattach)(sb_info_t *si, uint devid, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz);
17401 +static void BCMINIT(sb_scan)(sb_info_t *si);
17402 +static uint sb_corereg(void *sbh, uint coreidx, uint regoff, uint mask, uint val);
17403 +static uint _sb_coreidx(void *sbh);
17404 +static uint sb_findcoreidx(void *sbh, uint coreid, uint coreunit);
17405 +static uint BCMINIT(sb_pcidev2chip)(uint pcidev);
17406 +static uint BCMINIT(sb_chip2numcores)(uint chip);
17407 +
17408 +#define SB_INFO(sbh) (sb_info_t*)sbh
17409 +#define SET_SBREG(sbh, r, mask, val) W_SBREG((sbh), (r), ((R_SBREG((sbh), (r)) & ~(mask)) | (val)))
17410 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && ISALIGNED((x), SB_CORE_SIZE))
17411 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE))
17412 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF)
17413 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES)
17414 +#define BADIDX (SB_MAXCORES+1)
17415 +#define NOREV (SBIDH_RC_MASK + 1)
17416 +
17417 +#define R_SBREG(sbh, sbr) sb_read_sbreg((sbh), (sbr))
17418 +#define W_SBREG(sbh, sbr, v) sb_write_sbreg((sbh), (sbr), (v))
17419 +#define AND_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) & (v)))
17420 +#define OR_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) | (v)))
17421 +
17422 +/*
17423 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/
17424 + * after core switching to avoid invalid register accesss inside ISR.
17425 + */
17426 +#define INTR_OFF(si, intr_val) \
17427 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
17428 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); }
17429 +#define INTR_RESTORE(si, intr_val) \
17430 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
17431 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
17432 +
17433 +/* power control defines */
17434 +#define LPOMINFREQ 25000 /* low power oscillator min */
17435 +#define LPOMAXFREQ 43000 /* low power oscillator max */
17436 +#define XTALMINFREQ 19800000 /* 20mhz - 1% */
17437 +#define XTALMAXFREQ 20200000 /* 20mhz + 1% */
17438 +#define PCIMINFREQ 25000000 /* 25mhz */
17439 +#define PCIMAXFREQ 34000000 /* 33mhz + fudge */
17440 +#define SCC_DEF_DIV 0 /* default slow clock divider */
17441 +
17442 +#define XTAL_ON_DELAY 1000 /* Xtal power on delay in us */
17443 +
17444 +#define SCC_LOW2FAST_LIMIT 5000 /* turn on fast clock time, in unit of ms */
17445 +
17446 +static uint32
17447 +sb_read_sbreg(void *sbh, volatile uint32 *sbr)
17448 +{
17449 + sb_info_t *si;
17450 + uint8 tmp;
17451 + uint32 val, intr_val = 0;
17452 +
17453 + si = SB_INFO(sbh);
17454 +
17455 + /*
17456 + * compact flash only has 11 bits address, while we needs 12 bits address.
17457 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
17458 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
17459 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
17460 + */
17461 + if(si->memseg) {
17462 + INTR_OFF(si, intr_val);
17463 + tmp = 1;
17464 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
17465 + (uintptr)sbr &= ~(1 << 11); /* mask out bit 11*/
17466 + }
17467 +
17468 + val = R_REG(sbr);
17469 +
17470 + if(si->memseg) {
17471 + tmp = 0;
17472 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
17473 + INTR_RESTORE(si, intr_val);
17474 + }
17475 +
17476 + return (val);
17477 +}
17478 +
17479 +static void
17480 +sb_write_sbreg(void *sbh, volatile uint32 *sbr, uint32 v)
17481 +{
17482 + sb_info_t *si;
17483 + uint8 tmp;
17484 + volatile uint32 dummy;
17485 + uint32 intr_val = 0;
17486 +
17487 + si = SB_INFO(sbh);
17488 +
17489 + /*
17490 + * compact flash only has 11 bits address, while we needs 12 bits address.
17491 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
17492 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
17493 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
17494 + */
17495 + if(si->memseg) {
17496 + INTR_OFF(si, intr_val);
17497 + tmp = 1;
17498 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
17499 + (uintptr)sbr &= ~(1 << 11); /* mask out bit 11 */
17500 + }
17501 +
17502 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) {
17503 +#ifdef IL_BIGENDIAN
17504 + dummy = R_REG(sbr);
17505 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
17506 + dummy = R_REG(sbr);
17507 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
17508 +#else
17509 + dummy = R_REG(sbr);
17510 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
17511 + dummy = R_REG(sbr);
17512 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
17513 +#endif
17514 + } else
17515 + W_REG(sbr, v);
17516 +
17517 + if(si->memseg) {
17518 + tmp = 0;
17519 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
17520 + INTR_RESTORE(si, intr_val);
17521 + }
17522 +}
17523 +
17524 +/*
17525 + * Allocate a sb handle.
17526 + * devid - pci device id (used to determine chip#)
17527 + * osh - opaque OS handle
17528 + * regs - virtual address of initial core registers
17529 + * bustype - pci/pcmcia/sb/sdio/etc
17530 + * vars - pointer to a pointer area for "environment" variables
17531 + * varsz - pointer to int to return the size of the vars
17532 + */
17533 +void*
17534 +BCMINITFN(sb_attach)(uint devid, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz)
17535 +{
17536 + sb_info_t *si;
17537 +
17538 + /* alloc sb_info_t */
17539 + if ((si = MALLOC(osh, sizeof (sb_info_t))) == NULL) {
17540 + SB_ERROR(("sb_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh)));
17541 + return (NULL);
17542 + }
17543 +
17544 + if (BCMINIT(sb_doattach)(si, devid, osh, regs, bustype, sdh, vars, varsz) == NULL) {
17545 + MFREE(osh, si, sizeof (sb_info_t));
17546 + return (NULL);
17547 + }
17548 + return si;
17549 +}
17550 +
17551 +/* Using sb_kattach depends on SB_BUS support, either implicit */
17552 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */
17553 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS)
17554 +
17555 +/* global kernel resource */
17556 +static sb_info_t ksi;
17557 +
17558 +/* generic kernel variant of sb_attach() */
17559 +void*
17560 +BCMINITFN(sb_kattach)()
17561 +{
17562 + uint32 *regs;
17563 + char *unused;
17564 + int varsz;
17565 +
17566 + if (ksi.curmap == NULL) {
17567 + uint32 cid;
17568 +
17569 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE);
17570 + cid = R_REG((uint32 *)regs);
17571 + if (((cid & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
17572 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) &&
17573 + ((cid & CID_REV_MASK) <= 0x00020000)) {
17574 + uint32 *scc, val;
17575 +
17576 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl));
17577 + val = R_REG(scc);
17578 + SB_ERROR((" initial scc = 0x%x\n", val));
17579 + val |= SCC_SS_XTAL;
17580 + W_REG(scc, val);
17581 + }
17582 +
17583 + if (BCMINIT(sb_doattach)(&ksi, BCM4710_DEVICE_ID, NULL, (void*)regs,
17584 + SB_BUS, NULL, &unused, &varsz) == NULL) {
17585 + return NULL;
17586 + }
17587 + }
17588 +
17589 + return &ksi;
17590 +}
17591 +#endif
17592 +
17593 +static void*
17594 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz)
17595 +{
17596 + uint origidx;
17597 + chipcregs_t *cc;
17598 + uint32 w;
17599 + int res;
17600 +
17601 + ASSERT(GOODREGS(regs));
17602 +
17603 + bzero((uchar*)si, sizeof (sb_info_t));
17604 +
17605 + si->pciidx = si->gpioidx = BADIDX;
17606 +
17607 + si->osh = osh;
17608 + si->curmap = regs;
17609 + si->sdh = sdh;
17610 +
17611 + /* check to see if we are a sb core mimic'ing a pci core */
17612 + if (bustype == PCI_BUS) {
17613 + if (OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof (uint32)) == 0xffffffff)
17614 + bustype = SB_BUS;
17615 + else
17616 + bustype = PCI_BUS;
17617 + }
17618 +
17619 + si->bustype = bustype;
17620 + if (si->bustype != BUSTYPE(si->bustype)) {
17621 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n",
17622 + si->bustype, BUSTYPE(si->bustype)));
17623 + return NULL;
17624 + }
17625 +
17626 + /* need to set memseg flag for CF card first before any sb registers access */
17627 + if (BUSTYPE(si->bustype) == PCMCIA_BUS)
17628 + si->memseg = TRUE;
17629 +
17630 + /* kludge to enable the clock on the 4306 which lacks a slowclock */
17631 + if (BUSTYPE(si->bustype) == PCI_BUS)
17632 + sb_pwrctl_xtal((void*)si, XTAL|PLL, ON);
17633 +
17634 + /* initialize current core index value */
17635 + si->curidx = _sb_coreidx((void*)si);
17636 + if (si->curidx == BADIDX) {
17637 + return NULL;
17638 + }
17639 +
17640 + /* keep and reuse the initial register mapping */
17641 + origidx = si->curidx;
17642 + if (BUSTYPE(si->bustype) == SB_BUS)
17643 + si->regs[origidx] = regs;
17644 +
17645 + /* is core-0 a chipcommon core? */
17646 + si->numcores = 1;
17647 + cc = (chipcregs_t*) sb_setcoreidx((void*)si, 0);
17648 + if (sb_coreid((void*)si) != SB_CC)
17649 + cc = NULL;
17650 +
17651 + /* determine chip id and rev */
17652 + if (cc) {
17653 + /* chip common core found! */
17654 + si->chip = R_REG(&cc->chipid) & CID_ID_MASK;
17655 + si->chiprev = (R_REG(&cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT;
17656 + si->chippkg = (R_REG(&cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT;
17657 + } else {
17658 + /* The only pcmcia chip without a chipcommon core is a 4301 */
17659 + if (BUSTYPE(si->bustype) == PCMCIA_BUS)
17660 + devid = BCM4301_DEVICE_ID;
17661 +
17662 + /* no chip common core -- must convert device id to chip id */
17663 + if ((si->chip = BCMINIT(sb_pcidev2chip)(devid)) == 0) {
17664 + SB_ERROR(("sb_attach: unrecognized device id 0x%04x\n", devid));
17665 + return NULL;
17666 + }
17667 + }
17668 +
17669 + /* get chipcommon rev */
17670 + si->ccrev = cc ? sb_corerev((void*)si) : NOREV;
17671 +
17672 + /* determine numcores */
17673 + if (cc && ((si->ccrev == 4) || (si->ccrev >= 6)))
17674 + si->numcores = (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT;
17675 + else
17676 + si->numcores = BCMINIT(sb_chip2numcores)(si->chip);
17677 +
17678 + /* return to original core */
17679 + sb_setcoreidx((void*)si, origidx);
17680 +
17681 + /* sanity checks */
17682 + ASSERT(si->chip);
17683 +
17684 + /* scan for cores */
17685 + BCMINIT(sb_scan)(si);
17686 +
17687 + /* srom_var_init() depends on sb_scan() info */
17688 + if ((res = srom_var_init(si, si->bustype, si->curmap, osh, vars, varsz))) {
17689 + SB_ERROR(("sb_attach: srom_var_init failed: bad srom\n"));
17690 + return (NULL);
17691 + }
17692 +
17693 + if (cc == NULL) {
17694 + /*
17695 + * The chip revision number is hardwired into all
17696 + * of the pci function config rev fields and is
17697 + * independent from the individual core revision numbers.
17698 + * For example, the "A0" silicon of each chip is chip rev 0.
17699 + * For PCMCIA we get it from the CIS instead.
17700 + */
17701 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) {
17702 + ASSERT(vars);
17703 + si->chiprev = getintvar(*vars, "chiprev");
17704 + } else if (BUSTYPE(si->bustype) == PCI_BUS) {
17705 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_REV, sizeof (uint32));
17706 + si->chiprev = w & 0xff;
17707 + } else
17708 + si->chiprev = 0;
17709 + }
17710 +
17711 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) {
17712 + w = getintvar(*vars, "regwindowsz");
17713 + si->memseg = (w <= CFTABLE_REGWIN_2K) ? TRUE : FALSE;
17714 + }
17715 +
17716 + /* gpio control core is required */
17717 + if (!GOODIDX(si->gpioidx)) {
17718 + SB_ERROR(("sb_attach: gpio control core not found\n"));
17719 + return NULL;
17720 + }
17721 +
17722 + /* get boardtype and boardrev */
17723 + switch (BUSTYPE(si->bustype)) {
17724 + case PCI_BUS:
17725 + /* do a pci config read to get subsystem id and subvendor id */
17726 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_SVID, sizeof (uint32));
17727 + si->boardvendor = w & 0xffff;
17728 + si->boardtype = (w >> 16) & 0xffff;
17729 + break;
17730 +
17731 + case PCMCIA_BUS:
17732 + case SDIO_BUS:
17733 + si->boardvendor = getintvar(*vars, "manfid");
17734 + si->boardtype = getintvar(*vars, "prodid");
17735 + break;
17736 +
17737 + case SB_BUS:
17738 + si->boardvendor = VENDOR_BROADCOM;
17739 + si->boardtype = 0xffff;
17740 + break;
17741 + }
17742 +
17743 + if (si->boardtype == 0) {
17744 + SB_ERROR(("sb_attach: unknown board type\n"));
17745 + ASSERT(si->boardtype);
17746 + }
17747 +
17748 +
17749 + return ((void*)si);
17750 +}
17751 +
17752 +uint
17753 +sb_coreid(void *sbh)
17754 +{
17755 + sb_info_t *si;
17756 + sbconfig_t *sb;
17757 +
17758 + si = SB_INFO(sbh);
17759 + sb = REGS2SB(si->curmap);
17760 +
17761 + return ((R_SBREG(sbh, &(sb)->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT);
17762 +}
17763 +
17764 +uint
17765 +sb_coreidx(void *sbh)
17766 +{
17767 + sb_info_t *si;
17768 +
17769 + si = SB_INFO(sbh);
17770 + return (si->curidx);
17771 +}
17772 +
17773 +/* return current index of core */
17774 +static uint
17775 +_sb_coreidx(void *sbh)
17776 +{
17777 + sb_info_t *si;
17778 + sbconfig_t *sb;
17779 + uint32 sbaddr = 0;
17780 +
17781 + si = SB_INFO(sbh);
17782 + ASSERT(si);
17783 +
17784 + switch (BUSTYPE(si->bustype)) {
17785 + case SB_BUS:
17786 + sb = REGS2SB(si->curmap);
17787 + sbaddr = sb_base(R_SBREG(sbh, &sb->sbadmatch0));
17788 + break;
17789 +
17790 + case PCI_BUS:
17791 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32));
17792 + break;
17793 +
17794 + case PCMCIA_BUS: {
17795 + uint8 tmp = 0;
17796 +
17797 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
17798 + sbaddr = (uint)tmp << 12;
17799 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
17800 + sbaddr |= (uint)tmp << 16;
17801 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
17802 + sbaddr |= (uint)tmp << 24;
17803 + break;
17804 + }
17805 + default:
17806 + ASSERT(0);
17807 + }
17808 +
17809 + if (!GOODCOREADDR(sbaddr))
17810 + return BADIDX;
17811 +
17812 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE);
17813 +}
17814 +
17815 +uint
17816 +sb_corevendor(void *sbh)
17817 +{
17818 + sb_info_t *si;
17819 + sbconfig_t *sb;
17820 +
17821 + si = SB_INFO(sbh);
17822 + sb = REGS2SB(si->curmap);
17823 +
17824 + return ((R_SBREG(sbh, &(sb)->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT);
17825 +}
17826 +
17827 +uint
17828 +sb_corerev(void *sbh)
17829 +{
17830 + sb_info_t *si;
17831 + sbconfig_t *sb;
17832 +
17833 + si = SB_INFO(sbh);
17834 + sb = REGS2SB(si->curmap);
17835 +
17836 + return (R_SBREG(sbh, &(sb)->sbidhigh) & SBIDH_RC_MASK);
17837 +}
17838 +
17839 +void *
17840 +sb_osh(void *sbh)
17841 +{
17842 + sb_info_t *si;
17843 +
17844 + si = SB_INFO(sbh);
17845 + return si->osh;
17846 +}
17847 +
17848 +#define SBTML_ALLOW (SBTML_PE | SBTML_FGC | SBTML_FL_MASK)
17849 +
17850 +/* set/clear sbtmstatelow core-specific flags */
17851 +uint32
17852 +sb_coreflags(void *sbh, uint32 mask, uint32 val)
17853 +{
17854 + sb_info_t *si;
17855 + sbconfig_t *sb;
17856 + uint32 w;
17857 +
17858 + si = SB_INFO(sbh);
17859 + sb = REGS2SB(si->curmap);
17860 +
17861 + ASSERT((val & ~mask) == 0);
17862 + ASSERT((mask & ~SBTML_ALLOW) == 0);
17863 +
17864 + /* mask and set */
17865 + if (mask || val) {
17866 + w = (R_SBREG(sbh, &sb->sbtmstatelow) & ~mask) | val;
17867 + W_SBREG(sbh, &sb->sbtmstatelow, w);
17868 + }
17869 +
17870 + /* return the new value */
17871 + return (R_SBREG(sbh, &sb->sbtmstatelow) & SBTML_ALLOW);
17872 +}
17873 +
17874 +/* set/clear sbtmstatehigh core-specific flags */
17875 +uint32
17876 +sb_coreflagshi(void *sbh, uint32 mask, uint32 val)
17877 +{
17878 + sb_info_t *si;
17879 + sbconfig_t *sb;
17880 + uint32 w;
17881 +
17882 + si = SB_INFO(sbh);
17883 + sb = REGS2SB(si->curmap);
17884 +
17885 + ASSERT((val & ~mask) == 0);
17886 + ASSERT((mask & ~SBTMH_FL_MASK) == 0);
17887 +
17888 + /* mask and set */
17889 + if (mask || val) {
17890 + w = (R_SBREG(sbh, &sb->sbtmstatehigh) & ~mask) | val;
17891 + W_SBREG(sbh, &sb->sbtmstatehigh, w);
17892 + }
17893 +
17894 + /* return the new value */
17895 + return (R_SBREG(sbh, &sb->sbtmstatehigh) & SBTMH_FL_MASK);
17896 +}
17897 +
17898 +bool
17899 +sb_iscoreup(void *sbh)
17900 +{
17901 + sb_info_t *si;
17902 + sbconfig_t *sb;
17903 +
17904 + si = SB_INFO(sbh);
17905 + sb = REGS2SB(si->curmap);
17906 +
17907 + return ((R_SBREG(sbh, &(sb)->sbtmstatelow) & (SBTML_RESET | SBTML_REJ | SBTML_CLK)) == SBTML_CLK);
17908 +}
17909 +
17910 +/*
17911 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation,
17912 + * switch back to the original core, and return the new value.
17913 + */
17914 +static uint
17915 +sb_corereg(void *sbh, uint coreidx, uint regoff, uint mask, uint val)
17916 +{
17917 + sb_info_t *si;
17918 + uint origidx;
17919 + uint32 *r;
17920 + uint w;
17921 + uint intr_val = 0;
17922 +
17923 + ASSERT(GOODIDX(coreidx));
17924 + ASSERT(regoff < SB_CORE_SIZE);
17925 + ASSERT((val & ~mask) == 0);
17926 +
17927 + si = SB_INFO(sbh);
17928 +
17929 + INTR_OFF(si, intr_val);
17930 +
17931 + /* save current core index */
17932 + origidx = sb_coreidx(sbh);
17933 +
17934 + /* switch core */
17935 + r = (uint32*) ((uchar*) sb_setcoreidx(sbh, coreidx) + regoff);
17936 +
17937 + /* mask and set */
17938 + if (mask || val) {
17939 + if (regoff >= SBCONFIGOFF) {
17940 + w = (R_SBREG(sbh, r) & ~mask) | val;
17941 + W_SBREG(sbh, r, w);
17942 + } else {
17943 + w = (R_REG(r) & ~mask) | val;
17944 + W_REG(r, w);
17945 + }
17946 + }
17947 +
17948 + /* readback */
17949 + if (regoff >= SBCONFIGOFF)
17950 + w = R_SBREG(sbh, r);
17951 + else
17952 + w = R_REG(r);
17953 +
17954 + /* restore core index */
17955 + if (origidx != coreidx)
17956 + sb_setcoreidx(sbh, origidx);
17957 +
17958 + INTR_RESTORE(si, intr_val);
17959 + return (w);
17960 +}
17961 +
17962 +/* scan the sb enumerated space to identify all cores */
17963 +static void
17964 +BCMINITFN(sb_scan)(sb_info_t *si)
17965 +{
17966 + void *sbh;
17967 + uint origidx;
17968 + uint i;
17969 +
17970 + sbh = (void*) si;
17971 +
17972 + /* numcores should already be set */
17973 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES));
17974 +
17975 + /* save current core index */
17976 + origidx = sb_coreidx(sbh);
17977 +
17978 + si->pciidx = si->pcmciaidx = si->gpioidx = BADIDX;
17979 + si->pcirev = si->pcmciarev = NOREV;
17980 +
17981 + for (i = 0; i < si->numcores; i++) {
17982 + sb_setcoreidx(sbh, i);
17983 + si->coreid[i] = sb_coreid(sbh);
17984 +
17985 + if (si->coreid[i] == SB_PCI) {
17986 + si->pciidx = i;
17987 + si->pcirev = sb_corerev(sbh);
17988 +
17989 + } else if (si->coreid[i] == SB_PCMCIA) {
17990 + si->pcmciaidx = i;
17991 + si->pcmciarev = sb_corerev(sbh);
17992 + }
17993 + }
17994 +
17995 + /*
17996 + * Find the gpio "controlling core" type and index.
17997 + * Precedence:
17998 + * - if there's a chip common core - use that
17999 + * - else if there's a pci core (rev >= 2) - use that
18000 + * - else there had better be an extif core (4710 only)
18001 + */
18002 + if (GOODIDX(sb_findcoreidx(sbh, SB_CC, 0))) {
18003 + si->gpioidx = sb_findcoreidx(sbh, SB_CC, 0);
18004 + si->gpioid = SB_CC;
18005 + } else if (GOODIDX(si->pciidx) && (si->pcirev >= 2)) {
18006 + si->gpioidx = si->pciidx;
18007 + si->gpioid = SB_PCI;
18008 + } else if (sb_findcoreidx(sbh, SB_EXTIF, 0)) {
18009 + si->gpioidx = sb_findcoreidx(sbh, SB_EXTIF, 0);
18010 + si->gpioid = SB_EXTIF;
18011 + } else
18012 + ASSERT(si->gpioidx != BADIDX);
18013 +
18014 + /* return to original core index */
18015 + sb_setcoreidx(sbh, origidx);
18016 +}
18017 +
18018 +/* may be called with core in reset */
18019 +void
18020 +sb_detach(void *sbh)
18021 +{
18022 + sb_info_t *si;
18023 + uint idx;
18024 +
18025 + si = SB_INFO(sbh);
18026 +
18027 + if (si == NULL)
18028 + return;
18029 +
18030 + if (BUSTYPE(si->bustype) == SB_BUS)
18031 + for (idx = 0; idx < SB_MAXCORES; idx++)
18032 + if (si->regs[idx]) {
18033 + REG_UNMAP(si->regs[idx]);
18034 + si->regs[idx] = NULL;
18035 + }
18036 +
18037 + MFREE(si->osh, si, sizeof (sb_info_t));
18038 +}
18039 +
18040 +/* use pci dev id to determine chip id for chips not having a chipcommon core */
18041 +static uint
18042 +BCMINITFN(sb_pcidev2chip)(uint pcidev)
18043 +{
18044 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID))
18045 + return (BCM4710_DEVICE_ID);
18046 + if ((pcidev >= BCM4610_DEVICE_ID) && (pcidev <= BCM4610_USB_ID))
18047 + return (BCM4610_DEVICE_ID);
18048 + if ((pcidev >= BCM4402_DEVICE_ID) && (pcidev <= BCM4402_V90_ID))
18049 + return (BCM4402_DEVICE_ID);
18050 + if (pcidev == BCM4401_ENET_ID)
18051 + return (BCM4402_DEVICE_ID);
18052 + if ((pcidev >= BCM4307_V90_ID) && (pcidev <= BCM4307_D11B_ID))
18053 + return (BCM4307_DEVICE_ID);
18054 + if (pcidev == BCM4301_DEVICE_ID)
18055 + return (BCM4301_DEVICE_ID);
18056 +
18057 + return (0);
18058 +}
18059 +
18060 +/* convert chip number to number of i/o cores */
18061 +static uint
18062 +BCMINITFN(sb_chip2numcores)(uint chip)
18063 +{
18064 + if (chip == 0x4710)
18065 + return (9);
18066 + if (chip == 0x4610)
18067 + return (9);
18068 + if (chip == 0x4402)
18069 + return (3);
18070 + if ((chip == 0x4307) || (chip == 0x4301))
18071 + return (5);
18072 + if (chip == 0x4310)
18073 + return (8);
18074 + if (chip == 0x4306) /* < 4306c0 */
18075 + return (6);
18076 + if (chip == 0x4704)
18077 + return (9);
18078 + if (chip == 0x5365)
18079 + return (7);
18080 +
18081 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip));
18082 + ASSERT(0);
18083 + return (1);
18084 +}
18085 +
18086 +/* return index of coreid or BADIDX if not found */
18087 +static uint
18088 +sb_findcoreidx(void *sbh, uint coreid, uint coreunit)
18089 +{
18090 + sb_info_t *si;
18091 + uint found;
18092 + uint i;
18093 +
18094 + si = SB_INFO(sbh);
18095 + found = 0;
18096 +
18097 + for (i = 0; i < si->numcores; i++)
18098 + if (si->coreid[i] == coreid) {
18099 + if (found == coreunit)
18100 + return (i);
18101 + found++;
18102 + }
18103 +
18104 + return (BADIDX);
18105 +}
18106 +
18107 +/*
18108 + * this function changes logical "focus" to the indiciated core,
18109 + * must be called with interrupt off.
18110 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
18111 + */
18112 +void*
18113 +sb_setcoreidx(void *sbh, uint coreidx)
18114 +{
18115 + sb_info_t *si;
18116 + uint32 sbaddr;
18117 + uint8 tmp;
18118 +
18119 + si = SB_INFO(sbh);
18120 +
18121 + if (coreidx >= si->numcores)
18122 + return (NULL);
18123 +
18124 + /*
18125 + * If the user has provided an interrupt mask enabled function,
18126 + * then assert interrupts are disabled before switching the core.
18127 + */
18128 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg));
18129 +
18130 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE);
18131 +
18132 + switch (BUSTYPE(si->bustype)) {
18133 + case SB_BUS:
18134 + /* map new one */
18135 + if (!si->regs[coreidx]) {
18136 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE);
18137 + ASSERT(GOODREGS(si->regs[coreidx]));
18138 + }
18139 + si->curmap = si->regs[coreidx];
18140 + break;
18141 +
18142 + case PCI_BUS:
18143 + /* point bar0 window */
18144 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr);
18145 + break;
18146 +
18147 + case PCMCIA_BUS:
18148 + tmp = (sbaddr >> 12) & 0x0f;
18149 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
18150 + tmp = (sbaddr >> 16) & 0xff;
18151 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
18152 + tmp = (sbaddr >> 24) & 0xff;
18153 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
18154 + break;
18155 + }
18156 +
18157 + si->curidx = coreidx;
18158 +
18159 + return (si->curmap);
18160 +}
18161 +
18162 +/*
18163 + * this function changes logical "focus" to the indiciated core,
18164 + * must be called with interrupt off.
18165 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
18166 + */
18167 +void*
18168 +sb_setcore(void *sbh, uint coreid, uint coreunit)
18169 +{
18170 + sb_info_t *si;
18171 + uint idx;
18172 +
18173 + si = SB_INFO(sbh);
18174 +
18175 + idx = sb_findcoreidx(sbh, coreid, coreunit);
18176 + if (!GOODIDX(idx))
18177 + return (NULL);
18178 +
18179 + return (sb_setcoreidx(sbh, idx));
18180 +}
18181 +
18182 +/* return chip number */
18183 +uint
18184 +BCMINITFN(sb_chip)(void *sbh)
18185 +{
18186 + sb_info_t *si;
18187 +
18188 + si = SB_INFO(sbh);
18189 + return (si->chip);
18190 +}
18191 +
18192 +/* return chip revision number */
18193 +uint
18194 +BCMINITFN(sb_chiprev)(void *sbh)
18195 +{
18196 + sb_info_t *si;
18197 +
18198 + si = SB_INFO(sbh);
18199 + return (si->chiprev);
18200 +}
18201 +
18202 +/* return chip common revision number */
18203 +uint
18204 +BCMINITFN(sb_chipcrev)(void *sbh)
18205 +{
18206 + sb_info_t *si;
18207 +
18208 + si = SB_INFO(sbh);
18209 + return (si->ccrev);
18210 +}
18211 +
18212 +/* return chip package option */
18213 +uint
18214 +BCMINITFN(sb_chippkg)(void *sbh)
18215 +{
18216 + sb_info_t *si;
18217 +
18218 + si = SB_INFO(sbh);
18219 + return (si->chippkg);
18220 +}
18221 +
18222 +/* return PCI core rev. */
18223 +uint
18224 +BCMINITFN(sb_pcirev)(void *sbh)
18225 +{
18226 + sb_info_t *si;
18227 +
18228 + si = SB_INFO(sbh);
18229 + return (si->pcirev);
18230 +}
18231 +
18232 +/* return PCMCIA core rev. */
18233 +uint
18234 +BCMINITFN(sb_pcmciarev)(void *sbh)
18235 +{
18236 + sb_info_t *si;
18237 +
18238 + si = SB_INFO(sbh);
18239 + return (si->pcmciarev);
18240 +}
18241 +
18242 +/* return board vendor id */
18243 +uint
18244 +BCMINITFN(sb_boardvendor)(void *sbh)
18245 +{
18246 + sb_info_t *si;
18247 +
18248 + si = SB_INFO(sbh);
18249 + return (si->boardvendor);
18250 +}
18251 +
18252 +/* return boardtype */
18253 +uint
18254 +BCMINITFN(sb_boardtype)(void *sbh)
18255 +{
18256 + sb_info_t *si;
18257 + char *var;
18258 +
18259 + si = SB_INFO(sbh);
18260 +
18261 + if (BUSTYPE(si->bustype) == SB_BUS && si->boardtype == 0xffff) {
18262 + /* boardtype format is a hex string */
18263 + si->boardtype = getintvar(NULL, "boardtype");
18264 +
18265 + /* backward compatibility for older boardtype string format */
18266 + if ((si->boardtype == 0) && (var = getvar(NULL, "boardtype"))) {
18267 + if (!strcmp(var, "bcm94710dev"))
18268 + si->boardtype = BCM94710D_BOARD;
18269 + else if (!strcmp(var, "bcm94710ap"))
18270 + si->boardtype = BCM94710AP_BOARD;
18271 + else if (!strcmp(var, "bcm94310u"))
18272 + si->boardtype = BCM94310U_BOARD;
18273 + else if (!strcmp(var, "bu4711"))
18274 + si->boardtype = BU4711_BOARD;
18275 + else if (!strcmp(var, "bu4710"))
18276 + si->boardtype = BU4710_BOARD;
18277 + else if (!strcmp(var, "bcm94702mn"))
18278 + si->boardtype = BCM94702MN_BOARD;
18279 + else if (!strcmp(var, "bcm94710r1"))
18280 + si->boardtype = BCM94710R1_BOARD;
18281 + else if (!strcmp(var, "bcm94710r4"))
18282 + si->boardtype = BCM94710R4_BOARD;
18283 + else if (!strcmp(var, "bcm94702cpci"))
18284 + si->boardtype = BCM94702CPCI_BOARD;
18285 + else if (!strcmp(var, "bcm95380_rr"))
18286 + si->boardtype = BCM95380RR_BOARD;
18287 + }
18288 + }
18289 +
18290 + return (si->boardtype);
18291 +}
18292 +
18293 +/* return bus type of sdh device */
18294 +uint
18295 +sb_bus(void *sbh)
18296 +{
18297 + sb_info_t *si;
18298 +
18299 + si = SB_INFO(sbh);
18300 + return (si->bustype);
18301 +}
18302 +
18303 +/* return list of found cores */
18304 +uint
18305 +sb_corelist(void *sbh, uint coreid[])
18306 +{
18307 + sb_info_t *si;
18308 +
18309 + si = SB_INFO(sbh);
18310 +
18311 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof (uint)));
18312 + return (si->numcores);
18313 +}
18314 +
18315 +/* return current register mapping */
18316 +void *
18317 +sb_coreregs(void *sbh)
18318 +{
18319 + sb_info_t *si;
18320 +
18321 + si = SB_INFO(sbh);
18322 + ASSERT(GOODREGS(si->curmap));
18323 +
18324 + return (si->curmap);
18325 +}
18326 +
18327 +
18328 +/* do buffered registers update */
18329 +void
18330 +sb_commit(void *sbh)
18331 +{
18332 + sb_info_t *si;
18333 + uint origidx;
18334 + uint intr_val = 0;
18335 +
18336 + si = SB_INFO(sbh);
18337 +
18338 + origidx = si->curidx;
18339 + ASSERT(GOODIDX(origidx));
18340 +
18341 + INTR_OFF(si, intr_val);
18342 +
18343 + /* switch over to chipcommon core if there is one, else use pci */
18344 + if (si->ccrev != NOREV) {
18345 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0);
18346 +
18347 + /* do the buffer registers update */
18348 + W_REG(&ccregs->broadcastaddress, SB_COMMIT);
18349 + W_REG(&ccregs->broadcastdata, 0x0);
18350 + } else if (si->pciidx != BADIDX) {
18351 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0);
18352 +
18353 + /* do the buffer registers update */
18354 + W_REG(&pciregs->bcastaddr, SB_COMMIT);
18355 + W_REG(&pciregs->bcastdata, 0x0);
18356 + } else {
18357 + ASSERT((si->ccrev != NOREV) && (si->pciidx != BADIDX));
18358 + }
18359 +
18360 + /* restore core index */
18361 + sb_setcoreidx(sbh, origidx);
18362 + INTR_RESTORE(si, intr_val);
18363 +}
18364 +
18365 +/* reset and re-enable a core */
18366 +void
18367 +sb_core_reset(void *sbh, uint32 bits)
18368 +{
18369 + sb_info_t *si;
18370 + sbconfig_t *sb;
18371 + volatile uint32 dummy;
18372 +
18373 + si = SB_INFO(sbh);
18374 + ASSERT(GOODREGS(si->curmap));
18375 + sb = REGS2SB(si->curmap);
18376 +
18377 + /*
18378 + * Must do the disable sequence first to work for arbitrary current core state.
18379 + */
18380 + sb_core_disable(sbh, bits);
18381 +
18382 + /*
18383 + * Now do the initialization sequence.
18384 + */
18385 +
18386 + /* set reset while enabling the clock and forcing them on throughout the core */
18387 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits));
18388 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18389 +
18390 + if (sb_coreid(sbh) == SB_ILINE100) {
18391 + bcm_mdelay(50);
18392 + } else {
18393 + OSL_DELAY(1);
18394 + }
18395 +
18396 + if (R_SBREG(sbh, &sb->sbtmstatehigh) & SBTMH_SERR) {
18397 + W_SBREG(sbh, &sb->sbtmstatehigh, 0);
18398 + }
18399 + if ((dummy = R_SBREG(sbh, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) {
18400 + AND_SBREG(sbh, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO));
18401 + }
18402 +
18403 + /* clear reset and allow it to propagate throughout the core */
18404 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits));
18405 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18406 + OSL_DELAY(1);
18407 +
18408 + /* leave clock enabled */
18409 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_CLK | bits));
18410 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18411 + OSL_DELAY(1);
18412 +}
18413 +
18414 +void
18415 +sb_core_tofixup(void *sbh)
18416 +{
18417 + sb_info_t *si;
18418 + sbconfig_t *sb;
18419 +
18420 + si = SB_INFO(sbh);
18421 +
18422 + if ((si->pciidx == BADIDX) || (si->pcirev >= 5))
18423 + return;
18424 +
18425 + ASSERT(GOODREGS(si->curmap));
18426 + sb = REGS2SB(si->curmap);
18427 +
18428 + if (BUSTYPE(si->bustype) == SB_BUS) {
18429 + SET_SBREG(sbh, &sb->sbimconfiglow,
18430 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
18431 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3);
18432 + } else {
18433 + if (sb_coreid(sbh) == SB_PCI) {
18434 + SET_SBREG(sbh, &sb->sbimconfiglow,
18435 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
18436 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
18437 + } else {
18438 + SET_SBREG(sbh, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0);
18439 + }
18440 + }
18441 +
18442 + sb_commit(sbh);
18443 +}
18444 +
18445 +void
18446 +sb_core_disable(void *sbh, uint32 bits)
18447 +{
18448 + sb_info_t *si;
18449 + volatile uint32 dummy;
18450 + sbconfig_t *sb;
18451 +
18452 + si = SB_INFO(sbh);
18453 +
18454 + ASSERT(GOODREGS(si->curmap));
18455 + sb = REGS2SB(si->curmap);
18456 +
18457 + /* if core is already in reset, just return */
18458 + if (R_SBREG(sbh, &sb->sbtmstatelow) & SBTML_RESET)
18459 + return;
18460 +
18461 + /* if clocks are not enabled, put into reset and return */
18462 + if ((R_SBREG(sbh, &sb->sbtmstatelow) & SBTML_CLK) == 0)
18463 + goto disable;
18464 +
18465 + /* set the target reject bit and spin until busy is clear */
18466 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_CLK | SBTML_REJ));
18467 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18468 + OSL_DELAY(1);
18469 + SPINWAIT((R_SBREG(sbh, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
18470 +
18471 + if (R_SBREG(sbh, &sb->sbidlow) & SBIDL_INIT) {
18472 + OR_SBREG(sbh, &sb->sbimstate, SBIM_RJ);
18473 + dummy = R_SBREG(sbh, &sb->sbimstate);
18474 + OSL_DELAY(1);
18475 + SPINWAIT((R_SBREG(sbh, &sb->sbimstate) & SBIM_BY), 100000);
18476 + }
18477 +
18478 + /* set reset and reject while enabling the clocks */
18479 + W_SBREG(sbh, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | SBTML_REJ | SBTML_RESET));
18480 + dummy = R_SBREG(sbh, &sb->sbtmstatelow);
18481 + OSL_DELAY(10);
18482 +
18483 + /* don't forget to clear the initiator reject bit */
18484 + if (R_SBREG(sbh, &sb->sbidlow) & SBIDL_INIT)
18485 + AND_SBREG(sbh, &sb->sbimstate, ~SBIM_RJ);
18486 +
18487 +disable:
18488 + /* leave reset and reject asserted */
18489 + W_SBREG(sbh, &sb->sbtmstatelow, (bits | SBTML_REJ | SBTML_RESET));
18490 + OSL_DELAY(1);
18491 +}
18492 +
18493 +void
18494 +sb_watchdog(void *sbh, uint ticks)
18495 +{
18496 + sb_info_t *si = SB_INFO(sbh);
18497 +
18498 + /* instant NMI */
18499 + switch (si->gpioid) {
18500 + case SB_CC:
18501 + sb_corereg(sbh, si->gpioidx, OFFSETOF(chipcregs_t, watchdog), ~0, ticks);
18502 + break;
18503 + case SB_EXTIF:
18504 + sb_corereg(sbh, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks);
18505 + break;
18506 + }
18507 +}
18508 +
18509 +/* initialize the pcmcia core */
18510 +void
18511 +sb_pcmcia_init(void *sbh)
18512 +{
18513 + sb_info_t *si;
18514 + uint8 cor;
18515 +
18516 + si = SB_INFO(sbh);
18517 +
18518 + /* enable d11 mac interrupts */
18519 + if (si->chip == BCM4301_DEVICE_ID) {
18520 + /* Have to use FCR2 in 4301 */
18521 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
18522 + cor |= COR_IRQEN | COR_FUNEN;
18523 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
18524 + } else {
18525 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
18526 + cor |= COR_IRQEN | COR_FUNEN;
18527 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
18528 + }
18529 +
18530 +}
18531 +
18532 +
18533 +/*
18534 + * Configure the pci core for pci client (NIC) action
18535 + * and get appropriate dma offset value.
18536 + * coremask is the bitvec of cores by index to be enabled.
18537 + */
18538 +void
18539 +sb_pci_setup(void *sbh, uint32 *dmaoffset, uint coremask)
18540 +{
18541 + sb_info_t *si;
18542 + sbconfig_t *sb;
18543 + sbpciregs_t *pciregs;
18544 + uint32 sbflag;
18545 + uint32 w;
18546 + uint idx;
18547 +
18548 + si = SB_INFO(sbh);
18549 +
18550 + if (dmaoffset)
18551 + *dmaoffset = 0;
18552 +
18553 + /* if not pci bus, we're done */
18554 + if (BUSTYPE(si->bustype) != PCI_BUS)
18555 + return;
18556 +
18557 + ASSERT(si->pciidx != BADIDX);
18558 +
18559 + /* get current core index */
18560 + idx = si->curidx;
18561 +
18562 + /* we interrupt on this backplane flag number */
18563 + ASSERT(GOODREGS(si->curmap));
18564 + sb = REGS2SB(si->curmap);
18565 + sbflag = R_SBREG(sbh, &sb->sbtpsflag) & SBTPS_NUM0_MASK;
18566 +
18567 + /* switch over to pci core */
18568 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->pciidx);
18569 + sb = REGS2SB(pciregs);
18570 +
18571 + /*
18572 + * Enable sb->pci interrupts. Assume
18573 + * PCI rev 2.3 support was added in pci core rev 6 and things changed..
18574 + */
18575 + if (si->pcirev < 6) {
18576 + /* set sbintvec bit for our flag number */
18577 + OR_SBREG(sbh, &sb->sbintvec, (1 << sbflag));
18578 + } else {
18579 + /* pci config write to set this core bit in PCIIntMask */
18580 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32));
18581 + w |= (coremask << PCI_SBIM_SHIFT);
18582 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w);
18583 + }
18584 +
18585 + /* enable prefetch and bursts for dma big window */
18586 + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST));
18587 +
18588 + /* enable read multiple for dma big window */
18589 + if (si->pcirev >= 11)
18590 + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI);
18591 +
18592 + if (si->pcirev < 5) {
18593 + SET_SBREG(sbh, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
18594 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
18595 + sb_commit(sbh);
18596 + }
18597 +
18598 + /* switch back to previous core */
18599 + sb_setcoreidx(sbh, idx);
18600 +
18601 + /* use large sb pci dma window */
18602 + if (dmaoffset)
18603 + *dmaoffset = SB_PCI_DMA;
18604 +}
18605 +
18606 +uint32
18607 +sb_base(uint32 admatch)
18608 +{
18609 + uint32 base;
18610 + uint type;
18611 +
18612 + type = admatch & SBAM_TYPE_MASK;
18613 + ASSERT(type < 3);
18614 +
18615 + base = 0;
18616 +
18617 + if (type == 0) {
18618 + base = admatch & SBAM_BASE0_MASK;
18619 + } else if (type == 1) {
18620 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
18621 + base = admatch & SBAM_BASE1_MASK;
18622 + } else if (type == 2) {
18623 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
18624 + base = admatch & SBAM_BASE2_MASK;
18625 + }
18626 +
18627 + return (base);
18628 +}
18629 +
18630 +uint32
18631 +sb_size(uint32 admatch)
18632 +{
18633 + uint32 size;
18634 + uint type;
18635 +
18636 + type = admatch & SBAM_TYPE_MASK;
18637 + ASSERT(type < 3);
18638 +
18639 + size = 0;
18640 +
18641 + if (type == 0) {
18642 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1);
18643 + } else if (type == 1) {
18644 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
18645 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1);
18646 + } else if (type == 2) {
18647 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
18648 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1);
18649 + }
18650 +
18651 + return (size);
18652 +}
18653 +
18654 +/* return the core-type instantiation # of the current core */
18655 +uint
18656 +sb_coreunit(void *sbh)
18657 +{
18658 + sb_info_t *si;
18659 + uint idx;
18660 + uint coreid;
18661 + uint coreunit;
18662 + uint i;
18663 +
18664 + si = SB_INFO(sbh);
18665 + coreunit = 0;
18666 +
18667 + idx = si->curidx;
18668 +
18669 + ASSERT(GOODREGS(si->curmap));
18670 + coreid = sb_coreid(sbh);
18671 +
18672 + /* count the cores of our type */
18673 + for (i = 0; i < idx; i++)
18674 + if (si->coreid[i] == coreid)
18675 + coreunit++;
18676 +
18677 + return (coreunit);
18678 +}
18679 +
18680 +static INLINE uint32
18681 +factor6(uint32 x)
18682 +{
18683 + switch (x) {
18684 + case CC_F6_2: return 2;
18685 + case CC_F6_3: return 3;
18686 + case CC_F6_4: return 4;
18687 + case CC_F6_5: return 5;
18688 + case CC_F6_6: return 6;
18689 + case CC_F6_7: return 7;
18690 + default: return 0;
18691 + }
18692 +}
18693 +
18694 +/* calculate the speed the SB would run at given a set of clockcontrol values */
18695 +uint32
18696 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m)
18697 +{
18698 + uint32 n1, n2, clock, m1, m2, m3, mc;
18699 +
18700 + n1 = n & CN_N1_MASK;
18701 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT;
18702 +
18703 + if (pll_type == PLL_TYPE6) {
18704 + if (m & CC_T6_MMASK)
18705 + return CC_T6_M1;
18706 + else
18707 + return CC_T6_M0;
18708 + } else if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE4)|| (pll_type == PLL_TYPE3)) {
18709 + n1 = factor6(n1);
18710 + n2 += CC_F5_BIAS;
18711 + } else if (pll_type == PLL_TYPE2) {
18712 + n1 += CC_T2_BIAS;
18713 + n2 += CC_T2_BIAS;
18714 + ASSERT((n1 >= 2) && (n1 <= 7));
18715 + ASSERT((n2 >= 5) && (n2 <= 23));
18716 + } else if (pll_type == PLL_TYPE5) {
18717 + return (100000000);
18718 + } else
18719 + ASSERT((pll_type >= PLL_TYPE1) && (pll_type <= PLL_TYPE4));
18720 +
18721 + /* Special case for 5350 */
18722 + if (pll_type == PLL_TYPE3)
18723 + clock = CLOCK_BASE_5350 * n1 * n2;
18724 + else
18725 + clock = CC_CLOCK_BASE * n1 * n2;
18726 +
18727 + if (clock == 0)
18728 + return 0;
18729 +
18730 + m1 = m & CC_M1_MASK;
18731 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT;
18732 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT;
18733 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT;
18734 +
18735 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE4) || (pll_type == PLL_TYPE3)) {
18736 + m1 = factor6(m1);
18737 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3))
18738 + m2 += CC_F5_BIAS;
18739 + else
18740 + m2 = factor6(m2);
18741 + m3 = factor6(m3);
18742 +
18743 + switch (mc) {
18744 + case CC_MC_BYPASS: return (clock);
18745 + case CC_MC_M1: return (clock / m1);
18746 + case CC_MC_M1M2: return (clock / (m1 * m2));
18747 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3));
18748 + case CC_MC_M1M3: return (clock / (m1 * m3));
18749 + default: return (0);
18750 + }
18751 + } else {
18752 + ASSERT(pll_type == PLL_TYPE2);
18753 +
18754 + m1 += CC_T2_BIAS;
18755 + m2 += CC_T2M2_BIAS;
18756 + m3 += CC_T2_BIAS;
18757 + ASSERT((m1 >= 2) && (m1 <= 7));
18758 + ASSERT((m2 >= 3) && (m2 <= 10));
18759 + ASSERT((m3 >= 2) && (m3 <= 7));
18760 +
18761 + if ((mc & CC_T2MC_M1BYP) == 0)
18762 + clock /= m1;
18763 + if ((mc & CC_T2MC_M2BYP) == 0)
18764 + clock /= m2;
18765 + if ((mc & CC_T2MC_M3BYP) == 0)
18766 + clock /= m3;
18767 +
18768 + return(clock);
18769 + }
18770 +}
18771 +
18772 +/* returns the current speed the SB is running at */
18773 +uint32
18774 +sb_clock(void *sbh)
18775 +{
18776 + sb_info_t *si;
18777 + extifregs_t *eir;
18778 + chipcregs_t *cc;
18779 + uint32 n, m;
18780 + uint idx;
18781 + uint32 pll_type, rate;
18782 + uint intr_val = 0;
18783 +
18784 + si = SB_INFO(sbh);
18785 + idx = si->curidx;
18786 + pll_type = PLL_TYPE1;
18787 +
18788 + INTR_OFF(si, intr_val);
18789 +
18790 + /* switch to extif or chipc core */
18791 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
18792 + n = R_REG(&eir->clockcontrol_n);
18793 + m = R_REG(&eir->clockcontrol_sb);
18794 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
18795 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
18796 + n = R_REG(&cc->clockcontrol_n);
18797 + if (pll_type == PLL_TYPE6)
18798 + m = R_REG(&cc->clockcontrol_mips);
18799 + else if (pll_type == PLL_TYPE3)
18800 + {
18801 + // Added by Chen-I for 5365
18802 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
18803 + m = R_REG(&cc->clockcontrol_sb);
18804 + else m = R_REG(&cc->clockcontrol_m2);
18805 + }
18806 + else
18807 + m = R_REG(&cc->clockcontrol_sb);
18808 + } else {
18809 + INTR_RESTORE(si, intr_val);
18810 + return 0;
18811 + }
18812 +
18813 + // Added by Chen-I for 5365
18814 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
18815 + {
18816 + rate = 100000000;
18817 + }
18818 + else
18819 + {
18820 + /* calculate rate */
18821 + rate = sb_clock_rate(pll_type, n, m);
18822 + if (pll_type == PLL_TYPE3) rate = rate / 2;
18823 + }
18824 +
18825 + /* switch back to previous core */
18826 + sb_setcoreidx(sbh, idx);
18827 +
18828 + INTR_RESTORE(si, intr_val);
18829 +
18830 + return rate;
18831 +}
18832 +
18833 +/* change logical "focus" to the gpio core for optimized access */
18834 +void*
18835 +sb_gpiosetcore(void *sbh)
18836 +{
18837 + sb_info_t *si;
18838 +
18839 + si = SB_INFO(sbh);
18840 +
18841 + return (sb_setcoreidx(sbh, si->gpioidx));
18842 +}
18843 +
18844 +/* mask&set gpiocontrol bits */
18845 +uint32
18846 +sb_gpiocontrol(void *sbh, uint32 mask, uint32 val)
18847 +{
18848 + sb_info_t *si;
18849 + uint regoff;
18850 +
18851 + si = SB_INFO(sbh);
18852 + regoff = 0;
18853 +
18854 + switch (si->gpioid) {
18855 + case SB_CC:
18856 + regoff = OFFSETOF(chipcregs_t, gpiocontrol);
18857 + break;
18858 +
18859 + case SB_PCI:
18860 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol);
18861 + break;
18862 +
18863 + case SB_EXTIF:
18864 + return (0);
18865 + }
18866 +
18867 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
18868 +}
18869 +
18870 +/* mask&set gpio output enable bits */
18871 +uint32
18872 +sb_gpioouten(void *sbh, uint32 mask, uint32 val)
18873 +{
18874 + sb_info_t *si;
18875 + uint regoff;
18876 +
18877 + si = SB_INFO(sbh);
18878 + regoff = 0;
18879 +
18880 + switch (si->gpioid) {
18881 + case SB_CC:
18882 + regoff = OFFSETOF(chipcregs_t, gpioouten);
18883 + break;
18884 +
18885 + case SB_PCI:
18886 + regoff = OFFSETOF(sbpciregs_t, gpioouten);
18887 + break;
18888 +
18889 + case SB_EXTIF:
18890 + regoff = OFFSETOF(extifregs_t, gpio[0].outen);
18891 + break;
18892 + }
18893 +
18894 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
18895 +}
18896 +
18897 +/* mask&set gpio output bits */
18898 +uint32
18899 +sb_gpioout(void *sbh, uint32 mask, uint32 val)
18900 +{
18901 + sb_info_t *si;
18902 + uint regoff;
18903 +
18904 + si = SB_INFO(sbh);
18905 + regoff = 0;
18906 +
18907 + switch (si->gpioid) {
18908 + case SB_CC:
18909 + regoff = OFFSETOF(chipcregs_t, gpioout);
18910 + break;
18911 +
18912 + case SB_PCI:
18913 + regoff = OFFSETOF(sbpciregs_t, gpioout);
18914 + break;
18915 +
18916 + case SB_EXTIF:
18917 + regoff = OFFSETOF(extifregs_t, gpio[0].out);
18918 + break;
18919 + }
18920 +
18921 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
18922 +}
18923 +
18924 +/* return the current gpioin register value */
18925 +uint32
18926 +sb_gpioin(void *sbh)
18927 +{
18928 + sb_info_t *si;
18929 + uint regoff;
18930 +
18931 + si = SB_INFO(sbh);
18932 + regoff = 0;
18933 +
18934 + switch (si->gpioid) {
18935 + case SB_CC:
18936 + regoff = OFFSETOF(chipcregs_t, gpioin);
18937 + break;
18938 +
18939 + case SB_PCI:
18940 + regoff = OFFSETOF(sbpciregs_t, gpioin);
18941 + break;
18942 +
18943 + case SB_EXTIF:
18944 + regoff = OFFSETOF(extifregs_t, gpioin);
18945 + break;
18946 + }
18947 +
18948 + return (sb_corereg(sbh, si->gpioidx, regoff, 0, 0));
18949 +}
18950 +
18951 +/* mask&set gpio interrupt polarity bits */
18952 +uint32
18953 +sb_gpiointpolarity(void *sbh, uint32 mask, uint32 val)
18954 +{
18955 + sb_info_t *si;
18956 + uint regoff;
18957 +
18958 + si = SB_INFO(sbh);
18959 + regoff = 0;
18960 +
18961 + switch (si->gpioid) {
18962 + case SB_CC:
18963 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity);
18964 + break;
18965 +
18966 + case SB_PCI:
18967 + /* pci gpio implementation does not support interrupt polarity */
18968 + ASSERT(0);
18969 + break;
18970 +
18971 + case SB_EXTIF:
18972 + regoff = OFFSETOF(extifregs_t, gpiointpolarity);
18973 + break;
18974 + }
18975 +
18976 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
18977 +}
18978 +
18979 +/* mask&set gpio interrupt mask bits */
18980 +uint32
18981 +sb_gpiointmask(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, gpiointmask);
18992 + break;
18993 +
18994 + case SB_PCI:
18995 + /* pci gpio implementation does not support interrupt mask */
18996 + ASSERT(0);
18997 + break;
18998 +
18999 + case SB_EXTIF:
19000 + regoff = OFFSETOF(extifregs_t, gpiointmask);
19001 + break;
19002 + }
19003 +
19004 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val));
19005 +}
19006 +
19007 +
19008 +/*
19009 + * Return the slow clock source.
19010 + * Three sources of SLOW CLOCK: LPO, Xtal, PCI
19011 + */
19012 +static uint
19013 +sb_slowclk_src(void *sbh)
19014 +{
19015 + sb_info_t *si;
19016 + chipcregs_t *cc;
19017 + uint32 v;
19018 +
19019 + si = SB_INFO(sbh);
19020 +
19021 + ASSERT(sb_coreid(sbh) == SB_CC);
19022 +
19023 + if (si->ccrev < 6) {
19024 + switch (BUSTYPE(si->bustype)) {
19025 + case PCMCIA_BUS: return (SCC_SS_XTAL);
19026 + case PCI_BUS:
19027 + v = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
19028 + if (v & PCI_CFG_GPIO_SCS)
19029 + return (SCC_SS_PCI);
19030 + else
19031 + return (SCC_SS_XTAL);
19032 + default: return (SCC_SS_XTAL);
19033 + }
19034 + } else if (si->ccrev < 10) {
19035 + cc = (chipcregs_t*) sb_setcoreidx(sbh, si->curidx);
19036 + v = R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK;
19037 + return (v);
19038 + } else {
19039 + return (SCC_SS_XTAL);
19040 + }
19041 +}
19042 +
19043 +/*
19044 + * Return the slowclock min or max frequency.
19045 + * Three sources of SLOW CLOCK:
19046 + * 1. On Chip LPO - 32khz or 160khz
19047 + * 2. On Chip Xtal OSC - 20mhz/4*(divider+1)
19048 + * 3. External PCI clock - 66mhz/4*(divider+1)
19049 + */
19050 +static uint
19051 +sb_slowclk_freq(void *sbh, bool max)
19052 +{
19053 + sb_info_t *si;
19054 + chipcregs_t *cc;
19055 + uint32 slowclk;
19056 + uint div;
19057 +
19058 + si = SB_INFO(sbh);
19059 +
19060 + ASSERT(sb_coreid(sbh) == SB_CC);
19061 +
19062 + cc = (chipcregs_t*) sb_setcoreidx(sbh, si->curidx);
19063 +
19064 + /* shouldn't be here unless we've established the chip has dynamic power control */
19065 + ASSERT(R_REG(&cc->capabilities) & CAP_PWR_CTL);
19066 +
19067 + slowclk = sb_slowclk_src(sbh);
19068 + if (si->ccrev < 6) {
19069 + if (slowclk == SCC_SS_PCI)
19070 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64));
19071 + else
19072 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32));
19073 + } else if (si->ccrev < 10) {
19074 + div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHF) + 1);
19075 + if (slowclk == SCC_SS_LPO)
19076 + return (max? LPOMAXFREQ : LPOMINFREQ);
19077 + else if (slowclk == SCC_SS_XTAL)
19078 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div));
19079 + else if (slowclk == SCC_SS_PCI)
19080 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div));
19081 + else
19082 + ASSERT(0);
19083 + } else {
19084 + /* Chipc rev 10 is InstaClock */
19085 + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHF;
19086 + div = 4 * (div + 1);
19087 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div));
19088 + }
19089 + return (0);
19090 +}
19091 +
19092 +static void
19093 +sb_pwrctl_setdelay(void *sbh, void *chipcregs)
19094 +{
19095 + sb_info_t *si;
19096 + chipcregs_t * cc;
19097 + uint slowmaxfreq, pll_delay, slowclk;
19098 + uint pll_on_delay, fref_sel_delay;
19099 +
19100 + si = SB_INFO(sbh);
19101 + pll_delay = PLL_DELAY;
19102 +
19103 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay
19104 + * since the xtal will also be powered down by dynamic power control logic.
19105 + */
19106 + slowclk = sb_slowclk_src(sbh);
19107 + if (slowclk != SCC_SS_XTAL)
19108 + pll_delay += XTAL_ON_DELAY;
19109 +
19110 + /* Starting with 4318 it is ILP that is used for the delays */
19111 + slowmaxfreq = sb_slowclk_freq(sbh, (si->ccrev >= 10) ? FALSE : TRUE);
19112 +
19113 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
19114 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
19115 +
19116 + cc = (chipcregs_t *)chipcregs;
19117 + W_REG(&cc->pll_on_delay, pll_on_delay);
19118 + W_REG(&cc->fref_sel_delay, fref_sel_delay);
19119 +}
19120 +
19121 +/* set or get slow clock divider */
19122 +int
19123 +sb_pwrctl_slowclk(void *sbh, bool set, uint *div)
19124 +{
19125 + sb_info_t *si;
19126 + uint origidx;
19127 + chipcregs_t *cc;
19128 + uint intr_val = 0;
19129 + uint err = 0;
19130 +
19131 + si = SB_INFO(sbh);
19132 +
19133 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
19134 + if (si->ccrev < 6)
19135 + return 1;
19136 +
19137 + /* chipcommon cores rev10 are a whole new ball game */
19138 + if (si->ccrev >= 10)
19139 + return 1;
19140 +
19141 + if (set && ((*div % 4) || (*div < 4)))
19142 + return 2;
19143 +
19144 + INTR_OFF(si, intr_val);
19145 + origidx = si->curidx;
19146 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
19147 + ASSERT(cc != NULL);
19148 +
19149 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) {
19150 + err = 3;
19151 + goto done;
19152 + }
19153 +
19154 + if (set) {
19155 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, ((*div / 4 - 1) << SCC_CD_SHF));
19156 + sb_pwrctl_setdelay(sbh, (void *)cc);
19157 + } else
19158 + *div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHF) + 1);
19159 +
19160 +done:
19161 + sb_setcoreidx(sbh, origidx);
19162 + INTR_RESTORE(si, intr_val);
19163 + return err;
19164 +}
19165 +
19166 +/* initialize power control delay registers */
19167 +void
19168 +sb_pwrctl_init(void *sbh)
19169 +{
19170 + sb_info_t *si;
19171 + uint origidx;
19172 + chipcregs_t *cc;
19173 +
19174 + si = SB_INFO(sbh);
19175 +
19176 + origidx = si->curidx;
19177 +
19178 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
19179 + return;
19180 +
19181 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
19182 + goto done;
19183 +
19184 + /* 4317pc does not work with SlowClock less than 5Mhz */
19185 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) {
19186 + if ((si->ccrev >= 6) && (si->ccrev < 10))
19187 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, (SCC_DEF_DIV << SCC_CD_SHF));
19188 + }
19189 +
19190 + sb_pwrctl_setdelay(sbh, (void *)cc);
19191 +
19192 +done:
19193 + sb_setcoreidx(sbh, origidx);
19194 +}
19195 +
19196 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */
19197 +uint16
19198 +sb_pwrctl_fast_pwrup_delay(void *sbh)
19199 +{
19200 + sb_info_t *si;
19201 + uint origidx;
19202 + chipcregs_t *cc;
19203 + uint slowminfreq;
19204 + uint16 fpdelay;
19205 + uint intr_val = 0;
19206 +
19207 + si = SB_INFO(sbh);
19208 + fpdelay = 0;
19209 + origidx = si->curidx;
19210 +
19211 + if (BUSTYPE(si->bustype) == SB_BUS)
19212 + goto done;
19213 +
19214 + INTR_OFF(si, intr_val);
19215 +
19216 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
19217 + goto done;
19218 +
19219 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
19220 + goto done;
19221 +
19222 + slowminfreq = sb_slowclk_freq(sbh, FALSE);
19223 + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq;
19224 +
19225 +done:
19226 + sb_setcoreidx(sbh, origidx);
19227 + INTR_RESTORE(si, intr_val);
19228 + return (fpdelay);
19229 +}
19230 +
19231 +/* turn primary xtal and/or pll off/on */
19232 +int
19233 +sb_pwrctl_xtal(void *sbh, uint what, bool on)
19234 +{
19235 + sb_info_t *si;
19236 + uint32 in, out, outen;
19237 +
19238 + si = SB_INFO(sbh);
19239 +
19240 + switch (BUSTYPE(si->bustype)) {
19241 +
19242 +
19243 + case PCMCIA_BUS:
19244 + return (0);
19245 +
19246 +
19247 + case PCI_BUS:
19248 +
19249 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof (uint32));
19250 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
19251 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32));
19252 +
19253 + /*
19254 + * Avoid glitching the clock if GPRS is already using it.
19255 + * We can't actually read the state of the PLLPD so we infer it
19256 + * by the value of XTAL_PU which *is* readable via gpioin.
19257 + */
19258 + if (on && (in & PCI_CFG_GPIO_XTAL))
19259 + return (0);
19260 +
19261 + if (what & XTAL)
19262 + outen |= PCI_CFG_GPIO_XTAL;
19263 + if (what & PLL)
19264 + outen |= PCI_CFG_GPIO_PLL;
19265 +
19266 + if (on) {
19267 + /* turn primary xtal on */
19268 + if (what & XTAL) {
19269 + out |= PCI_CFG_GPIO_XTAL;
19270 + if (what & PLL)
19271 + out |= PCI_CFG_GPIO_PLL;
19272 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
19273 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
19274 + OSL_DELAY(XTAL_ON_DELAY);
19275 + }
19276 +
19277 + /* turn pll on */
19278 + if (what & PLL) {
19279 + out &= ~PCI_CFG_GPIO_PLL;
19280 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
19281 + OSL_DELAY(2000);
19282 + }
19283 + } else {
19284 + if (what & XTAL)
19285 + out &= ~PCI_CFG_GPIO_XTAL;
19286 + if (what & PLL)
19287 + out |= PCI_CFG_GPIO_PLL;
19288 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
19289 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
19290 + }
19291 +
19292 + default:
19293 + return (-1);
19294 + }
19295 +
19296 + return (0);
19297 +}
19298 +
19299 +/* set dynamic power control mode (forceslow, forcefast, dynamic) */
19300 +/* returns true if ignore pll off is set and false if it is not */
19301 +bool
19302 +sb_pwrctl_clk(void *sbh, uint mode)
19303 +{
19304 + sb_info_t *si;
19305 + uint origidx;
19306 + chipcregs_t *cc;
19307 + uint32 scc;
19308 + bool forcefastclk=FALSE;
19309 + uint intr_val = 0;
19310 +
19311 + si = SB_INFO(sbh);
19312 +
19313 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
19314 + if (si->ccrev < 6)
19315 + return (FALSE);
19316 +
19317 + /* chipcommon cores rev10 are a whole new ball game */
19318 + if (si->ccrev >= 10)
19319 + return (FALSE);
19320 +
19321 + INTR_OFF(si, intr_val);
19322 +
19323 + origidx = si->curidx;
19324 +
19325 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
19326 + ASSERT(cc != NULL);
19327 +
19328 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
19329 + goto done;
19330 +
19331 + switch (mode) {
19332 + case CLK_FAST: /* force fast (pll) clock */
19333 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */
19334 + sb_pwrctl_xtal(sbh, XTAL, ON);
19335 +
19336 + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
19337 + break;
19338 +
19339 + case CLK_SLOW: /* force slow clock */
19340 + if ((BUSTYPE(si->bustype) == SDIO_BUS) || (BUSTYPE(si->bustype) == PCMCIA_BUS))
19341 + return (-1);
19342 +
19343 + if (si->ccrev >= 6)
19344 + OR_REG(&cc->slow_clk_ctl, SCC_FS);
19345 + break;
19346 +
19347 + case CLK_DYNAMIC: /* enable dynamic power control */
19348 + scc = R_REG(&cc->slow_clk_ctl);
19349 + scc &= ~(SCC_FS | SCC_IP | SCC_XC);
19350 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
19351 + scc |= SCC_XC;
19352 + W_REG(&cc->slow_clk_ctl, scc);
19353 +
19354 + /* for dynamic control, we have to release our xtal_pu "force on" */
19355 + if (scc & SCC_XC)
19356 + sb_pwrctl_xtal(sbh, XTAL, OFF);
19357 + break;
19358 + }
19359 +
19360 + /* Is the h/w forcing the use of the fast clk */
19361 + forcefastclk = (bool)((R_REG(&cc->slow_clk_ctl) & SCC_IP) == SCC_IP);
19362 +
19363 +done:
19364 + sb_setcoreidx(sbh, origidx);
19365 + INTR_RESTORE(si, intr_val);
19366 + return (forcefastclk);
19367 +}
19368 +
19369 +/* register driver interrupt disabling and restoring callback functions */
19370 +void
19371 +sb_register_intr_callback(void *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg)
19372 +{
19373 + sb_info_t *si;
19374 +
19375 + si = SB_INFO(sbh);
19376 + si->intr_arg = intr_arg;
19377 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn;
19378 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn;
19379 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn;
19380 + /* save current core id. when this function called, the current core
19381 + * must be the core which provides driver functions(il, et, wl, etc.)
19382 + */
19383 + si->dev_coreid = si->coreid[si->curidx];
19384 +}
19385 +
19386 +
19387 diff -urN linux-2.4.30/drivers/net/hnd/shared_ksyms.sh linux-2.4.30.dev/drivers/net/hnd/shared_ksyms.sh
19388 --- linux-2.4.30/drivers/net/hnd/shared_ksyms.sh 1970-01-01 01:00:00.000000000 +0100
19389 +++ linux-2.4.30.dev/drivers/net/hnd/shared_ksyms.sh 2005-08-22 01:34:46.527120456 +0200
19390 @@ -0,0 +1,21 @@
19391 +#!/bin/sh
19392 +#
19393 +# Copyright 2004, Broadcom Corporation
19394 +# All Rights Reserved.
19395 +#
19396 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
19397 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
19398 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
19399 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
19400 +#
19401 +# $Id: shared_ksyms.sh,v 1.1 2005/03/16 13:50:00 wbx Exp $
19402 +#
19403 +
19404 +cat <<EOF
19405 +#include <linux/config.h>
19406 +#include <linux/module.h>
19407 +EOF
19408 +
19409 +for file in $* ; do
19410 + ${NM} $file | sed -ne 's/[0-9A-Fa-f]* [DT] \([^ ]*\)/extern void \1; EXPORT_SYMBOL(\1);/p'
19411 +done
19412 diff -urN linux-2.4.30/drivers/net/wireless/Config.in linux-2.4.30.dev/drivers/net/wireless/Config.in
19413 --- linux-2.4.30/drivers/net/wireless/Config.in 2004-11-17 12:54:21.000000000 +0100
19414 +++ linux-2.4.30.dev/drivers/net/wireless/Config.in 2005-08-22 01:34:46.558115744 +0200
19415 @@ -13,6 +13,7 @@
19416 fi
19417
19418 if [ "$CONFIG_PCI" = "y" ]; then
19419 + dep_tristate ' Proprietary Broadcom BCM43xx 802.11 Wireless support' CONFIG_WL
19420 dep_tristate ' Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.) (EXPERIMENTAL)' CONFIG_PLX_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
19421 dep_tristate ' Hermes in TMD7160/NCP130 based PCI adaptor support (Pheecom WL-PCI etc.) (EXPERIMENTAL)' CONFIG_TMD_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
19422 dep_tristate ' Prism 2.5 PCI 802.11b adaptor support (EXPERIMENTAL)' CONFIG_PCI_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
19423 diff -urN linux-2.4.30/drivers/net/wl/Makefile linux-2.4.30.dev/drivers/net/wl/Makefile
19424 --- linux-2.4.30/drivers/net/wl/Makefile 1970-01-01 01:00:00.000000000 +0100
19425 +++ linux-2.4.30.dev/drivers/net/wl/Makefile 2005-08-22 01:34:46.562115136 +0200
19426 @@ -0,0 +1,26 @@
19427 +#
19428 +# Makefile for the Broadcom wl driver
19429 +#
19430 +# Copyright 2004, Broadcom Corporation
19431 +# All Rights Reserved.
19432 +#
19433 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
19434 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
19435 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
19436 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
19437 +#
19438 +# $Id: Makefile,v 1.2 2005/03/29 03:32:18 mbm Exp $
19439 +
19440 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include
19441 +
19442 +O_TARGET := wl.o
19443 +
19444 +obj-y := apsta_aeskeywrap.o apsta_aes.o apsta_bcmwpa.o apsta_d11ucode.o
19445 +obj-y += apsta_hmac.o apsta_md5.o apsta_passhash.o apsta_prf.o apsta_rc4.o
19446 +obj-y += apsta_rijndael-alg-fst.o apsta_sha1.o apsta_tkhash.o apsta_wlc_led.o
19447 +obj-y += apsta_wlc_phy.o apsta_wlc_rate.o apsta_wlc_security.o
19448 +obj-y += apsta_wlc_sup.o apsta_wlc_wet.o apsta_wl_linux.o apsta_wlc.o
19449 +
19450 +obj-m := $(O_TARGET)
19451 +
19452 +include $(TOPDIR)/Rules.make
19453 diff -urN linux-2.4.30/drivers/parport/Config.in linux-2.4.30.dev/drivers/parport/Config.in
19454 --- linux-2.4.30/drivers/parport/Config.in 2004-02-18 14:36:31.000000000 +0100
19455 +++ linux-2.4.30.dev/drivers/parport/Config.in 2005-08-22 01:34:46.571113768 +0200
19456 @@ -11,6 +11,7 @@
19457 tristate 'Parallel port support' CONFIG_PARPORT
19458 if [ "$CONFIG_PARPORT" != "n" ]; then
19459 dep_tristate ' PC-style hardware' CONFIG_PARPORT_PC $CONFIG_PARPORT
19460 + dep_tristate ' Asus WL500g parallel port' CONFIG_PARPORT_SPLINK $CONFIG_PARPORT
19461 if [ "$CONFIG_PARPORT_PC" != "n" -a "$CONFIG_SERIAL" != "n" ]; then
19462 if [ "$CONFIG_SERIAL" = "m" ]; then
19463 define_tristate CONFIG_PARPORT_PC_CML1 m
19464 diff -urN linux-2.4.30/drivers/parport/Makefile linux-2.4.30.dev/drivers/parport/Makefile
19465 --- linux-2.4.30/drivers/parport/Makefile 2004-08-08 01:26:05.000000000 +0200
19466 +++ linux-2.4.30.dev/drivers/parport/Makefile 2005-08-22 01:34:46.572113616 +0200
19467 @@ -22,6 +22,7 @@
19468
19469 obj-$(CONFIG_PARPORT) += parport.o
19470 obj-$(CONFIG_PARPORT_PC) += parport_pc.o
19471 +obj-$(CONFIG_PARPORT_SPLINK) += parport_splink.o
19472 obj-$(CONFIG_PARPORT_PC_PCMCIA) += parport_cs.o
19473 obj-$(CONFIG_PARPORT_AMIGA) += parport_amiga.o
19474 obj-$(CONFIG_PARPORT_MFC3) += parport_mfc3.o
19475 diff -urN linux-2.4.30/drivers/parport/parport_splink.c linux-2.4.30.dev/drivers/parport/parport_splink.c
19476 --- linux-2.4.30/drivers/parport/parport_splink.c 1970-01-01 01:00:00.000000000 +0100
19477 +++ linux-2.4.30.dev/drivers/parport/parport_splink.c 2005-08-22 01:34:46.573113464 +0200
19478 @@ -0,0 +1,345 @@
19479 +/* Low-level parallel port routines for the ASUS WL-500g built-in port
19480 + *
19481 + * Author: Nuno Grilo <nuno.grilo@netcabo.pt>
19482 + * Based on parport_pc source
19483 + */
19484 +
19485 +#include <linux/config.h>
19486 +#include <linux/module.h>
19487 +#include <linux/init.h>
19488 +#include <linux/ioport.h>
19489 +#include <linux/kernel.h>
19490 +#include <linux/slab.h>
19491 +#include <linux/parport.h>
19492 +#include <linux/parport_pc.h>
19493 +
19494 +#define SPLINK_ADDRESS 0xBF800010
19495 +
19496 +#undef DEBUG
19497 +
19498 +#ifdef DEBUG
19499 +#define DPRINTK printk
19500 +#else
19501 +#define DPRINTK(stuff...)
19502 +#endif
19503 +
19504 +
19505 +/* __parport_splink_frob_control differs from parport_splink_frob_control in that
19506 + * it doesn't do any extra masking. */
19507 +static __inline__ unsigned char __parport_splink_frob_control (struct parport *p,
19508 + unsigned char mask,
19509 + unsigned char val)
19510 +{
19511 + struct parport_pc_private *priv = p->physport->private_data;
19512 + unsigned char *io = (unsigned char *) p->base;
19513 + unsigned char ctr = priv->ctr;
19514 +#ifdef DEBUG_PARPORT
19515 + printk (KERN_DEBUG
19516 + "__parport_splink_frob_control(%02x,%02x): %02x -> %02x\n",
19517 + mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
19518 +#endif
19519 + ctr = (ctr & ~mask) ^ val;
19520 + ctr &= priv->ctr_writable; /* only write writable bits. */
19521 + *(io+2) = ctr;
19522 + priv->ctr = ctr; /* Update soft copy */
19523 + return ctr;
19524 +}
19525 +
19526 +
19527 +
19528 +static void parport_splink_data_forward (struct parport *p)
19529 +{
19530 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
19531 + __parport_splink_frob_control (p, 0x20, 0);
19532 +}
19533 +
19534 +static void parport_splink_data_reverse (struct parport *p)
19535 +{
19536 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
19537 + __parport_splink_frob_control (p, 0x20, 0x20);
19538 +}
19539 +
19540 +/*
19541 +static void parport_splink_interrupt(int irq, void *dev_id, struct pt_regs *regs)
19542 +{
19543 + DPRINTK(KERN_DEBUG "parport_splink: IRQ handler called\n");
19544 + parport_generic_irq(irq, (struct parport *) dev_id, regs);
19545 +}
19546 +*/
19547 +
19548 +static void parport_splink_enable_irq(struct parport *p)
19549 +{
19550 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_enable_irq called\n");
19551 + __parport_splink_frob_control (p, 0x10, 0x10);
19552 +}
19553 +
19554 +static void parport_splink_disable_irq(struct parport *p)
19555 +{
19556 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_disable_irq called\n");
19557 + __parport_splink_frob_control (p, 0x10, 0);
19558 +}
19559 +
19560 +static void parport_splink_init_state(struct pardevice *dev, struct parport_state *s)
19561 +{
19562 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_init_state called\n");
19563 + s->u.pc.ctr = 0xc | (dev->irq_func ? 0x10 : 0x0);
19564 + if (dev->irq_func &&
19565 + dev->port->irq != PARPORT_IRQ_NONE)
19566 + /* Set ackIntEn */
19567 + s->u.pc.ctr |= 0x10;
19568 +}
19569 +
19570 +static void parport_splink_save_state(struct parport *p, struct parport_state *s)
19571 +{
19572 + const struct parport_pc_private *priv = p->physport->private_data;
19573 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_save_state called\n");
19574 + s->u.pc.ctr = priv->ctr;
19575 +}
19576 +
19577 +static void parport_splink_restore_state(struct parport *p, struct parport_state *s)
19578 +{
19579 + struct parport_pc_private *priv = p->physport->private_data;
19580 + unsigned char *io = (unsigned char *) p->base;
19581 + unsigned char ctr = s->u.pc.ctr;
19582 +
19583 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_restore_state called\n");
19584 + *(io+2) = ctr;
19585 + priv->ctr = ctr;
19586 +}
19587 +
19588 +static void parport_splink_setup_interrupt(void) {
19589 + return;
19590 +}
19591 +
19592 +static void parport_splink_write_data(struct parport *p, unsigned char d) {
19593 + DPRINTK(KERN_DEBUG "parport_splink: write data called\n");
19594 + unsigned char *io = (unsigned char *) p->base;
19595 + *io = d;
19596 +}
19597 +
19598 +static unsigned char parport_splink_read_data(struct parport *p) {
19599 + DPRINTK(KERN_DEBUG "parport_splink: read data called\n");
19600 + unsigned char *io = (unsigned char *) p->base;
19601 + return *io;
19602 +}
19603 +
19604 +static void parport_splink_write_control(struct parport *p, unsigned char d)
19605 +{
19606 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
19607 + PARPORT_CONTROL_AUTOFD |
19608 + PARPORT_CONTROL_INIT |
19609 + PARPORT_CONTROL_SELECT);
19610 +
19611 + DPRINTK(KERN_DEBUG "parport_splink: write control called\n");
19612 + /* Take this out when drivers have adapted to the newer interface. */
19613 + if (d & 0x20) {
19614 + printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
19615 + p->name, p->cad->name);
19616 + parport_splink_data_reverse (p);
19617 + }
19618 +
19619 + __parport_splink_frob_control (p, wm, d & wm);
19620 +}
19621 +
19622 +static unsigned char parport_splink_read_control(struct parport *p)
19623 +{
19624 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
19625 + PARPORT_CONTROL_AUTOFD |
19626 + PARPORT_CONTROL_INIT |
19627 + PARPORT_CONTROL_SELECT);
19628 + DPRINTK(KERN_DEBUG "parport_splink: read control called\n");
19629 + const struct parport_pc_private *priv = p->physport->private_data;
19630 + return priv->ctr & wm; /* Use soft copy */
19631 +}
19632 +
19633 +static unsigned char parport_splink_frob_control (struct parport *p, unsigned char mask,
19634 + unsigned char val)
19635 +{
19636 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
19637 + PARPORT_CONTROL_AUTOFD |
19638 + PARPORT_CONTROL_INIT |
19639 + PARPORT_CONTROL_SELECT);
19640 +
19641 + DPRINTK(KERN_DEBUG "parport_splink: frob control called\n");
19642 + /* Take this out when drivers have adapted to the newer interface. */
19643 + if (mask & 0x20) {
19644 + printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
19645 + p->name, p->cad->name,
19646 + (val & 0x20) ? "reverse" : "forward");
19647 + if (val & 0x20)
19648 + parport_splink_data_reverse (p);
19649 + else
19650 + parport_splink_data_forward (p);
19651 + }
19652 +
19653 + /* Restrict mask and val to control lines. */
19654 + mask &= wm;
19655 + val &= wm;
19656 +
19657 + return __parport_splink_frob_control (p, mask, val);
19658 +}
19659 +
19660 +static unsigned char parport_splink_read_status(struct parport *p)
19661 +{
19662 + DPRINTK(KERN_DEBUG "parport_splink: read status called\n");
19663 + unsigned char *io = (unsigned char *) p->base;
19664 + return *(io+1);
19665 +}
19666 +
19667 +static void parport_splink_inc_use_count(void)
19668 +{
19669 +#ifdef MODULE
19670 + MOD_INC_USE_COUNT;
19671 +#endif
19672 +}
19673 +
19674 +static void parport_splink_dec_use_count(void)
19675 +{
19676 +#ifdef MODULE
19677 + MOD_DEC_USE_COUNT;
19678 +#endif
19679 +}
19680 +
19681 +static struct parport_operations parport_splink_ops =
19682 +{
19683 + parport_splink_write_data,
19684 + parport_splink_read_data,
19685 +
19686 + parport_splink_write_control,
19687 + parport_splink_read_control,
19688 + parport_splink_frob_control,
19689 +
19690 + parport_splink_read_status,
19691 +
19692 + parport_splink_enable_irq,
19693 + parport_splink_disable_irq,
19694 +
19695 + parport_splink_data_forward,
19696 + parport_splink_data_reverse,
19697 +
19698 + parport_splink_init_state,
19699 + parport_splink_save_state,
19700 + parport_splink_restore_state,
19701 +
19702 + parport_splink_inc_use_count,
19703 + parport_splink_dec_use_count,
19704 +
19705 + parport_ieee1284_epp_write_data,
19706 + parport_ieee1284_epp_read_data,
19707 + parport_ieee1284_epp_write_addr,
19708 + parport_ieee1284_epp_read_addr,
19709 +
19710 + parport_ieee1284_ecp_write_data,
19711 + parport_ieee1284_ecp_read_data,
19712 + parport_ieee1284_ecp_write_addr,
19713 +
19714 + parport_ieee1284_write_compat,
19715 + parport_ieee1284_read_nibble,
19716 + parport_ieee1284_read_byte,
19717 +};
19718 +
19719 +/* --- Initialisation code -------------------------------- */
19720 +
19721 +static struct parport *parport_splink_probe_port (unsigned long int base)
19722 +{
19723 + struct parport_pc_private *priv;
19724 + struct parport_operations *ops;
19725 + struct parport *p;
19726 +
19727 + if (check_mem_region(base, 3)) {
19728 + printk (KERN_DEBUG "parport (0x%lx): iomem region not available\n", base);
19729 + return NULL;
19730 + }
19731 + priv = kmalloc (sizeof (struct parport_pc_private), GFP_KERNEL);
19732 + if (!priv) {
19733 + printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base);
19734 + return NULL;
19735 + }
19736 + ops = kmalloc (sizeof (struct parport_operations), GFP_KERNEL);
19737 + if (!ops) {
19738 + printk (KERN_DEBUG "parport (0x%lx): no memory for ops!\n",
19739 + base);
19740 + kfree (priv);
19741 + return NULL;
19742 + }
19743 + memcpy (ops, &parport_splink_ops, sizeof (struct parport_operations));
19744 + priv->ctr = 0xc;
19745 + priv->ctr_writable = 0xff;
19746 +
19747 + if (!(p = parport_register_port(base, PARPORT_IRQ_NONE,
19748 + PARPORT_DMA_NONE, ops))) {
19749 + printk (KERN_DEBUG "parport (0x%lx): registration failed!\n",
19750 + base);
19751 + kfree (priv);
19752 + kfree (ops);
19753 + return NULL;
19754 + }
19755 +
19756 + p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;
19757 + p->size = (p->modes & PARPORT_MODE_EPP)?8:3;
19758 + p->private_data = priv;
19759 +
19760 + parport_proc_register(p);
19761 + request_mem_region (p->base, 3, p->name);
19762 +
19763 + /* Done probing. Now put the port into a sensible start-up state. */
19764 + parport_splink_write_data(p, 0);
19765 + parport_splink_data_forward (p);
19766 +
19767 + /* Now that we've told the sharing engine about the port, and
19768 + found out its characteristics, let the high-level drivers
19769 + know about it. */
19770 + parport_announce_port (p);
19771 +
19772 + DPRINTK(KERN_DEBUG "parport (0x%lx): init ok!\n",
19773 + base);
19774 + return p;
19775 +}
19776 +
19777 +static void parport_splink_unregister_port(struct parport *p) {
19778 + struct parport_pc_private *priv = p->private_data;
19779 + struct parport_operations *ops = p->ops;
19780 +
19781 + if (p->irq != PARPORT_IRQ_NONE)
19782 + free_irq(p->irq, p);
19783 + release_mem_region(p->base, 3);
19784 + parport_proc_unregister(p);
19785 + kfree (priv);
19786 + parport_unregister_port(p);
19787 + kfree (ops);
19788 +}
19789 +
19790 +
19791 +int parport_splink_init(void)
19792 +{
19793 + int ret;
19794 +
19795 + DPRINTK(KERN_DEBUG "parport_splink init called\n");
19796 + parport_splink_setup_interrupt();
19797 + ret = !parport_splink_probe_port(SPLINK_ADDRESS);
19798 +
19799 + return ret;
19800 +}
19801 +
19802 +void parport_splink_cleanup(void) {
19803 + struct parport *p = parport_enumerate(), *tmp;
19804 + DPRINTK(KERN_DEBUG "parport_splink cleanup called\n");
19805 + if (p->size) {
19806 + if (p->modes & PARPORT_MODE_PCSPP) {
19807 + while(p) {
19808 + tmp = p->next;
19809 + parport_splink_unregister_port(p);
19810 + p = tmp;
19811 + }
19812 + }
19813 + }
19814 +}
19815 +
19816 +MODULE_AUTHOR("Nuno Grilo <nuno.grilo@netcabo.pt>");
19817 +MODULE_DESCRIPTION("Parport Driver for ASUS WL-500g router builtin Port");
19818 +MODULE_SUPPORTED_DEVICE("ASUS WL-500g builtin Parallel Port");
19819 +MODULE_LICENSE("GPL");
19820 +
19821 +module_init(parport_splink_init)
19822 +module_exit(parport_splink_cleanup)
19823 +
19824 diff -urN linux-2.4.30/drivers/pcmcia/Makefile linux-2.4.30.dev/drivers/pcmcia/Makefile
19825 --- linux-2.4.30/drivers/pcmcia/Makefile 2005-08-22 01:29:09.704325304 +0200
19826 +++ linux-2.4.30.dev/drivers/pcmcia/Makefile 2005-08-22 01:34:46.577112856 +0200
19827 @@ -74,6 +74,10 @@
19828 au1000_ss-objs-$(CONFIG_MIPS_HYDROGEN3) += au1000_hydrogen3.o
19829 au1000_ss-objs-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o
19830
19831 +obj-$(CONFIG_PCMCIA_BCM4710) += bcm4710_ss.o
19832 +bcm4710_ss-objs := bcm4710_generic.o
19833 +bcm4710_ss-objs += bcm4710_pcmcia.o
19834 +
19835 obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o
19836 obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o
19837 obj-$(CONFIG_PCMCIA_SIBYTE) += sibyte_generic.o
19838 @@ -112,5 +116,8 @@
19839 au1x00_ss.o: $(au1000_ss-objs-y)
19840 $(LD) -r -o $@ $(au1000_ss-objs-y)
19841
19842 +bcm4710_ss.o: $(bcm4710_ss-objs)
19843 + $(LD) -r -o $@ $(bcm4710_ss-objs)
19844 +
19845 yenta_socket.o: $(yenta_socket-objs)
19846 $(LD) $(LD_RFLAG) -r -o $@ $(yenta_socket-objs)
19847 diff -urN linux-2.4.30/drivers/pcmcia/bcm4710_generic.c linux-2.4.30.dev/drivers/pcmcia/bcm4710_generic.c
19848 --- linux-2.4.30/drivers/pcmcia/bcm4710_generic.c 1970-01-01 01:00:00.000000000 +0100
19849 +++ linux-2.4.30.dev/drivers/pcmcia/bcm4710_generic.c 2005-08-22 01:34:46.574113312 +0200
19850 @@ -0,0 +1,912 @@
19851 +/*
19852 + *
19853 + * bcm47xx pcmcia driver
19854 + *
19855 + * Copyright 2004, Broadcom Corporation
19856 + * All Rights Reserved.
19857 + *
19858 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
19859 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
19860 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
19861 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
19862 + *
19863 + * Based on sa1100_generic.c from www.handhelds.org,
19864 + * and au1000_generic.c from oss.sgi.com.
19865 + *
19866 + * $Id: bcm4710_generic.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
19867 + */
19868 +#include <linux/module.h>
19869 +#include <linux/init.h>
19870 +#include <linux/config.h>
19871 +#include <linux/delay.h>
19872 +#include <linux/ioport.h>
19873 +#include <linux/kernel.h>
19874 +#include <linux/tqueue.h>
19875 +#include <linux/timer.h>
19876 +#include <linux/mm.h>
19877 +#include <linux/proc_fs.h>
19878 +#include <linux/version.h>
19879 +#include <linux/types.h>
19880 +#include <linux/vmalloc.h>
19881 +
19882 +#include <pcmcia/version.h>
19883 +#include <pcmcia/cs_types.h>
19884 +#include <pcmcia/cs.h>
19885 +#include <pcmcia/ss.h>
19886 +#include <pcmcia/bulkmem.h>
19887 +#include <pcmcia/cistpl.h>
19888 +#include <pcmcia/bus_ops.h>
19889 +#include "cs_internal.h"
19890 +
19891 +#include <asm/io.h>
19892 +#include <asm/irq.h>
19893 +#include <asm/system.h>
19894 +
19895 +#include <typedefs.h>
19896 +#include <bcm4710.h>
19897 +#include <sbextif.h>
19898 +
19899 +#include "bcm4710pcmcia.h"
19900 +
19901 +#ifdef PCMCIA_DEBUG
19902 +static int pc_debug = PCMCIA_DEBUG;
19903 +#endif
19904 +
19905 +MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm47xx Socket Controller");
19906 +
19907 +/* This structure maintains housekeeping state for each socket, such
19908 + * as the last known values of the card detect pins, or the Card Services
19909 + * callback value associated with the socket:
19910 + */
19911 +static struct bcm47xx_pcmcia_socket *pcmcia_socket;
19912 +static int socket_count;
19913 +
19914 +
19915 +/* Returned by the low-level PCMCIA interface: */
19916 +static struct pcmcia_low_level *pcmcia_low_level;
19917 +
19918 +/* Event poll timer structure */
19919 +static struct timer_list poll_timer;
19920 +
19921 +
19922 +/* Prototypes for routines which are used internally: */
19923 +
19924 +static int bcm47xx_pcmcia_driver_init(void);
19925 +static void bcm47xx_pcmcia_driver_shutdown(void);
19926 +static void bcm47xx_pcmcia_task_handler(void *data);
19927 +static void bcm47xx_pcmcia_poll_event(unsigned long data);
19928 +static void bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs);
19929 +static struct tq_struct bcm47xx_pcmcia_task;
19930 +
19931 +#ifdef CONFIG_PROC_FS
19932 +static int bcm47xx_pcmcia_proc_status(char *buf, char **start,
19933 + off_t pos, int count, int *eof, void *data);
19934 +#endif
19935 +
19936 +
19937 +/* Prototypes for operations which are exported to the
19938 + * in-kernel PCMCIA core:
19939 + */
19940 +
19941 +static int bcm47xx_pcmcia_init(unsigned int sock);
19942 +static int bcm47xx_pcmcia_suspend(unsigned int sock);
19943 +static int bcm47xx_pcmcia_register_callback(unsigned int sock,
19944 + void (*handler)(void *, unsigned int), void *info);
19945 +static int bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap);
19946 +static int bcm47xx_pcmcia_get_status(unsigned int sock, u_int *value);
19947 +static int bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state);
19948 +static int bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state);
19949 +static int bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *io);
19950 +static int bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *io);
19951 +static int bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *mem);
19952 +static int bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *mem);
19953 +#ifdef CONFIG_PROC_FS
19954 +static void bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base);
19955 +#endif
19956 +
19957 +static struct pccard_operations bcm47xx_pcmcia_operations = {
19958 + bcm47xx_pcmcia_init,
19959 + bcm47xx_pcmcia_suspend,
19960 + bcm47xx_pcmcia_register_callback,
19961 + bcm47xx_pcmcia_inquire_socket,
19962 + bcm47xx_pcmcia_get_status,
19963 + bcm47xx_pcmcia_get_socket,
19964 + bcm47xx_pcmcia_set_socket,
19965 + bcm47xx_pcmcia_get_io_map,
19966 + bcm47xx_pcmcia_set_io_map,
19967 + bcm47xx_pcmcia_get_mem_map,
19968 + bcm47xx_pcmcia_set_mem_map,
19969 +#ifdef CONFIG_PROC_FS
19970 + bcm47xx_pcmcia_proc_setup
19971 +#endif
19972 +};
19973 +
19974 +
19975 +/*
19976 + * bcm47xx_pcmcia_driver_init()
19977 + *
19978 + * This routine performs a basic sanity check to ensure that this
19979 + * kernel has been built with the appropriate board-specific low-level
19980 + * PCMCIA support, performs low-level PCMCIA initialization, registers
19981 + * this socket driver with Card Services, and then spawns the daemon
19982 + * thread which is the real workhorse of the socket driver.
19983 + *
19984 + * Please see linux/Documentation/arm/SA1100/PCMCIA for more information
19985 + * on the low-level kernel interface.
19986 + *
19987 + * Returns: 0 on success, -1 on error
19988 + */
19989 +static int __init bcm47xx_pcmcia_driver_init(void)
19990 +{
19991 + servinfo_t info;
19992 + struct pcmcia_init pcmcia_init;
19993 + struct pcmcia_state state;
19994 + unsigned int i;
19995 + unsigned long tmp;
19996 +
19997 +
19998 + printk("\nBCM47XX PCMCIA (CS release %s)\n", CS_RELEASE);
19999 +
20000 + CardServices(GetCardServicesInfo, &info);
20001 +
20002 + if (info.Revision != CS_RELEASE_CODE) {
20003 + printk(KERN_ERR "Card Services release codes do not match\n");
20004 + return -1;
20005 + }
20006 +
20007 +#ifdef CONFIG_BCM4710
20008 + pcmcia_low_level=&bcm4710_pcmcia_ops;
20009 +#else
20010 +#error Unsupported Broadcom BCM47XX board.
20011 +#endif
20012 +
20013 + pcmcia_init.handler=bcm47xx_pcmcia_interrupt;
20014 +
20015 + if ((socket_count = pcmcia_low_level->init(&pcmcia_init)) < 0) {
20016 + printk(KERN_ERR "Unable to initialize PCMCIA service.\n");
20017 + return -EIO;
20018 + } else {
20019 + printk("\t%d PCMCIA sockets initialized.\n", socket_count);
20020 + }
20021 +
20022 + pcmcia_socket =
20023 + kmalloc(sizeof(struct bcm47xx_pcmcia_socket) * socket_count,
20024 + GFP_KERNEL);
20025 + memset(pcmcia_socket, 0,
20026 + sizeof(struct bcm47xx_pcmcia_socket) * socket_count);
20027 + if (!pcmcia_socket) {
20028 + printk(KERN_ERR "Card Services can't get memory \n");
20029 + return -1;
20030 + }
20031 +
20032 + for (i = 0; i < socket_count; i++) {
20033 + if (pcmcia_low_level->socket_state(i, &state) < 0) {
20034 + printk(KERN_ERR "Unable to get PCMCIA status\n");
20035 + return -EIO;
20036 + }
20037 + pcmcia_socket[i].k_state = state;
20038 + pcmcia_socket[i].cs_state.csc_mask = SS_DETECT;
20039 +
20040 + if (i == 0) {
20041 + pcmcia_socket[i].virt_io =
20042 + (unsigned long)ioremap_nocache(EXTIF_PCMCIA_IOBASE(BCM4710_EXTIF), 0x1000);
20043 + /* Substract ioport base which gets added by in/out */
20044 + pcmcia_socket[i].virt_io -= mips_io_port_base;
20045 + pcmcia_socket[i].phys_attr =
20046 + (unsigned long)EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF);
20047 + pcmcia_socket[i].phys_mem =
20048 + (unsigned long)EXTIF_PCMCIA_MEMBASE(BCM4710_EXTIF);
20049 + } else {
20050 + printk(KERN_ERR "bcm4710: socket 1 not supported\n");
20051 + return 1;
20052 + }
20053 + }
20054 +
20055 + /* Only advertise as many sockets as we can detect: */
20056 + if (register_ss_entry(socket_count, &bcm47xx_pcmcia_operations) < 0) {
20057 + printk(KERN_ERR "Unable to register socket service routine\n");
20058 + return -ENXIO;
20059 + }
20060 +
20061 + /* Start the event poll timer.
20062 + * It will reschedule by itself afterwards.
20063 + */
20064 + bcm47xx_pcmcia_poll_event(0);
20065 +
20066 + DEBUG(1, "bcm4710: initialization complete\n");
20067 + return 0;
20068 +
20069 +}
20070 +
20071 +module_init(bcm47xx_pcmcia_driver_init);
20072 +
20073 +
20074 +/*
20075 + * bcm47xx_pcmcia_driver_shutdown()
20076 + *
20077 + * Invokes the low-level kernel service to free IRQs associated with this
20078 + * socket controller and reset GPIO edge detection.
20079 + */
20080 +static void __exit bcm47xx_pcmcia_driver_shutdown(void)
20081 +{
20082 + int i;
20083 +
20084 + del_timer_sync(&poll_timer);
20085 + unregister_ss_entry(&bcm47xx_pcmcia_operations);
20086 + pcmcia_low_level->shutdown();
20087 + flush_scheduled_tasks();
20088 + for (i = 0; i < socket_count; i++) {
20089 + if (pcmcia_socket[i].virt_io)
20090 + iounmap((void *)pcmcia_socket[i].virt_io);
20091 + if (pcmcia_socket[i].phys_attr)
20092 + iounmap((void *)pcmcia_socket[i].phys_attr);
20093 + if (pcmcia_socket[i].phys_mem)
20094 + iounmap((void *)pcmcia_socket[i].phys_mem);
20095 + }
20096 + DEBUG(1, "bcm4710: shutdown complete\n");
20097 +}
20098 +
20099 +module_exit(bcm47xx_pcmcia_driver_shutdown);
20100 +
20101 +/*
20102 + * bcm47xx_pcmcia_init()
20103 + * We perform all of the interesting initialization tasks in
20104 + * bcm47xx_pcmcia_driver_init().
20105 + *
20106 + * Returns: 0
20107 + */
20108 +static int bcm47xx_pcmcia_init(unsigned int sock)
20109 +{
20110 + DEBUG(1, "%s(): initializing socket %u\n", __FUNCTION__, sock);
20111 +
20112 + return 0;
20113 +}
20114 +
20115 +/*
20116 + * bcm47xx_pcmcia_suspend()
20117 + *
20118 + * We don't currently perform any actions on a suspend.
20119 + *
20120 + * Returns: 0
20121 + */
20122 +static int bcm47xx_pcmcia_suspend(unsigned int sock)
20123 +{
20124 + DEBUG(1, "%s(): suspending socket %u\n", __FUNCTION__, sock);
20125 +
20126 + return 0;
20127 +}
20128 +
20129 +
20130 +/*
20131 + * bcm47xx_pcmcia_events()
20132 + *
20133 + * Helper routine to generate a Card Services event mask based on
20134 + * state information obtained from the kernel low-level PCMCIA layer
20135 + * in a recent (and previous) sampling. Updates `prev_state'.
20136 + *
20137 + * Returns: an event mask for the given socket state.
20138 + */
20139 +static inline unsigned
20140 +bcm47xx_pcmcia_events(struct pcmcia_state *state,
20141 + struct pcmcia_state *prev_state,
20142 + unsigned int mask, unsigned int flags)
20143 +{
20144 + unsigned int events=0;
20145 +
20146 + if (state->bvd1 != prev_state->bvd1) {
20147 +
20148 + DEBUG(3, "%s(): card BVD1 value %u\n", __FUNCTION__, state->bvd1);
20149 +
20150 + events |= mask & (flags & SS_IOCARD) ? SS_STSCHG : SS_BATDEAD;
20151 + }
20152 +
20153 + if (state->bvd2 != prev_state->bvd2) {
20154 +
20155 + DEBUG(3, "%s(): card BVD2 value %u\n", __FUNCTION__, state->bvd2);
20156 +
20157 + events |= mask & (flags & SS_IOCARD) ? 0 : SS_BATWARN;
20158 + }
20159 +
20160 + if (state->detect != prev_state->detect) {
20161 +
20162 + DEBUG(3, "%s(): card detect value %u\n", __FUNCTION__, state->detect);
20163 +
20164 + events |= mask & SS_DETECT;
20165 + }
20166 +
20167 +
20168 + if (state->ready != prev_state->ready) {
20169 +
20170 + DEBUG(3, "%s(): card ready value %u\n", __FUNCTION__, state->ready);
20171 +
20172 + events |= mask & ((flags & SS_IOCARD) ? 0 : SS_READY);
20173 + }
20174 +
20175 + if (events != 0) {
20176 + DEBUG(2, "events: %s%s%s%s%s\n",
20177 + (events & SS_DETECT) ? "DETECT " : "",
20178 + (events & SS_READY) ? "READY " : "",
20179 + (events & SS_BATDEAD) ? "BATDEAD " : "",
20180 + (events & SS_BATWARN) ? "BATWARN " : "",
20181 + (events & SS_STSCHG) ? "STSCHG " : "");
20182 + }
20183 +
20184 + *prev_state=*state;
20185 + return events;
20186 +}
20187 +
20188 +
20189 +/*
20190 + * bcm47xx_pcmcia_task_handler()
20191 + *
20192 + * Processes serviceable socket events using the "eventd" thread context.
20193 + *
20194 + * Event processing (specifically, the invocation of the Card Services event
20195 + * callback) occurs in this thread rather than in the actual interrupt
20196 + * handler due to the use of scheduling operations in the PCMCIA core.
20197 + */
20198 +static void bcm47xx_pcmcia_task_handler(void *data)
20199 +{
20200 + struct pcmcia_state state;
20201 + int i, events, irq_status;
20202 +
20203 + DEBUG(4, "%s(): entering PCMCIA monitoring thread\n", __FUNCTION__);
20204 +
20205 + for (i = 0; i < socket_count; i++) {
20206 + if ((irq_status = pcmcia_low_level->socket_state(i, &state)) < 0)
20207 + printk(KERN_ERR "Error in kernel low-level PCMCIA service.\n");
20208 +
20209 + events = bcm47xx_pcmcia_events(&state,
20210 + &pcmcia_socket[i].k_state,
20211 + pcmcia_socket[i].cs_state.csc_mask,
20212 + pcmcia_socket[i].cs_state.flags);
20213 +
20214 + if (pcmcia_socket[i].handler != NULL) {
20215 + pcmcia_socket[i].handler(pcmcia_socket[i].handler_info,
20216 + events);
20217 + }
20218 + }
20219 +}
20220 +
20221 +static struct tq_struct bcm47xx_pcmcia_task = {
20222 + routine: bcm47xx_pcmcia_task_handler
20223 +};
20224 +
20225 +
20226 +/*
20227 + * bcm47xx_pcmcia_poll_event()
20228 + *
20229 + * Let's poll for events in addition to IRQs since IRQ only is unreliable...
20230 + */
20231 +static void bcm47xx_pcmcia_poll_event(unsigned long dummy)
20232 +{
20233 + DEBUG(4, "%s(): polling for events\n", __FUNCTION__);
20234 +
20235 + poll_timer.function = bcm47xx_pcmcia_poll_event;
20236 + poll_timer.expires = jiffies + BCM47XX_PCMCIA_POLL_PERIOD;
20237 + add_timer(&poll_timer);
20238 + schedule_task(&bcm47xx_pcmcia_task);
20239 +}
20240 +
20241 +
20242 +/*
20243 + * bcm47xx_pcmcia_interrupt()
20244 + *
20245 + * Service routine for socket driver interrupts (requested by the
20246 + * low-level PCMCIA init() operation via bcm47xx_pcmcia_thread()).
20247 + *
20248 + * The actual interrupt-servicing work is performed by
20249 + * bcm47xx_pcmcia_task(), largely because the Card Services event-
20250 + * handling code performs scheduling operations which cannot be
20251 + * executed from within an interrupt context.
20252 + */
20253 +static void
20254 +bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs)
20255 +{
20256 + DEBUG(3, "%s(): servicing IRQ %d\n", __FUNCTION__, irq);
20257 + schedule_task(&bcm47xx_pcmcia_task);
20258 +}
20259 +
20260 +
20261 +/*
20262 + * bcm47xx_pcmcia_register_callback()
20263 + *
20264 + * Implements the register_callback() operation for the in-kernel
20265 + * PCMCIA service (formerly SS_RegisterCallback in Card Services). If
20266 + * the function pointer `handler' is not NULL, remember the callback
20267 + * location in the state for `sock', and increment the usage counter
20268 + * for the driver module. (The callback is invoked from the interrupt
20269 + * service routine, bcm47xx_pcmcia_interrupt(), to notify Card Services
20270 + * of interesting events.) Otherwise, clear the callback pointer in the
20271 + * socket state and decrement the module usage count.
20272 + *
20273 + * Returns: 0
20274 + */
20275 +static int
20276 +bcm47xx_pcmcia_register_callback(unsigned int sock,
20277 + void (*handler)(void *, unsigned int), void *info)
20278 +{
20279 + if (handler == NULL) {
20280 + pcmcia_socket[sock].handler = NULL;
20281 + MOD_DEC_USE_COUNT;
20282 + } else {
20283 + MOD_INC_USE_COUNT;
20284 + pcmcia_socket[sock].handler = handler;
20285 + pcmcia_socket[sock].handler_info = info;
20286 + }
20287 + return 0;
20288 +}
20289 +
20290 +
20291 +/*
20292 + * bcm47xx_pcmcia_inquire_socket()
20293 + *
20294 + * Implements the inquire_socket() operation for the in-kernel PCMCIA
20295 + * service (formerly SS_InquireSocket in Card Services). Of note is
20296 + * the setting of the SS_CAP_PAGE_REGS bit in the `features' field of
20297 + * `cap' to "trick" Card Services into tolerating large "I/O memory"
20298 + * addresses. Also set is SS_CAP_STATIC_MAP, which disables the memory
20299 + * resource database check. (Mapped memory is set up within the socket
20300 + * driver itself.)
20301 + *
20302 + * In conjunction with the STATIC_MAP capability is a new field,
20303 + * `io_offset', recommended by David Hinds. Rather than go through
20304 + * the SetIOMap interface (which is not quite suited for communicating
20305 + * window locations up from the socket driver), we just pass up
20306 + * an offset which is applied to client-requested base I/O addresses
20307 + * in alloc_io_space().
20308 + *
20309 + * Returns: 0 on success, -1 if no pin has been configured for `sock'
20310 + */
20311 +static int
20312 +bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap)
20313 +{
20314 + struct pcmcia_irq_info irq_info;
20315 +
20316 + if (sock >= socket_count) {
20317 + printk(KERN_ERR "bcm47xx: socket %u not configured\n", sock);
20318 + return -1;
20319 + }
20320 +
20321 + /* SS_CAP_PAGE_REGS: used by setup_cis_mem() in cistpl.c to set the
20322 + * force_low argument to validate_mem() in rsrc_mgr.c -- since in
20323 + * general, the mapped * addresses of the PCMCIA memory regions
20324 + * will not be within 0xffff, setting force_low would be
20325 + * undesirable.
20326 + *
20327 + * SS_CAP_STATIC_MAP: don't bother with the (user-configured) memory
20328 + * resource database; we instead pass up physical address ranges
20329 + * and allow other parts of Card Services to deal with remapping.
20330 + *
20331 + * SS_CAP_PCCARD: we can deal with 16-bit PCMCIA & CF cards, but
20332 + * not 32-bit CardBus devices.
20333 + */
20334 + cap->features = (SS_CAP_PAGE_REGS | SS_CAP_STATIC_MAP | SS_CAP_PCCARD);
20335 +
20336 + irq_info.sock = sock;
20337 + irq_info.irq = -1;
20338 +
20339 + if (pcmcia_low_level->get_irq_info(&irq_info) < 0) {
20340 + printk(KERN_ERR "Error obtaining IRQ info socket %u\n", sock);
20341 + return -1;
20342 + }
20343 +
20344 + cap->irq_mask = 0;
20345 + cap->map_size = PAGE_SIZE;
20346 + cap->pci_irq = irq_info.irq;
20347 + cap->io_offset = pcmcia_socket[sock].virt_io;
20348 +
20349 + return 0;
20350 +}
20351 +
20352 +
20353 +/*
20354 + * bcm47xx_pcmcia_get_status()
20355 + *
20356 + * Implements the get_status() operation for the in-kernel PCMCIA
20357 + * service (formerly SS_GetStatus in Card Services). Essentially just
20358 + * fills in bits in `status' according to internal driver state or
20359 + * the value of the voltage detect chipselect register.
20360 + *
20361 + * As a debugging note, during card startup, the PCMCIA core issues
20362 + * three set_socket() commands in a row the first with RESET deasserted,
20363 + * the second with RESET asserted, and the last with RESET deasserted
20364 + * again. Following the third set_socket(), a get_status() command will
20365 + * be issued. The kernel is looking for the SS_READY flag (see
20366 + * setup_socket(), reset_socket(), and unreset_socket() in cs.c).
20367 + *
20368 + * Returns: 0
20369 + */
20370 +static int
20371 +bcm47xx_pcmcia_get_status(unsigned int sock, unsigned int *status)
20372 +{
20373 + struct pcmcia_state state;
20374 +
20375 +
20376 + if ((pcmcia_low_level->socket_state(sock, &state)) < 0) {
20377 + printk(KERN_ERR "Unable to get PCMCIA status from kernel.\n");
20378 + return -1;
20379 + }
20380 +
20381 + pcmcia_socket[sock].k_state = state;
20382 +
20383 + *status = state.detect ? SS_DETECT : 0;
20384 +
20385 + *status |= state.ready ? SS_READY : 0;
20386 +
20387 + /* The power status of individual sockets is not available
20388 + * explicitly from the hardware, so we just remember the state
20389 + * and regurgitate it upon request:
20390 + */
20391 + *status |= pcmcia_socket[sock].cs_state.Vcc ? SS_POWERON : 0;
20392 +
20393 + if (pcmcia_socket[sock].cs_state.flags & SS_IOCARD)
20394 + *status |= state.bvd1 ? SS_STSCHG : 0;
20395 + else {
20396 + if (state.bvd1 == 0)
20397 + *status |= SS_BATDEAD;
20398 + else if (state.bvd2 == 0)
20399 + *status |= SS_BATWARN;
20400 + }
20401 +
20402 + *status |= state.vs_3v ? SS_3VCARD : 0;
20403 +
20404 + *status |= state.vs_Xv ? SS_XVCARD : 0;
20405 +
20406 + DEBUG(2, "\tstatus: %s%s%s%s%s%s%s%s\n",
20407 + (*status&SS_DETECT)?"DETECT ":"",
20408 + (*status&SS_READY)?"READY ":"",
20409 + (*status&SS_BATDEAD)?"BATDEAD ":"",
20410 + (*status&SS_BATWARN)?"BATWARN ":"",
20411 + (*status&SS_POWERON)?"POWERON ":"",
20412 + (*status&SS_STSCHG)?"STSCHG ":"",
20413 + (*status&SS_3VCARD)?"3VCARD ":"",
20414 + (*status&SS_XVCARD)?"XVCARD ":"");
20415 +
20416 + return 0;
20417 +}
20418 +
20419 +
20420 +/*
20421 + * bcm47xx_pcmcia_get_socket()
20422 + *
20423 + * Implements the get_socket() operation for the in-kernel PCMCIA
20424 + * service (formerly SS_GetSocket in Card Services). Not a very
20425 + * exciting routine.
20426 + *
20427 + * Returns: 0
20428 + */
20429 +static int
20430 +bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state)
20431 +{
20432 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
20433 +
20434 + /* This information was given to us in an earlier call to set_socket(),
20435 + * so we're just regurgitating it here:
20436 + */
20437 + *state = pcmcia_socket[sock].cs_state;
20438 + return 0;
20439 +}
20440 +
20441 +
20442 +/*
20443 + * bcm47xx_pcmcia_set_socket()
20444 + *
20445 + * Implements the set_socket() operation for the in-kernel PCMCIA
20446 + * service (formerly SS_SetSocket in Card Services). We more or
20447 + * less punt all of this work and let the kernel handle the details
20448 + * of power configuration, reset, &c. We also record the value of
20449 + * `state' in order to regurgitate it to the PCMCIA core later.
20450 + *
20451 + * Returns: 0
20452 + */
20453 +static int
20454 +bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state)
20455 +{
20456 + struct pcmcia_configure configure;
20457 +
20458 + DEBUG(2, "\tmask: %s%s%s%s%s%s\n\tflags: %s%s%s%s%s%s\n"
20459 + "\tVcc %d Vpp %d irq %d\n",
20460 + (state->csc_mask == 0) ? "<NONE>" : "",
20461 + (state->csc_mask & SS_DETECT) ? "DETECT " : "",
20462 + (state->csc_mask & SS_READY) ? "READY " : "",
20463 + (state->csc_mask & SS_BATDEAD) ? "BATDEAD " : "",
20464 + (state->csc_mask & SS_BATWARN) ? "BATWARN " : "",
20465 + (state->csc_mask & SS_STSCHG) ? "STSCHG " : "",
20466 + (state->flags == 0) ? "<NONE>" : "",
20467 + (state->flags & SS_PWR_AUTO) ? "PWR_AUTO " : "",
20468 + (state->flags & SS_IOCARD) ? "IOCARD " : "",
20469 + (state->flags & SS_RESET) ? "RESET " : "",
20470 + (state->flags & SS_SPKR_ENA) ? "SPKR_ENA " : "",
20471 + (state->flags & SS_OUTPUT_ENA) ? "OUTPUT_ENA " : "",
20472 + state->Vcc, state->Vpp, state->io_irq);
20473 +
20474 + configure.sock = sock;
20475 + configure.vcc = state->Vcc;
20476 + configure.vpp = state->Vpp;
20477 + configure.output = (state->flags & SS_OUTPUT_ENA) ? 1 : 0;
20478 + configure.speaker = (state->flags & SS_SPKR_ENA) ? 1 : 0;
20479 + configure.reset = (state->flags & SS_RESET) ? 1 : 0;
20480 +
20481 + if (pcmcia_low_level->configure_socket(&configure) < 0) {
20482 + printk(KERN_ERR "Unable to configure socket %u\n", sock);
20483 + return -1;
20484 + }
20485 +
20486 + pcmcia_socket[sock].cs_state = *state;
20487 + return 0;
20488 +}
20489 +
20490 +
20491 +/*
20492 + * bcm47xx_pcmcia_get_io_map()
20493 + *
20494 + * Implements the get_io_map() operation for the in-kernel PCMCIA
20495 + * service (formerly SS_GetIOMap in Card Services). Just returns an
20496 + * I/O map descriptor which was assigned earlier by a set_io_map().
20497 + *
20498 + * Returns: 0 on success, -1 if the map index was out of range
20499 + */
20500 +static int
20501 +bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *map)
20502 +{
20503 + DEBUG(2, "bcm47xx_pcmcia_get_io_map: sock %d\n", sock);
20504 +
20505 + if (map->map >= MAX_IO_WIN) {
20506 + printk(KERN_ERR "%s(): map (%d) out of range\n",
20507 + __FUNCTION__, map->map);
20508 + return -1;
20509 + }
20510 +
20511 + *map = pcmcia_socket[sock].io_map[map->map];
20512 + return 0;
20513 +}
20514 +
20515 +
20516 +/*
20517 + * bcm47xx_pcmcia_set_io_map()
20518 + *
20519 + * Implements the set_io_map() operation for the in-kernel PCMCIA
20520 + * service (formerly SS_SetIOMap in Card Services). We configure
20521 + * the map speed as requested, but override the address ranges
20522 + * supplied by Card Services.
20523 + *
20524 + * Returns: 0 on success, -1 on error
20525 + */
20526 +int
20527 +bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *map)
20528 +{
20529 + unsigned int speed;
20530 + unsigned long start;
20531 +
20532 + DEBUG(2, "\tmap %u speed %u\n\tstart 0x%08lx stop 0x%08lx\n"
20533 + "\tflags: %s%s%s%s%s%s%s%s\n",
20534 + map->map, map->speed, map->start, map->stop,
20535 + (map->flags == 0) ? "<NONE>" : "",
20536 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
20537 + (map->flags & MAP_16BIT) ? "16BIT " : "",
20538 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
20539 + (map->flags & MAP_0WS) ? "0WS " : "",
20540 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
20541 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "",
20542 + (map->flags & MAP_PREFETCH) ? "PREFETCH " : "");
20543 +
20544 + if (map->map >= MAX_IO_WIN) {
20545 + printk(KERN_ERR "%s(): map (%d) out of range\n",
20546 + __FUNCTION__, map->map);
20547 + return -1;
20548 + }
20549 +
20550 + if (map->flags & MAP_ACTIVE) {
20551 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_IO_SPEED;
20552 + pcmcia_socket[sock].speed_io = speed;
20553 + }
20554 +
20555 + start = map->start;
20556 +
20557 + if (map->stop == 1) {
20558 + map->stop = PAGE_SIZE - 1;
20559 + }
20560 +
20561 + map->start = pcmcia_socket[sock].virt_io;
20562 + map->stop = map->start + (map->stop - start);
20563 + pcmcia_socket[sock].io_map[map->map] = *map;
20564 + DEBUG(2, "set_io_map %d start %x stop %x\n",
20565 + map->map, map->start, map->stop);
20566 + return 0;
20567 +}
20568 +
20569 +
20570 +/*
20571 + * bcm47xx_pcmcia_get_mem_map()
20572 + *
20573 + * Implements the get_mem_map() operation for the in-kernel PCMCIA
20574 + * service (formerly SS_GetMemMap in Card Services). Just returns a
20575 + * memory map descriptor which was assigned earlier by a
20576 + * set_mem_map() request.
20577 + *
20578 + * Returns: 0 on success, -1 if the map index was out of range
20579 + */
20580 +static int
20581 +bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *map)
20582 +{
20583 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
20584 +
20585 + if (map->map >= MAX_WIN) {
20586 + printk(KERN_ERR "%s(): map (%d) out of range\n",
20587 + __FUNCTION__, map->map);
20588 + return -1;
20589 + }
20590 +
20591 + *map = pcmcia_socket[sock].mem_map[map->map];
20592 + return 0;
20593 +}
20594 +
20595 +
20596 +/*
20597 + * bcm47xx_pcmcia_set_mem_map()
20598 + *
20599 + * Implements the set_mem_map() operation for the in-kernel PCMCIA
20600 + * service (formerly SS_SetMemMap in Card Services). We configure
20601 + * the map speed as requested, but override the address ranges
20602 + * supplied by Card Services.
20603 + *
20604 + * Returns: 0 on success, -1 on error
20605 + */
20606 +static int
20607 +bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *map)
20608 +{
20609 + unsigned int speed;
20610 + unsigned long start;
20611 + u_long flags;
20612 +
20613 + if (map->map >= MAX_WIN) {
20614 + printk(KERN_ERR "%s(): map (%d) out of range\n",
20615 + __FUNCTION__, map->map);
20616 + return -1;
20617 + }
20618 +
20619 + DEBUG(2, "\tmap %u speed %u\n\tsys_start %#lx\n"
20620 + "\tsys_stop %#lx\n\tcard_start %#x\n"
20621 + "\tflags: %s%s%s%s%s%s%s%s\n",
20622 + map->map, map->speed, map->sys_start, map->sys_stop,
20623 + map->card_start, (map->flags == 0) ? "<NONE>" : "",
20624 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
20625 + (map->flags & MAP_16BIT) ? "16BIT " : "",
20626 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
20627 + (map->flags & MAP_0WS) ? "0WS " : "",
20628 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
20629 + (map->flags & MAP_ATTRIB) ? "ATTRIB " : "",
20630 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "");
20631 +
20632 + if (map->flags & MAP_ACTIVE) {
20633 + /* When clients issue RequestMap, the access speed is not always
20634 + * properly configured:
20635 + */
20636 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_MEM_SPEED;
20637 +
20638 + /* TBD */
20639 + if (map->flags & MAP_ATTRIB) {
20640 + pcmcia_socket[sock].speed_attr = speed;
20641 + } else {
20642 + pcmcia_socket[sock].speed_mem = speed;
20643 + }
20644 + }
20645 +
20646 + save_flags(flags);
20647 + cli();
20648 + start = map->sys_start;
20649 +
20650 + if (map->sys_stop == 0)
20651 + map->sys_stop = PAGE_SIZE - 1;
20652 +
20653 + if (map->flags & MAP_ATTRIB) {
20654 + map->sys_start = pcmcia_socket[sock].phys_attr +
20655 + map->card_start;
20656 + } else {
20657 + map->sys_start = pcmcia_socket[sock].phys_mem +
20658 + map->card_start;
20659 + }
20660 +
20661 + map->sys_stop = map->sys_start + (map->sys_stop - start);
20662 + pcmcia_socket[sock].mem_map[map->map] = *map;
20663 + restore_flags(flags);
20664 + DEBUG(2, "set_mem_map %d start %x stop %x card_start %x\n",
20665 + map->map, map->sys_start, map->sys_stop,
20666 + map->card_start);
20667 + return 0;
20668 +}
20669 +
20670 +
20671 +#if defined(CONFIG_PROC_FS)
20672 +
20673 +/*
20674 + * bcm47xx_pcmcia_proc_setup()
20675 + *
20676 + * Implements the proc_setup() operation for the in-kernel PCMCIA
20677 + * service (formerly SS_ProcSetup in Card Services).
20678 + *
20679 + * Returns: 0 on success, -1 on error
20680 + */
20681 +static void
20682 +bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base)
20683 +{
20684 + struct proc_dir_entry *entry;
20685 +
20686 + if ((entry = create_proc_entry("status", 0, base)) == NULL) {
20687 + printk(KERN_ERR "Unable to install \"status\" procfs entry\n");
20688 + return;
20689 + }
20690 +
20691 + entry->read_proc = bcm47xx_pcmcia_proc_status;
20692 + entry->data = (void *)sock;
20693 +}
20694 +
20695 +
20696 +/*
20697 + * bcm47xx_pcmcia_proc_status()
20698 + *
20699 + * Implements the /proc/bus/pccard/??/status file.
20700 + *
20701 + * Returns: the number of characters added to the buffer
20702 + */
20703 +static int
20704 +bcm47xx_pcmcia_proc_status(char *buf, char **start, off_t pos,
20705 + int count, int *eof, void *data)
20706 +{
20707 + char *p = buf;
20708 + unsigned int sock = (unsigned int)data;
20709 +
20710 + p += sprintf(p, "k_flags : %s%s%s%s%s%s%s\n",
20711 + pcmcia_socket[sock].k_state.detect ? "detect " : "",
20712 + pcmcia_socket[sock].k_state.ready ? "ready " : "",
20713 + pcmcia_socket[sock].k_state.bvd1 ? "bvd1 " : "",
20714 + pcmcia_socket[sock].k_state.bvd2 ? "bvd2 " : "",
20715 + pcmcia_socket[sock].k_state.wrprot ? "wrprot " : "",
20716 + pcmcia_socket[sock].k_state.vs_3v ? "vs_3v " : "",
20717 + pcmcia_socket[sock].k_state.vs_Xv ? "vs_Xv " : "");
20718 +
20719 + p += sprintf(p, "status : %s%s%s%s%s%s%s%s%s\n",
20720 + pcmcia_socket[sock].k_state.detect ? "SS_DETECT " : "",
20721 + pcmcia_socket[sock].k_state.ready ? "SS_READY " : "",
20722 + pcmcia_socket[sock].cs_state.Vcc ? "SS_POWERON " : "",
20723 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ? "SS_IOCARD " : "",
20724 + (pcmcia_socket[sock].cs_state.flags & SS_IOCARD &&
20725 + pcmcia_socket[sock].k_state.bvd1) ? "SS_STSCHG " : "",
20726 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
20727 + (pcmcia_socket[sock].k_state.bvd1 == 0)) ? "SS_BATDEAD " : "",
20728 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
20729 + (pcmcia_socket[sock].k_state.bvd2 == 0)) ? "SS_BATWARN " : "",
20730 + pcmcia_socket[sock].k_state.vs_3v ? "SS_3VCARD " : "",
20731 + pcmcia_socket[sock].k_state.vs_Xv ? "SS_XVCARD " : "");
20732 +
20733 + p += sprintf(p, "mask : %s%s%s%s%s\n",
20734 + pcmcia_socket[sock].cs_state.csc_mask & SS_DETECT ? "SS_DETECT " : "",
20735 + pcmcia_socket[sock].cs_state.csc_mask & SS_READY ? "SS_READY " : "",
20736 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATDEAD ? "SS_BATDEAD " : "",
20737 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATWARN ? "SS_BATWARN " : "",
20738 + pcmcia_socket[sock].cs_state.csc_mask & SS_STSCHG ? "SS_STSCHG " : "");
20739 +
20740 + p += sprintf(p, "cs_flags : %s%s%s%s%s\n",
20741 + pcmcia_socket[sock].cs_state.flags & SS_PWR_AUTO ?
20742 + "SS_PWR_AUTO " : "",
20743 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ?
20744 + "SS_IOCARD " : "",
20745 + pcmcia_socket[sock].cs_state.flags & SS_RESET ?
20746 + "SS_RESET " : "",
20747 + pcmcia_socket[sock].cs_state.flags & SS_SPKR_ENA ?
20748 + "SS_SPKR_ENA " : "",
20749 + pcmcia_socket[sock].cs_state.flags & SS_OUTPUT_ENA ?
20750 + "SS_OUTPUT_ENA " : "");
20751 +
20752 + p += sprintf(p, "Vcc : %d\n", pcmcia_socket[sock].cs_state.Vcc);
20753 + p += sprintf(p, "Vpp : %d\n", pcmcia_socket[sock].cs_state.Vpp);
20754 + p += sprintf(p, "irq : %d\n", pcmcia_socket[sock].cs_state.io_irq);
20755 + p += sprintf(p, "I/O : %u\n", pcmcia_socket[sock].speed_io);
20756 + p += sprintf(p, "attribute: %u\n", pcmcia_socket[sock].speed_attr);
20757 + p += sprintf(p, "common : %u\n", pcmcia_socket[sock].speed_mem);
20758 + return p-buf;
20759 +}
20760 +
20761 +
20762 +#endif /* defined(CONFIG_PROC_FS) */
20763 diff -urN linux-2.4.30/drivers/pcmcia/bcm4710_pcmcia.c linux-2.4.30.dev/drivers/pcmcia/bcm4710_pcmcia.c
20764 --- linux-2.4.30/drivers/pcmcia/bcm4710_pcmcia.c 1970-01-01 01:00:00.000000000 +0100
20765 +++ linux-2.4.30.dev/drivers/pcmcia/bcm4710_pcmcia.c 2005-08-22 01:34:46.575113160 +0200
20766 @@ -0,0 +1,266 @@
20767 +/*
20768 + * BCM4710 specific pcmcia routines.
20769 + *
20770 + * Copyright 2004, Broadcom Corporation
20771 + * All Rights Reserved.
20772 + *
20773 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
20774 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
20775 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
20776 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
20777 + *
20778 + * $Id: bcm4710_pcmcia.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
20779 + */
20780 +#include <linux/module.h>
20781 +#include <linux/init.h>
20782 +#include <linux/config.h>
20783 +#include <linux/delay.h>
20784 +#include <linux/ioport.h>
20785 +#include <linux/kernel.h>
20786 +#include <linux/tqueue.h>
20787 +#include <linux/timer.h>
20788 +#include <linux/mm.h>
20789 +#include <linux/proc_fs.h>
20790 +#include <linux/version.h>
20791 +#include <linux/types.h>
20792 +#include <linux/pci.h>
20793 +
20794 +#include <pcmcia/version.h>
20795 +#include <pcmcia/cs_types.h>
20796 +#include <pcmcia/cs.h>
20797 +#include <pcmcia/ss.h>
20798 +#include <pcmcia/bulkmem.h>
20799 +#include <pcmcia/cistpl.h>
20800 +#include <pcmcia/bus_ops.h>
20801 +#include "cs_internal.h"
20802 +
20803 +#include <asm/io.h>
20804 +#include <asm/irq.h>
20805 +#include <asm/system.h>
20806 +
20807 +
20808 +#include <typedefs.h>
20809 +#include <bcmdevs.h>
20810 +#include <bcm4710.h>
20811 +#include <sbconfig.h>
20812 +#include <sbextif.h>
20813 +
20814 +#include "bcm4710pcmcia.h"
20815 +
20816 +/* Use a static var for irq dev_id */
20817 +static int bcm47xx_pcmcia_dev_id;
20818 +
20819 +/* Do we think we have a card or not? */
20820 +static int bcm47xx_pcmcia_present = 0;
20821 +
20822 +
20823 +static void bcm4710_pcmcia_reset(void)
20824 +{
20825 + extifregs_t *eir;
20826 + unsigned long s;
20827 + uint32 out0, out1, outen;
20828 +
20829 +
20830 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
20831 +
20832 + save_and_cli(s);
20833 +
20834 + /* Use gpio7 to reset the pcmcia slot */
20835 + outen = readl(&eir->gpio[0].outen);
20836 + outen |= BCM47XX_PCMCIA_RESET;
20837 + out0 = readl(&eir->gpio[0].out);
20838 + out0 &= ~(BCM47XX_PCMCIA_RESET);
20839 + out1 = out0 | BCM47XX_PCMCIA_RESET;
20840 +
20841 + writel(out0, &eir->gpio[0].out);
20842 + writel(outen, &eir->gpio[0].outen);
20843 + mdelay(1);
20844 + writel(out1, &eir->gpio[0].out);
20845 + mdelay(1);
20846 + writel(out0, &eir->gpio[0].out);
20847 +
20848 + restore_flags(s);
20849 +}
20850 +
20851 +
20852 +static int bcm4710_pcmcia_init(struct pcmcia_init *init)
20853 +{
20854 + struct pci_dev *pdev;
20855 + extifregs_t *eir;
20856 + uint32 outen, intp, intm, tmp;
20857 + uint16 *attrsp;
20858 + int rc = 0, i;
20859 + extern unsigned long bcm4710_cpu_cycle;
20860 +
20861 +
20862 + if (!(pdev = pci_find_device(VENDOR_BROADCOM, SB_EXTIF, NULL))) {
20863 + printk(KERN_ERR "bcm4710_pcmcia: extif not found\n");
20864 + return -ENODEV;
20865 + }
20866 + eir = (extifregs_t *) ioremap_nocache(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
20867 +
20868 + /* Initialize the pcmcia i/f: 16bit no swap */
20869 + writel(CF_EM_PCMCIA | CF_DS | CF_EN, &eir->pcmcia_config);
20870 +
20871 +#ifdef notYet
20872 +
20873 + /* Set the timing for memory accesses */
20874 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
20875 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
20876 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
20877 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
20878 + writel(tmp, &eir->pcmcia_memwait); /* 0x01020a0c for a 100Mhz clock */
20879 +
20880 + /* Set the timing for I/O accesses */
20881 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
20882 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
20883 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
20884 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
20885 + writel(tmp, &eir->pcmcia_iowait); /* 0x01020a0c for a 100Mhz clock */
20886 +
20887 + /* Set the timing for attribute accesses */
20888 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
20889 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
20890 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
20891 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
20892 + writel(tmp, &eir->pcmcia_attrwait); /* 0x01020a0c for a 100Mhz clock */
20893 +
20894 +#endif
20895 + /* Make sure gpio0 and gpio5 are inputs */
20896 + outen = readl(&eir->gpio[0].outen);
20897 + outen &= ~(BCM47XX_PCMCIA_WP | BCM47XX_PCMCIA_STSCHG | BCM47XX_PCMCIA_RESET);
20898 + writel(outen, &eir->gpio[0].outen);
20899 +
20900 + /* Issue a reset to the pcmcia socket */
20901 + bcm4710_pcmcia_reset();
20902 +
20903 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
20904 + /* Setup gpio5 to be the STSCHG interrupt */
20905 + intp = readl(&eir->gpiointpolarity);
20906 + writel(intp | BCM47XX_PCMCIA_STSCHG, &eir->gpiointpolarity); /* Active low */
20907 + intm = readl(&eir->gpiointmask);
20908 + writel(intm | BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Enable it */
20909 +#endif
20910 +
20911 + DEBUG(2, "bcm4710_pcmcia after reset:\n");
20912 + DEBUG(2, "\textstatus\t= 0x%08x:\n", readl(&eir->extstatus));
20913 + DEBUG(2, "\tpcmcia_config\t= 0x%08x:\n", readl(&eir->pcmcia_config));
20914 + DEBUG(2, "\tpcmcia_memwait\t= 0x%08x:\n", readl(&eir->pcmcia_memwait));
20915 + DEBUG(2, "\tpcmcia_attrwait\t= 0x%08x:\n", readl(&eir->pcmcia_attrwait));
20916 + DEBUG(2, "\tpcmcia_iowait\t= 0x%08x:\n", readl(&eir->pcmcia_iowait));
20917 + DEBUG(2, "\tgpioin\t\t= 0x%08x:\n", readl(&eir->gpioin));
20918 + DEBUG(2, "\tgpio_outen0\t= 0x%08x:\n", readl(&eir->gpio[0].outen));
20919 + DEBUG(2, "\tgpio_out0\t= 0x%08x:\n", readl(&eir->gpio[0].out));
20920 + DEBUG(2, "\tgpiointpolarity\t= 0x%08x:\n", readl(&eir->gpiointpolarity));
20921 + DEBUG(2, "\tgpiointmask\t= 0x%08x:\n", readl(&eir->gpiointmask));
20922 +
20923 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
20924 + /* Request pcmcia interrupt */
20925 + rc = request_irq(BCM47XX_PCMCIA_IRQ, init->handler, SA_INTERRUPT,
20926 + "PCMCIA Interrupt", &bcm47xx_pcmcia_dev_id);
20927 +#endif
20928 +
20929 + attrsp = (uint16 *)ioremap_nocache(EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF), 0x1000);
20930 + tmp = readw(&attrsp[0]);
20931 + DEBUG(2, "\tattr[0] = 0x%04x\n", tmp);
20932 + if ((tmp == 0x7fff) || (tmp == 0x7f00)) {
20933 + bcm47xx_pcmcia_present = 0;
20934 + } else {
20935 + bcm47xx_pcmcia_present = 1;
20936 + }
20937 +
20938 + /* There's only one socket */
20939 + return 1;
20940 +}
20941 +
20942 +static int bcm4710_pcmcia_shutdown(void)
20943 +{
20944 + extifregs_t *eir;
20945 + uint32 intm;
20946 +
20947 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
20948 +
20949 + /* Disable the pcmcia i/f */
20950 + writel(0, &eir->pcmcia_config);
20951 +
20952 + /* Reset gpio's */
20953 + intm = readl(&eir->gpiointmask);
20954 + writel(intm & ~BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Disable it */
20955 +
20956 + free_irq(BCM47XX_PCMCIA_IRQ, &bcm47xx_pcmcia_dev_id);
20957 +
20958 + return 0;
20959 +}
20960 +
20961 +static int
20962 +bcm4710_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
20963 +{
20964 + extifregs_t *eir;
20965 +
20966 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
20967 +
20968 +
20969 + if (sock != 0) {
20970 + printk(KERN_ERR "bcm4710 socket_state bad sock %d\n", sock);
20971 + return -1;
20972 + }
20973 +
20974 + if (bcm47xx_pcmcia_present) {
20975 + state->detect = 1;
20976 + state->ready = 1;
20977 + state->bvd1 = 1;
20978 + state->bvd2 = 1;
20979 + state->wrprot = (readl(&eir->gpioin) & BCM47XX_PCMCIA_WP) == BCM47XX_PCMCIA_WP;
20980 + state->vs_3v = 0;
20981 + state->vs_Xv = 0;
20982 + } else {
20983 + state->detect = 0;
20984 + state->ready = 0;
20985 + }
20986 +
20987 + return 1;
20988 +}
20989 +
20990 +
20991 +static int bcm4710_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
20992 +{
20993 + if (info->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
20994 +
20995 + info->irq = BCM47XX_PCMCIA_IRQ;
20996 +
20997 + return 0;
20998 +}
20999 +
21000 +
21001 +static int
21002 +bcm4710_pcmcia_configure_socket(const struct pcmcia_configure *configure)
21003 +{
21004 + if (configure->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
21005 +
21006 +
21007 + DEBUG(2, "Vcc %dV Vpp %dV output %d speaker %d reset %d\n", configure->vcc,
21008 + configure->vpp, configure->output, configure->speaker, configure->reset);
21009 +
21010 + if ((configure->vcc != 50) || (configure->vpp != 50)) {
21011 + printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc,
21012 + configure->vpp);
21013 + }
21014 +
21015 + if (configure->reset) {
21016 + /* Issue a reset to the pcmcia socket */
21017 + DEBUG(1, "%s: Reseting socket\n", __FUNCTION__);
21018 + bcm4710_pcmcia_reset();
21019 + }
21020 +
21021 +
21022 + return 0;
21023 +}
21024 +
21025 +struct pcmcia_low_level bcm4710_pcmcia_ops = {
21026 + bcm4710_pcmcia_init,
21027 + bcm4710_pcmcia_shutdown,
21028 + bcm4710_pcmcia_socket_state,
21029 + bcm4710_pcmcia_get_irq_info,
21030 + bcm4710_pcmcia_configure_socket
21031 +};
21032 +
21033 diff -urN linux-2.4.30/drivers/pcmcia/bcm4710pcmcia.h linux-2.4.30.dev/drivers/pcmcia/bcm4710pcmcia.h
21034 --- linux-2.4.30/drivers/pcmcia/bcm4710pcmcia.h 1970-01-01 01:00:00.000000000 +0100
21035 +++ linux-2.4.30.dev/drivers/pcmcia/bcm4710pcmcia.h 2005-08-22 01:34:46.576113008 +0200
21036 @@ -0,0 +1,118 @@
21037 +/*
21038 + *
21039 + * bcm47xx pcmcia driver
21040 + *
21041 + * Copyright 2004, Broadcom Corporation
21042 + * All Rights Reserved.
21043 + *
21044 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
21045 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
21046 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
21047 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
21048 + *
21049 + * Based on sa1100.h and include/asm-arm/arch-sa1100/pcmica.h
21050 + * from www.handhelds.org,
21051 + * and au1000_generic.c from oss.sgi.com.
21052 + *
21053 + * $Id: bcm4710pcmcia.h,v 1.1 2005/03/16 13:50:00 wbx Exp $
21054 + */
21055 +
21056 +#if !defined(_BCM4710PCMCIA_H)
21057 +#define _BCM4710PCMCIA_H
21058 +
21059 +#include <pcmcia/cs_types.h>
21060 +#include <pcmcia/ss.h>
21061 +#include <pcmcia/bulkmem.h>
21062 +#include <pcmcia/cistpl.h>
21063 +#include "cs_internal.h"
21064 +
21065 +
21066 +/* The 47xx can only support one socket */
21067 +#define BCM47XX_PCMCIA_MAX_SOCK 1
21068 +
21069 +/* In the bcm947xx gpio's are used for some pcmcia functions */
21070 +#define BCM47XX_PCMCIA_WP 0x01 /* Bit 0 is WP input */
21071 +#define BCM47XX_PCMCIA_STSCHG 0x20 /* Bit 5 is STSCHG input/interrupt */
21072 +#define BCM47XX_PCMCIA_RESET 0x80 /* Bit 7 is RESET */
21073 +
21074 +#define BCM47XX_PCMCIA_IRQ 2
21075 +
21076 +/* The socket driver actually works nicely in interrupt-driven form,
21077 + * so the (relatively infrequent) polling is "just to be sure."
21078 + */
21079 +#define BCM47XX_PCMCIA_POLL_PERIOD (2 * HZ)
21080 +
21081 +#define BCM47XX_PCMCIA_IO_SPEED (255)
21082 +#define BCM47XX_PCMCIA_MEM_SPEED (300)
21083 +
21084 +
21085 +struct pcmcia_state {
21086 + unsigned detect: 1,
21087 + ready: 1,
21088 + bvd1: 1,
21089 + bvd2: 1,
21090 + wrprot: 1,
21091 + vs_3v: 1,
21092 + vs_Xv: 1;
21093 +};
21094 +
21095 +
21096 +struct pcmcia_configure {
21097 + unsigned sock: 8,
21098 + vcc: 8,
21099 + vpp: 8,
21100 + output: 1,
21101 + speaker: 1,
21102 + reset: 1;
21103 +};
21104 +
21105 +struct pcmcia_irq_info {
21106 + unsigned int sock;
21107 + unsigned int irq;
21108 +};
21109 +
21110 +/* This structure encapsulates per-socket state which we might need to
21111 + * use when responding to a Card Services query of some kind.
21112 + */
21113 +struct bcm47xx_pcmcia_socket {
21114 + socket_state_t cs_state;
21115 + struct pcmcia_state k_state;
21116 + unsigned int irq;
21117 + void (*handler)(void *, unsigned int);
21118 + void *handler_info;
21119 + pccard_io_map io_map[MAX_IO_WIN];
21120 + pccard_mem_map mem_map[MAX_WIN];
21121 + ioaddr_t virt_io, phys_attr, phys_mem;
21122 + unsigned short speed_io, speed_attr, speed_mem;
21123 +};
21124 +
21125 +struct pcmcia_init {
21126 + void (*handler)(int irq, void *dev, struct pt_regs *regs);
21127 +};
21128 +
21129 +struct pcmcia_low_level {
21130 + int (*init)(struct pcmcia_init *);
21131 + int (*shutdown)(void);
21132 + int (*socket_state)(unsigned sock, struct pcmcia_state *);
21133 + int (*get_irq_info)(struct pcmcia_irq_info *);
21134 + int (*configure_socket)(const struct pcmcia_configure *);
21135 +};
21136 +
21137 +extern struct pcmcia_low_level bcm47xx_pcmcia_ops;
21138 +
21139 +/* I/O pins replacing memory pins
21140 + * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75)
21141 + *
21142 + * These signals change meaning when going from memory-only to
21143 + * memory-or-I/O interface:
21144 + */
21145 +#define iostschg bvd1
21146 +#define iospkr bvd2
21147 +
21148 +
21149 +/*
21150 + * Declaration for implementation specific low_level operations.
21151 + */
21152 +extern struct pcmcia_low_level bcm4710_pcmcia_ops;
21153 +
21154 +#endif /* !defined(_BCM4710PCMCIA_H) */
21155 diff -urN linux-2.4.30/include/asm-mips/bootinfo.h linux-2.4.30.dev/include/asm-mips/bootinfo.h
21156 --- linux-2.4.30/include/asm-mips/bootinfo.h 2005-08-22 01:29:10.024276664 +0200
21157 +++ linux-2.4.30.dev/include/asm-mips/bootinfo.h 2005-08-22 01:34:46.612107536 +0200
21158 @@ -37,6 +37,7 @@
21159 #define MACH_GROUP_HP_LJ 20 /* Hewlett Packard LaserJet */
21160 #define MACH_GROUP_LASAT 21
21161 #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
21162 +#define MACH_GROUP_BRCM 23 /* Broadcom */
21163
21164 /*
21165 * Valid machtype values for group unknown (low order halfword of mips_machtype)
21166 @@ -197,6 +198,15 @@
21167 #define MACH_TANBAC_TB0229 7 /* TANBAC TB0229 (VR4131DIMM) */
21168
21169 /*
21170 + * Valid machtypes for group Broadcom
21171 + */
21172 +#define MACH_BCM93725 0
21173 +#define MACH_BCM93725_VJ 1
21174 +#define MACH_BCM93730 2
21175 +#define MACH_BCM947XX 3
21176 +#define MACH_BCM933XX 4
21177 +
21178 +/*
21179 * Valid machtype for group TITAN
21180 */
21181 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
21182 diff -urN linux-2.4.30/include/asm-mips/cpu.h linux-2.4.30.dev/include/asm-mips/cpu.h
21183 --- linux-2.4.30/include/asm-mips/cpu.h 2005-01-19 15:10:11.000000000 +0100
21184 +++ linux-2.4.30.dev/include/asm-mips/cpu.h 2005-08-22 01:34:46.629104952 +0200
21185 @@ -22,6 +22,11 @@
21186 spec.
21187 */
21188
21189 +#define PRID_COPT_MASK 0xff000000
21190 +#define PRID_COMP_MASK 0x00ff0000
21191 +#define PRID_IMP_MASK 0x0000ff00
21192 +#define PRID_REV_MASK 0x000000ff
21193 +
21194 #define PRID_COMP_LEGACY 0x000000
21195 #define PRID_COMP_MIPS 0x010000
21196 #define PRID_COMP_BROADCOM 0x020000
21197 @@ -58,6 +63,7 @@
21198 #define PRID_IMP_RM7000 0x2700
21199 #define PRID_IMP_NEVADA 0x2800 /* RM5260 ??? */
21200 #define PRID_IMP_RM9000 0x3400
21201 +#define PRID_IMP_BCM4710 0x4000
21202 #define PRID_IMP_R5432 0x5400
21203 #define PRID_IMP_R5500 0x5500
21204 #define PRID_IMP_4KC 0x8000
21205 @@ -66,10 +72,16 @@
21206 #define PRID_IMP_4KEC 0x8400
21207 #define PRID_IMP_4KSC 0x8600
21208 #define PRID_IMP_25KF 0x8800
21209 +#define PRID_IMP_BCM3302 0x9000
21210 +#define PRID_IMP_BCM3303 0x9100
21211 #define PRID_IMP_24K 0x9300
21212
21213 #define PRID_IMP_UNKNOWN 0xff00
21214
21215 +#define BCM330X(id) \
21216 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
21217 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
21218 +
21219 /*
21220 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
21221 */
21222 @@ -174,7 +186,9 @@
21223 #define CPU_AU1550 57
21224 #define CPU_24K 58
21225 #define CPU_AU1200 59
21226 -#define CPU_LAST 59
21227 +#define CPU_BCM4710 60
21228 +#define CPU_BCM3302 61
21229 +#define CPU_LAST 61
21230
21231 /*
21232 * ISA Level encodings
21233 diff -urN linux-2.4.30/include/asm-mips/r4kcache.h linux-2.4.30.dev/include/asm-mips/r4kcache.h
21234 --- linux-2.4.30/include/asm-mips/r4kcache.h 2004-02-18 14:36:32.000000000 +0100
21235 +++ linux-2.4.30.dev/include/asm-mips/r4kcache.h 2005-08-22 01:34:46.637103736 +0200
21236 @@ -567,4 +567,17 @@
21237 cache128_unroll32(addr|ws,Index_Writeback_Inv_SD);
21238 }
21239
21240 +extern inline void fill_icache_line(unsigned long addr)
21241 +{
21242 + __asm__ __volatile__(
21243 + ".set noreorder\n\t"
21244 + ".set mips3\n\t"
21245 + "cache %1, (%0)\n\t"
21246 + ".set mips0\n\t"
21247 + ".set reorder"
21248 + :
21249 + : "r" (addr),
21250 + "i" (Fill));
21251 +}
21252 +
21253 #endif /* __ASM_R4KCACHE_H */
21254 diff -urN linux-2.4.30/include/asm-mips/serial.h linux-2.4.30.dev/include/asm-mips/serial.h
21255 --- linux-2.4.30/include/asm-mips/serial.h 2005-01-19 15:10:12.000000000 +0100
21256 +++ linux-2.4.30.dev/include/asm-mips/serial.h 2005-08-22 01:34:46.645102520 +0200
21257 @@ -223,6 +223,13 @@
21258 #define TXX927_SERIAL_PORT_DEFNS
21259 #endif
21260
21261 +#ifdef CONFIG_BCM947XX
21262 +/* reserve 4 ports to be configured at runtime */
21263 +#define BCM947XX_SERIAL_PORT_DEFNS { 0, }, { 0, }, { 0, }, { 0, },
21264 +#else
21265 +#define BCM947XX_SERIAL_PORT_DEFNS
21266 +#endif
21267 +
21268 #ifdef CONFIG_HAVE_STD_PC_SERIAL_PORT
21269 #define STD_SERIAL_PORT_DEFNS \
21270 /* UART CLK PORT IRQ FLAGS */ \
21271 @@ -470,6 +477,7 @@
21272 #define SERIAL_PORT_DFNS \
21273 ATLAS_SERIAL_PORT_DEFNS \
21274 AU1000_SERIAL_PORT_DEFNS \
21275 + BCM947XX_SERIAL_PORT_DEFNS \
21276 COBALT_SERIAL_PORT_DEFNS \
21277 DDB5477_SERIAL_PORT_DEFNS \
21278 EV96100_SERIAL_PORT_DEFNS \
21279 diff -urN linux-2.4.30/init/do_mounts.c linux-2.4.30.dev/init/do_mounts.c
21280 --- linux-2.4.30/init/do_mounts.c 2005-08-22 01:29:10.628184856 +0200
21281 +++ linux-2.4.30.dev/init/do_mounts.c 2005-08-22 01:34:46.668099024 +0200
21282 @@ -254,7 +254,13 @@
21283 { "ftlb", 0x2c08 },
21284 { "ftlc", 0x2c10 },
21285 { "ftld", 0x2c18 },
21286 +#if defined(CONFIG_MTD_BLOCK) || defined(CONFIG_MTD_BLOCK_RO)
21287 { "mtdblock", 0x1f00 },
21288 + { "mtdblock0",0x1f00 },
21289 + { "mtdblock1",0x1f01 },
21290 + { "mtdblock2",0x1f02 },
21291 + { "mtdblock3",0x1f03 },
21292 +#endif
21293 { "nb", 0x2b00 },
21294 { NULL, 0 }
21295 };
This page took 1.200286 seconds and 5 git commands to generate.