1 diff -urN linux.old/Makefile linux.dev/Makefile
2 --- linux.old/Makefile 2005-08-26 13:41:41.689634168 +0200
3 +++ linux.dev/Makefile 2005-08-26 13:44:34.233403528 +0200
5 FINDHPATH = $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net $(HPATH)/math-emu
8 -HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
9 +HOSTCFLAGS = -Wall -Wstrict-prototypes -Os -fomit-frame-pointer
15 # Include the make variables (CC, etc...)
18 CPPFLAGS := -D__KERNEL__ -I$(HPATH)
20 -CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
21 +CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
22 -fno-strict-aliasing -fno-common
25 ifndef CONFIG_FRAME_POINTER
26 CFLAGS += -fomit-frame-pointer
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
38 ifdef CONFIG_MODVERSIONS
39 $(MAKE) update-modverfile
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
45 ifdef CONFIG_MODVERSIONS
46 diff -urN linux.old/Rules.make linux.dev/Rules.make
47 --- linux.old/Rules.make 2005-11-07 23:12:50.538884250 +0100
48 +++ linux.dev/Rules.make 2005-11-07 21:57:07.837585250 +0100
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; \
64 .PHONY: modules_install
65 diff -urN linux.old/arch/mips/Makefile linux.dev/arch/mips/Makefile
66 --- linux.old/arch/mips/Makefile 2005-11-07 23:12:50.582887000 +0100
67 +++ linux.dev/arch/mips/Makefile 2005-11-07 21:57:08.537629000 +0100
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
77 -ifdef CONFIG_DEBUG_INFO
78 +ifdef CONFIG_REMOTE_DEBUG
80 ifdef CONFIG_SB1XXX_CORELIS
81 GCCFLAGS += -mno-sched-prolog -fno-omit-frame-pointer
83 set_gccflags = $(shell \
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 && \
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 && \
100 gas_abi=-Wa,-32; gas_cpu=$$cpu; gas_isa=-Wa,$$isa; \
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 && \
110 AFLAGS += $(GCCFLAGS)
111 +ASFLAGS += $(GCCFLAGS)
112 CFLAGS += $(GCCFLAGS)
119 +# Broadcom BCM947XX variants
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
127 + $(MAKE) -C arch/$(ARCH)/bcm947xx/compressed
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.
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
142 @$(MAKEBOOT) mrproper
143 diff -urN linux.old/arch/mips/bcm947xx/Makefile linux.dev/arch/mips/bcm947xx/Makefile
144 --- linux.old/arch/mips/bcm947xx/Makefile 1970-01-01 01:00:00.000000000 +0100
145 +++ linux.dev/arch/mips/bcm947xx/Makefile 2005-11-08 00:55:04.392074500 +0100
148 +# Makefile for the BCM947xx specific kernel interface routines
152 +EXTRA_CFLAGS+=-I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
154 +O_TARGET := bcm947xx.o
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 sflash.o
159 +obj-$(CONFIG_PCI) += sbpci.o pcibios.o
161 +include $(TOPDIR)/Rules.make
162 diff -urN linux.old/arch/mips/bcm947xx/compressed/Makefile linux.dev/arch/mips/bcm947xx/compressed/Makefile
163 --- linux.old/arch/mips/bcm947xx/compressed/Makefile 1970-01-01 01:00:00.000000000 +0100
164 +++ linux.dev/arch/mips/bcm947xx/compressed/Makefile 2005-11-07 21:57:07.841585500 +0100
167 +# Makefile for Broadcom BCM947XX boards
169 +# Copyright 2001-2003, Broadcom Corporation
170 +# All Rights Reserved.
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.
177 +# $Id: Makefile,v 1.2 2005/04/02 12:12:57 wbx Exp $
180 +OBJCOPY_ARGS = -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
181 +SYSTEM ?= $(TOPDIR)/vmlinux
185 +# Don't build dependencies, this may die if $(CC) isn't gcc
188 +# Create a gzipped version named vmlinuz for compatibility
193 + $(OBJCOPY) $(OBJCOPY_ARGS) $< $@
198 + rm -f vmlinuz piggy
199 diff -urN linux.old/arch/mips/bcm947xx/generic/Makefile linux.dev/arch/mips/bcm947xx/generic/Makefile
200 --- linux.old/arch/mips/bcm947xx/generic/Makefile 1970-01-01 01:00:00.000000000 +0100
201 +++ linux.dev/arch/mips/bcm947xx/generic/Makefile 2005-11-07 21:57:07.841585500 +0100
204 +# Makefile for the BCM947xx specific kernel interface routines
209 + $(CPP) $(AFLAGS) $< -o $*.s
211 + $(CC) $(AFLAGS) -c $< -o $*.o
215 +obj-y := int-handler.o irq.o
217 +include $(TOPDIR)/Rules.make
218 diff -urN linux.old/arch/mips/bcm947xx/generic/int-handler.S linux.dev/arch/mips/bcm947xx/generic/int-handler.S
219 --- linux.old/arch/mips/bcm947xx/generic/int-handler.S 1970-01-01 01:00:00.000000000 +0100
220 +++ linux.dev/arch/mips/bcm947xx/generic/int-handler.S 2005-11-07 21:57:07.841585500 +0100
223 + * Generic interrupt handler for Broadcom MIPS boards
225 + * Copyright 2004, Broadcom Corporation
226 + * All Rights Reserved.
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.
233 + * $Id: int-handler.S,v 1.1 2005/03/16 13:50:00 wbx Exp $
236 +#include <linux/config.h>
238 +#include <asm/asm.h>
239 +#include <asm/mipsregs.h>
240 +#include <asm/regdef.h>
241 +#include <asm/stackframe.h>
246 + * 0 Software (ignored)
247 + * 1 Software (ignored)
248 + * 2 Combined hardware interrupt (hw0)
260 + NESTED(brcmIRQ, PT_SIZE, sp)
266 + jal brcm_irq_dispatch
273 diff -urN linux.old/arch/mips/bcm947xx/generic/irq.c linux.dev/arch/mips/bcm947xx/generic/irq.c
274 --- linux.old/arch/mips/bcm947xx/generic/irq.c 1970-01-01 01:00:00.000000000 +0100
275 +++ linux.dev/arch/mips/bcm947xx/generic/irq.c 2005-11-07 21:57:07.841585500 +0100
278 + * Generic interrupt control functions for Broadcom MIPS boards
280 + * Copyright 2004, Broadcom Corporation
281 + * All Rights Reserved.
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.
288 + * $Id: irq.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
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>
298 +#include <asm/irq.h>
299 +#include <asm/mipsregs.h>
300 +#include <asm/gdb-stub.h>
302 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
304 +extern asmlinkage void brcmIRQ(void);
305 +extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs);
308 +brcm_irq_dispatch(struct pt_regs *regs)
312 + cause = read_c0_cause() &
316 +#ifdef CONFIG_KERNPROF
317 + change_c0_status(cause | 1, 1);
319 + clear_c0_status(cause);
322 + if (cause & CAUSEF_IP7)
324 + if (cause & CAUSEF_IP2)
326 + if (cause & CAUSEF_IP3)
328 + if (cause & CAUSEF_IP4)
330 + if (cause & CAUSEF_IP5)
332 + if (cause & CAUSEF_IP6)
337 +enable_brcm_irq(unsigned int irq)
340 + set_c0_status(1 << (irq + 8));
342 + set_c0_status(IE_IRQ0);
346 +disable_brcm_irq(unsigned int irq)
349 + clear_c0_status(1 << (irq + 8));
351 + clear_c0_status(IE_IRQ0);
355 +ack_brcm_irq(unsigned int irq)
357 + /* Already done in brcm_irq_dispatch */
361 +startup_brcm_irq(unsigned int irq)
363 + enable_brcm_irq(irq);
365 + return 0; /* never anything pending */
369 +end_brcm_irq(unsigned int irq)
371 + if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
372 + enable_brcm_irq(irq);
375 +static struct hw_interrupt_type brcm_irq_type = {
377 + startup: startup_brcm_irq,
378 + shutdown: disable_brcm_irq,
379 + enable: enable_brcm_irq,
380 + disable: disable_brcm_irq,
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;
398 + set_except_vector(0, brcmIRQ);
399 + change_c0_status(ST0_IM, ALLINTS);
401 +#ifdef CONFIG_REMOTE_DEBUG
402 + printk("Breaking into debugger...\n");
407 diff -urN linux.old/arch/mips/bcm947xx/gpio.c linux.dev/arch/mips/bcm947xx/gpio.c
408 --- linux.old/arch/mips/bcm947xx/gpio.c 1970-01-01 01:00:00.000000000 +0100
409 +++ linux.dev/arch/mips/bcm947xx/gpio.c 2005-11-07 23:58:34.968754500 +0100
414 + * Copyright 2005, Broadcom Corporation
415 + * All Rights Reserved.
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.
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>
431 +#include <typedefs.h>
432 +#include <bcmutils.h>
433 +#include <sbutils.h>
434 +#include <bcmdevs.h>
436 +static sb_t *gpio_sbh;
437 +static int gpio_major;
438 +static devfs_handle_t gpio_dir;
441 + devfs_handle_t handle;
446 + { "control", NULL }
450 +gpio_open(struct inode *inode, struct file * file)
452 + if (MINOR(inode->i_rdev) > ARRAYSIZE(gpio_file))
460 +gpio_release(struct inode *inode, struct file * file)
467 +gpio_read(struct file *file, char *buf, size_t count, loff_t *ppos)
471 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
473 + val = sb_gpioin(gpio_sbh);
476 + val = sb_gpioout(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY);
479 + val = sb_gpioouten(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY);
482 + val = sb_gpiocontrol(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY);
488 + if (put_user(val, (u32 *) buf))
491 + return sizeof(val);
495 +gpio_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
499 + if (get_user(val, (u32 *) buf))
502 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
506 + sb_gpioout(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY);
509 + sb_gpioouten(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY);
512 + sb_gpiocontrol(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY);
518 + return sizeof(val);
521 +static struct file_operations gpio_fops = {
522 + owner: THIS_MODULE,
524 + release: gpio_release,
534 + if (!(gpio_sbh = sb_kattach()))
537 + sb_gpiosetcore(gpio_sbh);
539 + if ((gpio_major = devfs_register_chrdev(0, "gpio", &gpio_fops)) < 0)
542 + gpio_dir = devfs_mk_dir(NULL, "gpio", NULL);
544 + for (i = 0; i < ARRAYSIZE(gpio_file); i++) {
545 + gpio_file[i].handle = devfs_register(gpio_dir,
547 + DEVFS_FL_DEFAULT, gpio_major, i,
548 + S_IFCHR | S_IRUGO | S_IWUGO,
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);
567 +module_init(gpio_init);
568 +module_exit(gpio_exit);
569 diff -urN linux.old/arch/mips/bcm947xx/include/bcmdevs.h linux.dev/arch/mips/bcm947xx/include/bcmdevs.h
570 --- linux.old/arch/mips/bcm947xx/include/bcmdevs.h 1970-01-01 01:00:00.000000000 +0100
571 +++ linux.dev/arch/mips/bcm947xx/include/bcmdevs.h 2005-11-07 22:51:38.772725750 +0100
574 + * Broadcom device-specific manifest constants.
576 + * Copyright 2005, Broadcom Corporation
577 + * All Rights Reserved.
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.
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
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
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 */
611 +#define BCM3352_DEVICE_ID 0x3352 /* bcm3352 device id */
612 +#define BCM3360_DEVICE_ID 0x3360 /* bcm3360 device id */
614 +#define EPI41210_DEVICE_ID 0xa0fa /* bcm4210 */
615 +#define EPI41230_DEVICE_ID 0xa10e /* bcm4230 */
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 */
629 +#define BCM4710_DEVICE_ID 0x4710 /* 4710 primary function 0 */
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 */
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 */
643 +#define BCM4301_DEVICE_ID 0x4301 /* 4301 primary function 0 */
644 +#define BCM4301_D11B_ID 0x4301 /* 4301 802.11b */
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 */
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 */
659 +#define BCM4309_PKG_ID 1 /* 4309 package id */
661 +#define BCM4303_D11B_ID 0x4303 /* 4303 802.11b */
662 +#define BCM4303_PKG_ID 2 /* 4303 package id */
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 */
670 +#define BCMGPRS_UART_ID 0x4333 /* Uart id used by 4306/gprs card */
671 +#define BCMGPRS2_UART_ID 0x4344 /* Uart id used by 4306/gprs card */
674 +#define BCM4704_DEVICE_ID 0x4704 /* 4704 chipcommon chipid */
675 +#define BCM4704_ENET_ID 0x4706 /* 4704 enet (Use 47XX_ENET_ID instead!) */
677 +#define BCM4317_DEVICE_ID 0x4317 /* 4317 chip common chipid */
679 +#define BCM4318_DEVICE_ID 0x4318 /* 4318 chip common chipid */
680 +#define BCM4318_D11G_ID 0x4318 /* 4318 801.11b/g id */
681 +#define BCM4318_D11DUAL_ID 0x4319 /* 4318 801.11a/b/g id */
682 +#define BCM4318_JTAGM_ID 0x4331 /* 4318 jtagm device id */
684 +#define FPGA_JTAGM_ID 0x4330 /* ??? */
687 +#define BCM4710_SDRAM 0x00000000 /* Physical SDRAM */
688 +#define BCM4710_PCI_MEM 0x08000000 /* Host Mode PCI memory access space (64 MB) */
689 +#define BCM4710_PCI_CFG 0x0c000000 /* Host Mode PCI configuration space (64 MB) */
690 +#define BCM4710_PCI_DMA 0x40000000 /* Client Mode PCI memory access space (1 GB) */
691 +#define BCM4710_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
692 +#define BCM4710_ENUM 0x18000000 /* Beginning of core enumeration space */
694 +/* Core register space */
695 +#define BCM4710_REG_SDRAM 0x18000000 /* SDRAM core registers */
696 +#define BCM4710_REG_ILINE20 0x18001000 /* InsideLine20 core registers */
697 +#define BCM4710_REG_EMAC0 0x18002000 /* Ethernet MAC 0 core registers */
698 +#define BCM4710_REG_CODEC 0x18003000 /* Codec core registers */
699 +#define BCM4710_REG_USB 0x18004000 /* USB core registers */
700 +#define BCM4710_REG_PCI 0x18005000 /* PCI core registers */
701 +#define BCM4710_REG_MIPS 0x18006000 /* MIPS core registers */
702 +#define BCM4710_REG_EXTIF 0x18007000 /* External Interface core registers */
703 +#define BCM4710_REG_EMAC1 0x18008000 /* Ethernet MAC 1 core registers */
705 +#define BCM4710_EXTIF 0x1f000000 /* External Interface base address */
706 +#define BCM4710_PCMCIA_MEM 0x1f000000 /* External Interface PCMCIA memory access */
707 +#define BCM4710_PCMCIA_IO 0x1f100000 /* PCMCIA I/O access */
708 +#define BCM4710_PCMCIA_CONF 0x1f200000 /* PCMCIA configuration */
709 +#define BCM4710_PROG 0x1f800000 /* Programable interface */
710 +#define BCM4710_FLASH 0x1fc00000 /* Flash */
712 +#define BCM4710_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
714 +#define BCM4710_UART (BCM4710_REG_EXTIF + 0x00000300)
716 +#define BCM4710_EUART (BCM4710_EXTIF + 0x00800000)
717 +#define BCM4710_LED (BCM4710_EXTIF + 0x00900000)
719 +#define BCM4712_DEVICE_ID 0x4712 /* 4712 chipcommon chipid */
720 +#define BCM4712_MIPS_ID 0x4720 /* 4712 base devid */
721 +#define BCM4712LARGE_PKG_ID 0 /* 340pin 4712 package id */
722 +#define BCM4712SMALL_PKG_ID 1 /* 200pin 4712 package id */
723 +#define BCM4712MID_PKG_ID 2 /* 225pin 4712 package id */
725 +#define SDIOH_FPGA_ID 0x4380 /* sdio host fpga */
727 +#define BCM5365_DEVICE_ID 0x5365 /* 5365 chipcommon chipid */
728 +#define BCM5350_DEVICE_ID 0x5350 /* bcm5350 chipcommon chipid */
729 +#define BCM5352_DEVICE_ID 0x5352 /* bcm5352 chipcommon chipid */
731 +#define BCM4320_DEVICE_ID 0x4320 /* bcm4320 chipcommon chipid */
733 +/* PCMCIA vendor Id's */
735 +#define VENDOR_BROADCOM_PCMCIA 0x02d0
737 +/* SDIO vendor Id's */
738 +#define VENDOR_BROADCOM_SDIO 0x00BF
742 +#define BFL_BTCOEXIST 0x0001 /* This board implements Bluetooth coexistance */
743 +#define BFL_PACTRL 0x0002 /* This board has gpio 9 controlling the PA */
744 +#define BFL_AIRLINEMODE 0x0004 /* This board implements gpio13 radio disable indication */
745 +#define BFL_ENETROBO 0x0010 /* This board has robo switch or core */
746 +#define BFL_CCKHIPWR 0x0040 /* Can do high-power CCK transmission */
747 +#define BFL_ENETADM 0x0080 /* This board has ADMtek switch */
748 +#define BFL_ENETVLAN 0x0100 /* This board has vlan capability */
749 +#define BFL_AFTERBURNER 0x0200 /* This board supports Afterburner mode */
750 +#define BFL_NOPCI 0x0400 /* This board leaves PCI floating */
751 +#define BFL_FEM 0x0800 /* This board supports the Front End Module */
752 +#define BFL_EXTLNA 0x1000 /* This board has an external LNA */
753 +#define BFL_HGPA 0x2000 /* This board has a high gain PA */
754 +#define BFL_BTCMOD 0x4000 /* This board' BTCOEXIST is in the alternate gpios */
755 +#define BFL_ALTIQ 0x8000 /* Alternate I/Q settings */
757 +/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */
758 +#define BOARD_GPIO_HWRAD_B 0x010 /* bit 4 is HWRAD input on 4301 */
759 +#define BOARD_GPIO_BTCMOD_IN 0x010 /* bit 4 is the alternate BT Coexistance Input */
760 +#define BOARD_GPIO_BTCMOD_OUT 0x020 /* bit 5 is the alternate BT Coexistance Out */
761 +#define BOARD_GPIO_BTC_IN 0x080 /* bit 7 is BT Coexistance Input */
762 +#define BOARD_GPIO_BTC_OUT 0x100 /* bit 8 is BT Coexistance Out */
763 +#define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */
764 +#define PCI_CFG_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */
765 +#define PCI_CFG_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */
766 +#define PCI_CFG_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
767 +#define PCI_CFG_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
770 +#define SB_BUS 0 /* Silicon Backplane */
771 +#define PCI_BUS 1 /* PCI target */
772 +#define PCMCIA_BUS 2 /* PCMCIA target */
773 +#define SDIO_BUS 3 /* SDIO target */
774 +#define JTAG_BUS 4 /* JTAG */
776 +/* Allows optimization for single-bus support */
778 +#define BUSTYPE(bus) (BCMBUSTYPE)
780 +#define BUSTYPE(bus) (bus)
783 +/* power control defines */
784 +#define PLL_DELAY 150 /* us pll on delay */
785 +#define FREF_DELAY 200 /* us fref change delay */
786 +#define MIN_SLOW_CLK 32 /* us Slow clock period */
787 +#define XTAL_ON_DELAY 1000 /* us crystal power-on delay */
789 +/* Reference Board Types */
791 +#define BU4710_BOARD 0x0400
792 +#define VSIM4710_BOARD 0x0401
793 +#define QT4710_BOARD 0x0402
795 +#define BU4610_BOARD 0x0403
796 +#define VSIM4610_BOARD 0x0404
798 +#define BU4307_BOARD 0x0405
799 +#define BCM94301CB_BOARD 0x0406
800 +#define BCM94301PC_BOARD 0x0406 /* Pcmcia 5v card */
801 +#define BCM94301MP_BOARD 0x0407
802 +#define BCM94307MP_BOARD 0x0408
803 +#define BCMAP4307_BOARD 0x0409
805 +#define BU4309_BOARD 0x040a
806 +#define BCM94309CB_BOARD 0x040b
807 +#define BCM94309MP_BOARD 0x040c
808 +#define BCM4309AP_BOARD 0x040d
810 +#define BCM94302MP_BOARD 0x040e
812 +#define VSIM4310_BOARD 0x040f
813 +#define BU4711_BOARD 0x0410
814 +#define BCM94310U_BOARD 0x0411
815 +#define BCM94310AP_BOARD 0x0412
816 +#define BCM94310MP_BOARD 0x0414
818 +#define BU4306_BOARD 0x0416
819 +#define BCM94306CB_BOARD 0x0417
820 +#define BCM94306MP_BOARD 0x0418
822 +#define BCM94710D_BOARD 0x041a
823 +#define BCM94710R1_BOARD 0x041b
824 +#define BCM94710R4_BOARD 0x041c
825 +#define BCM94710AP_BOARD 0x041d
828 +#define BU2050_BOARD 0x041f
831 +#define BCM94309G_BOARD 0x0421
833 +#define BCM94301PC3_BOARD 0x0422 /* Pcmcia 3.3v card */
835 +#define BU4704_BOARD 0x0423
836 +#define BU4702_BOARD 0x0424
838 +#define BCM94306PC_BOARD 0x0425 /* pcmcia 3.3v 4306 card */
840 +#define BU4317_BOARD 0x0426
843 +#define BCM94702MN_BOARD 0x0428
845 +/* BCM4702 1U CompactPCI Board */
846 +#define BCM94702CPCI_BOARD 0x0429
848 +/* BCM4702 with BCM95380 VLAN Router */
849 +#define BCM95380RR_BOARD 0x042a
851 +/* cb4306 with SiGe PA */
852 +#define BCM94306CBSG_BOARD 0x042b
854 +/* mp4301 with 2050 radio */
855 +#define BCM94301MPL_BOARD 0x042c
857 +/* cb4306 with SiGe PA */
858 +#define PCSG94306_BOARD 0x042d
860 +/* bu4704 with sdram */
861 +#define BU4704SD_BOARD 0x042e
863 +/* Dual 11a/11g Router */
864 +#define BCM94704AGR_BOARD 0x042f
866 +/* 11a-only minipci */
867 +#define BCM94308MP_BOARD 0x0430
871 +/* BCM94317 boards */
872 +#define BCM94317CB_BOARD 0x0440
873 +#define BCM94317MP_BOARD 0x0441
874 +#define BCM94317PCMCIA_BOARD 0x0442
875 +#define BCM94317SDIO_BOARD 0x0443
877 +#define BU4712_BOARD 0x0444
878 +#define BU4712SD_BOARD 0x045d
879 +#define BU4712L_BOARD 0x045f
881 +/* BCM4712 boards */
882 +#define BCM94712AP_BOARD 0x0445
883 +#define BCM94712P_BOARD 0x0446
885 +/* BCM4318 boards */
886 +#define BU4318_BOARD 0x0447
887 +#define CB4318_BOARD 0x0448
888 +#define MPG4318_BOARD 0x0449
889 +#define MP4318_BOARD 0x044a
890 +#define SD4318_BOARD 0x044b
892 +/* BCM63XX boards */
893 +#define BCM96338_BOARD 0x6338
894 +#define BCM96345_BOARD 0x6345
895 +#define BCM96348_BOARD 0x6348
897 +/* Another mp4306 with SiGe */
898 +#define BCM94306P_BOARD 0x044c
900 +/* CF-like 4317 modules */
901 +#define BCM94317CF_BOARD 0x044d
904 +#define BCM94303MP_BOARD 0x044e
907 +#define BCM94306MPSGH_BOARD 0x044f
909 +/* BRCM 4306 w/ Front End Modules */
910 +#define BCM94306MPM 0x0450
911 +#define BCM94306MPL 0x0453
914 +#define BCM94712AGR_BOARD 0x0451
916 +/* The real CF 4317 board */
917 +#define CFI4317_BOARD 0x0452
920 +#define PC4303_BOARD 0x0454
923 +#define BCM95350K_BOARD 0x0455
926 +#define BCM95350R_BOARD 0x0456
929 +#define BCM94306MPLNA_BOARD 0x0457
932 +#define BU4320_BOARD 0x0458
933 +#define BU4320S_BOARD 0x0459
934 +#define BCM94320PH_BOARD 0x045a
937 +#define BCM94306MPH_BOARD 0x045b
940 +#define BCM94306PCIV_BOARD 0x045c
942 +#define BU4712SD_BOARD 0x045d
944 +#define BCM94320PFLSH_BOARD 0x045e
946 +#define BU4712L_BOARD 0x045f
947 +#define BCM94712LGR_BOARD 0x0460
948 +#define BCM94320R_BOARD 0x0461
950 +#define BU5352_BOARD 0x0462
952 +#define BCM94318MPGH_BOARD 0x0463
955 +#define BCM95352GR_BOARD 0x0467
958 +#define BCM95351AGR_BOARD 0x0470
960 +/* # of GPIO pins */
961 +#define GPIO_NUMPINS 16
963 +#endif /* _BCMDEVS_H */
964 diff -urN linux.old/arch/mips/bcm947xx/include/bcmendian.h linux.dev/arch/mips/bcm947xx/include/bcmendian.h
965 --- linux.old/arch/mips/bcm947xx/include/bcmendian.h 1970-01-01 01:00:00.000000000 +0100
966 +++ linux.dev/arch/mips/bcm947xx/include/bcmendian.h 2005-11-07 22:51:38.772725750 +0100
969 + * local version of endian.h - byte order defines
971 + * Copyright 2005, Broadcom Corporation
972 + * All Rights Reserved.
974 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
975 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
976 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
977 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
982 +#ifndef _BCMENDIAN_H_
983 +#define _BCMENDIAN_H_
985 +#include <typedefs.h>
987 +/* Byte swap a 16 bit value */
988 +#define BCMSWAP16(val) \
990 + (((uint16)(val) & (uint16)0x00ffU) << 8) | \
991 + (((uint16)(val) & (uint16)0xff00U) >> 8) ))
993 +/* Byte swap a 32 bit value */
994 +#define BCMSWAP32(val) \
996 + (((uint32)(val) & (uint32)0x000000ffUL) << 24) | \
997 + (((uint32)(val) & (uint32)0x0000ff00UL) << 8) | \
998 + (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) | \
999 + (((uint32)(val) & (uint32)0xff000000UL) >> 24) ))
1001 +/* 2 Byte swap a 32 bit value */
1002 +#define BCMSWAP32BY16(val) \
1004 + (((uint32)(val) & (uint32)0x0000ffffUL) << 16) | \
1005 + (((uint32)(val) & (uint32)0xffff0000UL) >> 16) ))
1008 +static INLINE uint16
1009 +bcmswap16(uint16 val)
1011 + return BCMSWAP16(val);
1014 +static INLINE uint32
1015 +bcmswap32(uint32 val)
1017 + return BCMSWAP32(val);
1020 +static INLINE uint32
1021 +bcmswap32by16(uint32 val)
1023 + return BCMSWAP32BY16(val);
1026 +/* buf - start of buffer of shorts to swap */
1027 +/* len - byte length of buffer */
1029 +bcmswap16_buf(uint16 *buf, uint len)
1034 + *buf = bcmswap16(*buf);
1040 +#ifndef IL_BIGENDIAN
1041 +#define HTON16(i) BCMSWAP16(i)
1042 +#define hton16(i) bcmswap16(i)
1043 +#define hton32(i) bcmswap32(i)
1044 +#define ntoh16(i) bcmswap16(i)
1045 +#define ntoh32(i) bcmswap32(i)
1046 +#define ltoh16(i) (i)
1047 +#define ltoh32(i) (i)
1048 +#define htol16(i) (i)
1049 +#define htol32(i) (i)
1051 +#define HTON16(i) (i)
1052 +#define hton16(i) (i)
1053 +#define hton32(i) (i)
1054 +#define ntoh16(i) (i)
1055 +#define ntoh32(i) (i)
1056 +#define ltoh16(i) bcmswap16(i)
1057 +#define ltoh32(i) bcmswap32(i)
1058 +#define htol16(i) bcmswap16(i)
1059 +#define htol32(i) bcmswap32(i)
1063 +#ifndef IL_BIGENDIAN
1064 +#define ltoh16_buf(buf, i)
1065 +#define htol16_buf(buf, i)
1067 +#define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
1068 +#define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
1072 +* load 16-bit value from unaligned little endian byte array.
1074 +static INLINE uint16
1075 +ltoh16_ua(uint8 *bytes)
1077 + return (bytes[1]<<8)+bytes[0];
1081 +* load 32-bit value from unaligned little endian byte array.
1083 +static INLINE uint32
1084 +ltoh32_ua(uint8 *bytes)
1086 + return (bytes[3]<<24)+(bytes[2]<<16)+(bytes[1]<<8)+bytes[0];
1090 +* load 16-bit value from unaligned big(network) endian byte array.
1092 +static INLINE uint16
1093 +ntoh16_ua(uint8 *bytes)
1095 + return (bytes[0]<<8)+bytes[1];
1099 +* load 32-bit value from unaligned big(network) endian byte array.
1101 +static INLINE uint32
1102 +ntoh32_ua(uint8 *bytes)
1104 + return (bytes[0]<<24)+(bytes[1]<<16)+(bytes[2]<<8)+bytes[3];
1107 +#define ltoh_ua(ptr) ( \
1108 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
1109 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] : \
1110 + (((uint8 *)ptr)[3]<<24)+(((uint8 *)ptr)[2]<<16)+(((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] \
1113 +#define ntoh_ua(ptr) ( \
1114 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
1115 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[0]<<8)+((uint8 *)ptr)[1] : \
1116 + (((uint8 *)ptr)[0]<<24)+(((uint8 *)ptr)[1]<<16)+(((uint8 *)ptr)[2]<<8)+((uint8 *)ptr)[3] \
1119 +#endif /* _BCMENDIAN_H_ */
1120 diff -urN linux.old/arch/mips/bcm947xx/include/bcmenet47xx.h linux.dev/arch/mips/bcm947xx/include/bcmenet47xx.h
1121 --- linux.old/arch/mips/bcm947xx/include/bcmenet47xx.h 1970-01-01 01:00:00.000000000 +0100
1122 +++ linux.dev/arch/mips/bcm947xx/include/bcmenet47xx.h 2005-11-07 22:51:38.772725750 +0100
1125 + * Hardware-specific definitions for
1126 + * Broadcom BCM47XX 10/100 Mbps Ethernet cores.
1128 + * Copyright 2005, Broadcom Corporation
1129 + * All Rights Reserved.
1131 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1132 + * the contents of this file may not be disclosed to third parties, copied
1133 + * or duplicated in any form, in whole or in part, without the prior
1134 + * written permission of Broadcom Corporation.
1138 +#ifndef _bcmenet_47xx_h_
1139 +#define _bcmenet_47xx_h_
1141 +#include <bcmenetmib.h>
1142 +#include <bcmenetrxh.h>
1143 +#include <bcmenetphy.h>
1145 +#define BCMENET_NFILTERS 64 /* # ethernet address filter entries */
1146 +#define BCMENET_MCHASHBASE 0x200 /* multicast hash filter base address */
1147 +#define BCMENET_MCHASHSIZE 256 /* multicast hash filter size in bytes */
1148 +#define BCMENET_MAX_DMA 4096 /* chip has 12 bits of DMA addressing */
1150 +/* power management event wakeup pattern constants */
1151 +#define BCMENET_NPMP 4 /* chip supports 4 wakeup patterns */
1152 +#define BCMENET_PMPBASE 0x400 /* wakeup pattern base address */
1153 +#define BCMENET_PMPSIZE 0x80 /* 128bytes each pattern */
1154 +#define BCMENET_PMMBASE 0x600 /* wakeup mask base address */
1155 +#define BCMENET_PMMSIZE 0x10 /* 128bits each mask */
1157 +/* cpp contortions to concatenate w/arg prescan */
1159 +#define _PADLINE(line) pad ## line
1160 +#define _XSTR(line) _PADLINE(line)
1161 +#define PAD _XSTR(__LINE__)
1165 + * Host Interface Registers
1167 +typedef volatile struct _bcmenettregs {
1168 + /* Device and Power Control */
1169 + uint32 devcontrol;
1171 + uint32 biststatus;
1172 + uint32 wakeuplength;
1175 + /* Interrupt Control */
1181 + /* Ethernet MAC Address Filtering Control */
1183 + uint32 enetftaddr;
1184 + uint32 enetftdata;
1187 + /* Ethernet MAC Control */
1188 + uint32 emactxmaxburstlen;
1189 + uint32 emacrxmaxburstlen;
1190 + uint32 emaccontrol;
1191 + uint32 emacflowcontrol;
1195 + /* DMA Lazy Interrupt Control */
1196 + uint32 intrecvlazy;
1200 + dma32regp_t dmaregs;
1201 + dma32diag_t dmafifo;
1204 + /* EMAC Registers */
1206 + uint32 rxmaxlength;
1207 + uint32 txmaxlength;
1209 + uint32 mdiocontrol;
1211 + uint32 emacintmask;
1212 + uint32 emacintstatus;
1215 + uint32 camcontrol;
1216 + uint32 enetcontrol;
1218 + uint32 txwatermark;
1219 + uint32 mibcontrol;
1222 + /* EMAC MIB counters */
1227 + /* Sonics SiliconBackplane config registers */
1228 + sbconfig_t sbconfig;
1231 +/* device control */
1232 +#define DC_PM ((uint32)1 << 7) /* pattern filtering enable */
1233 +#define DC_IP ((uint32)1 << 10) /* internal ephy present (rev >= 1) */
1234 +#define DC_ER ((uint32)1 << 15) /* ephy reset */
1235 +#define DC_MP ((uint32)1 << 16) /* mii phy mode enable */
1236 +#define DC_CO ((uint32)1 << 17) /* mii phy mode: enable clocks */
1237 +#define DC_PA_MASK 0x7c0000 /* mii phy mode: mdc/mdio phy address */
1238 +#define DC_PA_SHIFT 18
1239 +#define DC_FS_MASK 0x03800000 /* fifo size (rev >= 8) */
1240 +#define DC_FS_SHIFT 23
1241 +#define DC_FS_4K 0 /* 4Kbytes */
1242 +#define DC_FS_512 1 /* 512bytes */
1244 +/* wakeup length */
1245 +#define WL_P0_MASK 0x7f /* pattern 0 */
1246 +#define WL_D0 ((uint32)1 << 7)
1247 +#define WL_P1_MASK 0x7f00 /* pattern 1 */
1248 +#define WL_P1_SHIFT 8
1249 +#define WL_D1 ((uint32)1 << 15)
1250 +#define WL_P2_MASK 0x7f0000 /* pattern 2 */
1251 +#define WL_P2_SHIFT 16
1252 +#define WL_D2 ((uint32)1 << 23)
1253 +#define WL_P3_MASK 0x7f000000 /* pattern 3 */
1254 +#define WL_P3_SHIFT 24
1255 +#define WL_D3 ((uint32)1 << 31)
1257 +/* intstatus and intmask */
1258 +#define I_PME ((uint32)1 << 6) /* power management event */
1259 +#define I_TO ((uint32)1 << 7) /* general purpose timeout */
1260 +#define I_PC ((uint32)1 << 10) /* descriptor error */
1261 +#define I_PD ((uint32)1 << 11) /* data error */
1262 +#define I_DE ((uint32)1 << 12) /* descriptor protocol error */
1263 +#define I_RU ((uint32)1 << 13) /* receive descriptor underflow */
1264 +#define I_RO ((uint32)1 << 14) /* receive fifo overflow */
1265 +#define I_XU ((uint32)1 << 15) /* transmit fifo underflow */
1266 +#define I_RI ((uint32)1 << 16) /* receive interrupt */
1267 +#define I_XI ((uint32)1 << 24) /* transmit interrupt */
1268 +#define I_EM ((uint32)1 << 26) /* emac interrupt */
1269 +#define I_MW ((uint32)1 << 27) /* mii write */
1270 +#define I_MR ((uint32)1 << 28) /* mii read */
1273 +#define EMC_CG ((uint32)1 << 0) /* crc32 generation enable */
1274 +#define EMC_EP ((uint32)1 << 2) /* onchip ephy: powerdown (rev >= 1) */
1275 +#define EMC_ED ((uint32)1 << 3) /* onchip ephy: energy detected (rev >= 1) */
1276 +#define EMC_LC_MASK 0xe0 /* onchip ephy: led control (rev >= 1) */
1277 +#define EMC_LC_SHIFT 5
1279 +/* emacflowcontrol */
1280 +#define EMF_RFH_MASK 0xff /* rx fifo hi water mark */
1281 +#define EMF_PG ((uint32)1 << 15) /* enable pause frame generation */
1283 +/* interrupt receive lazy */
1284 +#define IRL_TO_MASK 0x00ffffff /* timeout */
1285 +#define IRL_FC_MASK 0xff000000 /* frame count */
1286 +#define IRL_FC_SHIFT 24 /* frame count */
1288 +/* emac receive config */
1289 +#define ERC_DB ((uint32)1 << 0) /* disable broadcast */
1290 +#define ERC_AM ((uint32)1 << 1) /* accept all multicast */
1291 +#define ERC_RDT ((uint32)1 << 2) /* receive disable while transmitting */
1292 +#define ERC_PE ((uint32)1 << 3) /* promiscuous enable */
1293 +#define ERC_LE ((uint32)1 << 4) /* loopback enable */
1294 +#define ERC_FE ((uint32)1 << 5) /* enable flow control */
1295 +#define ERC_UF ((uint32)1 << 6) /* accept unicast flow control frame */
1296 +#define ERC_RF ((uint32)1 << 7) /* reject filter */
1297 +#define ERC_CA ((uint32)1 << 8) /* cam absent */
1299 +/* emac mdio control */
1300 +#define MC_MF_MASK 0x7f /* mdc frequency */
1301 +#define MC_PE ((uint32)1 << 7) /* mii preamble enable */
1303 +/* emac mdio data */
1304 +#define MD_DATA_MASK 0xffff /* r/w data */
1305 +#define MD_TA_MASK 0x30000 /* turnaround value */
1306 +#define MD_TA_SHIFT 16
1307 +#define MD_TA_VALID (2 << MD_TA_SHIFT) /* valid ta */
1308 +#define MD_RA_MASK 0x7c0000 /* register address */
1309 +#define MD_RA_SHIFT 18
1310 +#define MD_PMD_MASK 0xf800000 /* physical media device */
1311 +#define MD_PMD_SHIFT 23
1312 +#define MD_OP_MASK 0x30000000 /* opcode */
1313 +#define MD_OP_SHIFT 28
1314 +#define MD_OP_WRITE (1 << MD_OP_SHIFT) /* write op */
1315 +#define MD_OP_READ (2 << MD_OP_SHIFT) /* read op */
1316 +#define MD_SB_MASK 0xc0000000 /* start bits */
1317 +#define MD_SB_SHIFT 30
1318 +#define MD_SB_START (0x1 << MD_SB_SHIFT) /* start of frame */
1320 +/* emac intstatus and intmask */
1321 +#define EI_MII ((uint32)1 << 0) /* mii mdio interrupt */
1322 +#define EI_MIB ((uint32)1 << 1) /* mib interrupt */
1323 +#define EI_FLOW ((uint32)1 << 2) /* flow control interrupt */
1325 +/* emac cam data high */
1326 +#define CD_V ((uint32)1 << 16) /* valid bit */
1328 +/* emac cam control */
1329 +#define CC_CE ((uint32)1 << 0) /* cam enable */
1330 +#define CC_MS ((uint32)1 << 1) /* mask select */
1331 +#define CC_RD ((uint32)1 << 2) /* read */
1332 +#define CC_WR ((uint32)1 << 3) /* write */
1333 +#define CC_INDEX_MASK 0x3f0000 /* index */
1334 +#define CC_INDEX_SHIFT 16
1335 +#define CC_CB ((uint32)1 << 31) /* cam busy */
1337 +/* emac ethernet control */
1338 +#define EC_EE ((uint32)1 << 0) /* emac enable */
1339 +#define EC_ED ((uint32)1 << 1) /* emac disable */
1340 +#define EC_ES ((uint32)1 << 2) /* emac soft reset */
1341 +#define EC_EP ((uint32)1 << 3) /* external phy select */
1343 +/* emac transmit control */
1344 +#define EXC_FD ((uint32)1 << 0) /* full duplex */
1345 +#define EXC_FM ((uint32)1 << 1) /* flowmode */
1346 +#define EXC_SB ((uint32)1 << 2) /* single backoff enable */
1347 +#define EXC_SS ((uint32)1 << 3) /* small slottime */
1349 +/* emac mib control */
1350 +#define EMC_RZ ((uint32)1 << 0) /* autoclear on read */
1352 +#endif /* _bcmenet_47xx_h_ */
1353 diff -urN linux.old/arch/mips/bcm947xx/include/bcmenetmib.h linux.dev/arch/mips/bcm947xx/include/bcmenetmib.h
1354 --- linux.old/arch/mips/bcm947xx/include/bcmenetmib.h 1970-01-01 01:00:00.000000000 +0100
1355 +++ linux.dev/arch/mips/bcm947xx/include/bcmenetmib.h 2005-11-07 21:57:07.845585750 +0100
1358 + * Hardware-specific MIB definition for
1359 + * Broadcom Home Networking Division
1360 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1362 + * Copyright 2005, Broadcom Corporation
1363 + * All Rights Reserved.
1365 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1366 + * the contents of this file may not be disclosed to third parties, copied
1367 + * or duplicated in any form, in whole or in part, without the prior
1368 + * written permission of Broadcom Corporation.
1372 +#ifndef _bcmenetmib_h_
1373 +#define _bcmenetmib_h_
1375 +/* cpp contortions to concatenate w/arg prescan */
1377 +#define _PADLINE(line) pad ## line
1378 +#define _XSTR(line) _PADLINE(line)
1379 +#define PAD _XSTR(__LINE__)
1383 + * EMAC MIB Registers
1385 +typedef volatile struct {
1386 + uint32 tx_good_octets;
1387 + uint32 tx_good_pkts;
1390 + uint32 tx_broadcast_pkts;
1391 + uint32 tx_multicast_pkts;
1393 + uint32 tx_len_65_to_127;
1394 + uint32 tx_len_128_to_255;
1395 + uint32 tx_len_256_to_511;
1396 + uint32 tx_len_512_to_1023;
1397 + uint32 tx_len_1024_to_max;
1398 + uint32 tx_jabber_pkts;
1399 + uint32 tx_oversize_pkts;
1400 + uint32 tx_fragment_pkts;
1401 + uint32 tx_underruns;
1402 + uint32 tx_total_cols;
1403 + uint32 tx_single_cols;
1404 + uint32 tx_multiple_cols;
1405 + uint32 tx_excessive_cols;
1406 + uint32 tx_late_cols;
1407 + uint32 tx_defered;
1408 + uint32 tx_carrier_lost;
1409 + uint32 tx_pause_pkts;
1412 + uint32 rx_good_octets;
1413 + uint32 rx_good_pkts;
1416 + uint32 rx_broadcast_pkts;
1417 + uint32 rx_multicast_pkts;
1419 + uint32 rx_len_65_to_127;
1420 + uint32 rx_len_128_to_255;
1421 + uint32 rx_len_256_to_511;
1422 + uint32 rx_len_512_to_1023;
1423 + uint32 rx_len_1024_to_max;
1424 + uint32 rx_jabber_pkts;
1425 + uint32 rx_oversize_pkts;
1426 + uint32 rx_fragment_pkts;
1427 + uint32 rx_missed_pkts;
1428 + uint32 rx_crc_align_errs;
1429 + uint32 rx_undersize;
1430 + uint32 rx_crc_errs;
1431 + uint32 rx_align_errs;
1432 + uint32 rx_symbol_errs;
1433 + uint32 rx_pause_pkts;
1434 + uint32 rx_nonpause_pkts;
1437 +#endif /* _bcmenetmib_h_ */
1438 diff -urN linux.old/arch/mips/bcm947xx/include/bcmenetphy.h linux.dev/arch/mips/bcm947xx/include/bcmenetphy.h
1439 --- linux.old/arch/mips/bcm947xx/include/bcmenetphy.h 1970-01-01 01:00:00.000000000 +0100
1440 +++ linux.dev/arch/mips/bcm947xx/include/bcmenetphy.h 2005-11-07 21:57:07.845585750 +0100
1443 + * Misc Broadcom BCM47XX MDC/MDIO enet phy definitions.
1445 + * Copyright 2005, Broadcom Corporation
1446 + * All Rights Reserved.
1448 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1449 + * the contents of this file may not be disclosed to third parties, copied
1450 + * or duplicated in any form, in whole or in part, without the prior
1451 + * written permission of Broadcom Corporation.
1455 +#ifndef _bcmenetphy_h_
1456 +#define _bcmenetphy_h_
1459 +#define MAXEPHY 32 /* mdio phy addresses are 5bit quantities */
1460 +#define EPHY_MASK 0x1f
1461 +#define EPHY_NONE 31 /* nvram: no phy present at all */
1462 +#define EPHY_NOREG 30 /* nvram: no local phy regs */
1464 +/* just a few phy registers */
1465 +#define CTL_RESET (1 << 15) /* reset */
1466 +#define CTL_LOOP (1 << 14) /* loopback */
1467 +#define CTL_SPEED (1 << 13) /* speed selection 0=10, 1=100 */
1468 +#define CTL_ANENAB (1 << 12) /* autonegotiation enable */
1469 +#define CTL_RESTART (1 << 9) /* restart autonegotiation */
1470 +#define CTL_DUPLEX (1 << 8) /* duplex mode 0=half, 1=full */
1472 +#define ADV_10FULL (1 << 6) /* autonegotiate advertise 10full */
1473 +#define ADV_10HALF (1 << 5) /* autonegotiate advertise 10half */
1474 +#define ADV_100FULL (1 << 8) /* autonegotiate advertise 100full */
1475 +#define ADV_100HALF (1 << 7) /* autonegotiate advertise 100half */
1477 +/* link partner ability register */
1478 +#define LPA_SLCT 0x001f /* same as advertise selector */
1479 +#define LPA_10HALF 0x0020 /* can do 10mbps half-duplex */
1480 +#define LPA_10FULL 0x0040 /* can do 10mbps full-duplex */
1481 +#define LPA_100HALF 0x0080 /* can do 100mbps half-duplex */
1482 +#define LPA_100FULL 0x0100 /* can do 100mbps full-duplex */
1483 +#define LPA_100BASE4 0x0200 /* can do 100mbps 4k packets */
1484 +#define LPA_RESV 0x1c00 /* unused */
1485 +#define LPA_RFAULT 0x2000 /* link partner faulted */
1486 +#define LPA_LPACK 0x4000 /* link partner acked us */
1487 +#define LPA_NPAGE 0x8000 /* next page bit */
1489 +#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
1490 +#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
1492 +#define STAT_REMFAULT (1 << 4) /* remote fault */
1493 +#define STAT_LINK (1 << 2) /* link status */
1494 +#define STAT_JAB (1 << 1) /* jabber detected */
1495 +#define AUX_FORCED (1 << 2) /* forced 10/100 */
1496 +#define AUX_SPEED (1 << 1) /* speed 0=10mbps 1=100mbps */
1497 +#define AUX_DUPLEX (1 << 0) /* duplex 0=half 1=full */
1499 +#endif /* _bcmenetphy_h_ */
1500 diff -urN linux.old/arch/mips/bcm947xx/include/bcmenetrxh.h linux.dev/arch/mips/bcm947xx/include/bcmenetrxh.h
1501 --- linux.old/arch/mips/bcm947xx/include/bcmenetrxh.h 1970-01-01 01:00:00.000000000 +0100
1502 +++ linux.dev/arch/mips/bcm947xx/include/bcmenetrxh.h 2005-11-07 21:57:07.845585750 +0100
1505 + * Hardware-specific Receive Data Header for the
1506 + * Broadcom Home Networking Division
1507 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1509 + * Copyright 2005, Broadcom Corporation
1510 + * All Rights Reserved.
1512 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1513 + * the contents of this file may not be disclosed to third parties, copied
1514 + * or duplicated in any form, in whole or in part, without the prior
1515 + * written permission of Broadcom Corporation.
1519 +#ifndef _bcmenetrxh_h_
1520 +#define _bcmenetrxh_h_
1523 + * The Ethernet MAC core returns an 8-byte Receive Frame Data Header
1524 + * with every frame consisting of
1525 + * 16bits of frame length, followed by
1526 + * 16bits of EMAC rx descriptor info, followed by 32bits of undefined.
1528 +typedef volatile struct {
1534 +#define RXHDR_LEN 28
1536 +#define RXF_L ((uint16)1 << 11) /* last buffer in a frame */
1537 +#define RXF_MISS ((uint16)1 << 7) /* received due to promisc mode */
1538 +#define RXF_BRDCAST ((uint16)1 << 6) /* dest is broadcast address */
1539 +#define RXF_MULT ((uint16)1 << 5) /* dest is multicast address */
1540 +#define RXF_LG ((uint16)1 << 4) /* frame length > rxmaxlength */
1541 +#define RXF_NO ((uint16)1 << 3) /* odd number of nibbles */
1542 +#define RXF_RXER ((uint16)1 << 2) /* receive symbol error */
1543 +#define RXF_CRC ((uint16)1 << 1) /* crc error */
1544 +#define RXF_OV ((uint16)1 << 0) /* fifo overflow */
1546 +#endif /* _bcmenetrxh_h_ */
1547 diff -urN linux.old/arch/mips/bcm947xx/include/bcmnvram.h linux.dev/arch/mips/bcm947xx/include/bcmnvram.h
1548 --- linux.old/arch/mips/bcm947xx/include/bcmnvram.h 1970-01-01 01:00:00.000000000 +0100
1549 +++ linux.dev/arch/mips/bcm947xx/include/bcmnvram.h 2005-11-07 22:51:38.772725750 +0100
1552 + * NVRAM variable manipulation
1554 + * Copyright 2005, Broadcom Corporation
1555 + * All Rights Reserved.
1557 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1558 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1559 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1560 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1565 +#ifndef _bcmnvram_h_
1566 +#define _bcmnvram_h_
1568 +#ifndef _LANGUAGE_ASSEMBLY
1570 +#include <typedefs.h>
1572 +struct nvram_header {
1575 + uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
1576 + uint32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
1577 + uint32 config_ncdl; /* ncdl values for memc */
1580 +struct nvram_tuple {
1583 + struct nvram_tuple *next;
1587 + * Initialize NVRAM access. May be unnecessary or undefined on certain
1590 +extern int BCMINIT(nvram_init)(void *sbh);
1593 + * Disable NVRAM access. May be unnecessary or undefined on certain
1596 +extern void BCMINIT(nvram_exit)(void *sbh);
1599 + * Get the value of an NVRAM variable. The pointer returned may be
1600 + * invalid after a set.
1601 + * @param name name of variable to get
1602 + * @return value of variable or NULL if undefined
1604 +extern char * BCMINIT(nvram_get)(const char *name);
1607 + * Read the reset GPIO value from the nvram and set the GPIO
1610 +extern int BCMINITFN(nvram_resetgpio_init)(void *sbh);
1613 + * Get the value of an NVRAM variable.
1614 + * @param name name of variable to get
1615 + * @return value of variable or NUL if undefined
1617 +#define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "")
1620 + * Match an NVRAM variable.
1621 + * @param name name of variable to match
1622 + * @param match value to compare against value of variable
1623 + * @return TRUE if variable is defined and its value is string equal
1624 + * to match or FALSE otherwise
1627 +nvram_match(char *name, char *match) {
1628 + const char *value = BCMINIT(nvram_get)(name);
1629 + return (value && !strcmp(value, match));
1633 + * Inversely match an NVRAM variable.
1634 + * @param name name of variable to match
1635 + * @param match value to compare against value of variable
1636 + * @return TRUE if variable is defined and its value is not string
1637 + * equal to invmatch or FALSE otherwise
1640 +nvram_invmatch(char *name, char *invmatch) {
1641 + const char *value = BCMINIT(nvram_get)(name);
1642 + return (value && strcmp(value, invmatch));
1646 + * Set the value of an NVRAM variable. The name and value strings are
1647 + * copied into private storage. Pointers to previously set values
1648 + * may become invalid. The new value may be immediately
1649 + * retrieved but will not be permanently stored until a commit.
1650 + * @param name name of variable to set
1651 + * @param value value of variable
1652 + * @return 0 on success and errno on failure
1654 +extern int BCMINIT(nvram_set)(const char *name, const char *value);
1657 + * Unset an NVRAM variable. Pointers to previously set values
1658 + * remain valid until a set.
1659 + * @param name name of variable to unset
1660 + * @return 0 on success and errno on failure
1661 + * NOTE: use nvram_commit to commit this change to flash.
1663 +extern int BCMINIT(nvram_unset)(const char *name);
1666 + * Commit NVRAM variables to permanent storage. All pointers to values
1667 + * may be invalid after a commit.
1668 + * NVRAM values are undefined after a commit.
1669 + * @return 0 on success and errno on failure
1671 +extern int BCMINIT(nvram_commit)(void);
1674 + * Get all NVRAM variables (format name=value\0 ... \0\0).
1675 + * @param buf buffer to store variables
1676 + * @param count size of buffer in bytes
1677 + * @return 0 on success and errno on failure
1679 +extern int BCMINIT(nvram_getall)(char *buf, int count);
1681 +#endif /* _LANGUAGE_ASSEMBLY */
1683 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
1684 +#define NVRAM_VERSION 1
1685 +#define NVRAM_HEADER_SIZE 20
1686 +#define NVRAM_SPACE 0x8000
1688 +#define NVRAM_MAX_VALUE_LEN 255
1689 +#define NVRAM_MAX_PARAM_LEN 64
1691 +#endif /* _bcmnvram_h_ */
1692 diff -urN linux.old/arch/mips/bcm947xx/include/bcmparams.h linux.dev/arch/mips/bcm947xx/include/bcmparams.h
1693 --- linux.old/arch/mips/bcm947xx/include/bcmparams.h 1970-01-01 01:00:00.000000000 +0100
1694 +++ linux.dev/arch/mips/bcm947xx/include/bcmparams.h 2005-11-07 22:51:38.776726000 +0100
1697 + * Misc system wide parameters.
1699 + * Copyright 2005, Broadcom Corporation
1700 + * All Rights Reserved.
1702 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1703 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1704 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1705 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1709 +#ifndef _bcmparams_h_
1710 +#define _bcmparams_h_
1712 +#define VLAN_MAXVID 15 /* Max. VLAN ID supported/allowed */
1714 +#define VLAN_NUMPRIS 8 /* # of prio, start from 0 */
1716 +#define DEV_NUMIFS 16 /* Max. # of devices/interfaces supported */
1718 +#define WL_MAXBSSCFG 16 /* maximum number of BSS Configs we can configure */
1721 diff -urN linux.old/arch/mips/bcm947xx/include/bcmsrom.h linux.dev/arch/mips/bcm947xx/include/bcmsrom.h
1722 --- linux.old/arch/mips/bcm947xx/include/bcmsrom.h 1970-01-01 01:00:00.000000000 +0100
1723 +++ linux.dev/arch/mips/bcm947xx/include/bcmsrom.h 2005-11-07 22:51:38.776726000 +0100
1726 + * Misc useful routines to access NIC local SROM/OTP .
1728 + * Copyright 2005, Broadcom Corporation
1729 + * All Rights Reserved.
1731 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1732 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1733 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1734 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1739 +#ifndef _bcmsrom_h_
1740 +#define _bcmsrom_h_
1742 +extern int srom_var_init(void *sbh, uint bus, void *curmap, osl_t *osh, char **vars, int *count);
1744 +extern int srom_read(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
1745 +extern int srom_write(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
1747 +#endif /* _bcmsrom_h_ */
1748 diff -urN linux.old/arch/mips/bcm947xx/include/bcmutils.h linux.dev/arch/mips/bcm947xx/include/bcmutils.h
1749 --- linux.old/arch/mips/bcm947xx/include/bcmutils.h 1970-01-01 01:00:00.000000000 +0100
1750 +++ linux.dev/arch/mips/bcm947xx/include/bcmutils.h 2005-11-07 22:51:38.776726000 +0100
1753 + * Misc useful os-independent macros and functions.
1755 + * Copyright 2005, Broadcom Corporation
1756 + * All Rights Reserved.
1758 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1759 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1760 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1761 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1765 +#ifndef _bcmutils_h_
1766 +#define _bcmutils_h_
1768 +/*** driver-only section ***/
1772 +#define _BCM_U 0x01 /* upper */
1773 +#define _BCM_L 0x02 /* lower */
1774 +#define _BCM_D 0x04 /* digit */
1775 +#define _BCM_C 0x08 /* cntrl */
1776 +#define _BCM_P 0x10 /* punct */
1777 +#define _BCM_S 0x20 /* white space (space/lf/tab) */
1778 +#define _BCM_X 0x40 /* hex digit */
1779 +#define _BCM_SP 0x80 /* hard space (0x20) */
1781 +#define GPIO_PIN_NOTDEFINED 0x20
1783 +extern unsigned char bcm_ctype[];
1784 +#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
1786 +#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
1787 +#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
1788 +#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0)
1789 +#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0)
1790 +#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
1791 +#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0)
1792 +#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
1793 +#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0)
1794 +#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0)
1795 +#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0)
1796 +#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
1799 + * Spin at most 'us' microseconds while 'exp' is true.
1800 + * Caller should explicitly test 'exp' when this completes
1801 + * and take appropriate error action if 'exp' is still true.
1803 +#define SPINWAIT(exp, us) { \
1804 + uint countdown = (us) + 9; \
1805 + while ((exp) && (countdown >= 10)) {\
1807 + countdown -= 10; \
1811 +/* generic osl packet queue */
1813 + void *head; /* first packet to dequeue */
1814 + void *tail; /* last packet to dequeue */
1815 + uint len; /* number of queued packets */
1816 + uint maxlen; /* maximum number of queued packets */
1817 + bool priority; /* enqueue by packet priority */
1818 + uint8 prio_map[MAXPRIO+1]; /* user priority to packet enqueue policy map */
1820 +#define DEFAULT_QLEN 128
1822 +#define pktq_len(q) ((q)->len)
1823 +#define pktq_avail(q) ((q)->maxlen - (q)->len)
1824 +#define pktq_head(q) ((q)->head)
1825 +#define pktq_full(q) ((q)->len >= (q)->maxlen)
1826 +#define _pktq_pri(q, pri) ((q)->prio_map[pri])
1827 +#define pktq_tailpri(q) ((q)->tail ? _pktq_pri(q, PKTPRIO((q)->tail)) : _pktq_pri(q, 0))
1831 +extern uint pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf);
1832 +extern uint pkttotlen(osl_t *osh, void *);
1833 +extern void pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[]);
1834 +extern void pktenq(struct pktq *q, void *p, bool lifo);
1835 +extern void *pktdeq(struct pktq *q);
1836 +extern void *pktdeqtail(struct pktq *q);
1838 +extern uint bcm_atoi(char *s);
1839 +extern uchar bcm_toupper(uchar c);
1840 +extern ulong bcm_strtoul(char *cp, char **endp, uint base);
1841 +extern char *bcmstrstr(char *haystack, char *needle);
1842 +extern char *bcmstrcat(char *dest, const char *src);
1843 +extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen);
1844 +/* ethernet address */
1845 +extern char *bcm_ether_ntoa(char *ea, char *buf);
1846 +extern int bcm_ether_atoe(char *p, char *ea);
1848 +extern void bcm_mdelay(uint ms);
1849 +/* variable access */
1850 +extern char *getvar(char *vars, char *name);
1851 +extern int getintvar(char *vars, char *name);
1852 +extern uint getgpiopin(char *vars, char *pin_name, uint def_pin);
1853 +#define bcmlog(fmt, a1, a2)
1854 +#define bcmdumplog(buf, size) *buf = '\0'
1855 +#define bcmdumplogent(buf, idx) -1
1857 +#endif /* #ifdef BCMDRIVER */
1859 +/*** driver/apps-shared section ***/
1861 +#define BCME_STRLEN 64
1862 +#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST))
1866 + * error codes could be added but the defined ones shouldn't be changed/deleted
1867 + * these error codes are exposed to the user code
1868 + * when ever a new error code is added to this list
1869 + * please update errorstring table with the related error string and
1870 + * update osl files with os specific errorcode map
1873 +#define BCME_ERROR -1 /* Error generic */
1874 +#define BCME_BADARG -2 /* Bad Argument */
1875 +#define BCME_BADOPTION -3 /* Bad option */
1876 +#define BCME_NOTUP -4 /* Not up */
1877 +#define BCME_NOTDOWN -5 /* Not down */
1878 +#define BCME_NOTAP -6 /* Not AP */
1879 +#define BCME_NOTSTA -7 /* Not STA */
1880 +#define BCME_BADKEYIDX -8 /* BAD Key Index */
1881 +#define BCME_RADIOOFF -9 /* Radio Off */
1882 +#define BCME_NOTBANDLOCKED -10 /* Not bandlocked */
1883 +#define BCME_NOCLK -11 /* No Clock*/
1884 +#define BCME_BADRATESET -12 /* BAD RateSet*/
1885 +#define BCME_BADBAND -13 /* BAD Band */
1886 +#define BCME_BUFTOOSHORT -14 /* Buffer too short */
1887 +#define BCME_BUFTOOLONG -15 /* Buffer too Long */
1888 +#define BCME_BUSY -16 /* Busy*/
1889 +#define BCME_NOTASSOCIATED -17 /* Not associated*/
1890 +#define BCME_BADSSIDLEN -18 /* BAD SSID Len */
1891 +#define BCME_OUTOFRANGECHAN -19 /* Out of Range Channel*/
1892 +#define BCME_BADCHAN -20 /* BAD Channel */
1893 +#define BCME_BADADDR -21 /* BAD Address*/
1894 +#define BCME_NORESOURCE -22 /* No resources*/
1895 +#define BCME_UNSUPPORTED -23 /* Unsupported*/
1896 +#define BCME_BADLEN -24 /* Bad Length*/
1897 +#define BCME_NOTREADY -25 /* Not ready Yet*/
1898 +#define BCME_EPERM -26 /* Not Permitted */
1899 +#define BCME_NOMEM -27 /* No Memory */
1900 +#define BCME_ASSOCIATED -28 /* Associated */
1901 +#define BCME_RANGE -29 /* Range Error*/
1902 +#define BCME_NOTFOUND -30 /* Not found */
1903 +#define BCME_LAST BCME_NOTFOUND
1906 +#define ABS(a) (((a)<0)?-(a):(a))
1910 +#define MIN(a, b) (((a)<(b))?(a):(b))
1914 +#define MAX(a, b) (((a)>(b))?(a):(b))
1917 +#define CEIL(x, y) (((x) + ((y)-1)) / (y))
1918 +#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
1919 +#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0)
1920 +#define ISPOWEROF2(x) ((((x)-1)&(x))==0)
1921 +#define VALID_MASK(mask) !((mask) & ((mask) + 1))
1922 +#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member)
1923 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
1925 +/* bit map related macros */
1927 +#define NBBY 8 /* 8 bits per byte */
1928 +#define setbit(a,i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
1929 +#define clrbit(a,i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1930 +#define isset(a,i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY)))
1931 +#define isclr(a,i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1934 +#define NBITS(type) (sizeof(type) * 8)
1935 +#define NBITVAL(bits) (1 << (bits))
1936 +#define MAXBITVAL(bits) ((1 << (bits)) - 1)
1939 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
1940 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
1941 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
1942 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
1943 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
1944 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
1946 +/* bcm_format_flags() bit description structure */
1947 +typedef struct bcm_bit_desc {
1952 +/* tag_ID/length/value_buffer tuple */
1953 +typedef struct bcm_tlv {
1959 +/* Check that bcm_tlv_t fits into the given buflen */
1960 +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len))
1962 +/* buffer length for ethernet address from bcm_ether_ntoa() */
1963 +#define ETHER_ADDR_STR_LEN 18
1965 +/* unaligned load and store macros */
1966 +#ifdef IL_BIGENDIAN
1967 +static INLINE uint32
1968 +load32_ua(uint8 *a)
1970 + return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
1974 +store32_ua(uint8 *a, uint32 v)
1976 + a[0] = (v >> 24) & 0xff;
1977 + a[1] = (v >> 16) & 0xff;
1978 + a[2] = (v >> 8) & 0xff;
1982 +static INLINE uint16
1983 +load16_ua(uint8 *a)
1985 + return ((a[0] << 8) | a[1]);
1989 +store16_ua(uint8 *a, uint16 v)
1991 + a[0] = (v >> 8) & 0xff;
1997 +static INLINE uint32
1998 +load32_ua(uint8 *a)
2000 + return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
2004 +store32_ua(uint8 *a, uint32 v)
2006 + a[3] = (v >> 24) & 0xff;
2007 + a[2] = (v >> 16) & 0xff;
2008 + a[1] = (v >> 8) & 0xff;
2012 +static INLINE uint16
2013 +load16_ua(uint8 *a)
2015 + return ((a[1] << 8) | a[0]);
2019 +store16_ua(uint8 *a, uint16 v)
2021 + a[1] = (v >> 8) & 0xff;
2029 +extern uint8 hndcrc8(uint8 *p, uint nbytes, uint8 crc);
2030 +extern uint16 hndcrc16(uint8 *p, uint nbytes, uint16 crc);
2031 +extern uint32 hndcrc32(uint8 *p, uint nbytes, uint32 crc);
2034 +extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
2035 +extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
2036 +extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
2039 +extern const char *bcmerrorstr(int bcmerror);
2041 +/* multi-bool data type: set of bools, mbool is true if any is set */
2042 +typedef uint32 mbool;
2043 +#define mboolset(mb, bit) (mb |= bit) /* set one bool */
2044 +#define mboolclr(mb, bit) (mb &= ~bit) /* clear one bool */
2045 +#define mboolisset(mb, bit) ((mb & bit) != 0) /* TRUE if one bool is set */
2046 +#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val)))
2048 +/* power conversion */
2049 +extern uint16 bcm_qdbm_to_mw(uint8 qdbm);
2050 +extern uint8 bcm_mw_to_qdbm(uint16 mw);
2052 +/* generic datastruct to help dump routines */
2059 +typedef uint32 (*readreg_rtn)(void *arg0, void *arg1, uint32 offset);
2060 +extern uint bcmdumpfields(readreg_rtn func_ptr, void *arg0, void *arg1, struct fielddesc *str, char *buf, uint32 bufsize);
2062 +extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len);
2064 +#endif /* _bcmutils_h_ */
2065 diff -urN linux.old/arch/mips/bcm947xx/include/bitfuncs.h linux.dev/arch/mips/bcm947xx/include/bitfuncs.h
2066 --- linux.old/arch/mips/bcm947xx/include/bitfuncs.h 1970-01-01 01:00:00.000000000 +0100
2067 +++ linux.dev/arch/mips/bcm947xx/include/bitfuncs.h 2005-11-07 21:57:07.849586000 +0100
2070 + * bit manipulation utility functions
2072 + * Copyright 2005, Broadcom Corporation
2073 + * All Rights Reserved.
2075 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2076 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2077 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2078 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2082 +#ifndef _BITFUNCS_H
2083 +#define _BITFUNCS_H
2085 +#include <typedefs.h>
2087 +/* local prototypes */
2088 +static INLINE uint32 find_msbit(uint32 x);
2092 + * find_msbit: returns index of most significant set bit in x, with index
2093 + * range defined as 0-31. NOTE: returns zero if input is zero.
2096 +#if defined(USE_PENTIUM_BSR) && defined(__GNUC__)
2099 + * Implementation for Pentium processors and gcc. Note that this
2100 + * instruction is actually very slow on some processors (e.g., family 5,
2101 + * model 2, stepping 12, "Pentium 75 - 200"), so we use the generic
2102 + * implementation instead.
2104 +static INLINE uint32 find_msbit(uint32 x)
2107 + __asm__("bsrl %1,%0"
2116 + * Generic Implementation
2119 +#define DB_POW_MASK16 0xffff0000
2120 +#define DB_POW_MASK8 0x0000ff00
2121 +#define DB_POW_MASK4 0x000000f0
2122 +#define DB_POW_MASK2 0x0000000c
2123 +#define DB_POW_MASK1 0x00000002
2125 +static INLINE uint32 find_msbit(uint32 x)
2127 + uint32 temp_x = x;
2129 + if (temp_x & DB_POW_MASK16) {
2133 + if (temp_x & DB_POW_MASK8) {
2137 + if (temp_x & DB_POW_MASK4) {
2141 + if (temp_x & DB_POW_MASK2) {
2145 + if (temp_x & DB_POW_MASK1) {
2153 +#endif /* _BITFUNCS_H */
2154 diff -urN linux.old/arch/mips/bcm947xx/include/cfe_osl.h linux.dev/arch/mips/bcm947xx/include/cfe_osl.h
2155 --- linux.old/arch/mips/bcm947xx/include/cfe_osl.h 1970-01-01 01:00:00.000000000 +0100
2156 +++ linux.dev/arch/mips/bcm947xx/include/cfe_osl.h 2005-11-07 22:51:38.776726000 +0100
2159 + * CFE boot loader OS Abstraction Layer.
2161 + * Copyright 2005, Broadcom Corporation
2162 + * All Rights Reserved.
2164 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
2165 + * the contents of this file may not be disclosed to third parties, copied
2166 + * or duplicated in any form, in whole or in part, without the prior
2167 + * written permission of Broadcom Corporation.
2172 +#ifndef _cfe_osl_h_
2173 +#define _cfe_osl_h_
2175 +#include <lib_types.h>
2176 +#include <lib_string.h>
2177 +#include <lib_printf.h>
2178 +#include <lib_malloc.h>
2179 +#include <cpu_config.h>
2180 +#include <cfe_timer.h>
2181 +#include <cfe_iocb.h>
2182 +#include <cfe_devfuncs.h>
2183 +#include <addrspace.h>
2185 +#include <typedefs.h>
2188 +extern int (*xprinthook)(const char *str);
2189 +#define puts(str) do { if (xprinthook) xprinthook(str); } while (0)
2191 +/* assert and panic */
2192 +#define ASSERT(exp) do {} while (0)
2194 +/* PCMCIA attribute space access macros */
2195 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
2197 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
2200 +/* PCI configuration space access macros */
2201 +#define OSL_PCI_READ_CONFIG(loc, offset, size) \
2202 + (offset == 8 ? 0 : 0xffffffff)
2203 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) \
2206 +/* PCI device bus # and slot # */
2207 +#define OSL_PCI_BUS(osh) (0)
2208 +#define OSL_PCI_SLOT(osh) (0)
2210 +/* register access macros */
2211 +#define wreg32(r, v) (*(volatile uint32*)(r) = (uint32)(v))
2212 +#define rreg32(r) (*(volatile uint32*)(r))
2213 +#ifdef IL_BIGENDIAN
2214 +#define wreg16(r, v) (*(volatile uint16*)((ulong)(r)^2) = (uint16)(v))
2215 +#define rreg16(r) (*(volatile uint16*)((ulong)(r)^2))
2216 +#define wreg8(r, v) (*(volatile uint8*)((ulong)(r)^3) = (uint8)(v))
2217 +#define rreg8(r) (*(volatile uint8*)((ulong)(r)^3))
2219 +#define wreg16(r, v) (*(volatile uint16*)(r) = (uint16)(v))
2220 +#define rreg16(r) (*(volatile uint16*)(r))
2221 +#define wreg8(r, v) (*(volatile uint8*)(r) = (uint8)(v))
2222 +#define rreg8(r) (*(volatile uint8*)(r))
2224 +#define R_REG(r) ({ \
2225 + __typeof(*(r)) __osl_v; \
2226 + switch (sizeof(*(r))) { \
2227 + case sizeof(uint8): __osl_v = rreg8((r)); break; \
2228 + case sizeof(uint16): __osl_v = rreg16((r)); break; \
2229 + case sizeof(uint32): __osl_v = rreg32((r)); break; \
2233 +#define W_REG(r, v) do { \
2234 + switch (sizeof(*(r))) { \
2235 + case sizeof(uint8): wreg8((r), (v)); break; \
2236 + case sizeof(uint16): wreg16((r), (v)); break; \
2237 + case sizeof(uint32): wreg32((r), (v)); break; \
2240 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
2241 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
2243 +/* bcopy, bcmp, and bzero */
2244 +#define bcmp(b1, b2, len) lib_memcmp((b1), (b2), (len))
2246 +#define osl_attach(pdev) ((osl_t*)pdev)
2247 +#define osl_detach(osh)
2249 +/* general purpose memory allocation */
2250 +#define MALLOC(osh, size) KMALLOC((size),0)
2251 +#define MFREE(osh, addr, size) KFREE((addr))
2252 +#define MALLOCED(osh) (0)
2253 +#define MALLOC_DUMP(osh, buf, sz)
2254 +#define MALLOC_FAILED(osh) (0)
2256 +/* uncached virtual address */
2257 +#define OSL_UNCACHED(va) ((void*)UNCADDR((ulong)(va)))
2259 +/* host/bus architecture-specific address byte swap */
2260 +#define BUS_SWAP32(v) (v)
2262 +/* get processor cycle count */
2263 +#define OSL_GETCYCLES(x) ((x) = 0)
2265 +/* microsecond delay */
2266 +#define OSL_DELAY(usec) cfe_usleep((cfe_cpu_speed/CPUCFG_CYCLESPERCPUTICK/1000000*(usec)))
2268 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
2270 +/* map/unmap physical to virtual I/O */
2271 +#define REG_MAP(pa, size) ((void*)UNCADDR((ulong)(pa)))
2272 +#define REG_UNMAP(va) do {} while (0)
2274 +/* dereference an address that may cause a bus exception */
2275 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (uint32)(addr))
2276 +extern int osl_busprobe(uint32 *val, uint32 addr);
2278 +/* allocate/free shared (dma-able) consistent (uncached) memory */
2279 +#define DMA_CONSISTENT_ALIGN 4096
2280 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
2281 + osl_dma_alloc_consistent((size), (pap))
2282 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
2283 + osl_dma_free_consistent((void*)(va))
2284 +extern void *osl_dma_alloc_consistent(uint size, ulong *pap);
2285 +extern void osl_dma_free_consistent(void *va);
2287 +/* map/unmap direction */
2291 +/* map/unmap shared (dma-able) memory */
2292 +#define DMA_MAP(osh, va, size, direction, lb) ({ \
2293 + cfe_flushcache(CFE_CACHE_FLUSH_D); \
2294 + PHYSADDR((ulong)(va)); \
2296 +#define DMA_UNMAP(osh, pa, size, direction, p) \
2299 +/* shared (dma-able) memory access macros */
2300 +#define R_SM(r) *(r)
2301 +#define W_SM(r, v) (*(r) = (v))
2302 +#define BZERO_SM(r, len) lib_memset((r), '\0', (len))
2304 +/* generic packet structure */
2305 +#define LBUFSZ 4096
2306 +#define LBDATASZ (LBUFSZ - sizeof(struct lbuf))
2308 + struct lbuf *next; /* pointer to next lbuf if in a chain */
2309 + struct lbuf *link; /* pointer to next lbuf if in a list */
2310 + uchar *head; /* start of buffer */
2311 + uchar *end; /* end of buffer */
2312 + uchar *data; /* start of data */
2313 + uchar *tail; /* end of data */
2314 + uint len; /* nbytes of data */
2315 + void *cookie; /* generic cookie */
2318 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
2319 +#define PKTBUFSZ 2048
2321 +/* packet primitives */
2322 +#define PKTGET(osh, len, send) ((void*)osl_pktget((len)))
2323 +#define PKTFREE(osh, lb, send) osl_pktfree((struct lbuf*)(lb))
2324 +#define PKTDATA(osh, lb) (((struct lbuf*)(lb))->data)
2325 +#define PKTLEN(osh, lb) (((struct lbuf*)(lb))->len)
2326 +#define PKTHEADROOM(osh, lb) (PKTDATA(osh,lb)-(((struct lbuf*)(lb))->head))
2327 +#define PKTTAILROOM(osh, lb) ((((struct lbuf*)(lb))->end)-(((struct lbuf*)(lb))->tail))
2328 +#define PKTNEXT(osh, lb) (((struct lbuf*)(lb))->next)
2329 +#define PKTSETNEXT(lb, x) (((struct lbuf*)(lb))->next = (struct lbuf*)(x))
2330 +#define PKTSETLEN(osh, lb, len) osl_pktsetlen((struct lbuf*)(lb), (len))
2331 +#define PKTPUSH(osh, lb, bytes) osl_pktpush((struct lbuf*)(lb), (bytes))
2332 +#define PKTPULL(osh, lb, bytes) osl_pktpull((struct lbuf*)(lb), (bytes))
2333 +#define PKTDUP(osh, lb) osl_pktdup((struct lbuf*)(lb))
2334 +#define PKTCOOKIE(lb) (((struct lbuf*)(lb))->cookie)
2335 +#define PKTSETCOOKIE(lb, x) (((struct lbuf*)(lb))->cookie = (void*)(x))
2336 +#define PKTLINK(lb) (((struct lbuf*)(lb))->link)
2337 +#define PKTSETLINK(lb, x) (((struct lbuf*)(lb))->link = (struct lbuf*)(x))
2338 +#define PKTPRIO(lb) (0)
2339 +#define PKTSETPRIO(lb, x) do {} while (0)
2340 +extern struct lbuf *osl_pktget(uint len);
2341 +extern void osl_pktfree(struct lbuf *lb);
2342 +extern void osl_pktsetlen(struct lbuf *lb, uint len);
2343 +extern uchar *osl_pktpush(struct lbuf *lb, uint bytes);
2344 +extern uchar *osl_pktpull(struct lbuf *lb, uint bytes);
2345 +extern struct lbuf *osl_pktdup(struct lbuf *lb);
2346 +extern int osl_error(int bcmerror);
2348 +#endif /* _cfe_osl_h_ */
2349 diff -urN linux.old/arch/mips/bcm947xx/include/epivers.h linux.dev/arch/mips/bcm947xx/include/epivers.h
2350 --- linux.old/arch/mips/bcm947xx/include/epivers.h 1970-01-01 01:00:00.000000000 +0100
2351 +++ linux.dev/arch/mips/bcm947xx/include/epivers.h 2005-11-07 22:51:38.776726000 +0100
2354 + * Copyright 2005, Broadcom Corporation
2355 + * All Rights Reserved.
2357 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2358 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2359 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2360 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2366 +#ifndef _epivers_h_
2367 +#define _epivers_h_
2370 +#include <linux/config.h>
2373 +/* Vendor Name, ASCII, 32 chars max */
2375 +#define HPNA_VENDOR COMPANYNAME
2377 +#define HPNA_VENDOR "Broadcom Corporation"
2380 +/* Driver Date, ASCII, 32 chars max */
2381 +#define HPNA_DRV_BUILD_DATE __DATE__
2383 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2384 +#define HPNA_HW_MFG_DATE "Not Specified"
2386 +/* See documentation for Device Type values, 32 values max */
2387 +#ifndef HPNA_DEV_TYPE
2389 +#if defined(CONFIG_BRCM_VJ)
2390 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2392 +#elif defined(CONFIG_BCRM_93725)
2393 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2396 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2400 +#endif /* !HPNA_DEV_TYPE */
2403 +#define EPI_MAJOR_VERSION 3
2405 +#define EPI_MINOR_VERSION 130
2407 +#define EPI_RC_NUMBER 20
2409 +#define EPI_INCREMENTAL_NUMBER 0
2411 +#define EPI_BUILD_NUMBER 0
2413 +#define EPI_VERSION 3,130,20,0
2415 +#define EPI_VERSION_NUM 0x03821400
2417 +/* Driver Version String, ASCII, 32 chars max */
2418 +#define EPI_VERSION_STR "3.130.20.0"
2419 +#define EPI_ROUTER_VERSION_STR "3.131.20.0"
2421 +#endif /* _epivers_h_ */
2422 diff -urN linux.old/arch/mips/bcm947xx/include/epivers.h.in linux.dev/arch/mips/bcm947xx/include/epivers.h.in
2423 --- linux.old/arch/mips/bcm947xx/include/epivers.h.in 1970-01-01 01:00:00.000000000 +0100
2424 +++ linux.dev/arch/mips/bcm947xx/include/epivers.h.in 2005-11-07 21:57:07.849586000 +0100
2427 + * Copyright 2005, Broadcom Corporation
2428 + * All Rights Reserved.
2430 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2431 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2432 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2433 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2439 +#ifndef _epivers_h_
2440 +#define _epivers_h_
2443 +#include <linux/config.h>
2446 +/* Vendor Name, ASCII, 32 chars max */
2448 +#define HPNA_VENDOR COMPANYNAME
2450 +#define HPNA_VENDOR "Broadcom Corporation"
2453 +/* Driver Date, ASCII, 32 chars max */
2454 +#define HPNA_DRV_BUILD_DATE __DATE__
2456 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2457 +#define HPNA_HW_MFG_DATE "Not Specified"
2459 +/* See documentation for Device Type values, 32 values max */
2460 +#ifndef HPNA_DEV_TYPE
2462 +#if defined(CONFIG_BRCM_VJ)
2463 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2465 +#elif defined(CONFIG_BCRM_93725)
2466 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2469 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2473 +#endif /* !HPNA_DEV_TYPE */
2476 +#define EPI_MAJOR_VERSION @EPI_MAJOR_VERSION@
2478 +#define EPI_MINOR_VERSION @EPI_MINOR_VERSION@
2480 +#define EPI_RC_NUMBER @EPI_RC_NUMBER@
2482 +#define EPI_INCREMENTAL_NUMBER @EPI_INCREMENTAL_NUMBER@
2484 +#define EPI_BUILD_NUMBER @EPI_BUILD_NUMBER@
2486 +#define EPI_VERSION @EPI_VERSION@
2488 +#define EPI_VERSION_NUM @EPI_VERSION_NUM@
2490 +/* Driver Version String, ASCII, 32 chars max */
2491 +#define EPI_VERSION_STR "@EPI_VERSION_STR@"
2492 +#define EPI_ROUTER_VERSION_STR "@EPI_ROUTER_VERSION_STR@"
2494 +#endif /* _epivers_h_ */
2495 diff -urN linux.old/arch/mips/bcm947xx/include/etsockio.h linux.dev/arch/mips/bcm947xx/include/etsockio.h
2496 --- linux.old/arch/mips/bcm947xx/include/etsockio.h 1970-01-01 01:00:00.000000000 +0100
2497 +++ linux.dev/arch/mips/bcm947xx/include/etsockio.h 2005-11-07 21:57:07.861586750 +0100
2500 + * Driver-specific socket ioctls
2501 + * used by BSD, Linux, and PSOS
2502 + * Broadcom BCM44XX 10/100Mbps Ethernet Device Driver
2504 + * Copyright 2005, Broadcom Corporation
2505 + * All Rights Reserved.
2507 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2508 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2509 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2510 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2515 +#ifndef _etsockio_h_
2516 +#define _etsockio_h_
2518 +/* THESE MUST BE CONTIGUOUS AND CONSISTENT WITH VALUES IN ETC.H */
2522 +#define SIOCSETCUP (SIOCDEVPRIVATE + 0)
2523 +#define SIOCSETCDOWN (SIOCDEVPRIVATE + 1)
2524 +#define SIOCSETCLOOP (SIOCDEVPRIVATE + 2)
2525 +#define SIOCGETCDUMP (SIOCDEVPRIVATE + 3)
2526 +#define SIOCSETCSETMSGLEVEL (SIOCDEVPRIVATE + 4)
2527 +#define SIOCSETCPROMISC (SIOCDEVPRIVATE + 5)
2528 +#define SIOCSETCTXDOWN (SIOCDEVPRIVATE + 6) /* obsolete */
2529 +#define SIOCSETCSPEED (SIOCDEVPRIVATE + 7)
2530 +#define SIOCTXGEN (SIOCDEVPRIVATE + 8)
2531 +#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
2532 +#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
2533 +#define SIOCSETCQOS (SIOCDEVPRIVATE + 11)
2537 +#define SIOCSETCUP _IOWR('e', 130 + 0, struct ifreq)
2538 +#define SIOCSETCDOWN _IOWR('e', 130 + 1, struct ifreq)
2539 +#define SIOCSETCLOOP _IOWR('e', 130 + 2, struct ifreq)
2540 +#define SIOCGETCDUMP _IOWR('e', 130 + 3, struct ifreq)
2541 +#define SIOCSETCSETMSGLEVEL _IOWR('e', 130 + 4, struct ifreq)
2542 +#define SIOCSETCPROMISC _IOWR('e', 130 + 5, struct ifreq)
2543 +#define SIOCSETCTXDOWN _IOWR('e', 130 + 6, struct ifreq) /* obsolete */
2544 +#define SIOCSETCSPEED _IOWR('e', 130 + 7, struct ifreq)
2545 +#define SIOCTXGEN _IOWR('e', 130 + 8, struct ifreq)
2549 +/* arg to SIOCTXGEN */
2551 + uint32 num; /* number of frames to send */
2552 + uint32 delay; /* delay in microseconds between sending each */
2553 + uint32 size; /* size of ether frame to send */
2554 + uchar buf[1514]; /* starting ether frame data */
2558 diff -urN linux.old/arch/mips/bcm947xx/include/flash.h linux.dev/arch/mips/bcm947xx/include/flash.h
2559 --- linux.old/arch/mips/bcm947xx/include/flash.h 1970-01-01 01:00:00.000000000 +0100
2560 +++ linux.dev/arch/mips/bcm947xx/include/flash.h 2005-11-07 21:57:07.861586750 +0100
2563 + * flash.h: Common definitions for flash access.
2565 + * Copyright 2005, Broadcom Corporation
2566 + * All Rights Reserved.
2568 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2569 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2570 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2571 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2576 +/* Types of flashes we know about */
2577 +typedef enum _flash_type {OLD, BSC, SCS, AMD, SST, SFLASH} flash_type_t;
2579 +/* Commands to write/erase the flases */
2580 +typedef struct _flash_cmds{
2581 + flash_type_t type;
2584 + uint16 erase_block;
2585 + uint16 erase_chip;
2586 + uint16 write_word;
2592 + uint16 read_array;
2595 +#define UNLOCK_CMD_WORDS 2
2597 +typedef struct _unlock_cmd {
2598 + uint addr[UNLOCK_CMD_WORDS];
2599 + uint16 cmd[UNLOCK_CMD_WORDS];
2602 +/* Flash descriptors */
2603 +typedef struct _flash_desc {
2604 + uint16 mfgid; /* Manufacturer Id */
2605 + uint16 devid; /* Device Id */
2606 + uint size; /* Total size in bytes */
2607 + uint width; /* Device width in bytes */
2608 + flash_type_t type; /* Device type old, S, J */
2609 + uint bsize; /* Block size */
2610 + uint nb; /* Number of blocks */
2611 + uint ff; /* First full block */
2612 + uint lf; /* Last full block */
2613 + uint nsub; /* Number of subblocks */
2614 + uint *subblocks; /* Offsets for subblocks */
2615 + char *desc; /* Description */
2619 +#ifdef DECLARE_FLASHES
2620 +flash_cmds_t sflash_cmd_t =
2621 + { SFLASH, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2623 +flash_cmds_t flash_cmds[] = {
2624 +/* type needu preera eraseb erasech write wbuf clcsr rdcsr rdid confrm read */
2625 + { BSC, 0, 0x00, 0x20, 0x00, 0x40, 0x00, 0x50, 0x70, 0x90, 0xd0, 0xff },
2626 + { SCS, 0, 0x00, 0x20, 0x00, 0x40, 0xe8, 0x50, 0x70, 0x90, 0xd0, 0xff },
2627 + { AMD, 1, 0x80, 0x30, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
2628 + { SST, 1, 0x80, 0x50, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
2632 +unlock_cmd_t unlock_cmd_amd = {
2634 +/* addr: */ { 0x0aa8, 0x0556},
2636 +/* addr: */ { 0x0aaa, 0x0554},
2638 +/* data: */ { 0xaa, 0x55}
2641 +unlock_cmd_t unlock_cmd_sst = {
2643 +/* addr: */ { 0xaaa8, 0x5556},
2645 +/* addr: */ { 0xaaaa, 0x5554},
2647 +/* data: */ { 0xaa, 0x55}
2650 +#define AMD_CMD 0xaaa
2651 +#define SST_CMD 0xaaaa
2653 +/* intel unlock block cmds */
2654 +#define INTEL_UNLOCK1 0x60
2655 +#define INTEL_UNLOCK2 0xD0
2657 +/* Just eight blocks of 8KB byte each */
2659 +uint blk8x8k[] = { 0x00000000,
2670 +/* Funky AMD arrangement for 29xx800's */
2671 +uint amd800[] = { 0x00000000, /* 16KB */
2672 + 0x00004000, /* 32KB */
2673 + 0x0000c000, /* 8KB */
2674 + 0x0000e000, /* 8KB */
2675 + 0x00010000, /* 8KB */
2676 + 0x00012000, /* 8KB */
2677 + 0x00014000, /* 32KB */
2678 + 0x0001c000, /* 16KB */
2682 +/* AMD arrangement for 29xx160's */
2683 +uint amd4112[] = { 0x00000000, /* 32KB */
2684 + 0x00008000, /* 8KB */
2685 + 0x0000a000, /* 8KB */
2686 + 0x0000c000, /* 16KB */
2689 +uint amd2114[] = { 0x00000000, /* 16KB */
2690 + 0x00004000, /* 8KB */
2691 + 0x00006000, /* 8KB */
2692 + 0x00008000, /* 32KB */
2697 +flash_desc_t sflash_desc =
2698 + { 0, 0, 0, 0, SFLASH, 0, 0, 0, 0, 0, NULL, "SFLASH" };
2700 +flash_desc_t flashes[] = {
2701 + { 0x00b0, 0x00d0, 0x0200000, 2, SCS, 0x10000, 32, 0, 31, 0, NULL, "Intel 28F160S3/5 1Mx16" },
2702 + { 0x00b0, 0x00d4, 0x0400000, 2, SCS, 0x10000, 64, 0, 63, 0, NULL, "Intel 28F320S3/5 2Mx16" },
2703 + { 0x0089, 0x8890, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160B3 1Mx16 TopB" },
2704 + { 0x0089, 0x8891, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160B3 1Mx16 BotB" },
2705 + { 0x0089, 0x8896, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320B3 2Mx16 TopB" },
2706 + { 0x0089, 0x8897, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320B3 2Mx16 BotB" },
2707 + { 0x0089, 0x8898, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640B3 4Mx16 TopB" },
2708 + { 0x0089, 0x8899, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640B3 4Mx16 BotB" },
2709 + { 0x0089, 0x88C2, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160C3 1Mx16 TopB" },
2710 + { 0x0089, 0x88C3, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160C3 1Mx16 BotB" },
2711 + { 0x0089, 0x88C4, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320C3 2Mx16 TopB" },
2712 + { 0x0089, 0x88C5, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320C3 2Mx16 BotB" },
2713 + { 0x0089, 0x88CC, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640C3 4Mx16 TopB" },
2714 + { 0x0089, 0x88CD, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640C3 4Mx16 BotB" },
2715 + { 0x0089, 0x0014, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J5 2Mx16" },
2716 + { 0x0089, 0x0015, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J5 4Mx16" },
2717 + { 0x0089, 0x0016, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J3 2Mx16" },
2718 + { 0x0089, 0x0017, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J3 4Mx16" },
2719 + { 0x0089, 0x0018, 0x1000000, 2, SCS, 0x20000, 128, 0, 127, 0, NULL, "Intel 28F128J3 8Mx16" },
2720 + { 0x00b0, 0x00e3, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Sharp 28F320BJE 2Mx16 BotB" },
2721 + { 0x0001, 0x224a, 0x0100000, 2, AMD, 0x10000, 16, 0, 13, 8, amd800, "AMD 29DL800BT 512Kx16 TopB" },
2722 + { 0x0001, 0x22cb, 0x0100000, 2, AMD, 0x10000, 16, 2, 15, 8, amd800, "AMD 29DL800BB 512Kx16 BotB" },
2723 + { 0x0001, 0x22c4, 0x0200000, 2, AMD, 0x10000, 32, 0, 30, 4, amd2114, "AMD 29lv160DT 1Mx16 TopB" },
2724 + { 0x0001, 0x2249, 0x0200000, 2, AMD, 0x10000, 32, 1, 31, 4, amd4112, "AMD 29lv160DB 1Mx16 BotB" },
2725 + { 0x0001, 0x22f6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320DT 2Mx16 TopB" },
2726 + { 0x0001, 0x22f9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320DB 2Mx16 BotB" },
2727 + { 0x0001, 0x227e, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320MT 2Mx16 TopB" },
2728 + { 0x0001, 0x2200, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320MB 2Mx16 BotB" },
2729 + { 0x0020, 0x22CA, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "ST 29w320DT 2Mx16 TopB" },
2730 + { 0x0020, 0x22CB, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "ST 29w320DB 2Mx16 BotB" },
2731 + { 0x00C2, 0x00A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
2732 + { 0x00C2, 0x00A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
2733 + { 0x0004, 0x22F6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MBM29LV320TE 2Mx16 TopB" },
2734 + { 0x0004, 0x22F9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MBM29LV320BE 2Mx16 BotB" },
2735 + { 0x0098, 0x009A, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "TC58FVT321 2Mx16 TopB" },
2736 + { 0x0098, 0x009C, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "TC58FVB321 2Mx16 BotB" },
2737 + { 0x00C2, 0x22A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
2738 + { 0x00C2, 0x22A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
2739 + { 0x00BF, 0x2783, 0x0400000, 2, SST, 0x10000, 64, 0, 63, 0, NULL, "SST39VF320 2Mx16" },
2740 + { 0, 0, 0, 0, OLD, 0, 0, 0, 0, 0, NULL, NULL },
2745 +extern flash_cmds_t flash_cmds[];
2746 +extern unlock_cmd_t unlock_cmd;
2747 +extern flash_desc_t flashes[];
2750 diff -urN linux.old/arch/mips/bcm947xx/include/flashutl.h linux.dev/arch/mips/bcm947xx/include/flashutl.h
2751 --- linux.old/arch/mips/bcm947xx/include/flashutl.h 1970-01-01 01:00:00.000000000 +0100
2752 +++ linux.dev/arch/mips/bcm947xx/include/flashutl.h 2005-11-07 21:57:07.861586750 +0100
2755 + * BCM47XX FLASH driver interface
2757 + * Copyright 2005, Broadcom Corporation
2758 + * All Rights Reserved.
2760 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2761 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2762 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2763 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2767 +#ifndef _flashutl_h_
2768 +#define _flashutl_h_
2771 +#ifndef _LANGUAGE_ASSEMBLY
2773 +int sysFlashInit(char *flash_str);
2774 +int sysFlashRead(uint off, uchar *dst, uint bytes);
2775 +int sysFlashWrite(uint off, uchar *src, uint bytes);
2776 +void nvWrite(unsigned short *data, unsigned int len);
2778 +#endif /* _LANGUAGE_ASSEMBLY */
2780 +#endif /* _flashutl_h_ */
2781 diff -urN linux.old/arch/mips/bcm947xx/include/hnddma.h linux.dev/arch/mips/bcm947xx/include/hnddma.h
2782 --- linux.old/arch/mips/bcm947xx/include/hnddma.h 1970-01-01 01:00:00.000000000 +0100
2783 +++ linux.dev/arch/mips/bcm947xx/include/hnddma.h 2005-11-07 22:51:38.776726000 +0100
2786 + * Generic Broadcom Home Networking Division (HND) DMA engine SW interface
2787 + * This supports the following chips: BCM42xx, 44xx, 47xx .
2789 + * Copyright 2005, Broadcom Corporation
2790 + * All Rights Reserved.
2792 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2793 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2794 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2795 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2802 +/* export structure */
2803 +typedef volatile struct {
2804 + /* rx error counters */
2805 + uint rxgiants; /* rx giant frames */
2806 + uint rxnobuf; /* rx out of dma descriptors */
2807 + /* tx error counters */
2808 + uint txnobuf; /* tx out of dma descriptors */
2820 +extern void * dma_attach(osl_t *osh, char *name, sb_t *sbh, void *dmaregstx, void *dmaregsrx,
2821 + uint ntxd, uint nrxd, uint rxbufsize, uint nrxpost, uint rxoffset, uint *msg_level);
2822 +extern void dma_detach(di_t *di);
2823 +extern void dma_txreset(di_t *di);
2824 +extern void dma_rxreset(di_t *di);
2825 +extern void dma_txinit(di_t *di);
2826 +extern bool dma_txenabled(di_t *di);
2827 +extern void dma_rxinit(di_t *di);
2828 +extern void dma_rxenable(di_t *di);
2829 +extern bool dma_rxenabled(di_t *di);
2830 +extern void dma_txsuspend(di_t *di);
2831 +extern void dma_txresume(di_t *di);
2832 +extern bool dma_txsuspended(di_t *di);
2833 +extern bool dma_txsuspendedidle(di_t *di);
2834 +extern bool dma_txstopped(di_t *di);
2835 +extern bool dma_rxstopped(di_t *di);
2836 +extern int dma_txfast(di_t *di, void *p, uint32 coreflags);
2837 +extern void dma_fifoloopbackenable(di_t *di);
2838 +extern void *dma_rx(di_t *di);
2839 +extern void dma_rxfill(di_t *di);
2840 +extern void dma_txreclaim(di_t *di, bool forceall);
2841 +extern void dma_rxreclaim(di_t *di);
2842 +extern uintptr dma_getvar(di_t *di, char *name);
2843 +extern void *dma_getnexttxp(di_t *di, bool forceall);
2844 +extern void *dma_peeknexttxp(di_t *di);
2845 +extern void *dma_getnextrxp(di_t *di, bool forceall);
2846 +extern void dma_txblock(di_t *di);
2847 +extern void dma_txunblock(di_t *di);
2848 +extern uint dma_txactive(di_t *di);
2849 +extern void dma_txrotate(di_t *di);
2851 +extern void dma_rxpiomode(dma32regs_t *);
2852 +extern void dma_txpioloopback(dma32regs_t *);
2855 +#endif /* _hnddma_h_ */
2856 diff -urN linux.old/arch/mips/bcm947xx/include/hndmips.h linux.dev/arch/mips/bcm947xx/include/hndmips.h
2857 --- linux.old/arch/mips/bcm947xx/include/hndmips.h 1970-01-01 01:00:00.000000000 +0100
2858 +++ linux.dev/arch/mips/bcm947xx/include/hndmips.h 2005-11-07 21:57:07.861586750 +0100
2861 + * Alternate include file for HND sbmips.h since CFE also ships with
2864 + * Copyright 2005, Broadcom Corporation
2865 + * All Rights Reserved.
2867 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2868 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2869 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2870 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2875 +#include "sbmips.h"
2876 diff -urN linux.old/arch/mips/bcm947xx/include/linux_osl.h linux.dev/arch/mips/bcm947xx/include/linux_osl.h
2877 --- linux.old/arch/mips/bcm947xx/include/linux_osl.h 1970-01-01 01:00:00.000000000 +0100
2878 +++ linux.dev/arch/mips/bcm947xx/include/linux_osl.h 2005-11-07 22:51:38.776726000 +0100
2881 + * Linux OS Independent Layer
2883 + * Copyright 2005, Broadcom Corporation
2884 + * All Rights Reserved.
2886 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2887 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2888 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2889 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2894 +#ifndef _linux_osl_h_
2895 +#define _linux_osl_h_
2897 +#include <typedefs.h>
2899 +/* use current 2.4.x calling conventions */
2900 +#include <linuxver.h>
2902 +/* assert and panic */
2904 +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
2905 +#if GCC_VERSION > 30100
2906 +#define ASSERT(exp) do {} while (0)
2908 +/* ASSERT could causes segmentation fault on GCC3.1, use empty instead*/
2909 +#define ASSERT(exp)
2913 +/* microsecond delay */
2914 +#define OSL_DELAY(usec) osl_delay(usec)
2915 +extern void osl_delay(uint usec);
2917 +/* PCMCIA attribute space access macros */
2918 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
2919 +struct pcmcia_dev {
2920 + dev_link_t link; /* PCMCIA device pointer */
2921 + dev_node_t node; /* PCMCIA node structure */
2922 + void *base; /* Mapped attribute memory window */
2923 + size_t size; /* Size of window */
2924 + void *drv; /* Driver data */
2927 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
2928 + osl_pcmcia_read_attr((osh), (offset), (buf), (size))
2929 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
2930 + osl_pcmcia_write_attr((osh), (offset), (buf), (size))
2931 +extern void osl_pcmcia_read_attr(osl_t *osh, uint offset, void *buf, int size);
2932 +extern void osl_pcmcia_write_attr(osl_t *osh, uint offset, void *buf, int size);
2934 +/* PCI configuration space access macros */
2935 +#define OSL_PCI_READ_CONFIG(osh, offset, size) \
2936 + osl_pci_read_config((osh), (offset), (size))
2937 +#define OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
2938 + osl_pci_write_config((osh), (offset), (size), (val))
2939 +extern uint32 osl_pci_read_config(osl_t *osh, uint size, uint offset);
2940 +extern void osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val);
2942 +/* PCI device bus # and slot # */
2943 +#define OSL_PCI_BUS(osh) osl_pci_bus(osh)
2944 +#define OSL_PCI_SLOT(osh) osl_pci_slot(osh)
2945 +extern uint osl_pci_bus(osl_t *osh);
2946 +extern uint osl_pci_slot(osl_t *osh);
2948 +/* OSL initialization */
2949 +extern osl_t *osl_attach(void *pdev);
2950 +extern void osl_detach(osl_t *osh);
2952 +/* host/bus architecture-specific byte swap */
2953 +#define BUS_SWAP32(v) (v)
2955 +/* general purpose memory allocation */
2957 +#if defined(BCMDBG_MEM)
2959 +#define MALLOC(osh, size) osl_debug_malloc((osh), (size), __LINE__, __FILE__)
2960 +#define MFREE(osh, addr, size) osl_debug_mfree((osh), (addr), (size), __LINE__, __FILE__)
2961 +#define MALLOCED(osh) osl_malloced((osh))
2962 +#define MALLOC_DUMP(osh, buf, sz) osl_debug_memdump((osh), (buf), (sz))
2963 +extern void *osl_debug_malloc(osl_t *osh, uint size, int line, char* file);
2964 +extern void osl_debug_mfree(osl_t *osh, void *addr, uint size, int line, char* file);
2965 +extern char *osl_debug_memdump(osl_t *osh, char *buf, uint sz);
2969 +#define MALLOC(osh, size) osl_malloc((osh), (size))
2970 +#define MFREE(osh, addr, size) osl_mfree((osh), (addr), (size))
2971 +#define MALLOCED(osh) osl_malloced((osh))
2973 +#endif /* BCMDBG_MEM */
2975 +#define MALLOC_FAILED(osh) osl_malloc_failed((osh))
2977 +extern void *osl_malloc(osl_t *osh, uint size);
2978 +extern void osl_mfree(osl_t *osh, void *addr, uint size);
2979 +extern uint osl_malloced(osl_t *osh);
2980 +extern uint osl_malloc_failed(osl_t *osh);
2982 +/* allocate/free shared (dma-able) consistent memory */
2983 +#define DMA_CONSISTENT_ALIGN PAGE_SIZE
2984 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
2985 + osl_dma_alloc_consistent((osh), (size), (pap))
2986 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
2987 + osl_dma_free_consistent((osh), (void*)(va), (size), (pa))
2988 +extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap);
2989 +extern void osl_dma_free_consistent(osl_t *osh, void *va, uint size, ulong pa);
2991 +/* map/unmap direction */
2995 +/* map/unmap shared (dma-able) memory */
2996 +#define DMA_MAP(osh, va, size, direction, p) \
2997 + osl_dma_map((osh), (va), (size), (direction))
2998 +#define DMA_UNMAP(osh, pa, size, direction, p) \
2999 + osl_dma_unmap((osh), (pa), (size), (direction))
3000 +extern uint osl_dma_map(osl_t *osh, void *va, uint size, int direction);
3001 +extern void osl_dma_unmap(osl_t *osh, uint pa, uint size, int direction);
3003 +/* register access macros */
3004 +#if defined(BCMJTAG)
3005 +#include <bcmjtag.h>
3006 +#define R_REG(r) bcmjtag_read(NULL, (uint32)(r), sizeof (*(r)))
3007 +#define W_REG(r, v) bcmjtag_write(NULL, (uint32)(r), (uint32)(v), sizeof (*(r)))
3011 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
3012 + * Macros expand to calls to functions defined in linux_osl.c .
3016 +/* string library, kernel mode */
3017 +#define printf(fmt, args...) printk(fmt, ## args)
3018 +#include <linux/kernel.h>
3019 +#include <linux/string.h>
3021 +/* register access macros */
3022 +#if !defined(BCMJTAG)
3023 +#ifndef IL_BIGENDIAN
3024 +#define R_REG(r) ( \
3025 + sizeof(*(r)) == sizeof(uint8) ? readb((volatile uint8*)(r)) : \
3026 + sizeof(*(r)) == sizeof(uint16) ? readw((volatile uint16*)(r)) : \
3027 + readl((volatile uint32*)(r)) \
3029 +#define W_REG(r, v) do { \
3030 + switch (sizeof(*(r))) { \
3031 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)(r)); break; \
3032 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)(r)); break; \
3033 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
3036 +#else /* IL_BIGENDIAN */
3037 +#define R_REG(r) ({ \
3038 + __typeof(*(r)) __osl_v; \
3039 + switch (sizeof(*(r))) { \
3040 + case sizeof(uint8): __osl_v = readb((volatile uint8*)((uint32)r^3)); break; \
3041 + case sizeof(uint16): __osl_v = readw((volatile uint16*)((uint32)r^2)); break; \
3042 + case sizeof(uint32): __osl_v = readl((volatile uint32*)(r)); break; \
3046 +#define W_REG(r, v) do { \
3047 + switch (sizeof(*(r))) { \
3048 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)((uint32)r^3)); break; \
3049 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)((uint32)r^2)); break; \
3050 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
3056 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3057 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3059 +/* bcopy, bcmp, and bzero */
3060 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
3061 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
3062 +#define bzero(b, len) memset((b), '\0', (len))
3064 +/* uncached virtual address */
3066 +#define OSL_UNCACHED(va) KSEG1ADDR((va))
3067 +#include <asm/addrspace.h>
3069 +#define OSL_UNCACHED(va) (va)
3072 +/* get processor cycle count */
3074 +#define OSL_GETCYCLES(x) ((x) = read_c0_count() * 2)
3075 +#elif defined(__i386__)
3076 +#define OSL_GETCYCLES(x) rdtscl((x))
3078 +#define OSL_GETCYCLES(x) ((x) = 0)
3081 +/* dereference an address that may cause a bus exception */
3083 +#if defined(MODULE) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17))
3084 +#define BUSPROBE(val, addr) panic("get_dbe() will not fixup a bus exception when compiled into a module")
3086 +#define BUSPROBE(val, addr) get_dbe((val), (addr))
3087 +#include <asm/paccess.h>
3090 +#define BUSPROBE(val, addr) ({ (val) = R_REG((addr)); 0; })
3093 +/* map/unmap physical to virtual I/O */
3094 +#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), (unsigned long)(size))
3095 +#define REG_UNMAP(va) iounmap((void *)(va))
3097 +/* shared (dma-able) memory access macros */
3098 +#define R_SM(r) *(r)
3099 +#define W_SM(r, v) (*(r) = (v))
3100 +#define BZERO_SM(r, len) memset((r), '\0', (len))
3102 +/* packet primitives */
3103 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
3104 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
3105 +#define PKTDATA(osh, skb) (((struct sk_buff*)(skb))->data)
3106 +#define PKTLEN(osh, skb) (((struct sk_buff*)(skb))->len)
3107 +#define PKTHEADROOM(osh, skb) (PKTDATA(osh,skb)-(((struct sk_buff*)(skb))->head))
3108 +#define PKTTAILROOM(osh, skb) ((((struct sk_buff*)(skb))->end)-(((struct sk_buff*)(skb))->tail))
3109 +#define PKTNEXT(osh, skb) (((struct sk_buff*)(skb))->next)
3110 +#define PKTSETNEXT(skb, x) (((struct sk_buff*)(skb))->next = (struct sk_buff*)(x))
3111 +#define PKTSETLEN(osh, skb, len) __skb_trim((struct sk_buff*)(skb), (len))
3112 +#define PKTPUSH(osh, skb, bytes) skb_push((struct sk_buff*)(skb), (bytes))
3113 +#define PKTPULL(osh, skb, bytes) skb_pull((struct sk_buff*)(skb), (bytes))
3114 +#define PKTDUP(osh, skb) skb_clone((struct sk_buff*)(skb), GFP_ATOMIC)
3115 +#define PKTCOOKIE(skb) ((void*)((struct sk_buff*)(skb))->csum)
3116 +#define PKTSETCOOKIE(skb, x) (((struct sk_buff*)(skb))->csum = (uint)(x))
3117 +#define PKTLINK(skb) (((struct sk_buff*)(skb))->prev)
3118 +#define PKTSETLINK(skb, x) (((struct sk_buff*)(skb))->prev = (struct sk_buff*)(x))
3119 +#define PKTPRIO(skb) (((struct sk_buff*)(skb))->priority)
3120 +#define PKTSETPRIO(skb, x) (((struct sk_buff*)(skb))->priority = (x))
3121 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
3122 +extern void osl_pktfree(void *skb);
3126 +/* string library */
3129 +#define printf(fmt, args...) osl_printf((fmt), ## args)
3131 +#define sprintf(buf, fmt, args...) osl_sprintf((buf), (fmt), ## args)
3133 +#define strcmp(s1, s2) osl_strcmp((s1), (s2))
3135 +#define strncmp(s1, s2, n) osl_strncmp((s1), (s2), (n))
3137 +#define strlen(s) osl_strlen((s))
3139 +#define strcpy(d, s) osl_strcpy((d), (s))
3141 +#define strncpy(d, s, n) osl_strncpy((d), (s), (n))
3143 +extern int osl_printf(const char *format, ...);
3144 +extern int osl_sprintf(char *buf, const char *format, ...);
3145 +extern int osl_strcmp(const char *s1, const char *s2);
3146 +extern int osl_strncmp(const char *s1, const char *s2, uint n);
3147 +extern int osl_strlen(const char *s);
3148 +extern char* osl_strcpy(char *d, const char *s);
3149 +extern char* osl_strncpy(char *d, const char *s, uint n);
3151 +/* register access macros */
3152 +#if !defined(BCMJTAG)
3153 +#define R_REG(r) ( \
3154 + sizeof(*(r)) == sizeof(uint8) ? osl_readb((volatile uint8*)(r)) : \
3155 + sizeof(*(r)) == sizeof(uint16) ? osl_readw((volatile uint16*)(r)) : \
3156 + osl_readl((volatile uint32*)(r)) \
3158 +#define W_REG(r, v) do { \
3159 + switch (sizeof(*(r))) { \
3160 + case sizeof(uint8): osl_writeb((uint8)(v), (volatile uint8*)(r)); break; \
3161 + case sizeof(uint16): osl_writew((uint16)(v), (volatile uint16*)(r)); break; \
3162 + case sizeof(uint32): osl_writel((uint32)(v), (volatile uint32*)(r)); break; \
3167 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3168 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3169 +extern uint8 osl_readb(volatile uint8 *r);
3170 +extern uint16 osl_readw(volatile uint16 *r);
3171 +extern uint32 osl_readl(volatile uint32 *r);
3172 +extern void osl_writeb(uint8 v, volatile uint8 *r);
3173 +extern void osl_writew(uint16 v, volatile uint16 *r);
3174 +extern void osl_writel(uint32 v, volatile uint32 *r);
3176 +/* bcopy, bcmp, and bzero */
3177 +extern void bcopy(const void *src, void *dst, int len);
3178 +extern int bcmp(const void *b1, const void *b2, int len);
3179 +extern void bzero(void *b, int len);
3181 +/* uncached virtual address */
3182 +#define OSL_UNCACHED(va) osl_uncached((va))
3183 +extern void *osl_uncached(void *va);
3185 +/* get processor cycle count */
3186 +#define OSL_GETCYCLES(x) ((x) = osl_getcycles())
3187 +extern uint osl_getcycles(void);
3189 +/* dereference an address that may target abort */
3190 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (addr))
3191 +extern int osl_busprobe(uint32 *val, uint32 addr);
3193 +/* map/unmap physical to virtual */
3194 +#define REG_MAP(pa, size) osl_reg_map((pa), (size))
3195 +#define REG_UNMAP(va) osl_reg_unmap((va))
3196 +extern void *osl_reg_map(uint32 pa, uint size);
3197 +extern void osl_reg_unmap(void *va);
3199 +/* shared (dma-able) memory access macros */
3200 +#define R_SM(r) *(r)
3201 +#define W_SM(r, v) (*(r) = (v))
3202 +#define BZERO_SM(r, len) bzero((r), (len))
3204 +/* packet primitives */
3205 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
3206 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
3207 +#define PKTDATA(osh, skb) osl_pktdata((osh), (skb))
3208 +#define PKTLEN(osh, skb) osl_pktlen((osh), (skb))
3209 +#define PKTHEADROOM(osh, skb) osl_pktheadroom((osh), (skb))
3210 +#define PKTTAILROOM(osh, skb) osl_pkttailroom((osh), (skb))
3211 +#define PKTNEXT(osh, skb) osl_pktnext((osh), (skb))
3212 +#define PKTSETNEXT(skb, x) osl_pktsetnext((skb), (x))
3213 +#define PKTSETLEN(osh, skb, len) osl_pktsetlen((osh), (skb), (len))
3214 +#define PKTPUSH(osh, skb, bytes) osl_pktpush((osh), (skb), (bytes))
3215 +#define PKTPULL(osh, skb, bytes) osl_pktpull((osh), (skb), (bytes))
3216 +#define PKTDUP(osh, skb) osl_pktdup((osh), (skb))
3217 +#define PKTCOOKIE(skb) osl_pktcookie((skb))
3218 +#define PKTSETCOOKIE(skb, x) osl_pktsetcookie((skb), (x))
3219 +#define PKTLINK(skb) osl_pktlink((skb))
3220 +#define PKTSETLINK(skb, x) osl_pktsetlink((skb), (x))
3221 +#define PKTPRIO(skb) osl_pktprio((skb))
3222 +#define PKTSETPRIO(skb, x) osl_pktsetprio((skb), (x))
3223 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
3224 +extern void osl_pktfree(void *skb);
3225 +extern uchar *osl_pktdata(osl_t *osh, void *skb);
3226 +extern uint osl_pktlen(osl_t *osh, void *skb);
3227 +extern uint osl_pktheadroom(osl_t *osh, void *skb);
3228 +extern uint osl_pkttailroom(osl_t *osh, void *skb);
3229 +extern void *osl_pktnext(osl_t *osh, void *skb);
3230 +extern void osl_pktsetnext(void *skb, void *x);
3231 +extern void osl_pktsetlen(osl_t *osh, void *skb, uint len);
3232 +extern uchar *osl_pktpush(osl_t *osh, void *skb, int bytes);
3233 +extern uchar *osl_pktpull(osl_t *osh, void *skb, int bytes);
3234 +extern void *osl_pktdup(osl_t *osh, void *skb);
3235 +extern void *osl_pktcookie(void *skb);
3236 +extern void osl_pktsetcookie(void *skb, void *x);
3237 +extern void *osl_pktlink(void *skb);
3238 +extern void osl_pktsetlink(void *skb, void *x);
3239 +extern uint osl_pktprio(void *skb);
3240 +extern void osl_pktsetprio(void *skb, uint x);
3242 +#endif /* BINOSL */
3244 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
3245 +extern int osl_error(int bcmerror);
3247 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
3248 +#define PKTBUFSZ 2048
3250 +#endif /* _linux_osl_h_ */
3251 diff -urN linux.old/arch/mips/bcm947xx/include/linuxver.h linux.dev/arch/mips/bcm947xx/include/linuxver.h
3252 --- linux.old/arch/mips/bcm947xx/include/linuxver.h 1970-01-01 01:00:00.000000000 +0100
3253 +++ linux.dev/arch/mips/bcm947xx/include/linuxver.h 2005-11-07 22:51:38.780726250 +0100
3256 + * Linux-specific abstractions to gain some independence from linux kernel versions.
3257 + * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
3259 + * Copyright 2005, Broadcom Corporation
3260 + * All Rights Reserved.
3262 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3263 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3264 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3265 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3270 +#ifndef _linuxver_h_
3271 +#define _linuxver_h_
3273 +#include <linux/config.h>
3274 +#include <linux/version.h>
3276 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
3277 +/* __NO_VERSION__ must be defined for all linkables except one in 2.2 */
3278 +#ifdef __UNDEF_NO_VERSION__
3279 +#undef __NO_VERSION__
3281 +#define __NO_VERSION__
3285 +#if defined(MODULE) && defined(MODVERSIONS)
3286 +#include <linux/modversions.h>
3289 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
3290 +#include <linux/moduleparam.h>
3294 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
3295 +#define module_param(_name_, _type_, _perm_) MODULE_PARM(_name_, "i")
3296 +#define module_param_string(_name_, _string_, _size_, _perm_) MODULE_PARM(_string_, "c" __MODULE_STRING(_size_))
3299 +/* linux/malloc.h is deprecated, use linux/slab.h instead. */
3300 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9))
3301 +#include <linux/malloc.h>
3303 +#include <linux/slab.h>
3306 +#include <linux/types.h>
3307 +#include <linux/init.h>
3308 +#include <linux/mm.h>
3309 +#include <linux/string.h>
3310 +#include <linux/pci.h>
3311 +#include <linux/interrupt.h>
3312 +#include <linux/netdevice.h>
3313 +#include <asm/io.h>
3315 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41))
3316 +#include <linux/workqueue.h>
3318 +#include <linux/tqueue.h>
3319 +#ifndef work_struct
3320 +#define work_struct tq_struct
3323 +#define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
3325 +#ifndef schedule_work
3326 +#define schedule_work(_work) schedule_task((_work))
3328 +#ifndef flush_scheduled_work
3329 +#define flush_scheduled_work() flush_scheduled_tasks()
3333 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
3334 +/* Some distributions have their own 2.6.x compatibility layers */
3336 +typedef void irqreturn_t;
3338 +#define IRQ_HANDLED
3339 +#define IRQ_RETVAL(x)
3342 +typedef irqreturn_t (*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs);
3345 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
3347 +#include <pcmcia/version.h>
3348 +#include <pcmcia/cs_types.h>
3349 +#include <pcmcia/cs.h>
3350 +#include <pcmcia/cistpl.h>
3351 +#include <pcmcia/cisreg.h>
3352 +#include <pcmcia/ds.h>
3354 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,69))
3355 +/* In 2.5 (as of 2.5.69 at least) there is a cs_error exported which
3356 + * does this, but it's not in 2.4 so we do our own for now. */
3358 +cs_error(client_handle_t handle, int func, int ret)
3360 + error_info_t err = { func, ret };
3361 + CardServices(ReportError, handle, &err);
3365 +#endif /* CONFIG_PCMCIA */
3374 +#define __devinit __init
3376 +#ifndef __devinitdata
3377 +#define __devinitdata
3379 +#ifndef __devexit_p
3380 +#define __devexit_p(x) x
3383 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
3385 +#define pci_get_drvdata(dev) (dev)->sysdata
3386 +#define pci_set_drvdata(dev, value) (dev)->sysdata=(value)
3389 + * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
3392 +struct pci_device_id {
3393 + unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
3394 + unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
3395 + unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
3396 + unsigned long driver_data; /* Data private to the driver */
3399 +struct pci_driver {
3400 + struct list_head node;
3402 + const struct pci_device_id *id_table; /* NULL if wants all devices */
3403 + int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
3404 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
3405 + void (*suspend)(struct pci_dev *dev); /* Device suspended */
3406 + void (*resume)(struct pci_dev *dev); /* Device woken up */
3409 +#define MODULE_DEVICE_TABLE(type, name)
3410 +#define PCI_ANY_ID (~0)
3413 +#define pci_module_init pci_register_driver
3414 +extern int pci_register_driver(struct pci_driver *drv);
3415 +extern void pci_unregister_driver(struct pci_driver *drv);
3417 +#endif /* PCI registration */
3419 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
3421 +#define module_init(x) int init_module(void) { return x(); }
3422 +#define module_exit(x) void cleanup_module(void) { x(); }
3424 +#define module_init(x) __initcall(x);
3425 +#define module_exit(x) __exitcall(x);
3429 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,48))
3430 +#define list_for_each(pos, head) \
3431 + for (pos = (head)->next; pos != (head); pos = pos->next)
3434 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,13))
3435 +#define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
3436 +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,44))
3437 +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
3440 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,23))
3441 +#define pci_enable_device(dev) do { } while (0)
3444 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,14))
3445 +#define net_device device
3448 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,42))
3453 + * See linux/Documentation/DMA-mapping.txt
3456 +#ifndef PCI_DMA_TODEVICE
3457 +#define PCI_DMA_TODEVICE 1
3458 +#define PCI_DMA_FROMDEVICE 2
3461 +typedef u32 dma_addr_t;
3463 +/* Pure 2^n version of get_order */
3464 +static inline int get_order(unsigned long size)
3468 + size = (size-1) >> (PAGE_SHIFT-1);
3477 +static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
3478 + dma_addr_t *dma_handle)
3481 + int gfp = GFP_ATOMIC | GFP_DMA;
3483 + ret = (void *)__get_free_pages(gfp, get_order(size));
3485 + if (ret != NULL) {
3486 + memset(ret, 0, size);
3487 + *dma_handle = virt_to_bus(ret);
3491 +static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
3492 + void *vaddr, dma_addr_t dma_handle)
3494 + free_pages((unsigned long)vaddr, get_order(size));
3497 +extern uint pci_map_single(void *dev, void *va, uint size, int direction);
3498 +extern void pci_unmap_single(void *dev, uint pa, uint size, int direction);
3500 +#define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
3501 +#define pci_unmap_single(cookie, address, size, dir)
3504 +#endif /* DMA mapping */
3506 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43))
3508 +#define dev_kfree_skb_any(a) dev_kfree_skb(a)
3509 +#define netif_down(dev) do { (dev)->start = 0; } while(0)
3511 +/* pcmcia-cs provides its own netdevice compatibility layer */
3512 +#ifndef _COMPAT_NETDEVICE_H
3517 + * For pre-softnet kernels we need to tell the upper layer not to
3518 + * re-enter start_xmit() while we are in there. However softnet
3519 + * guarantees not to enter while we are in there so there is no need
3520 + * to do the netif_stop_queue() dance unless the transmit queue really
3521 + * gets stuck. This should also improve performance according to tests
3522 + * done by Aman Singla.
3525 +#define dev_kfree_skb_irq(a) dev_kfree_skb(a)
3526 +#define netif_wake_queue(dev) do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while(0)
3527 +#define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy)
3529 +static inline void netif_start_queue(struct net_device *dev)
3532 + dev->interrupt = 0;
3536 +#define netif_queue_stopped(dev) (dev)->tbusy
3537 +#define netif_running(dev) (dev)->start
3539 +#endif /* _COMPAT_NETDEVICE_H */
3541 +#define netif_device_attach(dev) netif_start_queue(dev)
3542 +#define netif_device_detach(dev) netif_stop_queue(dev)
3544 +/* 2.4.x renamed bottom halves to tasklets */
3545 +#define tasklet_struct tq_struct
3546 +static inline void tasklet_schedule(struct tasklet_struct *tasklet)
3548 + queue_task(tasklet, &tq_immediate);
3549 + mark_bh(IMMEDIATE_BH);
3552 +static inline void tasklet_init(struct tasklet_struct *tasklet,
3553 + void (*func)(unsigned long),
3554 + unsigned long data)
3556 + tasklet->next = NULL;
3557 + tasklet->sync = 0;
3558 + tasklet->routine = (void (*)(void *))func;
3559 + tasklet->data = (void *)data;
3561 +#define tasklet_kill(tasklet) {do{} while(0);}
3563 +/* 2.4.x introduced del_timer_sync() */
3564 +#define del_timer_sync(timer) del_timer(timer)
3568 +#define netif_down(dev)
3570 +#endif /* SoftNet */
3572 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3))
3575 + * Emit code to initialise a tq_struct's routine and data pointers
3577 +#define PREPARE_TQUEUE(_tq, _routine, _data) \
3579 + (_tq)->routine = _routine; \
3580 + (_tq)->data = _data; \
3584 + * Emit code to initialise all of a tq_struct
3586 +#define INIT_TQUEUE(_tq, _routine, _data) \
3588 + INIT_LIST_HEAD(&(_tq)->list); \
3589 + (_tq)->sync = 0; \
3590 + PREPARE_TQUEUE((_tq), (_routine), (_data)); \
3595 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6))
3597 +/* Power management related routines */
3600 +pci_save_state(struct pci_dev *dev, u32 *buffer)
3604 + for (i = 0; i < 16; i++)
3605 + pci_read_config_dword(dev, i * 4,&buffer[i]);
3611 +pci_restore_state(struct pci_dev *dev, u32 *buffer)
3616 + for (i = 0; i < 16; i++)
3617 + pci_write_config_dword(dev,i * 4, buffer[i]);
3620 + * otherwise, write the context information we know from bootup.
3621 + * This works around a problem where warm-booting from Windows
3622 + * combined with a D3(hot)->D0 transition causes PCI config
3623 + * header data to be forgotten.
3626 + for (i = 0; i < 6; i ++)
3627 + pci_write_config_dword(dev,
3628 + PCI_BASE_ADDRESS_0 + (i * 4),
3629 + pci_resource_start(dev, i));
3630 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
3635 +#endif /* PCI power management */
3637 +/* Old cp0 access macros deprecated in 2.4.19 */
3638 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19))
3639 +#define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
3642 +/* Module refcount handled internally in 2.6.x */
3643 +#ifndef SET_MODULE_OWNER
3644 +#define SET_MODULE_OWNER(dev) do {} while (0)
3645 +#define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
3646 +#define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
3648 +#define OLD_MOD_INC_USE_COUNT do {} while (0)
3649 +#define OLD_MOD_DEC_USE_COUNT do {} while (0)
3652 +#ifndef SET_NETDEV_DEV
3653 +#define SET_NETDEV_DEV(net, pdev) do {} while (0)
3656 +#ifndef HAVE_FREE_NETDEV
3657 +#define free_netdev(dev) kfree(dev)
3660 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
3661 +/* struct packet_type redefined in 2.6.x */
3662 +#define af_packet_priv data
3665 +#endif /* _linuxver_h_ */
3666 diff -urN linux.old/arch/mips/bcm947xx/include/min_osl.h linux.dev/arch/mips/bcm947xx/include/min_osl.h
3667 --- linux.old/arch/mips/bcm947xx/include/min_osl.h 1970-01-01 01:00:00.000000000 +0100
3668 +++ linux.dev/arch/mips/bcm947xx/include/min_osl.h 2005-11-07 22:51:38.780726250 +0100
3671 + * HND Minimal OS Abstraction Layer.
3673 + * Copyright 2005, Broadcom Corporation
3674 + * All Rights Reserved.
3676 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3677 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3678 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3679 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3684 +#ifndef _min_osl_h_
3685 +#define _min_osl_h_
3687 +#include <typedefs.h>
3688 +#include <sbconfig.h>
3689 +#include <mipsinc.h>
3691 +/* Cache support */
3692 +extern void caches_on(void);
3693 +extern void blast_dcache(void);
3694 +extern void blast_icache(void);
3697 +extern void putc(int c);
3699 +/* lib functions */
3700 +extern int printf(const char *fmt, ...);
3701 +extern int sprintf(char *buf, const char *fmt, ...);
3702 +extern int strcmp(const char *s1, const char *s2);
3703 +extern int strncmp(const char *s1, const char *s2, uint n);
3704 +extern char *strcpy(char *dest, const char *src);
3705 +extern char *strncpy(char *dest, const char *src, uint n);
3706 +extern uint strlen(const char *s);
3707 +extern char *strchr(const char *str,int c);
3708 +extern char *strrchr(const char *str, int c);
3709 +extern char *strcat(char *d, const char *s);
3710 +extern void *memset(void *dest, int c, uint n);
3711 +extern void *memcpy(void *dest, const void *src, uint n);
3712 +extern int memcmp(const void *s1, const void *s2, uint n);
3713 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
3714 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
3715 +#define bzero(b, len) memset((b), '\0', (len))
3717 +/* assert & debugging */
3718 +#define ASSERT(exp) do {} while (0)
3720 +/* PCMCIA attribute space access macros */
3721 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
3723 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
3726 +/* PCI configuration space access macros */
3727 +#define OSL_PCI_READ_CONFIG(loc, offset, size) \
3728 + (offset == 8 ? 0 : 0xffffffff)
3729 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) \
3732 +/* PCI device bus # and slot # */
3733 +#define OSL_PCI_BUS(osh) (0)
3734 +#define OSL_PCI_SLOT(osh) (0)
3736 +/* register access macros */
3737 +#define wreg32(r, v) (*(volatile uint32*)(r) = (uint32)(v))
3738 +#define rreg32(r) (*(volatile uint32*)(r))
3739 +#define wreg16(r, v) (*(volatile uint16*)(r) = (uint16)(v))
3740 +#define rreg16(r) (*(volatile uint16*)(r))
3741 +#define wreg8(r, v) (*(volatile uint8*)(r) = (uint8)(v))
3742 +#define rreg8(r) (*(volatile uint8*)(r))
3743 +#define R_REG(r) ({ \
3744 + __typeof(*(r)) __osl_v; \
3745 + switch (sizeof(*(r))) { \
3746 + case sizeof(uint8): __osl_v = rreg8((r)); break; \
3747 + case sizeof(uint16): __osl_v = rreg16((r)); break; \
3748 + case sizeof(uint32): __osl_v = rreg32((r)); break; \
3752 +#define W_REG(r, v) do { \
3753 + switch (sizeof(*(r))) { \
3754 + case sizeof(uint8): wreg8((r), (v)); break; \
3755 + case sizeof(uint16): wreg16((r), (v)); break; \
3756 + case sizeof(uint32): wreg32((r), (v)); break; \
3759 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3760 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3762 +/* general purpose memory allocation */
3763 +#define MALLOC(osh, size) malloc(size)
3764 +#define MFREE(osh, addr, size) free(addr)
3765 +#define MALLOCED(osh) 0
3766 +#define MALLOC_FAILED(osh) 0
3767 +#define MALLOC_DUMP(osh, buf, sz)
3768 +extern int free(void *ptr);
3769 +extern void *malloc(uint size);
3771 +/* uncached virtual address */
3772 +#define OSL_UNCACHED(va) ((void*)KSEG1ADDR((ulong)(va)))
3774 +/* host/bus architecture-specific address byte swap */
3775 +#define BUS_SWAP32(v) (v)
3777 +/* microsecond delay */
3778 +#define OSL_DELAY(usec) udelay(usec)
3779 +extern void udelay(uint32 usec);
3781 +/* map/unmap physical to virtual I/O */
3782 +#define REG_MAP(pa, size) ((void*)KSEG1ADDR((ulong)(pa)))
3783 +#define REG_UNMAP(va) do {} while (0)
3785 +/* dereference an address that may cause a bus exception */
3786 +#define BUSPROBE(val, addr) (uint32 *)(addr) = (val)
3789 +#define osl_attach(pdev) ((osl_t*)pdev)
3790 +#define osl_detach(osh)
3791 +extern void *osl_init(void);
3792 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
3793 +extern int osl_error(int);
3795 +#endif /* _min_osl_h_ */
3796 diff -urN linux.old/arch/mips/bcm947xx/include/mipsinc.h linux.dev/arch/mips/bcm947xx/include/mipsinc.h
3797 --- linux.old/arch/mips/bcm947xx/include/mipsinc.h 1970-01-01 01:00:00.000000000 +0100
3798 +++ linux.dev/arch/mips/bcm947xx/include/mipsinc.h 2005-11-07 22:51:38.780726250 +0100
3801 + * HND Run Time Environment for standalone MIPS programs.
3803 + * Copyright 2005, Broadcom Corporation
3804 + * All Rights Reserved.
3806 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3807 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3808 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3809 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3820 +#ifdef _LANGUAGE_ASSEMBLY
3823 + * Symbolic register names for 32 bit ABI
3825 +#define zero $0 /* wired zero */
3826 +#define AT $1 /* assembler temp - uppercase because of ".set at" */
3827 +#define v0 $2 /* return value */
3829 +#define a0 $4 /* argument registers */
3833 +#define t0 $8 /* caller saved */
3841 +#define s0 $16 /* callee saved */
3849 +#define t8 $24 /* caller saved */
3851 +#define jp $25 /* PIC jump register */
3852 +#define k0 $26 /* kernel scratch */
3854 +#define gp $28 /* global pointer */
3855 +#define sp $29 /* stack pointer */
3856 +#define fp $30 /* frame pointer */
3857 +#define s8 $30 /* same like fp! */
3858 +#define ra $31 /* return address */
3867 +#define C0_TLBLO0 $2
3868 +#define C0_TLBLO C0_TLBLO0
3869 +#define C0_TLBLO1 $3
3870 +#define C0_CTEXT $4
3871 +#define C0_PGMASK $5
3872 +#define C0_WIRED $6
3873 +#define C0_BADVADDR $8
3874 +#define C0_COUNT $9
3875 +#define C0_TLBHI $10
3876 +#define C0_COMPARE $11
3878 +#define C0_STATUS C0_SR
3879 +#define C0_CAUSE $13
3881 +#define C0_PRID $15
3882 +#define C0_CONFIG $16
3883 +#define C0_LLADDR $17
3884 +#define C0_WATCHLO $18
3885 +#define C0_WATCHHI $19
3886 +#define C0_XCTEXT $20
3887 +#define C0_DIAGNOSTIC $22
3888 +#define C0_BROADCOM C0_DIAGNOSTIC
3889 +#define C0_PERFORMANCE $25
3891 +#define C0_CACHEERR $27
3892 +#define C0_TAGLO $28
3893 +#define C0_TAGHI $29
3894 +#define C0_ERREPC $30
3895 +#define C0_DESAVE $31
3898 + * LEAF - declare leaf routine
3900 +#define LEAF(symbol) \
3903 + .type symbol,@function; \
3905 +symbol: .frame sp,0,ra
3908 + * END - mark end of function
3910 +#define END(function) \
3912 + .size function,.-function
3919 + * The following macros are especially useful for __asm__
3920 + * inline assembler.
3923 +#define __STR(x) #x
3926 +#define STR(x) __STR(x)
3929 +#define _ULCAST_ (unsigned long)
3936 +#define C0_INX 0 /* CP0: TLB Index */
3937 +#define C0_RAND 1 /* CP0: TLB Random */
3938 +#define C0_TLBLO0 2 /* CP0: TLB EntryLo0 */
3939 +#define C0_TLBLO C0_TLBLO0 /* CP0: TLB EntryLo0 */
3940 +#define C0_TLBLO1 3 /* CP0: TLB EntryLo1 */
3941 +#define C0_CTEXT 4 /* CP0: Context */
3942 +#define C0_PGMASK 5 /* CP0: TLB PageMask */
3943 +#define C0_WIRED 6 /* CP0: TLB Wired */
3944 +#define C0_BADVADDR 8 /* CP0: Bad Virtual Address */
3945 +#define C0_COUNT 9 /* CP0: Count */
3946 +#define C0_TLBHI 10 /* CP0: TLB EntryHi */
3947 +#define C0_COMPARE 11 /* CP0: Compare */
3948 +#define C0_SR 12 /* CP0: Processor Status */
3949 +#define C0_STATUS C0_SR /* CP0: Processor Status */
3950 +#define C0_CAUSE 13 /* CP0: Exception Cause */
3951 +#define C0_EPC 14 /* CP0: Exception PC */
3952 +#define C0_PRID 15 /* CP0: Processor Revision Indentifier */
3953 +#define C0_CONFIG 16 /* CP0: Config */
3954 +#define C0_LLADDR 17 /* CP0: LLAddr */
3955 +#define C0_WATCHLO 18 /* CP0: WatchpointLo */
3956 +#define C0_WATCHHI 19 /* CP0: WatchpointHi */
3957 +#define C0_XCTEXT 20 /* CP0: XContext */
3958 +#define C0_DIAGNOSTIC 22 /* CP0: Diagnostic */
3959 +#define C0_BROADCOM C0_DIAGNOSTIC /* CP0: Broadcom Register */
3960 +#define C0_PERFORMANCE 25 /* CP0: Performance Counter/Control Registers */
3961 +#define C0_ECC 26 /* CP0: ECC */
3962 +#define C0_CACHEERR 27 /* CP0: CacheErr */
3963 +#define C0_TAGLO 28 /* CP0: TagLo */
3964 +#define C0_TAGHI 29 /* CP0: TagHi */
3965 +#define C0_ERREPC 30 /* CP0: ErrorEPC */
3966 +#define C0_DESAVE 31 /* CP0: DebugSave */
3968 +#endif /* _LANGUAGE_ASSEMBLY */
3971 + * Memory segments (32bit kernel mode addresses)
3978 +#define KUSEG 0x00000000
3979 +#define KSEG0 0x80000000
3980 +#define KSEG1 0xa0000000
3981 +#define KSEG2 0xc0000000
3982 +#define KSEG3 0xe0000000
3983 +#define PHYSADDR_MASK 0x1fffffff
3986 + * Map an address to a certain kernel segment
3994 +#define PHYSADDR(a) (_ULCAST_(a) & PHYSADDR_MASK)
3995 +#define KSEG0ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG0)
3996 +#define KSEG1ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG1)
3997 +#define KSEG2ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG2)
3998 +#define KSEG3ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG3)
4001 +#ifndef Index_Invalidate_I
4003 + * Cache Operations
4005 +#define Index_Invalidate_I 0x00
4006 +#define Index_Writeback_Inv_D 0x01
4007 +#define Index_Invalidate_SI 0x02
4008 +#define Index_Writeback_Inv_SD 0x03
4009 +#define Index_Load_Tag_I 0x04
4010 +#define Index_Load_Tag_D 0x05
4011 +#define Index_Load_Tag_SI 0x06
4012 +#define Index_Load_Tag_SD 0x07
4013 +#define Index_Store_Tag_I 0x08
4014 +#define Index_Store_Tag_D 0x09
4015 +#define Index_Store_Tag_SI 0x0A
4016 +#define Index_Store_Tag_SD 0x0B
4017 +#define Create_Dirty_Excl_D 0x0d
4018 +#define Create_Dirty_Excl_SD 0x0f
4019 +#define Hit_Invalidate_I 0x10
4020 +#define Hit_Invalidate_D 0x11
4021 +#define Hit_Invalidate_SI 0x12
4022 +#define Hit_Invalidate_SD 0x13
4023 +#define Fill_I 0x14
4024 +#define Hit_Writeback_Inv_D 0x15
4025 + /* 0x16 is unused */
4026 +#define Hit_Writeback_Inv_SD 0x17
4027 +#define R5K_Page_Invalidate_S 0x17
4028 +#define Hit_Writeback_I 0x18
4029 +#define Hit_Writeback_D 0x19
4030 + /* 0x1a is unused */
4031 +#define Hit_Writeback_SD 0x1b
4032 + /* 0x1c is unused */
4033 + /* 0x1e is unused */
4034 +#define Hit_Set_Virtual_SI 0x1e
4035 +#define Hit_Set_Virtual_SD 0x1f
4040 + * R4x00 interrupt enable / cause bits
4042 +#define IE_SW0 (_ULCAST_(1) << 8)
4043 +#define IE_SW1 (_ULCAST_(1) << 9)
4044 +#define IE_IRQ0 (_ULCAST_(1) << 10)
4045 +#define IE_IRQ1 (_ULCAST_(1) << 11)
4046 +#define IE_IRQ2 (_ULCAST_(1) << 12)
4047 +#define IE_IRQ3 (_ULCAST_(1) << 13)
4048 +#define IE_IRQ4 (_ULCAST_(1) << 14)
4049 +#define IE_IRQ5 (_ULCAST_(1) << 15)
4053 + * Bitfields in the mips32 cp0 status register
4055 +#define ST0_IE 0x00000001
4056 +#define ST0_EXL 0x00000002
4057 +#define ST0_ERL 0x00000004
4058 +#define ST0_UM 0x00000010
4059 +#define ST0_SWINT0 0x00000100
4060 +#define ST0_SWINT1 0x00000200
4061 +#define ST0_HWINT0 0x00000400
4062 +#define ST0_HWINT1 0x00000800
4063 +#define ST0_HWINT2 0x00001000
4064 +#define ST0_HWINT3 0x00002000
4065 +#define ST0_HWINT4 0x00004000
4066 +#define ST0_HWINT5 0x00008000
4067 +#define ST0_IM 0x0000ff00
4068 +#define ST0_NMI 0x00080000
4069 +#define ST0_SR 0x00100000
4070 +#define ST0_TS 0x00200000
4071 +#define ST0_BEV 0x00400000
4072 +#define ST0_RE 0x02000000
4073 +#define ST0_RP 0x08000000
4074 +#define ST0_CU 0xf0000000
4075 +#define ST0_CU0 0x10000000
4076 +#define ST0_CU1 0x20000000
4077 +#define ST0_CU2 0x40000000
4078 +#define ST0_CU3 0x80000000
4083 + * Bitfields in the mips32 cp0 cause register
4085 +#define C_EXC 0x0000007c
4086 +#define C_EXC_SHIFT 2
4087 +#define C_INT 0x0000ff00
4088 +#define C_INT_SHIFT 8
4089 +#define C_SW0 (_ULCAST_(1) << 8)
4090 +#define C_SW1 (_ULCAST_(1) << 9)
4091 +#define C_IRQ0 (_ULCAST_(1) << 10)
4092 +#define C_IRQ1 (_ULCAST_(1) << 11)
4093 +#define C_IRQ2 (_ULCAST_(1) << 12)
4094 +#define C_IRQ3 (_ULCAST_(1) << 13)
4095 +#define C_IRQ4 (_ULCAST_(1) << 14)
4096 +#define C_IRQ5 (_ULCAST_(1) << 15)
4097 +#define C_WP 0x00400000
4098 +#define C_IV 0x00800000
4099 +#define C_CE 0x30000000
4100 +#define C_CE_SHIFT 28
4101 +#define C_BD 0x80000000
4103 +/* Values in C_EXC */
4118 +#define EXC_WATCH 23
4119 +#define EXC_MCHK 24
4123 + * Bits in the cp0 config register.
4125 +#define CONF_CM_CACHABLE_NO_WA 0
4126 +#define CONF_CM_CACHABLE_WA 1
4127 +#define CONF_CM_UNCACHED 2
4128 +#define CONF_CM_CACHABLE_NONCOHERENT 3
4129 +#define CONF_CM_CACHABLE_CE 4
4130 +#define CONF_CM_CACHABLE_COW 5
4131 +#define CONF_CM_CACHABLE_CUW 6
4132 +#define CONF_CM_CACHABLE_ACCELERATED 7
4133 +#define CONF_CM_CMASK 7
4134 +#define CONF_CU (_ULCAST_(1) << 3)
4135 +#define CONF_DB (_ULCAST_(1) << 4)
4136 +#define CONF_IB (_ULCAST_(1) << 5)
4137 +#define CONF_SE (_ULCAST_(1) << 12)
4138 +#define CONF_SC (_ULCAST_(1) << 17)
4139 +#define CONF_AC (_ULCAST_(1) << 23)
4140 +#define CONF_HALT (_ULCAST_(1) << 25)
4144 + * Bits in the cp0 config register select 1.
4146 +#define CONF1_FP 0x00000001 /* FPU present */
4147 +#define CONF1_EP 0x00000002 /* EJTAG present */
4148 +#define CONF1_CA 0x00000004 /* mips16 implemented */
4149 +#define CONF1_WR 0x00000008 /* Watch registers present */
4150 +#define CONF1_PC 0x00000010 /* Performance counters present */
4151 +#define CONF1_DA_SHIFT 7 /* D$ associativity */
4152 +#define CONF1_DA_MASK 0x00000380
4153 +#define CONF1_DA_BASE 1
4154 +#define CONF1_DL_SHIFT 10 /* D$ line size */
4155 +#define CONF1_DL_MASK 0x00001c00
4156 +#define CONF1_DL_BASE 2
4157 +#define CONF1_DS_SHIFT 13 /* D$ sets/way */
4158 +#define CONF1_DS_MASK 0x0000e000
4159 +#define CONF1_DS_BASE 64
4160 +#define CONF1_IA_SHIFT 16 /* I$ associativity */
4161 +#define CONF1_IA_MASK 0x00070000
4162 +#define CONF1_IA_BASE 1
4163 +#define CONF1_IL_SHIFT 19 /* I$ line size */
4164 +#define CONF1_IL_MASK 0x00380000
4165 +#define CONF1_IL_BASE 2
4166 +#define CONF1_IS_SHIFT 22 /* Instruction cache sets/way */
4167 +#define CONF1_IS_MASK 0x01c00000
4168 +#define CONF1_IS_BASE 64
4169 +#define CONF1_MS_MASK 0x7e000000 /* Number of tlb entries */
4170 +#define CONF1_MS_SHIFT 25
4172 +/* PRID register */
4173 +#define PRID_COPT_MASK 0xff000000
4174 +#define PRID_COMP_MASK 0x00ff0000
4175 +#define PRID_IMP_MASK 0x0000ff00
4176 +#define PRID_REV_MASK 0x000000ff
4178 +#define PRID_COMP_LEGACY 0x000000
4179 +#define PRID_COMP_MIPS 0x010000
4180 +#define PRID_COMP_BROADCOM 0x020000
4181 +#define PRID_COMP_ALCHEMY 0x030000
4182 +#define PRID_COMP_SIBYTE 0x040000
4183 +#define PRID_IMP_BCM4710 0x4000
4184 +#define PRID_IMP_BCM3302 0x9000
4185 +#define PRID_IMP_BCM3303 0x9100
4187 +#define PRID_IMP_UNKNOWN 0xff00
4189 +#define BCM330X(id) \
4190 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
4191 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
4193 +/* Bits in C0_BROADCOM */
4194 +#define BRCM_PFC_AVAIL 0x20000000 /* PFC is available */
4195 +#define BRCM_DC_ENABLE 0x40000000 /* Enable Data $ */
4196 +#define BRCM_IC_ENABLE 0x80000000 /* Enable Instruction $ */
4197 +#define BRCM_PFC_ENABLE 0x00400000 /* Obsolete? Enable PFC (at least on 4310) */
4199 +/* PreFetch Cache aka Read Ahead Cache */
4201 +#define PFC_CR0 0xff400000 /* control reg 0 */
4202 +#define PFC_CR1 0xff400004 /* control reg 1 */
4204 +/* PFC operations */
4205 +#define PFC_I 0x00000001 /* Enable PFC use for instructions */
4206 +#define PFC_D 0x00000002 /* Enable PFC use for data */
4207 +#define PFC_PFI 0x00000004 /* Enable seq. prefetch for instructions */
4208 +#define PFC_PFD 0x00000008 /* Enable seq. prefetch for data */
4209 +#define PFC_CINV 0x00000010 /* Enable selective (i/d) cacheop flushing */
4210 +#define PFC_NCH 0x00000020 /* Disable flushing based on cacheops */
4211 +#define PFC_DPF 0x00000040 /* Enable directional prefetching */
4212 +#define PFC_FLUSH 0x00000100 /* Flush the PFC */
4213 +#define PFC_BRR 0x40000000 /* Bus error indication */
4214 +#define PFC_PWR 0x80000000 /* Disable power saving (clock gating) */
4216 +/* Handy defaults */
4217 +#define PFC_DISABLED 0
4218 +#define PFC_AUTO 0xffffffff /* auto select the default mode */
4219 +#define PFC_INST (PFC_I | PFC_PFI | PFC_CINV)
4220 +#define PFC_INST_NOPF (PFC_I | PFC_CINV)
4221 +#define PFC_DATA (PFC_D | PFC_PFD | PFC_CINV)
4222 +#define PFC_DATA_NOPF (PFC_D | PFC_CINV)
4223 +#define PFC_I_AND_D (PFC_INST | PFC_DATA)
4224 +#define PFC_I_AND_D_NOPF (PFC_INST_NOPF | PFC_DATA_NOPF)
4228 + * These are the UART port assignments, expressed as offsets from the base
4229 + * register. These assignments should hold for any serial port based on
4230 + * a 8250, 16450, or 16550(A).
4233 +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */
4234 +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
4235 +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
4236 +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */
4237 +#define UART_LCR 3 /* Out: Line Control Register */
4238 +#define UART_MCR 4 /* Out: Modem Control Register */
4239 +#define UART_LSR 5 /* In: Line Status Register */
4240 +#define UART_MSR 6 /* In: Modem Status Register */
4241 +#define UART_SCR 7 /* I/O: Scratch Register */
4242 +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
4243 +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
4244 +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
4245 +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
4246 +#define UART_LSR_RXRDY 0x01 /* Receiver ready */
4249 +#ifndef _LANGUAGE_ASSEMBLY
4252 + * Macros to access the system control coprocessor
4255 +#define MFC0(source, sel) \
4258 + __asm__ __volatile__( \
4259 + ".set\tnoreorder\n\t" \
4260 + ".set\tnoat\n\t" \
4261 + ".word\t"STR(0x40010000 | ((source)<<11) | (sel))"\n\t" \
4262 + "move\t%0,$1\n\t" \
4271 +#define MTC0(source, sel, value) \
4273 + __asm__ __volatile__( \
4274 + ".set\tnoreorder\n\t" \
4275 + ".set\tnoat\n\t" \
4276 + "move\t$1,%z0\n\t" \
4277 + ".word\t"STR(0x40810000 | ((source)<<11) | (sel))"\n\t" \
4285 +#define get_c0_count() \
4288 + __asm__ __volatile__( \
4289 + ".set\tnoreorder\n\t" \
4290 + ".set\tnoat\n\t" \
4291 + "mfc0\t%0,$9\n\t" \
4298 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize)
4300 + uint lsz, sets, ways;
4302 + /* Instruction Cache Size = Associativity * Line Size * Sets Per Way */
4303 + if ((lsz = ((config1 & CONF1_IL_MASK) >> CONF1_IL_SHIFT)))
4304 + lsz = CONF1_IL_BASE << lsz;
4305 + sets = CONF1_IS_BASE << ((config1 & CONF1_IS_MASK) >> CONF1_IS_SHIFT);
4306 + ways = CONF1_IA_BASE + ((config1 & CONF1_IA_MASK) >> CONF1_IA_SHIFT);
4307 + *size = lsz * sets * ways;
4311 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize)
4313 + uint lsz, sets, ways;
4315 + /* Data Cache Size = Associativity * Line Size * Sets Per Way */
4316 + if ((lsz = ((config1 & CONF1_DL_MASK) >> CONF1_DL_SHIFT)))
4317 + lsz = CONF1_DL_BASE << lsz;
4318 + sets = CONF1_DS_BASE << ((config1 & CONF1_DS_MASK) >> CONF1_DS_SHIFT);
4319 + ways = CONF1_DA_BASE + ((config1 & CONF1_DA_MASK) >> CONF1_DA_SHIFT);
4320 + *size = lsz * sets * ways;
4324 +#define cache_op(base, op) \
4325 + __asm__ __volatile__(" \
4335 +#define cache_unroll4(base, delta, op) \
4336 + __asm__ __volatile__(" \
4340 + cache %1,delta(%0); \
4341 + cache %1,(2 * delta)(%0); \
4342 + cache %1,(3 * delta)(%0); \
4349 +#endif /* !_LANGUAGE_ASSEMBLY */
4351 +#endif /* _MISPINC_H */
4352 diff -urN linux.old/arch/mips/bcm947xx/include/nvports.h linux.dev/arch/mips/bcm947xx/include/nvports.h
4353 --- linux.old/arch/mips/bcm947xx/include/nvports.h 1970-01-01 01:00:00.000000000 +0100
4354 +++ linux.dev/arch/mips/bcm947xx/include/nvports.h 2005-11-07 21:57:07.865587000 +0100
4357 + * BCM53xx RoboSwitch utility functions
4359 + * Copyright (C) 2002 Broadcom Corporation
4363 +#ifndef _nvports_h_
4364 +#define _nvports_h_
4366 +#define uint32 unsigned long
4367 +#define uint16 unsigned short
4368 +#define uint unsigned int
4369 +#define uint8 unsigned char
4370 +#define uint64 unsigned long long
4382 +typedef struct _PORT_ATTRIBS
4390 +nvExistsPortAttrib(char *attrib, uint portno);
4393 +nvExistsAnyForcePortAttrib(uint portno);
4396 +nvSetPortAttrib(char *attrib, uint portno);
4399 +nvUnsetPortAttrib(char *attrib, uint portno);
4402 +nvUnsetAllForcePortAttrib(uint portno);
4404 +extern PORT_ATTRIBS
4405 +nvGetSwitchPortAttribs(uint portno);
4407 +#endif /* _nvports_h_ */
4411 diff -urN linux.old/arch/mips/bcm947xx/include/osl.h linux.dev/arch/mips/bcm947xx/include/osl.h
4412 --- linux.old/arch/mips/bcm947xx/include/osl.h 1970-01-01 01:00:00.000000000 +0100
4413 +++ linux.dev/arch/mips/bcm947xx/include/osl.h 2005-11-07 22:51:38.780726250 +0100
4416 + * OS Abstraction Layer
4418 + * Copyright 2005, Broadcom Corporation
4419 + * All Rights Reserved.
4421 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4422 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4423 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4424 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4431 +/* osl handle type forward declaration */
4432 +typedef struct os_handle osl_t;
4435 +#include <linux_osl.h>
4436 +#elif defined(NDIS)
4437 +#include <ndis_osl.h>
4438 +#elif defined(_CFE_)
4439 +#include <cfe_osl.h>
4440 +#elif defined(_HNDRTE_)
4441 +#include <hndrte_osl.h>
4442 +#elif defined(_MINOSL_)
4443 +#include <min_osl.h>
4445 +#include <pmon_osl.h>
4446 +#elif defined(MACOSX)
4447 +#include <macosx_osl.h>
4449 +#error "Unsupported OSL requested"
4453 +#define SET_REG(r, mask, val) W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
4454 +#define MAXPRIO 7 /* 0-7 */
4456 +#endif /* _osl_h_ */
4457 diff -urN linux.old/arch/mips/bcm947xx/include/pcicfg.h linux.dev/arch/mips/bcm947xx/include/pcicfg.h
4458 --- linux.old/arch/mips/bcm947xx/include/pcicfg.h 1970-01-01 01:00:00.000000000 +0100
4459 +++ linux.dev/arch/mips/bcm947xx/include/pcicfg.h 2005-11-07 22:51:38.780726250 +0100
4462 + * pcicfg.h: PCI configuration constants and structures.
4464 + * Copyright 2005, Broadcom Corporation
4465 + * All Rights Reserved.
4467 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4468 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4469 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4470 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4478 +/* The following inside ifndef's so we don't collide with NTDDK.H */
4479 +#ifndef PCI_MAX_BUS
4480 +#define PCI_MAX_BUS 0x100
4482 +#ifndef PCI_MAX_DEVICES
4483 +#define PCI_MAX_DEVICES 0x20
4485 +#ifndef PCI_MAX_FUNCTION
4486 +#define PCI_MAX_FUNCTION 0x8
4489 +#ifndef PCI_INVALID_VENDORID
4490 +#define PCI_INVALID_VENDORID 0xffff
4492 +#ifndef PCI_INVALID_DEVICEID
4493 +#define PCI_INVALID_DEVICEID 0xffff
4497 +/* Convert between bus-slot-function-register and config addresses */
4499 +#define PCICFG_BUS_SHIFT 16 /* Bus shift */
4500 +#define PCICFG_SLOT_SHIFT 11 /* Slot shift */
4501 +#define PCICFG_FUN_SHIFT 8 /* Function shift */
4502 +#define PCICFG_OFF_SHIFT 0 /* Register shift */
4504 +#define PCICFG_BUS_MASK 0xff /* Bus mask */
4505 +#define PCICFG_SLOT_MASK 0x1f /* Slot mask */
4506 +#define PCICFG_FUN_MASK 7 /* Function mask */
4507 +#define PCICFG_OFF_MASK 0xff /* Bus mask */
4509 +#define PCI_CONFIG_ADDR(b, s, f, o) \
4510 + ((((b) & PCICFG_BUS_MASK) << PCICFG_BUS_SHIFT) \
4511 + | (((s) & PCICFG_SLOT_MASK) << PCICFG_SLOT_SHIFT) \
4512 + | (((f) & PCICFG_FUN_MASK) << PCICFG_FUN_SHIFT) \
4513 + | (((o) & PCICFG_OFF_MASK) << PCICFG_OFF_SHIFT))
4515 +#define PCI_CONFIG_BUS(a) (((a) >> PCICFG_BUS_SHIFT) & PCICFG_BUS_MASK)
4516 +#define PCI_CONFIG_SLOT(a) (((a) >> PCICFG_SLOT_SHIFT) & PCICFG_SLOT_MASK)
4517 +#define PCI_CONFIG_FUN(a) (((a) >> PCICFG_FUN_SHIFT) & PCICFG_FUN_MASK)
4518 +#define PCI_CONFIG_OFF(a) (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK)
4520 +/* PCIE Config space accessing MACROS*/
4522 +#define PCIECFG_BUS_SHIFT 24 /* Bus shift */
4523 +#define PCIECFG_SLOT_SHIFT 19 /* Slot/Device shift */
4524 +#define PCIECFG_FUN_SHIFT 16 /* Function shift */
4525 +#define PCIECFG_OFF_SHIFT 0 /* Register shift */
4527 +#define PCIECFG_BUS_MASK 0xff /* Bus mask */
4528 +#define PCIECFG_SLOT_MASK 0x1f /* Slot/Device mask */
4529 +#define PCIECFG_FUN_MASK 7 /* Function mask */
4530 +#define PCIECFG_OFF_MASK 0x3ff /* Register mask */
4532 +#define PCIE_CONFIG_ADDR(b, s, f, o) \
4533 + ((((b) & PCIECFG_BUS_MASK) << PCIECFG_BUS_SHIFT) \
4534 + | (((s) & PCIECFG_SLOT_MASK) << PCIECFG_SLOT_SHIFT) \
4535 + | (((f) & PCIECFG_FUN_MASK) << PCIECFG_FUN_SHIFT) \
4536 + | (((o) & PCIECFG_OFF_MASK) << PCIECFG_OFF_SHIFT))
4538 +#define PCIE_CONFIG_BUS(a) (((a) >> PCIECFG_BUS_SHIFT) & PCIECFG_BUS_MASK)
4539 +#define PCIE_CONFIG_SLOT(a) (((a) >> PCIECFG_SLOT_SHIFT) & PCIECFG_SLOT_MASK)
4540 +#define PCIE_CONFIG_FUN(a) (((a) >> PCIECFG_FUN_SHIFT) & PCIECFG_FUN_MASK)
4541 +#define PCIE_CONFIG_OFF(a) (((a) >> PCIECFG_OFF_SHIFT) & PCIECFG_OFF_MASK)
4544 +/* The actual config space */
4546 +#define PCI_BAR_MAX 6
4548 +#define PCI_ROM_BAR 8
4550 +#define PCR_RSVDA_MAX 2
4552 +/* pci config status reg has a bit to indicate that capability ptr is present*/
4554 +#define PCI_CAPPTR_PRESENT 0x0010
4556 +typedef struct _pci_config_regs {
4557 + unsigned short vendor;
4558 + unsigned short device;
4559 + unsigned short command;
4560 + unsigned short status;
4561 + unsigned char rev_id;
4562 + unsigned char prog_if;
4563 + unsigned char sub_class;
4564 + unsigned char base_class;
4565 + unsigned char cache_line_size;
4566 + unsigned char latency_timer;
4567 + unsigned char header_type;
4568 + unsigned char bist;
4569 + unsigned long base[PCI_BAR_MAX];
4570 + unsigned long cardbus_cis;
4571 + unsigned short subsys_vendor;
4572 + unsigned short subsys_id;
4573 + unsigned long baserom;
4574 + unsigned long rsvd_a[PCR_RSVDA_MAX];
4575 + unsigned char int_line;
4576 + unsigned char int_pin;
4577 + unsigned char min_gnt;
4578 + unsigned char max_lat;
4579 + unsigned char dev_dep[192];
4582 +#define SZPCR (sizeof (pci_config_regs))
4583 +#define MINSZPCR 64 /* offsetof (dev_dep[0] */
4585 +/* A structure for the config registers is nice, but in most
4586 + * systems the config space is not memory mapped, so we need
4587 + * filed offsetts. :-(
4589 +#define PCI_CFG_VID 0
4590 +#define PCI_CFG_DID 2
4591 +#define PCI_CFG_CMD 4
4592 +#define PCI_CFG_STAT 6
4593 +#define PCI_CFG_REV 8
4594 +#define PCI_CFG_PROGIF 9
4595 +#define PCI_CFG_SUBCL 0xa
4596 +#define PCI_CFG_BASECL 0xb
4597 +#define PCI_CFG_CLSZ 0xc
4598 +#define PCI_CFG_LATTIM 0xd
4599 +#define PCI_CFG_HDR 0xe
4600 +#define PCI_CFG_BIST 0xf
4601 +#define PCI_CFG_BAR0 0x10
4602 +#define PCI_CFG_BAR1 0x14
4603 +#define PCI_CFG_BAR2 0x18
4604 +#define PCI_CFG_BAR3 0x1c
4605 +#define PCI_CFG_BAR4 0x20
4606 +#define PCI_CFG_BAR5 0x24
4607 +#define PCI_CFG_CIS 0x28
4608 +#define PCI_CFG_SVID 0x2c
4609 +#define PCI_CFG_SSID 0x2e
4610 +#define PCI_CFG_ROMBAR 0x30
4611 +#define PCI_CFG_CAPPTR 0x34
4612 +#define PCI_CFG_INT 0x3c
4613 +#define PCI_CFG_PIN 0x3d
4614 +#define PCI_CFG_MINGNT 0x3e
4615 +#define PCI_CFG_MAXLAT 0x3f
4617 +/* Classes and subclasses */
4620 + PCI_CLASS_OLD = 0,
4623 + PCI_CLASS_DISPLAY,
4633 + PCI_CLASS_INTELLIGENT = 0xe,
4634 + PCI_CLASS_SATELLITE,
4646 + PCI_DASDI_OTHER = 0x80
4647 +} pci_dasdi_subclasses;
4654 + PCI_NET_OTHER = 0x80
4655 +} pci_net_subclasses;
4661 + PCI_DISPLAY_OTHER = 0x80
4662 +} pci_display_subclasses;
4668 + PCI_MEDIA_OTHER = 0x80
4669 +} pci_mmedia_subclasses;
4674 + PCI_MEMORY_OTHER = 0x80
4675 +} pci_memory_subclasses;
4683 + PCI_BRIDGE_PCMCIA,
4685 + PCI_BRIDGE_CARDBUS,
4686 + PCI_BRIDGE_RACEWAY,
4687 + PCI_BRIDGE_OTHER = 0x80
4688 +} pci_bridge_subclasses;
4692 + PCI_COMM_PARALLEL,
4693 + PCI_COMM_MULTIUART,
4695 + PCI_COMM_OTHER = 0x80
4696 +} pci_comm_subclasses;
4703 + PCI_BASE_PCI_HOTPLUG,
4704 + PCI_BASE_OTHER = 0x80
4705 +} pci_base_subclasses;
4711 + PCI_INPUT_SCANNER,
4712 + PCI_INPUT_GAMEPORT,
4713 + PCI_INPUT_OTHER = 0x80
4714 +} pci_input_subclasses;
4718 + PCI_DOCK_OTHER = 0x80
4719 +} pci_dock_subclasses;
4725 + PCI_CPU_ALPHA = 0x10,
4726 + PCI_CPU_POWERPC = 0x20,
4727 + PCI_CPU_MIPS = 0x30,
4728 + PCI_CPU_COPROC = 0x40,
4729 + PCI_CPU_OTHER = 0x80
4730 +} pci_cpu_subclasses;
4733 + PCI_SERIAL_IEEE1394,
4734 + PCI_SERIAL_ACCESS,
4739 + PCI_SERIAL_OTHER = 0x80
4740 +} pci_serial_subclasses;
4743 + PCI_INTELLIGENT_I2O,
4744 +} pci_intelligent_subclasses;
4748 + PCI_SATELLITE_AUDIO,
4749 + PCI_SATELLITE_VOICE,
4750 + PCI_SATELLITE_DATA,
4751 + PCI_SATELLITE_OTHER = 0x80
4752 +} pci_satellite_subclasses;
4755 + PCI_CRYPT_NETWORK,
4756 + PCI_CRYPT_ENTERTAINMENT,
4757 + PCI_CRYPT_OTHER = 0x80
4758 +} pci_crypt_subclasses;
4762 + PCI_DSP_OTHER = 0x80
4763 +} pci_dsp_subclasses;
4767 + PCI_HEADER_NORMAL,
4768 + PCI_HEADER_BRIDGE,
4769 + PCI_HEADER_CARDBUS
4770 +} pci_header_types;
4773 +/* Overlay for a PCI-to-PCI bridge */
4775 +#define PPB_RSVDA_MAX 2
4776 +#define PPB_RSVDD_MAX 8
4778 +typedef struct _ppb_config_regs {
4779 + unsigned short vendor;
4780 + unsigned short device;
4781 + unsigned short command;
4782 + unsigned short status;
4783 + unsigned char rev_id;
4784 + unsigned char prog_if;
4785 + unsigned char sub_class;
4786 + unsigned char base_class;
4787 + unsigned char cache_line_size;
4788 + unsigned char latency_timer;
4789 + unsigned char header_type;
4790 + unsigned char bist;
4791 + unsigned long rsvd_a[PPB_RSVDA_MAX];
4792 + unsigned char prim_bus;
4793 + unsigned char sec_bus;
4794 + unsigned char sub_bus;
4795 + unsigned char sec_lat;
4796 + unsigned char io_base;
4797 + unsigned char io_lim;
4798 + unsigned short sec_status;
4799 + unsigned short mem_base;
4800 + unsigned short mem_lim;
4801 + unsigned short pf_mem_base;
4802 + unsigned short pf_mem_lim;
4803 + unsigned long pf_mem_base_hi;
4804 + unsigned long pf_mem_lim_hi;
4805 + unsigned short io_base_hi;
4806 + unsigned short io_lim_hi;
4807 + unsigned short subsys_vendor;
4808 + unsigned short subsys_id;
4809 + unsigned long rsvd_b;
4810 + unsigned char rsvd_c;
4811 + unsigned char int_pin;
4812 + unsigned short bridge_ctrl;
4813 + unsigned char chip_ctrl;
4814 + unsigned char diag_ctrl;
4815 + unsigned short arb_ctrl;
4816 + unsigned long rsvd_d[PPB_RSVDD_MAX];
4817 + unsigned char dev_dep[192];
4821 +/* PCI CAPABILITY DEFINES */
4822 +#define PCI_CAP_POWERMGMTCAP_ID 0x01
4823 +#define PCI_CAP_MSICAP_ID 0x05
4824 +#define PCI_CAP_PCIECAP_ID 0x10
4826 +/* Data structure to define the Message Signalled Interrupt facility
4827 + * Valid for PCI and PCIE configurations */
4828 +typedef struct _pciconfig_cap_msi {
4829 + unsigned char capID;
4830 + unsigned char nextptr;
4831 + unsigned short msgctrl;
4832 + unsigned int msgaddr;
4833 +} pciconfig_cap_msi;
4835 +/* Data structure to define the Power managment facility
4836 + * Valid for PCI and PCIE configurations */
4837 +typedef struct _pciconfig_cap_pwrmgmt {
4838 + unsigned char capID;
4839 + unsigned char nextptr;
4840 + unsigned short pme_cap;
4841 + unsigned short pme_sts_ctrl;
4842 + unsigned char pme_bridge_ext;
4843 + unsigned char data;
4844 +} pciconfig_cap_pwrmgmt;
4846 +/* Data structure to define the PCIE capability */
4847 +typedef struct _pciconfig_cap_pcie {
4848 + unsigned char capID;
4849 + unsigned char nextptr;
4850 + unsigned short pcie_cap;
4851 + unsigned int dev_cap;
4852 + unsigned short dev_ctrl;
4853 + unsigned short dev_status;
4854 + unsigned int link_cap;
4855 + unsigned short link_ctrl;
4856 + unsigned short link_status;
4857 +} pciconfig_cap_pcie;
4859 +/* PCIE Enhanced CAPABILITY DEFINES */
4860 +#define PCIE_EXTCFG_OFFSET 0x100
4861 +#define PCIE_ADVERRREP_CAPID 0x0001
4862 +#define PCIE_VC_CAPID 0x0002
4863 +#define PCIE_DEVSNUM_CAPID 0x0003
4864 +#define PCIE_PWRBUDGET_CAPID 0x0004
4866 +/* Header to define the PCIE specific capabilities in the extended config space */
4867 +typedef struct _pcie_enhanced_caphdr {
4868 + unsigned short capID;
4869 + unsigned short cap_ver : 4;
4870 + unsigned short next_ptr : 12;
4871 +} pcie_enhanced_caphdr;
4874 +/* Everything below is BRCM HND proprietary */
4876 +#define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */
4877 +#define PCI_BAR1_WIN 0x84 /* backplane addres space accessed by BAR1 */
4878 +#define PCI_SPROM_CONTROL 0x88 /* sprom property control */
4879 +#define PCI_BAR1_CONTROL 0x8c /* BAR1 region burst control */
4880 +#define PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */
4881 +#define PCI_INT_MASK 0x94 /* mask of PCI and other cores interrupts */
4882 +#define PCI_TO_SB_MB 0x98 /* signal backplane interrupts */
4883 +#define PCI_BACKPLANE_ADDR 0xA0 /* address an arbitrary location on the system backplane */
4884 +#define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address register */
4885 +#define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */
4886 +#define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */
4887 +#define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */
4889 +#define PCI_BAR0_SPROM_OFFSET (4 * 1024) /* bar0 + 4K accesses external sprom */
4890 +#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) /* bar0 + 6K accesses pci core registers */
4892 +/* PCI_INT_STATUS */
4893 +#define PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */
4896 +#define PCI_SBIM_SHIFT 8 /* backplane core interrupt mask bits offset */
4897 +#define PCI_SBIM_MASK 0xff00 /* backplane core interrupt mask */
4898 +#define PCI_SBIM_MASK_SERR 0x4 /* backplane SBErr interrupt mask */
4900 +/* PCI_SPROM_CONTROL */
4901 +#define SPROM_BLANK 0x04 /* indicating a blank sprom */
4902 +#define SPROM_WRITEEN 0x10 /* sprom write enable */
4903 +#define SPROM_BOOTROM_WE 0x20 /* external bootrom write enable */
4905 +#define SPROM_SIZE 256 /* sprom size in 16-bit */
4906 +#define SPROM_CRC_RANGE 64 /* crc cover range in 16-bit */
4908 +/* PCI_CFG_CMD_STAT */
4909 +#define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */
4912 diff -urN linux.old/arch/mips/bcm947xx/include/pmon_osl.h linux.dev/arch/mips/bcm947xx/include/pmon_osl.h
4913 --- linux.old/arch/mips/bcm947xx/include/pmon_osl.h 1970-01-01 01:00:00.000000000 +0100
4914 +++ linux.dev/arch/mips/bcm947xx/include/pmon_osl.h 2005-11-07 21:57:07.869587250 +0100
4917 + * MIPS PMON boot loader OS Abstraction Layer.
4919 + * Copyright 2005, Broadcom Corporation
4920 + * All Rights Reserved.
4922 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
4923 + * the contents of this file may not be disclosed to third parties, copied
4924 + * or duplicated in any form, in whole or in part, without the prior
4925 + * written permission of Broadcom Corporation.
4929 +#ifndef _pmon_osl_h_
4930 +#define _pmon_osl_h_
4932 +#include <typedefs.h>
4934 +#include <string.h>
4935 +#include <utypes.h>
4937 +extern int printf(char *fmt,...);
4938 +extern int sprintf(char *dst,char *fmt,...);
4940 +#define OSL_UNCACHED(va) phy2k1(log2phy((va)))
4941 +#define REG_MAP(pa, size) phy2k1((pa))
4942 +#define REG_UNMAP(va) /* nop */
4944 +/* Common macros */
4946 +#define BUSPROBE(val, addr) ((val) = *(addr))
4948 +#define ASSERT(exp)
4950 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) bzero(buf, size)
4951 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size)
4954 +#define OSL_PCI_READ_CONFIG(loc, offset, size) ((offset == 8)? 0: 0xffffffff)
4955 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) ASSERT(0)
4957 +#define wreg32(r,v) (*(volatile uint32 *)(r) = (v))
4958 +#define rreg32(r) (*(volatile uint32 *)(r))
4959 +#ifdef IL_BIGENDIAN
4960 +#define wreg16(r,v) (*(volatile uint16 *)((uint32)r^2) = (v))
4961 +#define rreg16(r) (*(volatile uint16 *)((uint32)r^2))
4963 +#define wreg16(r,v) (*(volatile uint16 *)(r) = (v))
4964 +#define rreg16(r) (*(volatile uint16 *)(r))
4967 +#include <memory.h>
4968 +#define bcopy(src, dst, len) memcpy(dst, src, len)
4969 +#define bcmp(b1, b2, len) memcmp(b1, b2, len)
4970 +#define bzero(b, len) memset(b, '\0', len)
4972 +/* register access macros */
4973 +#define R_REG(r) ((sizeof *(r) == sizeof (uint32))? rreg32(r): rreg16(r))
4974 +#define W_REG(r,v) ((sizeof *(r) == sizeof (uint32))? wreg32(r,(uint32)v): wreg16(r,(uint16)v))
4975 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
4976 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
4978 +#define R_SM(r) *(r)
4979 +#define W_SM(r, v) (*(r) = (v))
4980 +#define BZERO_SM(r, len) memset(r, '\0', len)
4982 +/* Host/Bus architecture specific swap. Noop for little endian systems, possible swap on big endian */
4983 +#define BUS_SWAP32(v) (v)
4985 +#define OSL_DELAY(usec) delay_us(usec)
4986 +extern void delay_us(uint usec);
4988 +#define OSL_GETCYCLES(x) ((x) = 0)
4990 +#define osl_attach(pdev) (pdev)
4991 +#define osl_detach(osh)
4993 +#define MALLOC(osh, size) malloc(size)
4994 +#define MFREE(osh, addr, size) free(addr)
4995 +#define MALLOCED(osh) (0)
4996 +#define MALLOC_DUMP(osh, buf, sz)
4997 +#define MALLOC_FAILED(osh)
4998 +extern void *malloc();
4999 +extern void free(void *addr);
5001 +#define DMA_CONSISTENT_ALIGN sizeof (int)
5002 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) et_dma_alloc_consistent(osh, size, pap)
5003 +#define DMA_FREE_CONSISTENT(osh, va, size, pa)
5004 +extern void* et_dma_alloc_consistent(void *osh, uint size, ulong *pap);
5008 +#define DMA_MAP(osh, va, size, direction, p) osl_dma_map(osh, (void*)va, size, direction)
5009 +#define DMA_UNMAP(osh, pa, size, direction, p) /* nop */
5010 +extern void* osl_dma_map(void *osh, void *va, uint size, uint direction);
5013 + struct lbuf *next; /* pointer to next lbuf on freelist */
5014 + uchar *buf; /* pointer to buffer */
5015 + uint len; /* nbytes of data */
5018 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
5019 +#define PKTBUFSZ 2048
5021 +/* packet primitives */
5022 +#define PKTGET(drv, len, send) et_pktget(drv, len, send)
5023 +#define PKTFREE(drv, lb, send) et_pktfree(drv, (struct lbuf*)lb, send)
5024 +#define PKTDATA(drv, lb) ((uchar*)OSL_UNCACHED(((struct lbuf*)lb)->buf))
5025 +#define PKTLEN(drv, lb) ((struct lbuf*)lb)->len
5026 +#define PKTHEADROOM(drv, lb) (0)
5027 +#define PKTTAILROOM(drv, lb) (0)
5028 +#define PKTNEXT(drv, lb) NULL
5029 +#define PKTSETNEXT(lb, x) ASSERT(0)
5030 +#define PKTSETLEN(drv, lb, bytes) ((struct lbuf*)lb)->len = bytes
5031 +#define PKTPUSH(drv, lb, bytes) ASSERT(0)
5032 +#define PKTPULL(drv, lb, bytes) ASSERT(0)
5033 +#define PKTDUP(drv, lb) ASSERT(0)
5034 +#define PKTLINK(lb) ((struct lbuf*)lb)->next
5035 +#define PKTSETLINK(lb, x) ((struct lbuf*)lb)->next = (struct lbuf*)x
5036 +#define PKTPRIO(lb) (0)
5037 +#define PKTSETPRIO(lb, x) do {} while (0)
5038 +extern void *et_pktget(void *drv, uint len, bool send);
5039 +extern void et_pktfree(void *drv, struct lbuf *lb, bool send);
5041 +#endif /* _pmon_osl_h_ */
5042 diff -urN linux.old/arch/mips/bcm947xx/include/proto/802.11.h linux.dev/arch/mips/bcm947xx/include/proto/802.11.h
5043 --- linux.old/arch/mips/bcm947xx/include/proto/802.11.h 1970-01-01 01:00:00.000000000 +0100
5044 +++ linux.dev/arch/mips/bcm947xx/include/proto/802.11.h 2005-11-07 22:51:38.784726500 +0100
5047 + * Copyright 2005, Broadcom Corporation
5048 + * All Rights Reserved.
5050 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5051 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5052 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5053 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5055 + * Fundamental types and constants relating to 802.11
5063 +#ifndef _TYPEDEFS_H_
5064 +#include <typedefs.h>
5067 +#ifndef _NET_ETHERNET_H_
5068 +#include <proto/ethernet.h>
5071 +#include <proto/wpa.h>
5074 +/* enable structure packing */
5075 +#if defined(__GNUC__)
5076 +#define PACKED __attribute__((packed))
5082 +#define DOT11_TU_TO_US 1024 /* 802.11 Time Unit is 1024 microseconds */
5084 +/* Generic 802.11 frame constants */
5085 +#define DOT11_A3_HDR_LEN 24
5086 +#define DOT11_A4_HDR_LEN 30
5087 +#define DOT11_MAC_HDR_LEN DOT11_A3_HDR_LEN
5088 +#define DOT11_FCS_LEN 4
5089 +#define DOT11_ICV_LEN 4
5090 +#define DOT11_ICV_AES_LEN 8
5091 +#define DOT11_QOS_LEN 2
5093 +#define DOT11_KEY_INDEX_SHIFT 6
5094 +#define DOT11_IV_LEN 4
5095 +#define DOT11_IV_TKIP_LEN 8
5096 +#define DOT11_IV_AES_OCB_LEN 4
5097 +#define DOT11_IV_AES_CCM_LEN 8
5100 +#define DOT11_MAX_MPDU_BODY_LEN 2304
5101 +/* A4 header + QoS + CCMP + PDU + ICV + FCS = 2352 */
5102 +#define DOT11_MAX_MPDU_LEN (DOT11_A4_HDR_LEN + \
5104 + DOT11_IV_AES_CCM_LEN + \
5105 + DOT11_MAX_MPDU_BODY_LEN + \
5109 +#define DOT11_MAX_SSID_LEN 32
5111 +/* dot11RTSThreshold */
5112 +#define DOT11_DEFAULT_RTS_LEN 2347
5113 +#define DOT11_MAX_RTS_LEN 2347
5115 +/* dot11FragmentationThreshold */
5116 +#define DOT11_MIN_FRAG_LEN 256
5117 +#define DOT11_MAX_FRAG_LEN 2346 /* Max frag is also limited by aMPDUMaxLength of the attached PHY */
5118 +#define DOT11_DEFAULT_FRAG_LEN 2346
5120 +/* dot11BeaconPeriod */
5121 +#define DOT11_MIN_BEACON_PERIOD 1
5122 +#define DOT11_MAX_BEACON_PERIOD 0xFFFF
5124 +/* dot11DTIMPeriod */
5125 +#define DOT11_MIN_DTIM_PERIOD 1
5126 +#define DOT11_MAX_DTIM_PERIOD 0xFF
5128 +/* 802.2 LLC/SNAP header used by 802.11 per 802.1H */
5129 +#define DOT11_LLC_SNAP_HDR_LEN 8
5130 +#define DOT11_OUI_LEN 3
5131 +struct dot11_llc_snap_header {
5132 + uint8 dsap; /* always 0xAA */
5133 + uint8 ssap; /* always 0xAA */
5134 + uint8 ctl; /* always 0x03 */
5135 + uint8 oui[DOT11_OUI_LEN]; /* RFC1042: 0x00 0x00 0x00
5136 + Bridge-Tunnel: 0x00 0x00 0xF8 */
5137 + uint16 type; /* ethertype */
5140 +/* RFC1042 header used by 802.11 per 802.1H */
5141 +#define RFC1042_HDR_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN)
5143 +/* Generic 802.11 MAC header */
5145 + * N.B.: This struct reflects the full 4 address 802.11 MAC header.
5146 + * The fields are defined such that the shorter 1, 2, and 3
5147 + * address headers just use the first k fields.
5149 +struct dot11_header {
5150 + uint16 fc; /* frame control */
5151 + uint16 durid; /* duration/ID */
5152 + struct ether_addr a1; /* address 1 */
5153 + struct ether_addr a2; /* address 2 */
5154 + struct ether_addr a3; /* address 3 */
5155 + uint16 seq; /* sequence control */
5156 + struct ether_addr a4; /* address 4 */
5159 +/* Control frames */
5161 +struct dot11_rts_frame {
5162 + uint16 fc; /* frame control */
5163 + uint16 durid; /* duration/ID */
5164 + struct ether_addr ra; /* receiver address */
5165 + struct ether_addr ta; /* transmitter address */
5167 +#define DOT11_RTS_LEN 16
5169 +struct dot11_cts_frame {
5170 + uint16 fc; /* frame control */
5171 + uint16 durid; /* duration/ID */
5172 + struct ether_addr ra; /* receiver address */
5174 +#define DOT11_CTS_LEN 10
5176 +struct dot11_ack_frame {
5177 + uint16 fc; /* frame control */
5178 + uint16 durid; /* duration/ID */
5179 + struct ether_addr ra; /* receiver address */
5181 +#define DOT11_ACK_LEN 10
5183 +struct dot11_ps_poll_frame {
5184 + uint16 fc; /* frame control */
5185 + uint16 durid; /* AID */
5186 + struct ether_addr bssid; /* receiver address, STA in AP */
5187 + struct ether_addr ta; /* transmitter address */
5189 +#define DOT11_PS_POLL_LEN 16
5191 +struct dot11_cf_end_frame {
5192 + uint16 fc; /* frame control */
5193 + uint16 durid; /* duration/ID */
5194 + struct ether_addr ra; /* receiver address */
5195 + struct ether_addr bssid; /* transmitter address, STA in AP */
5197 +#define DOT11_CS_END_LEN 16
5199 +/* Management frame header */
5200 +struct dot11_management_header {
5201 + uint16 fc; /* frame control */
5202 + uint16 durid; /* duration/ID */
5203 + struct ether_addr da; /* receiver address */
5204 + struct ether_addr sa; /* transmitter address */
5205 + struct ether_addr bssid; /* BSS ID */
5206 + uint16 seq; /* sequence control */
5208 +#define DOT11_MGMT_HDR_LEN 24
5210 +/* Management frame payloads */
5212 +struct dot11_bcn_prb {
5213 + uint32 timestamp[2];
5214 + uint16 beacon_interval;
5215 + uint16 capability;
5217 +#define DOT11_BCN_PRB_LEN 12
5219 +struct dot11_auth {
5220 + uint16 alg; /* algorithm */
5221 + uint16 seq; /* sequence control */
5222 + uint16 status; /* status code */
5224 +#define DOT11_AUTH_FIXED_LEN 6 /* length of auth frame without challenge info elt */
5226 +struct dot11_assoc_req {
5227 + uint16 capability; /* capability information */
5228 + uint16 listen; /* listen interval */
5230 +#define DOT11_ASSOC_REQ_FIXED_LEN 4 /* length of assoc frame without info elts */
5232 +struct dot11_reassoc_req {
5233 + uint16 capability; /* capability information */
5234 + uint16 listen; /* listen interval */
5235 + struct ether_addr ap; /* Current AP address */
5237 +#define DOT11_REASSOC_REQ_FIXED_LEN 10 /* length of assoc frame without info elts */
5239 +struct dot11_assoc_resp {
5240 + uint16 capability; /* capability information */
5241 + uint16 status; /* status code */
5242 + uint16 aid; /* association ID */
5245 +struct dot11_action_measure {
5251 +#define DOT11_ACTION_MEASURE_LEN 3
5253 +struct dot11_action_switch_channel {
5256 + uint8 data[5]; /* for switch IE */
5260 + 802.11h related definitions.
5266 +} dot11_power_cnst_t;
5271 +} dot11_power_cap_t;
5279 +#define DOT11_MNG_IE_TPC_REPORT_LEN 2 /* length of IE data, not including 2 byte header */
5284 + uint8 first_channel;
5285 + uint8 num_channels;
5286 +} dot11_supp_channels_t;
5288 +/* csa mode type */
5289 +#define DOT11_CSA_MODE_ADVISORY 0
5290 +#define DOT11_CSA_MODE_NO_TX 1
5291 +struct dot11_channel_switch {
5298 +typedef struct dot11_channel_switch dot11_channel_switch_t;
5300 +/* length of IE data, not including 2 byte header */
5301 +#define DOT11_SWITCH_IE_LEN 3
5303 +/* 802.11h Measurement Request/Report IEs */
5304 +/* Measurement Type field */
5305 +#define DOT11_MEASURE_TYPE_BASIC 0
5306 +#define DOT11_MEASURE_TYPE_CCA 1
5307 +#define DOT11_MEASURE_TYPE_RPI 2
5309 +/* Measurement Mode field */
5311 +/* Measurement Request Modes */
5312 +#define DOT11_MEASURE_MODE_ENABLE (1<<1)
5313 +#define DOT11_MEASURE_MODE_REQUEST (1<<2)
5314 +#define DOT11_MEASURE_MODE_REPORT (1<<3)
5315 +/* Measurement Report Modes */
5316 +#define DOT11_MEASURE_MODE_LATE (1<<0)
5317 +#define DOT11_MEASURE_MODE_INCAPABLE (1<<1)
5318 +#define DOT11_MEASURE_MODE_REFUSED (1<<2)
5319 +/* Basic Measurement Map bits */
5320 +#define DOT11_MEASURE_BASIC_MAP_BSS ((uint8)(1<<0))
5321 +#define DOT11_MEASURE_BASIC_MAP_OFDM ((uint8)(1<<1))
5322 +#define DOT11_MEASURE_BASIC_MAP_UKNOWN ((uint8)(1<<2))
5323 +#define DOT11_MEASURE_BASIC_MAP_RADAR ((uint8)(1<<3))
5324 +#define DOT11_MEASURE_BASIC_MAP_UNMEAS ((uint8)(1<<4))
5333 + uint8 start_time[8];
5335 +} dot11_meas_req_t;
5336 +#define DOT11_MNG_IE_MREQ_LEN 14
5337 +/* length of Measure Request IE data not including variable len */
5338 +#define DOT11_MNG_IE_MREQ_FIXED_LEN 3
5340 +struct dot11_meas_rep {
5350 + uint8 start_time[8];
5357 +typedef struct dot11_meas_rep dot11_meas_rep_t;
5359 +/* length of Measure Report IE data not including variable len */
5360 +#define DOT11_MNG_IE_MREP_FIXED_LEN 3
5362 +struct dot11_meas_rep_basic {
5364 + uint8 start_time[8];
5368 +typedef struct dot11_meas_rep_basic dot11_meas_rep_basic_t;
5369 +#define DOT11_MEASURE_BASIC_REP_LEN 12
5371 +struct dot11_quiet {
5374 + uint8 count; /* TBTTs until beacon interval in quiet starts */
5375 + uint8 period; /* Beacon intervals between periodic quiet periods ? */
5376 + uint16 duration;/* Length of quiet period, in TU's */
5377 + uint16 offset; /* TU's offset from TBTT in Count field */
5379 +typedef struct dot11_quiet dot11_quiet_t;
5384 +} chan_map_tuple_t;
5389 + uint8 eaddr[ETHER_ADDR_LEN];
5391 + chan_map_tuple_t map[1];
5392 +} dot11_ibss_dfs_t;
5395 +#define WME_OUI "\x00\x50\xf2"
5398 +#define WME_SUBTYPE_IE 0 /* Information Element */
5399 +#define WME_SUBTYPE_PARAM_IE 1 /* Parameter Element */
5400 +#define WME_SUBTYPE_TSPEC 2 /* Traffic Specification */
5402 +/* WME Access Category Indices (ACIs) */
5403 +#define AC_BE 0 /* Best Effort */
5404 +#define AC_BK 1 /* Background */
5405 +#define AC_VI 2 /* Video */
5406 +#define AC_VO 3 /* Voice */
5409 +/* WME Information Element (IE) */
5417 +typedef struct wme_ie wme_ie_t;
5418 +#define WME_IE_LEN 7
5420 +struct wme_acparam {
5423 + uint16 TXOP; /* stored in network order (ls octet first) */
5425 +typedef struct wme_acparam wme_acparam_t;
5427 +/* WME Parameter Element (PE) */
5428 +struct wme_params {
5435 + wme_acparam_t acparam[4];
5437 +typedef struct wme_params wme_params_t;
5438 +#define WME_PARAMS_IE_LEN 24
5441 +#define WME_COUNT_MASK 0x0f
5443 +#define WME_AIFS_MASK 0x0f
5444 +#define WME_ACM_MASK 0x10
5445 +#define WME_ACI_MASK 0x60
5446 +#define WME_ACI_SHIFT 5
5448 +#define WME_CWMIN_MASK 0x0f
5449 +#define WME_CWMAX_MASK 0xf0
5450 +#define WME_CWMAX_SHIFT 4
5452 +#define WME_TXOP_UNITS 32
5454 +/* AP: default params to be announced in the Beacon Frames/Probe Responses Table 12 WME Draft*/
5455 +/* AP: default params to be Used in the AP Side Table 14 WME Draft January 2004 802.11-03-504r5 */
5456 +#define WME_AC_BK_ACI_STA 0x27
5457 +#define WME_AC_BK_ECW_STA 0xA4
5458 +#define WME_AC_BK_TXOP_STA 0x0000
5459 +#define WME_AC_BE_ACI_STA 0x03
5460 +#define WME_AC_BE_ECW_STA 0xA4
5461 +#define WME_AC_BE_TXOP_STA 0x0000
5462 +#define WME_AC_VI_ACI_STA 0x42
5463 +#define WME_AC_VI_ECW_STA 0x43
5464 +#define WME_AC_VI_TXOP_STA 0x005e
5465 +#define WME_AC_VO_ACI_STA 0x62
5466 +#define WME_AC_VO_ECW_STA 0x32
5467 +#define WME_AC_VO_TXOP_STA 0x002f
5469 +#define WME_AC_BK_ACI_AP 0x27
5470 +#define WME_AC_BK_ECW_AP 0xA4
5471 +#define WME_AC_BK_TXOP_AP 0x0000
5472 +#define WME_AC_BE_ACI_AP 0x03
5473 +#define WME_AC_BE_ECW_AP 0x64
5474 +#define WME_AC_BE_TXOP_AP 0x0000
5475 +#define WME_AC_VI_ACI_AP 0x41
5476 +#define WME_AC_VI_ECW_AP 0x43
5477 +#define WME_AC_VI_TXOP_AP 0x005e
5478 +#define WME_AC_VO_ACI_AP 0x61
5479 +#define WME_AC_VO_ECW_AP 0x32
5480 +#define WME_AC_VO_TXOP_AP 0x002f
5482 +/* WME Traffic Specification (TSPEC) element */
5483 +#define WME_SUBTYPE_TSPEC 2
5484 +#define WME_TSPEC_HDR_LEN 2
5485 +#define WME_TSPEC_BODY_OFF 2
5487 + uint8 oui[DOT11_OUI_LEN]; /* WME_OUI */
5488 + uint8 type; /* WME_TYPE */
5489 + uint8 subtype; /* WME_SUBTYPE_TSPEC */
5490 + uint8 version; /* WME_VERSION */
5491 + uint16 ts_info; /* TS Info */
5492 + uint16 nom_msdu_size; /* (Nominal or fixed) MSDU Size (bytes) */
5493 + uint16 max_msdu_size; /* Maximum MSDU Size (bytes) */
5494 + uint32 min_service_interval; /* Minimum Service Interval (us) */
5495 + uint32 max_service_interval; /* Maximum Service Interval (us) */
5496 + uint32 inactivity_interval; /* Inactivity Interval (us) */
5497 + uint32 service_start; /* Service Start Time (us) */
5498 + uint32 min_rate; /* Minimum Data Rate (bps) */
5499 + uint32 mean_rate; /* Mean Data Rate (bps) */
5500 + uint32 max_burst_size; /* Maximum Burst Size (bytes) */
5501 + uint32 min_phy_rate; /* Minimum PHY Rate (bps) */
5502 + uint32 peak_rate; /* Peak Data Rate (bps) */
5503 + uint32 delay_bound; /* Delay Bound (us) */
5504 + uint16 surplus_bandwidth; /* Surplus Bandwidth Allowance Factor */
5505 + uint16 medium_time; /* Medium Time (32 us/s periods) */
5507 +typedef struct wme_tspec wme_tspec_t;
5508 +#define WME_TSPEC_LEN 56 /* not including 2-byte header */
5511 +/* 802.1D priority is duplicated - bits 13-11 AND bits 3-1 */
5512 +#define TS_INFO_PRIO_SHIFT_HI 11
5513 +#define TS_INFO_PRIO_MASK_HI (0x7 << TS_INFO_PRIO_SHIFT_HI)
5514 +#define TS_INFO_PRIO_SHIFT_LO 1
5515 +#define TS_INFO_PRIO_MASK_LO (0x7 << TS_INFO_PRIO_SHIFT_LO)
5516 +#define TS_INFO_CONTENTION_SHIFT 7
5517 +#define TS_INFO_CONTENTION_MASK (0x1 << TS_INFO_CONTENTION_SHIFT)
5518 +#define TS_INFO_DIRECTION_SHIFT 5
5519 +#define TS_INFO_DIRECTION_MASK (0x3 << TS_INFO_DIRECTION_SHIFT)
5520 +#define TS_INFO_UPLINK (0 << TS_INFO_DIRECTION_SHIFT)
5521 +#define TS_INFO_DOWNLINK (1 << TS_INFO_DIRECTION_SHIFT)
5522 +#define TS_INFO_BIDIRECTIONAL (3 << TS_INFO_DIRECTION_SHIFT)
5524 +/* nom_msdu_size */
5525 +#define FIXED_MSDU_SIZE 0x8000 /* MSDU size is fixed */
5526 +#define MSDU_SIZE_MASK 0x7fff /* (Nominal or fixed) MSDU size */
5528 +/* surplus_bandwidth */
5529 +/* Represented as 3 bits of integer, binary point, 13 bits fraction */
5530 +#define INTEGER_SHIFT 13
5531 +#define FRACTION_MASK 0x1FFF
5533 +/* Management Notification Frame */
5534 +struct dot11_management_notification {
5535 + uint8 category; /* DOT11_ACTION_NOTIFICATION */
5539 + uint8 data[1]; /* Elements */
5541 +#define DOT11_MGMT_NOTIFICATION_LEN 4 /* Fixed length */
5543 +/* WME Action Codes */
5544 +#define WME_SETUP_REQUEST 0
5545 +#define WME_SETUP_RESPONSE 1
5546 +#define WME_TEARDOWN 2
5548 +/* WME Setup Response Status Codes */
5549 +#define WME_ADMISSION_ACCEPTED 0
5550 +#define WME_INVALID_PARAMETERS 1
5551 +#define WME_ADMISSION_REFUSED 3
5553 +/* Macro to take a pointer to a beacon or probe response
5554 + * header and return the char* pointer to the SSID info element
5556 +#define BCN_PRB_SSID(hdr) ((char*)(hdr) + DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_LEN)
5558 +/* Authentication frame payload constants */
5559 +#define DOT11_OPEN_SYSTEM 0
5560 +#define DOT11_SHARED_KEY 1
5561 +#define DOT11_CHALLENGE_LEN 128
5563 +/* Frame control macros */
5564 +#define FC_PVER_MASK 0x3
5565 +#define FC_PVER_SHIFT 0
5566 +#define FC_TYPE_MASK 0xC
5567 +#define FC_TYPE_SHIFT 2
5568 +#define FC_SUBTYPE_MASK 0xF0
5569 +#define FC_SUBTYPE_SHIFT 4
5570 +#define FC_TODS 0x100
5571 +#define FC_TODS_SHIFT 8
5572 +#define FC_FROMDS 0x200
5573 +#define FC_FROMDS_SHIFT 9
5574 +#define FC_MOREFRAG 0x400
5575 +#define FC_MOREFRAG_SHIFT 10
5576 +#define FC_RETRY 0x800
5577 +#define FC_RETRY_SHIFT 11
5578 +#define FC_PM 0x1000
5579 +#define FC_PM_SHIFT 12
5580 +#define FC_MOREDATA 0x2000
5581 +#define FC_MOREDATA_SHIFT 13
5582 +#define FC_WEP 0x4000
5583 +#define FC_WEP_SHIFT 14
5584 +#define FC_ORDER 0x8000
5585 +#define FC_ORDER_SHIFT 15
5587 +/* sequence control macros */
5588 +#define SEQNUM_SHIFT 4
5589 +#define FRAGNUM_MASK 0xF
5591 +/* Frame Control type/subtype defs */
5594 +#define FC_TYPE_MNG 0
5595 +#define FC_TYPE_CTL 1
5596 +#define FC_TYPE_DATA 2
5598 +/* Management Subtypes */
5599 +#define FC_SUBTYPE_ASSOC_REQ 0
5600 +#define FC_SUBTYPE_ASSOC_RESP 1
5601 +#define FC_SUBTYPE_REASSOC_REQ 2
5602 +#define FC_SUBTYPE_REASSOC_RESP 3
5603 +#define FC_SUBTYPE_PROBE_REQ 4
5604 +#define FC_SUBTYPE_PROBE_RESP 5
5605 +#define FC_SUBTYPE_BEACON 8
5606 +#define FC_SUBTYPE_ATIM 9
5607 +#define FC_SUBTYPE_DISASSOC 10
5608 +#define FC_SUBTYPE_AUTH 11
5609 +#define FC_SUBTYPE_DEAUTH 12
5610 +#define FC_SUBTYPE_ACTION 13
5612 +/* Control Subtypes */
5613 +#define FC_SUBTYPE_PS_POLL 10
5614 +#define FC_SUBTYPE_RTS 11
5615 +#define FC_SUBTYPE_CTS 12
5616 +#define FC_SUBTYPE_ACK 13
5617 +#define FC_SUBTYPE_CF_END 14
5618 +#define FC_SUBTYPE_CF_END_ACK 15
5620 +/* Data Subtypes */
5621 +#define FC_SUBTYPE_DATA 0
5622 +#define FC_SUBTYPE_DATA_CF_ACK 1
5623 +#define FC_SUBTYPE_DATA_CF_POLL 2
5624 +#define FC_SUBTYPE_DATA_CF_ACK_POLL 3
5625 +#define FC_SUBTYPE_NULL 4
5626 +#define FC_SUBTYPE_CF_ACK 5
5627 +#define FC_SUBTYPE_CF_POLL 6
5628 +#define FC_SUBTYPE_CF_ACK_POLL 7
5629 +#define FC_SUBTYPE_QOS_DATA 8
5630 +#define FC_SUBTYPE_QOS_NULL 12
5632 +/* type-subtype combos */
5633 +#define FC_KIND_MASK (FC_TYPE_MASK | FC_SUBTYPE_MASK)
5635 +#define FC_KIND(t, s) (((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT))
5637 +#define FC_ASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_REQ)
5638 +#define FC_ASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_RESP)
5639 +#define FC_REASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_REQ)
5640 +#define FC_REASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_RESP)
5641 +#define FC_PROBE_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_REQ)
5642 +#define FC_PROBE_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_RESP)
5643 +#define FC_BEACON FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_BEACON)
5644 +#define FC_DISASSOC FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DISASSOC)
5645 +#define FC_AUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_AUTH)
5646 +#define FC_DEAUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DEAUTH)
5647 +#define FC_ACTION FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ACTION)
5649 +#define FC_PS_POLL FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_PS_POLL)
5650 +#define FC_RTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_RTS)
5651 +#define FC_CTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTS)
5652 +#define FC_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_ACK)
5653 +#define FC_CF_END FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END)
5654 +#define FC_CF_END_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END_ACK)
5656 +#define FC_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA)
5657 +#define FC_NULL_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_NULL)
5658 +#define FC_DATA_CF_ACK FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA_CF_ACK)
5659 +#define FC_QOS_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_DATA)
5660 +#define FC_QOS_NULL FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_NULL)
5662 +/* QoS Control Field */
5665 +#define QOS_PRIO_SHIFT 0
5666 +#define QOS_PRIO_MASK 0x0007
5667 +#define QOS_PRIO(qos) (((qos) & QOS_PRIO_MASK) >> QOS_PRIO_SHIFT)
5669 +#define QOS_TID_SHIFT 0
5670 +#define QOS_TID_MASK 0x000f
5671 +#define QOS_TID(qos) (((qos) & QOS_TID_MASK) >> QOS_TID_SHIFT)
5673 +/* Ack Policy (0 means Acknowledge) */
5674 +#define QOS_ACK_SHIFT 5
5675 +#define QOS_ACK_MASK 0x0060
5676 +#define QOS_ACK(qos) (((qos) & QOS_ACK_MASK) >> QOS_ACK_SHIFT)
5678 +/* Management Frames */
5680 +/* Management Frame Constants */
5683 +#define DOT11_MNG_AUTH_ALGO_LEN 2
5684 +#define DOT11_MNG_AUTH_SEQ_LEN 2
5685 +#define DOT11_MNG_BEACON_INT_LEN 2
5686 +#define DOT11_MNG_CAP_LEN 2
5687 +#define DOT11_MNG_AP_ADDR_LEN 6
5688 +#define DOT11_MNG_LISTEN_INT_LEN 2
5689 +#define DOT11_MNG_REASON_LEN 2
5690 +#define DOT11_MNG_AID_LEN 2
5691 +#define DOT11_MNG_STATUS_LEN 2
5692 +#define DOT11_MNG_TIMESTAMP_LEN 8
5694 +/* DUR/ID field in assoc resp is 0xc000 | AID */
5695 +#define DOT11_AID_MASK 0x3fff
5698 +#define DOT11_RC_RESERVED 0
5699 +#define DOT11_RC_UNSPECIFIED 1 /* Unspecified reason */
5700 +#define DOT11_RC_AUTH_INVAL 2 /* Previous authentication no longer valid */
5701 +#define DOT11_RC_DEAUTH_LEAVING 3 /* Deauthenticated because sending station is
5702 + leaving (or has left) IBSS or ESS */
5703 +#define DOT11_RC_INACTIVITY 4 /* Disassociated due to inactivity */
5704 +#define DOT11_RC_BUSY 5 /* Disassociated because AP is unable to handle
5705 + all currently associated stations */
5706 +#define DOT11_RC_INVAL_CLASS_2 6 /* Class 2 frame received from
5707 + nonauthenticated station */
5708 +#define DOT11_RC_INVAL_CLASS_3 7 /* Class 3 frame received from
5709 + nonassociated station */
5710 +#define DOT11_RC_DISASSOC_LEAVING 8 /* Disassociated because sending station is
5711 + leaving (or has left) BSS */
5712 +#define DOT11_RC_NOT_AUTH 9 /* Station requesting (re)association is
5713 + not authenticated with responding station */
5714 +#define DOT11_RC_MAX 23 /* Reason codes > 23 are reserved */
5717 +#define DOT11_STATUS_SUCCESS 0 /* Successful */
5718 +#define DOT11_STATUS_FAILURE 1 /* Unspecified failure */
5719 +#define DOT11_STATUS_CAP_MISMATCH 10 /* Cannot support all requested capabilities
5720 + in the Capability Information field */
5721 +#define DOT11_STATUS_REASSOC_FAIL 11 /* Reassociation denied due to inability to
5722 + confirm that association exists */
5723 +#define DOT11_STATUS_ASSOC_FAIL 12 /* Association denied due to reason outside
5724 + the scope of this standard */
5725 +#define DOT11_STATUS_AUTH_MISMATCH 13 /* Responding station does not support the
5726 + specified authentication algorithm */
5727 +#define DOT11_STATUS_AUTH_SEQ 14 /* Received an Authentication frame with
5728 + authentication transaction sequence number
5729 + out of expected sequence */
5730 +#define DOT11_STATUS_AUTH_CHALLENGE_FAIL 15 /* Authentication rejected because of challenge failure */
5731 +#define DOT11_STATUS_AUTH_TIMEOUT 16 /* Authentication rejected due to timeout waiting
5732 + for next frame in sequence */
5733 +#define DOT11_STATUS_ASSOC_BUSY_FAIL 17 /* Association denied because AP is unable to
5734 + handle additional associated stations */
5735 +#define DOT11_STATUS_ASSOC_RATE_MISMATCH 18 /* Association denied due to requesting station
5736 + not supporting all of the data rates in the
5737 + BSSBasicRateSet parameter */
5738 +#define DOT11_STATUS_ASSOC_SHORT_REQUIRED 19 /* Association denied due to requesting station
5739 + not supporting the Short Preamble option */
5740 +#define DOT11_STATUS_ASSOC_PBCC_REQUIRED 20 /* Association denied due to requesting station
5741 + not supporting the PBCC Modulation option */
5742 +#define DOT11_STATUS_ASSOC_AGILITY_REQUIRED 21 /* Association denied due to requesting station
5743 + not supporting the Channel Agility option */
5744 +#define DOT11_STATUS_ASSOC_SPECTRUM_REQUIRED 22 /* Association denied because Spectrum Management
5745 + capability is required. */
5746 +#define DOT11_STATUS_ASSOC_BAD_POWER_CAP 23 /* Association denied because the info in the
5747 + Power Cap element is unacceptable. */
5748 +#define DOT11_STATUS_ASSOC_BAD_SUP_CHANNELS 24 /* Association denied because the info in the
5749 + Supported Channel element is unacceptable */
5750 +#define DOT11_STATUS_ASSOC_SHORTSLOT_REQUIRED 25 /* Association denied due to requesting station
5751 + not supporting the Short Slot Time option */
5752 +#define DOT11_STATUS_ASSOC_ERPBCC_REQUIRED 26 /* Association denied due to requesting station
5753 + not supporting the ER-PBCC Modulation option */
5754 +#define DOT11_STATUS_ASSOC_DSSOFDM_REQUIRED 27 /* Association denied due to requesting station
5755 + not supporting the DSS-OFDM option */
5757 +/* Info Elts, length of INFORMATION portion of Info Elts */
5758 +#define DOT11_MNG_DS_PARAM_LEN 1
5759 +#define DOT11_MNG_IBSS_PARAM_LEN 2
5761 +/* TIM Info element has 3 bytes fixed info in INFORMATION field,
5762 + * followed by 1 to 251 bytes of Partial Virtual Bitmap */
5763 +#define DOT11_MNG_TIM_FIXED_LEN 3
5764 +#define DOT11_MNG_TIM_DTIM_COUNT 0
5765 +#define DOT11_MNG_TIM_DTIM_PERIOD 1
5766 +#define DOT11_MNG_TIM_BITMAP_CTL 2
5767 +#define DOT11_MNG_TIM_PVB 3
5770 +#define TLV_TAG_OFF 0
5771 +#define TLV_LEN_OFF 1
5772 +#define TLV_HDR_LEN 2
5773 +#define TLV_BODY_OFF 2
5775 +/* Management Frame Information Element IDs */
5776 +#define DOT11_MNG_SSID_ID 0
5777 +#define DOT11_MNG_RATES_ID 1
5778 +#define DOT11_MNG_FH_PARMS_ID 2
5779 +#define DOT11_MNG_DS_PARMS_ID 3
5780 +#define DOT11_MNG_CF_PARMS_ID 4
5781 +#define DOT11_MNG_TIM_ID 5
5782 +#define DOT11_MNG_IBSS_PARMS_ID 6
5783 +#define DOT11_MNG_COUNTRY_ID 7
5784 +#define DOT11_MNG_HOPPING_PARMS_ID 8
5785 +#define DOT11_MNG_HOPPING_TABLE_ID 9
5786 +#define DOT11_MNG_REQUEST_ID 10
5787 +#define DOT11_MNG_CHALLENGE_ID 16
5788 +#define DOT11_MNG_PWR_CONSTRAINT_ID 32 /* 11H PowerConstraint */
5789 +#define DOT11_MNG_PWR_CAP_ID 33 /* 11H PowerCapability */
5790 +#define DOT11_MNG_TPC_REQUEST_ID 34 /* 11H TPC Request */
5791 +#define DOT11_MNG_TPC_REPORT_ID 35 /* 11H TPC Report */
5792 +#define DOT11_MNG_SUPP_CHANNELS_ID 36 /* 11H Supported Channels */
5793 +#define DOT11_MNG_CHANNEL_SWITCH_ID 37 /* 11H ChannelSwitch Announcement*/
5794 +#define DOT11_MNG_MEASURE_REQUEST_ID 38 /* 11H MeasurementRequest */
5795 +#define DOT11_MNG_MEASURE_REPORT_ID 39 /* 11H MeasurementReport */
5796 +#define DOT11_MNG_QUIET_ID 40 /* 11H Quiet */
5797 +#define DOT11_MNG_IBSS_DFS_ID 41 /* 11H IBSS_DFS */
5798 +#define DOT11_MNG_ERP_ID 42
5799 +#define DOT11_MNG_NONERP_ID 47
5801 +#define DOT11_MNG_RSN_ID 48
5802 +#endif /* BCMWPA2 */
5803 +#define DOT11_MNG_EXT_RATES_ID 50
5804 +#define DOT11_MNG_WPA_ID 221
5805 +#define DOT11_MNG_PROPR_ID 221
5807 +/* ERP info element bit values */
5808 +#define DOT11_MNG_ERP_LEN 1 /* ERP is currently 1 byte long */
5809 +#define DOT11_MNG_NONERP_PRESENT 0x01 /* NonERP (802.11b) STAs are present in the BSS */
5810 +#define DOT11_MNG_USE_PROTECTION 0x02 /* Use protection mechanisms for ERP-OFDM frames */
5811 +#define DOT11_MNG_BARKER_PREAMBLE 0x04 /* Short Preambles: 0 == allowed, 1 == not allowed */
5813 +/* Capability Information Field */
5814 +#define DOT11_CAP_ESS 0x0001
5815 +#define DOT11_CAP_IBSS 0x0002
5816 +#define DOT11_CAP_POLLABLE 0x0004
5817 +#define DOT11_CAP_POLL_RQ 0x0008
5818 +#define DOT11_CAP_PRIVACY 0x0010
5819 +#define DOT11_CAP_SHORT 0x0020
5820 +#define DOT11_CAP_PBCC 0x0040
5821 +#define DOT11_CAP_AGILITY 0x0080
5822 +#define DOT11_CAP_SPECTRUM 0x0100
5823 +#define DOT11_CAP_SHORTSLOT 0x0400
5824 +#define DOT11_CAP_CCK_OFDM 0x2000
5826 +/* Action Frame Constants */
5827 +#define DOT11_ACTION_CAT_ERR_MASK 0x80
5828 +#define DOT11_ACTION_CAT_SPECT_MNG 0x00
5829 +#define DOT11_ACTION_NOTIFICATION 0x11 /* 17 */
5831 +#define DOT11_ACTION_ID_M_REQ 0
5832 +#define DOT11_ACTION_ID_M_REP 1
5833 +#define DOT11_ACTION_ID_TPC_REQ 2
5834 +#define DOT11_ACTION_ID_TPC_REP 3
5835 +#define DOT11_ACTION_ID_CHANNEL_SWITCH 4
5837 +/* MLME Enumerations */
5838 +#define DOT11_BSSTYPE_INFRASTRUCTURE 0
5839 +#define DOT11_BSSTYPE_INDEPENDENT 1
5840 +#define DOT11_BSSTYPE_ANY 2
5841 +#define DOT11_SCANTYPE_ACTIVE 0
5842 +#define DOT11_SCANTYPE_PASSIVE 1
5844 +/* 802.11 A PHY constants */
5845 +#define APHY_SLOT_TIME 9
5846 +#define APHY_SIFS_TIME 16
5847 +#define APHY_DIFS_TIME (APHY_SIFS_TIME + (2 * APHY_SLOT_TIME))
5848 +#define APHY_PREAMBLE_TIME 16
5849 +#define APHY_SIGNAL_TIME 4
5850 +#define APHY_SYMBOL_TIME 4
5851 +#define APHY_SERVICE_NBITS 16
5852 +#define APHY_TAIL_NBITS 6
5853 +#define APHY_CWMIN 15
5855 +/* 802.11 B PHY constants */
5856 +#define BPHY_SLOT_TIME 20
5857 +#define BPHY_SIFS_TIME 10
5858 +#define BPHY_DIFS_TIME 50
5859 +#define BPHY_PLCP_TIME 192
5860 +#define BPHY_PLCP_SHORT_TIME 96
5861 +#define BPHY_CWMIN 31
5863 +/* 802.11 G constants */
5864 +#define DOT11_OFDM_SIGNAL_EXTENSION 6
5866 +#define PHY_CWMAX 1023
5868 +#define DOT11_MAXNUMFRAGS 16 /* max # fragments per MSDU */
5870 +/* dot11Counters Table - 802.11 spec., Annex D */
5871 +typedef struct d11cnt {
5872 + uint32 txfrag; /* dot11TransmittedFragmentCount */
5873 + uint32 txmulti; /* dot11MulticastTransmittedFrameCount */
5874 + uint32 txfail; /* dot11FailedCount */
5875 + uint32 txretry; /* dot11RetryCount */
5876 + uint32 txretrie; /* dot11MultipleRetryCount */
5877 + uint32 rxdup; /* dot11FrameduplicateCount */
5878 + uint32 txrts; /* dot11RTSSuccessCount */
5879 + uint32 txnocts; /* dot11RTSFailureCount */
5880 + uint32 txnoack; /* dot11ACKFailureCount */
5881 + uint32 rxfrag; /* dot11ReceivedFragmentCount */
5882 + uint32 rxmulti; /* dot11MulticastReceivedFrameCount */
5883 + uint32 rxcrc; /* dot11FCSErrorCount */
5884 + uint32 txfrmsnt; /* dot11TransmittedFrameCount */
5885 + uint32 rxundec; /* dot11WEPUndecryptableCount */
5889 +#define BRCM_OUI "\x00\x10\x18"
5891 +/* BRCM info element */
5893 + uchar id; /* 221, DOT11_MNG_PROPR_ID */
5897 + uchar assoc; /* # of assoc STAs */
5898 + uchar flags; /* misc flags */
5900 +#define BRCM_IE_LEN 8
5901 +typedef struct brcm_ie brcm_ie_t;
5902 +#define BRCM_IE_VER 2
5903 +#define BRCM_IE_LEGACY_AES_VER 1
5905 +/* brcm_ie flags */
5906 +#define BRF_ABCAP 0x1 /* afterburner capable */
5907 +#define BRF_ABRQRD 0x2 /* afterburner requested */
5908 +#define BRF_LZWDS 0x4 /* lazy wds enabled */
5909 +#define BRF_ABCOUNTER_MASK 0xf0 /* afterburner wds "state" counter */
5910 +#define BRF_ABCOUNTER_SHIFT 4
5912 +#define AB_WDS_TIMEOUT_MAX 15 /* afterburner wds Max count indicating not locally capable */
5913 +#define AB_WDS_TIMEOUT_MIN 1 /* afterburner wds, use zero count as indicating "downrev" */
5916 +/* OUI for BRCM proprietary IE */
5917 +#define BRCM_PROP_OUI "\x00\x90\x4C"
5919 +/* Vendor IE structure */
5924 + uchar data [1]; /* Variable size data */
5926 +typedef struct vndr_ie vndr_ie_t;
5928 +#define VNDR_IE_HDR_LEN 2 /* id + len field */
5929 +#define VNDR_IE_MIN_LEN 3 /* size of the oui field */
5930 +#define VNDR_IE_MAX_LEN 256
5932 +/* WPA definitions */
5933 +#define WPA_VERSION 1
5934 +#define WPA_OUI "\x00\x50\xF2"
5937 +#define WPA2_VERSION 1
5938 +#define WPA2_VERSION_LEN 2
5939 +#define WPA2_OUI "\x00\x0F\xAC"
5940 +#endif /* BCMWPA2 */
5942 +#define WPA_OUI_LEN 3
5944 +/* RSN authenticated key managment suite */
5945 +#define RSN_AKM_NONE 0 /* None (IBSS) */
5946 +#define RSN_AKM_UNSPECIFIED 1 /* Over 802.1x */
5947 +#define RSN_AKM_PSK 2 /* Pre-shared Key */
5950 +/* Key related defines */
5951 +#define DOT11_MAX_DEFAULT_KEYS 4 /* number of default keys */
5952 +#define DOT11_MAX_KEY_SIZE 32 /* max size of any key */
5953 +#define DOT11_MAX_IV_SIZE 16 /* max size of any IV */
5954 +#define DOT11_EXT_IV_FLAG (1<<5) /* flag to indicate IV is > 4 bytes */
5956 +#define WEP1_KEY_SIZE 5 /* max size of any WEP key */
5957 +#define WEP1_KEY_HEX_SIZE 10 /* size of WEP key in hex. */
5958 +#define WEP128_KEY_SIZE 13 /* max size of any WEP key */
5959 +#define WEP128_KEY_HEX_SIZE 26 /* size of WEP key in hex. */
5960 +#define TKIP_MIC_SIZE 8 /* size of TKIP MIC */
5961 +#define TKIP_EOM_SIZE 7 /* max size of TKIP EOM */
5962 +#define TKIP_EOM_FLAG 0x5a /* TKIP EOM flag byte */
5963 +#define TKIP_KEY_SIZE 32 /* size of any TKIP key */
5964 +#define TKIP_MIC_AUTH_TX 16 /* offset to Authenticator MIC TX key */
5965 +#define TKIP_MIC_AUTH_RX 24 /* offset to Authenticator MIC RX key */
5966 +#define TKIP_MIC_SUP_RX 16 /* offset to Supplicant MIC RX key */
5967 +#define TKIP_MIC_SUP_TX 24 /* offset to Supplicant MIC TX key */
5968 +#define AES_KEY_SIZE 16 /* size of AES key */
5971 +#if !defined(__GNUC__)
5975 +#endif /* _802_11_H_ */
5976 diff -urN linux.old/arch/mips/bcm947xx/include/proto/bcmeth.h linux.dev/arch/mips/bcm947xx/include/proto/bcmeth.h
5977 --- linux.old/arch/mips/bcm947xx/include/proto/bcmeth.h 1970-01-01 01:00:00.000000000 +0100
5978 +++ linux.dev/arch/mips/bcm947xx/include/proto/bcmeth.h 2005-11-07 22:51:38.784726500 +0100
5981 + * Broadcom Ethernettype protocol definitions
5983 + * Copyright 2005, Broadcom Corporation
5984 + * All Rights Reserved.
5986 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5987 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5988 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5989 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5994 + * Broadcom Ethernet protocol defines
6001 +/* enable structure packing */
6002 +#if defined(__GNUC__)
6003 +#define PACKED __attribute__((packed))
6009 +/* ETHER_TYPE_BRCM is defined in ethernet.h */
6012 + * Following the 2byte BRCM ether_type is a 16bit BRCM subtype field
6013 + * in one of two formats: (only subtypes 32768-65535 are in use now)
6015 + * subtypes 0-32767:
6016 + * 8 bit subtype (0-127)
6017 + * 8 bit length in bytes (0-255)
6019 + * subtypes 32768-65535:
6020 + * 16 bit big-endian subtype
6021 + * 16 bit big-endian length in bytes (0-65535)
6023 + * length is the number of additional bytes beyond the 4 or 6 byte header
6025 + * Reserved values:
6027 + * 5-15 reserved for iLine protocol assignments
6028 + * 17-126 reserved, assignable
6031 + * 32769-65534 reserved, assignable
6036 + * While adding the subtypes and their specific processing code make sure
6037 + * bcmeth_bcm_hdr_t is the first data structure in the user specific data structure definition
6040 +#define BCMILCP_SUBTYPE_RATE 1
6041 +#define BCMILCP_SUBTYPE_LINK 2
6042 +#define BCMILCP_SUBTYPE_CSA 3
6043 +#define BCMILCP_SUBTYPE_LARQ 4
6044 +#define BCMILCP_SUBTYPE_VENDOR 5
6045 +#define BCMILCP_SUBTYPE_FLH 17
6047 +#define BCMILCP_SUBTYPE_VENDOR_LONG 32769
6048 +#define BCMILCP_SUBTYPE_CERT 32770
6049 +#define BCMILCP_SUBTYPE_SES 32771
6052 +#define BCMILCP_BCM_SUBTYPE_RESERVED 0
6053 +#define BCMILCP_BCM_SUBTYPE_EVENT 1
6054 +#define BCMILCP_BCM_SUBTYPE_SES 2
6056 +The EAPOL type is not used anymore. Instead EAPOL messages are now embedded
6057 +within BCMILCP_BCM_SUBTYPE_EVENT type messages
6059 +/*#define BCMILCP_BCM_SUBTYPE_EAPOL 3*/
6061 +#define BCMILCP_BCM_SUBTYPEHDR_MINLENGTH 8
6062 +#define BCMILCP_BCM_SUBTYPEHDR_VERSION 0
6064 +/* These fields are stored in network order */
6065 +typedef struct bcmeth_hdr
6067 + uint16 subtype; /* Vendor specific..32769*/
6069 + uint8 version; /* Version is 0*/
6070 + uint8 oui[3]; /* Broadcom OUI*/
6071 + /* user specific Data */
6072 + uint16 usr_subtype;
6073 +} PACKED bcmeth_hdr_t;
6078 +#if !defined(__GNUC__)
6083 diff -urN linux.old/arch/mips/bcm947xx/include/proto/bcmip.h linux.dev/arch/mips/bcm947xx/include/proto/bcmip.h
6084 --- linux.old/arch/mips/bcm947xx/include/proto/bcmip.h 1970-01-01 01:00:00.000000000 +0100
6085 +++ linux.dev/arch/mips/bcm947xx/include/proto/bcmip.h 2005-11-08 00:15:47.881307500 +0100
6088 + * Copyright 2005, Broadcom Corporation
6089 + * All Rights Reserved.
6091 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
6092 + * the contents of this file may not be disclosed to third parties, copied
6093 + * or duplicated in any form, in whole or in part, without the prior
6094 + * written permission of Broadcom Corporation.
6096 + * Fundamental constants relating to IP Protocol
6105 +#define IPV4_VERIHL_OFFSET 0 /* version and ihl byte offset */
6106 +#define IPV4_TOS_OFFSET 1 /* TOS offset */
6107 +#define IPV4_PROT_OFFSET 9 /* protocol type offset */
6108 +#define IPV4_CHKSUM_OFFSET 10 /* IP header checksum offset */
6109 +#define IPV4_SRC_IP_OFFSET 12 /* src IP addr offset */
6110 +#define IPV4_DEST_IP_OFFSET 16 /* dest IP addr offset */
6112 +#define IPV4_VER_MASK 0xf0
6113 +#define IPV4_IHL_MASK 0x0f
6115 +#define IPV4_PROT_UDP 17 /* UDP protocol type */
6117 +#define IPV4_ADDR_LEN 4 /* IP v4 address length */
6119 +#define IPV4_VER_NUM 0x40 /* IP v4 version number */
6121 +/* NULL IP address check */
6122 +#define IPV4_ISNULLADDR(a) ((((uint8 *)(a))[0] + ((uint8 *)(a))[1] + \
6123 + ((uint8 *)(a))[2] + ((uint8 *)(a))[3]) == 0)
6125 +#define IPV4_ADDR_STR_LEN 16
6127 +#endif /* #ifndef _bcmip_h_ */
6129 diff -urN linux.old/arch/mips/bcm947xx/include/proto/ethernet.h linux.dev/arch/mips/bcm947xx/include/proto/ethernet.h
6130 --- linux.old/arch/mips/bcm947xx/include/proto/ethernet.h 1970-01-01 01:00:00.000000000 +0100
6131 +++ linux.dev/arch/mips/bcm947xx/include/proto/ethernet.h 2005-11-07 22:51:38.784726500 +0100
6133 +/*******************************************************************************
6135 + * Copyright 2005, Broadcom Corporation
6136 + * All Rights Reserved.
6138 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6139 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6140 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6141 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6142 + * From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
6143 + ******************************************************************************/
6145 +#ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
6146 +#define _NET_ETHERNET_H_
6148 +#ifndef _TYPEDEFS_H_
6149 +#include "typedefs.h"
6152 +/* enable structure packing */
6153 +#if defined(__GNUC__)
6154 +#define PACKED __attribute__((packed))
6161 + * The number of bytes in an ethernet (MAC) address.
6163 +#define ETHER_ADDR_LEN 6
6166 + * The number of bytes in the type field.
6168 +#define ETHER_TYPE_LEN 2
6171 + * The number of bytes in the trailing CRC field.
6173 +#define ETHER_CRC_LEN 4
6176 + * The length of the combined header.
6178 +#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
6181 + * The minimum packet length.
6183 +#define ETHER_MIN_LEN 64
6186 + * The minimum packet user data length.
6188 +#define ETHER_MIN_DATA 46
6191 + * The maximum packet length.
6193 +#define ETHER_MAX_LEN 1518
6196 + * The maximum packet user data length.
6198 +#define ETHER_MAX_DATA 1500
6201 +#define ETHER_TYPE_IP 0x0800 /* IP */
6202 +#define ETHER_TYPE_ARP 0x0806 /* ARP */
6203 +#define ETHER_TYPE_8021Q 0x8100 /* 802.1Q */
6204 +#define ETHER_TYPE_BRCM 0x886c /* Broadcom Corp. */
6205 +#define ETHER_TYPE_802_1X 0x888e /* 802.1x */
6206 +#define ETHER_TYPE_802_1X_PREAUTH 0x88c7 /* 802.1x preauthentication*/
6208 +/* Broadcom subtype follows ethertype; First 2 bytes are reserved; Next 2 are subtype; */
6209 +#define ETHER_BRCM_SUBTYPE_LEN 4 /* Broadcom 4 byte subtype */
6210 +#define ETHER_BRCM_CRAM 0x1 /* Broadcom subtype cram protocol */
6213 +#define ETHER_DEST_OFFSET 0 /* dest address offset */
6214 +#define ETHER_SRC_OFFSET 6 /* src address offset */
6215 +#define ETHER_TYPE_OFFSET 12 /* ether type offset */
6218 + * A macro to validate a length with
6220 +#define ETHER_IS_VALID_LEN(foo) \
6221 + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
6224 +#ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
6226 + * Structure of a 10Mb/s Ethernet header.
6228 +struct ether_header {
6229 + uint8 ether_dhost[ETHER_ADDR_LEN];
6230 + uint8 ether_shost[ETHER_ADDR_LEN];
6231 + uint16 ether_type;
6235 + * Structure of a 48-bit Ethernet address.
6237 +struct ether_addr {
6238 + uint8 octet[ETHER_ADDR_LEN];
6243 + * Takes a pointer, sets locally admininistered
6244 + * address bit in the 48-bit Ethernet address.
6246 +#define ETHER_SET_LOCALADDR(ea) ( ((uint8 *)(ea))[0] = \
6247 + (((uint8 *)(ea))[0] | 2) )
6250 + * Takes a pointer, returns true if a 48-bit multicast address
6251 + * (including broadcast, since it is all ones)
6253 +#define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
6256 +/* compare two ethernet addresses - assumes the pointers can be referenced as shorts */
6257 +#define ether_cmp(a, b) ( \
6258 + !(((short*)a)[0] == ((short*)b)[0]) | \
6259 + !(((short*)a)[1] == ((short*)b)[1]) | \
6260 + !(((short*)a)[2] == ((short*)b)[2]))
6262 +/* copy an ethernet address - assumes the pointers can be referenced as shorts */
6263 +#define ether_copy(s, d) { \
6264 + ((short*)d)[0] = ((short*)s)[0]; \
6265 + ((short*)d)[1] = ((short*)s)[1]; \
6266 + ((short*)d)[2] = ((short*)s)[2]; }
6269 + * Takes a pointer, returns true if a 48-bit broadcast (all ones)
6271 +#define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \
6272 + ((uint8 *)(ea))[1] & \
6273 + ((uint8 *)(ea))[2] & \
6274 + ((uint8 *)(ea))[3] & \
6275 + ((uint8 *)(ea))[4] & \
6276 + ((uint8 *)(ea))[5]) == 0xff)
6278 +static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
6281 + * Takes a pointer, returns true if a 48-bit null address (all zeros)
6283 +#define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \
6284 + ((uint8 *)(ea))[1] | \
6285 + ((uint8 *)(ea))[2] | \
6286 + ((uint8 *)(ea))[3] | \
6287 + ((uint8 *)(ea))[4] | \
6288 + ((uint8 *)(ea))[5]) == 0)
6290 +/* Differentiated Services Codepoint - upper 6 bits of tos in iphdr */
6291 +#define DSCP_MASK 0xFC /* upper 6 bits */
6292 +#define DSCP_SHIFT 2
6293 +#define DSCP_WME_PRI_MASK 0xE0 /* upper 3 bits */
6294 +#define DSCP_WME_PRI_SHIFT 5
6297 +#if !defined(__GNUC__)
6301 +#endif /* _NET_ETHERNET_H_ */
6302 diff -urN linux.old/arch/mips/bcm947xx/include/proto/vlan.h linux.dev/arch/mips/bcm947xx/include/proto/vlan.h
6303 --- linux.old/arch/mips/bcm947xx/include/proto/vlan.h 1970-01-01 01:00:00.000000000 +0100
6304 +++ linux.dev/arch/mips/bcm947xx/include/proto/vlan.h 2005-11-07 21:57:07.873587500 +0100
6307 + * 802.1Q VLAN protocol definitions
6309 + * Copyright 2005, Broadcom Corporation
6310 + * All Rights Reserved.
6312 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6313 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6314 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6315 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6323 +/* enable structure packing */
6324 +#if defined(__GNUC__)
6325 +#define PACKED __attribute__((packed))
6331 +#define VLAN_VID_MASK 0xfff /* low 12 bits are vlan id */
6332 +#define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */
6333 +#define VLAN_PRI_SHIFT 13 /* user priority */
6335 +#define VLAN_PRI_MASK 7 /* 3 bits of priority */
6337 +#define VLAN_TAG_LEN 4
6338 +#define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN)
6340 +struct ethervlan_header {
6341 + uint8 ether_dhost[ETHER_ADDR_LEN];
6342 + uint8 ether_shost[ETHER_ADDR_LEN];
6343 + uint16 vlan_type; /* 0x8100 */
6344 + uint16 vlan_tag; /* priority, cfi and vid */
6345 + uint16 ether_type;
6348 +#define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN)
6351 +#if !defined(__GNUC__)
6355 +#endif /* _vlan_h_ */
6356 diff -urN linux.old/arch/mips/bcm947xx/include/proto/wpa.h linux.dev/arch/mips/bcm947xx/include/proto/wpa.h
6357 --- linux.old/arch/mips/bcm947xx/include/proto/wpa.h 1970-01-01 01:00:00.000000000 +0100
6358 +++ linux.dev/arch/mips/bcm947xx/include/proto/wpa.h 2005-11-07 21:57:07.873587500 +0100
6361 + * Fundamental types and constants relating to WPA
6363 + * Copyright 2005, Broadcom Corporation
6364 + * All Rights Reserved.
6366 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6367 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6368 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6369 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6374 +#ifndef _proto_wpa_h_
6375 +#define _proto_wpa_h_
6377 +#include <typedefs.h>
6378 +#include <proto/ethernet.h>
6380 +/* enable structure packing */
6381 +#if defined(__GNUC__)
6382 +#define PACKED __attribute__((packed))
6390 +/* 10 and 11 are from TGh. */
6391 +#define DOT11_RC_BAD_PC 10 /* Unacceptable power capability element */
6392 +#define DOT11_RC_BAD_CHANNELS 11 /* Unacceptable supported channels element */
6394 +/* 13 through 23 taken from P802.11i/D3.0, November 2002 */
6395 +#define DOT11_RC_INVALID_WPA_IE 13 /* Invalid info. element */
6396 +#define DOT11_RC_MIC_FAILURE 14 /* Michael failure */
6397 +#define DOT11_RC_4WH_TIMEOUT 15 /* 4-way handshake timeout */
6398 +#define DOT11_RC_GTK_UPDATE_TIMEOUT 16 /* Group key update timeout */
6399 +#define DOT11_RC_WPA_IE_MISMATCH 17 /* WPA IE in 4-way handshake differs from (re-)assoc. request/probe response */
6400 +#define DOT11_RC_INVALID_MC_CIPHER 18 /* Invalid multicast cipher */
6401 +#define DOT11_RC_INVALID_UC_CIPHER 19 /* Invalid unicast cipher */
6402 +#define DOT11_RC_INVALID_AKMP 20 /* Invalid authenticated key management protocol */
6403 +#define DOT11_RC_BAD_WPA_VERSION 21 /* Unsupported WPA version */
6404 +#define DOT11_RC_INVALID_WPA_CAP 22 /* Invalid WPA IE capabilities */
6405 +#define DOT11_RC_8021X_AUTH_FAIL 23 /* 802.1X authentication failure */
6407 +#define WPA2_PMKID_LEN 16
6409 +/* WPA IE fixed portion */
6412 + uint8 tag; /* TAG */
6413 + uint8 length; /* TAG length */
6414 + uint8 oui[3]; /* IE OUI */
6415 + uint8 oui_type; /* OUI type */
6419 + } PACKED version; /* IE version */
6420 +} PACKED wpa_ie_fixed_t;
6421 +#define WPA_IE_OUITYPE_LEN 4
6422 +#define WPA_IE_FIXED_LEN 8
6423 +#define WPA_IE_TAG_FIXED_LEN 6
6426 + uint8 tag; /* TAG */
6427 + uint8 length; /* TAG length */
6431 + } PACKED version; /* IE version */
6432 +} PACKED wpa_rsn_ie_fixed_t;
6433 +#define WPA_RSN_IE_FIXED_LEN 4
6434 +#define WPA_RSN_IE_TAG_FIXED_LEN 2
6435 +typedef uint8 wpa_pmkid_t[WPA2_PMKID_LEN];
6437 +/* WPA suite/multicast suite */
6442 +} PACKED wpa_suite_t, wpa_suite_mcast_t;
6443 +#define WPA_SUITE_LEN 4
6445 +/* WPA unicast suite list/key management suite list */
6452 + wpa_suite_t list[1];
6453 +} PACKED wpa_suite_ucast_t, wpa_suite_auth_key_mgmt_t;
6454 +#define WPA_IE_SUITE_COUNT_LEN 2
6461 + wpa_pmkid_t list[1];
6462 +} PACKED wpa_pmkid_list_t;
6464 +/* WPA cipher suites */
6465 +#define WPA_CIPHER_NONE 0 /* None */
6466 +#define WPA_CIPHER_WEP_40 1 /* WEP (40-bit) */
6467 +#define WPA_CIPHER_TKIP 2 /* TKIP: default for WPA */
6468 +#define WPA_CIPHER_AES_OCB 3 /* AES (OCB) */
6469 +#define WPA_CIPHER_AES_CCM 4 /* AES (CCM) */
6470 +#define WPA_CIPHER_WEP_104 5 /* WEP (104-bit) */
6472 +#define IS_WPA_CIPHER(cipher) ((cipher) == WPA_CIPHER_NONE || \
6473 + (cipher) == WPA_CIPHER_WEP_40 || \
6474 + (cipher) == WPA_CIPHER_WEP_104 || \
6475 + (cipher) == WPA_CIPHER_TKIP || \
6476 + (cipher) == WPA_CIPHER_AES_OCB || \
6477 + (cipher) == WPA_CIPHER_AES_CCM)
6479 +/* WPA TKIP countermeasures parameters */
6480 +#define WPA_TKIP_CM_DETECT 60 /* multiple MIC failure window (seconds) */
6481 +#define WPA_TKIP_CM_BLOCK 60 /* countermeasures active window (seconds) */
6483 +/* WPA capabilities defined in 802.11i */
6484 +#define WPA_CAP_4_REPLAY_CNTRS 2
6485 +#define WPA_CAP_16_REPLAY_CNTRS 3
6486 +#define WPA_CAP_REPLAY_CNTR_SHIFT 2
6487 +#define WPA_CAP_REPLAY_CNTR_MASK 0x000c
6489 +/* WPA Specific defines */
6490 +#define WPA_CAP_LEN 2
6492 +#define WPA_CAP_WPA2_PREAUTH 1
6495 +#if !defined(__GNUC__)
6499 +#endif /* _proto_wpa_h_ */
6500 diff -urN linux.old/arch/mips/bcm947xx/include/rts/crc.h linux.dev/arch/mips/bcm947xx/include/rts/crc.h
6501 --- linux.old/arch/mips/bcm947xx/include/rts/crc.h 1970-01-01 01:00:00.000000000 +0100
6502 +++ linux.dev/arch/mips/bcm947xx/include/rts/crc.h 2005-11-07 21:57:07.873587500 +0100
6504 +/*******************************************************************************
6506 + * Copyright 2005, Broadcom Corporation
6507 + * All Rights Reserved.
6509 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6510 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6511 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6512 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6513 + * crc.h - a function to compute crc for iLine10 headers
6514 + ******************************************************************************/
6516 +#ifndef _RTS_CRC_H_
6517 +#define _RTS_CRC_H_ 1
6519 +#include "typedefs.h"
6526 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
6527 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
6528 +#define HCS_GOOD_VALUE 0x39 /* Good final header checksum value */
6530 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
6531 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
6533 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
6534 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
6536 +void hcs(uint8 *, uint);
6537 +uint8 crc8(uint8 *, uint, uint8);
6538 +uint16 crc16(uint8 *, uint, uint16);
6539 +uint32 crc32(uint8 *, uint, uint32);
6541 +/* macros for common usage */
6543 +#define APPEND_CRC8(pbytes, nbytes) \
6545 + uint8 tmp = crc8(pbytes, nbytes, CRC8_INIT_VALUE) ^ 0xff; \
6546 + (pbytes)[(nbytes)] = tmp; \
6550 +#define APPEND_CRC16(pbytes, nbytes) \
6552 + uint16 tmp = crc16(pbytes, nbytes, CRC16_INIT_VALUE) ^ 0xffff; \
6553 + (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
6554 + (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
6558 +#define APPEND_CRC32(pbytes, nbytes) \
6560 + uint32 tmp = crc32(pbytes, nbytes, CRC32_INIT_VALUE) ^ 0xffffffff; \
6561 + (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
6562 + (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
6563 + (pbytes)[(nbytes) + 2] = (tmp >> 16) & 0xff; \
6564 + (pbytes)[(nbytes) + 3] = (tmp >> 24) & 0xff; \
6572 +#endif /* _RTS_CRC_H_ */
6573 diff -urN linux.old/arch/mips/bcm947xx/include/sbchipc.h linux.dev/arch/mips/bcm947xx/include/sbchipc.h
6574 --- linux.old/arch/mips/bcm947xx/include/sbchipc.h 1970-01-01 01:00:00.000000000 +0100
6575 +++ linux.dev/arch/mips/bcm947xx/include/sbchipc.h 2005-11-07 22:51:38.784726500 +0100
6578 + * SiliconBackplane Chipcommon core hardware definitions.
6580 + * The chipcommon core provides chip identification, SB control,
6581 + * jtag, 0/1/2 uarts, clock frequency control, a watchdog interrupt timer,
6582 + * gpio interface, extbus, and support for serial and parallel flashes.
6585 + * Copyright 2005, Broadcom Corporation
6586 + * All Rights Reserved.
6588 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6589 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6590 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6591 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6599 +#ifndef _LANGUAGE_ASSEMBLY
6601 +/* cpp contortions to concatenate w/arg prescan */
6603 +#define _PADLINE(line) pad ## line
6604 +#define _XSTR(line) _PADLINE(line)
6605 +#define PAD _XSTR(__LINE__)
6608 +typedef volatile struct {
6609 + uint32 chipid; /* 0x0 */
6610 + uint32 capabilities;
6611 + uint32 corecontrol; /* corerev >= 1 */
6615 + uint32 otpstatus; /* 0x10, corerev >= 10 */
6616 + uint32 otpcontrol;
6620 + /* Interrupt control */
6621 + uint32 intstatus; /* 0x20 */
6623 + uint32 chipcontrol; /* 0x28, rev >= 11 */
6624 + uint32 chipstatus; /* 0x2c, rev >= 11 */
6627 + uint32 jtagcmd; /* 0x30, rev >= 10 */
6632 + /* serial flash interface registers */
6633 + uint32 flashcontrol; /* 0x40 */
6634 + uint32 flashaddress;
6638 + /* Silicon backplane configuration broadcast control */
6639 + uint32 broadcastaddress; /* 0x50 */
6640 + uint32 broadcastdata;
6643 + /* gpio - cleared only by power-on-reset */
6644 + uint32 gpioin; /* 0x60 */
6647 + uint32 gpiocontrol;
6648 + uint32 gpiointpolarity;
6649 + uint32 gpiointmask;
6652 + /* Watchdog timer */
6653 + uint32 watchdog; /* 0x80 */
6656 + /*GPIO based LED powersave registers corerev >= 16*/
6657 + uint32 gpiotimerval; /*0x88 */
6658 + uint32 gpiotimeroutmask;
6660 + /* clock control */
6661 + uint32 clockcontrol_n; /* 0x90 */
6662 + uint32 clockcontrol_sb; /* aka m0 */
6663 + uint32 clockcontrol_pci; /* aka m1 */
6664 + uint32 clockcontrol_m2; /* mii/uart/mipsref */
6665 + uint32 clockcontrol_mips; /* aka m3 */
6666 + uint32 clkdiv; /* corerev >= 3 */
6669 + /* pll delay registers (corerev >= 4) */
6670 + uint32 pll_on_delay; /* 0xb0 */
6671 + uint32 fref_sel_delay;
6672 + uint32 slow_clk_ctl; /* 5 < corerev < 10 */
6675 + /* Instaclock registers (corerev >= 10) */
6676 + uint32 system_clk_ctl; /* 0xc0 */
6677 + uint32 clkstatestretch;
6680 + /* ExtBus control registers (corerev >= 3) */
6681 + uint32 pcmcia_config; /* 0x100 */
6682 + uint32 pcmcia_memwait;
6683 + uint32 pcmcia_attrwait;
6684 + uint32 pcmcia_iowait;
6685 + uint32 ide_config;
6686 + uint32 ide_memwait;
6687 + uint32 ide_attrwait;
6688 + uint32 ide_iowait;
6689 + uint32 prog_config;
6690 + uint32 prog_waitcount;
6691 + uint32 flash_config;
6692 + uint32 flash_waitcount;
6696 + uint8 uart0data; /* 0x300 */
6703 + uint8 uart0scratch;
6704 + uint8 PAD[248]; /* corerev >= 1 */
6706 + uint8 uart1data; /* 0x400 */
6713 + uint8 uart1scratch;
6716 +#endif /* _LANGUAGE_ASSEMBLY */
6718 +#define CC_CHIPID 0
6719 +#define CC_CAPABILITIES 4
6720 +#define CC_JTAGCMD 0x30
6721 +#define CC_JTAGIR 0x34
6722 +#define CC_JTAGDR 0x38
6723 +#define CC_JTAGCTRL 0x3c
6724 +#define CC_WATCHDOG 0x80
6725 +#define CC_CLKC_N 0x90
6726 +#define CC_CLKC_M0 0x94
6727 +#define CC_CLKC_M1 0x98
6728 +#define CC_CLKC_M2 0x9c
6729 +#define CC_CLKC_M3 0xa0
6730 +#define CC_CLKDIV 0xa4
6731 +#define CC_SYS_CLK_CTL 0xc0
6732 +#define CC_OTP 0x800
6735 +#define CID_ID_MASK 0x0000ffff /* Chip Id mask */
6736 +#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */
6737 +#define CID_REV_SHIFT 16 /* Chip Revision shift */
6738 +#define CID_PKG_MASK 0x00f00000 /* Package Option mask */
6739 +#define CID_PKG_SHIFT 20 /* Package Option shift */
6740 +#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */
6741 +#define CID_CC_SHIFT 24
6744 +#define CAP_UARTS_MASK 0x00000003 /* Number of uarts */
6745 +#define CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */
6746 +#define CAP_UCLKSEL 0x00000018 /* UARTs clock select */
6747 +#define CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */
6748 +#define CAP_UARTGPIO 0x00000020 /* UARTs own Gpio's 15:12 */
6749 +#define CAP_EXTBUS 0x00000040 /* External bus present */
6750 +#define CAP_FLASH_MASK 0x00000700 /* Type of flash */
6751 +#define CAP_PLL_MASK 0x00038000 /* Type of PLL */
6752 +#define CAP_PWR_CTL 0x00040000 /* Power control */
6753 +#define CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */
6754 +#define CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */
6755 +#define CAP_OTPSIZE_BASE 5 /* OTP Size base */
6756 +#define CAP_JTAGP 0x00400000 /* JTAG Master Present */
6757 +#define CAP_ROM 0x00800000 /* Internal boot rom active */
6760 +#define PLL_NONE 0x00000000
6761 +#define PLL_TYPE1 0x00010000 /* 48Mhz base, 3 dividers */
6762 +#define PLL_TYPE2 0x00020000 /* 48Mhz, 4 dividers */
6763 +#define PLL_TYPE3 0x00030000 /* 25Mhz, 2 dividers */
6764 +#define PLL_TYPE4 0x00008000 /* 48Mhz, 4 dividers */
6765 +#define PLL_TYPE5 0x00018000 /* 25Mhz, 4 dividers */
6766 +#define PLL_TYPE6 0x00028000 /* 100/200 or 120/240 only */
6767 +#define PLL_TYPE7 0x00038000 /* 25Mhz, 4 dividers */
6770 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */
6771 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
6773 +/* Fields in the otpstatus register */
6774 +#define OTPS_PROGFAIL 0x80000000
6775 +#define OTPS_PROTECT 0x00000007
6776 +#define OTPS_HW_PROTECT 0x00000001
6777 +#define OTPS_SW_PROTECT 0x00000002
6778 +#define OTPS_CID_PROTECT 0x00000004
6780 +/* Fields in the otpcontrol register */
6781 +#define OTPC_RECWAIT 0xff000000
6782 +#define OTPC_PROGWAIT 0x00ffff00
6783 +#define OTPC_PRW_SHIFT 8
6784 +#define OTPC_MAXFAIL 0x00000038
6785 +#define OTPC_VSEL 0x00000006
6786 +#define OTPC_SELVL 0x00000001
6788 +/* Fields in otpprog */
6789 +#define OTPP_COL_MASK 0x000000ff
6790 +#define OTPP_ROW_MASK 0x0000ff00
6791 +#define OTPP_ROW_SHIFT 8
6792 +#define OTPP_READERR 0x10000000
6793 +#define OTPP_VALUE 0x20000000
6794 +#define OTPP_VALUE_SHIFT 29
6795 +#define OTPP_READ 0x40000000
6796 +#define OTPP_START 0x80000000
6797 +#define OTPP_BUSY 0x80000000
6800 +#define JCMD_START 0x80000000
6801 +#define JCMD_BUSY 0x80000000
6802 +#define JCMD_PAUSE 0x40000000
6803 +#define JCMD0_ACC_MASK 0x0000f000
6804 +#define JCMD0_ACC_IRDR 0x00000000
6805 +#define JCMD0_ACC_DR 0x00001000
6806 +#define JCMD0_ACC_IR 0x00002000
6807 +#define JCMD0_ACC_RESET 0x00003000
6808 +#define JCMD0_ACC_IRPDR 0x00004000
6809 +#define JCMD0_ACC_PDR 0x00005000
6810 +#define JCMD0_IRW_MASK 0x00000f00
6811 +#define JCMD_ACC_MASK 0x000f0000 /* Changes for corerev 11 */
6812 +#define JCMD_ACC_IRDR 0x00000000
6813 +#define JCMD_ACC_DR 0x00010000
6814 +#define JCMD_ACC_IR 0x00020000
6815 +#define JCMD_ACC_RESET 0x00030000
6816 +#define JCMD_ACC_IRPDR 0x00040000
6817 +#define JCMD_ACC_PDR 0x00050000
6818 +#define JCMD_IRW_MASK 0x00001f00
6819 +#define JCMD_IRW_SHIFT 8
6820 +#define JCMD_DRW_MASK 0x0000003f
6823 +#define JCTRL_FORCE_CLK 4 /* Force clock */
6824 +#define JCTRL_EXT_EN 2 /* Enable external targets */
6825 +#define JCTRL_EN 1 /* Enable Jtag master */
6827 +/* Fields in clkdiv */
6828 +#define CLKD_SFLASH 0x0f000000
6829 +#define CLKD_SFLASH_SHIFT 24
6830 +#define CLKD_OTP 0x000f0000
6831 +#define CLKD_OTP_SHIFT 16
6832 +#define CLKD_JTAG 0x00000f00
6833 +#define CLKD_JTAG_SHIFT 8
6834 +#define CLKD_UART 0x000000ff
6836 +/* intstatus/intmask */
6837 +#define CI_GPIO 0x00000001 /* gpio intr */
6838 +#define CI_EI 0x00000002 /* ro: ext intr pin (corerev >= 3) */
6839 +#define CI_WDRESET 0x80000000 /* watchdog reset occurred */
6842 +#define SCC_SS_MASK 0x00000007 /* slow clock source mask */
6843 +#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */
6844 +#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */
6845 +#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */
6846 +#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */
6847 +#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */
6848 +#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */
6849 +#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */
6850 +#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */
6851 +#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */
6852 +#define SCC_CD_MASK 0xffff0000 /* ClockDivider (SlowClk = 1/(4+divisor)) */
6853 +#define SCC_CD_SHIFT 16
6855 +/* system_clk_ctl */
6856 +#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */
6857 +#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */
6858 +#define SYCC_FP 0x00000004 /* ForcePLLOn */
6859 +#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */
6860 +#define SYCC_HR 0x00000010 /* Force HT */
6861 +#define SYCC_CD_MASK 0xffff0000 /* ClkDiv (ILP = 1/(4+divisor)) */
6862 +#define SYCC_CD_SHIFT 16
6865 +#define GPIO_ONTIME_SHIFT 16
6867 +/* clockcontrol_n */
6868 +#define CN_N1_MASK 0x3f /* n1 control */
6869 +#define CN_N2_MASK 0x3f00 /* n2 control */
6870 +#define CN_N2_SHIFT 8
6871 +#define CN_PLLC_MASK 0xf0000 /* pll control */
6872 +#define CN_PLLC_SHIFT 16
6874 +/* clockcontrol_sb/pci/uart */
6875 +#define CC_M1_MASK 0x3f /* m1 control */
6876 +#define CC_M2_MASK 0x3f00 /* m2 control */
6877 +#define CC_M2_SHIFT 8
6878 +#define CC_M3_MASK 0x3f0000 /* m3 control */
6879 +#define CC_M3_SHIFT 16
6880 +#define CC_MC_MASK 0x1f000000 /* mux control */
6881 +#define CC_MC_SHIFT 24
6883 +/* N3M Clock control magic field values */
6884 +#define CC_F6_2 0x02 /* A factor of 2 in */
6885 +#define CC_F6_3 0x03 /* 6-bit fields like */
6886 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
6887 +#define CC_F6_5 0x09
6888 +#define CC_F6_6 0x11
6889 +#define CC_F6_7 0x21
6891 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
6893 +#define CC_MC_BYPASS 0x08
6894 +#define CC_MC_M1 0x04
6895 +#define CC_MC_M1M2 0x02
6896 +#define CC_MC_M1M2M3 0x01
6897 +#define CC_MC_M1M3 0x11
6899 +/* Type 2 Clock control magic field values */
6900 +#define CC_T2_BIAS 2 /* n1, n2, m1 & m3 bias */
6901 +#define CC_T2M2_BIAS 3 /* m2 bias */
6903 +#define CC_T2MC_M1BYP 1
6904 +#define CC_T2MC_M2BYP 2
6905 +#define CC_T2MC_M3BYP 4
6907 +/* Type 6 Clock control magic field values */
6908 +#define CC_T6_MMASK 1 /* bits of interest in m */
6909 +#define CC_T6_M0 120000000 /* sb clock for m = 0 */
6910 +#define CC_T6_M1 100000000 /* sb clock for m = 1 */
6911 +#define SB2MIPS_T6(sb) (2 * (sb))
6913 +/* Common clock base */
6914 +#define CC_CLOCK_BASE1 24000000 /* Half the clock freq */
6915 +#define CC_CLOCK_BASE2 12500000 /* Alternate crystal on some PLL's */
6917 +/* Clock control values for 200Mhz in 5350 */
6918 +#define CLKC_5350_N 0x0311
6919 +#define CLKC_5350_M 0x04020009
6921 +/* Flash types in the chipcommon capabilities register */
6922 +#define FLASH_NONE 0x000 /* No flash */
6923 +#define SFLASH_ST 0x100 /* ST serial flash */
6924 +#define SFLASH_AT 0x200 /* Atmel serial flash */
6925 +#define PFLASH 0x700 /* Parallel flash */
6927 +/* Bits in the config registers */
6928 +#define CC_CFG_EN 0x0001 /* Enable */
6929 +#define CC_CFG_EM_MASK 0x000e /* Extif Mode */
6930 +#define CC_CFG_EM_ASYNC 0x0002 /* Async/Parallel flash */
6931 +#define CC_CFG_EM_SYNC 0x0004 /* Synchronous */
6932 +#define CC_CFG_EM_PCMCIA 0x0008 /* PCMCIA */
6933 +#define CC_CFG_EM_IDE 0x000a /* IDE */
6934 +#define CC_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
6935 +#define CC_CFG_CD_MASK 0x0060 /* Sync: Clock divisor */
6936 +#define CC_CFG_CE 0x0080 /* Sync: Clock enable */
6937 +#define CC_CFG_SB 0x0100 /* Sync: Size/Bytestrobe */
6939 +/* Start/busy bit in flashcontrol */
6940 +#define SFLASH_START 0x80000000
6941 +#define SFLASH_BUSY SFLASH_START
6943 +/* flashcontrol opcodes for ST flashes */
6944 +#define SFLASH_ST_WREN 0x0006 /* Write Enable */
6945 +#define SFLASH_ST_WRDIS 0x0004 /* Write Disable */
6946 +#define SFLASH_ST_RDSR 0x0105 /* Read Status Register */
6947 +#define SFLASH_ST_WRSR 0x0101 /* Write Status Register */
6948 +#define SFLASH_ST_READ 0x0303 /* Read Data Bytes */
6949 +#define SFLASH_ST_PP 0x0302 /* Page Program */
6950 +#define SFLASH_ST_SE 0x02d8 /* Sector Erase */
6951 +#define SFLASH_ST_BE 0x00c7 /* Bulk Erase */
6952 +#define SFLASH_ST_DP 0x00b9 /* Deep Power-down */
6953 +#define SFLASH_ST_RES 0x03ab /* Read Electronic Signature */
6955 +/* Status register bits for ST flashes */
6956 +#define SFLASH_ST_WIP 0x01 /* Write In Progress */
6957 +#define SFLASH_ST_WEL 0x02 /* Write Enable Latch */
6958 +#define SFLASH_ST_BP_MASK 0x1c /* Block Protect */
6959 +#define SFLASH_ST_BP_SHIFT 2
6960 +#define SFLASH_ST_SRWD 0x80 /* Status Register Write Disable */
6962 +/* flashcontrol opcodes for Atmel flashes */
6963 +#define SFLASH_AT_READ 0x07e8
6964 +#define SFLASH_AT_PAGE_READ 0x07d2
6965 +#define SFLASH_AT_BUF1_READ
6966 +#define SFLASH_AT_BUF2_READ
6967 +#define SFLASH_AT_STATUS 0x01d7
6968 +#define SFLASH_AT_BUF1_WRITE 0x0384
6969 +#define SFLASH_AT_BUF2_WRITE 0x0387
6970 +#define SFLASH_AT_BUF1_ERASE_PROGRAM 0x0283
6971 +#define SFLASH_AT_BUF2_ERASE_PROGRAM 0x0286
6972 +#define SFLASH_AT_BUF1_PROGRAM 0x0288
6973 +#define SFLASH_AT_BUF2_PROGRAM 0x0289
6974 +#define SFLASH_AT_PAGE_ERASE 0x0281
6975 +#define SFLASH_AT_BLOCK_ERASE 0x0250
6976 +#define SFLASH_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382
6977 +#define SFLASH_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385
6978 +#define SFLASH_AT_BUF1_LOAD 0x0253
6979 +#define SFLASH_AT_BUF2_LOAD 0x0255
6980 +#define SFLASH_AT_BUF1_COMPARE 0x0260
6981 +#define SFLASH_AT_BUF2_COMPARE 0x0261
6982 +#define SFLASH_AT_BUF1_REPROGRAM 0x0258
6983 +#define SFLASH_AT_BUF2_REPROGRAM 0x0259
6985 +/* Status register bits for Atmel flashes */
6986 +#define SFLASH_AT_READY 0x80
6987 +#define SFLASH_AT_MISMATCH 0x40
6988 +#define SFLASH_AT_ID_MASK 0x38
6989 +#define SFLASH_AT_ID_SHIFT 3
6992 +#define OTP_HW_REGION OTPS_HW_PROTECT
6993 +#define OTP_SW_REGION OTPS_SW_PROTECT
6994 +#define OTP_CID_REGION OTPS_CID_PROTECT
6996 +/* OTP regions (Byte offsets from otp size) */
6997 +#define OTP_SWLIM_OFF (-8)
6998 +#define OTP_CIDBASE_OFF 0
6999 +#define OTP_CIDLIM_OFF 8
7001 +/* Predefined OTP words (Word offset from otp size) */
7002 +#define OTP_BOUNDARY_OFF (-4)
7003 +#define OTP_HWSIGN_OFF (-3)
7004 +#define OTP_SWSIGN_OFF (-2)
7005 +#define OTP_CIDSIGN_OFF (-1)
7007 +#define OTP_CID_OFF 0
7008 +#define OTP_PKG_OFF 1
7009 +#define OTP_FID_OFF 2
7010 +#define OTP_RSV_OFF 3
7011 +#define OTP_LIM_OFF 4
7013 +#define OTP_SIGNATURE 0x578a
7014 +#define OTP_MAGIC 0x4e56
7016 +#endif /* _SBCHIPC_H */
7017 diff -urN linux.old/arch/mips/bcm947xx/include/sbconfig.h linux.dev/arch/mips/bcm947xx/include/sbconfig.h
7018 --- linux.old/arch/mips/bcm947xx/include/sbconfig.h 1970-01-01 01:00:00.000000000 +0100
7019 +++ linux.dev/arch/mips/bcm947xx/include/sbconfig.h 2005-11-07 22:51:38.784726500 +0100
7022 + * Broadcom SiliconBackplane hardware register definitions.
7024 + * Copyright 2005, Broadcom Corporation
7025 + * All Rights Reserved.
7027 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7028 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7029 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7030 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7034 +#ifndef _SBCONFIG_H
7035 +#define _SBCONFIG_H
7037 +/* cpp contortions to concatenate w/arg prescan */
7039 +#define _PADLINE(line) pad ## line
7040 +#define _XSTR(line) _PADLINE(line)
7041 +#define PAD _XSTR(__LINE__)
7045 + * SiliconBackplane Address Map.
7046 + * All regions may not exist on all chips.
7048 +#define SB_SDRAM_BASE 0x00000000 /* Physical SDRAM */
7049 +#define SB_PCI_MEM 0x08000000 /* Host Mode sb2pcitranslation0 (64 MB) */
7050 +#define SB_PCI_CFG 0x0c000000 /* Host Mode sb2pcitranslation1 (64 MB) */
7051 +#define SB_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
7052 +#define SB_ENUM_BASE 0x18000000 /* Enumeration space base */
7053 +#define SB_ENUM_LIM 0x18010000 /* Enumeration space limit */
7055 +#define SB_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
7056 +#define SB_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
7058 +#define SB_EXTIF_BASE 0x1f000000 /* External Interface region base address */
7059 +#define SB_FLASH1 0x1fc00000 /* Flash Region 1 */
7060 +#define SB_FLASH1_SZ 0x00400000 /* Size of Flash Region 1 */
7062 +#define SB_PCI_DMA 0x40000000 /* Client Mode sb2pcitranslation2 (1 GB) */
7063 +#define SB_PCI_DMA_SZ 0x40000000 /* Client Mode sb2pcitranslation2 size in bytes */
7064 +#define SB_PCIE_DMA_L32 0x00000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */
7065 +#define SB_PCIE_DMA_H32 0x80000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */
7066 +#define SB_EUART (SB_EXTIF_BASE + 0x00800000)
7067 +#define SB_LED (SB_EXTIF_BASE + 0x00900000)
7070 +/* enumeration space related defs */
7071 +#define SB_CORE_SIZE 0x1000 /* each core gets 4Kbytes for registers */
7072 +#define SB_MAXCORES ((SB_ENUM_LIM - SB_ENUM_BASE)/SB_CORE_SIZE)
7073 +#define SBCONFIGOFF 0xf00 /* core sbconfig regs are top 256bytes of regs */
7074 +#define SBCONFIGSIZE 256 /* sizeof (sbconfig_t) */
7077 +#define SB_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
7080 + * Sonics Configuration Space Registers.
7082 +#define SBIPSFLAG 0x08
7083 +#define SBTPSFLAG 0x18
7084 +#define SBTMERRLOGA 0x48 /* sonics >= 2.3 */
7085 +#define SBTMERRLOG 0x50 /* sonics >= 2.3 */
7086 +#define SBADMATCH3 0x60
7087 +#define SBADMATCH2 0x68
7088 +#define SBADMATCH1 0x70
7089 +#define SBIMSTATE 0x90
7090 +#define SBINTVEC 0x94
7091 +#define SBTMSTATELOW 0x98
7092 +#define SBTMSTATEHIGH 0x9c
7093 +#define SBBWA0 0xa0
7094 +#define SBIMCONFIGLOW 0xa8
7095 +#define SBIMCONFIGHIGH 0xac
7096 +#define SBADMATCH0 0xb0
7097 +#define SBTMCONFIGLOW 0xb8
7098 +#define SBTMCONFIGHIGH 0xbc
7099 +#define SBBCONFIG 0xc0
7100 +#define SBBSTATE 0xc8
7101 +#define SBACTCNFG 0xd8
7102 +#define SBFLAGST 0xe8
7103 +#define SBIDLOW 0xf8
7104 +#define SBIDHIGH 0xfc
7106 +#ifndef _LANGUAGE_ASSEMBLY
7108 +typedef volatile struct _sbconfig {
7110 + uint32 sbipsflag; /* initiator port ocp slave flag */
7112 + uint32 sbtpsflag; /* target port ocp slave flag */
7114 + uint32 sbtmerrloga; /* (sonics >= 2.3) */
7116 + uint32 sbtmerrlog; /* (sonics >= 2.3) */
7118 + uint32 sbadmatch3; /* address match3 */
7120 + uint32 sbadmatch2; /* address match2 */
7122 + uint32 sbadmatch1; /* address match1 */
7124 + uint32 sbimstate; /* initiator agent state */
7125 + uint32 sbintvec; /* interrupt mask */
7126 + uint32 sbtmstatelow; /* target state */
7127 + uint32 sbtmstatehigh; /* target state */
7128 + uint32 sbbwa0; /* bandwidth allocation table0 */
7130 + uint32 sbimconfiglow; /* initiator configuration */
7131 + uint32 sbimconfighigh; /* initiator configuration */
7132 + uint32 sbadmatch0; /* address match0 */
7134 + uint32 sbtmconfiglow; /* target configuration */
7135 + uint32 sbtmconfighigh; /* target configuration */
7136 + uint32 sbbconfig; /* broadcast configuration */
7138 + uint32 sbbstate; /* broadcast state */
7140 + uint32 sbactcnfg; /* activate configuration */
7142 + uint32 sbflagst; /* current sbflags */
7144 + uint32 sbidlow; /* identification */
7145 + uint32 sbidhigh; /* identification */
7148 +#endif /* _LANGUAGE_ASSEMBLY */
7151 +#define SBIPS_INT1_MASK 0x3f /* which sbflags get routed to mips interrupt 1 */
7152 +#define SBIPS_INT1_SHIFT 0
7153 +#define SBIPS_INT2_MASK 0x3f00 /* which sbflags get routed to mips interrupt 2 */
7154 +#define SBIPS_INT2_SHIFT 8
7155 +#define SBIPS_INT3_MASK 0x3f0000 /* which sbflags get routed to mips interrupt 3 */
7156 +#define SBIPS_INT3_SHIFT 16
7157 +#define SBIPS_INT4_MASK 0x3f000000 /* which sbflags get routed to mips interrupt 4 */
7158 +#define SBIPS_INT4_SHIFT 24
7161 +#define SBTPS_NUM0_MASK 0x3f /* interrupt sbFlag # generated by this core */
7162 +#define SBTPS_F0EN0 0x40 /* interrupt is always sent on the backplane */
7165 +#define SBTMEL_CM 0x00000007 /* command */
7166 +#define SBTMEL_CI 0x0000ff00 /* connection id */
7167 +#define SBTMEL_EC 0x0f000000 /* error code */
7168 +#define SBTMEL_ME 0x80000000 /* multiple error */
7171 +#define SBIM_PC 0xf /* pipecount */
7172 +#define SBIM_AP_MASK 0x30 /* arbitration policy */
7173 +#define SBIM_AP_BOTH 0x00 /* use both timeslaces and token */
7174 +#define SBIM_AP_TS 0x10 /* use timesliaces only */
7175 +#define SBIM_AP_TK 0x20 /* use token only */
7176 +#define SBIM_AP_RSV 0x30 /* reserved */
7177 +#define SBIM_IBE 0x20000 /* inbanderror */
7178 +#define SBIM_TO 0x40000 /* timeout */
7179 +#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */
7180 +#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */
7183 +#define SBTML_RESET 0x1 /* reset */
7184 +#define SBTML_REJ_MASK 0x6 /* reject */
7185 +#define SBTML_REJ_SHIFT 1
7186 +#define SBTML_CLK 0x10000 /* clock enable */
7187 +#define SBTML_FGC 0x20000 /* force gated clocks on */
7188 +#define SBTML_FL_MASK 0x3ffc0000 /* core-specific flags */
7189 +#define SBTML_PE 0x40000000 /* pme enable */
7190 +#define SBTML_BE 0x80000000 /* bist enable */
7192 +/* sbtmstatehigh */
7193 +#define SBTMH_SERR 0x1 /* serror */
7194 +#define SBTMH_INT 0x2 /* interrupt */
7195 +#define SBTMH_BUSY 0x4 /* busy */
7196 +#define SBTMH_TO 0x00000020 /* timeout (sonics >= 2.3) */
7197 +#define SBTMH_FL_MASK 0x1fff0000 /* core-specific flags */
7198 +#define SBTMH_DMA64 0x10000000 /* supports DMA with 64-bit addresses */
7199 +#define SBTMH_GCR 0x20000000 /* gated clock request */
7200 +#define SBTMH_BISTF 0x40000000 /* bist failed */
7201 +#define SBTMH_BISTD 0x80000000 /* bist done */
7205 +#define SBBWA_TAB0_MASK 0xffff /* lookup table 0 */
7206 +#define SBBWA_TAB1_MASK 0xffff /* lookup table 1 */
7207 +#define SBBWA_TAB1_SHIFT 16
7209 +/* sbimconfiglow */
7210 +#define SBIMCL_STO_MASK 0x7 /* service timeout */
7211 +#define SBIMCL_RTO_MASK 0x70 /* request timeout */
7212 +#define SBIMCL_RTO_SHIFT 4
7213 +#define SBIMCL_CID_MASK 0xff0000 /* connection id */
7214 +#define SBIMCL_CID_SHIFT 16
7216 +/* sbimconfighigh */
7217 +#define SBIMCH_IEM_MASK 0xc /* inband error mode */
7218 +#define SBIMCH_TEM_MASK 0x30 /* timeout error mode */
7219 +#define SBIMCH_TEM_SHIFT 4
7220 +#define SBIMCH_BEM_MASK 0xc0 /* bus error mode */
7221 +#define SBIMCH_BEM_SHIFT 6
7224 +#define SBAM_TYPE_MASK 0x3 /* address type */
7225 +#define SBAM_AD64 0x4 /* reserved */
7226 +#define SBAM_ADINT0_MASK 0xf8 /* type0 size */
7227 +#define SBAM_ADINT0_SHIFT 3
7228 +#define SBAM_ADINT1_MASK 0x1f8 /* type1 size */
7229 +#define SBAM_ADINT1_SHIFT 3
7230 +#define SBAM_ADINT2_MASK 0x1f8 /* type2 size */
7231 +#define SBAM_ADINT2_SHIFT 3
7232 +#define SBAM_ADEN 0x400 /* enable */
7233 +#define SBAM_ADNEG 0x800 /* negative decode */
7234 +#define SBAM_BASE0_MASK 0xffffff00 /* type0 base address */
7235 +#define SBAM_BASE0_SHIFT 8
7236 +#define SBAM_BASE1_MASK 0xfffff000 /* type1 base address for the core */
7237 +#define SBAM_BASE1_SHIFT 12
7238 +#define SBAM_BASE2_MASK 0xffff0000 /* type2 base address for the core */
7239 +#define SBAM_BASE2_SHIFT 16
7241 +/* sbtmconfiglow */
7242 +#define SBTMCL_CD_MASK 0xff /* clock divide */
7243 +#define SBTMCL_CO_MASK 0xf800 /* clock offset */
7244 +#define SBTMCL_CO_SHIFT 11
7245 +#define SBTMCL_IF_MASK 0xfc0000 /* interrupt flags */
7246 +#define SBTMCL_IF_SHIFT 18
7247 +#define SBTMCL_IM_MASK 0x3000000 /* interrupt mode */
7248 +#define SBTMCL_IM_SHIFT 24
7250 +/* sbtmconfighigh */
7251 +#define SBTMCH_BM_MASK 0x3 /* busy mode */
7252 +#define SBTMCH_RM_MASK 0x3 /* retry mode */
7253 +#define SBTMCH_RM_SHIFT 2
7254 +#define SBTMCH_SM_MASK 0x30 /* stop mode */
7255 +#define SBTMCH_SM_SHIFT 4
7256 +#define SBTMCH_EM_MASK 0x300 /* sb error mode */
7257 +#define SBTMCH_EM_SHIFT 8
7258 +#define SBTMCH_IM_MASK 0xc00 /* int mode */
7259 +#define SBTMCH_IM_SHIFT 10
7262 +#define SBBC_LAT_MASK 0x3 /* sb latency */
7263 +#define SBBC_MAX0_MASK 0xf0000 /* maxccntr0 */
7264 +#define SBBC_MAX0_SHIFT 16
7265 +#define SBBC_MAX1_MASK 0xf00000 /* maxccntr1 */
7266 +#define SBBC_MAX1_SHIFT 20
7269 +#define SBBS_SRD 0x1 /* st reg disable */
7270 +#define SBBS_HRD 0x2 /* hold reg disable */
7273 +#define SBIDL_CS_MASK 0x3 /* config space */
7274 +#define SBIDL_AR_MASK 0x38 /* # address ranges supported */
7275 +#define SBIDL_AR_SHIFT 3
7276 +#define SBIDL_SYNCH 0x40 /* sync */
7277 +#define SBIDL_INIT 0x80 /* initiator */
7278 +#define SBIDL_MINLAT_MASK 0xf00 /* minimum backplane latency */
7279 +#define SBIDL_MINLAT_SHIFT 8
7280 +#define SBIDL_MAXLAT 0xf000 /* maximum backplane latency */
7281 +#define SBIDL_MAXLAT_SHIFT 12
7282 +#define SBIDL_FIRST 0x10000 /* this initiator is first */
7283 +#define SBIDL_CW_MASK 0xc0000 /* cycle counter width */
7284 +#define SBIDL_CW_SHIFT 18
7285 +#define SBIDL_TP_MASK 0xf00000 /* target ports */
7286 +#define SBIDL_TP_SHIFT 20
7287 +#define SBIDL_IP_MASK 0xf000000 /* initiator ports */
7288 +#define SBIDL_IP_SHIFT 24
7289 +#define SBIDL_RV_MASK 0xf0000000 /* sonics backplane revision code */
7290 +#define SBIDL_RV_SHIFT 28
7291 +#define SBIDL_RV_2_2 0x00000000 /* version 2.2 or earlier */
7292 +#define SBIDL_RV_2_3 0x10000000 /* version 2.3 */
7295 +#define SBIDH_RC_MASK 0x000f /* revision code */
7296 +#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */
7297 +#define SBIDH_RCE_SHIFT 8
7298 +#define SBCOREREV(sbidh) \
7299 + ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | ((sbidh) & SBIDH_RC_MASK))
7300 +#define SBIDH_CC_MASK 0x8ff0 /* core code */
7301 +#define SBIDH_CC_SHIFT 4
7302 +#define SBIDH_VC_MASK 0xffff0000 /* vendor code */
7303 +#define SBIDH_VC_SHIFT 16
7305 +#define SB_COMMIT 0xfd8 /* update buffered registers value */
7308 +#define SB_VEND_BCM 0x4243 /* Broadcom's SB vendor code */
7311 +#define SB_CC 0x800 /* chipcommon core */
7312 +#define SB_ILINE20 0x801 /* iline20 core */
7313 +#define SB_SDRAM 0x803 /* sdram core */
7314 +#define SB_PCI 0x804 /* pci core */
7315 +#define SB_MIPS 0x805 /* mips core */
7316 +#define SB_ENET 0x806 /* enet mac core */
7317 +#define SB_CODEC 0x807 /* v90 codec core */
7318 +#define SB_USB 0x808 /* usb 1.1 host/device core */
7319 +#define SB_ADSL 0x809 /* ADSL core */
7320 +#define SB_ILINE100 0x80a /* iline100 core */
7321 +#define SB_IPSEC 0x80b /* ipsec core */
7322 +#define SB_PCMCIA 0x80d /* pcmcia core */
7323 +#define SB_SOCRAM 0x80e /* internal memory core */
7324 +#define SB_MEMC 0x80f /* memc sdram core */
7325 +#define SB_EXTIF 0x811 /* external interface core */
7326 +#define SB_D11 0x812 /* 802.11 MAC core */
7327 +#define SB_MIPS33 0x816 /* mips3302 core */
7328 +#define SB_USB11H 0x817 /* usb 1.1 host core */
7329 +#define SB_USB11D 0x818 /* usb 1.1 device core */
7330 +#define SB_USB20H 0x819 /* usb 2.0 host core */
7331 +#define SB_USB20D 0x81a /* usb 2.0 device core */
7332 +#define SB_SDIOH 0x81b /* sdio host core */
7333 +#define SB_ROBO 0x81c /* roboswitch core */
7334 +#define SB_ATA100 0x81d /* parallel ATA core */
7335 +#define SB_SATAXOR 0x81e /* serial ATA & XOR DMA core */
7336 +#define SB_GIGETH 0x81f /* gigabit ethernet core */
7337 +#define SB_PCIE 0x820 /* pci express core */
7338 +#define SB_SRAMC 0x822 /* SRAM controller core */
7339 +#define SB_MINIMAC 0x823 /* MINI MAC/phy core */
7341 +#define SB_CC_IDX 0 /* chipc, when present, is always core 0 */
7343 +/* Not really related to Silicon Backplane, but a couple of software
7344 + * conventions for the use the flash space:
7347 +/* Minumum amount of flash we support */
7348 +#define FLASH_MIN 0x00020000 /* Minimum flash size */
7350 +/* A boot/binary may have an embedded block that describes its size */
7351 +#define BISZ_OFFSET 0x3e0 /* At this offset into the binary */
7352 +#define BISZ_MAGIC 0x4249535a /* Marked with this value: 'BISZ' */
7353 +#define BISZ_MAGIC_IDX 0 /* Word 0: magic */
7354 +#define BISZ_TXTST_IDX 1 /* 1: text start */
7355 +#define BISZ_TXTEND_IDX 2 /* 2: text start */
7356 +#define BISZ_DATAST_IDX 3 /* 3: text start */
7357 +#define BISZ_DATAEND_IDX 4 /* 4: text start */
7358 +#define BISZ_BSSST_IDX 5 /* 5: text start */
7359 +#define BISZ_BSSEND_IDX 6 /* 6: text start */
7360 +#define BISZ_SIZE 7 /* descriptor size in 32-bit intergers */
7362 +#endif /* _SBCONFIG_H */
7363 diff -urN linux.old/arch/mips/bcm947xx/include/sbextif.h linux.dev/arch/mips/bcm947xx/include/sbextif.h
7364 --- linux.old/arch/mips/bcm947xx/include/sbextif.h 1970-01-01 01:00:00.000000000 +0100
7365 +++ linux.dev/arch/mips/bcm947xx/include/sbextif.h 2005-11-07 21:57:07.877587750 +0100
7368 + * Hardware-specific External Interface I/O core definitions
7369 + * for the BCM47xx family of SiliconBackplane-based chips.
7371 + * The External Interface core supports a total of three external chip selects
7372 + * supporting external interfaces. One of the external chip selects is
7373 + * used for Flash, one is used for PCMCIA, and the other may be
7374 + * programmed to support either a synchronous interface or an
7375 + * asynchronous interface. The asynchronous interface can be used to
7376 + * support external devices such as UARTs and the BCM2019 Bluetooth
7377 + * baseband processor.
7378 + * The external interface core also contains 2 on-chip 16550 UARTs, clock
7379 + * frequency control, a watchdog interrupt timer, and a GPIO interface.
7381 + * Copyright 2005, Broadcom Corporation
7382 + * All Rights Reserved.
7384 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7385 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7386 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7387 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7394 +/* external interface address space */
7395 +#define EXTIF_PCMCIA_MEMBASE(x) (x)
7396 +#define EXTIF_PCMCIA_IOBASE(x) ((x) + 0x100000)
7397 +#define EXTIF_PCMCIA_CFGBASE(x) ((x) + 0x200000)
7398 +#define EXTIF_CFGIF_BASE(x) ((x) + 0x800000)
7399 +#define EXTIF_FLASH_BASE(x) ((x) + 0xc00000)
7401 +/* cpp contortions to concatenate w/arg prescan */
7403 +#define _PADLINE(line) pad ## line
7404 +#define _XSTR(line) _PADLINE(line)
7405 +#define PAD _XSTR(__LINE__)
7409 + * The multiple instances of output and output enable registers
7410 + * are present to allow driver software for multiple cores to control
7411 + * gpio outputs without needing to share a single register pair.
7417 +#define NGPIOUSER 5
7419 +typedef volatile struct {
7420 + uint32 corecontrol;
7424 + /* pcmcia control registers */
7425 + uint32 pcmcia_config;
7426 + uint32 pcmcia_memwait;
7427 + uint32 pcmcia_attrwait;
7428 + uint32 pcmcia_iowait;
7430 + /* programmable interface control registers */
7431 + uint32 prog_config;
7432 + uint32 prog_waitcount;
7434 + /* flash control registers */
7435 + uint32 flash_config;
7436 + uint32 flash_waitcount;
7441 + /* clock control */
7442 + uint32 clockcontrol_n;
7443 + uint32 clockcontrol_sb;
7444 + uint32 clockcontrol_pci;
7445 + uint32 clockcontrol_mii;
7450 + struct gpiouser gpio[NGPIOUSER];
7452 + uint32 ejtagouten;
7453 + uint32 gpiointpolarity;
7454 + uint32 gpiointmask;
7471 + uint8 uartscratch;
7476 +#define CC_UE (1 << 0) /* uart enable */
7479 +#define ES_EM (1 << 0) /* endian mode (ro) */
7480 +#define ES_EI (1 << 1) /* external interrupt pin (ro) */
7481 +#define ES_GI (1 << 2) /* gpio interrupt pin (ro) */
7483 +/* gpio bit mask */
7484 +#define GPIO_BIT0 (1 << 0)
7485 +#define GPIO_BIT1 (1 << 1)
7486 +#define GPIO_BIT2 (1 << 2)
7487 +#define GPIO_BIT3 (1 << 3)
7488 +#define GPIO_BIT4 (1 << 4)
7489 +#define GPIO_BIT5 (1 << 5)
7490 +#define GPIO_BIT6 (1 << 6)
7491 +#define GPIO_BIT7 (1 << 7)
7494 +/* pcmcia/prog/flash_config */
7495 +#define CF_EN (1 << 0) /* enable */
7496 +#define CF_EM_MASK 0xe /* mode */
7497 +#define CF_EM_SHIFT 1
7498 +#define CF_EM_FLASH 0x0 /* flash/asynchronous mode */
7499 +#define CF_EM_SYNC 0x2 /* synchronous mode */
7500 +#define CF_EM_PCMCIA 0x4 /* pcmcia mode */
7501 +#define CF_DS (1 << 4) /* destsize: 0=8bit, 1=16bit */
7502 +#define CF_BS (1 << 5) /* byteswap */
7503 +#define CF_CD_MASK 0xc0 /* clock divider */
7504 +#define CF_CD_SHIFT 6
7505 +#define CF_CD_DIV2 0x0 /* backplane/2 */
7506 +#define CF_CD_DIV3 0x40 /* backplane/3 */
7507 +#define CF_CD_DIV4 0x80 /* backplane/4 */
7508 +#define CF_CE (1 << 8) /* clock enable */
7509 +#define CF_SB (1 << 9) /* size/bytestrobe (synch only) */
7511 +/* pcmcia_memwait */
7512 +#define PM_W0_MASK 0x3f /* waitcount0 */
7513 +#define PM_W1_MASK 0x1f00 /* waitcount1 */
7514 +#define PM_W1_SHIFT 8
7515 +#define PM_W2_MASK 0x1f0000 /* waitcount2 */
7516 +#define PM_W2_SHIFT 16
7517 +#define PM_W3_MASK 0x1f000000 /* waitcount3 */
7518 +#define PM_W3_SHIFT 24
7520 +/* pcmcia_attrwait */
7521 +#define PA_W0_MASK 0x3f /* waitcount0 */
7522 +#define PA_W1_MASK 0x1f00 /* waitcount1 */
7523 +#define PA_W1_SHIFT 8
7524 +#define PA_W2_MASK 0x1f0000 /* waitcount2 */
7525 +#define PA_W2_SHIFT 16
7526 +#define PA_W3_MASK 0x1f000000 /* waitcount3 */
7527 +#define PA_W3_SHIFT 24
7529 +/* pcmcia_iowait */
7530 +#define PI_W0_MASK 0x3f /* waitcount0 */
7531 +#define PI_W1_MASK 0x1f00 /* waitcount1 */
7532 +#define PI_W1_SHIFT 8
7533 +#define PI_W2_MASK 0x1f0000 /* waitcount2 */
7534 +#define PI_W2_SHIFT 16
7535 +#define PI_W3_MASK 0x1f000000 /* waitcount3 */
7536 +#define PI_W3_SHIFT 24
7538 +/* prog_waitcount */
7539 +#define PW_W0_MASK 0x0000001f /* waitcount0 */
7540 +#define PW_W1_MASK 0x00001f00 /* waitcount1 */
7541 +#define PW_W1_SHIFT 8
7542 +#define PW_W2_MASK 0x001f0000 /* waitcount2 */
7543 +#define PW_W2_SHIFT 16
7544 +#define PW_W3_MASK 0x1f000000 /* waitcount3 */
7545 +#define PW_W3_SHIFT 24
7547 +#define PW_W0 0x0000000c
7548 +#define PW_W1 0x00000a00
7549 +#define PW_W2 0x00020000
7550 +#define PW_W3 0x01000000
7552 +/* flash_waitcount */
7553 +#define FW_W0_MASK 0x1f /* waitcount0 */
7554 +#define FW_W1_MASK 0x1f00 /* waitcount1 */
7555 +#define FW_W1_SHIFT 8
7556 +#define FW_W2_MASK 0x1f0000 /* waitcount2 */
7557 +#define FW_W2_SHIFT 16
7558 +#define FW_W3_MASK 0x1f000000 /* waitcount3 */
7559 +#define FW_W3_SHIFT 24
7562 +#define WATCHDOG_CLOCK 48000000 /* Hz */
7564 +/* clockcontrol_n */
7565 +#define CN_N1_MASK 0x3f /* n1 control */
7566 +#define CN_N2_MASK 0x3f00 /* n2 control */
7567 +#define CN_N2_SHIFT 8
7569 +/* clockcontrol_sb/pci/mii */
7570 +#define CC_M1_MASK 0x3f /* m1 control */
7571 +#define CC_M2_MASK 0x3f00 /* m2 control */
7572 +#define CC_M2_SHIFT 8
7573 +#define CC_M3_MASK 0x3f0000 /* m3 control */
7574 +#define CC_M3_SHIFT 16
7575 +#define CC_MC_MASK 0x1f000000 /* mux control */
7576 +#define CC_MC_SHIFT 24
7578 +/* Clock control default values */
7579 +#define CC_DEF_N 0x0009 /* Default values for bcm4710 */
7580 +#define CC_DEF_100 0x04020011
7581 +#define CC_DEF_33 0x11030011
7582 +#define CC_DEF_25 0x11050011
7584 +/* Clock control values for 125Mhz */
7585 +#define CC_125_N 0x0802
7586 +#define CC_125_M 0x04020009
7587 +#define CC_125_M25 0x11090009
7588 +#define CC_125_M33 0x11090005
7590 +/* Clock control magic field values */
7591 +#define CC_F6_2 0x02 /* A factor of 2 in */
7592 +#define CC_F6_3 0x03 /* 6-bit fields like */
7593 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
7594 +#define CC_F6_5 0x09
7595 +#define CC_F6_6 0x11
7596 +#define CC_F6_7 0x21
7598 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
7600 +#define CC_MC_BYPASS 0x08
7601 +#define CC_MC_M1 0x04
7602 +#define CC_MC_M1M2 0x02
7603 +#define CC_MC_M1M2M3 0x01
7604 +#define CC_MC_M1M3 0x11
7606 +#define CC_CLOCK_BASE 24000000 /* Half the clock freq. in the 4710 */
7608 +#endif /* _SBEXTIF_H */
7609 diff -urN linux.old/arch/mips/bcm947xx/include/sbhnddma.h linux.dev/arch/mips/bcm947xx/include/sbhnddma.h
7610 --- linux.old/arch/mips/bcm947xx/include/sbhnddma.h 1970-01-01 01:00:00.000000000 +0100
7611 +++ linux.dev/arch/mips/bcm947xx/include/sbhnddma.h 2005-11-07 23:37:03.453685750 +0100
7614 + * Generic Broadcom Home Networking Division (HND) DMA engine HW interface
7615 + * This supports the following chips: BCM42xx, 44xx, 47xx .
7617 + * Copyright 2005, Broadcom Corporation
7618 + * All Rights Reserved.
7620 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7621 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7622 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7623 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7627 +#ifndef _sbhnddma_h_
7628 +#define _sbhnddma_h_
7631 +/* 2byte-wide pio register set per channel(xmt or rcv) */
7632 +typedef volatile struct {
7633 + uint16 fifocontrol;
7635 + uint16 fifofree; /* only valid in xmt channel, not in rcv channel */
7639 +/* a pair of pio channels(tx and rx) */
7640 +typedef volatile struct {
7645 +/* 4byte-wide pio register set per channel(xmt or rcv) */
7646 +typedef volatile struct {
7647 + uint32 fifocontrol;
7651 +/* a pair of pio channels(tx and rx) */
7652 +typedef volatile struct {
7660 + * support two DMA engines: 32 bits address or 64 bit addressing
7661 + * basic DMA register set is per channel(transmit or receive)
7662 + * a pair of channels is defined for convenience
7666 +/*** 32 bits addressing ***/
7668 +/* dma registers per channel(xmt or rcv) */
7669 +typedef volatile struct {
7670 + uint32 control; /* enable, et al */
7671 + uint32 addr; /* descriptor ring base address (4K aligned) */
7672 + uint32 ptr; /* last descriptor posted to chip */
7673 + uint32 status; /* current active descriptor, et al */
7676 +typedef volatile struct {
7677 + dma32regs_t xmt; /* dma tx channel */
7678 + dma32regs_t rcv; /* dma rx channel */
7681 +typedef volatile struct { /* diag access */
7682 + uint32 fifoaddr; /* diag address */
7683 + uint32 fifodatalow; /* low 32bits of data */
7684 + uint32 fifodatahigh; /* high 32bits of data */
7685 + uint32 pad; /* reserved */
7690 + * Descriptors are only read by the hardware, never written back.
7692 +typedef volatile struct {
7693 + uint32 ctrl; /* misc control bits & bufcount */
7694 + uint32 addr; /* data buffer address */
7698 + * Each descriptor ring must be 4096byte aligned, and fit within a single 4096byte page.
7700 +#define D32MAXRINGSZ 4096
7701 +#define D32RINGALIGN 4096
7702 +#define D32MAXDD (D32MAXRINGSZ / sizeof (dma32dd_t))
7704 +/* transmit channel control */
7705 +#define XC_XE ((uint32)1 << 0) /* transmit enable */
7706 +#define XC_SE ((uint32)1 << 1) /* transmit suspend request */
7707 +#define XC_LE ((uint32)1 << 2) /* loopback enable */
7708 +#define XC_FL ((uint32)1 << 4) /* flush request */
7709 +#define XC_AE ((uint32)3 << 16) /* address extension bits */
7710 +#define XC_AE_SHIFT 16
7712 +/* transmit descriptor table pointer */
7713 +#define XP_LD_MASK 0xfff /* last valid descriptor */
7715 +/* transmit channel status */
7716 +#define XS_CD_MASK 0x0fff /* current descriptor pointer */
7717 +#define XS_XS_MASK 0xf000 /* transmit state */
7718 +#define XS_XS_SHIFT 12
7719 +#define XS_XS_DISABLED 0x0000 /* disabled */
7720 +#define XS_XS_ACTIVE 0x1000 /* active */
7721 +#define XS_XS_IDLE 0x2000 /* idle wait */
7722 +#define XS_XS_STOPPED 0x3000 /* stopped */
7723 +#define XS_XS_SUSP 0x4000 /* suspend pending */
7724 +#define XS_XE_MASK 0xf0000 /* transmit errors */
7725 +#define XS_XE_SHIFT 16
7726 +#define XS_XE_NOERR 0x00000 /* no error */
7727 +#define XS_XE_DPE 0x10000 /* descriptor protocol error */
7728 +#define XS_XE_DFU 0x20000 /* data fifo underrun */
7729 +#define XS_XE_BEBR 0x30000 /* bus error on buffer read */
7730 +#define XS_XE_BEDA 0x40000 /* bus error on descriptor access */
7731 +#define XS_AD_MASK 0xfff00000 /* active descriptor */
7732 +#define XS_AD_SHIFT 20
7734 +/* receive channel control */
7735 +#define RC_RE ((uint32)1 << 0) /* receive enable */
7736 +#define RC_RO_MASK 0xfe /* receive frame offset */
7737 +#define RC_RO_SHIFT 1
7738 +#define RC_FM ((uint32)1 << 8) /* direct fifo receive (pio) mode */
7739 +#define RC_AE ((uint32)3 << 16) /* address extension bits */
7740 +#define RC_AE_SHIFT 16
7742 +/* receive descriptor table pointer */
7743 +#define RP_LD_MASK 0xfff /* last valid descriptor */
7745 +/* receive channel status */
7746 +#define RS_CD_MASK 0x0fff /* current descriptor pointer */
7747 +#define RS_RS_MASK 0xf000 /* receive state */
7748 +#define RS_RS_SHIFT 12
7749 +#define RS_RS_DISABLED 0x0000 /* disabled */
7750 +#define RS_RS_ACTIVE 0x1000 /* active */
7751 +#define RS_RS_IDLE 0x2000 /* idle wait */
7752 +#define RS_RS_STOPPED 0x3000 /* reserved */
7753 +#define RS_RE_MASK 0xf0000 /* receive errors */
7754 +#define RS_RE_SHIFT 16
7755 +#define RS_RE_NOERR 0x00000 /* no error */
7756 +#define RS_RE_DPE 0x10000 /* descriptor protocol error */
7757 +#define RS_RE_DFO 0x20000 /* data fifo overflow */
7758 +#define RS_RE_BEBW 0x30000 /* bus error on buffer write */
7759 +#define RS_RE_BEDA 0x40000 /* bus error on descriptor access */
7760 +#define RS_AD_MASK 0xfff00000 /* active descriptor */
7761 +#define RS_AD_SHIFT 20
7764 +#define FA_OFF_MASK 0xffff /* offset */
7765 +#define FA_SEL_MASK 0xf0000 /* select */
7766 +#define FA_SEL_SHIFT 16
7767 +#define FA_SEL_XDD 0x00000 /* transmit dma data */
7768 +#define FA_SEL_XDP 0x10000 /* transmit dma pointers */
7769 +#define FA_SEL_RDD 0x40000 /* receive dma data */
7770 +#define FA_SEL_RDP 0x50000 /* receive dma pointers */
7771 +#define FA_SEL_XFD 0x80000 /* transmit fifo data */
7772 +#define FA_SEL_XFP 0x90000 /* transmit fifo pointers */
7773 +#define FA_SEL_RFD 0xc0000 /* receive fifo data */
7774 +#define FA_SEL_RFP 0xd0000 /* receive fifo pointers */
7775 +#define FA_SEL_RSD 0xe0000 /* receive frame status data */
7776 +#define FA_SEL_RSP 0xf0000 /* receive frame status pointers */
7778 +/* descriptor control flags */
7779 +#define CTRL_BC_MASK 0x1fff /* buffer byte count */
7780 +#define CTRL_AE ((uint32)3 << 16) /* address extension bits */
7781 +#define CTRL_AE_SHIFT 16
7782 +#define CTRL_EOT ((uint32)1 << 28) /* end of descriptor table */
7783 +#define CTRL_IOC ((uint32)1 << 29) /* interrupt on completion */
7784 +#define CTRL_EOF ((uint32)1 << 30) /* end of frame */
7785 +#define CTRL_SOF ((uint32)1 << 31) /* start of frame */
7787 +/* control flags in the range [27:20] are core-specific and not defined here */
7788 +#define CTRL_CORE_MASK 0x0ff00000
7790 +/*** 64 bits addressing ***/
7792 +/* dma registers per channel(xmt or rcv) */
7793 +typedef volatile struct {
7794 + uint32 control; /* enable, et al */
7795 + uint32 ptr; /* last descriptor posted to chip */
7796 + uint32 addrlow; /* descriptor ring base address low 32-bits (8K aligned) */
7797 + uint32 addrhigh; /* descriptor ring base address bits 63:32 (8K aligned) */
7798 + uint32 status0; /* current descriptor, xmt state */
7799 + uint32 status1; /* active descriptor, xmt error */
7802 +typedef volatile struct {
7803 + dma64regs_t tx; /* dma64 tx channel */
7804 + dma64regs_t rx; /* dma64 rx channel */
7807 +typedef volatile struct { /* diag access */
7808 + uint32 fifoaddr; /* diag address */
7809 + uint32 fifodatalow; /* low 32bits of data */
7810 + uint32 fifodatahigh; /* high 32bits of data */
7811 + uint32 pad; /* reserved */
7816 + * Descriptors are only read by the hardware, never written back.
7818 +typedef volatile struct {
7819 + uint32 ctrl1; /* misc control bits & bufcount */
7820 + uint32 ctrl2; /* buffer count and address extension */
7821 + uint32 addrlow; /* memory address of the first byte of the date buffer, bits 31:0 */
7822 + uint32 addrhigh; /* memory address of the first byte of the date buffer, bits 63:32 */
7826 + * Each descriptor ring must be 8kB aligned, and fit within a contiguous 8kB physical addresss.
7828 +#define D64MAXRINGSZ 8192
7829 +#define D64RINGALIGN 8192
7830 +#define D64MAXDD (D64MAXRINGSZ / sizeof (dma64dd_t))
7832 +/* transmit channel control */
7833 +#define D64_XC_XE 0x00000001 /* transmit enable */
7834 +#define D64_XC_SE 0x00000002 /* transmit suspend request */
7835 +#define D64_XC_LE 0x00000004 /* loopback enable */
7836 +#define D64_XC_FL 0x00000010 /* flush request */
7837 +#define D64_XC_AE 0x00110000 /* address extension bits */
7838 +#define D64_XC_AE_SHIFT 16
7840 +/* transmit descriptor table pointer */
7841 +#define D64_XP_LD_MASK 0x00000fff /* last valid descriptor */
7843 +/* transmit channel status */
7844 +#define D64_XS0_CD_MASK 0x00001fff /* current descriptor pointer */
7845 +#define D64_XS0_XS_MASK 0xf0000000 /* transmit state */
7846 +#define D64_XS0_XS_SHIFT 28
7847 +#define D64_XS0_XS_DISABLED 0x00000000 /* disabled */
7848 +#define D64_XS0_XS_ACTIVE 0x10000000 /* active */
7849 +#define D64_XS0_XS_IDLE 0x20000000 /* idle wait */
7850 +#define D64_XS0_XS_STOPPED 0x30000000 /* stopped */
7851 +#define D64_XS0_XS_SUSP 0x40000000 /* suspend pending */
7853 +#define D64_XS1_AD_MASK 0x0001ffff /* active descriptor */
7854 +#define D64_XS1_XE_MASK 0xf0000000 /* transmit errors */
7855 +#define D64_XS1_XE_SHIFT 28
7856 +#define D64_XS1_XE_NOERR 0x00000000 /* no error */
7857 +#define D64_XS1_XE_DPE 0x10000000 /* descriptor protocol error */
7858 +#define D64_XS1_XE_DFU 0x20000000 /* data fifo underrun */
7859 +#define D64_XS1_XE_DTE 0x30000000 /* data transfer error */
7860 +#define D64_XS1_XE_DESRE 0x40000000 /* descriptor read error */
7861 +#define D64_XS1_XE_COREE 0x50000000 /* core error */
7863 +/* receive channel control */
7864 +#define D64_RC_RE 0x00000001 /* receive enable */
7865 +#define D64_RC_RO_MASK 0x000000fe /* receive frame offset */
7866 +#define D64_RC_RO_SHIFT 1
7867 +#define D64_RC_FM 0x00000100 /* direct fifo receive (pio) mode */
7868 +#define D64_RC_AE 0x00110000 /* address extension bits */
7869 +#define D64_RC_AE_SHIFT 16
7871 +/* receive descriptor table pointer */
7872 +#define D64_RP_LD_MASK 0x00000fff /* last valid descriptor */
7874 +/* receive channel status */
7875 +#define D64_RS0_CD_MASK 0x00001fff /* current descriptor pointer */
7876 +#define D64_RS0_RS_MASK 0xf0000000 /* receive state */
7877 +#define D64_RS0_RS_SHIFT 28
7878 +#define D64_RS0_RS_DISABLED 0x00000000 /* disabled */
7879 +#define D64_RS0_RS_ACTIVE 0x10000000 /* active */
7880 +#define D64_RS0_RS_IDLE 0x20000000 /* idle wait */
7881 +#define D64_RS0_RS_STOPPED 0x30000000 /* stopped */
7882 +#define D64_RS0_RS_SUSP 0x40000000 /* suspend pending */
7884 +#define D64_RS1_AD_MASK 0x0001ffff /* active descriptor */
7885 +#define D64_RS1_RE_MASK 0xf0000000 /* receive errors */
7886 +#define D64_RS1_RE_SHIFT 28
7887 +#define D64_RS1_RE_NOERR 0x00000000 /* no error */
7888 +#define D64_RS1_RE_DPO 0x10000000 /* descriptor protocol error */
7889 +#define D64_RS1_RE_DFU 0x20000000 /* data fifo overflow */
7890 +#define D64_RS1_RE_DTE 0x30000000 /* data transfer error */
7891 +#define D64_RS1_RE_DESRE 0x40000000 /* descriptor read error */
7892 +#define D64_RS1_RE_COREE 0x50000000 /* core error */
7895 +#define D64_FA_OFF_MASK 0xffff /* offset */
7896 +#define D64_FA_SEL_MASK 0xf0000 /* select */
7897 +#define D64_FA_SEL_SHIFT 16
7898 +#define D64_FA_SEL_XDD 0x00000 /* transmit dma data */
7899 +#define D64_FA_SEL_XDP 0x10000 /* transmit dma pointers */
7900 +#define D64_FA_SEL_RDD 0x40000 /* receive dma data */
7901 +#define D64_FA_SEL_RDP 0x50000 /* receive dma pointers */
7902 +#define D64_FA_SEL_XFD 0x80000 /* transmit fifo data */
7903 +#define D64_FA_SEL_XFP 0x90000 /* transmit fifo pointers */
7904 +#define D64_FA_SEL_RFD 0xc0000 /* receive fifo data */
7905 +#define D64_FA_SEL_RFP 0xd0000 /* receive fifo pointers */
7906 +#define D64_FA_SEL_RSD 0xe0000 /* receive frame status data */
7907 +#define D64_FA_SEL_RSP 0xf0000 /* receive frame status pointers */
7909 +/* descriptor control flags 1 */
7910 +#define D64_CTRL1_EOT ((uint32)1 << 28) /* end of descriptor table */
7911 +#define D64_CTRL1_IOC ((uint32)1 << 29) /* interrupt on completion */
7912 +#define D64_CTRL1_EOF ((uint32)1 << 30) /* end of frame */
7913 +#define D64_CTRL1_SOF ((uint32)1 << 31) /* start of frame */
7915 +/* descriptor control flags 2 */
7916 +#define D64_CTRL2_BC_MASK 0x00007fff /* buffer byte count mask */
7917 +#define D64_CTRL2_AE 0x00110000 /* address extension bits */
7918 +#define D64_CTRL2_AE_SHIFT 16
7920 +/* control flags in the range [27:20] are core-specific and not defined here */
7921 +#define D64_CTRL_CORE_MASK 0x0ff00000
7924 +#endif /* _sbhnddma_h_ */
7925 diff -urN linux.old/arch/mips/bcm947xx/include/sbmemc.h linux.dev/arch/mips/bcm947xx/include/sbmemc.h
7926 --- linux.old/arch/mips/bcm947xx/include/sbmemc.h 1970-01-01 01:00:00.000000000 +0100
7927 +++ linux.dev/arch/mips/bcm947xx/include/sbmemc.h 2005-11-07 22:51:38.784726500 +0100
7930 + * BCM47XX Sonics SiliconBackplane DDR/SDRAM controller core hardware definitions.
7932 + * Copyright 2005, Broadcom Corporation
7933 + * All Rights Reserved.
7935 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7936 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7937 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7938 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7946 +#ifdef _LANGUAGE_ASSEMBLY
7948 +#define MEMC_CONTROL 0x00
7949 +#define MEMC_CONFIG 0x04
7950 +#define MEMC_REFRESH 0x08
7951 +#define MEMC_BISTSTAT 0x0c
7952 +#define MEMC_MODEBUF 0x10
7953 +#define MEMC_BKCLS 0x14
7954 +#define MEMC_PRIORINV 0x18
7955 +#define MEMC_DRAMTIM 0x1c
7956 +#define MEMC_INTSTAT 0x20
7957 +#define MEMC_INTMASK 0x24
7958 +#define MEMC_INTINFO 0x28
7959 +#define MEMC_NCDLCTL 0x30
7960 +#define MEMC_RDNCDLCOR 0x34
7961 +#define MEMC_WRNCDLCOR 0x38
7962 +#define MEMC_MISCDLYCTL 0x3c
7963 +#define MEMC_DQSGATENCDL 0x40
7964 +#define MEMC_SPARE 0x44
7965 +#define MEMC_TPADDR 0x48
7966 +#define MEMC_TPDATA 0x4c
7967 +#define MEMC_BARRIER 0x50
7968 +#define MEMC_CORE 0x54
7973 +/* Sonics side: MEMC core registers */
7974 +typedef volatile struct sbmemcregs {
7990 + uint32 miscdlyctl;
7991 + uint32 dqsgatencdl;
8001 +/* MEMC Core Init values (OCP ID 0x80f) */
8004 +#define MEMC_SD_CONFIG_INIT 0x00048000
8005 +#define MEMC_SD_DRAMTIM2_INIT 0x000754d8
8006 +#define MEMC_SD_DRAMTIM3_INIT 0x000754da
8007 +#define MEMC_SD_RDNCDLCOR_INIT 0x00000000
8008 +#define MEMC_SD_WRNCDLCOR_INIT 0x49351200
8009 +#define MEMC_SD1_WRNCDLCOR_INIT 0x14500200 /* For corerev 1 (4712) */
8010 +#define MEMC_SD_MISCDLYCTL_INIT 0x00061c1b
8011 +#define MEMC_SD1_MISCDLYCTL_INIT 0x00021416 /* For corerev 1 (4712) */
8012 +#define MEMC_SD_CONTROL_INIT0 0x00000002
8013 +#define MEMC_SD_CONTROL_INIT1 0x00000008
8014 +#define MEMC_SD_CONTROL_INIT2 0x00000004
8015 +#define MEMC_SD_CONTROL_INIT3 0x00000010
8016 +#define MEMC_SD_CONTROL_INIT4 0x00000001
8017 +#define MEMC_SD_MODEBUF_INIT 0x00000000
8018 +#define MEMC_SD_REFRESH_INIT 0x0000840f
8021 +/* This is for SDRM8X8X4 */
8022 +#define MEMC_SDR_INIT 0x0008
8023 +#define MEMC_SDR_MODE 0x32
8024 +#define MEMC_SDR_NCDL 0x00020032
8025 +#define MEMC_SDR1_NCDL 0x0002020f /* For corerev 1 (4712) */
8028 +#define MEMC_CONFIG_INIT 0x00048000
8029 +#define MEMC_DRAMTIM2_INIT 0x000754d8
8030 +#define MEMC_DRAMTIM25_INIT 0x000754d9
8031 +#define MEMC_RDNCDLCOR_INIT 0x00000000
8032 +#define MEMC_RDNCDLCOR_SIMINIT 0xf6f6f6f6 /* For hdl sim */
8033 +#define MEMC_WRNCDLCOR_INIT 0x49351200
8034 +#define MEMC_1_WRNCDLCOR_INIT 0x14500200
8035 +#define MEMC_DQSGATENCDL_INIT 0x00030000
8036 +#define MEMC_MISCDLYCTL_INIT 0x21061c1b
8037 +#define MEMC_1_MISCDLYCTL_INIT 0x21021400
8038 +#define MEMC_NCDLCTL_INIT 0x00002001
8039 +#define MEMC_CONTROL_INIT0 0x00000002
8040 +#define MEMC_CONTROL_INIT1 0x00000008
8041 +#define MEMC_MODEBUF_INIT0 0x00004000
8042 +#define MEMC_CONTROL_INIT2 0x00000010
8043 +#define MEMC_MODEBUF_INIT1 0x00000100
8044 +#define MEMC_CONTROL_INIT3 0x00000010
8045 +#define MEMC_CONTROL_INIT4 0x00000008
8046 +#define MEMC_REFRESH_INIT 0x0000840f
8047 +#define MEMC_CONTROL_INIT5 0x00000004
8048 +#define MEMC_MODEBUF_INIT2 0x00000000
8049 +#define MEMC_CONTROL_INIT6 0x00000010
8050 +#define MEMC_CONTROL_INIT7 0x00000001
8053 +/* This is for DDRM16X16X2 */
8054 +#define MEMC_DDR_INIT 0x0009
8055 +#define MEMC_DDR_MODE 0x62
8056 +#define MEMC_DDR_NCDL 0x0005050a
8057 +#define MEMC_DDR1_NCDL 0x00000a0a /* For corerev 1 (4712) */
8059 +/* mask for sdr/ddr calibration registers */
8060 +#define MEMC_RDNCDLCOR_RD_MASK 0x000000ff
8061 +#define MEMC_WRNCDLCOR_WR_MASK 0x000000ff
8062 +#define MEMC_DQSGATENCDL_G_MASK 0x000000ff
8064 +/* masks for miscdlyctl registers */
8065 +#define MEMC_MISC_SM_MASK 0x30000000
8066 +#define MEMC_MISC_SM_SHIFT 28
8067 +#define MEMC_MISC_SD_MASK 0x0f000000
8068 +#define MEMC_MISC_SD_SHIFT 24
8070 +/* hw threshhold for calculating wr/rd for sdr memc */
8071 +#define MEMC_CD_THRESHOLD 128
8073 +/* Low bit of init register says if memc is ddr or sdr */
8074 +#define MEMC_CONFIG_DDR 0x00000001
8076 +#endif /* _SBMEMC_H */
8077 diff -urN linux.old/arch/mips/bcm947xx/include/sbmips.h linux.dev/arch/mips/bcm947xx/include/sbmips.h
8078 --- linux.old/arch/mips/bcm947xx/include/sbmips.h 1970-01-01 01:00:00.000000000 +0100
8079 +++ linux.dev/arch/mips/bcm947xx/include/sbmips.h 2005-11-07 22:51:38.784726500 +0100
8082 + * Broadcom SiliconBackplane MIPS definitions
8084 + * SB MIPS cores are custom MIPS32 processors with SiliconBackplane
8085 + * OCP interfaces. The CP0 processor ID is 0x00024000, where bits
8086 + * 23:16 mean Broadcom and bits 15:8 mean a MIPS core with an OCP
8087 + * interface. The core revision is stored in the SB ID register in SB
8088 + * configuration space.
8090 + * Copyright 2005, Broadcom Corporation
8091 + * All Rights Reserved.
8093 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8094 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8095 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8096 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8104 +#include <mipsinc.h>
8106 +#ifndef _LANGUAGE_ASSEMBLY
8108 +/* cpp contortions to concatenate w/arg prescan */
8110 +#define _PADLINE(line) pad ## line
8111 +#define _XSTR(line) _PADLINE(line)
8112 +#define PAD _XSTR(__LINE__)
8115 +typedef volatile struct {
8116 + uint32 corecontrol;
8118 + uint32 biststatus;
8125 +extern uint32 sb_flag(sb_t *sbh);
8126 +extern uint sb_irq(sb_t *sbh);
8128 +extern void BCMINIT(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift));
8130 +extern void *sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap);
8131 +extern void sb_jtagm_disable(void *h);
8132 +extern uint32 jtag_rwreg(void *h, uint32 ir, uint32 dr);
8133 +extern void BCMINIT(sb_mips_init)(sb_t *sbh);
8134 +extern uint32 BCMINIT(sb_mips_clock)(sb_t *sbh);
8135 +extern bool BCMINIT(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock);
8136 +extern void BCMINIT(enable_pfc)(uint32 mode);
8137 +extern uint32 BCMINIT(sb_memc_get_ncdl)(sb_t *sbh);
8140 +#endif /* _LANGUAGE_ASSEMBLY */
8142 +#endif /* _SBMIPS_H */
8143 diff -urN linux.old/arch/mips/bcm947xx/include/sbpci.h linux.dev/arch/mips/bcm947xx/include/sbpci.h
8144 --- linux.old/arch/mips/bcm947xx/include/sbpci.h 1970-01-01 01:00:00.000000000 +0100
8145 +++ linux.dev/arch/mips/bcm947xx/include/sbpci.h 2005-11-07 22:51:38.788726750 +0100
8148 + * BCM47XX Sonics SiliconBackplane PCI core hardware definitions.
8151 + * Copyright 2005, Broadcom Corporation
8152 + * All Rights Reserved.
8154 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8155 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8156 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8157 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8163 +/* cpp contortions to concatenate w/arg prescan */
8165 +#define _PADLINE(line) pad ## line
8166 +#define _XSTR(line) _PADLINE(line)
8167 +#define PAD _XSTR(__LINE__)
8170 +/* Sonics side: PCI core and host control registers */
8171 +typedef struct sbpciregs {
8172 + uint32 control; /* PCI control */
8174 + uint32 arbcontrol; /* PCI arbiter control */
8176 + uint32 intstatus; /* Interrupt status */
8177 + uint32 intmask; /* Interrupt mask */
8178 + uint32 sbtopcimailbox; /* Sonics to PCI mailbox */
8180 + uint32 bcastaddr; /* Sonics broadcast address */
8181 + uint32 bcastdata; /* Sonics broadcast data */
8183 + uint32 gpioin; /* ro: gpio input (>=rev2) */
8184 + uint32 gpioout; /* rw: gpio output (>=rev2) */
8185 + uint32 gpioouten; /* rw: gpio output enable (>= rev2) */
8186 + uint32 gpiocontrol; /* rw: gpio control (>= rev2) */
8188 + uint32 sbtopci0; /* Sonics to PCI translation 0 */
8189 + uint32 sbtopci1; /* Sonics to PCI translation 1 */
8190 + uint32 sbtopci2; /* Sonics to PCI translation 2 */
8192 + uint16 sprom[36]; /* SPROM shadow Area */
8197 +#define PCI_RST_OE 0x01 /* When set, drives PCI_RESET out to pin */
8198 +#define PCI_RST 0x02 /* Value driven out to pin */
8199 +#define PCI_CLK_OE 0x04 /* When set, drives clock as gated by PCI_CLK out to pin */
8200 +#define PCI_CLK 0x08 /* Gate for clock driven out to pin */
8202 +/* PCI arbiter control */
8203 +#define PCI_INT_ARB 0x01 /* When set, use an internal arbiter */
8204 +#define PCI_EXT_ARB 0x02 /* When set, use an external arbiter */
8205 +#define PCI_PARKID_MASK 0x06 /* Selects which agent is parked on an idle bus */
8206 +#define PCI_PARKID_SHIFT 1
8207 +#define PCI_PARKID_LAST 0 /* Last requestor */
8208 +#define PCI_PARKID_4710 1 /* 4710 */
8209 +#define PCI_PARKID_EXTREQ0 2 /* External requestor 0 */
8210 +#define PCI_PARKID_EXTREQ1 3 /* External requestor 1 */
8212 +/* Interrupt status/mask */
8213 +#define PCI_INTA 0x01 /* PCI INTA# is asserted */
8214 +#define PCI_INTB 0x02 /* PCI INTB# is asserted */
8215 +#define PCI_SERR 0x04 /* PCI SERR# has been asserted (write one to clear) */
8216 +#define PCI_PERR 0x08 /* PCI PERR# has been asserted (write one to clear) */
8217 +#define PCI_PME 0x10 /* PCI PME# is asserted */
8219 +/* (General) PCI/SB mailbox interrupts, two bits per pci function */
8220 +#define MAILBOX_F0_0 0x100 /* function 0, int 0 */
8221 +#define MAILBOX_F0_1 0x200 /* function 0, int 1 */
8222 +#define MAILBOX_F1_0 0x400 /* function 1, int 0 */
8223 +#define MAILBOX_F1_1 0x800 /* function 1, int 1 */
8224 +#define MAILBOX_F2_0 0x1000 /* function 2, int 0 */
8225 +#define MAILBOX_F2_1 0x2000 /* function 2, int 1 */
8226 +#define MAILBOX_F3_0 0x4000 /* function 3, int 0 */
8227 +#define MAILBOX_F3_1 0x8000 /* function 3, int 1 */
8229 +/* Sonics broadcast address */
8230 +#define BCAST_ADDR_MASK 0xff /* Broadcast register address */
8232 +/* Sonics to PCI translation types */
8233 +#define SBTOPCI0_MASK 0xfc000000
8234 +#define SBTOPCI1_MASK 0xfc000000
8235 +#define SBTOPCI2_MASK 0xc0000000
8236 +#define SBTOPCI_MEM 0
8237 +#define SBTOPCI_IO 1
8238 +#define SBTOPCI_CFG0 2
8239 +#define SBTOPCI_CFG1 3
8240 +#define SBTOPCI_PREF 0x4 /* prefetch enable */
8241 +#define SBTOPCI_BURST 0x8 /* burst enable */
8242 +#define SBTOPCI_RC_MASK 0x30 /* read command (>= rev11) */
8243 +#define SBTOPCI_RC_READ 0x00 /* memory read */
8244 +#define SBTOPCI_RC_READLINE 0x10 /* memory read line */
8245 +#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */
8247 +/* PCI core index in SROM shadow area */
8248 +#define SRSH_PI_OFFSET 0 /* first word */
8249 +#define SRSH_PI_MASK 0xf000 /* bit 15:12 */
8250 +#define SRSH_PI_SHIFT 12 /* bit 15:12 */
8252 +/* PCI side: Reserved PCI configuration registers (see pcicfg.h) */
8253 +#define cap_list rsvd_a[0]
8254 +#define bar0_window dev_dep[0x80 - 0x40]
8255 +#define bar1_window dev_dep[0x84 - 0x40]
8256 +#define sprom_control dev_dep[0x88 - 0x40]
8258 +#ifndef _LANGUAGE_ASSEMBLY
8260 +extern int sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
8261 +extern int sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
8262 +extern void sbpci_ban(uint16 core);
8263 +extern int sbpci_init(sb_t *sbh);
8264 +extern void sbpci_check(sb_t *sbh);
8266 +#endif /* !_LANGUAGE_ASSEMBLY */
8268 +#endif /* _SBPCI_H */
8269 diff -urN linux.old/arch/mips/bcm947xx/include/sbpcie.h linux.dev/arch/mips/bcm947xx/include/sbpcie.h
8270 --- linux.old/arch/mips/bcm947xx/include/sbpcie.h 1970-01-01 01:00:00.000000000 +0100
8271 +++ linux.dev/arch/mips/bcm947xx/include/sbpcie.h 2005-11-07 23:39:41.403557000 +0100
8274 + * BCM43XX SiliconBackplane PCIE core hardware definitions.
8277 + * Copyright 2005, Broadcom Corporation
8278 + * All Rights Reserved.
8280 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8281 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8282 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8283 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8289 +/* cpp contortions to concatenate w/arg prescan */
8291 +#define _PADLINE(line) pad ## line
8292 +#define _XSTR(line) _PADLINE(line)
8293 +#define PAD _XSTR(__LINE__)
8296 +/* PCIE Enumeration space offsets*/
8297 +#define PCIE_CORE_CONFIG_OFFSET 0x0
8298 +#define PCIE_FUNC0_CONFIG_OFFSET 0x400
8299 +#define PCIE_FUNC1_CONFIG_OFFSET 0x500
8300 +#define PCIE_FUNC2_CONFIG_OFFSET 0x600
8301 +#define PCIE_FUNC3_CONFIG_OFFSET 0x700
8302 +#define PCIE_SPROM_SHADOW_OFFSET 0x800
8303 +#define PCIE_SBCONFIG_OFFSET 0xE00
8305 +/* PCIE Bar0 Address Mapping. Each function maps 16KB config space */
8306 +#define PCIE_BAR0_WINMAPCORE_OFFSET 0x0
8307 +#define PCIE_BAR0_EXTSPROM_OFFSET 0x1000
8308 +#define PCIE_BAR0_PCIECORE_OFFSET 0x2000
8309 +#define PCIE_BAR0_CCCOREREG_OFFSET 0x3000
8311 +/* SB side: PCIE core and host control registers */
8312 +typedef struct sbpcieregs {
8315 + uint32 biststatus; /* bist Status: 0x00C*/
8317 + uint32 sbtopcimailbox; /* sb to pcie mailbox: 0x028*/
8319 + uint32 sbtopcie0; /* sb to pcie translation 0: 0x100 */
8320 + uint32 sbtopcie1; /* sb to pcie translation 1: 0x104 */
8321 + uint32 sbtopcie2; /* sb to pcie translation 2: 0x108 */
8324 + /* pcie core supports in direct access to config space */
8325 + uint32 configaddr; /* pcie config space access: Address field: 0x120*/
8326 + uint32 configdata; /* pcie config space access: Data field: 0x124*/
8328 + /* mdio access to serdes */
8329 + uint32 mdiocontrol; /* controls the mdio access: 0x128 */
8330 + uint32 mdiodata; /* Data to the mdio access: 0x12c */
8332 + /* pcie protocol phy/dllp/tlp register access mechanism*/
8333 + uint32 pcieaddr; /* address of the internal registeru: 0x130 */
8334 + uint32 pciedata; /* Data to/from the internal regsiter: 0x134 */
8337 + uint16 sprom[36]; /* SPROM shadow Area */
8340 +/* SB to PCIE translation masks */
8341 +#define SBTOPCIE0_MASK 0xfc000000
8342 +#define SBTOPCIE1_MASK 0xfc000000
8343 +#define SBTOPCIE2_MASK 0xc0000000
8345 +/* Access type bits (0:1)*/
8346 +#define SBTOPCIE_MEM 0
8347 +#define SBTOPCIE_IO 1
8348 +#define SBTOPCIE_CFG0 2
8349 +#define SBTOPCIE_CFG1 3
8351 +/*Prefetch enable bit 2*/
8352 +#define SBTOPCIE_PF 4
8354 +/*Write Burst enable for memory write bit 3*/
8355 +#define SBTOPCIE_WR_BURST 8
8357 +/* config access */
8358 +#define CONFIGADDR_FUNC_MASK 0x7000
8359 +#define CONFIGADDR_FUNC_SHF 12
8360 +#define CONFIGADDR_REG_MASK 0x0FFF
8361 +#define CONFIGADDR_REG_SHF 0
8363 +/* PCIE protocol regs Indirect Address */
8364 +#define PCIEADDR_PROT_MASK 0x300
8365 +#define PCIEADDR_PROT_SHF 8
8366 +#define PCIEADDR_PL_TLP 0
8367 +#define PCIEADDR_PL_DLLP 1
8368 +#define PCIEADDR_PL_PLP 2
8370 +/* PCIE protocol PHY diagnostic registers */
8371 +#define PCIE_PLP_MODEREG 0x200 /* Mode*/
8372 +#define PCIE_PLP_STATUSREG 0x204 /* Status*/
8373 +#define PCIE_PLP_LTSSMCTRLREG 0x208 /* LTSSM control */
8374 +#define PCIE_PLP_LTLINKNUMREG 0x20c /* Link Training Link number*/
8375 +#define PCIE_PLP_LTLANENUMREG 0x210 /* Link Training Lane number*/
8376 +#define PCIE_PLP_LTNFTSREG 0x214 /* Link Training N_FTS */
8377 +#define PCIE_PLP_ATTNREG 0x218 /* Attention */
8378 +#define PCIE_PLP_ATTNMASKREG 0x21C /* Attention Mask */
8379 +#define PCIE_PLP_RXERRCTR 0x220 /* Rx Error */
8380 +#define PCIE_PLP_RXFRMERRCTR 0x224 /* Rx Framing Error*/
8381 +#define PCIE_PLP_RXERRTHRESHREG 0x228 /* Rx Error threshold */
8382 +#define PCIE_PLP_TESTCTRLREG 0x22C /* Test Control reg*/
8383 +#define PCIE_PLP_SERDESCTRLOVRDREG 0x230 /* SERDES Control Override */
8384 +#define PCIE_PLP_TIMINGOVRDREG 0x234 /* Timing param override */
8385 +#define PCIE_PLP_RXTXSMDIAGREG 0x238 /* RXTX State Machine Diag*/
8386 +#define PCIE_PLP_LTSSMDIAGREG 0x23C /* LTSSM State Machine Diag*/
8388 +/* PCIE protocol DLLP diagnostic registers */
8389 +#define PCIE_DLLP_LCREG 0x100 /* Link Control*/
8390 +#define PCIE_DLLP_LSREG 0x104 /* Link Status */
8391 +#define PCIE_DLLP_LAREG 0x108 /* Link Attention*/
8392 +#define PCIE_DLLP_LAMASKREG 0x10C /* Link Attention Mask */
8393 +#define PCIE_DLLP_NEXTTXSEQNUMREG 0x110 /* Next Tx Seq Num*/
8394 +#define PCIE_DLLP_ACKEDTXSEQNUMREG 0x114 /* Acked Tx Seq Num*/
8395 +#define PCIE_DLLP_PURGEDTXSEQNUMREG 0x118 /* Purged Tx Seq Num*/
8396 +#define PCIE_DLLP_RXSEQNUMREG 0x11C /* Rx Sequence Number */
8397 +#define PCIE_DLLP_LRREG 0x120 /* Link Replay*/
8398 +#define PCIE_DLLP_LACKTOREG 0x124 /* Link Ack Timeout*/
8399 +#define PCIE_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold*/
8400 +#define PCIE_DLLP_RTRYWPREG 0x12C /* Retry buffer write ptr*/
8401 +#define PCIE_DLLP_RTRYRPREG 0x130 /* Retry buffer Read ptr*/
8402 +#define PCIE_DLLP_RTRYPPREG 0x134 /* Retry buffer Purged ptr*/
8403 +#define PCIE_DLLP_RTRRWREG 0x138 /* Retry buffer Read/Write*/
8404 +#define PCIE_DLLP_ECTHRESHREG 0x13C /* Error Count Threshold */
8405 +#define PCIE_DLLP_TLPERRCTRREG 0x140 /* TLP Error Counter */
8406 +#define PCIE_DLLP_ERRCTRREG 0x144 /* Error Counter*/
8407 +#define PCIE_DLLP_NAKRXCTRREG 0x148 /* NAK Received Counter*/
8408 +#define PCIE_DLLP_TESTREG 0x14C /* Test */
8409 +#define PCIE_DLLP_PKTBIST 0x150 /* Packet BIST*/
8411 +/* PCIE protocol TLP diagnostic registers */
8412 +#define PCIE_TLP_CONFIGREG 0x000 /* Configuration */
8413 +#define PCIE_TLP_WORKAROUNDSREG 0x004 /* TLP Workarounds */
8414 +#define PCIE_TLP_WRDMAUPPER 0x010 /* Write DMA Upper Address*/
8415 +#define PCIE_TLP_WRDMALOWER 0x014 /* Write DMA Lower Address*/
8416 +#define PCIE_TLP_WRDMAREQ_LBEREG 0x018 /* Write DMA Len/ByteEn Req*/
8417 +#define PCIE_TLP_RDDMAUPPER 0x01C /* Read DMA Upper Address*/
8418 +#define PCIE_TLP_RDDMALOWER 0x020 /* Read DMA Lower Address*/
8419 +#define PCIE_TLP_RDDMALENREG 0x024 /* Read DMA Len Req*/
8420 +#define PCIE_TLP_MSIDMAUPPER 0x028 /* MSI DMA Upper Address*/
8421 +#define PCIE_TLP_MSIDMALOWER 0x02C /* MSI DMA Lower Address*/
8422 +#define PCIE_TLP_MSIDMALENREG 0x030 /* MSI DMA Len Req*/
8423 +#define PCIE_TLP_SLVREQLENREG 0x034 /* Slave Request Len*/
8424 +#define PCIE_TLP_FCINPUTSREQ 0x038 /* Flow Control Inputs*/
8425 +#define PCIE_TLP_TXSMGRSREQ 0x03C /* Tx StateMachine and Gated Req*/
8426 +#define PCIE_TLP_ADRACKCNTARBLEN 0x040 /* Address Ack XferCnt and ARB Len*/
8427 +#define PCIE_TLP_DMACPLHDR0 0x044 /* DMA Completion Hdr 0*/
8428 +#define PCIE_TLP_DMACPLHDR1 0x048 /* DMA Completion Hdr 1*/
8429 +#define PCIE_TLP_DMACPLHDR2 0x04C /* DMA Completion Hdr 2*/
8430 +#define PCIE_TLP_DMACPLMISC0 0x050 /* DMA Completion Misc0 */
8431 +#define PCIE_TLP_DMACPLMISC1 0x054 /* DMA Completion Misc1 */
8432 +#define PCIE_TLP_DMACPLMISC2 0x058 /* DMA Completion Misc2 */
8433 +#define PCIE_TLP_SPTCTRLLEN 0x05C /* Split Controller Req len*/
8434 +#define PCIE_TLP_SPTCTRLMSIC0 0x060 /* Split Controller Misc 0*/
8435 +#define PCIE_TLP_SPTCTRLMSIC1 0x064 /* Split Controller Misc 1*/
8436 +#define PCIE_TLP_BUSDEVFUNC 0x068 /* Bus/Device/Func*/
8437 +#define PCIE_TLP_RESETCTR 0x06C /* Reset Counter*/
8438 +#define PCIE_TLP_RTRYBUF 0x070 /* Retry Buffer value*/
8439 +#define PCIE_TLP_TGTDEBUG1 0x074 /* Target Debug Reg1*/
8440 +#define PCIE_TLP_TGTDEBUG2 0x078 /* Target Debug Reg2*/
8441 +#define PCIE_TLP_TGTDEBUG3 0x07C /* Target Debug Reg3*/
8442 +#define PCIE_TLP_TGTDEBUG4 0x080 /* Target Debug Reg4*/
8445 +#define MDIOCTL_DIVISOR_MASK 0x7f /* clock to be used on MDIO */
8446 +#define MDIOCTL_DIVISOR_VAL 0x2
8447 +#define MDIOCTL_PREAM_EN 0x80 /* Enable preamble sequnce */
8448 +#define MDIOCTL_ACCESS_DONE 0x100 /* Tranaction complete */
8451 +#define MDIODATA_MASK 0x0000ffff /* data 2 bytes */
8452 +#define MDIODATA_TA 0x00020000 /* Turnaround */
8453 +#define MDIODATA_REGADDR_SHF 18 /* Regaddr shift */
8454 +#define MDIODATA_REGADDR_MASK 0x003c0000 /* Regaddr Mask */
8455 +#define MDIODATA_DEVADDR_SHF 22 /* Physmedia devaddr shift */
8456 +#define MDIODATA_DEVADDR_MASK 0x0fc00000 /* Physmedia devaddr Mask */
8457 +#define MDIODATA_WRITE 0x10000000 /* write Transaction */
8458 +#define MDIODATA_READ 0x20000000 /* Read Transaction */
8459 +#define MDIODATA_START 0x40000000 /* start of Transaction */
8461 +/* MDIO devices (SERDES modules) */
8462 +#define MDIODATA_DEV_PLL 0x1d /* SERDES PLL Dev */
8463 +#define MDIODATA_DEV_TX 0x1e /* SERDES TX Dev */
8464 +#define MDIODATA_DEV_RX 0x1f /* SERDES RX Dev */
8466 +/* SERDES registers */
8467 +#define SERDES_RX_TIMER1 2 /* Rx Timer1 */
8468 +#define SERDES_RX_CDR 6 /* CDR */
8469 +#define SERDES_RX_CDRBW 7 /* CDR BW */
8471 +#endif /* _SBPCIE_H */
8472 diff -urN linux.old/arch/mips/bcm947xx/include/sbpcmcia.h linux.dev/arch/mips/bcm947xx/include/sbpcmcia.h
8473 --- linux.old/arch/mips/bcm947xx/include/sbpcmcia.h 1970-01-01 01:00:00.000000000 +0100
8474 +++ linux.dev/arch/mips/bcm947xx/include/sbpcmcia.h 2005-11-07 22:51:38.788726750 +0100
8477 + * BCM43XX Sonics SiliconBackplane PCMCIA core hardware definitions.
8480 + * Copyright 2005, Broadcom Corporation
8481 + * All Rights Reserved.
8483 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8484 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8485 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8486 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8489 +#ifndef _SBPCMCIA_H
8490 +#define _SBPCMCIA_H
8493 +/* All the addresses that are offsets in attribute space are divided
8494 + * by two to account for the fact that odd bytes are invalid in
8495 + * attribute space and our read/write routines make the space appear
8496 + * as if they didn't exist. Still we want to show the original numbers
8497 + * as documented in the hnd_pcmcia core manual.
8500 +/* PCMCIA Function Configuration Registers */
8501 +#define PCMCIA_FCR (0x700 / 2)
8504 +#define FCR1_OFF (0x40 / 2)
8505 +#define FCR2_OFF (0x80 / 2)
8506 +#define FCR3_OFF (0xc0 / 2)
8508 +#define PCMCIA_FCR0 (0x700 / 2)
8509 +#define PCMCIA_FCR1 (0x740 / 2)
8510 +#define PCMCIA_FCR2 (0x780 / 2)
8511 +#define PCMCIA_FCR3 (0x7c0 / 2)
8513 +/* Standard PCMCIA FCR registers */
8515 +#define PCMCIA_COR 0
8517 +#define COR_RST 0x80
8518 +#define COR_LEV 0x40
8519 +#define COR_IRQEN 0x04
8520 +#define COR_BLREN 0x01
8521 +#define COR_FUNEN 0x01
8524 +#define PCICIA_FCSR (2 / 2)
8525 +#define PCICIA_PRR (4 / 2)
8526 +#define PCICIA_SCR (6 / 2)
8527 +#define PCICIA_ESR (8 / 2)
8530 +#define PCM_MEMOFF 0x0000
8531 +#define F0_MEMOFF 0x1000
8532 +#define F1_MEMOFF 0x2000
8533 +#define F2_MEMOFF 0x3000
8534 +#define F3_MEMOFF 0x4000
8536 +/* Memory base in the function fcr's */
8537 +#define MEM_ADDR0 (0x728 / 2)
8538 +#define MEM_ADDR1 (0x72a / 2)
8539 +#define MEM_ADDR2 (0x72c / 2)
8541 +/* PCMCIA base plus Srom access in fcr0: */
8542 +#define PCMCIA_ADDR0 (0x072e / 2)
8543 +#define PCMCIA_ADDR1 (0x0730 / 2)
8544 +#define PCMCIA_ADDR2 (0x0732 / 2)
8546 +#define MEM_SEG (0x0734 / 2)
8547 +#define SROM_CS (0x0736 / 2)
8548 +#define SROM_DATAL (0x0738 / 2)
8549 +#define SROM_DATAH (0x073a / 2)
8550 +#define SROM_ADDRL (0x073c / 2)
8551 +#define SROM_ADDRH (0x073e / 2)
8553 +/* Values for srom_cs: */
8554 +#define SROM_IDLE 0
8555 +#define SROM_WRITE 1
8556 +#define SROM_READ 2
8559 +#define SROM_DONE 8
8563 +/* The CIS stops where the FCRs start */
8564 +#define CIS_SIZE PCMCIA_FCR
8566 +/* Standard tuples we know about */
8568 +#define CISTPL_MANFID 0x20 /* Manufacturer and device id */
8569 +#define CISTPL_FUNCE 0x22 /* Function extensions */
8570 +#define CISTPL_CFTABLE 0x1b /* Config table entry */
8572 +/* Function extensions for LANs */
8574 +#define LAN_TECH 1 /* Technology type */
8575 +#define LAN_SPEED 2 /* Raw bit rate */
8576 +#define LAN_MEDIA 3 /* Transmission media */
8577 +#define LAN_NID 4 /* Node identification (aka MAC addr) */
8578 +#define LAN_CONN 5 /* Connector standard */
8582 +#define CFTABLE_REGWIN_2K 0x08 /* 2k reg windows size */
8583 +#define CFTABLE_REGWIN_4K 0x10 /* 4k reg windows size */
8584 +#define CFTABLE_REGWIN_8K 0x20 /* 8k reg windows size */
8586 +/* Vendor unique tuples are 0x80-0x8f. Within Broadcom we'll
8587 + * take one for HNBU, and use "extensions" (a la FUNCE) within it.
8590 +#define CISTPL_BRCM_HNBU 0x80
8592 +/* Subtypes of BRCM_HNBU: */
8594 +#define HNBU_SROMREV 0x00 /* A byte with sromrev, 1 if not present */
8595 +#define HNBU_CHIPID 0x01 /* Six bytes with PCI vendor &
8596 + * device id and chiprev
8598 +#define HNBU_BOARDREV 0x02 /* Two bytes board revision */
8599 +#define HNBU_PAPARMS 0x03 /* PA parameters: 1 (old), 8 (sreomrev == 1)
8600 + * or 9 (sromrev > 1) bytes */
8601 +#define HNBU_OEM 0x04 /* Eight bytes OEM data (sromrev == 1) */
8602 +#define HNBU_CC 0x05 /* Default country code (sromrev == 1) */
8603 +#define HNBU_AA 0x06 /* Antennas available */
8604 +#define HNBU_AG 0x07 /* Antenna gain */
8605 +#define HNBU_BOARDFLAGS 0x08 /* board flags (2 or 4 bytes) */
8606 +#define HNBU_LEDS 0x09 /* LED set */
8607 +#define HNBU_CCODE 0x0a /* Country code (2 bytes ascii + 1 byte cctl)
8610 +#define HNBU_CCKPO 0x0b /* 2 byte cck power offsets in rev 3 */
8611 +#define HNBU_OFDMPO 0x0c /* 4 byte 11g ofdm power offsets in rev 3 */
8615 +#define SBTML_INT_ACK 0x40000 /* ack the sb interrupt */
8616 +#define SBTML_INT_EN 0x20000 /* enable sb interrupt */
8618 +/* sbtmstatehigh */
8619 +#define SBTMH_INT_STATUS 0x40000 /* sb interrupt status */
8621 +#endif /* _SBPCMCIA_H */
8622 diff -urN linux.old/arch/mips/bcm947xx/include/sbsdram.h linux.dev/arch/mips/bcm947xx/include/sbsdram.h
8623 --- linux.old/arch/mips/bcm947xx/include/sbsdram.h 1970-01-01 01:00:00.000000000 +0100
8624 +++ linux.dev/arch/mips/bcm947xx/include/sbsdram.h 2005-11-07 21:57:07.877587750 +0100
8627 + * BCM47XX Sonics SiliconBackplane SDRAM controller core hardware definitions.
8629 + * Copyright 2005, Broadcom Corporation
8630 + * All Rights Reserved.
8632 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8633 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8634 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8635 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8642 +#ifndef _LANGUAGE_ASSEMBLY
8644 +/* Sonics side: SDRAM core registers */
8645 +typedef volatile struct sbsdramregs {
8646 + uint32 initcontrol; /* Generates external SDRAM initialization sequence */
8647 + uint32 config; /* Initializes external SDRAM mode register */
8648 + uint32 refresh; /* Controls external SDRAM refresh rate */
8655 +/* SDRAM initialization control (initcontrol) register bits */
8656 +#define SDRAM_CBR 0x0001 /* Writing 1 generates refresh cycle and toggles bit */
8657 +#define SDRAM_PRE 0x0002 /* Writing 1 generates precharge cycle and toggles bit */
8658 +#define SDRAM_MRS 0x0004 /* Writing 1 generates mode register select cycle and toggles bit */
8659 +#define SDRAM_EN 0x0008 /* When set, enables access to SDRAM */
8660 +#define SDRAM_16Mb 0x0000 /* Use 16 Megabit SDRAM */
8661 +#define SDRAM_64Mb 0x0010 /* Use 64 Megabit SDRAM */
8662 +#define SDRAM_128Mb 0x0020 /* Use 128 Megabit SDRAM */
8663 +#define SDRAM_RSVMb 0x0030 /* Use special SDRAM */
8664 +#define SDRAM_RST 0x0080 /* Writing 1 causes soft reset of controller */
8665 +#define SDRAM_SELFREF 0x0100 /* Writing 1 enables self refresh mode */
8666 +#define SDRAM_PWRDOWN 0x0200 /* Writing 1 causes controller to power down */
8667 +#define SDRAM_32BIT 0x0400 /* When set, indicates 32 bit SDRAM interface */
8668 +#define SDRAM_9BITCOL 0x0800 /* When set, indicates 9 bit column */
8670 +/* SDRAM configuration (config) register bits */
8671 +#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
8672 +#define SDRAM_BURST8 0x0001 /* Use burst of 8 */
8673 +#define SDRAM_BURST4 0x0002 /* Use burst of 4 */
8674 +#define SDRAM_BURST2 0x0003 /* Use burst of 2 */
8675 +#define SDRAM_CAS3 0x0000 /* Use CAS latency of 3 */
8676 +#define SDRAM_CAS2 0x0004 /* Use CAS latency of 2 */
8678 +/* SDRAM refresh control (refresh) register bits */
8679 +#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
8680 +#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
8682 +/* SDRAM Core default Init values (OCP ID 0x803) */
8683 +#define SDRAM_INIT MEM4MX16X2
8684 +#define SDRAM_CONFIG SDRAM_BURSTFULL
8685 +#define SDRAM_REFRESH SDRAM_REF(0x40)
8687 +#define MEM1MX16 0x009 /* 2 MB */
8688 +#define MEM1MX16X2 0x409 /* 4 MB */
8689 +#define MEM2MX8X2 0x809 /* 4 MB */
8690 +#define MEM2MX8X4 0xc09 /* 8 MB */
8691 +#define MEM2MX32 0x439 /* 8 MB */
8692 +#define MEM4MX16 0x019 /* 8 MB */
8693 +#define MEM4MX16X2 0x419 /* 16 MB */
8694 +#define MEM8MX8X2 0x819 /* 16 MB */
8695 +#define MEM8MX16 0x829 /* 16 MB */
8696 +#define MEM4MX32 0x429 /* 16 MB */
8697 +#define MEM8MX8X4 0xc19 /* 32 MB */
8698 +#define MEM8MX16X2 0xc29 /* 32 MB */
8700 +#endif /* _SBSDRAM_H */
8701 diff -urN linux.old/arch/mips/bcm947xx/include/sbsocram.h linux.dev/arch/mips/bcm947xx/include/sbsocram.h
8702 --- linux.old/arch/mips/bcm947xx/include/sbsocram.h 1970-01-01 01:00:00.000000000 +0100
8703 +++ linux.dev/arch/mips/bcm947xx/include/sbsocram.h 2005-11-07 21:57:07.877587750 +0100
8706 + * BCM47XX Sonics SiliconBackplane embedded ram core
8708 + * Copyright 2005, Broadcom Corporation
8709 + * All Rights Reserved.
8711 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8712 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8713 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8714 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8719 +#ifndef _SBSOCRAM_H
8720 +#define _SBSOCRAM_H
8722 +#define SOCRAM_MEMSIZE 0x00
8723 +#define SOCRAM_BISTSTAT 0x0c
8726 +#ifndef _LANGUAGE_ASSEMBLY
8728 +/* Memcsocram core registers */
8729 +typedef volatile struct sbsocramregs {
8736 +/* Them memory size is 2 to the power of the following
8737 + * base added to the contents of the memsize register.
8739 +#define SOCRAM_MEMSIZE_BASESHIFT 16
8741 +#endif /* _SBSOCRAM_H */
8742 diff -urN linux.old/arch/mips/bcm947xx/include/sbutils.h linux.dev/arch/mips/bcm947xx/include/sbutils.h
8743 --- linux.old/arch/mips/bcm947xx/include/sbutils.h 1970-01-01 01:00:00.000000000 +0100
8744 +++ linux.dev/arch/mips/bcm947xx/include/sbutils.h 2005-11-07 22:51:38.788726750 +0100
8747 + * Misc utility routines for accessing chip-specific features
8748 + * of Broadcom HNBU SiliconBackplane-based chips.
8750 + * Copyright 2005, Broadcom Corporation
8751 + * All Rights Reserved.
8753 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8754 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8755 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8756 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8761 +#ifndef _sbutils_h_
8762 +#define _sbutils_h_
8765 + * Datastructure to export all chip specific common variables
8766 + * public (read-only) portion of sbutils handle returned by
8767 + * sb_attach()/sb_kattach()
8772 + uint bustype; /* SB_BUS, PCI_BUS */
8773 + uint buscoretype; /* SB_PCI, SB_PCMCIA, SB_PCIE*/
8774 + uint buscorerev; /* buscore rev */
8775 + uint buscoreidx; /* buscore index */
8776 + int ccrev; /* chip common core rev */
8777 + uint boardtype; /* board type */
8778 + uint boardvendor; /* board vendor */
8779 + uint chip; /* chip number */
8780 + uint chiprev; /* chip revision */
8781 + uint chippkg; /* chip package option */
8782 + uint sonicsrev; /* sonics backplane rev */
8785 +typedef const struct sb_pub sb_t;
8788 + * Many of the routines below take an 'sbh' handle as their first arg.
8789 + * Allocate this by calling sb_attach(). Free it by calling sb_detach().
8790 + * At any one time, the sbh is logically focused on one particular sb core
8791 + * (the "current core").
8792 + * Use sb_setcore() or sb_setcoreidx() to change the association to another core.
8795 +/* exported externs */
8796 +extern sb_t * BCMINIT(sb_attach)(uint pcidev, osl_t *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz);
8797 +extern sb_t * BCMINIT(sb_kattach)(void);
8798 +extern void sb_detach(sb_t *sbh);
8799 +extern uint BCMINIT(sb_chip)(sb_t *sbh);
8800 +extern uint BCMINIT(sb_chiprev)(sb_t *sbh);
8801 +extern uint BCMINIT(sb_chipcrev)(sb_t *sbh);
8802 +extern uint BCMINIT(sb_chippkg)(sb_t *sbh);
8803 +extern uint BCMINIT(sb_pcirev)(sb_t *sbh);
8804 +extern bool BCMINIT(sb_war16165)(sb_t *sbh);
8805 +extern uint BCMINIT(sb_pcmciarev)(sb_t *sbh);
8806 +extern uint BCMINIT(sb_boardvendor)(sb_t *sbh);
8807 +extern uint BCMINIT(sb_boardtype)(sb_t *sbh);
8808 +extern uint sb_bus(sb_t *sbh);
8809 +extern uint sb_buscoretype(sb_t *sbh);
8810 +extern uint sb_buscorerev(sb_t *sbh);
8811 +extern uint sb_corelist(sb_t *sbh, uint coreid[]);
8812 +extern uint sb_coreid(sb_t *sbh);
8813 +extern uint sb_coreidx(sb_t *sbh);
8814 +extern uint sb_coreunit(sb_t *sbh);
8815 +extern uint sb_corevendor(sb_t *sbh);
8816 +extern uint sb_corerev(sb_t *sbh);
8817 +extern void *sb_osh(sb_t *sbh);
8818 +extern void *sb_coreregs(sb_t *sbh);
8819 +extern uint32 sb_coreflags(sb_t *sbh, uint32 mask, uint32 val);
8820 +extern uint32 sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val);
8821 +extern bool sb_iscoreup(sb_t *sbh);
8822 +extern void *sb_setcoreidx(sb_t *sbh, uint coreidx);
8823 +extern void *sb_setcore(sb_t *sbh, uint coreid, uint coreunit);
8824 +extern int sb_corebist(sb_t *sbh, uint coreid, uint coreunit);
8825 +extern void sb_commit(sb_t *sbh);
8826 +extern uint32 sb_base(uint32 admatch);
8827 +extern uint32 sb_size(uint32 admatch);
8828 +extern void sb_core_reset(sb_t *sbh, uint32 bits);
8829 +extern void sb_core_tofixup(sb_t *sbh);
8830 +extern void sb_core_disable(sb_t *sbh, uint32 bits);
8831 +extern uint32 sb_clock_rate(uint32 pll_type, uint32 n, uint32 m);
8832 +extern uint32 sb_clock(sb_t *sbh);
8833 +extern void sb_pci_setup(sb_t *sbh, uint coremask);
8834 +extern void sb_pcmcia_init(sb_t *sbh);
8835 +extern void sb_watchdog(sb_t *sbh, uint ticks);
8836 +extern void *sb_gpiosetcore(sb_t *sbh);
8837 +extern uint32 sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8838 +extern uint32 sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8839 +extern uint32 sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8840 +extern uint32 sb_gpioin(sb_t *sbh);
8841 +extern uint32 sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8842 +extern uint32 sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8843 +extern uint32 sb_gpioled(sb_t *sbh, uint32 mask, uint32 val);
8844 +extern uint32 sb_gpioreserve(sb_t *sbh, uint32 gpio_num, uint8 priority);
8845 +extern uint32 sb_gpiorelease(sb_t *sbh, uint32 gpio_num, uint8 priority);
8847 +extern void sb_clkctl_init(sb_t *sbh);
8848 +extern uint16 sb_clkctl_fast_pwrup_delay(sb_t *sbh);
8849 +extern bool sb_clkctl_clk(sb_t *sbh, uint mode);
8850 +extern int sb_clkctl_xtal(sb_t *sbh, uint what, bool on);
8851 +extern void sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn,
8852 + void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg);
8853 +extern uint32 sb_set_initiator_to(sb_t *sbh, uint32 to);
8854 +extern void sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
8855 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif);
8856 +extern uint sb_pcie_readreg(void *sbh, void* arg1, uint offset);
8857 +extern uint sb_pcie_writereg(sb_t *sbh, void *arg1, uint offset, uint val);
8858 +extern uint32 sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 val);
8863 +* Build device path. Path size must be >= SB_DEVPATH_BUFSZ.
8864 +* The returned path is NULL terminated and has trailing '/'.
8865 +* Return 0 on success, nonzero otherwise.
8867 +extern int sb_devpath(sb_t *sbh, char *path, int size);
8869 +/* clkctl xtal what flags */
8870 +#define XTAL 0x1 /* primary crystal oscillator (2050) */
8871 +#define PLL 0x2 /* main chip pll */
8873 +/* clkctl clk mode */
8874 +#define CLK_FAST 0 /* force fast (pll) clock */
8875 +#define CLK_DYNAMIC 2 /* enable dynamic clock control */
8878 +/* GPIO usage priorities */
8879 +#define GPIO_DRV_PRIORITY 0
8880 +#define GPIO_APP_PRIORITY 1
8883 +#define SB_DEVPATH_BUFSZ 16 /* min buffer size in bytes */
8885 +#endif /* _sbutils_h_ */
8886 diff -urN linux.old/arch/mips/bcm947xx/include/sflash.h linux.dev/arch/mips/bcm947xx/include/sflash.h
8887 --- linux.old/arch/mips/bcm947xx/include/sflash.h 1970-01-01 01:00:00.000000000 +0100
8888 +++ linux.dev/arch/mips/bcm947xx/include/sflash.h 2005-11-07 21:57:07.881588000 +0100
8891 + * Broadcom SiliconBackplane chipcommon serial flash interface
8893 + * Copyright 2005, Broadcom Corporation
8894 + * All Rights Reserved.
8896 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8897 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8898 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8899 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8907 +#include <typedefs.h>
8908 +#include <sbchipc.h>
8911 + uint blocksize; /* Block size */
8912 + uint numblocks; /* Number of blocks */
8913 + uint32 type; /* Type */
8914 + uint size; /* Total size in bytes */
8917 +/* Utility functions */
8918 +extern int sflash_poll(chipcregs_t *cc, uint offset);
8919 +extern int sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf);
8920 +extern int sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
8921 +extern int sflash_erase(chipcregs_t *cc, uint offset);
8922 +extern int sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
8923 +extern struct sflash * sflash_init(chipcregs_t *cc);
8925 +#endif /* _sflash_h_ */
8926 diff -urN linux.old/arch/mips/bcm947xx/include/trxhdr.h linux.dev/arch/mips/bcm947xx/include/trxhdr.h
8927 --- linux.old/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +0100
8928 +++ linux.dev/arch/mips/bcm947xx/include/trxhdr.h 2005-11-07 21:57:07.881588000 +0100
8931 + * TRX image file header format.
8933 + * Copyright 2005, Broadcom Corporation
8934 + * All Rights Reserved.
8936 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8937 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8938 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8939 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8944 +#include <typedefs.h>
8946 +#define TRX_MAGIC 0x30524448 /* "HDR0" */
8947 +#define TRX_VERSION 1
8948 +#define TRX_MAX_LEN 0x3A0000
8949 +#define TRX_NO_HEADER 1 /* Do not write TRX header */
8950 +#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
8951 +#define TRX_MAX_OFFSET 3
8953 +struct trx_header {
8954 + uint32 magic; /* "HDR0" */
8955 + uint32 len; /* Length of file including header */
8956 + uint32 crc32; /* 32-bit CRC from flag_version to end of file */
8957 + uint32 flag_version; /* 0:15 flags, 16:31 version */
8958 + uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
8961 +/* Compatibility */
8962 +typedef struct trx_header TRXHDR, *PTRXHDR;
8963 diff -urN linux.old/arch/mips/bcm947xx/include/typedefs.h linux.dev/arch/mips/bcm947xx/include/typedefs.h
8964 --- linux.old/arch/mips/bcm947xx/include/typedefs.h 1970-01-01 01:00:00.000000000 +0100
8965 +++ linux.dev/arch/mips/bcm947xx/include/typedefs.h 2005-11-07 22:51:38.788726750 +0100
8968 + * Copyright 2005, Broadcom Corporation
8969 + * All Rights Reserved.
8971 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8972 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8973 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8974 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8978 +#ifndef _TYPEDEFS_H_
8979 +#define _TYPEDEFS_H_
8982 +/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
8983 + * typedef file "site_typedefs.h".
8985 + * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
8986 + * section of this file makes inferences about the compile environment
8987 + * based on defined symbols and possibly compiler pragmas.
8989 + * Following these two sections is the "Default Typedefs"
8990 + * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
8991 + * defined. This section has a default set of typedefs and a few
8992 + * proprocessor symbols (TRUE, FALSE, NULL, ...).
8995 +#ifdef SITE_TYPEDEFS
8997 +/*******************************************************************************
8998 + * Site Specific Typedefs
8999 + *******************************************************************************/
9001 +#include "site_typedefs.h"
9005 +/*******************************************************************************
9006 + * Inferred Typedefs
9007 + *******************************************************************************/
9009 +/* Infer the compile environment based on preprocessor symbols and pramas.
9010 + * Override type definitions as needed, and include configuration dependent
9011 + * header files to define types.
9016 +#define TYPEDEF_BOOL
9018 +#define FALSE false
9024 +#else /* ! __cplusplus */
9026 +#if defined(_WIN32)
9028 +#define TYPEDEF_BOOL
9029 +typedef unsigned char bool; /* consistent w/BOOL */
9031 +#endif /* _WIN32 */
9033 +#endif /* ! __cplusplus */
9035 +/* use the Windows ULONG_PTR type when compiling for 64 bit */
9036 +#if defined(_WIN64)
9037 +#include <basetsd.h>
9038 +#define TYPEDEF_UINTPTR
9039 +typedef ULONG_PTR uintptr;
9043 +typedef long unsigned int size_t;
9046 +#ifdef _MSC_VER /* Microsoft C */
9047 +#define TYPEDEF_INT64
9048 +#define TYPEDEF_UINT64
9049 +typedef signed __int64 int64;
9050 +typedef unsigned __int64 uint64;
9053 +#if defined(MACOSX) && defined(KERNEL)
9054 +#define TYPEDEF_BOOL
9059 +#define TYPEDEF_UINT
9060 +#define TYPEDEF_USHORT
9061 +#define TYPEDEF_ULONG
9064 +#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
9065 +#define TYPEDEF_UINT
9066 +#define TYPEDEF_USHORT
9070 +/* Do not support the (u)int64 types with strict ansi for GNU C */
9071 +#if defined(__GNUC__) && defined(__STRICT_ANSI__)
9072 +#define TYPEDEF_INT64
9073 +#define TYPEDEF_UINT64
9076 +/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
9077 + * for singned or unsigned */
9080 +#define TYPEDEF_INT64
9082 +#if defined(__STDC__)
9083 +#define TYPEDEF_UINT64
9089 +#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
9091 +/* pick up ushort & uint from standard types.h */
9092 +#if defined(linux) && defined(__KERNEL__)
9094 +#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
9098 +#include <sys/types.h>
9102 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */
9104 +#if defined(MACOSX) && defined(KERNEL)
9105 +#include <IOKit/IOTypes.h>
9109 +/* use the default typedefs in the next section of this file */
9110 +#define USE_TYPEDEF_DEFAULTS
9112 +#endif /* SITE_TYPEDEFS */
9115 +/*******************************************************************************
9116 + * Default Typedefs
9117 + *******************************************************************************/
9119 +#ifdef USE_TYPEDEF_DEFAULTS
9120 +#undef USE_TYPEDEF_DEFAULTS
9122 +#ifndef TYPEDEF_BOOL
9123 +typedef /*@abstract@*/ unsigned char bool;
9126 +/*----------------------- define uchar, ushort, uint, ulong ------------------*/
9128 +#ifndef TYPEDEF_UCHAR
9129 +typedef unsigned char uchar;
9132 +#ifndef TYPEDEF_USHORT
9133 +typedef unsigned short ushort;
9136 +#ifndef TYPEDEF_UINT
9137 +typedef unsigned int uint;
9140 +#ifndef TYPEDEF_ULONG
9141 +typedef unsigned long ulong;
9144 +/*----------------------- define [u]int8/16/32/64, uintptr --------------------*/
9146 +#ifndef TYPEDEF_UINT8
9147 +typedef unsigned char uint8;
9150 +#ifndef TYPEDEF_UINT16
9151 +typedef unsigned short uint16;
9154 +#ifndef TYPEDEF_UINT32
9155 +typedef unsigned int uint32;
9158 +#ifndef TYPEDEF_UINT64
9159 +typedef unsigned long long uint64;
9162 +#ifndef TYPEDEF_UINTPTR
9163 +typedef unsigned int uintptr;
9166 +#ifndef TYPEDEF_INT8
9167 +typedef signed char int8;
9170 +#ifndef TYPEDEF_INT16
9171 +typedef signed short int16;
9174 +#ifndef TYPEDEF_INT32
9175 +typedef signed int int32;
9178 +#ifndef TYPEDEF_INT64
9179 +typedef signed long long int64;
9182 +/*----------------------- define float32/64, float_t -----------------------*/
9184 +#ifndef TYPEDEF_FLOAT32
9185 +typedef float float32;
9188 +#ifndef TYPEDEF_FLOAT64
9189 +typedef double float64;
9193 + * abstracted floating point type allows for compile time selection of
9194 + * single or double precision arithmetic. Compiling with -DFLOAT32
9195 + * selects single precision; the default is double precision.
9198 +#ifndef TYPEDEF_FLOAT_T
9200 +#if defined(FLOAT32)
9201 +typedef float32 float_t;
9202 +#else /* default to double precision floating point */
9203 +typedef float64 float_t;
9206 +#endif /* TYPEDEF_FLOAT_T */
9208 +/*----------------------- define macro values -----------------------------*/
9232 +/* Reclaiming text and data :
9233 + The following macros specify special linker sections that can be reclaimed
9234 + after a system is considered 'up'.
9236 +#if defined(__GNUC__) && defined(BCMRECLAIM)
9237 +extern bool bcmreclaimed;
9238 +#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data##_ini
9239 +#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn##_ini
9240 +#define BCMINIT(_id) _id##_ini
9242 +#define BCMINITDATA(_data) _data
9243 +#define BCMINITFN(_fn) _fn
9244 +#define BCMINIT(_id) _id
9245 +#define bcmreclaimed 0
9248 +/*----------------------- define PTRSZ, INLINE ----------------------------*/
9251 +#define PTRSZ sizeof (char*)
9258 +#define INLINE __inline
9262 +#define INLINE __inline__
9268 +#endif /* _MSC_VER */
9270 +#endif /* INLINE */
9272 +#undef TYPEDEF_BOOL
9273 +#undef TYPEDEF_UCHAR
9274 +#undef TYPEDEF_USHORT
9275 +#undef TYPEDEF_UINT
9276 +#undef TYPEDEF_ULONG
9277 +#undef TYPEDEF_UINT8
9278 +#undef TYPEDEF_UINT16
9279 +#undef TYPEDEF_UINT32
9280 +#undef TYPEDEF_UINT64
9281 +#undef TYPEDEF_UINTPTR
9282 +#undef TYPEDEF_INT8
9283 +#undef TYPEDEF_INT16
9284 +#undef TYPEDEF_INT32
9285 +#undef TYPEDEF_INT64
9286 +#undef TYPEDEF_FLOAT32
9287 +#undef TYPEDEF_FLOAT64
9288 +#undef TYPEDEF_FLOAT_T
9290 +#endif /* USE_TYPEDEF_DEFAULTS */
9292 +#endif /* _TYPEDEFS_H_ */
9293 diff -urN linux.old/arch/mips/bcm947xx/include/wlioctl.h linux.dev/arch/mips/bcm947xx/include/wlioctl.h
9294 --- linux.old/arch/mips/bcm947xx/include/wlioctl.h 1970-01-01 01:00:00.000000000 +0100
9295 +++ linux.dev/arch/mips/bcm947xx/include/wlioctl.h 2005-11-07 22:51:38.792727000 +0100
9298 + * Custom OID/ioctl definitions for
9299 + * Broadcom 802.11abg Networking Device Driver
9301 + * Definitions subject to change without notice.
9303 + * Copyright 2005, Broadcom Corporation
9304 + * All Rights Reserved.
9306 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9307 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9308 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9309 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9314 +#ifndef _wlioctl_h_
9315 +#define _wlioctl_h_
9317 +#include <typedefs.h>
9318 +#include <proto/ethernet.h>
9319 +#include <proto/bcmeth.h>
9320 +#include <proto/bcmevent.h>
9321 +#include <proto/802.11.h>
9323 +/* require default structure packing */
9324 +#if !defined(__GNUC__)
9325 +#pragma pack(push,8)
9328 +#define WL_NUMRATES 255 /* max # of rates in a rateset */
9330 +typedef struct wl_rateset {
9331 + uint32 count; /* # rates in this set */
9332 + uint8 rates[WL_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */
9335 +#define WL_CHANSPEC_CHAN_MASK 0x0fff
9336 +#define WL_CHANSPEC_BAND_MASK 0xf000
9337 +#define WL_CHANSPEC_BAND_SHIFT 12
9338 +#define WL_CHANSPEC_BAND_A 0x1000
9339 +#define WL_CHANSPEC_BAND_B 0x2000
9342 + * Per-bss information structure.
9345 +#define WL_BSS_INFO_VERSION 107 /* current version of wl_bss_info struct */
9347 +typedef struct wl_bss_info {
9348 + uint32 version; /* version field */
9349 + uint32 length; /* byte length of data in this record, starting at version and including IEs */
9350 + struct ether_addr BSSID;
9351 + uint16 beacon_period; /* units are Kusec */
9352 + uint16 capability; /* Capability information */
9356 + uint count; /* # rates in this set */
9357 + uint8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */
9358 + } rateset; /* supported rates */
9359 + uint8 channel; /* Channel no. */
9360 + uint16 atim_window; /* units are Kusec */
9361 + uint8 dtim_period; /* DTIM period */
9362 + int16 RSSI; /* receive signal strength (in dBm) */
9363 + int8 phy_noise; /* noise (in dBm) */
9364 + uint32 ie_length; /* byte length of Information Elements */
9365 + /* variable length Information Elements */
9368 +typedef struct wlc_ssid {
9373 +typedef struct wl_scan_params {
9374 + wlc_ssid_t ssid; /* default is {0, ""} */
9375 + struct ether_addr bssid;/* default is bcast */
9376 + int8 bss_type; /* default is any, DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT */
9377 + int8 scan_type; /* -1 use default, DOT11_SCANTYPE_ACTIVE/PASSIVE */
9378 + int32 nprobes; /* -1 use default, number of probes per channel */
9379 + int32 active_time; /* -1 use default, dwell time per channel for active scanning */
9380 + int32 passive_time; /* -1 use default, dwell time per channel for passive scanning */
9381 + int32 home_time; /* -1 use default, dwell time for the home channel between channel scans */
9382 + int32 channel_num; /* 0 use default (all available channels), count of channels in channel_list */
9383 + uint16 channel_list[1]; /* list of chanspecs */
9384 +} wl_scan_params_t;
9385 +/* size of wl_scan_params not including variable length array */
9386 +#define WL_SCAN_PARAMS_FIXED_SIZE 64
9388 +typedef struct wl_scan_results {
9392 + wl_bss_info_t bss_info[1];
9393 +} wl_scan_results_t;
9394 +/* size of wl_scan_results not including variable length array */
9395 +#define WL_SCAN_RESULTS_FIXED_SIZE 12
9398 +typedef struct wl_uint32_list {
9399 + /* in - # of elements, out - # of entries */
9401 + /* variable length uint32 list */
9402 + uint32 element[1];
9403 +} wl_uint32_list_t;
9405 +#define WLC_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NULL */
9407 +typedef struct wl_channels_in_country {
9410 + char country_abbrev[WLC_CNTRY_BUF_SZ];
9412 + uint32 channel[1];
9413 +} wl_channels_in_country_t;
9415 +typedef struct wl_country_list {
9420 + char country_abbrev[1];
9421 +} wl_country_list_t;
9423 +#define WL_RM_TYPE_BASIC 1
9424 +#define WL_RM_TYPE_CCA 2
9425 +#define WL_RM_TYPE_RPI 3
9427 +#define WL_RM_FLAG_PARALLEL (1<<0)
9429 +#define WL_RM_FLAG_LATE (1<<1)
9430 +#define WL_RM_FLAG_INCAPABLE (1<<2)
9431 +#define WL_RM_FLAG_REFUSED (1<<3)
9433 +typedef struct wl_rm_req_elt {
9437 + uint32 token; /* token for this measurement */
9438 + uint32 tsf_h; /* TSF high 32-bits of Measurement start time */
9439 + uint32 tsf_l; /* TSF low 32-bits */
9440 + uint32 dur; /* TUs */
9443 +typedef struct wl_rm_req {
9444 + uint32 token; /* overall measurement set token */
9445 + uint32 count; /* number of measurement reqests */
9446 + wl_rm_req_elt_t req[1]; /* variable length block of requests */
9448 +#define WL_RM_REQ_FIXED_LEN 8
9450 +typedef struct wl_rm_rep_elt {
9454 + uint32 token; /* token for this measurement */
9455 + uint32 tsf_h; /* TSF high 32-bits of Measurement start time */
9456 + uint32 tsf_l; /* TSF low 32-bits */
9457 + uint32 dur; /* TUs */
9458 + uint32 len; /* byte length of data block */
9459 + uint8 data[1]; /* variable length data block */
9461 +#define WL_RM_REP_ELT_FIXED_LEN 24 /* length excluding data block */
9463 +#define WL_RPI_REP_BIN_NUM 8
9464 +typedef struct wl_rm_rpi_rep {
9465 + uint8 rpi[WL_RPI_REP_BIN_NUM];
9466 + int8 rpi_max[WL_RPI_REP_BIN_NUM];
9469 +typedef struct wl_rm_rep {
9470 + uint32 token; /* overall measurement set token */
9471 + uint32 len; /* length of measurement report block */
9472 + wl_rm_rep_elt_t rep[1]; /* variable length block of reports */
9474 +#define WL_RM_REP_FIXED_LEN 8
9477 +#if defined(BCMSUP_PSK)
9478 +typedef enum sup_auth_status {
9479 + WLC_SUP_DISCONNECTED = 0,
9480 + WLC_SUP_CONNECTING,
9481 + WLC_SUP_IDREQUIRED,
9482 + WLC_SUP_AUTHENTICATING,
9483 + WLC_SUP_AUTHENTICATED,
9484 + WLC_SUP_KEYXCHANGE,
9487 +} sup_auth_status_t;
9488 +#endif /* BCMCCX | BCMSUP_PSK */
9490 +/* Enumerate crypto algorithms */
9491 +#define CRYPTO_ALGO_OFF 0
9492 +#define CRYPTO_ALGO_WEP1 1
9493 +#define CRYPTO_ALGO_TKIP 2
9494 +#define CRYPTO_ALGO_WEP128 3
9495 +#define CRYPTO_ALGO_AES_CCM 4
9496 +#define CRYPTO_ALGO_AES_OCB_MSDU 5
9497 +#define CRYPTO_ALGO_AES_OCB_MPDU 6
9498 +#define CRYPTO_ALGO_NALG 7
9500 +#define WSEC_GEN_MIC_ERROR 0x0001
9501 +#define WSEC_GEN_REPLAY 0x0002
9503 +#define WL_SOFT_KEY (1 << 0) /* Indicates this key is using soft encrypt */
9504 +#define WL_PRIMARY_KEY (1 << 1) /* Indicates this key is the primary (ie tx) key */
9505 +#define WL_KF_RES_4 (1 << 4) /* Reserved for backward compat */
9506 +#define WL_KF_RES_5 (1 << 5) /* Reserved for backward compat */
9508 +typedef struct wl_wsec_key {
9509 + uint32 index; /* key index */
9510 + uint32 len; /* key length */
9511 + uint8 data[DOT11_MAX_KEY_SIZE]; /* key data */
9513 + uint32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
9514 + uint32 flags; /* misc flags */
9517 + int iv_initialized; /* has IV been initialized already? */
9521 + uint32 hi; /* upper 32 bits of IV */
9522 + uint16 lo; /* lower 16 bits of IV */
9525 + struct ether_addr ea; /* per station */
9529 +#define WSEC_MIN_PSK_LEN 8
9530 +#define WSEC_MAX_PSK_LEN 64
9532 +/* Flag for key material needing passhash'ing */
9533 +#define WSEC_PASSPHRASE (1<<0)
9535 +/* recepticle for WLC_SET_WSEC_PMK parameter */
9537 + ushort key_len; /* octets in key material */
9538 + ushort flags; /* key handling qualification */
9539 + uint8 key[WSEC_MAX_PSK_LEN]; /* PMK material */
9542 +/* wireless security bitvec */
9543 +#define WEP_ENABLED 0x0001
9544 +#define TKIP_ENABLED 0x0002
9545 +#define AES_ENABLED 0x0004
9546 +#define WSEC_SWFLAG 0x0008
9547 +#define SES_OW_ENABLED 0x0040 /* to go into transition mode without setting wep */
9549 +/* WPA authentication mode bitvec */
9550 +#define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */
9551 +#define WPA_AUTH_NONE 0x0001 /* none (IBSS) */
9552 +#define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */
9553 +#define WPA_AUTH_PSK 0x0004 /* Pre-shared key */
9554 +/*#define WPA_AUTH_8021X 0x0020*/ /* 802.1x, reserved */
9556 +#define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
9557 +#define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
9562 +#define MAXPMKID 16
9564 +typedef struct _pmkid
9566 + struct ether_addr BSSID;
9567 + uint8 PMKID[WPA2_PMKID_LEN];
9570 +typedef struct _pmkid_list
9576 +typedef struct _pmkid_cand {
9577 + struct ether_addr BSSID;
9581 +typedef struct _pmkid_cand_list {
9582 + uint32 npmkid_cand;
9583 + pmkid_cand_t pmkid_cand[1];
9584 +} pmkid_cand_list_t;
9587 +typedef struct wl_led_info {
9588 + uint32 index; /* led index */
9593 +typedef struct wlc_assoc_info {
9597 + struct dot11_assoc_req req;
9598 + struct ether_addr reassoc_bssid; /* used in reassoc's */
9599 + struct dot11_assoc_resp resp;
9602 +#define WLC_ASSOC_REQ_IS_REASSOC 0x01 /* assoc req was actually a reassoc */
9603 +/* srom read/write struct passed through ioctl */
9605 + uint byteoff; /* byte offset */
9606 + uint nbytes; /* number of bytes */
9610 +/* R_REG and W_REG struct passed through ioctl */
9612 + uint32 byteoff; /* byte offset of the field in d11regs_t */
9613 + uint32 val; /* read/write value of the field */
9614 + uint32 size; /* sizeof the field */
9615 + uint band; /* band (optional) */
9618 +/* Structure used by GET/SET_ATTEN ioctls */
9620 + uint16 auto_ctrl; /* 1: Automatic control, 0: overriden */
9621 + uint16 bb; /* Baseband attenuation */
9622 + uint16 radio; /* Radio attenuation */
9623 + uint16 txctl1; /* Radio TX_CTL1 value */
9626 +/* Used to get specific STA parameters */
9629 + struct ether_addr ea;
9633 +/* Event data type */
9634 +typedef struct wlc_event {
9635 + wl_event_msg_t event; /* encapsulated event */
9636 + struct ether_addr *addr; /* used to keep a trace of the potential present of
9637 + an address in wlc_event_msg_t */
9638 + void *data; /* used to hang additional data on an event */
9639 + struct wlc_event *next; /* enables ordered list of pending events */
9642 +#define BCM_MAC_STATUS_INDICATION (0x40010200L)
9645 + uint16 ver; /* version of this struct */
9646 + uint16 len; /* length in bytes of this structure */
9647 + uint16 cap; /* sta's advertized capabilities */
9648 + uint32 flags; /* flags defined below */
9649 + uint32 idle; /* time since data pkt rx'd from sta */
9650 + struct ether_addr ea; /* Station address */
9651 + wl_rateset_t rateset; /* rateset in use */
9652 + uint32 in; /* seconds elapsed since associated */
9653 + uint32 listen_interval_inms; /* Min Listen interval in ms for this STA*/
9656 +#define WL_STA_VER 2
9659 +#define WL_STA_BRCM 0x01
9660 +#define WL_STA_WME 0x02
9661 +#define WL_STA_ABCAP 0x04
9662 +#define WL_STA_AUTHE 0x08
9663 +#define WL_STA_ASSOC 0x10
9664 +#define WL_STA_AUTHO 0x20
9665 +#define WL_STA_WDS 0x40
9666 +#define WL_WDS_LINKUP 0x80
9670 + * Country locale determines which channels are available to us.
9672 +typedef enum _wlc_locale {
9673 + WLC_WW = 0, /* Worldwide */
9674 + WLC_THA, /* Thailand */
9675 + WLC_ISR, /* Israel */
9676 + WLC_JDN, /* Jordan */
9677 + WLC_PRC, /* China */
9678 + WLC_JPN, /* Japan */
9679 + WLC_FCC, /* USA */
9680 + WLC_EUR, /* Europe */
9681 + WLC_USL, /* US Low Band only */
9682 + WLC_JPH, /* Japan High Band only */
9683 + WLC_ALL, /* All the channels in this band */
9684 + WLC_11D, /* Represents locale recieved by 11d beacons */
9686 + WLC_UNDEFINED_LOCALE = 0xf
9689 +/* channel encoding */
9690 +typedef struct channel_info {
9692 + int target_channel;
9696 +/* For ioctls that take a list of MAC addresses */
9698 + uint count; /* number of MAC addresses */
9699 + struct ether_addr ea[1]; /* variable length array of MAC addresses */
9702 +/* get pkt count struct passed through ioctl */
9703 +typedef struct get_pktcnt {
9710 +/* Linux network driver ioctl encoding */
9711 +typedef struct wl_ioctl {
9712 + uint cmd; /* common ioctl definition */
9713 + void *buf; /* pointer to user buffer */
9714 + uint len; /* length of user buffer */
9715 + bool set; /* get or set request (optional) */
9716 + uint used; /* bytes read or written (optional) */
9717 + uint needed; /* bytes needed (optional) */
9721 + * Structure for passing hardware and software
9722 + * revision info up from the driver.
9724 +typedef struct wlc_rev_info {
9725 + uint vendorid; /* PCI vendor id */
9726 + uint deviceid; /* device id of chip */
9727 + uint radiorev; /* radio revision */
9728 + uint chiprev; /* chip revision */
9729 + uint corerev; /* core revision */
9730 + uint boardid; /* board identifier (usu. PCI sub-device id) */
9731 + uint boardvendor; /* board vendor (usu. PCI sub-vendor id) */
9732 + uint boardrev; /* board revision */
9733 + uint driverrev; /* driver version */
9734 + uint ucoderev; /* microcode version */
9735 + uint bus; /* bus type */
9736 + uint chipnum; /* chip number */
9739 +#define WL_BRAND_MAX 10
9740 +typedef struct wl_instance_info {
9742 + char brand[WL_BRAND_MAX];
9743 +} wl_instance_info_t;
9745 +/* check this magic number */
9746 +#define WLC_IOCTL_MAGIC 0x14e46c77
9748 +/* bump this number if you change the ioctl interface */
9749 +#define WLC_IOCTL_VERSION 1
9751 +#define WLC_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */
9752 +#define WLC_IOCTL_SMLEN 256 /* "small" length ioctl buffer required */
9754 +/* common ioctl definitions */
9755 +#define WLC_GET_MAGIC 0
9756 +#define WLC_GET_VERSION 1
9760 +#define WLC_GET_MSGLEVEL 7
9761 +#define WLC_SET_MSGLEVEL 8
9762 +#define WLC_GET_PROMISC 9
9763 +#define WLC_SET_PROMISC 10
9764 +#define WLC_GET_RATE 12
9765 +/* #define WLC_SET_RATE 13 */ /* no longer supported */
9766 +#define WLC_GET_INSTANCE 14
9767 +/* #define WLC_GET_FRAG 15 */ /* no longer supported */
9768 +/* #define WLC_SET_FRAG 16 */ /* no longer supported */
9769 +/* #define WLC_GET_RTS 17 */ /* no longer supported */
9770 +/* #define WLC_SET_RTS 18 */ /* no longer supported */
9771 +#define WLC_GET_INFRA 19
9772 +#define WLC_SET_INFRA 20
9773 +#define WLC_GET_AUTH 21
9774 +#define WLC_SET_AUTH 22
9775 +#define WLC_GET_BSSID 23
9776 +#define WLC_SET_BSSID 24
9777 +#define WLC_GET_SSID 25
9778 +#define WLC_SET_SSID 26
9779 +#define WLC_RESTART 27
9780 +#define WLC_GET_CHANNEL 29
9781 +#define WLC_SET_CHANNEL 30
9782 +#define WLC_GET_SRL 31
9783 +#define WLC_SET_SRL 32
9784 +#define WLC_GET_LRL 33
9785 +#define WLC_SET_LRL 34
9786 +#define WLC_GET_PLCPHDR 35
9787 +#define WLC_SET_PLCPHDR 36
9788 +#define WLC_GET_RADIO 37
9789 +#define WLC_SET_RADIO 38
9790 +#define WLC_GET_PHYTYPE 39
9791 +/* #define WLC_GET_WEP 42 */ /* no longer supported */
9792 +/* #define WLC_SET_WEP 43 */ /* no longer supported */
9793 +#define WLC_GET_KEY 44
9794 +#define WLC_SET_KEY 45
9795 +#define WLC_GET_REGULATORY 46
9796 +#define WLC_SET_REGULATORY 47
9797 +#define WLC_SCAN 50
9798 +#define WLC_SCAN_RESULTS 51
9799 +#define WLC_DISASSOC 52
9800 +#define WLC_REASSOC 53
9801 +#define WLC_GET_ROAM_TRIGGER 54
9802 +#define WLC_SET_ROAM_TRIGGER 55
9803 +#define WLC_GET_TXANT 61
9804 +#define WLC_SET_TXANT 62
9805 +#define WLC_GET_ANTDIV 63
9806 +#define WLC_SET_ANTDIV 64
9807 +/* #define WLC_GET_TXPWR 65 */ /* no longer supported */
9808 +/* #define WLC_SET_TXPWR 66 */ /* no longer supported */
9809 +#define WLC_GET_CLOSED 67
9810 +#define WLC_SET_CLOSED 68
9811 +#define WLC_GET_MACLIST 69
9812 +#define WLC_SET_MACLIST 70
9813 +#define WLC_GET_RATESET 71
9814 +#define WLC_SET_RATESET 72
9815 +#define WLC_GET_LOCALE 73
9816 +#define WLC_LONGTRAIN 74
9817 +#define WLC_GET_BCNPRD 75
9818 +#define WLC_SET_BCNPRD 76
9819 +#define WLC_GET_DTIMPRD 77
9820 +#define WLC_SET_DTIMPRD 78
9821 +#define WLC_GET_SROM 79
9822 +#define WLC_SET_SROM 80
9823 +#define WLC_GET_WEP_RESTRICT 81
9824 +#define WLC_SET_WEP_RESTRICT 82
9825 +#define WLC_GET_COUNTRY 83
9826 +#define WLC_SET_COUNTRY 84
9827 +#define WLC_GET_REVINFO 98
9828 +#define WLC_GET_MACMODE 105
9829 +#define WLC_SET_MACMODE 106
9830 +#define WLC_GET_GMODE 109
9831 +#define WLC_SET_GMODE 110
9832 +#define WLC_GET_CURR_RATESET 114 /* current rateset */
9833 +#define WLC_GET_SCANSUPPRESS 115
9834 +#define WLC_SET_SCANSUPPRESS 116
9835 +#define WLC_GET_AP 117
9836 +#define WLC_SET_AP 118
9837 +#define WLC_GET_EAP_RESTRICT 119
9838 +#define WLC_SET_EAP_RESTRICT 120
9839 +#define WLC_GET_WDSLIST 123
9840 +#define WLC_SET_WDSLIST 124
9841 +#define WLC_GET_RSSI 127
9842 +#define WLC_GET_WSEC 133
9843 +#define WLC_SET_WSEC 134
9844 +#define WLC_GET_BSS_INFO 136
9845 +#define WLC_GET_LAZYWDS 138
9846 +#define WLC_SET_LAZYWDS 139
9847 +#define WLC_GET_BANDLIST 140
9848 +#define WLC_GET_BAND 141
9849 +#define WLC_SET_BAND 142
9850 +#define WLC_GET_SHORTSLOT 144
9851 +#define WLC_GET_SHORTSLOT_OVERRIDE 145
9852 +#define WLC_SET_SHORTSLOT_OVERRIDE 146
9853 +#define WLC_GET_SHORTSLOT_RESTRICT 147
9854 +#define WLC_SET_SHORTSLOT_RESTRICT 148
9855 +#define WLC_GET_GMODE_PROTECTION 149
9856 +#define WLC_GET_GMODE_PROTECTION_OVERRIDE 150
9857 +#define WLC_SET_GMODE_PROTECTION_OVERRIDE 151
9858 +#define WLC_UPGRADE 152
9859 +/* #define WLC_GET_MRATE 153 */ /* no longer supported */
9860 +/* #define WLC_SET_MRATE 154 */ /* no longer supported */
9861 +#define WLC_GET_ASSOCLIST 159
9862 +#define WLC_GET_CLK 160
9863 +#define WLC_SET_CLK 161
9864 +#define WLC_GET_UP 162
9865 +#define WLC_OUT 163
9866 +#define WLC_GET_WPA_AUTH 164
9867 +#define WLC_SET_WPA_AUTH 165
9868 +#define WLC_GET_GMODE_PROTECTION_CONTROL 178
9869 +#define WLC_SET_GMODE_PROTECTION_CONTROL 179
9870 +#define WLC_GET_PHYLIST 180
9871 +#define WLC_GET_KEY_SEQ 183
9872 +#define WLC_GET_GMODE_PROTECTION_CTS 198
9873 +#define WLC_SET_GMODE_PROTECTION_CTS 199
9874 +#define WLC_GET_PIOMODE 203
9875 +#define WLC_SET_PIOMODE 204
9876 +#define WLC_SET_LED 209
9877 +#define WLC_GET_LED 210
9878 +#define WLC_GET_CHANNEL_SEL 215
9879 +#define WLC_START_CHANNEL_SEL 216
9880 +#define WLC_GET_VALID_CHANNELS 217
9881 +#define WLC_GET_FAKEFRAG 218
9882 +#define WLC_SET_FAKEFRAG 219
9883 +#define WLC_GET_WET 230
9884 +#define WLC_SET_WET 231
9885 +#define WLC_GET_KEY_PRIMARY 235
9886 +#define WLC_SET_KEY_PRIMARY 236
9887 +#define WLC_GET_RADAR 242
9888 +#define WLC_SET_RADAR 243
9889 +#define WLC_SET_SPECT_MANAGMENT 244
9890 +#define WLC_GET_SPECT_MANAGMENT 245
9891 +#define WLC_WDS_GET_REMOTE_HWADDR 246 /* currently handled in wl_linux.c/wl_vx.c */
9892 +#define WLC_SET_CS_SCAN_TIMER 248
9893 +#define WLC_GET_CS_SCAN_TIMER 249
9894 +#define WLC_SEND_PWR_CONSTRAINT 254
9895 +#define WLC_CURRENT_PWR 256
9896 +#define WLC_GET_CHANNELS_IN_COUNTRY 260
9897 +#define WLC_GET_COUNTRY_LIST 261
9898 +#define WLC_GET_VAR 262 /* get value of named variable */
9899 +#define WLC_SET_VAR 263 /* set named variable to value */
9900 +#define WLC_NVRAM_GET 264
9901 +#define WLC_NVRAM_SET 265
9902 +#define WLC_SET_WSEC_PMK 268
9903 +#define WLC_GET_AUTH_MODE 269
9904 +#define WLC_SET_AUTH_MODE 270
9905 +#define WLC_NDCONFIG_ITEM 273 /* currently handled in wl_oid.c */
9906 +#define WLC_NVOTPW 274
9907 +/* #define WLC_OTPW 275 */ /* no longer supported */
9908 +#define WLC_SET_LOCALE 278
9909 +#define WLC_LAST 279 /* do not change - use get_var/set_var */
9912 + * Minor kludge alert:
9913 + * Duplicate a few definitions that irelay requires from epiioctl.h here
9914 + * so caller doesn't have to include this file and epiioctl.h .
9915 + * If this grows any more, it would be time to move these irelay-specific
9916 + * definitions out of the epiioctl.h and into a separate driver common file.
9918 +#ifndef EPICTRL_COOKIE
9919 +#define EPICTRL_COOKIE 0xABADCEDE
9922 +/* vx wlc ioctl's offset */
9923 +#define CMN_IOCTL_OFF 0x180
9926 + * custom OID support
9928 + * 0xFF - implementation specific OID
9929 + * 0xE4 - first byte of Broadcom PCI vendor ID
9930 + * 0x14 - second byte of Broadcom PCI vendor ID
9931 + * 0xXX - the custom OID number
9934 +/* begin 0x1f values beyond the start of the ET driver range. */
9935 +#define WL_OID_BASE 0xFFE41420
9937 +/* NDIS overrides */
9938 +#define OID_WL_GETINSTANCE (WL_OID_BASE + WLC_GET_INSTANCE)
9939 +#define OID_WL_NDCONFIG_ITEM (WL_OID_BASE + WLC_NDCONFIG_ITEM)
9941 +#define WL_DECRYPT_STATUS_SUCCESS 1
9942 +#define WL_DECRYPT_STATUS_FAILURE 2
9943 +#define WL_DECRYPT_STATUS_UNKNOWN 3
9945 +/* allows user-mode app to poll the status of USB image upgrade */
9946 +#define WLC_UPGRADE_SUCCESS 0
9947 +#define WLC_UPGRADE_PENDING 1
9949 +#ifdef CONFIG_USBRNDIS_RETAIL
9950 +/* struct passed in for WLC_NDCONFIG_ITEM */
9957 +/* Bit masks for radio disabled status - returned by WL_GET_RADIO */
9958 +#define WL_RADIO_SW_DISABLE (1<<0)
9959 +#define WL_RADIO_HW_DISABLE (1<<1)
9960 +#define WL_RADIO_MPC_DISABLE (1<<2)
9961 +#define WL_RADIO_COUNTRY_DISABLE (1<<3) /* some countries don't support any 802.11 channel */
9963 +/* Override bit for WLC_SET_TXPWR. if set, ignore other level limits */
9964 +#define WL_TXPWR_OVERRIDE (1<<31)
9966 +/* "diag" iovar argument and error code */
9967 +#define WL_DIAG_INTERRUPT 1 /* d11 loopback interrupt test */
9968 +#define WL_DIAG_MEMORY 3 /* d11 memory test */
9969 +#define WL_DIAG_LED 4 /* LED test */
9970 +#define WL_DIAG_REG 5 /* d11/phy register test */
9971 +#define WL_DIAG_SROM 6 /* srom read/crc test */
9972 +#define WL_DIAG_DMA 7 /* DMA test */
9974 +#define WL_DIAGERR_SUCCESS 0
9975 +#define WL_DIAGERR_FAIL_TO_RUN 1 /* unable to run requested diag */
9976 +#define WL_DIAGERR_NOT_SUPPORTED 2 /* diag requested is not supported */
9977 +#define WL_DIAGERR_INTERRUPT_FAIL 3 /* loopback interrupt test failed */
9978 +#define WL_DIAGERR_LOOPBACK_FAIL 4 /* loopback data test failed */
9979 +#define WL_DIAGERR_SROM_FAIL 5 /* srom read failed */
9980 +#define WL_DIAGERR_SROM_BADCRC 6 /* srom crc failed */
9981 +#define WL_DIAGERR_REG_FAIL 7 /* d11/phy register test failed */
9982 +#define WL_DIAGERR_MEMORY_FAIL 8 /* d11 memory test failed */
9983 +#define WL_DIAGERR_NOMEM 9 /* diag test failed due to no memory */
9984 +#define WL_DIAGERR_DMA_FAIL 10 /* DMA test failed */
9987 +#define WL_SB_BUS 0 /* Silicon Backplane */
9988 +#define WL_PCI_BUS 1 /* PCI target */
9989 +#define WL_PCMCIA_BUS 2 /* PCMCIA target */
9992 +#define WLC_BAND_AUTO 0 /* auto-select */
9993 +#define WLC_BAND_A 1 /* "a" band (5 Ghz) */
9994 +#define WLC_BAND_B 2 /* "b" band (2.4 Ghz) */
9995 +#define WLC_BAND_ALL 3 /* all bands */
9997 +/* phy types (returned by WLC_GET_PHYTPE) */
9998 +#define WLC_PHY_TYPE_A 0
9999 +#define WLC_PHY_TYPE_B 1
10000 +#define WLC_PHY_TYPE_G 2
10001 +#define WLC_PHY_TYPE_NULL 0xf
10003 +/* MAC list modes */
10004 +#define WLC_MACMODE_DISABLED 0 /* MAC list disabled */
10005 +#define WLC_MACMODE_DENY 1 /* Deny specified (i.e. allow unspecified) */
10006 +#define WLC_MACMODE_ALLOW 2 /* Allow specified (i.e. deny unspecified) */
10011 +#define GMODE_LEGACY_B 0
10012 +#define GMODE_AUTO 1
10013 +#define GMODE_ONLY 2
10014 +#define GMODE_B_DEFERRED 3
10015 +#define GMODE_PERFORMANCE 4
10016 +#define GMODE_LRS 5
10017 +#define GMODE_MAX 6
10019 +/* values for PLCPHdr_override */
10020 +#define WLC_PLCP_AUTO -1
10021 +#define WLC_PLCP_SHORT 0
10022 +#define WLC_PLCP_LONG 1
10024 +/* values for g_protection_override */
10025 +#define WLC_G_PROTECTION_AUTO -1
10026 +#define WLC_G_PROTECTION_OFF 0
10027 +#define WLC_G_PROTECTION_ON 1
10029 +/* values for g_protection_control */
10030 +#define WLC_G_PROTECTION_CTL_OFF 0
10031 +#define WLC_G_PROTECTION_CTL_LOCAL 1
10032 +#define WLC_G_PROTECTION_CTL_OVERLAP 2
10034 +/* Values for PM */
10042 + int npulses; /* required number of pulses at n * t_int */
10043 + int ncontig; /* required number of pulses at t_int */
10044 + int min_pw; /* minimum pulse width (20 MHz clocks) */
10045 + int max_pw; /* maximum pulse width (20 MHz clocks) */
10046 + uint16 thresh0; /* Radar detection, thresh 0 */
10047 + uint16 thresh1; /* Radar detection, thresh 1 */
10048 +} wl_radar_args_t;
10050 +/* radar iovar SET defines */
10051 +#define WL_RADRA_DETECTOR_OFF 0 /* radar dector off */
10052 +#define WL_RADAR_DETECTOR_ON 1 /* radar detector on */
10053 +#define WL_RADAR_SIMULATED 2 /* force radar detector to declare detection once */
10055 +/* dfs_status iovar-related defines */
10057 +/* cac - channel availability check,
10058 + * ism - in-service monitoring
10059 + * csa - channel switching anouncement
10062 +/* cac state values */
10063 +#define WL_DFS_CACSTATE_IDLE 0 /* state for operating in non-radar channel */
10064 +#define WL_DFS_CACSTATE_PREISM_CAC 1 /* CAC in progress */
10065 +#define WL_DFS_CACSTATE_ISM 2 /* ISM in progress */
10066 +#define WL_DFS_CACSTATE_CSA 3 /* csa */
10067 +#define WL_DFS_CACSTATE_POSTISM_CAC 4 /* ISM CAC */
10068 +#define WL_DFS_CACSTATE_PREISM_OOC 5 /* PREISM OOC */
10069 +#define WL_DFS_CACSTATE_POSTISM_OOC 6 /* POSTISM OOC */
10070 +#define WL_DFS_CACSTATES 7 /* this many states exist */
10072 +/* data structure used in 'dfs_status' wl interface, which is used to query dfs status */
10074 + uint state; /* noted by WL_DFS_CACSTATE_XX. */
10075 + uint duration; /* time spent in ms in state. */
10076 + /* as dfs enters ISM state, it removes the operational channel from quiet channel list
10077 + * and notes the channel in channel_cleared. set to 0 if no channel is cleared
10079 + uint channel_cleared;
10080 +} wl_dfs_status_t;
10082 +#define NUM_PWRCTRL_RATES 12
10085 +/* 802.11h enforcement levels */
10086 +#define SPECT_MNGMT_OFF 0 /* 11h disabled */
10087 +#define SPECT_MNGMT_LOOSE 1 /* allow scan lists to contain non-11h AP */
10088 +#define SPECT_MNGMT_STRICT 2 /* prune out non-11h APs from scan list */
10089 +#define SPECT_MNGMT_11D 3 /* switch to 802.11D mode */
10091 +#define WL_CHAN_VALID_HW (1 << 0) /* valid with current HW */
10092 +#define WL_CHAN_VALID_SW (1 << 1) /* valid with current country setting */
10093 +#define WL_CHAN_BAND_A (1 << 2) /* A-band channel */
10094 +#define WL_CHAN_RADAR (1 << 3) /* radar sensitive channel */
10095 +#define WL_CHAN_INACTIVE (1 << 4) /* temporarily out of service due to radar */
10096 +#define WL_CHAN_RADAR_PASSIVE (1 << 5) /* radar channel is in passive mode */
10098 +#define WL_MPC_VAL 0x00400000
10099 +#define WL_APSTA_VAL 0x00800000
10100 +#define WL_DFS_VAL 0x01000000
10102 +/* max # of leds supported by GPIO (gpio pin# == led index#) */
10103 +#define WL_LED_NUMGPIO 16 /* gpio 0-15 */
10105 +/* led per-pin behaviors */
10106 +#define WL_LED_OFF 0 /* always off */
10107 +#define WL_LED_ON 1 /* always on */
10108 +#define WL_LED_ACTIVITY 2 /* activity */
10109 +#define WL_LED_RADIO 3 /* radio enabled */
10110 +#define WL_LED_ARADIO 4 /* 5 Ghz radio enabled */
10111 +#define WL_LED_BRADIO 5 /* 2.4Ghz radio enabled */
10112 +#define WL_LED_BGMODE 6 /* on if gmode, off if bmode */
10113 +#define WL_LED_WI1 7
10114 +#define WL_LED_WI2 8
10115 +#define WL_LED_WI3 9
10116 +#define WL_LED_ASSOC 10 /* associated state indicator */
10117 +#define WL_LED_INACTIVE 11 /* null behavior (clears default behavior) */
10118 +#define WL_LED_NUMBEHAVIOR 12
10120 +/* led behavior numeric value format */
10121 +#define WL_LED_BEH_MASK 0x7f /* behavior mask */
10122 +#define WL_LED_AL_MASK 0x80 /* activelow (polarity) bit */
10125 +/* WDS link local endpoint WPA role */
10126 +#define WL_WDS_WPA_ROLE_AUTH 0 /* authenticator */
10127 +#define WL_WDS_WPA_ROLE_SUP 1 /* supplicant */
10128 +#define WL_WDS_WPA_ROLE_AUTO 255 /* auto, based on mac addr value */
10130 +/* number of bytes needed to define a 128-bit mask for MAC event reporting */
10131 +#define WL_EVENTING_MASK_LEN 16
10133 +/* Structures and constants used for "vndr_ie" IOVar interface */
10134 +#define VNDR_IE_CMD_LEN 4 /* length of the set command string: "add", "del" (+ NULL) */
10136 +/* 802.11 Mgmt Packet flags */
10137 +#define VNDR_IE_BEACON_FLAG 0x1
10138 +#define VNDR_IE_PRBRSP_FLAG 0x2
10139 +#define VNDR_IE_ASSOCRSP_FLAG 0x4
10140 +#define VNDR_IE_AUTHRSP_FLAG 0x8
10143 + uint32 pktflag; /* bitmask indicating which packet(s) contain this IE */
10144 + vndr_ie_t vndr_ie_data; /* vendor IE data */
10148 + int iecount; /* number of entries in the vndr_ie_list[] array */
10149 + vndr_ie_info_t vndr_ie_list[1]; /* variable size list of vndr_ie_info_t structs */
10153 + char cmd[VNDR_IE_CMD_LEN]; /* vndr_ie IOVar set command : "add", "del" + NULL */
10154 + vndr_ie_buf_t vndr_ie_buffer; /* buffer containing Vendor IE list information */
10155 +} vndr_ie_setbuf_t;
10157 +/* join target preference types */
10158 +#define WL_JOIN_PREF_RSSI 1 /* by RSSI, mandatory */
10159 +#define WL_JOIN_PREF_WPA 2 /* by akm and ciphers, optional, RSN and WPA as values */
10160 +#define WL_JOIN_PREF_BAND 3 /* by 802.11 band, optional, WLC_BAND_XXXX as values */
10162 +/* band preference */
10163 +#define WLJP_BAND_ASSOC_PREF 255 /* use assoc preference settings */
10164 + /* others use WLC_BAND_XXXX as values */
10166 +/* any multicast cipher suite */
10167 +#define WL_WPA_ACP_MCS_ANY "\x00\x00\x00\x00"
10169 +#if !defined(__GNUC__)
10173 +#define NFIFO 6 /* # tx/rx fifopairs */
10175 +#define WL_CNT_T_VERSION 1 /* current version of wl_cnt_t struct */
10178 + uint16 version; /* see definition of WL_CNT_T_VERSION */
10179 + uint16 length; /* length of entire structure */
10181 + /* transmit stat counters */
10182 + uint32 txframe; /* tx data frames */
10183 + uint32 txbyte; /* tx data bytes */
10184 + uint32 txretrans; /* tx mac retransmits */
10185 + uint32 txerror; /* tx data errors */
10186 + uint32 txctl; /* tx management frames */
10187 + uint32 txprshort; /* tx short preamble frames */
10188 + uint32 txserr; /* tx status errors */
10189 + uint32 txnobuf; /* tx out of buffers errors */
10190 + uint32 txnoassoc; /* tx discard because we're not associated */
10191 + uint32 txrunt; /* tx runt frames */
10192 + uint32 txchit; /* tx header cache hit (fastpath) */
10193 + uint32 txcmiss; /* tx header cache miss (slowpath) */
10195 + /* transmit chip error counters */
10196 + uint32 txuflo; /* tx fifo underflows */
10197 + uint32 txphyerr; /* tx phy errors (indicated in tx status) */
10200 + /* receive stat counters */
10201 + uint32 rxframe; /* rx data frames */
10202 + uint32 rxbyte; /* rx data bytes */
10203 + uint32 rxerror; /* rx data errors */
10204 + uint32 rxctl; /* rx management frames */
10205 + uint32 rxnobuf; /* rx out of buffers errors */
10206 + uint32 rxnondata; /* rx non data frames in the data channel errors */
10207 + uint32 rxbadds; /* rx bad DS errors */
10208 + uint32 rxbadcm; /* rx bad control or management frames */
10209 + uint32 rxfragerr; /* rx fragmentation errors */
10210 + uint32 rxrunt; /* rx runt frames */
10211 + uint32 rxgiant; /* rx giant frames */
10212 + uint32 rxnoscb; /* rx no scb error */
10213 + uint32 rxbadproto; /* rx invalid frames */
10214 + uint32 rxbadsrcmac; /* rx frames with Invalid Src Mac*/
10215 + uint32 rxbadda; /* rx frames tossed for invalid da */
10216 + uint32 rxfilter; /* rx frames filtered out */
10218 + /* receive chip error counters */
10219 + uint32 rxoflo; /* rx fifo overflow errors */
10220 + uint32 rxuflo[NFIFO]; /* rx dma descriptor underflow errors */
10222 + uint32 d11cnt_txrts_off; /* d11cnt txrts value when reset d11cnt */
10223 + uint32 d11cnt_rxcrc_off; /* d11cnt rxcrc value when reset d11cnt */
10224 + uint32 d11cnt_txnocts_off; /* d11cnt txnocts value when reset d11cnt */
10226 + /* misc counters */
10227 + uint32 dmade; /* tx/rx dma descriptor errors */
10228 + uint32 dmada; /* tx/rx dma data errors */
10229 + uint32 dmape; /* tx/rx dma descriptor protocol errors */
10230 + uint32 reset; /* reset count */
10231 + uint32 tbtt; /* cnts the TBTT int's */
10234 + /* MAC counters: 32-bit version of d11.h's macstat_t */
10235 + uint32 txallfrm; /* total number of frames sent, incl. Data, ACK, RTS, CTS,
10236 + Control Management (includes retransmissions) */
10237 + uint32 txrtsfrm; /* number of RTS sent out by the MAC */
10238 + uint32 txctsfrm; /* number of CTS sent out by the MAC */
10239 + uint32 txackfrm; /* number of ACK frames sent out */
10240 + uint32 txdnlfrm; /* Not used */
10241 + uint32 txbcnfrm; /* beacons transmitted */
10242 + uint32 txfunfl[8]; /* per-fifo tx underflows */
10243 + uint32 txtplunfl; /* Template underflows (mac was too slow to transmit ACK/CTS or BCN) */
10244 + uint32 txphyerror; /* Transmit phy error, type of error is reported in tx-status for
10245 + driver enqueued frames*/
10246 + uint32 rxfrmtoolong; /* Received frame longer than legal limit (2346 bytes) */
10247 + uint32 rxfrmtooshrt; /* Received frame did not contain enough bytes for its frame type */
10248 + uint32 rxinvmachdr; /* Either the protocol version != 0 or frame type not
10249 + data/control/management*/
10250 + uint32 rxbadfcs; /* number of frames for which the CRC check failed in the MAC */
10251 + uint32 rxbadplcp; /* parity check of the PLCP header failed */
10252 + uint32 rxcrsglitch; /* PHY was able to correlate the preamble but not the header */
10253 + uint32 rxstrt; /* Number of received frames with a good PLCP (i.e. passing parity check) */
10254 + uint32 rxdfrmucastmbss; /* Number of received DATA frames with good FCS and matching RA */
10255 + uint32 rxmfrmucastmbss; /* number of received mgmt frames with good FCS and matching RA */
10256 + uint32 rxcfrmucast; /* number of received CNTRL frames with good FCS and matching RA */
10257 + uint32 rxrtsucast; /* number of unicast RTS addressed to the MAC (good FCS) */
10258 + uint32 rxctsucast; /* number of unicast CTS addressed to the MAC (good FCS)*/
10259 + uint32 rxackucast; /* number of ucast ACKS received (good FCS)*/
10260 + uint32 rxdfrmocast; /* number of received DATA frames with good FCS and not matching RA */
10261 + uint32 rxmfrmocast; /* number of received MGMT frames with good FCS and not matching RA */
10262 + uint32 rxcfrmocast; /* number of received CNTRL frame with good FCS and not matching RA */
10263 + uint32 rxrtsocast; /* number of received RTS not addressed to the MAC */
10264 + uint32 rxctsocast; /* number of received CTS not addressed to the MAC */
10265 + uint32 rxdfrmmcast; /* number of RX Data multicast frames received by the MAC */
10266 + uint32 rxmfrmmcast; /* number of RX Management multicast frames received by the MAC */
10267 + uint32 rxcfrmmcast; /* number of RX Control multicast frames received by the MAC (unlikely
10269 + uint32 rxbeaconmbss; /* beacons received from member of BSS */
10270 + uint32 rxdfrmucastobss; /* number of unicast frames addressed to the MAC from other BSS (WDS FRAME) */
10271 + uint32 rxbeaconobss; /* beacons received from other BSS */
10272 + uint32 rxrsptmout; /* Number of response timeouts for transmitted frames expecting a
10274 + uint32 bcntxcancl; /* transmit beacons cancelled due to receipt of beacon (IBSS) */
10275 + uint32 rxf0ovfl; /* Number of receive fifo 0 overflows */
10276 + uint32 rxf1ovfl; /* Number of receive fifo 1 overflows (obsolete) */
10277 + uint32 rxf2ovfl; /* Number of receive fifo 2 overflows (obsolete) */
10278 + uint32 txsfovfl; /* Number of transmit status fifo overflows (obsolete) */
10279 + uint32 pmqovfl; /* Number of PMQ overflows */
10280 + uint32 rxcgprqfrm; /* Number of received Probe requests that made it into the PRQ fifo */
10281 + uint32 rxcgprsqovfl; /* Rx Probe Request Que overflow in the AP */
10282 + uint32 txcgprsfail; /* Tx Probe Response Fail. AP sent probe response but did not get ACK */
10283 + uint32 txcgprssuc; /* Tx Probe Rresponse Success (ACK was received) */
10284 + uint32 prs_timeout; /* Number of probe requests that were dropped from the PRQ fifo because
10285 + a probe response could not be sent out within the time limit defined
10286 + in M_PRS_MAXTIME */
10287 + uint32 rxnack; /* Number of NACKS received (Afterburner) */
10288 + uint32 frmscons; /* Number of frames completed without transmission because of an
10289 + Afterburner re-queue */
10290 + uint32 txnack; /* Number of NACKs transmtitted (Afterburner) */
10291 + uint32 txglitch_nack; /* obsolete */
10292 + uint32 txburst; /* obsolete */
10293 + uint32 rxburst; /* obsolete */
10295 + /* 802.11 MIB counters, pp. 614 of 802.11 reaff doc. */
10296 + uint32 txfrag; /* dot11TransmittedFragmentCount */
10297 + uint32 txmulti; /* dot11MulticastTransmittedFrameCount */
10298 + uint32 txfail; /* dot11FailedCount */
10299 + uint32 txretry; /* dot11RetryCount */
10300 + uint32 txretrie; /* dot11MultipleRetryCount */
10301 + uint32 rxdup; /* dot11FrameduplicateCount */
10302 + uint32 txrts; /* dot11RTSSuccessCount */
10303 + uint32 txnocts; /* dot11RTSFailureCount */
10304 + uint32 txnoack; /* dot11ACKFailureCount */
10305 + uint32 rxfrag; /* dot11ReceivedFragmentCount */
10306 + uint32 rxmulti; /* dot11MulticastReceivedFrameCount */
10307 + uint32 rxcrc; /* dot11FCSErrorCount */
10308 + uint32 txfrmsnt; /* dot11TransmittedFrameCount (bogus MIB?) */
10309 + uint32 rxundec; /* dot11WEPUndecryptableCount */
10311 + /* WPA2 counters (see rxundec for DecryptFailureCount) */
10312 + uint32 tkipmicfaill; /* TKIPLocalMICFailures */
10313 + uint32 tkipcntrmsr; /* TKIPCounterMeasuresInvoked */
10314 + uint32 tkipreplay; /* TKIPReplays */
10315 + uint32 ccmpfmterr; /* CCMPFormatErrors */
10316 + uint32 ccmpreplay; /* CCMPReplays */
10317 + uint32 ccmpundec; /* CCMPDecryptErrors */
10318 + uint32 fourwayfail; /* FourWayHandshakeFailures */
10319 + uint32 wepundec; /* dot11WEPUndecryptableCount */
10320 + uint32 wepicverr; /* dot11WEPICVErrorCount */
10321 + uint32 decsuccess; /* DecryptSuccessCount */
10322 + uint32 tkipicverr; /* TKIPICVErrorCount */
10323 + uint32 wepexcluded; /* dot11WEPExcludedCount */
10326 +#endif /* _wlioctl_h_ */
10327 diff -urN linux.old/arch/mips/bcm947xx/nvram.c linux.dev/arch/mips/bcm947xx/nvram.c
10328 --- linux.old/arch/mips/bcm947xx/nvram.c 1970-01-01 01:00:00.000000000 +0100
10329 +++ linux.dev/arch/mips/bcm947xx/nvram.c 2005-11-07 21:57:07.881588000 +0100
10332 + * NVRAM variable manipulation (common)
10334 + * Copyright 2004, Broadcom Corporation
10335 + * All Rights Reserved.
10337 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10338 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10339 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10340 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10345 +#include <typedefs.h>
10347 +#include <bcmendian.h>
10348 +#include <bcmnvram.h>
10349 +#include <bcmutils.h>
10350 +#include <sbsdram.h>
10352 +extern struct nvram_tuple * BCMINIT(_nvram_realloc)(struct nvram_tuple *t, const char *name, const char *value);
10353 +extern void BCMINIT(_nvram_free)(struct nvram_tuple *t);
10354 +extern int BCMINIT(_nvram_read)(void *buf);
10356 +char * BCMINIT(_nvram_get)(const char *name);
10357 +int BCMINIT(_nvram_set)(const char *name, const char *value);
10358 +int BCMINIT(_nvram_unset)(const char *name);
10359 +int BCMINIT(_nvram_getall)(char *buf, int count);
10360 +int BCMINIT(_nvram_commit)(struct nvram_header *header);
10361 +int BCMINIT(_nvram_init)(void);
10362 +void BCMINIT(_nvram_exit)(void);
10364 +static struct nvram_tuple * BCMINITDATA(nvram_hash)[257];
10365 +static struct nvram_tuple * nvram_dead;
10367 +/* Free all tuples. Should be locked. */
10369 +BCMINITFN(nvram_free)(void)
10372 + struct nvram_tuple *t, *next;
10374 + /* Free hash table */
10375 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
10376 + for (t = BCMINIT(nvram_hash)[i]; t; t = next) {
10378 + BCMINIT(_nvram_free)(t);
10380 + BCMINIT(nvram_hash)[i] = NULL;
10383 + /* Free dead table */
10384 + for (t = nvram_dead; t; t = next) {
10386 + BCMINIT(_nvram_free)(t);
10388 + nvram_dead = NULL;
10390 + /* Indicate to per-port code that all tuples have been freed */
10391 + BCMINIT(_nvram_free)(NULL);
10395 +static INLINE uint
10396 +hash(const char *s)
10401 + hash = 31 * hash + *s++;
10406 +/* (Re)initialize the hash table. Should be locked. */
10408 +BCMINITFN(nvram_rehash)(struct nvram_header *header)
10410 + char buf[] = "0xXXXXXXXX", *name, *value, *end, *eq;
10412 + /* (Re)initialize hash table */
10413 + BCMINIT(nvram_free)();
10415 + /* Parse and set "name=value\0 ... \0\0" */
10416 + name = (char *) &header[1];
10417 + end = (char *) header + NVRAM_SPACE - 2;
10418 + end[0] = end[1] = '\0';
10419 + for (; *name; name = value + strlen(value) + 1) {
10420 + if (!(eq = strchr(name, '=')))
10424 + BCMINIT(_nvram_set)(name, value);
10428 + /* Set special SDRAM parameters */
10429 + if (!BCMINIT(_nvram_get)("sdram_init")) {
10430 + sprintf(buf, "0x%04X", (uint16)(header->crc_ver_init >> 16));
10431 + BCMINIT(_nvram_set)("sdram_init", buf);
10433 + if (!BCMINIT(_nvram_get)("sdram_config")) {
10434 + sprintf(buf, "0x%04X", (uint16)(header->config_refresh & 0xffff));
10435 + BCMINIT(_nvram_set)("sdram_config", buf);
10437 + if (!BCMINIT(_nvram_get)("sdram_refresh")) {
10438 + sprintf(buf, "0x%04X", (uint16)((header->config_refresh >> 16) & 0xffff));
10439 + BCMINIT(_nvram_set)("sdram_refresh", buf);
10441 + if (!BCMINIT(_nvram_get)("sdram_ncdl")) {
10442 + sprintf(buf, "0x%08X", header->config_ncdl);
10443 + BCMINIT(_nvram_set)("sdram_ncdl", buf);
10449 +/* Get the value of an NVRAM variable. Should be locked. */
10451 +BCMINITFN(_nvram_get)(const char *name)
10454 + struct nvram_tuple *t;
10460 + /* Hash the name */
10461 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
10463 + /* Find the associated tuple in the hash table */
10464 + for (t = BCMINIT(nvram_hash)[i]; t && strcmp(t->name, name); t = t->next);
10466 + value = t ? t->value : NULL;
10471 +/* Get the value of an NVRAM variable. Should be locked. */
10473 +BCMINITFN(_nvram_set)(const char *name, const char *value)
10476 + struct nvram_tuple *t, *u, **prev;
10478 + /* Hash the name */
10479 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
10481 + /* Find the associated tuple in the hash table */
10482 + for (prev = &BCMINIT(nvram_hash)[i], t = *prev; t && strcmp(t->name, name); prev = &t->next, t = *prev);
10484 + /* (Re)allocate tuple */
10485 + if (!(u = BCMINIT(_nvram_realloc)(t, name, value)))
10486 + return -12; /* -ENOMEM */
10488 + /* Value reallocated */
10492 + /* Move old tuple to the dead table */
10495 + t->next = nvram_dead;
10499 + /* Add new tuple to the hash table */
10500 + u->next = BCMINIT(nvram_hash)[i];
10501 + BCMINIT(nvram_hash)[i] = u;
10506 +/* Unset the value of an NVRAM variable. Should be locked. */
10508 +BCMINITFN(_nvram_unset)(const char *name)
10511 + struct nvram_tuple *t, **prev;
10516 + /* Hash the name */
10517 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
10519 + /* Find the associated tuple in the hash table */
10520 + for (prev = &BCMINIT(nvram_hash)[i], t = *prev; t && strcmp(t->name, name); prev = &t->next, t = *prev);
10522 + /* Move it to the dead table */
10525 + t->next = nvram_dead;
10532 +/* Get all NVRAM variables. Should be locked. */
10534 +BCMINITFN(_nvram_getall)(char *buf, int count)
10537 + struct nvram_tuple *t;
10540 + bzero(buf, count);
10542 + /* Write name=value\0 ... \0\0 */
10543 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
10544 + for (t = BCMINIT(nvram_hash)[i]; t; t = t->next) {
10545 + if ((count - len) > (strlen(t->name) + 1 + strlen(t->value) + 1))
10546 + len += sprintf(buf + len, "%s=%s", t->name, t->value) + 1;
10555 +/* Regenerate NVRAM. Should be locked. */
10557 +BCMINITFN(_nvram_commit)(struct nvram_header *header)
10559 + char *init, *config, *refresh, *ncdl;
10562 + struct nvram_tuple *t;
10563 + struct nvram_header tmp;
10566 + /* Regenerate header */
10567 + header->magic = NVRAM_MAGIC;
10568 + header->crc_ver_init = (NVRAM_VERSION << 8);
10569 + if (!(init = BCMINIT(_nvram_get)("sdram_init")) ||
10570 + !(config = BCMINIT(_nvram_get)("sdram_config")) ||
10571 + !(refresh = BCMINIT(_nvram_get)("sdram_refresh")) ||
10572 + !(ncdl = BCMINIT(_nvram_get)("sdram_ncdl"))) {
10573 + header->crc_ver_init |= SDRAM_INIT << 16;
10574 + header->config_refresh = SDRAM_CONFIG;
10575 + header->config_refresh |= SDRAM_REFRESH << 16;
10576 + header->config_ncdl = 0;
10578 + header->crc_ver_init |= (bcm_strtoul(init, NULL, 0) & 0xffff) << 16;
10579 + header->config_refresh = bcm_strtoul(config, NULL, 0) & 0xffff;
10580 + header->config_refresh |= (bcm_strtoul(refresh, NULL, 0) & 0xffff) << 16;
10581 + header->config_ncdl = bcm_strtoul(ncdl, NULL, 0);
10584 + /* Clear data area */
10585 + ptr = (char *) header + sizeof(struct nvram_header);
10586 + bzero(ptr, NVRAM_SPACE - sizeof(struct nvram_header));
10588 + /* Leave space for a double NUL at the end */
10589 + end = (char *) header + NVRAM_SPACE - 2;
10591 + /* Write out all tuples */
10592 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
10593 + for (t = BCMINIT(nvram_hash)[i]; t; t = t->next) {
10594 + if ((ptr + strlen(t->name) + 1 + strlen(t->value) + 1) > end)
10596 + ptr += sprintf(ptr, "%s=%s", t->name, t->value) + 1;
10600 + /* End with a double NUL */
10603 + /* Set new length */
10604 + header->len = ROUNDUP(ptr - (char *) header, 4);
10606 + /* Little-endian CRC8 over the last 11 bytes of the header */
10607 + tmp.crc_ver_init = htol32(header->crc_ver_init);
10608 + tmp.config_refresh = htol32(header->config_refresh);
10609 + tmp.config_ncdl = htol32(header->config_ncdl);
10610 + crc = hndcrc8((char *) &tmp + 9, sizeof(struct nvram_header) - 9, CRC8_INIT_VALUE);
10612 + /* Continue CRC8 over data bytes */
10613 + crc = hndcrc8((char *) &header[1], header->len - sizeof(struct nvram_header), crc);
10615 + /* Set new CRC8 */
10616 + header->crc_ver_init |= crc;
10618 + /* Reinitialize hash table */
10619 + return BCMINIT(nvram_rehash)(header);
10622 +/* Initialize hash table. Should be locked. */
10624 +BCMINITFN(_nvram_init)(void)
10626 + struct nvram_header *header;
10630 + /* get kernel osl handler */
10631 + osh = osl_attach(NULL);
10633 + if (!(header = (struct nvram_header *) MALLOC(osh, NVRAM_SPACE))) {
10634 + printf("nvram_init: out of memory, malloced %d bytes\n", MALLOCED(osh));
10635 + return -12; /* -ENOMEM */
10638 + if ((ret = BCMINIT(_nvram_read)(header)) == 0 &&
10639 + header->magic == NVRAM_MAGIC)
10640 + BCMINIT(nvram_rehash)(header);
10642 + MFREE(osh, header, NVRAM_SPACE);
10646 +/* Free hash table. Should be locked. */
10648 +BCMINITFN(_nvram_exit)(void)
10650 + BCMINIT(nvram_free)();
10652 diff -urN linux.old/arch/mips/bcm947xx/nvram_linux.c linux.dev/arch/mips/bcm947xx/nvram_linux.c
10653 --- linux.old/arch/mips/bcm947xx/nvram_linux.c 1970-01-01 01:00:00.000000000 +0100
10654 +++ linux.dev/arch/mips/bcm947xx/nvram_linux.c 2005-11-08 00:54:56.755597250 +0100
10657 + * NVRAM variable manipulation (Linux kernel half)
10659 + * Copyright 2005, Broadcom Corporation
10660 + * All Rights Reserved.
10662 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10663 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10664 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10665 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10670 +#include <linux/config.h>
10671 +#include <linux/init.h>
10672 +#include <linux/module.h>
10673 +#include <linux/kernel.h>
10674 +#include <linux/string.h>
10675 +#include <linux/interrupt.h>
10676 +#include <linux/spinlock.h>
10677 +#include <linux/slab.h>
10678 +#include <linux/bootmem.h>
10679 +#include <linux/wrapper.h>
10680 +#include <linux/fs.h>
10681 +#include <linux/miscdevice.h>
10682 +#include <linux/mtd/mtd.h>
10683 +#include <asm/addrspace.h>
10684 +#include <asm/io.h>
10685 +#include <asm/uaccess.h>
10687 +#include <typedefs.h>
10688 +#include <bcmendian.h>
10689 +#include <bcmnvram.h>
10690 +#include <bcmutils.h>
10691 +#include <sbconfig.h>
10692 +#include <sbchipc.h>
10693 +#include <sbutils.h>
10694 +#include <sbmips.h>
10695 +#include <sflash.h>
10697 +/* In BSS to minimize text size and page aligned so it can be mmap()-ed */
10698 +static char nvram_buf[NVRAM_SPACE] __attribute__((aligned(PAGE_SIZE)));
10702 +#define early_nvram_get(name) nvram_get(name)
10704 +#else /* !MODULE */
10706 +/* Global SB handle */
10707 +extern void *bcm947xx_sbh;
10708 +extern spinlock_t bcm947xx_sbh_lock;
10711 +#define sbh bcm947xx_sbh
10712 +#define sbh_lock bcm947xx_sbh_lock
10714 +#define MB * 1024 * 1024
10716 +/* Probe for NVRAM header */
10717 +static void __init
10718 +early_nvram_init(void)
10720 + struct nvram_header *header;
10722 + struct sflash *info = NULL;
10724 + uint32 base, off, lim;
10727 + if ((cc = sb_setcore(sbh, SB_CC, 0)) != NULL) {
10728 + base = KSEG1ADDR(SB_FLASH2);
10729 + switch (readl(&cc->capabilities) & CAP_FLASH_MASK) {
10731 + lim = SB_FLASH2_SZ;
10736 + if ((info = sflash_init(cc)) == NULL)
10738 + lim = info->size;
10746 + /* extif assumed, Stop at 4 MB */
10747 + base = KSEG1ADDR(SB_FLASH1);
10748 + lim = SB_FLASH1_SZ;
10752 + while (off <= lim) {
10753 + /* Windowed flash access */
10754 + header = (struct nvram_header *) KSEG1ADDR(base + off - NVRAM_SPACE);
10755 + if (header->magic == NVRAM_MAGIC)
10760 + /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
10761 + header = (struct nvram_header *) KSEG1ADDR(base + 4 KB);
10762 + if (header->magic == NVRAM_MAGIC)
10765 + header = (struct nvram_header *) KSEG1ADDR(base + 1 KB);
10766 + if (header->magic == NVRAM_MAGIC)
10769 + printk("early_nvram_init: NVRAM not found\n");
10773 + src = (u32 *) header;
10774 + dst = (u32 *) nvram_buf;
10775 + for (i = 0; i < sizeof(struct nvram_header); i += 4)
10777 + for (; i < header->len && i < NVRAM_SPACE; i += 4)
10778 + *dst++ = ltoh32(*src++);
10781 +/* Early (before mm or mtd) read-only access to NVRAM */
10782 +static char * __init
10783 +early_nvram_get(const char *name)
10785 + char *var, *value, *end, *eq;
10794 + if (!nvram_buf[0])
10795 + early_nvram_init();
10797 + /* Look for name=value and return value */
10798 + var = &nvram_buf[sizeof(struct nvram_header)];
10799 + end = nvram_buf + sizeof(nvram_buf) - 2;
10800 + end[0] = end[1] = '\0';
10801 + for (; *var; var = value + strlen(value) + 1) {
10802 + if (!(eq = strchr(var, '=')))
10805 + if ((eq - var) == strlen(name) && strncmp(var, name, (eq - var)) == 0)
10812 +#endif /* !MODULE */
10814 +extern char * _nvram_get(const char *name);
10815 +extern int _nvram_set(const char *name, const char *value);
10816 +extern int _nvram_unset(const char *name);
10817 +extern int _nvram_getall(char *buf, int count);
10818 +extern int _nvram_commit(struct nvram_header *header);
10819 +extern int _nvram_init(void);
10820 +extern void _nvram_exit(void);
10823 +static spinlock_t nvram_lock = SPIN_LOCK_UNLOCKED;
10824 +static struct semaphore nvram_sem;
10825 +static unsigned long nvram_offset = 0;
10826 +static int nvram_major = -1;
10827 +static devfs_handle_t nvram_handle = NULL;
10828 +static struct mtd_info *nvram_mtd = NULL;
10831 +_nvram_read(char *buf)
10833 + struct nvram_header *header = (struct nvram_header *) buf;
10836 + if (!nvram_mtd ||
10837 + MTD_READ(nvram_mtd, nvram_mtd->size - NVRAM_SPACE, NVRAM_SPACE, &len, buf) ||
10838 + len != NVRAM_SPACE ||
10839 + header->magic != NVRAM_MAGIC) {
10840 + /* Maybe we can recover some data from early initialization */
10841 + memcpy(buf, nvram_buf, NVRAM_SPACE);
10847 +struct nvram_tuple *
10848 +_nvram_realloc(struct nvram_tuple *t, const char *name, const char *value)
10850 + if ((nvram_offset + strlen(value) + 1) > NVRAM_SPACE)
10854 + if (!(t = kmalloc(sizeof(struct nvram_tuple) + strlen(name) + 1, GFP_ATOMIC)))
10858 + t->name = (char *) &t[1];
10859 + strcpy(t->name, name);
10865 + if (!t->value || strcmp(t->value, value)) {
10866 + t->value = &nvram_buf[nvram_offset];
10867 + strcpy(t->value, value);
10868 + nvram_offset += strlen(value) + 1;
10875 +_nvram_free(struct nvram_tuple *t)
10878 + nvram_offset = 0;
10884 +nvram_set(const char *name, const char *value)
10886 + unsigned long flags;
10888 + struct nvram_header *header;
10890 + spin_lock_irqsave(&nvram_lock, flags);
10891 + if ((ret = _nvram_set(name, value))) {
10892 + /* Consolidate space and try again */
10893 + if ((header = kmalloc(NVRAM_SPACE, GFP_ATOMIC))) {
10894 + if (_nvram_commit(header) == 0)
10895 + ret = _nvram_set(name, value);
10899 + spin_unlock_irqrestore(&nvram_lock, flags);
10905 +real_nvram_get(const char *name)
10907 + unsigned long flags;
10910 + spin_lock_irqsave(&nvram_lock, flags);
10911 + value = _nvram_get(name);
10912 + spin_unlock_irqrestore(&nvram_lock, flags);
10918 +nvram_get(const char *name)
10920 + if (nvram_major >= 0)
10921 + return real_nvram_get(name);
10923 + return early_nvram_get(name);
10927 +nvram_unset(const char *name)
10929 + unsigned long flags;
10932 + spin_lock_irqsave(&nvram_lock, flags);
10933 + ret = _nvram_unset(name);
10934 + spin_unlock_irqrestore(&nvram_lock, flags);
10940 +erase_callback(struct erase_info *done)
10942 + wait_queue_head_t *wait_q = (wait_queue_head_t *) done->priv;
10947 +nvram_commit(void)
10950 + size_t erasesize, len;
10953 + struct nvram_header *header;
10954 + unsigned long flags;
10955 + u_int32_t offset;
10956 + DECLARE_WAITQUEUE(wait, current);
10957 + wait_queue_head_t wait_q;
10958 + struct erase_info erase;
10960 + if (!nvram_mtd) {
10961 + printk("nvram_commit: NVRAM not found\n");
10965 + if (in_interrupt()) {
10966 + printk("nvram_commit: not committing in interrupt\n");
10970 + /* Backup sector blocks to be erased */
10971 + erasesize = ROUNDUP(NVRAM_SPACE, nvram_mtd->erasesize);
10972 + if (!(buf = kmalloc(erasesize, GFP_KERNEL))) {
10973 + printk("nvram_commit: out of memory\n");
10977 + down(&nvram_sem);
10979 + if ((i = erasesize - NVRAM_SPACE) > 0) {
10980 + offset = nvram_mtd->size - erasesize;
10982 + ret = MTD_READ(nvram_mtd, offset, i, &len, buf);
10983 + if (ret || len != i) {
10984 + printk("nvram_commit: read error ret = %d, len = %d/%d\n", ret, len, i);
10988 + header = (struct nvram_header *)(buf + i);
10990 + offset = nvram_mtd->size - NVRAM_SPACE;
10991 + header = (struct nvram_header *)buf;
10994 + /* Regenerate NVRAM */
10995 + spin_lock_irqsave(&nvram_lock, flags);
10996 + ret = _nvram_commit(header);
10997 + spin_unlock_irqrestore(&nvram_lock, flags);
11001 + /* Erase sector blocks */
11002 + init_waitqueue_head(&wait_q);
11003 + for (; offset < nvram_mtd->size - NVRAM_SPACE + header->len; offset += nvram_mtd->erasesize) {
11004 + erase.mtd = nvram_mtd;
11005 + erase.addr = offset;
11006 + erase.len = nvram_mtd->erasesize;
11007 + erase.callback = erase_callback;
11008 + erase.priv = (u_long) &wait_q;
11010 + set_current_state(TASK_INTERRUPTIBLE);
11011 + add_wait_queue(&wait_q, &wait);
11013 + /* Unlock sector blocks */
11014 + if (nvram_mtd->unlock)
11015 + nvram_mtd->unlock(nvram_mtd, offset, nvram_mtd->erasesize);
11017 + if ((ret = MTD_ERASE(nvram_mtd, &erase))) {
11018 + set_current_state(TASK_RUNNING);
11019 + remove_wait_queue(&wait_q, &wait);
11020 + printk("nvram_commit: erase error\n");
11024 + /* Wait for erase to finish */
11026 + remove_wait_queue(&wait_q, &wait);
11029 + /* Write partition up to end of data area */
11030 + offset = nvram_mtd->size - erasesize;
11031 + i = erasesize - NVRAM_SPACE + header->len;
11032 + ret = MTD_WRITE(nvram_mtd, offset, i, &len, buf);
11033 + if (ret || len != i) {
11034 + printk("nvram_commit: write error\n");
11039 + offset = nvram_mtd->size - erasesize;
11040 + ret = MTD_READ(nvram_mtd, offset, 4, &len, buf);
11049 +nvram_getall(char *buf, int count)
11051 + unsigned long flags;
11054 + spin_lock_irqsave(&nvram_lock, flags);
11055 + ret = _nvram_getall(buf, count);
11056 + spin_unlock_irqrestore(&nvram_lock, flags);
11061 +EXPORT_SYMBOL(nvram_get);
11062 +EXPORT_SYMBOL(nvram_getall);
11063 +EXPORT_SYMBOL(nvram_set);
11064 +EXPORT_SYMBOL(nvram_unset);
11065 +EXPORT_SYMBOL(nvram_commit);
11067 +/* User mode interface below */
11070 +dev_nvram_read(struct file *file, char *buf, size_t count, loff_t *ppos)
11072 + char tmp[100], *name = tmp, *value;
11074 + unsigned long off;
11076 + if (count > sizeof(tmp)) {
11077 + if (!(name = kmalloc(count, GFP_KERNEL)))
11081 + if (copy_from_user(name, buf, count)) {
11086 + if (*name == '\0') {
11087 + /* Get all variables */
11088 + ret = nvram_getall(name, count);
11090 + if (copy_to_user(buf, name, count)) {
11097 + if (!(value = nvram_get(name))) {
11102 + /* Provide the offset into mmap() space */
11103 + off = (unsigned long) value - (unsigned long) nvram_buf;
11105 + if (put_user(off, (unsigned long *) buf)) {
11110 + ret = sizeof(unsigned long);
11113 + flush_cache_all();
11123 +dev_nvram_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
11125 + char tmp[100], *name = tmp, *value;
11128 + if (count > sizeof(tmp)) {
11129 + if (!(name = kmalloc(count, GFP_KERNEL)))
11133 + if (copy_from_user(name, buf, count)) {
11139 + name = strsep(&value, "=");
11141 + ret = nvram_set(name, value) ? : count;
11143 + ret = nvram_unset(name) ? : count;
11153 +dev_nvram_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
11155 + if (cmd != NVRAM_MAGIC)
11157 + return nvram_commit();
11161 +dev_nvram_mmap(struct file *file, struct vm_area_struct *vma)
11163 + unsigned long offset = virt_to_phys(nvram_buf);
11165 + if (remap_page_range(vma->vm_start, offset, vma->vm_end-vma->vm_start,
11166 + vma->vm_page_prot))
11173 +dev_nvram_open(struct inode *inode, struct file * file)
11175 + MOD_INC_USE_COUNT;
11180 +dev_nvram_release(struct inode *inode, struct file * file)
11182 + MOD_DEC_USE_COUNT;
11186 +static struct file_operations dev_nvram_fops = {
11187 + owner: THIS_MODULE,
11188 + open: dev_nvram_open,
11189 + release: dev_nvram_release,
11190 + read: dev_nvram_read,
11191 + write: dev_nvram_write,
11192 + ioctl: dev_nvram_ioctl,
11193 + mmap: dev_nvram_mmap,
11197 +dev_nvram_exit(void)
11200 + struct page *page, *end;
11202 + if (nvram_handle)
11203 + devfs_unregister(nvram_handle);
11205 + if (nvram_major >= 0)
11206 + devfs_unregister_chrdev(nvram_major, "nvram");
11209 + put_mtd_device(nvram_mtd);
11211 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
11213 + end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
11214 + for (page = virt_to_page(nvram_buf); page <= end; page++)
11215 + mem_map_unreserve(page);
11221 +dev_nvram_init(void)
11223 + int order = 0, ret = 0;
11224 + struct page *page, *end;
11227 + /* Allocate and reserve memory to mmap() */
11228 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
11230 + end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
11231 + for (page = virt_to_page(nvram_buf); page <= end; page++)
11232 + mem_map_reserve(page);
11235 + /* Find associated MTD device */
11236 + for (i = 0; i < MAX_MTD_DEVICES; i++) {
11237 + nvram_mtd = get_mtd_device(NULL, i);
11239 + if (!strcmp(nvram_mtd->name, "nvram") &&
11240 + nvram_mtd->size >= NVRAM_SPACE)
11242 + put_mtd_device(nvram_mtd);
11245 + if (i >= MAX_MTD_DEVICES)
11246 + nvram_mtd = NULL;
11249 + /* Initialize hash table lock */
11250 + spin_lock_init(&nvram_lock);
11252 + /* Initialize commit semaphore */
11253 + init_MUTEX(&nvram_sem);
11255 + /* Register char device */
11256 + if ((nvram_major = devfs_register_chrdev(0, "nvram", &dev_nvram_fops)) < 0) {
11257 + ret = nvram_major;
11261 + /* Initialize hash table */
11264 + /* Create /dev/nvram handle */
11265 + nvram_handle = devfs_register(NULL, "nvram", DEVFS_FL_NONE, nvram_major, 0,
11266 + S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, &dev_nvram_fops, NULL);
11268 + /* Set the SDRAM NCDL value into NVRAM if not already done */
11269 + if (getintvar(NULL, "sdram_ncdl") == 0) {
11270 + unsigned int ncdl;
11271 + char buf[] = "0x00000000";
11273 + if ((ncdl = sb_memc_get_ncdl(sbh))) {
11274 + sprintf(buf, "0x%08x", ncdl);
11275 + nvram_set("sdram_ncdl", buf);
11283 + dev_nvram_exit();
11287 +module_init(dev_nvram_init);
11288 +module_exit(dev_nvram_exit);
11289 diff -urN linux.old/arch/mips/bcm947xx/pcibios.c linux.dev/arch/mips/bcm947xx/pcibios.c
11290 --- linux.old/arch/mips/bcm947xx/pcibios.c 1970-01-01 01:00:00.000000000 +0100
11291 +++ linux.dev/arch/mips/bcm947xx/pcibios.c 2005-11-07 23:59:38.908750500 +0100
11294 + * Low-Level PCI and SB support for BCM47xx (Linux support code)
11296 + * Copyright 2005, Broadcom Corporation
11297 + * All Rights Reserved.
11299 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
11300 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11301 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11302 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11307 +#include <linux/config.h>
11308 +#include <linux/types.h>
11309 +#include <linux/kernel.h>
11310 +#include <linux/sched.h>
11311 +#include <linux/pci.h>
11312 +#include <linux/init.h>
11313 +#include <linux/delay.h>
11314 +#include <asm/io.h>
11315 +#include <asm/irq.h>
11316 +#include <asm/paccess.h>
11318 +#include <typedefs.h>
11319 +#include <bcmutils.h>
11320 +#include <sbconfig.h>
11321 +#include <sbutils.h>
11322 +#include <sbpci.h>
11323 +#include <pcicfg.h>
11324 +#include <bcmdevs.h>
11325 +#include <bcmnvram.h>
11327 +/* Global SB handle */
11328 +extern sb_t *bcm947xx_sbh;
11329 +extern spinlock_t bcm947xx_sbh_lock;
11332 +#define sbh bcm947xx_sbh
11333 +#define sbh_lock bcm947xx_sbh_lock
11336 +sbpci_read_config_byte(struct pci_dev *dev, int where, u8 *value)
11338 + unsigned long flags;
11341 + spin_lock_irqsave(&sbh_lock, flags);
11342 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
11343 + spin_unlock_irqrestore(&sbh_lock, flags);
11344 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11348 +sbpci_read_config_word(struct pci_dev *dev, int where, u16 *value)
11350 + unsigned long flags;
11353 + spin_lock_irqsave(&sbh_lock, flags);
11354 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
11355 + spin_unlock_irqrestore(&sbh_lock, flags);
11356 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11360 +sbpci_read_config_dword(struct pci_dev *dev, int where, u32 *value)
11362 + unsigned long flags;
11365 + spin_lock_irqsave(&sbh_lock, flags);
11366 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
11367 + spin_unlock_irqrestore(&sbh_lock, flags);
11368 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11372 +sbpci_write_config_byte(struct pci_dev *dev, int where, u8 value)
11374 + unsigned long flags;
11377 + spin_lock_irqsave(&sbh_lock, flags);
11378 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
11379 + spin_unlock_irqrestore(&sbh_lock, flags);
11380 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11384 +sbpci_write_config_word(struct pci_dev *dev, int where, u16 value)
11386 + unsigned long flags;
11389 + spin_lock_irqsave(&sbh_lock, flags);
11390 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
11391 + spin_unlock_irqrestore(&sbh_lock, flags);
11392 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11396 +sbpci_write_config_dword(struct pci_dev *dev, int where, u32 value)
11398 + unsigned long flags;
11401 + spin_lock_irqsave(&sbh_lock, flags);
11402 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
11403 + spin_unlock_irqrestore(&sbh_lock, flags);
11404 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11407 +static struct pci_ops pcibios_ops = {
11408 + sbpci_read_config_byte,
11409 + sbpci_read_config_word,
11410 + sbpci_read_config_dword,
11411 + sbpci_write_config_byte,
11412 + sbpci_write_config_word,
11413 + sbpci_write_config_dword
11418 +pcibios_init(void)
11422 + if (!(sbh = sb_kattach()))
11423 + panic("sb_kattach failed");
11424 + spin_lock_init(&sbh_lock);
11426 + spin_lock_irqsave(&sbh_lock, flags);
11428 + spin_unlock_irqrestore(&sbh_lock, flags);
11430 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
11432 + mdelay(300); //By Joey for Atheros Card
11434 + /* Scan the SB bus */
11435 + pci_scan_bus(0, &pcibios_ops, NULL);
11440 +pcibios_setup(char *str)
11442 + if (!strncmp(str, "ban=", 4)) {
11443 + sbpci_ban(simple_strtoul(str + 4, NULL, 0));
11450 +static u32 pci_iobase = 0x100;
11451 +static u32 pci_membase = SB_PCI_DMA;
11454 +pcibios_fixup_bus(struct pci_bus *b)
11456 + struct list_head *ln;
11457 + struct pci_dev *d;
11458 + struct resource *res;
11463 + printk("PCI: Fixing up bus %d\n", b->number);
11466 + if (b->number == 0) {
11467 + for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
11468 + d = pci_dev_b(ln);
11469 + /* Fix up interrupt lines */
11470 + pci_read_config_byte(d, PCI_INTERRUPT_LINE, &irq);
11471 + d->irq = irq + 2;
11472 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
11476 + /* Fix up external PCI */
11478 + for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
11479 + d = pci_dev_b(ln);
11480 + /* Fix up resource bases */
11481 + for (pos = 0; pos < 6; pos++) {
11482 + res = &d->resource[pos];
11483 + base = (res->flags & IORESOURCE_IO) ? &pci_iobase : &pci_membase;
11485 + size = res->end - res->start + 1;
11486 + if (*base & (size - 1))
11487 + *base = (*base + size) & ~(size - 1);
11488 + res->start = *base;
11489 + res->end = res->start + size - 1;
11491 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
11493 + /* Fix up PCI bridge BAR0 only */
11494 + if (b->number == 1 && PCI_SLOT(d->devfn) == 0)
11497 + /* Fix up interrupt lines */
11498 + if (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))
11499 + d->irq = (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))->irq;
11500 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
11506 +pcibios_assign_all_busses(void)
11512 +pcibios_align_resource(void *data, struct resource *res,
11513 + unsigned long size, unsigned long align)
11518 +pcibios_enable_resources(struct pci_dev *dev)
11520 + u16 cmd, old_cmd;
11522 + struct resource *r;
11524 + /* External PCI only */
11525 + if (dev->bus->number == 0)
11528 + pci_read_config_word(dev, PCI_COMMAND, &cmd);
11530 + for(idx=0; idx<6; idx++) {
11531 + r = &dev->resource[idx];
11532 + if (r->flags & IORESOURCE_IO)
11533 + cmd |= PCI_COMMAND_IO;
11534 + if (r->flags & IORESOURCE_MEM)
11535 + cmd |= PCI_COMMAND_MEMORY;
11537 + if (dev->resource[PCI_ROM_RESOURCE].start)
11538 + cmd |= PCI_COMMAND_MEMORY;
11539 + if (cmd != old_cmd) {
11540 + printk("PCI: Enabling device %s (%04x -> %04x)\n", dev->slot_name, old_cmd, cmd);
11541 + pci_write_config_word(dev, PCI_COMMAND, cmd);
11547 +pcibios_enable_device(struct pci_dev *dev, int mask)
11552 + /* External PCI device enable */
11553 + if (dev->bus->number != 0)
11554 + return pcibios_enable_resources(dev);
11556 + /* These cores come out of reset enabled */
11557 + if (dev->device == SB_MIPS ||
11558 + dev->device == SB_MIPS33 ||
11559 + dev->device == SB_EXTIF ||
11560 + dev->device == SB_CC)
11563 + spin_lock_irqsave(&sbh_lock, flags);
11564 + coreidx = sb_coreidx(sbh);
11565 + if (!sb_setcoreidx(sbh, PCI_SLOT(dev->devfn)))
11566 + return PCIBIOS_DEVICE_NOT_FOUND;
11569 + * The USB core requires a special bit to be set during core
11570 + * reset to enable host (OHCI) mode. Resetting the SB core in
11571 + * pcibios_enable_device() is a hack for compatibility with
11572 + * vanilla usb-ohci so that it does not have to know about
11573 + * SB. A driver that wants to use the USB core in device mode
11574 + * should know about SB and should reset the bit back to 0
11575 + * after calling pcibios_enable_device().
11577 + if (sb_coreid(sbh) == SB_USB) {
11578 + sb_core_disable(sbh, sb_coreflags(sbh, 0, 0));
11579 + sb_core_reset(sbh, 1 << 29);
11581 + sb_core_reset(sbh, 0);
11583 + sb_setcoreidx(sbh, coreidx);
11584 + spin_unlock_irqrestore(&sbh_lock, flags);
11590 +pcibios_update_resource(struct pci_dev *dev, struct resource *root,
11591 + struct resource *res, int resource)
11593 + unsigned long where, size;
11596 + /* External PCI only */
11597 + if (dev->bus->number == 0)
11600 + where = PCI_BASE_ADDRESS_0 + (resource * 4);
11601 + size = res->end - res->start;
11602 + pci_read_config_dword(dev, where, ®);
11603 + reg = (reg & size) | (((u32)(res->start - root->start)) & ~size);
11604 + pci_write_config_dword(dev, where, reg);
11607 +static void __init
11608 +quirk_sbpci_bridge(struct pci_dev *dev)
11610 + if (dev->bus->number != 1 || PCI_SLOT(dev->devfn) != 0)
11613 + printk("PCI: Fixing up bridge\n");
11615 + /* Enable PCI bridge bus mastering and memory space */
11616 + pci_set_master(dev);
11617 + pcibios_enable_resources(dev);
11619 + /* Enable PCI bridge BAR1 prefetch and burst */
11620 + pci_write_config_dword(dev, PCI_BAR1_CONTROL, 3);
11623 +struct pci_fixup pcibios_fixups[] = {
11624 + { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, quirk_sbpci_bridge },
11629 + * If we set up a device for bus mastering, we need to check the latency
11630 + * timer as certain crappy BIOSes forget to set it properly.
11632 +unsigned int pcibios_max_latency = 255;
11634 +void pcibios_set_master(struct pci_dev *dev)
11637 + pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
11639 + lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
11640 + else if (lat > pcibios_max_latency)
11641 + lat = pcibios_max_latency;
11644 + printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", dev->slot_name, lat);
11645 + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
11648 diff -urN linux.old/arch/mips/bcm947xx/prom.c linux.dev/arch/mips/bcm947xx/prom.c
11649 --- linux.old/arch/mips/bcm947xx/prom.c 1970-01-01 01:00:00.000000000 +0100
11650 +++ linux.dev/arch/mips/bcm947xx/prom.c 2005-11-07 21:57:07.885588250 +0100
11653 + * Early initialization code for BCM94710 boards
11655 + * Copyright 2004, Broadcom Corporation
11656 + * All Rights Reserved.
11658 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
11659 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11660 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11661 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11663 + * $Id: prom.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
11666 +#include <linux/config.h>
11667 +#include <linux/init.h>
11668 +#include <linux/kernel.h>
11669 +#include <linux/types.h>
11670 +#include <asm/bootinfo.h>
11673 +prom_init(int argc, const char **argv)
11675 + unsigned long mem;
11677 + mips_machgroup = MACH_GROUP_BRCM;
11678 + mips_machtype = MACH_BCM947XX;
11680 + /* Figure out memory size by finding aliases */
11681 + for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
11682 + if (*(unsigned long *)((unsigned long)(prom_init) + mem) ==
11683 + *(unsigned long *)(prom_init))
11686 + add_memory_region(0, mem, BOOT_MEM_RAM);
11690 +prom_free_prom_memory(void)
11693 diff -urN linux.old/arch/mips/bcm947xx/sbmips.c linux.dev/arch/mips/bcm947xx/sbmips.c
11694 --- linux.old/arch/mips/bcm947xx/sbmips.c 1970-01-01 01:00:00.000000000 +0100
11695 +++ linux.dev/arch/mips/bcm947xx/sbmips.c 2005-11-07 23:55:45.682174750 +0100
11698 + * BCM47XX Sonics SiliconBackplane MIPS core routines
11700 + * Copyright 2005, Broadcom Corporation
11701 + * All Rights Reserved.
11703 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
11704 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11705 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11706 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11711 +#include <typedefs.h>
11713 +#include <sbutils.h>
11714 +#include <bcmdevs.h>
11715 +#include <bcmnvram.h>
11716 +#include <bcmutils.h>
11717 +#include <hndmips.h>
11718 +#include <sbconfig.h>
11719 +#include <sbextif.h>
11720 +#include <sbchipc.h>
11721 +#include <sbmemc.h>
11722 +#include <mipsinc.h>
11723 +#include <sbutils.h>
11726 + * Returns TRUE if an external UART exists at the given base
11730 +BCMINITFN(serial_exists)(uint8 *regs)
11732 + uint8 save_mcr, status1;
11734 + save_mcr = R_REG(®s[UART_MCR]);
11735 + W_REG(®s[UART_MCR], UART_MCR_LOOP | 0x0a);
11736 + status1 = R_REG(®s[UART_MSR]) & 0xf0;
11737 + W_REG(®s[UART_MCR], save_mcr);
11739 + return (status1 == 0x90);
11743 + * Initializes UART access. The callback function will be called once
11744 + * per found UART.
11747 +BCMINITFN(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift))
11754 + if ((regs = sb_setcore(sbh, SB_EXTIF, 0))) {
11755 + extifregs_t *eir = (extifregs_t *) regs;
11758 + /* Determine external UART register base */
11759 + sb = (sbconfig_t *)((ulong) eir + SBCONFIGOFF);
11760 + base = EXTIF_CFGIF_BASE(sb_base(R_REG(&sb->sbadmatch1)));
11762 + /* Determine IRQ */
11763 + irq = sb_irq(sbh);
11765 + /* Disable GPIO interrupt initially */
11766 + W_REG(&eir->gpiointpolarity, 0);
11767 + W_REG(&eir->gpiointmask, 0);
11769 + /* Search for external UARTs */
11771 + for (i = 0; i < 2; i++) {
11772 + regs = (void *) REG_MAP(base + (i * 8), 8);
11773 + if (BCMINIT(serial_exists)(regs)) {
11774 + /* Set GPIO 1 to be the external UART IRQ */
11775 + W_REG(&eir->gpiointmask, 2);
11777 + add(regs, irq, 13500000, 0);
11781 + /* Add internal UART if enabled */
11782 + if (R_REG(&eir->corecontrol) & CC_UE)
11784 + add((void *) &eir->uartdata, irq, sb_clock(sbh), 2);
11785 + } else if ((regs = sb_setcore(sbh, SB_CC, 0))) {
11786 + chipcregs_t *cc = (chipcregs_t *) regs;
11787 + uint32 rev, cap, pll, baud_base, div;
11789 + /* Determine core revision and capabilities */
11790 + rev = sb_corerev(sbh);
11791 + cap = R_REG(&cc->capabilities);
11792 + pll = cap & CAP_PLL_MASK;
11794 + /* Determine IRQ */
11795 + irq = sb_irq(sbh);
11797 + if (pll == PLL_TYPE1) {
11799 + baud_base = sb_clock_rate(pll,
11800 + R_REG(&cc->clockcontrol_n),
11801 + R_REG(&cc->clockcontrol_m2));
11805 + /* Fixed ALP clock */
11806 + baud_base = 20000000;
11808 + /* Set the override bit so we don't divide it */
11809 + W_REG(&cc->corecontrol, CC_UARTCLKO);
11810 + } else if (rev >= 3) {
11811 + /* Internal backplane clock */
11812 + baud_base = sb_clock(sbh);
11813 + div = 2; /* Minimum divisor */
11814 + W_REG(&cc->clkdiv,
11815 + ((R_REG(&cc->clkdiv) & ~CLKD_UART) | div));
11817 + /* Fixed internal backplane clock */
11818 + baud_base = 88000000;
11822 + /* Clock source depends on strapping if UartClkOverride is unset */
11824 + ((R_REG(&cc->corecontrol) & CC_UARTCLKO) == 0)) {
11825 + if ((cap & CAP_UCLKSEL) == CAP_UINTCLK) {
11826 + /* Internal divided backplane clock */
11827 + baud_base /= div;
11829 + /* Assume external clock of 1.8432 MHz */
11830 + baud_base = 1843200;
11835 + /* Add internal UARTs */
11836 + n = cap & CAP_UARTS_MASK;
11837 + for (i = 0; i < n; i++) {
11838 + /* Register offset changed after revision 0 */
11840 + regs = (void *)((ulong) &cc->uart0data + (i * 256));
11842 + regs = (void *)((ulong) &cc->uart0data + (i * 8));
11845 + add(regs, irq, baud_base, 0);
11851 + * Initialize jtag master and return handle for
11852 + * jtag_rwreg. Returns NULL on failure.
11855 +sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap)
11859 + if ((regs = sb_setcore(sbh, SB_CC, 0)) != NULL) {
11860 + chipcregs_t *cc = (chipcregs_t *) regs;
11864 + * Determine jtagm availability from
11865 + * core revision and capabilities.
11867 + tmp = sb_corerev(sbh);
11869 + * Corerev 10 has jtagm, but the only chip
11870 + * with it does not have a mips, and
11871 + * the layout of the jtagcmd register is
11872 + * different. We'll only accept >= 11.
11877 + tmp = R_REG(&cc->capabilities);
11878 + if ((tmp & CAP_JTAGP) == 0)
11881 + /* Set clock divider if requested */
11883 + tmp = R_REG(&cc->clkdiv);
11884 + tmp = (tmp & ~CLKD_JTAG) |
11885 + ((clkd << CLKD_JTAG_SHIFT) & CLKD_JTAG);
11886 + W_REG(&cc->clkdiv, tmp);
11889 + /* Enable jtagm */
11890 + tmp = JCTRL_EN | (exttap ? JCTRL_EXT_EN : 0);
11891 + W_REG(&cc->jtagctrl, tmp);
11898 +sb_jtagm_disable(void *h)
11900 + chipcregs_t *cc = (chipcregs_t *)h;
11902 + W_REG(&cc->jtagctrl, R_REG(&cc->jtagctrl) & ~JCTRL_EN);
11906 + * Read/write a jtag register. Assumes a target with
11907 + * 8 bit IR and 32 bit DR.
11910 +#define DRWIDTH 32
11912 +jtag_rwreg(void *h, uint32 ir, uint32 dr)
11914 + chipcregs_t *cc = (chipcregs_t *) h;
11917 + W_REG(&cc->jtagir, ir);
11918 + W_REG(&cc->jtagdr, dr);
11919 + tmp = JCMD_START | JCMD_ACC_IRDR |
11920 + ((IRWIDTH - 1) << JCMD_IRW_SHIFT) |
11922 + W_REG(&cc->jtagcmd, tmp);
11923 + while (((tmp = R_REG(&cc->jtagcmd)) & JCMD_BUSY) == JCMD_BUSY) {
11924 + /* OSL_DELAY(1); */
11927 + tmp = R_REG(&cc->jtagdr);
11931 +/* Returns the SB interrupt flag of the current core. */
11933 +sb_flag(sb_t *sbh)
11938 + regs = sb_coreregs(sbh);
11939 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
11941 + return (R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK);
11944 +static const uint32 sbips_int_mask[] = {
11952 +static const uint32 sbips_int_shift[] = {
11955 + SBIPS_INT2_SHIFT,
11956 + SBIPS_INT3_SHIFT,
11961 + * Returns the MIPS IRQ assignment of the current core. If unassigned,
11970 + uint32 flag, sbipsflag;
11973 + flag = sb_flag(sbh);
11975 + idx = sb_coreidx(sbh);
11977 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
11978 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
11979 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
11981 + /* sbipsflag specifies which core is routed to interrupts 1 to 4 */
11982 + sbipsflag = R_REG(&sb->sbipsflag);
11983 + for (irq = 1; irq <= 4; irq++) {
11984 + if (((sbipsflag & sbips_int_mask[irq]) >> sbips_int_shift[irq]) == flag)
11991 + sb_setcoreidx(sbh, idx);
11996 +/* Clears the specified MIPS IRQ. */
11998 +BCMINITFN(sb_clearirq)(sb_t *sbh, uint irq)
12003 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
12004 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
12006 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12009 + W_REG(&sb->sbintvec, 0);
12011 + OR_REG(&sb->sbipsflag, sbips_int_mask[irq]);
12015 + * Assigns the specified MIPS IRQ to the specified core. Shared MIPS
12016 + * IRQ 0 may be assigned more than once.
12019 +BCMINITFN(sb_setirq)(sb_t *sbh, uint irq, uint coreid, uint coreunit)
12025 + regs = sb_setcore(sbh, coreid, coreunit);
12027 + flag = sb_flag(sbh);
12029 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
12030 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
12032 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12035 + OR_REG(&sb->sbintvec, 1 << flag);
12037 + flag <<= sbips_int_shift[irq];
12038 + ASSERT(!(flag & ~sbips_int_mask[irq]));
12039 + flag |= R_REG(&sb->sbipsflag) & ~sbips_int_mask[irq];
12040 + W_REG(&sb->sbipsflag, flag);
12045 + * Initializes clocks and interrupts. SB and NVRAM access must be
12046 + * initialized prior to calling.
12049 +BCMINITFN(sb_mips_init)(sb_t *sbh)
12051 + ulong hz, ns, tmp;
12052 + extifregs_t *eir;
12057 + /* Figure out current SB clock speed */
12058 + if ((hz = sb_clock(sbh)) == 0)
12060 + ns = 1000000000 / hz;
12062 + /* Setup external interface timing */
12063 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
12064 + /* Initialize extif so we can get to the LEDs and external UART */
12065 + W_REG(&eir->prog_config, CF_EN);
12067 + /* Set timing for the flash */
12068 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
12069 + tmp = tmp | (CEIL(40, ns) << FW_W1_SHIFT); /* W1 = 40nS */
12070 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
12071 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
12073 + /* Set programmable interface timing for external uart */
12074 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
12075 + tmp = tmp | (CEIL(20, ns) << FW_W2_SHIFT); /* W2 = 20nS */
12076 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */
12077 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
12078 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
12079 + } else if ((cc = sb_setcore(sbh, SB_CC, 0))) {
12080 + /* Set timing for the flash */
12081 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
12082 + tmp |= CEIL(10, ns) << FW_W1_SHIFT; /* W1 = 10nS */
12083 + tmp |= CEIL(120, ns); /* W0 = 120nS */
12085 + // Added by Chen-I for 5365
12086 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
12088 + W_REG(&cc->flash_waitcount, tmp);
12089 + W_REG(&cc->pcmcia_memwait, tmp);
12093 + if (sb_corerev(sbh) < 9)
12094 + W_REG(&cc->flash_waitcount, tmp);
12096 + if ((sb_corerev(sbh) < 9) ||
12097 + ((BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID) && BCMINIT(sb_chiprev)(sbh) == 0)) {
12098 + W_REG(&cc->pcmcia_memwait, tmp);
12103 + /* Chip specific initialization */
12104 + switch (BCMINIT(sb_chip)(sbh)) {
12105 + case BCM4710_DEVICE_ID:
12106 + /* Clear interrupt map */
12107 + for (irq = 0; irq <= 4; irq++)
12108 + BCMINIT(sb_clearirq)(sbh, irq);
12109 + BCMINIT(sb_setirq)(sbh, 0, SB_CODEC, 0);
12110 + BCMINIT(sb_setirq)(sbh, 0, SB_EXTIF, 0);
12111 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 1);
12112 + BCMINIT(sb_setirq)(sbh, 3, SB_ILINE20, 0);
12113 + BCMINIT(sb_setirq)(sbh, 4, SB_PCI, 0);
12115 + value = BCMINIT(nvram_get)("et0phyaddr");
12116 + if (value && !strcmp(value, "31")) {
12117 + /* Enable internal UART */
12118 + W_REG(&eir->corecontrol, CC_UE);
12119 + /* Give USB its own interrupt */
12120 + BCMINIT(sb_setirq)(sbh, 1, SB_USB, 0);
12122 + /* Disable internal UART */
12123 + W_REG(&eir->corecontrol, 0);
12124 + /* Give Ethernet its own interrupt */
12125 + BCMINIT(sb_setirq)(sbh, 1, SB_ENET, 0);
12126 + BCMINIT(sb_setirq)(sbh, 0, SB_USB, 0);
12129 + case BCM5350_DEVICE_ID:
12130 + /* Clear interrupt map */
12131 + for (irq = 0; irq <= 4; irq++)
12132 + BCMINIT(sb_clearirq)(sbh, irq);
12133 + BCMINIT(sb_setirq)(sbh, 0, SB_CC, 0);
12134 + BCMINIT(sb_setirq)(sbh, 1, SB_D11, 0);
12135 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 0);
12136 + BCMINIT(sb_setirq)(sbh, 3, SB_PCI, 0);
12137 + BCMINIT(sb_setirq)(sbh, 4, SB_USB, 0);
12143 +BCMINITFN(sb_mips_clock)(sb_t *sbh)
12145 + extifregs_t *eir;
12149 + uint32 pll_type, rate = 0;
12151 + /* get index of the current core */
12152 + idx = sb_coreidx(sbh);
12153 + pll_type = PLL_TYPE1;
12155 + /* switch to extif or chipc core */
12156 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
12157 + n = R_REG(&eir->clockcontrol_n);
12158 + m = R_REG(&eir->clockcontrol_sb);
12159 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
12160 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
12161 + n = R_REG(&cc->clockcontrol_n);
12162 + if ((pll_type == PLL_TYPE2) ||
12163 + (pll_type == PLL_TYPE4) ||
12164 + (pll_type == PLL_TYPE6) ||
12165 + (pll_type == PLL_TYPE7))
12166 + m = R_REG(&cc->clockcontrol_mips);
12167 + else if (pll_type == PLL_TYPE5) {
12168 + rate = 200000000;
12171 + else if (pll_type == PLL_TYPE3) {
12172 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) { /* 5365 is also type3 */
12173 + rate = 200000000;
12176 + m = R_REG(&cc->clockcontrol_m2); /* 5350 uses m2 to control mips */
12178 + m = R_REG(&cc->clockcontrol_sb);
12182 + // Added by Chen-I for 5365
12183 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
12184 + rate = 100000000;
12186 + /* calculate rate */
12187 + rate = sb_clock_rate(pll_type, n, m);
12189 + if (pll_type == PLL_TYPE6)
12190 + rate = SB2MIPS_T6(rate);
12193 + /* switch back to previous core */
12194 + sb_setcoreidx(sbh, idx);
12199 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
12202 +BCMINITFN(handler)(void)
12206 + ".set\tmips32\n\t"
12209 + /* Disable interrupts */
12210 + /* MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~(ALLINTS | STO_IE)); */
12211 + "mfc0 $15, $12\n\t"
12212 + /* Just a Hack to not to use reg 'at' which was causing problems on 4704 A2 */
12213 + "li $14, -31746\n\t"
12214 + "and $15, $15, $14\n\t"
12215 + "mtc0 $15, $12\n\t"
12223 +/* The following MUST come right after handler() */
12225 +BCMINITFN(afterhandler)(void)
12230 + * Set the MIPS, backplane and PCI clocks as closely as possible.
12233 +BCMINITFN(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock)
12235 + extifregs_t *eir = NULL;
12236 + chipcregs_t *cc = NULL;
12237 + mipsregs_t *mipsr = NULL;
12238 + volatile uint32 *clockcontrol_n, *clockcontrol_sb, *clockcontrol_pci, *clockcontrol_m2;
12239 + uint32 orig_n, orig_sb, orig_pci, orig_m2, orig_mips, orig_ratio_parm, orig_ratio_cfg;
12240 + uint32 pll_type, sync_mode;
12241 + uint ic_size, ic_lsize;
12244 + uint32 mipsclock;
12250 + static n3m_table_t BCMINITDATA(type1_table)[] = {
12251 + { 96000000, 0x0303, 0x04020011, 0x11030011, 0x11050011 }, /* 96.000 32.000 24.000 */
12252 + { 100000000, 0x0009, 0x04020011, 0x11030011, 0x11050011 }, /* 100.000 33.333 25.000 */
12253 + { 104000000, 0x0802, 0x04020011, 0x11050009, 0x11090009 }, /* 104.000 31.200 24.960 */
12254 + { 108000000, 0x0403, 0x04020011, 0x11050009, 0x02000802 }, /* 108.000 32.400 24.923 */
12255 + { 112000000, 0x0205, 0x04020011, 0x11030021, 0x02000403 }, /* 112.000 32.000 24.889 */
12256 + { 115200000, 0x0303, 0x04020009, 0x11030011, 0x11050011 }, /* 115.200 32.000 24.000 */
12257 + { 120000000, 0x0011, 0x04020011, 0x11050011, 0x11090011 }, /* 120.000 30.000 24.000 */
12258 + { 124800000, 0x0802, 0x04020009, 0x11050009, 0x11090009 }, /* 124.800 31.200 24.960 */
12259 + { 128000000, 0x0305, 0x04020011, 0x11050011, 0x02000305 }, /* 128.000 32.000 24.000 */
12260 + { 132000000, 0x0603, 0x04020011, 0x11050011, 0x02000305 }, /* 132.000 33.000 24.750 */
12261 + { 136000000, 0x0c02, 0x04020011, 0x11090009, 0x02000603 }, /* 136.000 32.640 24.727 */
12262 + { 140000000, 0x0021, 0x04020011, 0x11050021, 0x02000c02 }, /* 140.000 30.000 24.706 */
12263 + { 144000000, 0x0405, 0x04020011, 0x01020202, 0x11090021 }, /* 144.000 30.857 24.686 */
12264 + { 150857142, 0x0605, 0x04020021, 0x02000305, 0x02000605 }, /* 150.857 33.000 24.000 */
12265 + { 152000000, 0x0e02, 0x04020011, 0x11050021, 0x02000e02 }, /* 152.000 32.571 24.000 */
12266 + { 156000000, 0x0802, 0x04020005, 0x11050009, 0x11090009 }, /* 156.000 31.200 24.960 */
12267 + { 160000000, 0x0309, 0x04020011, 0x11090011, 0x02000309 }, /* 160.000 32.000 24.000 */
12268 + { 163200000, 0x0c02, 0x04020009, 0x11090009, 0x02000603 }, /* 163.200 32.640 24.727 */
12269 + { 168000000, 0x0205, 0x04020005, 0x11030021, 0x02000403 }, /* 168.000 32.000 24.889 */
12270 + { 176000000, 0x0602, 0x04020003, 0x11050005, 0x02000602 }, /* 176.000 33.000 24.000 */
12273 + uint32 mipsclock;
12275 + uint32 m2; /* that is the clockcontrol_m2 */
12277 + static type3_table_t type3_table[] = { /* for 5350, mips clock is always double sb clock */
12278 + { 150000000, 0x311, 0x4020005 },
12279 + { 200000000, 0x311, 0x4020003 },
12282 + uint32 mipsclock;
12289 + uint32 ratio_cfg;
12290 + uint32 ratio_parm;
12293 + static n4m_table_t BCMINITDATA(type2_table)[] = {
12294 + { 180000000, 80000000, 0x0403, 0x01010000, 0x01020300, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12295 + { 180000000, 90000000, 0x0403, 0x01000100, 0x01020300, 0x01000100, 0x05000100, 11, 0x0aaa0555 },
12296 + { 200000000, 100000000, 0x0303, 0x02010000, 0x02040001, 0x02010000, 0x06000001, 11, 0x0aaa0555 },
12297 + { 211200000, 105600000, 0x0902, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12298 + { 220800000, 110400000, 0x1500, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12299 + { 230400000, 115200000, 0x0604, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12300 + { 234000000, 104000000, 0x0b01, 0x01010000, 0x01010700, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12301 + { 240000000, 120000000, 0x0803, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12302 + { 252000000, 126000000, 0x0504, 0x01000100, 0x01020500, 0x01000100, 0x05000100, 11, 0x0aaa0555 },
12303 + { 264000000, 132000000, 0x0903, 0x01000200, 0x01020700, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12304 + { 270000000, 120000000, 0x0703, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12305 + { 276000000, 122666666, 0x1500, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12306 + { 280000000, 140000000, 0x0503, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 },
12307 + { 288000000, 128000000, 0x0604, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12308 + { 288000000, 144000000, 0x0404, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 },
12309 + { 300000000, 133333333, 0x0803, 0x01010000, 0x01020600, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12310 + { 300000000, 150000000, 0x0803, 0x01000100, 0x01020600, 0x01000100, 0x05000100, 11, 0x0aaa0555 }
12313 + static n4m_table_t BCMINITDATA(type4_table)[] = {
12314 + { 192000000, 96000000, 0x0702, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
12315 + { 198000000, 99000000, 0x0603, 0x11020005, 0x11030011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12316 + { 200000000, 100000000, 0x0009, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 },
12317 + { 204000000, 102000000, 0x0c02, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12318 + { 208000000, 104000000, 0x0802, 0x11030002, 0x11090005, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
12319 + { 210000000, 105000000, 0x0209, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12320 + { 216000000, 108000000, 0x0111, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12321 + { 224000000, 112000000, 0x0205, 0x11030002, 0x02002103, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
12322 + { 228000000, 101333333, 0x0e02, 0x11030003, 0x11210005, 0x01030305, 0x04000005, 8, 0x012a00a9 },
12323 + { 228000000, 114000000, 0x0e02, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12324 + { 240000000, 102857143, 0x0109, 0x04000021, 0x01050203, 0x11030021, 0x04000003, 13, 0x254a14a9 },
12325 + { 240000000, 120000000, 0x0109, 0x11030002, 0x01050203, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
12326 + { 252000000, 100800000, 0x0203, 0x04000009, 0x11050005, 0x02000209, 0x04000002, 9, 0x02520129 },
12327 + { 252000000, 126000000, 0x0203, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 },
12328 + { 264000000, 132000000, 0x0602, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 },
12329 + { 272000000, 116571428, 0x0c02, 0x04000021, 0x02000909, 0x02000221, 0x04000003, 13, 0x254a14a9 },
12330 + { 280000000, 120000000, 0x0209, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 },
12331 + { 288000000, 123428571, 0x0111, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 },
12332 + { 300000000, 120000000, 0x0009, 0x04000009, 0x01030203, 0x02000902, 0x04000002, 9, 0x02520129 },
12333 + { 300000000, 150000000, 0x0009, 0x04000005, 0x01030203, 0x04000005, 0x04000002, 11, 0x0aaa0555 }
12336 + static n4m_table_t BCMINITDATA(type7_table)[] = {
12337 + { 183333333, 91666666, 0x0605, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
12338 + { 187500000, 93750000, 0x0a03, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
12339 + { 196875000, 98437500, 0x1003, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12340 + { 200000000, 100000000, 0x0311, 0x04000011, 0x11030011, 0x04000009, 0x04000003, 11, 0x0aaa0555 },
12341 + { 200000000, 100000000, 0x0311, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 },
12342 + { 206250000, 103125000, 0x1103, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12343 + { 212500000, 106250000, 0x0c05, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12344 + { 215625000, 107812500, 0x1203, 0x11090009, 0x11050005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12345 + { 216666666, 108333333, 0x0805, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
12346 + { 225000000, 112500000, 0x0d03, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
12347 + { 233333333, 116666666, 0x0905, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
12348 + { 237500000, 118750000, 0x0e05, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12349 + { 240000000, 120000000, 0x0b11, 0x11020009, 0x11210009, 0x11020009, 0x04000009, 11, 0x0aaa0555 },
12350 + { 250000000, 125000000, 0x0f03, 0x11020003, 0x11210003, 0x11020003, 0x04000003, 11, 0x0aaa0555 }
12353 + ulong start, end, dst;
12354 + bool ret = FALSE;
12356 + /* get index of the current core */
12357 + idx = sb_coreidx(sbh);
12358 + clockcontrol_m2 = NULL;
12360 + /* switch to extif or chipc core */
12361 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
12362 + pll_type = PLL_TYPE1;
12363 + clockcontrol_n = &eir->clockcontrol_n;
12364 + clockcontrol_sb = &eir->clockcontrol_sb;
12365 + clockcontrol_pci = &eir->clockcontrol_pci;
12366 + clockcontrol_m2 = &cc->clockcontrol_m2;
12367 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
12368 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
12369 + if (pll_type == PLL_TYPE6) {
12370 + clockcontrol_n = NULL;
12371 + clockcontrol_sb = NULL;
12372 + clockcontrol_pci = NULL;
12374 + clockcontrol_n = &cc->clockcontrol_n;
12375 + clockcontrol_sb = &cc->clockcontrol_sb;
12376 + clockcontrol_pci = &cc->clockcontrol_pci;
12377 + clockcontrol_m2 = &cc->clockcontrol_m2;
12382 + if (pll_type == PLL_TYPE6) {
12383 + /* Silence compilers */
12384 + orig_n = orig_sb = orig_pci = 0;
12386 + /* Store the current clock register values */
12387 + orig_n = R_REG(clockcontrol_n);
12388 + orig_sb = R_REG(clockcontrol_sb);
12389 + orig_pci = R_REG(clockcontrol_pci);
12392 + if (pll_type == PLL_TYPE1) {
12393 + /* Keep the current PCI clock if not specified */
12394 + if (pciclock == 0) {
12395 + pciclock = sb_clock_rate(pll_type, R_REG(clockcontrol_n), R_REG(clockcontrol_pci));
12396 + pciclock = (pciclock <= 25000000) ? 25000000 : 33000000;
12399 + /* Search for the closest MIPS clock less than or equal to a preferred value */
12400 + for (i = 0; i < ARRAYSIZE(BCMINIT(type1_table)); i++) {
12401 + ASSERT(BCMINIT(type1_table)[i].mipsclock ==
12402 + sb_clock_rate(pll_type, BCMINIT(type1_table)[i].n, BCMINIT(type1_table)[i].sb));
12403 + if (BCMINIT(type1_table)[i].mipsclock > mipsclock)
12413 + ASSERT(BCMINIT(type1_table)[i].mipsclock <= mipsclock);
12415 + /* No PLL change */
12416 + if ((orig_n == BCMINIT(type1_table)[i].n) &&
12417 + (orig_sb == BCMINIT(type1_table)[i].sb) &&
12418 + (orig_pci == BCMINIT(type1_table)[i].pci33))
12421 + /* Set the PLL controls */
12422 + W_REG(clockcontrol_n, BCMINIT(type1_table)[i].n);
12423 + W_REG(clockcontrol_sb, BCMINIT(type1_table)[i].sb);
12424 + if (pciclock == 25000000)
12425 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci25);
12427 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci33);
12430 + sb_watchdog(sbh, 1);
12433 + } else if ((pll_type == PLL_TYPE3) &&
12434 + (BCMINIT(sb_chip)(sbh) != BCM5365_DEVICE_ID)) {
12436 + /* Search for the closest MIPS clock less than or equal to a preferred value */
12438 + for (i = 0; i < ARRAYSIZE(type3_table); i++) {
12439 + if (type3_table[i].mipsclock > mipsclock)
12449 + ASSERT(type3_table[i].mipsclock <= mipsclock);
12451 + /* No PLL change */
12452 + orig_m2 = R_REG(&cc->clockcontrol_m2);
12453 + if ((orig_n == type3_table[i].n) &&
12454 + (orig_m2 == type3_table[i].m2)) {
12458 + /* Set the PLL controls */
12459 + W_REG(clockcontrol_n, type3_table[i].n);
12460 + W_REG(clockcontrol_m2, type3_table[i].m2);
12463 + sb_watchdog(sbh, 1);
12465 + } else if ((pll_type == PLL_TYPE2) ||
12466 + (pll_type == PLL_TYPE4) ||
12467 + (pll_type == PLL_TYPE6) ||
12468 + (pll_type == PLL_TYPE7)) {
12469 + n4m_table_t *table = NULL, *te;
12474 + orig_mips = R_REG(&cc->clockcontrol_mips);
12476 + if (pll_type == PLL_TYPE6) {
12477 + uint32 new_mips = 0;
12480 + if (mipsclock <= SB2MIPS_T6(CC_T6_M1))
12481 + new_mips = CC_T6_MMASK;
12483 + if (orig_mips == new_mips)
12486 + W_REG(&cc->clockcontrol_mips, new_mips);
12490 + if (pll_type == PLL_TYPE2) {
12491 + table = BCMINIT(type2_table);
12492 + tabsz = ARRAYSIZE(BCMINIT(type2_table));
12493 + } else if (pll_type == PLL_TYPE4) {
12494 + table = BCMINIT(type4_table);
12495 + tabsz = ARRAYSIZE(BCMINIT(type4_table));
12496 + } else if (pll_type == PLL_TYPE7) {
12497 + table = BCMINIT(type7_table);
12498 + tabsz = ARRAYSIZE(BCMINIT(type7_table));
12500 + ASSERT("No table for plltype" == NULL);
12502 + /* Store the current clock register values */
12503 + orig_m2 = R_REG(&cc->clockcontrol_m2);
12504 + orig_ratio_parm = 0;
12505 + orig_ratio_cfg = 0;
12507 + /* Look up current ratio */
12508 + for (i = 0; i < tabsz; i++) {
12509 + if ((orig_n == table[i].n) &&
12510 + (orig_sb == table[i].sb) &&
12511 + (orig_pci == table[i].pci33) &&
12512 + (orig_m2 == table[i].m2) &&
12513 + (orig_mips == table[i].m3)) {
12514 + orig_ratio_parm = table[i].ratio_parm;
12515 + orig_ratio_cfg = table[i].ratio_cfg;
12520 + /* Search for the closest MIPS clock greater or equal to a preferred value */
12521 + for (i = 0; i < tabsz; i++) {
12522 + ASSERT(table[i].mipsclock ==
12523 + sb_clock_rate(pll_type, table[i].n, table[i].m3));
12524 + if ((mipsclock <= table[i].mipsclock) &&
12525 + ((sbclock == 0) || (sbclock <= table[i].sbclock)))
12528 + if (i == tabsz) {
12536 + /* No PLL change */
12537 + if ((orig_n == te->n) &&
12538 + (orig_sb == te->sb) &&
12539 + (orig_pci == te->pci33) &&
12540 + (orig_m2 == te->m2) &&
12541 + (orig_mips == te->m3))
12544 + /* Set the PLL controls */
12545 + W_REG(clockcontrol_n, te->n);
12546 + W_REG(clockcontrol_sb, te->sb);
12547 + W_REG(clockcontrol_pci, te->pci33);
12548 + W_REG(&cc->clockcontrol_m2, te->m2);
12549 + W_REG(&cc->clockcontrol_mips, te->m3);
12551 + /* Set the chipcontrol bit to change mipsref to the backplane divider if needed */
12552 + if ((pll_type == PLL_TYPE7) &&
12553 + (te->sb != te->m2) &&
12554 + (sb_clock_rate(pll_type, te->n, te->m2) == 120000000))
12555 + W_REG(&cc->chipcontrol, R_REG(&cc->chipcontrol) | 0x100);
12557 + /* No ratio change */
12558 + if (orig_ratio_parm == te->ratio_parm)
12561 + icache_probe(MFC0(C0_CONFIG, 1), &ic_size, &ic_lsize);
12563 + /* Preload the code into the cache */
12564 + start = ((ulong) &&start_fill) & ~(ic_lsize - 1);
12565 + end = ((ulong) &&end_fill + (ic_lsize - 1)) & ~(ic_lsize - 1);
12566 + while (start < end) {
12567 + cache_op(start, Fill_I);
12568 + start += ic_lsize;
12571 + /* Copy the handler */
12572 + start = (ulong) &BCMINIT(handler);
12573 + end = (ulong) &BCMINIT(afterhandler);
12574 + dst = KSEG1ADDR(0x180);
12575 + for (i = 0; i < (end - start); i += 4)
12576 + *((ulong *)(dst + i)) = *((ulong *)(start + i));
12578 + /* Preload handler into the cache one line at a time */
12579 + for (i = 0; i < (end - start); i += 4)
12580 + cache_op(dst + i, Fill_I);
12582 + /* Clear BEV bit */
12583 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~ST0_BEV);
12585 + /* Enable interrupts */
12586 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) | (ALLINTS | ST0_IE));
12588 + /* Enable MIPS timer interrupt */
12589 + if (!(mipsr = sb_setcore(sbh, SB_MIPS, 0)) &&
12590 + !(mipsr = sb_setcore(sbh, SB_MIPS33, 0)))
12592 + W_REG(&mipsr->intmask, 1);
12595 + /* step 1, set clock ratios */
12596 + MTC0(C0_BROADCOM, 3, te->ratio_parm);
12597 + MTC0(C0_BROADCOM, 1, te->ratio_cfg);
12599 + /* step 2: program timer intr */
12600 + W_REG(&mipsr->timer, 100);
12601 + (void) R_REG(&mipsr->timer);
12603 + /* step 3, switch to async */
12604 + sync_mode = MFC0(C0_BROADCOM, 4);
12605 + MTC0(C0_BROADCOM, 4, 1 << 22);
12607 + /* step 4, set cfg active */
12608 + MTC0(C0_BROADCOM, 2, 0x9);
12611 + /* steps 5 & 6 */
12612 + __asm__ __volatile__ (
12613 + ".set\tmips3\n\t"
12618 + /* step 7, clear cfg_active */
12619 + MTC0(C0_BROADCOM, 2, 0);
12621 + /* Additional Step: set back to orig sync mode */
12622 + MTC0(C0_BROADCOM, 4, sync_mode);
12624 + /* step 8, fake soft reset */
12625 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | 4);
12628 + /* step 9 set watchdog timer */
12629 + sb_watchdog(sbh, 20);
12630 + (void) R_REG(&cc->chipid);
12633 + __asm__ __volatile__ (
12634 + ".set\tmips3\n\t"
12643 + /* switch back to previous core */
12644 + sb_setcoreidx(sbh, idx);
12650 + * This also must be run from the cache on 47xx
12651 + * so there are no mips core BIU ops in progress
12652 + * when the PFC is enabled.
12656 +BCMINITFN(_enable_pfc)(uint32 mode)
12658 + /* write range */
12659 + *(volatile uint32 *)PFC_CR1 = 0xffff0000;
12662 + *(volatile uint32 *)PFC_CR0 = mode;
12666 +BCMINITFN(enable_pfc)(uint32 mode)
12668 + ulong start, end;
12671 + /* If auto then choose the correct mode for this
12672 + platform, currently we only ever select one mode */
12673 + if (mode == PFC_AUTO)
12676 + /* enable prefetch cache if available */
12677 + if (MFC0(C0_BROADCOM, 0) & BRCM_PFC_AVAIL) {
12678 + start = (ulong) &BCMINIT(_enable_pfc);
12679 + end = (ulong) &BCMINIT(enable_pfc);
12681 + /* Preload handler into the cache one line at a time */
12682 + for (i = 0; i < (end - start); i += 4)
12683 + cache_op(start + i, Fill_I);
12685 + BCMINIT(_enable_pfc)(mode);
12689 +/* returns the ncdl value to be programmed into sdram_ncdl for calibration */
12691 +BCMINITFN(sb_memc_get_ncdl)(sb_t *sbh)
12693 + sbmemcregs_t *memc;
12695 + uint32 config, rd, wr, misc, dqsg, cd, sm, sd;
12698 + idx = sb_coreidx(sbh);
12700 + memc = (sbmemcregs_t *)sb_setcore(sbh, SB_MEMC, 0);
12704 + rev = sb_corerev(sbh);
12706 + config = R_REG(&memc->config);
12707 + wr = R_REG(&memc->wrncdlcor);
12708 + rd = R_REG(&memc->rdncdlcor);
12709 + misc = R_REG(&memc->miscdlyctl);
12710 + dqsg = R_REG(&memc->dqsgatencdl);
12712 + rd &= MEMC_RDNCDLCOR_RD_MASK;
12713 + wr &= MEMC_WRNCDLCOR_WR_MASK;
12714 + dqsg &= MEMC_DQSGATENCDL_G_MASK;
12716 + if (config & MEMC_CONFIG_DDR) {
12717 + ret = (wr << 16) | (rd << 8) | dqsg;
12722 + cd = (rd == MEMC_CD_THRESHOLD) ? rd : (wr + MEMC_CD_THRESHOLD);
12723 + sm = (misc & MEMC_MISC_SM_MASK) >> MEMC_MISC_SM_SHIFT;
12724 + sd = (misc & MEMC_MISC_SD_MASK) >> MEMC_MISC_SD_SHIFT;
12725 + ret = (sm << 16) | (sd << 8) | cd;
12729 + /* switch back to previous core */
12730 + sb_setcoreidx(sbh, idx);
12735 diff -urN linux.old/arch/mips/bcm947xx/sbpci.c linux.dev/arch/mips/bcm947xx/sbpci.c
12736 --- linux.old/arch/mips/bcm947xx/sbpci.c 1970-01-01 01:00:00.000000000 +0100
12737 +++ linux.dev/arch/mips/bcm947xx/sbpci.c 2005-11-07 23:53:20.981131500 +0100
12740 + * Low-Level PCI and SB support for BCM47xx
12742 + * Copyright 2005, Broadcom Corporation
12743 + * All Rights Reserved.
12745 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
12746 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
12747 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
12748 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
12753 +#include <typedefs.h>
12754 +#include <pcicfg.h>
12755 +#include <bcmdevs.h>
12756 +#include <sbconfig.h>
12758 +#include <sbutils.h>
12759 +#include <sbpci.h>
12760 +#include <bcmendian.h>
12761 +#include <bcmutils.h>
12762 +#include <bcmnvram.h>
12763 +#include <hndmips.h>
12765 +/* Can free sbpci_init() memory after boot */
12770 +/* Emulated configuration space */
12771 +static pci_config_regs sb_config_regs[SB_MAXCORES];
12773 +/* Banned cores */
12774 +static uint16 pci_ban[32] = { 0 };
12775 +static uint pci_banned = 0;
12777 +/* CardBus mode */
12778 +static bool cardbus = FALSE;
12780 +/* Disable PCI host core */
12781 +static bool pci_disabled = FALSE;
12784 + * Functions for accessing external PCI configuration space
12787 +/* Assume one-hot slot wiring */
12788 +#define PCI_SLOT_MAX 16
12791 +config_cmd(sb_t *sbh, uint bus, uint dev, uint func, uint off)
12794 + sbpciregs_t *regs;
12797 + /* CardBusMode supports only one device */
12798 + if (cardbus && dev > 1)
12801 + coreidx = sb_coreidx(sbh);
12802 + regs = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
12804 + /* Type 0 transaction */
12806 + /* Skip unwired slots */
12807 + if (dev < PCI_SLOT_MAX) {
12808 + /* Slide the PCI window to the appropriate slot */
12809 + W_REG(®s->sbtopci1, SBTOPCI_CFG0 | ((1 << (dev + 16)) & SBTOPCI1_MASK));
12810 + addr = SB_PCI_CFG | ((1 << (dev + 16)) & ~SBTOPCI1_MASK) |
12811 + (func << 8) | (off & ~3);
12815 + /* Type 1 transaction */
12817 + W_REG(®s->sbtopci1, SBTOPCI_CFG1);
12818 + addr = SB_PCI_CFG | (bus << 16) | (dev << 11) | (func << 8) | (off & ~3);
12821 + sb_setcoreidx(sbh, coreidx);
12827 +extpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12829 + uint32 addr, *reg = NULL, val;
12832 + if (pci_disabled ||
12833 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
12834 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
12835 + BUSPROBE(val, reg))
12836 + val = 0xffffffff;
12838 + val >>= 8 * (off & 3);
12840 + *((uint32 *) buf) = val;
12841 + else if (len == 2)
12842 + *((uint16 *) buf) = (uint16) val;
12843 + else if (len == 1)
12844 + *((uint8 *) buf) = (uint8) val;
12855 +extpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12857 + uint32 addr, *reg = NULL, val;
12860 + if (pci_disabled ||
12861 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
12862 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
12863 + BUSPROBE(val, reg))
12867 + val = *((uint32 *) buf);
12868 + else if (len == 2) {
12869 + val &= ~(0xffff << (8 * (off & 3)));
12870 + val |= *((uint16 *) buf) << (8 * (off & 3));
12871 + } else if (len == 1) {
12872 + val &= ~(0xff << (8 * (off & 3)));
12873 + val |= *((uint8 *) buf) << (8 * (off & 3));
12887 + * Functions for accessing translated SB configuration space
12891 +sb_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12893 + pci_config_regs *cfg;
12895 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
12897 + cfg = &sb_config_regs[dev];
12899 + ASSERT(ISALIGNED(off, len));
12900 + ASSERT(ISALIGNED((uintptr)buf, len));
12903 + *((uint32 *) buf) = ltoh32(*((uint32 *)((ulong) cfg + off)));
12904 + else if (len == 2)
12905 + *((uint16 *) buf) = ltoh16(*((uint16 *)((ulong) cfg + off)));
12906 + else if (len == 1)
12907 + *((uint8 *) buf) = *((uint8 *)((ulong) cfg + off));
12915 +sb_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12920 + pci_config_regs *cfg;
12922 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
12924 + cfg = &sb_config_regs[dev];
12926 + ASSERT(ISALIGNED(off, len));
12927 + ASSERT(ISALIGNED((uintptr)buf, len));
12929 + /* Emulate BAR sizing */
12930 + if (off >= OFFSETOF(pci_config_regs, base[0]) && off <= OFFSETOF(pci_config_regs, base[3]) &&
12931 + len == 4 && *((uint32 *) buf) == ~0) {
12932 + coreidx = sb_coreidx(sbh);
12933 + if ((regs = sb_setcoreidx(sbh, dev))) {
12934 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12935 + /* Highest numbered address match register */
12936 + n = (R_REG(&sb->sbidlow) & SBIDL_AR_MASK) >> SBIDL_AR_SHIFT;
12937 + if (off == OFFSETOF(pci_config_regs, base[0]))
12938 + cfg->base[0] = ~(sb_size(R_REG(&sb->sbadmatch0)) - 1);
12939 + else if (off == OFFSETOF(pci_config_regs, base[1]) && n >= 1)
12940 + cfg->base[1] = ~(sb_size(R_REG(&sb->sbadmatch1)) - 1);
12941 + else if (off == OFFSETOF(pci_config_regs, base[2]) && n >= 2)
12942 + cfg->base[2] = ~(sb_size(R_REG(&sb->sbadmatch2)) - 1);
12943 + else if (off == OFFSETOF(pci_config_regs, base[3]) && n >= 3)
12944 + cfg->base[3] = ~(sb_size(R_REG(&sb->sbadmatch3)) - 1);
12946 + sb_setcoreidx(sbh, coreidx);
12951 + *((uint32 *)((ulong) cfg + off)) = htol32(*((uint32 *) buf));
12952 + else if (len == 2)
12953 + *((uint16 *)((ulong) cfg + off)) = htol16(*((uint16 *) buf));
12954 + else if (len == 1)
12955 + *((uint8 *)((ulong) cfg + off)) = *((uint8 *) buf);
12963 +sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12966 + return sb_read_config(sbh, bus, dev, func, off, buf, len);
12968 + return extpci_read_config(sbh, bus, dev, func, off, buf, len);
12972 +sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12975 + return sb_write_config(sbh, bus, dev, func, off, buf, len);
12977 + return extpci_write_config(sbh, bus, dev, func, off, buf, len);
12981 +sbpci_ban(uint16 core)
12983 + if (pci_banned < ARRAYSIZE(pci_ban))
12984 + pci_ban[pci_banned++] = core;
12988 +sbpci_init_pci(sb_t *sbh)
12990 + uint chip, chiprev, chippkg, host;
12991 + uint32 boardflags;
12992 + sbpciregs_t *pci;
12996 + chip = sb_chip(sbh);
12997 + chiprev = sb_chiprev(sbh);
12998 + chippkg = sb_chippkg(sbh);
13000 + if (!(pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0))) {
13001 + printf("PCI: no core\n");
13002 + pci_disabled = TRUE;
13005 + sb_core_reset(sbh, 0);
13007 + boardflags = (uint32) getintvar(NULL, "boardflags");
13009 + if ((chip == BCM4310_DEVICE_ID) && (chiprev == 0))
13010 + pci_disabled = TRUE;
13013 + * The 200-pin BCM4712 package does not bond out PCI. Even when
13014 + * PCI is bonded out, some boards may leave the pins
13017 + if (((chip == BCM4712_DEVICE_ID) &&
13018 + ((chippkg == BCM4712SMALL_PKG_ID) ||
13019 + (chippkg == BCM4712MID_PKG_ID))) ||
13020 + (boardflags & BFL_NOPCI))
13021 + pci_disabled = TRUE;
13024 + * If the PCI core should not be touched (disabled, not bonded
13025 + * out, or pins floating), do not even attempt to access core
13026 + * registers. Otherwise, try to determine if it is in host
13029 + if (pci_disabled)
13032 + host = !BUSPROBE(val, &pci->control);
13035 + /* Disable PCI interrupts in client mode */
13036 + sb = (sbconfig_t *)((ulong) pci + SBCONFIGOFF);
13037 + W_REG(&sb->sbintvec, 0);
13039 + /* Disable the PCI bridge in client mode */
13040 + sbpci_ban(SB_PCI);
13041 + printf("PCI: Disabled\n");
13043 + /* Reset the external PCI bus and enable the clock */
13044 + W_REG(&pci->control, 0x5); /* enable the tristate drivers */
13045 + W_REG(&pci->control, 0xd); /* enable the PCI clock */
13046 + OSL_DELAY(150); /* delay > 100 us */
13047 + W_REG(&pci->control, 0xf); /* deassert PCI reset */
13048 + W_REG(&pci->arbcontrol, PCI_INT_ARB); /* use internal arbiter */
13049 + OSL_DELAY(1); /* delay 1 us */
13051 + /* Enable CardBusMode */
13052 + cardbus = nvram_match("cardbus", "1");
13054 + printf("PCI: Enabling CardBus\n");
13055 + /* GPIO 1 resets the CardBus device on bcm94710ap */
13056 + sb_gpioout(sbh, 1, 1, GPIO_DRV_PRIORITY);
13057 + sb_gpioouten(sbh, 1, 1, GPIO_DRV_PRIORITY);
13058 + W_REG(&pci->sprom[0], R_REG(&pci->sprom[0]) | 0x400);
13061 + /* 64 MB I/O access window */
13062 + W_REG(&pci->sbtopci0, SBTOPCI_IO);
13063 + /* 64 MB configuration access window */
13064 + W_REG(&pci->sbtopci1, SBTOPCI_CFG0);
13065 + /* 1 GB memory access window */
13066 + W_REG(&pci->sbtopci2, SBTOPCI_MEM | SB_PCI_DMA);
13068 + /* Enable PCI bridge BAR0 prefetch and burst */
13070 + sbpci_write_config(sbh, 1, 0, 0, PCI_CFG_CMD, &val, sizeof(val));
13072 + /* Enable PCI interrupts */
13073 + W_REG(&pci->intmask, PCI_INTA);
13080 +sbpci_init_cores(sb_t *sbh)
13082 + uint chip, chiprev, chippkg, coreidx, i;
13084 + pci_config_regs *cfg;
13088 + uint16 vendor, core;
13089 + uint8 class, subclass, progif;
13091 + uint32 sbips_int_mask[] = { 0, SBIPS_INT1_MASK, SBIPS_INT2_MASK, SBIPS_INT3_MASK, SBIPS_INT4_MASK };
13092 + uint32 sbips_int_shift[] = { 0, 0, SBIPS_INT2_SHIFT, SBIPS_INT3_SHIFT, SBIPS_INT4_SHIFT };
13094 + chip = sb_chip(sbh);
13095 + chiprev = sb_chiprev(sbh);
13096 + chippkg = sb_chippkg(sbh);
13097 + coreidx = sb_coreidx(sbh);
13099 + /* Scan the SB bus */
13100 + bzero(sb_config_regs, sizeof(sb_config_regs));
13101 + for (cfg = sb_config_regs; cfg < &sb_config_regs[SB_MAXCORES]; cfg++) {
13102 + cfg->vendor = 0xffff;
13103 + if (!(regs = sb_setcoreidx(sbh, cfg - sb_config_regs)))
13105 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
13107 + /* Read ID register and parse vendor and core */
13108 + val = R_REG(&sb->sbidhigh);
13109 + vendor = (val & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT;
13110 + core = (val & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;
13113 + /* Check if this core is banned */
13114 + for (i = 0; i < pci_banned; i++)
13115 + if (core == pci_ban[i])
13117 + if (i < pci_banned)
13120 + /* Known vendor translations */
13121 + switch (vendor) {
13122 + case SB_VEND_BCM:
13123 + vendor = VENDOR_BROADCOM;
13127 + /* Determine class based on known core codes */
13130 + class = PCI_CLASS_NET;
13131 + subclass = PCI_NET_ETHER;
13132 + core = BCM47XX_ILINE_ID;
13134 + case SB_ILINE100:
13135 + class = PCI_CLASS_NET;
13136 + subclass = PCI_NET_ETHER;
13137 + core = BCM4610_ILINE_ID;
13140 + class = PCI_CLASS_NET;
13141 + subclass = PCI_NET_ETHER;
13142 + core = BCM47XX_ENET_ID;
13146 + class = PCI_CLASS_MEMORY;
13147 + subclass = PCI_MEMORY_RAM;
13150 + class = PCI_CLASS_BRIDGE;
13151 + subclass = PCI_BRIDGE_PCI;
13155 + class = PCI_CLASS_CPU;
13156 + subclass = PCI_CPU_MIPS;
13159 + class = PCI_CLASS_COMM;
13160 + subclass = PCI_COMM_MODEM;
13161 + core = BCM47XX_V90_ID;
13164 + class = PCI_CLASS_SERIAL;
13165 + subclass = PCI_SERIAL_USB;
13166 + progif = 0x10; /* OHCI */
13167 + core = BCM47XX_USB_ID;
13170 + class = PCI_CLASS_SERIAL;
13171 + subclass = PCI_SERIAL_USB;
13172 + progif = 0x10; /* OHCI */
13173 + core = BCM47XX_USBH_ID;
13176 + class = PCI_CLASS_SERIAL;
13177 + subclass = PCI_SERIAL_USB;
13178 + core = BCM47XX_USBD_ID;
13181 + class = PCI_CLASS_CRYPT;
13182 + subclass = PCI_CRYPT_NETWORK;
13183 + core = BCM47XX_IPSEC_ID;
13186 + class = PCI_CLASS_NET;
13187 + subclass = PCI_NET_OTHER;
13188 + core = BCM47XX_ROBO_ID;
13192 + class = PCI_CLASS_MEMORY;
13193 + subclass = PCI_MEMORY_FLASH;
13196 + class = PCI_CLASS_NET;
13197 + subclass = PCI_NET_OTHER;
13198 + /* Let an nvram variable override this */
13199 + sprintf(varname, "wl%did", wlidx);
13201 + if ((core = getintvar(NULL, varname)) == 0) {
13202 + if (chip == BCM4712_DEVICE_ID) {
13203 + if (chippkg == BCM4712SMALL_PKG_ID)
13204 + core = BCM4306_D11G_ID;
13206 + core = BCM4306_D11DUAL_ID;
13209 + core = BCM4310_D11B_ID;
13215 + class = subclass = progif = 0xff;
13219 + /* Supported translations */
13220 + cfg->vendor = htol16(vendor);
13221 + cfg->device = htol16(core);
13222 + cfg->rev_id = chiprev;
13223 + cfg->prog_if = progif;
13224 + cfg->sub_class = subclass;
13225 + cfg->base_class = class;
13226 + cfg->base[0] = htol32(sb_base(R_REG(&sb->sbadmatch0)));
13227 + cfg->base[1] = htol32(sb_base(R_REG(&sb->sbadmatch1)));
13228 + cfg->base[2] = htol32(sb_base(R_REG(&sb->sbadmatch2)));
13229 + cfg->base[3] = htol32(sb_base(R_REG(&sb->sbadmatch3)));
13230 + cfg->base[4] = 0;
13231 + cfg->base[5] = 0;
13232 + if (class == PCI_CLASS_BRIDGE && subclass == PCI_BRIDGE_PCI)
13233 + cfg->header_type = PCI_HEADER_BRIDGE;
13235 + cfg->header_type = PCI_HEADER_NORMAL;
13236 + /* Save core interrupt flag */
13237 + cfg->int_pin = R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK;
13238 + /* Default to MIPS shared interrupt 0 */
13239 + cfg->int_line = 0;
13240 + /* MIPS sbipsflag maps core interrupt flags to interrupts 1 through 4 */
13241 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
13242 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
13243 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
13244 + val = R_REG(&sb->sbipsflag);
13245 + for (cfg->int_line = 1; cfg->int_line <= 4; cfg->int_line++) {
13246 + if (((val & sbips_int_mask[cfg->int_line]) >> sbips_int_shift[cfg->int_line]) == cfg->int_pin)
13249 + if (cfg->int_line > 4)
13250 + cfg->int_line = 0;
13252 + /* Emulated core */
13253 + *((uint32 *) &cfg->sprom_control) = 0xffffffff;
13256 + sb_setcoreidx(sbh, coreidx);
13261 +sbpci_init(sb_t *sbh)
13263 + sbpci_init_pci(sbh);
13264 + sbpci_init_cores(sbh);
13269 +sbpci_check(sb_t *sbh)
13272 + sbpciregs_t *pci;
13274 + uint32 buf[64], *ptr, i;
13278 + coreidx = sb_coreidx(sbh);
13279 + pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
13281 + /* Clear the test array */
13282 + pa = (ulong) DMA_MAP(NULL, buf, sizeof(buf), DMA_RX, NULL);
13283 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]);
13284 + memset(ptr, 0, sizeof(buf));
13286 + /* Point PCI window 1 to memory */
13287 + sbtopci1 = R_REG(&pci->sbtopci1);
13288 + W_REG(&pci->sbtopci1, SBTOPCI_MEM | (pa & SBTOPCI1_MASK));
13290 + /* Fill the test array via PCI window 1 */
13291 + ptr = (uint32 *) REG_MAP(SB_PCI_CFG + (pa & ~SBTOPCI1_MASK), sizeof(buf));
13292 + for (i = 0; i < ARRAYSIZE(buf); i++) {
13293 + for (j = 0; j < 2; j++);
13294 + W_REG(&ptr[i], i);
13298 + /* Restore PCI window 1 */
13299 + W_REG(&pci->sbtopci1, sbtopci1);
13301 + /* Check the test array */
13302 + DMA_UNMAP(NULL, pa, sizeof(buf), DMA_RX, NULL);
13303 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]);
13304 + for (i = 0; i < ARRAYSIZE(buf); i++) {
13309 + /* Change the clock if the test fails */
13310 + if (i < ARRAYSIZE(buf)) {
13313 + cur = sb_clock(sbh);
13314 + printf("PCI: Test failed at %d MHz\n", (cur + 500000) / 1000000);
13315 + for (req = 104000000; req < 176000000; req += 4000000) {
13316 + printf("PCI: Resetting to %d MHz\n", (req + 500000) / 1000000);
13317 + /* This will only reset if the clocks are valid and have changed */
13318 + sb_mips_setclock(sbh, req, 0, 0);
13320 + /* Should not reach here */
13324 + sb_setcoreidx(sbh, coreidx);
13327 diff -urN linux.old/arch/mips/bcm947xx/setup.c linux.dev/arch/mips/bcm947xx/setup.c
13328 --- linux.old/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100
13329 +++ linux.dev/arch/mips/bcm947xx/setup.c 2005-11-08 00:11:55.346775000 +0100
13332 + * Generic setup routines for Broadcom MIPS boards
13334 + * Copyright 2005, Broadcom Corporation
13335 + * All Rights Reserved.
13337 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
13338 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13339 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
13340 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
13345 +#include <linux/config.h>
13346 +#include <linux/init.h>
13347 +#include <linux/kernel.h>
13348 +#include <linux/serialP.h>
13349 +#include <linux/ide.h>
13350 +#include <asm/bootinfo.h>
13351 +#include <asm/cpu.h>
13352 +#include <asm/time.h>
13353 +#include <asm/reboot.h>
13355 +#ifdef CONFIG_MTD_PARTITIONS
13356 +#include <linux/mtd/mtd.h>
13357 +#include <linux/mtd/partitions.h>
13360 +#include <typedefs.h>
13362 +#include <sbutils.h>
13363 +#include <bcmutils.h>
13364 +#include <bcmnvram.h>
13365 +#include <sbmips.h>
13366 +#include <trxhdr.h>
13368 +extern void bcm947xx_time_init(void);
13369 +extern void bcm947xx_timer_setup(struct irqaction *irq);
13371 +#ifdef CONFIG_REMOTE_DEBUG
13372 +extern void set_debug_traps(void);
13373 +extern void rs_kgdb_hook(struct serial_state *);
13374 +extern void breakpoint(void);
13377 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
13378 +extern struct ide_ops std_ide_ops;
13381 +/* Global SB handle */
13382 +sb_t *bcm947xx_sbh = NULL;
13383 +spinlock_t bcm947xx_sbh_lock = SPIN_LOCK_UNLOCKED;
13384 +EXPORT_SYMBOL(bcm947xx_sbh);
13385 +EXPORT_SYMBOL(bcm947xx_sbh_lock);
13388 +#define sbh bcm947xx_sbh
13389 +#define sbh_lock bcm947xx_sbh_lock
13391 +/* Kernel command line */
13392 +char arcs_cmdline[CL_SIZE] __initdata = CONFIG_CMDLINE;
13395 +bcm947xx_machine_restart(char *command)
13397 + printk("Please stand by while rebooting the system...\n");
13399 + /* Set the watchdog timer to reset immediately */
13401 + sb_watchdog(sbh, 1);
13406 +bcm947xx_machine_halt(void)
13408 + printk("System halted\n");
13410 + /* Disable interrupts and watchdog and spin forever */
13412 + sb_watchdog(sbh, 0);
13416 +#ifdef CONFIG_SERIAL
13418 +static struct serial_struct rs = {
13420 + flags: ASYNC_BOOT_AUTOCONF,
13421 + io_type: SERIAL_IO_MEM,
13424 +static void __init
13425 +serial_add(void *regs, uint irq, uint baud_base, uint reg_shift)
13427 + rs.iomem_base = regs;
13428 + rs.irq = irq + 2;
13429 + rs.baud_base = baud_base / 16;
13430 + rs.iomem_reg_shift = reg_shift;
13432 + early_serial_setup(&rs);
13437 +static void __init
13438 +serial_setup(sb_t *sbh)
13440 + sb_serial_init(sbh, serial_add);
13442 +#ifdef CONFIG_REMOTE_DEBUG
13443 + /* Use the last port for kernel debugging */
13444 + if (rs.iomem_base)
13445 + rs_kgdb_hook(&rs);
13449 +#endif /* CONFIG_SERIAL */
13456 + /* Get global SB handle */
13457 + sbh = sb_kattach();
13459 + /* Initialize clocks and interrupts */
13460 + sb_mips_init(sbh);
13462 + if (BCM330X(current_cpu_data.processor_id) &&
13463 + (read_c0_diag() & BRCM_PFC_AVAIL)) {
13465 + * Now that the sbh is inited set the proper PFC value
13467 + printk("Setting the PFC to its default value\n");
13468 + enable_pfc(PFC_AUTO);
13472 +#ifdef CONFIG_SERIAL
13473 + /* Initialize UARTs */
13474 + serial_setup(sbh);
13477 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
13478 + ide_ops = &std_ide_ops;
13481 + /* Override default command line arguments */
13482 + value = nvram_get("kernel_cmdline");
13483 + if (value && strlen(value) && strncmp(value, "empty", 5))
13484 + strncpy(arcs_cmdline, value, sizeof(arcs_cmdline));
13487 + /* Generic setup */
13488 + _machine_restart = bcm947xx_machine_restart;
13489 + _machine_halt = bcm947xx_machine_halt;
13490 + _machine_power_off = bcm947xx_machine_halt;
13492 + board_time_init = bcm947xx_time_init;
13493 + board_timer_setup = bcm947xx_timer_setup;
13497 +get_system_type(void)
13499 + static char s[32];
13501 + if (bcm947xx_sbh) {
13502 + sprintf(s, "Broadcom BCM%X chip rev %d", sb_chip(bcm947xx_sbh),
13503 + sb_chiprev(bcm947xx_sbh));
13507 + return "Broadcom BCM947XX";
13511 +bus_error_init(void)
13515 +#ifdef CONFIG_MTD_PARTITIONS
13517 +static struct mtd_partition bcm947xx_parts[] = {
13518 + { name: "pmon", offset: 0, size: 0, mask_flags: MTD_WRITEABLE, },
13519 + { name: "linux", offset: 0, size: 0, },
13520 + { name: "rootfs", offset: 0, size: 0, },
13521 + { name: "nvram", offset: 0, size: 0, },
13522 + { name: "OpenWrt", offset: 0, size: 0, },
13527 +find_root(struct mtd_info *mtd, size_t size, struct mtd_partition *part)
13529 + struct trx_header *trx;
13530 + unsigned char buf[512];
13534 + trx = (struct trx_header *) buf;
13536 + for (off = (256*1024); off < size; off += mtd->erasesize) {
13537 + memset(buf, 0xe5, sizeof(buf));
13540 + * Read into buffer
13542 + if (MTD_READ(mtd, off, sizeof(buf), &len, buf) ||
13543 + len != sizeof(buf))
13546 + /* found a TRX header */
13547 + if (le32_to_cpu(trx->magic) == TRX_MAGIC) {
13548 + part->offset = le32_to_cpu(trx->offsets[2]) ? :
13549 + le32_to_cpu(trx->offsets[1]);
13550 + part->size = le32_to_cpu(trx->len);
13552 + part->size -= part->offset;
13553 + part->offset += off;
13559 + printk(KERN_NOTICE
13560 + "%s: Couldn't find root filesystem\n",
13565 + return part->size;
13568 +struct mtd_partition * __init
13569 +init_mtd_partitions(struct mtd_info *mtd, size_t size)
13572 + /* boot loader */
13573 + bcm947xx_parts[0].offset=0;
13574 + bcm947xx_parts[0].size=256*1024;
13577 + bcm947xx_parts[3].offset = size - ROUNDUP(NVRAM_SPACE, mtd->erasesize);
13578 + bcm947xx_parts[3].size = size - bcm947xx_parts[3].offset;
13580 + /* Size linux (kernel and rootfs) */
13581 + bcm947xx_parts[1].offset = bcm947xx_parts[0].size;
13582 + bcm947xx_parts[1].size = bcm947xx_parts[3].offset - bcm947xx_parts[1].offset;
13584 + /* Find and size rootfs */
13585 + if (find_root(mtd,size,&bcm947xx_parts[2])==0) {
13586 + /* entirely jffs2 */
13587 + bcm947xx_parts[2].size = bcm947xx_parts[3].offset - bcm947xx_parts[2].offset;
13588 + bcm947xx_parts[4].name = NULL;
13590 + /* legacy setup */
13591 + /* calculate leftover flash, and assign it to the jffs2 partition */
13592 + bcm947xx_parts[4].offset = bcm947xx_parts[2].offset + bcm947xx_parts[2].size;
13593 + bcm947xx_parts[4].offset = ROUNDUP(bcm947xx_parts[4].offset, mtd->erasesize);
13594 + bcm947xx_parts[4].size = bcm947xx_parts[3].offset - bcm947xx_parts[4].offset;
13597 + return bcm947xx_parts;
13600 +EXPORT_SYMBOL(init_mtd_partitions);
13603 diff -urN linux.old/arch/mips/bcm947xx/sflash.c linux.dev/arch/mips/bcm947xx/sflash.c
13604 --- linux.old/arch/mips/bcm947xx/sflash.c 1970-01-01 01:00:00.000000000 +0100
13605 +++ linux.dev/arch/mips/bcm947xx/sflash.c 2005-11-08 00:54:43.022739000 +0100
13608 + * Broadcom SiliconBackplane chipcommon serial flash interface
13610 + * Copyright 2005, Broadcom Corporation
13611 + * All Rights Reserved.
13613 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
13614 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13615 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
13616 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
13622 +#include <typedefs.h>
13623 +#include <sbconfig.h>
13624 +#include <sbchipc.h>
13625 +#include <mipsinc.h>
13626 +#include <bcmutils.h>
13627 +#include <bcmdevs.h>
13628 +#include <sflash.h>
13630 +/* Private global state */
13631 +static struct sflash sflash;
13633 +/* Issue a serial flash command */
13634 +static INLINE void
13635 +sflash_cmd(chipcregs_t *cc, uint opcode)
13637 + W_REG(&cc->flashcontrol, SFLASH_START | opcode);
13638 + while (R_REG(&cc->flashcontrol) & SFLASH_BUSY);
13641 +/* Initialize serial flash access */
13643 +sflash_init(chipcregs_t *cc)
13647 + bzero(&sflash, sizeof(sflash));
13649 + sflash.type = R_REG(&cc->capabilities) & CAP_FLASH_MASK;
13651 + switch (sflash.type) {
13653 + /* Probe for ST chips */
13654 + sflash_cmd(cc, SFLASH_ST_DP);
13655 + sflash_cmd(cc, SFLASH_ST_RES);
13656 + id = R_REG(&cc->flashdata);
13659 + /* ST M25P20 2 Mbit Serial Flash */
13660 + sflash.blocksize = 64 * 1024;
13661 + sflash.numblocks = 4;
13664 + /* ST M25P40 4 Mbit Serial Flash */
13665 + sflash.blocksize = 64 * 1024;
13666 + sflash.numblocks = 8;
13669 + /* ST M25P80 8 Mbit Serial Flash */
13670 + sflash.blocksize = 64 * 1024;
13671 + sflash.numblocks = 16;
13674 + /* ST M25P16 16 Mbit Serial Flash */
13675 + sflash.blocksize = 64 * 1024;
13676 + sflash.numblocks = 32;
13679 + /* ST M25P32 32 Mbit Serial Flash */
13680 + sflash.blocksize = 64 * 1024;
13681 + sflash.numblocks = 64;
13684 + W_REG(&cc->flashaddress, 1);
13685 + sflash_cmd(cc, SFLASH_ST_RES);
13686 + id2 = R_REG(&cc->flashdata);
13687 + if (id2 == 0x44) {
13688 + /* SST M25VF80 4 Mbit Serial Flash */
13689 + sflash.blocksize = 64 * 1024;
13690 + sflash.numblocks = 8;
13697 + /* Probe for Atmel chips */
13698 + sflash_cmd(cc, SFLASH_AT_STATUS);
13699 + id = R_REG(&cc->flashdata) & 0x3c;
13702 + /* Atmel AT45DB011 1Mbit Serial Flash */
13703 + sflash.blocksize = 256;
13704 + sflash.numblocks = 512;
13707 + /* Atmel AT45DB021 2Mbit Serial Flash */
13708 + sflash.blocksize = 256;
13709 + sflash.numblocks = 1024;
13712 + /* Atmel AT45DB041 4Mbit Serial Flash */
13713 + sflash.blocksize = 256;
13714 + sflash.numblocks = 2048;
13717 + /* Atmel AT45DB081 8Mbit Serial Flash */
13718 + sflash.blocksize = 256;
13719 + sflash.numblocks = 4096;
13722 + /* Atmel AT45DB161 16Mbit Serial Flash */
13723 + sflash.blocksize = 512;
13724 + sflash.numblocks = 4096;
13727 + /* Atmel AT45DB321 32Mbit Serial Flash */
13728 + sflash.blocksize = 512;
13729 + sflash.numblocks = 8192;
13732 + /* Atmel AT45DB642 64Mbit Serial Flash */
13733 + sflash.blocksize = 1024;
13734 + sflash.numblocks = 8192;
13740 + sflash.size = sflash.blocksize * sflash.numblocks;
13741 + return sflash.size ? &sflash : NULL;
13744 +/* Read len bytes starting at offset into buf. Returns number of bytes read. */
13746 +sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf)
13749 + uint32 *from, *to;
13754 + if ((offset + len) > sflash.size)
13757 + if ((len >= 4) && (offset & 3))
13758 + cnt = 4 - (offset & 3);
13759 + else if ((len >= 4) && ((uint32)buf & 3))
13760 + cnt = 4 - ((uint32)buf & 3);
13764 + from = (uint32 *)KSEG1ADDR(SB_FLASH2 + offset);
13765 + to = (uint32 *)buf;
13768 + bcopy(from, to, cnt);
13772 + while (cnt >= 4) {
13777 + return (len - cnt);
13780 +/* Poll for command completion. Returns zero when complete. */
13782 +sflash_poll(chipcregs_t *cc, uint offset)
13784 + if (offset >= sflash.size)
13787 + switch (sflash.type) {
13789 + /* Check for ST Write In Progress bit */
13790 + sflash_cmd(cc, SFLASH_ST_RDSR);
13791 + return R_REG(&cc->flashdata) & SFLASH_ST_WIP;
13793 + /* Check for Atmel Ready bit */
13794 + sflash_cmd(cc, SFLASH_AT_STATUS);
13795 + return !(R_REG(&cc->flashdata) & SFLASH_AT_READY);
13801 +/* Write len bytes starting at offset into buf. Returns number of bytes
13802 + * written. Caller should poll for completion.
13805 +sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
13807 + struct sflash *sfl;
13810 + uint32 page, byte, mask;
13815 + if ((offset + len) > sflash.size)
13819 + switch (sfl->type) {
13821 + mask = R_REG(&cc->chipid);
13822 + is4712b0 = (((mask & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
13823 + ((mask & CID_REV_MASK) == (3 << CID_REV_SHIFT)));
13824 + /* Enable writes */
13825 + sflash_cmd(cc, SFLASH_ST_WREN);
13828 + W_REG(&cc->flashaddress, offset);
13829 + W_REG(&cc->flashdata, *buf++);
13830 + /* Set chip select */
13831 + OR_REG(&cc->gpioout, mask);
13832 + /* Issue a page program with the first byte */
13833 + sflash_cmd(cc, SFLASH_ST_PP);
13837 + while (len > 0) {
13838 + if ((offset & 255) == 0) {
13839 + /* Page boundary, drop cs and return */
13840 + AND_REG(&cc->gpioout, ~mask);
13841 + if (!sflash_poll(cc, offset)) {
13842 + /* Flash rejected command */
13847 + /* Write single byte */
13848 + sflash_cmd(cc, *buf++);
13854 + /* All done, drop cs if needed */
13855 + if ((offset & 255) != 1) {
13857 + AND_REG(&cc->gpioout, ~mask);
13858 + if (!sflash_poll(cc, offset)) {
13859 + /* Flash rejected command */
13865 + W_REG(&cc->flashaddress, offset);
13866 + W_REG(&cc->flashdata, *buf);
13867 + /* Page program */
13868 + sflash_cmd(cc, SFLASH_ST_PP);
13872 + mask = sfl->blocksize - 1;
13873 + page = (offset & ~mask) << 1;
13874 + byte = offset & mask;
13875 + /* Read main memory page into buffer 1 */
13876 + if (byte || len < sfl->blocksize) {
13877 + W_REG(&cc->flashaddress, page);
13878 + sflash_cmd(cc, SFLASH_AT_BUF1_LOAD);
13879 + /* 250 us for AT45DB321B */
13880 + SPINWAIT(sflash_poll(cc, offset), 1000);
13881 + ASSERT(!sflash_poll(cc, offset));
13883 + /* Write into buffer 1 */
13884 + for (ret = 0; ret < len && byte < sfl->blocksize; ret++) {
13885 + W_REG(&cc->flashaddress, byte++);
13886 + W_REG(&cc->flashdata, *buf++);
13887 + sflash_cmd(cc, SFLASH_AT_BUF1_WRITE);
13889 + /* Write buffer 1 into main memory page */
13890 + W_REG(&cc->flashaddress, page);
13891 + sflash_cmd(cc, SFLASH_AT_BUF1_PROGRAM);
13898 +/* Erase a region. Returns number of bytes scheduled for erasure.
13899 + * Caller should poll for completion.
13902 +sflash_erase(chipcregs_t *cc, uint offset)
13904 + struct sflash *sfl;
13906 + if (offset >= sflash.size)
13910 + switch (sfl->type) {
13912 + sflash_cmd(cc, SFLASH_ST_WREN);
13913 + W_REG(&cc->flashaddress, offset);
13914 + sflash_cmd(cc, SFLASH_ST_SE);
13915 + return sfl->blocksize;
13917 + W_REG(&cc->flashaddress, offset << 1);
13918 + sflash_cmd(cc, SFLASH_AT_PAGE_ERASE);
13919 + return sfl->blocksize;
13926 + * writes the appropriate range of flash, a NULL buf simply erases
13927 + * the region of flash
13930 +sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
13932 + struct sflash *sfl;
13933 + uchar *block = NULL, *cur_ptr, *blk_ptr;
13934 + uint blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder;
13935 + uint blk_offset, blk_len, copied;
13936 + int bytes, ret = 0;
13938 + /* Check address range */
13943 + if ((offset + len) > sfl->size)
13946 + blocksize = sfl->blocksize;
13947 + mask = blocksize - 1;
13949 + /* Allocate a block of mem */
13950 + if (!(block = MALLOC(NULL, blocksize)))
13954 + /* Align offset */
13955 + cur_offset = offset & ~mask;
13956 + cur_length = blocksize;
13959 + remainder = blocksize - (offset & mask);
13960 + if (len < remainder)
13961 + cur_retlen = len;
13963 + cur_retlen = remainder;
13965 + /* buf == NULL means erase only */
13967 + /* Copy existing data into holding block if necessary */
13968 + if ((offset & mask) || (len < blocksize)) {
13969 + blk_offset = cur_offset;
13970 + blk_len = cur_length;
13971 + blk_ptr = cur_ptr;
13973 + /* Copy entire block */
13975 + copied = sflash_read(cc, blk_offset, blk_len, blk_ptr);
13976 + blk_offset += copied;
13977 + blk_len -= copied;
13978 + blk_ptr += copied;
13982 + /* Copy input data into holding block */
13983 + memcpy(cur_ptr + (offset & mask), buf, cur_retlen);
13986 + /* Erase block */
13987 + if ((ret = sflash_erase(cc, (uint) cur_offset)) < 0)
13989 + while (sflash_poll(cc, (uint) cur_offset));
13991 + /* buf == NULL means erase only */
13993 + offset += cur_retlen;
13994 + len -= cur_retlen;
13998 + /* Write holding block */
13999 + while (cur_length > 0) {
14000 + if ((bytes = sflash_write(cc,
14001 + (uint) cur_offset,
14002 + (uint) cur_length,
14003 + (uchar *) cur_ptr)) < 0) {
14007 + while (sflash_poll(cc, (uint) cur_offset));
14008 + cur_offset += bytes;
14009 + cur_length -= bytes;
14010 + cur_ptr += bytes;
14013 + offset += cur_retlen;
14014 + len -= cur_retlen;
14015 + buf += cur_retlen;
14021 + MFREE(NULL, block, blocksize);
14025 diff -urN linux.old/arch/mips/bcm947xx/time.c linux.dev/arch/mips/bcm947xx/time.c
14026 --- linux.old/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +0100
14027 +++ linux.dev/arch/mips/bcm947xx/time.c 2005-11-07 23:47:27.528101500 +0100
14030 + * Copyright 2004, Broadcom Corporation
14031 + * All Rights Reserved.
14033 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14034 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14035 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14036 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14038 + * $Id: time.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
14040 +#include <linux/config.h>
14041 +#include <linux/init.h>
14042 +#include <linux/kernel.h>
14043 +#include <linux/sched.h>
14044 +#include <linux/serial_reg.h>
14045 +#include <linux/interrupt.h>
14046 +#include <asm/addrspace.h>
14047 +#include <asm/io.h>
14048 +#include <asm/time.h>
14050 +#include <typedefs.h>
14052 +#include <sbutils.h>
14053 +#include <bcmnvram.h>
14054 +#include <sbconfig.h>
14055 +#include <sbextif.h>
14056 +#include <sbmips.h>
14058 +/* Global SB handle */
14059 +extern void *bcm947xx_sbh;
14060 +extern spinlock_t bcm947xx_sbh_lock;
14063 +#define sbh bcm947xx_sbh
14064 +#define sbh_lock bcm947xx_sbh_lock
14066 +extern int panic_timeout;
14067 +static int watchdog = 0;
14068 +static u8 *mcr = NULL;
14071 +bcm947xx_time_init(void)
14074 + extifregs_t *eir;
14077 + * Use deterministic values for initial counter interrupt
14078 + * so that calibrate delay avoids encountering a counter wrap.
14080 + write_c0_count(0);
14081 + write_c0_compare(0xffff);
14083 + if (!(hz = sb_mips_clock(sbh)))
14086 + printk("CPU: BCM%04x rev %d at %d MHz\n", sb_chip(sbh), sb_chiprev(sbh),
14087 + (hz + 500000) / 1000000);
14089 + /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
14090 + mips_hpt_frequency = hz / 2;
14092 + /* Set watchdog interval in ms */
14093 + watchdog = simple_strtoul(nvram_safe_get("watchdog"), NULL, 0);
14095 + /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */
14096 + if (watchdog > 0) {
14097 + if (watchdog < 3000)
14102 + /* Set panic timeout in seconds */
14103 + panic_timeout = watchdog / 1000;
14105 + /* Setup blink */
14106 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
14107 + sbconfig_t *sb = (sbconfig_t *)((unsigned int) eir + SBCONFIGOFF);
14108 + unsigned long base = EXTIF_CFGIF_BASE(sb_base(readl(&sb->sbadmatch1)));
14109 + mcr = (u8 *) ioremap_nocache(base + UART_MCR, 1);
14114 +bcm947xx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
14116 + /* Generic MIPS timer code */
14117 + timer_interrupt(irq, dev_id, regs);
14119 + /* Set the watchdog timer to reset after the specified number of ms */
14120 + if (watchdog > 0)
14121 + sb_watchdog(sbh, WATCHDOG_CLOCK / 1000 * watchdog);
14123 +#ifdef CONFIG_HWSIM
14124 + (*((int *)0xa0000f1c))++;
14126 + /* Blink one of the LEDs in the external UART */
14127 + if (mcr && !(jiffies % (HZ/2)))
14128 + writeb(readb(mcr) ^ UART_MCR_OUT2, mcr);
14132 +static struct irqaction bcm947xx_timer_irqaction = {
14133 + bcm947xx_timer_interrupt,
14142 +bcm947xx_timer_setup(struct irqaction *irq)
14144 + /* Enable the timer interrupt */
14145 + setup_irq(7, &bcm947xx_timer_irqaction);
14147 diff -urN linux.old/arch/mips/config-shared.in linux.dev/arch/mips/config-shared.in
14148 --- linux.old/arch/mips/config-shared.in 2005-11-07 23:12:50.850903750 +0100
14149 +++ linux.dev/arch/mips/config-shared.in 2005-11-07 21:57:07.889588500 +0100
14150 @@ -208,6 +208,14 @@
14152 define_bool CONFIG_MIPS_RTC y
14154 +dep_bool 'Support for Broadcom MIPS-based boards' CONFIG_MIPS_BRCM $CONFIG_EXPERIMENTAL
14155 +dep_bool 'Support for Broadcom BCM947XX' CONFIG_BCM947XX $CONFIG_MIPS_BRCM
14156 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
14157 + bool ' Support for Broadcom BCM4710' CONFIG_BCM4710
14158 + bool ' Support for Broadcom BCM4310' CONFIG_BCM4310
14159 + bool ' Support for Broadcom BCM4704' CONFIG_BCM4704
14160 + bool ' Support for Broadcom BCM5365' CONFIG_BCM5365
14162 bool 'Support for SNI RM200 PCI' CONFIG_SNI_RM200_PCI
14163 bool 'Support for TANBAC TB0226 (Mbase)' CONFIG_TANBAC_TB0226
14164 bool 'Support for TANBAC TB0229 (VR4131DIMM)' CONFIG_TANBAC_TB0229
14165 @@ -229,6 +237,11 @@
14166 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
14169 +# Provide an option for a default kernel command line
14171 +string 'Default kernel command string' CONFIG_CMDLINE ""
14174 # Select some configuration options automatically based on user selections.
14176 if [ "$CONFIG_ACER_PICA_61" = "y" ]; then
14177 @@ -554,6 +567,13 @@
14178 define_bool CONFIG_SWAP_IO_SPACE_L y
14179 define_bool CONFIG_BOOT_ELF32 y
14181 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
14182 + define_bool CONFIG_PCI y
14183 + define_bool CONFIG_NONCOHERENT_IO y
14184 + define_bool CONFIG_NEW_TIME_C y
14185 + define_bool CONFIG_NEW_IRQ y
14186 + define_bool CONFIG_HND y
14188 if [ "$CONFIG_SNI_RM200_PCI" = "y" ]; then
14189 define_bool CONFIG_ARC32 y
14190 define_bool CONFIG_ARC_MEMORY y
14191 @@ -1042,7 +1062,11 @@
14193 bool 'Are you using a crosscompiler' CONFIG_CROSSCOMPILE
14194 bool 'Enable run-time debugging' CONFIG_RUNTIME_DEBUG
14195 -bool 'Remote GDB kernel debugging' CONFIG_KGDB
14196 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
14197 + bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG
14199 + bool 'Remote GDB kernel debugging' CONFIG_KGDB
14201 dep_bool ' Console output to GDB' CONFIG_GDB_CONSOLE $CONFIG_KGDB
14202 if [ "$CONFIG_KGDB" = "y" ]; then
14203 define_bool CONFIG_DEBUG_INFO y
14204 diff -urN linux.old/arch/mips/kernel/cpu-probe.c linux.dev/arch/mips/kernel/cpu-probe.c
14205 --- linux.old/arch/mips/kernel/cpu-probe.c 2005-11-07 23:12:50.890906250 +0100
14206 +++ linux.dev/arch/mips/kernel/cpu-probe.c 2005-11-07 21:57:07.893588750 +0100
14207 @@ -163,7 +163,7 @@
14209 static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
14211 - switch (c->processor_id & 0xff00) {
14212 + switch (c->processor_id & PRID_IMP_MASK) {
14213 case PRID_IMP_R2000:
14214 c->cputype = CPU_R2000;
14215 c->isa_level = MIPS_CPU_ISA_I;
14216 @@ -173,7 +173,7 @@
14219 case PRID_IMP_R3000:
14220 - if ((c->processor_id & 0xff) == PRID_REV_R3000A)
14221 + if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A)
14222 if (cpu_has_confreg())
14223 c->cputype = CPU_R3081E;
14225 @@ -188,12 +188,12 @@
14227 case PRID_IMP_R4000:
14228 if (read_c0_config() & CONF_SC) {
14229 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
14230 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
14231 c->cputype = CPU_R4400PC;
14233 c->cputype = CPU_R4000PC;
14235 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
14236 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
14237 c->cputype = CPU_R4400SC;
14239 c->cputype = CPU_R4000SC;
14240 @@ -439,7 +439,7 @@
14241 static inline void cpu_probe_mips(struct cpuinfo_mips *c)
14244 - switch (c->processor_id & 0xff00) {
14245 + switch (c->processor_id & PRID_IMP_MASK) {
14247 c->cputype = CPU_4KC;
14248 c->isa_level = MIPS_CPU_ISA_M32;
14249 @@ -480,10 +480,10 @@
14252 c->options |= MIPS_CPU_PREFETCH;
14253 - switch (c->processor_id & 0xff00) {
14254 + switch (c->processor_id & PRID_IMP_MASK) {
14255 case PRID_IMP_AU1_REV1:
14256 case PRID_IMP_AU1_REV2:
14257 - switch ((c->processor_id >> 24) & 0xff) {
14258 + switch ((c->processor_id >> 24) & PRID_REV_MASK) {
14260 c->cputype = CPU_AU1000;
14262 @@ -511,10 +511,34 @@
14266 +static inline void cpu_probe_broadcom(struct cpuinfo_mips *c)
14268 + decode_config1(c);
14269 + c->options |= MIPS_CPU_PREFETCH;
14270 + switch (c->processor_id & PRID_IMP_MASK) {
14271 + case PRID_IMP_BCM4710:
14272 + c->cputype = CPU_BCM4710;
14273 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
14274 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
14275 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
14277 + case PRID_IMP_4KC:
14278 + case PRID_IMP_BCM3302:
14279 + c->cputype = CPU_BCM3302;
14280 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
14281 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
14282 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
14285 + c->cputype = CPU_UNKNOWN;
14290 static inline void cpu_probe_sibyte(struct cpuinfo_mips *c)
14293 - switch (c->processor_id & 0xff00) {
14294 + switch (c->processor_id & PRID_IMP_MASK) {
14296 c->cputype = CPU_SB1;
14297 c->isa_level = MIPS_CPU_ISA_M64;
14298 @@ -536,7 +560,7 @@
14299 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c)
14302 - switch (c->processor_id & 0xff00) {
14303 + switch (c->processor_id & PRID_IMP_MASK) {
14304 case PRID_IMP_SR71000:
14305 c->cputype = CPU_SR71000;
14306 c->isa_level = MIPS_CPU_ISA_M64;
14307 @@ -561,7 +585,7 @@
14308 c->cputype = CPU_UNKNOWN;
14310 c->processor_id = read_c0_prid();
14311 - switch (c->processor_id & 0xff0000) {
14312 + switch (c->processor_id & PRID_COMP_MASK) {
14314 case PRID_COMP_LEGACY:
14315 cpu_probe_legacy(c);
14316 @@ -572,6 +596,9 @@
14317 case PRID_COMP_ALCHEMY:
14318 cpu_probe_alchemy(c);
14320 + case PRID_COMP_BROADCOM:
14321 + cpu_probe_broadcom(c);
14323 case PRID_COMP_SIBYTE:
14324 cpu_probe_sibyte(c);
14326 diff -urN linux.old/arch/mips/kernel/head.S linux.dev/arch/mips/kernel/head.S
14327 --- linux.old/arch/mips/kernel/head.S 2005-11-07 23:12:50.898906750 +0100
14328 +++ linux.dev/arch/mips/kernel/head.S 2005-11-07 21:57:07.893588750 +0100
14329 @@ -28,12 +28,20 @@
14330 #include <asm/mipsregs.h>
14331 #include <asm/stackframe.h>
14333 +#ifdef CONFIG_BCM4710
14335 +#define eret nop; nop; eret
14343 * Reserved space for exception handlers.
14344 * Necessary for machines which link their kernels at KSEG0.
14349 /* The following two symbols are used for kernel profiling. */
14351 diff -urN linux.old/arch/mips/kernel/proc.c linux.dev/arch/mips/kernel/proc.c
14352 --- linux.old/arch/mips/kernel/proc.c 2005-11-07 23:12:50.906907250 +0100
14353 +++ linux.dev/arch/mips/kernel/proc.c 2005-11-07 21:57:07.893588750 +0100
14355 [CPU_AU1550] "Au1550",
14356 [CPU_24K] "MIPS 24K",
14357 [CPU_AU1200] "Au1200",
14358 + [CPU_BCM4710] "BCM4710",
14359 + [CPU_BCM3302] "BCM3302",
14363 static int show_cpuinfo(struct seq_file *m, void *v)
14365 unsigned int version = current_cpu_data.processor_id;
14366 diff -urN linux.old/arch/mips/kernel/setup.c linux.dev/arch/mips/kernel/setup.c
14367 --- linux.old/arch/mips/kernel/setup.c 2005-11-07 23:12:50.906907250 +0100
14368 +++ linux.dev/arch/mips/kernel/setup.c 2005-11-07 21:57:07.893588750 +0100
14369 @@ -493,6 +493,7 @@
14370 void swarm_setup(void);
14371 void hp_setup(void);
14372 void au1x00_setup(void);
14373 + void brcm_setup(void);
14374 void frame_info_init(void);
14377 @@ -691,6 +692,11 @@
14378 pmc_yosemite_setup();
14381 +#if defined(CONFIG_BCM4710) || defined(CONFIG_BCM4310)
14382 + case MACH_GROUP_BRCM:
14387 panic("Unsupported architecture");
14389 diff -urN linux.old/arch/mips/kernel/traps.c linux.dev/arch/mips/kernel/traps.c
14390 --- linux.old/arch/mips/kernel/traps.c 2005-11-07 23:12:50.922908250 +0100
14391 +++ linux.dev/arch/mips/kernel/traps.c 2005-11-07 21:57:07.893588750 +0100
14392 @@ -920,6 +920,7 @@
14393 void __init trap_init(void)
14395 extern char except_vec1_generic;
14396 + extern char except_vec2_generic;
14397 extern char except_vec3_generic, except_vec3_r4000;
14398 extern char except_vec_ejtag_debug;
14399 extern char except_vec4;
14400 @@ -927,6 +928,7 @@
14402 /* Copy the generic exception handler code to it's final destination. */
14403 memcpy((void *)(KSEG0 + 0x80), &except_vec1_generic, 0x80);
14404 + memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80);
14407 * Setup default vectors
14408 @@ -985,6 +987,12 @@
14409 set_except_vector(13, handle_tr);
14410 set_except_vector(22, handle_mdmx);
14412 + if (current_cpu_data.cputype == CPU_SB1) {
14413 + /* Enable timer interrupt and scd mapped interrupt */
14414 + clear_c0_status(0xf000);
14415 + set_c0_status(0xc00);
14418 if (cpu_has_fpu && !cpu_has_nofpuex)
14419 set_except_vector(15, handle_fpe);
14421 diff -urN linux.old/arch/mips/mm/c-r4k.c linux.dev/arch/mips/mm/c-r4k.c
14422 --- linux.old/arch/mips/mm/c-r4k.c 2005-11-07 23:12:50.954910250 +0100
14423 +++ linux.dev/arch/mips/mm/c-r4k.c 2005-11-07 21:57:08.157605250 +0100
14424 @@ -1166,3 +1166,47 @@
14425 build_clear_page();
14429 +#ifdef CONFIG_BCM4704
14430 +static void __init mips32_icache_fill(unsigned long addr, uint nbytes)
14432 + unsigned long ic_lsize = current_cpu_data.icache.linesz;
14434 + for (i = 0; i < nbytes; i += ic_lsize)
14435 + fill_icache_line((addr + i));
14439 + * This must be run from the cache on 4704A0
14440 + * so there are no mips core BIU ops in progress
14441 + * when the PFC is enabled.
14443 +#define PFC_CR0 0xff400000 /* control reg 0 */
14444 +#define PFC_CR1 0xff400004 /* control reg 1 */
14445 +static void __init enable_pfc(u32 mode)
14447 + /* write range */
14448 + *(volatile u32 *)PFC_CR1 = 0xffff0000;
14451 + *(volatile u32 *)PFC_CR0 = mode;
14456 +void check_enable_mips_pfc(int val)
14459 +#ifdef CONFIG_BCM4704
14460 + struct cpuinfo_mips *c = ¤t_cpu_data;
14462 + /* enable prefetch cache */
14463 + if (((c->processor_id & (PRID_COMP_MASK | PRID_IMP_MASK)) == PRID_IMP_BCM3302)
14464 + && (read_c0_diag() & (1 << 29))) {
14465 + mips32_icache_fill((unsigned long) &enable_pfc, 64);
14472 diff -urN linux.old/arch/mips/pci/Makefile linux.dev/arch/mips/pci/Makefile
14473 --- linux.old/arch/mips/pci/Makefile 2005-11-07 23:12:50.978911750 +0100
14474 +++ linux.dev/arch/mips/pci/Makefile 2005-11-07 21:57:07.897589000 +0100
14476 obj-$(CONFIG_MIPS_MSC) += ops-msc.o
14477 obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o
14478 obj-$(CONFIG_SNI_RM200_PCI) += ops-sni.o
14479 +ifndef CONFIG_BCM947XX
14482 obj-$(CONFIG_PCI_AUTO) += pci_auto.o
14484 include $(TOPDIR)/Rules.make
14485 diff -urN linux.old/drivers/char/serial.c linux.dev/drivers/char/serial.c
14486 --- linux.old/drivers/char/serial.c 2005-11-07 23:12:51.038915500 +0100
14487 +++ linux.dev/drivers/char/serial.c 2005-11-07 21:57:07.901589250 +0100
14488 @@ -444,6 +444,10 @@
14489 return inb(info->port+1);
14491 case SERIAL_IO_MEM:
14492 +#ifdef CONFIG_BCM4310
14493 + readb((unsigned long) info->iomem_base +
14494 + (UART_SCR<<info->iomem_reg_shift));
14496 return readb((unsigned long) info->iomem_base +
14497 (offset<<info->iomem_reg_shift));
14499 @@ -464,6 +468,9 @@
14500 case SERIAL_IO_MEM:
14501 writeb(value, (unsigned long) info->iomem_base +
14502 (offset<<info->iomem_reg_shift));
14503 +#ifdef CONFIG_BCM4704
14504 + *((volatile unsigned int *) KSEG1ADDR(0x18000000));
14508 outb(value, info->port+offset);
14509 @@ -1728,7 +1735,7 @@
14510 /* Special case since 134 is really 134.5 */
14511 quot = (2*baud_base / 269);
14513 - quot = baud_base / baud;
14514 + quot = (baud_base + (baud / 2)) / baud;
14516 /* If the quotient is zero refuse the change */
14517 if (!quot && old_termios) {
14518 @@ -1745,12 +1752,12 @@
14519 /* Special case since 134 is really 134.5 */
14520 quot = (2*baud_base / 269);
14522 - quot = baud_base / baud;
14523 + quot = (baud_base + (baud / 2)) / baud;
14526 /* As a last resort, if the quotient is zero, default to 9600 bps */
14528 - quot = baud_base / 9600;
14529 + quot = (baud_base + 4800) / 9600;
14531 * Work around a bug in the Oxford Semiconductor 952 rev B
14532 * chip which causes it to seriously miscalculate baud rates
14533 @@ -5984,6 +5991,13 @@
14534 * Divisor, bytesize and parity
14536 state = rs_table + co->index;
14538 + * Safe guard: state structure must have been initialized
14540 + if (state->iomem_base == NULL) {
14541 + printk("!unable to setup serial console!\n");
14545 state->flags |= ASYNC_CONS_FLOW;
14546 info = &async_sercons;
14547 @@ -5997,7 +6011,7 @@
14548 info->io_type = state->io_type;
14549 info->iomem_base = state->iomem_base;
14550 info->iomem_reg_shift = state->iomem_reg_shift;
14551 - quot = state->baud_base / baud;
14552 + quot = (state->baud_base + (baud / 2)) / baud;
14553 cval = cflag & (CSIZE | CSTOPB);
14554 #if defined(__powerpc__) || defined(__alpha__)
14556 diff -urN linux.old/drivers/mtd/maps/Config.in linux.dev/drivers/mtd/maps/Config.in
14557 --- linux.old/drivers/mtd/maps/Config.in 2005-11-07 23:12:51.086918500 +0100
14558 +++ linux.dev/drivers/mtd/maps/Config.in 2005-11-07 21:57:07.901589250 +0100
14562 if [ "$CONFIG_MIPS" = "y" ]; then
14563 + dep_tristate ' CFI Flash device mapped on Broadcom BCM947XX boards' CONFIG_MTD_BCM947XX $CONFIG_MTD_CFI
14564 dep_tristate ' Pb1000 MTD support' CONFIG_MTD_PB1000 $CONFIG_MIPS_PB1000
14565 dep_tristate ' Pb1500 MTD support' CONFIG_MTD_PB1500 $CONFIG_MIPS_PB1500
14566 dep_tristate ' Pb1100 MTD support' CONFIG_MTD_PB1100 $CONFIG_MIPS_PB1100
14567 diff -urN linux.old/drivers/mtd/maps/Makefile linux.dev/drivers/mtd/maps/Makefile
14568 --- linux.old/drivers/mtd/maps/Makefile 2005-11-07 23:12:51.086918500 +0100
14569 +++ linux.dev/drivers/mtd/maps/Makefile 2005-11-07 21:57:07.905589500 +0100
14572 # $Id: Makefile,v 1.37 2003/01/24 14:26:38 dwmw2 Exp $
14574 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include
14576 BELOW25 := $(shell echo $(PATCHLEVEL) | sed s/[1234]/y/)
14578 ifeq ($(BELOW25),y)
14583 +obj-$(CONFIG_MTD_BCM947XX) += bcm947xx-flash.o
14584 obj-$(CONFIG_MTD_CDB89712) += cdb89712.o
14585 obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o
14586 obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o
14587 diff -urN linux.old/drivers/mtd/maps/bcm947xx-flash.c linux.dev/drivers/mtd/maps/bcm947xx-flash.c
14588 --- linux.old/drivers/mtd/maps/bcm947xx-flash.c 1970-01-01 01:00:00.000000000 +0100
14589 +++ linux.dev/drivers/mtd/maps/bcm947xx-flash.c 2005-11-07 23:33:20.715765500 +0100
14592 + * Flash mapping for BCM947XX boards
14594 + * Copyright 2004, Broadcom Corporation
14595 + * All Rights Reserved.
14597 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14598 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14599 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14600 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14602 + * $Id: bcm947xx-flash.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
14605 +#include <linux/module.h>
14606 +#include <linux/types.h>
14607 +#include <linux/kernel.h>
14608 +#include <asm/io.h>
14609 +#include <linux/mtd/mtd.h>
14610 +#include <linux/mtd/map.h>
14611 +#include <linux/mtd/partitions.h>
14612 +#include <linux/config.h>
14615 +#include <typedefs.h>
14616 +#include <bcmnvram.h>
14617 +#include <bcmutils.h>
14618 +#include <sbconfig.h>
14619 +#include <sbchipc.h>
14620 +#include <sbutils.h>
14621 +#include <trxhdr.h>
14623 +/* Global SB handle */
14624 +extern void *bcm947xx_sbh;
14625 +extern spinlock_t bcm947xx_sbh_lock;
14628 +#define sbh bcm947xx_sbh
14629 +#define sbh_lock bcm947xx_sbh_lock
14631 +#ifdef CONFIG_MTD_PARTITIONS
14632 +extern struct mtd_partition * init_mtd_partitions(struct mtd_info *mtd, size_t size);
14635 +#define WINDOW_ADDR 0x1fc00000
14636 +#define WINDOW_SIZE 0x400000
14637 +#define BUSWIDTH 2
14639 +/* e.g., flash=2M or flash=4M */
14640 +static int flash = 0;
14641 +MODULE_PARM(flash, "i");
14643 +bcm947xx_setup(char *str)
14645 + flash = memparse(str, &str);
14648 +__setup("flash=", bcm947xx_setup);
14650 +static struct mtd_info *bcm947xx_mtd;
14652 +__u8 bcm947xx_map_read8(struct map_info *map, unsigned long ofs)
14654 + if (map->map_priv_2 == 1)
14655 + return __raw_readb(map->map_priv_1 + ofs);
14657 + u16 val = __raw_readw(map->map_priv_1 + (ofs & ~1));
14659 + return ((val >> 8) & 0xff);
14661 + return (val & 0xff);
14664 +__u16 bcm947xx_map_read16(struct map_info *map, unsigned long ofs)
14666 + return __raw_readw(map->map_priv_1 + ofs);
14669 +__u32 bcm947xx_map_read32(struct map_info *map, unsigned long ofs)
14671 + return __raw_readl(map->map_priv_1 + ofs);
14674 +void bcm947xx_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
14677 + memcpy_fromio(to, map->map_priv_1 + from, len);
14680 + u16 *dest = (u16 *) to;
14681 + u16 *src = (u16 *) (map->map_priv_1 + from);
14682 + for (i = 0; i < (len / 2); i++) {
14683 + dest[i] = src[i];
14686 + *((u8 *)dest+len-1) = src[i] & 0xff;
14690 +void bcm947xx_map_write8(struct map_info *map, __u8 d, unsigned long adr)
14692 + __raw_writeb(d, map->map_priv_1 + adr);
14696 +void bcm947xx_map_write16(struct map_info *map, __u16 d, unsigned long adr)
14698 + __raw_writew(d, map->map_priv_1 + adr);
14702 +void bcm947xx_map_write32(struct map_info *map, __u32 d, unsigned long adr)
14704 + __raw_writel(d, map->map_priv_1 + adr);
14708 +void bcm947xx_map_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
14710 + memcpy_toio(map->map_priv_1 + to, from, len);
14713 +struct map_info bcm947xx_map = {
14714 + name: "Physically mapped flash",
14715 + size: WINDOW_SIZE,
14716 + buswidth: BUSWIDTH,
14717 + read8: bcm947xx_map_read8,
14718 + read16: bcm947xx_map_read16,
14719 + read32: bcm947xx_map_read32,
14720 + copy_from: bcm947xx_map_copy_from,
14721 + write8: bcm947xx_map_write8,
14722 + write16: bcm947xx_map_write16,
14723 + write32: bcm947xx_map_write32,
14724 + copy_to: bcm947xx_map_copy_to
14727 +#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE)
14728 +#define init_bcm947xx_map init_module
14729 +#define cleanup_bcm947xx_map cleanup_module
14732 +mod_init_t init_bcm947xx_map(void)
14738 + uint window_addr = 0, window_size = 0;
14741 +#ifdef CONFIG_MTD_PARTITIONS
14742 + struct mtd_partition *parts;
14746 + spin_lock_irqsave(&sbh_lock, flags);
14747 + coreidx = sb_coreidx(sbh);
14749 + /* Check strapping option if chipcommon exists */
14750 + if ((cc = sb_setcore(sbh, SB_CC, 0))) {
14751 + fltype = readl(&cc->capabilities) & CAP_FLASH_MASK;
14752 + if (fltype == PFLASH) {
14753 + bcm947xx_map.map_priv_2 = 1;
14754 + window_addr = 0x1c000000;
14755 + bcm947xx_map.size = window_size = 32 * 1024 * 1024;
14756 + if ((readl(&cc->flash_config) & CC_CFG_DS) == 0)
14757 + bcm947xx_map.buswidth = 1;
14761 + bcm947xx_map.map_priv_2 = 0;
14762 + window_addr = WINDOW_ADDR;
14763 + window_size = WINDOW_SIZE;
14766 + sb_setcoreidx(sbh, coreidx);
14767 + spin_unlock_irqrestore(&sbh_lock, flags);
14769 + if (fltype != PFLASH) {
14770 + printk(KERN_ERR "pflash: found no supported devices\n");
14775 + bcm947xx_map.map_priv_1 = (unsigned long) ioremap(window_addr, window_size);
14776 + if (!bcm947xx_map.map_priv_1) {
14777 + printk(KERN_ERR "pflash: ioremap failed\n");
14782 + if (!(bcm947xx_mtd = do_map_probe("cfi_probe", &bcm947xx_map))) {
14783 + printk(KERN_ERR "pflash: cfi_probe failed\n");
14788 + bcm947xx_mtd->module = THIS_MODULE;
14790 + /* Allow size override for testing */
14791 + size = flash ? : bcm947xx_mtd->size;
14793 + printk(KERN_NOTICE "Flash device: 0x%x at 0x%x\n", size, window_addr);
14795 +#ifdef CONFIG_MTD_PARTITIONS
14796 + parts = init_mtd_partitions(bcm947xx_mtd, size);
14797 + for (i = 0; parts[i].name; i++);
14798 + ret = add_mtd_partitions(bcm947xx_mtd, parts, i);
14800 + printk(KERN_ERR "pflash: add_mtd_partitions failed\n");
14808 + if (bcm947xx_mtd)
14809 + map_destroy(bcm947xx_mtd);
14810 + if (bcm947xx_map.map_priv_1)
14811 + iounmap((void *) bcm947xx_map.map_priv_1);
14812 + bcm947xx_map.map_priv_1 = 0;
14816 +mod_exit_t cleanup_bcm947xx_map(void)
14818 +#ifdef CONFIG_MTD_PARTITIONS
14819 + del_mtd_partitions(bcm947xx_mtd);
14821 + map_destroy(bcm947xx_mtd);
14822 + iounmap((void *) bcm947xx_map.map_priv_1);
14823 + bcm947xx_map.map_priv_1 = 0;
14826 +module_init(init_bcm947xx_map);
14827 +module_exit(cleanup_bcm947xx_map);
14828 diff -urN linux.old/drivers/net/Config.in linux.dev/drivers/net/Config.in
14829 --- linux.old/drivers/net/Config.in 2005-11-07 23:12:51.110920000 +0100
14830 +++ linux.dev/drivers/net/Config.in 2005-11-07 21:57:07.905589500 +0100
14832 # Network device configuration
14835 +tristate 'Broadcom Home Network Division' CONFIG_HND $CONFIG_PCI
14837 source drivers/net/arcnet/Config.in
14839 tristate 'Dummy net driver support' CONFIG_DUMMY
14840 @@ -174,6 +176,7 @@
14842 dep_tristate ' Apricot Xen-II on board Ethernet' CONFIG_APRICOT $CONFIG_ISA
14843 dep_tristate ' Broadcom 4400 ethernet support (EXPERIMENTAL)' CONFIG_B44 $CONFIG_PCI $CONFIG_EXPERIMENTAL
14844 + dep_tristate ' Proprietary Broadcom 10/100 Ethernet support' CONFIG_ET $CONFIG_PCI
14845 dep_tristate ' CS89x0 support' CONFIG_CS89x0 $CONFIG_ISA
14846 dep_tristate ' DECchip Tulip (dc21x4x) PCI support' CONFIG_TULIP $CONFIG_PCI
14847 if [ "$CONFIG_TULIP" = "y" -o "$CONFIG_TULIP" = "m" ]; then
14848 diff -urN linux.old/drivers/net/Makefile linux.dev/drivers/net/Makefile
14849 --- linux.old/drivers/net/Makefile 2005-11-07 23:12:51.110920000 +0100
14850 +++ linux.dev/drivers/net/Makefile 2005-11-07 21:57:07.905589500 +0100
14852 # Makefile for the Linux network (ethercard) device drivers.
14855 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include
14861 obj-$(CONFIG_ISDN) += slhc.o
14864 +subdir-$(CONFIG_HND) += hnd
14865 +subdir-$(CONFIG_ET) += et
14866 +subdir-$(CONFIG_WL) += wl
14867 subdir-$(CONFIG_NET_PCMCIA) += pcmcia
14868 subdir-$(CONFIG_NET_WIRELESS) += wireless
14869 subdir-$(CONFIG_TULIP) += tulip
14871 obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o
14872 obj-$(CONFIG_SUNGEM) += sungem.o
14874 +ifeq ($(CONFIG_HND),y)
14875 + obj-y += hnd/hnd.o
14877 +ifeq ($(CONFIG_ET),y)
14880 +ifeq ($(CONFIG_WL),y)
14884 obj-$(CONFIG_MACE) += mace.o
14885 obj-$(CONFIG_BMAC) += bmac.o
14886 obj-$(CONFIG_GMAC) += gmac.o
14887 @@ -266,6 +281,7 @@
14892 include $(TOPDIR)/Rules.make
14895 diff -urN linux.old/drivers/net/et/Makefile linux.dev/drivers/net/et/Makefile
14896 --- linux.old/drivers/net/et/Makefile 1970-01-01 01:00:00.000000000 +0100
14897 +++ linux.dev/drivers/net/et/Makefile 2005-11-07 21:57:07.905589500 +0100
14900 +# Makefile for the Broadcom et driver
14902 +# Copyright 2004, Broadcom Corporation
14903 +# All Rights Reserved.
14905 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14906 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14907 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14908 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14910 +# $Id: Makefile,v 1.1 2005/03/16 13:50:00 wbx Exp $
14913 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCM47XX_CHOPS -DDMA -DBCMDRIVER
14916 +obj-y := et_linux.o etc.o etc47xx.o etc_robo.o etc_adm.o
14917 +obj-m := $(O_TARGET)
14919 +include $(TOPDIR)/Rules.make
14920 diff -urN linux.old/drivers/net/hnd/Makefile linux.dev/drivers/net/hnd/Makefile
14921 --- linux.old/drivers/net/hnd/Makefile 1970-01-01 01:00:00.000000000 +0100
14922 +++ linux.dev/drivers/net/hnd/Makefile 2005-11-07 21:57:07.905589500 +0100
14925 +# Makefile for the BCM47xx specific kernel interface routines
14929 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
14933 +HND_OBJS := bcmutils.o hnddma.o linux_osl.o sbutils.o bcmsrom.o
14935 +export-objs := shared_ksyms.o
14936 +obj-y := shared_ksyms.o $(HND_OBJS)
14937 +obj-m := $(O_TARGET)
14939 +include $(TOPDIR)/Rules.make
14941 +shared_ksyms.c: shared_ksyms.sh $(HND_OBJS)
14942 + sh -e $< $(HND_OBJS) > $@
14943 diff -urN linux.old/drivers/net/hnd/bcmsrom.c linux.dev/drivers/net/hnd/bcmsrom.c
14944 --- linux.old/drivers/net/hnd/bcmsrom.c 1970-01-01 01:00:00.000000000 +0100
14945 +++ linux.dev/drivers/net/hnd/bcmsrom.c 2005-11-07 22:28:05.077337250 +0100
14948 + * Misc useful routines to access NIC SROM/OTP .
14950 + * Copyright 2005, Broadcom Corporation
14951 + * All Rights Reserved.
14953 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14954 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14955 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14956 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14960 +#include <typedefs.h>
14962 +#include <bcmutils.h>
14963 +#include <bcmsrom.h>
14964 +#include <bcmdevs.h>
14965 +#include <bcmendian.h>
14966 +#include <sbpcmcia.h>
14967 +#include <pcicfg.h>
14968 +#include <sbutils.h>
14969 +#include <bcmnvram.h>
14971 +#include <proto/ethernet.h> /* for sprom content groking */
14973 +#define VARS_MAX 4096 /* should be reduced */
14975 +#define WRITE_ENABLE_DELAY 500 /* 500 ms after write enable/disable toggle */
14976 +#define WRITE_WORD_DELAY 20 /* 20 ms between each word write */
14978 +static int initvars_srom_pci(void *sbh, void *curmap, char **vars, int *count);
14979 +static int initvars_cis_pcmcia(void *sbh, osl_t *osh, char **vars, int *count);
14980 +static int initvars_flash_sb(void *sbh, char **vars, int *count);
14981 +static int srom_parsecis(osl_t *osh, uint8 *cis, char **vars, int *count);
14982 +static int sprom_cmd_pcmcia(osl_t *osh, uint8 cmd);
14983 +static int sprom_read_pcmcia(osl_t *osh, uint16 addr, uint16 *data);
14984 +static int sprom_write_pcmcia(osl_t *osh, uint16 addr, uint16 data);
14985 +static int sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc);
14987 +static int initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count);
14988 +static int initvars_flash(osl_t *osh, char **vp, int len, char *devpath);
14991 + * Initialize local vars from the right source for this platform.
14992 + * Return 0 on success, nonzero on error.
14995 +srom_var_init(void *sbh, uint bustype, void *curmap, osl_t *osh, char **vars, int *count)
14997 + ASSERT(bustype == BUSTYPE(bustype));
14998 + if (vars == NULL || count == NULL)
15001 + switch (BUSTYPE(bustype)) {
15004 + return initvars_flash_sb(sbh, vars, count);
15007 + ASSERT(curmap); /* can not be NULL */
15008 + return initvars_srom_pci(sbh, curmap, vars, count);
15011 + return initvars_cis_pcmcia(sbh, osh, vars, count);
15020 +/* support only 16-bit word read from srom */
15022 +srom_read(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf)
15027 + ASSERT(bustype == BUSTYPE(bustype));
15029 + /* check input - 16-bit access only */
15030 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
15033 + off = byteoff / 2;
15036 + if (BUSTYPE(bustype) == PCI_BUS) {
15039 + srom = (uchar*)curmap + PCI_BAR0_SPROM_OFFSET;
15040 + if (sprom_read_pci(srom, off, buf, nw, FALSE))
15042 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
15043 + for (i = 0; i < nw; i++) {
15044 + if (sprom_read_pcmcia(osh, (uint16)(off + i), (uint16*)(buf + i)))
15054 +/* support only 16-bit word write into srom */
15056 +srom_write(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf)
15059 + uint i, off, nw, crc_range;
15060 + uint16 image[SPROM_SIZE], *p;
15062 + volatile uint32 val32;
15064 + ASSERT(bustype == BUSTYPE(bustype));
15066 + /* check input - 16-bit access only */
15067 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
15070 + crc_range = (((BUSTYPE(bustype) == PCMCIA_BUS) || (BUSTYPE(bustype) == SDIO_BUS)) ? SPROM_SIZE : SPROM_CRC_RANGE) * 2;
15072 + /* if changes made inside crc cover range */
15073 + if (byteoff < crc_range) {
15074 + nw = (((byteoff + nbytes) > crc_range) ? byteoff + nbytes : crc_range) / 2;
15075 + /* read data including entire first 64 words from srom */
15076 + if (srom_read(bustype, curmap, osh, 0, nw * 2, image))
15078 + /* make changes */
15079 + bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes);
15080 + /* calculate crc */
15081 + htol16_buf(image, crc_range);
15082 + crc = ~hndcrc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE);
15083 + ltoh16_buf(image, crc_range);
15084 + image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff);
15089 + off = byteoff / 2;
15093 + if (BUSTYPE(bustype) == PCI_BUS) {
15094 + srom = (uint16*)((uchar*)curmap + PCI_BAR0_SPROM_OFFSET);
15095 + /* enable writes to the SPROM */
15096 + val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32));
15097 + val32 |= SPROM_WRITEEN;
15098 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32);
15099 + bcm_mdelay(WRITE_ENABLE_DELAY);
15101 + for (i = 0; i < nw; i++) {
15102 + W_REG(&srom[off + i], p[i]);
15103 + bcm_mdelay(WRITE_WORD_DELAY);
15105 + /* disable writes to the SPROM */
15106 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 & ~SPROM_WRITEEN);
15107 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
15108 + /* enable writes to the SPROM */
15109 + if (sprom_cmd_pcmcia(osh, SROM_WEN))
15111 + bcm_mdelay(WRITE_ENABLE_DELAY);
15113 + for (i = 0; i < nw; i++) {
15114 + sprom_write_pcmcia(osh, (uint16)(off + i), p[i]);
15115 + bcm_mdelay(WRITE_WORD_DELAY);
15117 + /* disable writes to the SPROM */
15118 + if (sprom_cmd_pcmcia(osh, SROM_WDS))
15124 + bcm_mdelay(WRITE_ENABLE_DELAY);
15130 +srom_parsecis(osl_t *osh, uint8 *cis, char **vars, int *count)
15134 + uint8 tup, tlen, sromrev = 1;
15137 + bool ag_init = FALSE;
15143 + base = vp = MALLOC(osh, VARS_MAX);
15152 + if ((i + tlen) >= CIS_SIZE)
15156 + case CISTPL_MANFID:
15157 + vp += sprintf(vp, "manfid=%d", (cis[i + 1] << 8) + cis[i]);
15159 + vp += sprintf(vp, "prodid=%d", (cis[i + 3] << 8) + cis[i + 2]);
15163 + case CISTPL_FUNCE:
15164 + if (cis[i] == LAN_NID) {
15165 + ASSERT(cis[i + 1] == ETHER_ADDR_LEN);
15166 + bcm_ether_ntoa((uchar*)&cis[i + 2], eabuf);
15167 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
15172 + case CISTPL_CFTABLE:
15173 + vp += sprintf(vp, "regwindowsz=%d", (cis[i + 7] << 8) | cis[i + 6]);
15177 + case CISTPL_BRCM_HNBU:
15178 + switch (cis[i]) {
15179 + case HNBU_SROMREV:
15180 + sromrev = cis[i + 1];
15183 + case HNBU_CHIPID:
15184 + vp += sprintf(vp, "vendid=%d", (cis[i + 2] << 8) + cis[i + 1]);
15186 + vp += sprintf(vp, "devid=%d", (cis[i + 4] << 8) + cis[i + 3]);
15189 + vp += sprintf(vp, "chiprev=%d", (cis[i + 6] << 8) + cis[i + 5]);
15194 + case HNBU_BOARDREV:
15195 + vp += sprintf(vp, "boardrev=%d", cis[i + 1]);
15200 + vp += sprintf(vp, "aa0=%d", cis[i + 1]);
15205 + vp += sprintf(vp, "ag0=%d", cis[i + 1]);
15211 + ASSERT(sromrev > 1);
15212 + vp += sprintf(vp, "cc=%d", cis[i + 1]);
15216 + case HNBU_PAPARMS:
15218 + ASSERT(sromrev == 1);
15219 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + 1]);
15221 + } else if (tlen >= 9) {
15222 + if (tlen == 10) {
15223 + ASSERT(sromrev == 2);
15224 + vp += sprintf(vp, "opo=%d", cis[i + 9]);
15227 + ASSERT(tlen == 9);
15229 + for (j = 0; j < 3; j++) {
15230 + vp += sprintf(vp, "pa0b%d=%d", j,
15231 + (cis[i + (j * 2) + 2] << 8) + cis[i + (j * 2) + 1]);
15234 + vp += sprintf(vp, "pa0itssit=%d", cis[i + 7]);
15236 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + 8]);
15239 + ASSERT(tlen >= 9);
15243 + ASSERT(sromrev == 1);
15244 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
15245 + cis[i + 1], cis[i + 2], cis[i + 3], cis[i + 4],
15246 + cis[i + 5], cis[i + 6], cis[i + 7], cis[i + 8]);
15250 + case HNBU_BOARDFLAGS:
15251 + w32 = (cis[i + 2] << 8) + cis[i + 1];
15253 + w32 |= (cis[i + 4] << 24) + (cis[i + 3] << 16);
15254 + vp += sprintf(vp, "boardflags=0x%x", w32);
15259 + if (cis[i + 1] != 0xff) {
15260 + vp += sprintf(vp, "wl0gpio0=%d", cis[i + 1]);
15263 + if (cis[i + 2] != 0xff) {
15264 + vp += sprintf(vp, "wl0gpio1=%d", cis[i + 2]);
15267 + if (cis[i + 3] != 0xff) {
15268 + vp += sprintf(vp, "wl0gpio2=%d", cis[i + 3]);
15271 + if (cis[i + 4] != 0xff) {
15272 + vp += sprintf(vp, "wl0gpio3=%d", cis[i + 4]);
15278 + ASSERT(sromrev > 1);
15279 + vp += sprintf(vp, "ccode=%c%c", cis[i + 1], cis[i + 2]);
15281 + vp += sprintf(vp, "cctl=0x%x", cis[i + 3]);
15286 + ASSERT(sromrev > 2);
15287 + vp += sprintf(vp, "cckpo=0x%x", (cis[i + 2] << 8) | cis[i + 1]);
15291 + case HNBU_OFDMPO:
15292 + ASSERT(sromrev > 2);
15293 + vp += sprintf(vp, "ofdmpo=0x%x", (cis[i + 4] << 24) |
15294 + (cis[i + 3] << 16) | (cis[i + 2] << 8) | cis[i + 1]);
15302 + } while (tup != 0xff);
15304 + /* Set the srom version */
15305 + vp += sprintf(vp, "sromrev=%d", sromrev);
15308 + /* if there is no antenna gain field, set default */
15309 + if (ag_init == FALSE) {
15310 + ASSERT(sromrev == 1);
15311 + vp += sprintf(vp, "ag0=%d", 0xff);
15315 + /* final nullbyte terminator */
15317 + varsize = (uint)(vp - base);
15319 + ASSERT((vp - base) < VARS_MAX);
15321 + if (varsize == VARS_MAX) {
15324 + vp = MALLOC(osh, varsize);
15327 + bcopy(base, vp, varsize);
15328 + MFREE(osh, base, VARS_MAX);
15335 + *count = varsize;
15341 +/* set PCMCIA sprom command register */
15343 +sprom_cmd_pcmcia(osl_t *osh, uint8 cmd)
15345 + uint8 status = 0;
15346 + uint wait_cnt = 1000;
15348 + /* write sprom command register */
15349 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_CS, &cmd, 1);
15351 + /* wait status */
15352 + while (wait_cnt--) {
15353 + OSL_PCMCIA_READ_ATTR(osh, SROM_CS, &status, 1);
15354 + if (status & SROM_DONE)
15361 +/* read a word from the PCMCIA srom */
15363 +sprom_read_pcmcia(osl_t *osh, uint16 addr, uint16 *data)
15365 + uint8 addr_l, addr_h, data_l, data_h;
15367 + addr_l = (uint8)((addr * 2) & 0xff);
15368 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
15370 + /* set address */
15371 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
15372 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
15375 + if (sprom_cmd_pcmcia(osh, SROM_READ))
15379 + data_h = data_l = 0;
15380 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAH, &data_h, 1);
15381 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAL, &data_l, 1);
15383 + *data = (data_h << 8) | data_l;
15387 +/* write a word to the PCMCIA srom */
15389 +sprom_write_pcmcia(osl_t *osh, uint16 addr, uint16 data)
15391 + uint8 addr_l, addr_h, data_l, data_h;
15393 + addr_l = (uint8)((addr * 2) & 0xff);
15394 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
15395 + data_l = (uint8)(data & 0xff);
15396 + data_h = (uint8)((data >> 8) & 0xff);
15398 + /* set address */
15399 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
15400 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
15403 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAH, &data_h, 1);
15404 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAL, &data_l, 1);
15407 + return sprom_cmd_pcmcia(osh, SROM_WRITE);
15411 + * Read in and validate sprom.
15412 + * Return 0 on success, nonzero on error.
15415 +sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc)
15420 + /* read the sprom */
15421 + for (i = 0; i < nwords; i++)
15422 + buf[i] = R_REG(&sprom[wordoff + i]);
15425 + /* fixup the endianness so crc8 will pass */
15426 + htol16_buf(buf, nwords * 2);
15427 + if (hndcrc8((uint8*)buf, nwords * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE)
15429 + /* now correct the endianness of the byte array */
15430 + ltoh16_buf(buf, nwords * 2);
15437 +* Create variable table from memory.
15438 +* Return 0 on success, nonzero on error.
15441 +initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count)
15443 + int c = (int)(end - start);
15445 + /* do it only when there is more than just the null string */
15447 + char *vp = MALLOC(osh, c);
15450 + return BCME_NOMEM;
15451 + bcopy(start, vp, c);
15464 +* Find variables with <devpath> from flash. 'base' points to the beginning
15465 +* of the table upon enter and to the end of the table upon exit when success.
15466 +* Return 0 on success, nonzero on error.
15469 +initvars_flash(osl_t *osh, char **base, int size, char *devpath)
15471 + char *vp = *base;
15475 + uint l, dl, copy_len;
15477 + /* allocate memory and read in flash */
15478 + if (!(flash = MALLOC(osh, NVRAM_SPACE)))
15479 + return BCME_NOMEM;
15480 + if ((err = BCMINIT(nvram_getall)(flash, NVRAM_SPACE)))
15483 + /* grab vars with the <devpath> prefix in name */
15484 + dl = strlen(devpath);
15485 + for (s = flash; s && *s; s += l + 1) {
15488 + /* skip non-matching variable */
15489 + if (strncmp(s, devpath, dl))
15492 + /* is there enough room to copy? */
15493 + copy_len = l - dl + 1;
15494 + if (size < (int)copy_len) {
15495 + err = BCME_BUFTOOSHORT;
15499 + /* no prefix, just the name=value */
15500 + strcpy(vp, &s[dl]);
15502 + size -= copy_len;
15505 + /* add null string as terminator */
15507 + err = BCME_BUFTOOSHORT;
15514 +exit: MFREE(osh, flash, NVRAM_SPACE);
15519 + * Initialize nonvolatile variable table from flash.
15520 + * Return 0 on success, nonzero on error.
15523 +initvars_flash_sb(void *sbh, char **vars, int *count)
15525 + osl_t *osh = sb_osh(sbh);
15526 + char devpath[SB_DEVPATH_BUFSZ];
15533 + if ((err = sb_devpath(sbh, devpath, sizeof(devpath))))
15536 + base = vp = MALLOC(osh, VARS_MAX);
15539 + return BCME_NOMEM;
15541 + if ((err = initvars_flash(osh, &vp, VARS_MAX, devpath)))
15544 + err = initvars_table(osh, base, vp, vars, count);
15546 +err: MFREE(osh, base, VARS_MAX);
15551 + * Initialize nonvolatile variable table from sprom.
15552 + * Return 0 on success, nonzero on error.
15555 +initvars_srom_pci(void *sbh, void *curmap, char **vars, int *count)
15559 + struct ether_addr ea;
15564 + osl_t *osh = sb_osh(sbh);
15565 + bool flash = FALSE;
15566 + char name[SB_DEVPATH_BUFSZ+16], *value;
15567 + char devpath[SB_DEVPATH_BUFSZ];
15571 + * Apply CRC over SROM content regardless SROM is present or not,
15572 + * and use variable <devpath>sromrev's existance in flash to decide
15573 + * if we should return an error when CRC fails or read SROM variables
15576 + if (sprom_read_pci((void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, sizeof(b)/sizeof(b[0]), TRUE)) {
15577 + if ((err = sb_devpath(sbh, devpath, sizeof(devpath))))
15579 + sprintf(name, "%ssromrev", devpath);
15580 + if (!(value = getvar(NULL, name)))
15582 + sromrev = (uint8)bcm_strtoul(value, NULL, 0);
15585 + /* srom is good */
15587 + /* top word of sprom contains version and crc8 */
15588 + sromrev = b[63] & 0xff;
15589 + /* bcm4401 sroms misprogrammed */
15590 + if (sromrev == 0x10)
15594 + /* srom version check */
15601 + base = vp = MALLOC(osh, VARS_MAX);
15606 + /* read variables from flash */
15608 + if ((err = initvars_flash(osh, &vp, VARS_MAX, devpath)))
15613 + vp += sprintf(vp, "sromrev=%d", sromrev);
15616 + if (sromrev >= 3) {
15617 + /* New section takes over the 3th hardware function space */
15619 + /* Words 22+23 are 11a (mid) ofdm power offsets */
15620 + w32 = ((uint32)b[23] << 16) | b[22];
15621 + vp += sprintf(vp, "ofdmapo=%d", w32);
15624 + /* Words 24+25 are 11a (low) ofdm power offsets */
15625 + w32 = ((uint32)b[25] << 16) | b[24];
15626 + vp += sprintf(vp, "ofdmalpo=%d", w32);
15629 + /* Words 26+27 are 11a (high) ofdm power offsets */
15630 + w32 = ((uint32)b[27] << 16) | b[26];
15631 + vp += sprintf(vp, "ofdmahpo=%d", w32);
15634 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
15635 + w32 = ((uint32)b[43] << 24) | ((uint32)b[42] << 8);
15636 + vp += sprintf(vp, "gpiotimerval=%d", w32);
15638 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
15639 + w32 = ((uint32)((unsigned char)(b[21] >> 8) & 0xFF) << 24) | /* oncount*/
15640 + ((uint32)((unsigned char)(b[21] & 0xFF)) << 8); /* offcount */
15641 + vp += sprintf(vp, "gpiotimerval=%d", w32);
15646 + if (sromrev >= 2) {
15647 + /* New section takes over the 4th hardware function space */
15649 + /* Word 29 is max power 11a high/low */
15651 + vp += sprintf(vp, "pa1himaxpwr=%d", w & 0xff);
15653 + vp += sprintf(vp, "pa1lomaxpwr=%d", (w >> 8) & 0xff);
15656 + /* Words 30-32 set the 11alow pa settings,
15657 + * 33-35 are the 11ahigh ones.
15659 + for (i = 0; i < 3; i++) {
15660 + vp += sprintf(vp, "pa1lob%d=%d", i, b[30 + i]);
15662 + vp += sprintf(vp, "pa1hib%d=%d", i, b[33 + i]);
15667 + vp += sprintf(vp, "ccode=");
15669 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff));
15674 + /* parameter section of sprom starts at byte offset 72 */
15677 + /* first 6 bytes are il0macaddr */
15678 + ea.octet[0] = (b[woff] >> 8) & 0xff;
15679 + ea.octet[1] = b[woff] & 0xff;
15680 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
15681 + ea.octet[3] = b[woff+1] & 0xff;
15682 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
15683 + ea.octet[5] = b[woff+2] & 0xff;
15684 + woff += ETHER_ADDR_LEN/2 ;
15685 + bcm_ether_ntoa((uchar*)&ea, eabuf);
15686 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
15689 + /* next 6 bytes are et0macaddr */
15690 + ea.octet[0] = (b[woff] >> 8) & 0xff;
15691 + ea.octet[1] = b[woff] & 0xff;
15692 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
15693 + ea.octet[3] = b[woff+1] & 0xff;
15694 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
15695 + ea.octet[5] = b[woff+2] & 0xff;
15696 + woff += ETHER_ADDR_LEN/2 ;
15697 + bcm_ether_ntoa((uchar*)&ea, eabuf);
15698 + vp += sprintf(vp, "et0macaddr=%s", eabuf);
15701 + /* next 6 bytes are et1macaddr */
15702 + ea.octet[0] = (b[woff] >> 8) & 0xff;
15703 + ea.octet[1] = b[woff] & 0xff;
15704 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
15705 + ea.octet[3] = b[woff+1] & 0xff;
15706 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
15707 + ea.octet[5] = b[woff+2] & 0xff;
15708 + woff += ETHER_ADDR_LEN/2 ;
15709 + bcm_ether_ntoa((uchar*)&ea, eabuf);
15710 + vp += sprintf(vp, "et1macaddr=%s", eabuf);
15714 + * Enet phy settings one or two singles or a dual
15715 + * Bits 4-0 : MII address for enet0 (0x1f for not there)
15716 + * Bits 9-5 : MII address for enet1 (0x1f for not there)
15717 + * Bit 14 : Mdio for enet0
15718 + * Bit 15 : Mdio for enet1
15721 + vp += sprintf(vp, "et0phyaddr=%d", (w & 0x1f));
15723 + vp += sprintf(vp, "et1phyaddr=%d", ((w >> 5) & 0x1f));
15725 + vp += sprintf(vp, "et0mdcport=%d", ((w >> 14) & 0x1));
15727 + vp += sprintf(vp, "et1mdcport=%d", ((w >> 15) & 0x1));
15730 + /* Word 46 has board rev, antennas 0/1 & Country code/control */
15732 + vp += sprintf(vp, "boardrev=%d", w & 0xff);
15736 + vp += sprintf(vp, "cctl=%d", (w >> 8) & 0xf);
15738 + vp += sprintf(vp, "cc=%d", (w >> 8) & 0xf);
15741 + vp += sprintf(vp, "aa0=%d", (w >> 12) & 0x3);
15744 + vp += sprintf(vp, "aa1=%d", (w >> 14) & 0x3);
15747 + /* Words 47-49 set the (wl) pa settings */
15750 + for (i = 0; i < 3; i++) {
15751 + vp += sprintf(vp, "pa0b%d=%d", i, b[woff+i]);
15753 + vp += sprintf(vp, "pa1b%d=%d", i, b[woff+i+6]);
15758 + * Words 50-51 set the customer-configured wl led behavior.
15759 + * 8 bits/gpio pin. High bit: activehi=0, activelo=1;
15760 + * LED behavior values defined in wlioctl.h .
15763 + if ((w != 0) && (w != 0xffff)) {
15765 + vp += sprintf(vp, "wl0gpio0=%d", (w & 0xff));
15769 + vp += sprintf(vp, "wl0gpio1=%d", (w >> 8) & 0xff);
15773 + if ((w != 0) && (w != 0xffff)) {
15775 + vp += sprintf(vp, "wl0gpio2=%d", w & 0xff);
15779 + vp += sprintf(vp, "wl0gpio3=%d", (w >> 8) & 0xff);
15783 + /* Word 52 is max power 0/1 */
15785 + vp += sprintf(vp, "pa0maxpwr=%d", w & 0xff);
15787 + vp += sprintf(vp, "pa1maxpwr=%d", (w >> 8) & 0xff);
15790 + /* Word 56 is idle tssi target 0/1 */
15792 + vp += sprintf(vp, "pa0itssit=%d", w & 0xff);
15794 + vp += sprintf(vp, "pa1itssit=%d", (w >> 8) & 0xff);
15797 + /* Word 57 is boardflags, if not programmed make it zero */
15798 + w32 = (uint32)b[57];
15799 + if (w32 == 0xffff) w32 = 0;
15800 + if (sromrev > 1) {
15801 + /* Word 28 is the high bits of boardflags */
15802 + w32 |= (uint32)b[28] << 16;
15804 + vp += sprintf(vp, "boardflags=%d", w32);
15807 + /* Word 58 is antenna gain 0/1 */
15809 + vp += sprintf(vp, "ag0=%d", w & 0xff);
15812 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff);
15815 + if (sromrev == 1) {
15816 + /* set the oem string */
15817 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
15818 + ((b[59] >> 8) & 0xff), (b[59] & 0xff),
15819 + ((b[60] >> 8) & 0xff), (b[60] & 0xff),
15820 + ((b[61] >> 8) & 0xff), (b[61] & 0xff),
15821 + ((b[62] >> 8) & 0xff), (b[62] & 0xff));
15823 + } else if (sromrev == 2) {
15824 + /* Word 60 OFDM tx power offset from CCK level */
15825 + /* OFDM Power Offset - opo */
15826 + vp += sprintf(vp, "opo=%d", b[60] & 0xff);
15829 + /* Word 60: cck power offsets */
15830 + vp += sprintf(vp, "cckpo=%d", b[60]);
15833 + /* Words 61+62: 11g ofdm power offsets */
15834 + w32 = ((uint32)b[62] << 16) | b[61];
15835 + vp += sprintf(vp, "ofdmgpo=%d", w32);
15839 + /* final nullbyte terminator */
15842 + ASSERT((vp - base) <= VARS_MAX);
15844 +done: err = initvars_table(osh, base, vp, vars, count);
15846 +err: MFREE(osh, base, VARS_MAX);
15851 + * Read the cis and call parsecis to initialize the vars.
15852 + * Return 0 on success, nonzero on error.
15855 +initvars_cis_pcmcia(void *sbh, osl_t *osh, char **vars, int *count)
15857 + uint8 *cis = NULL;
15861 + data_sz = (sb_pcmciarev(sbh) == 1) ? (SPROM_SIZE * 2) : CIS_SIZE;
15863 + if ((cis = MALLOC(osh, data_sz)) == NULL)
15866 + if (sb_pcmciarev(sbh) == 1) {
15867 + if (srom_read(PCMCIA_BUS, (void *)NULL, osh, 0, data_sz, (uint16 *)cis)) {
15868 + MFREE(osh, cis, data_sz);
15871 + /* fix up endianess for 16-bit data vs 8-bit parsing */
15872 + ltoh16_buf((uint16 *)cis, data_sz);
15874 + OSL_PCMCIA_READ_ATTR(osh, 0, cis, data_sz);
15876 + rc = srom_parsecis(osh, cis, vars, count);
15878 + MFREE(osh, cis, data_sz);
15883 diff -urN linux.old/drivers/net/hnd/bcmutils.c linux.dev/drivers/net/hnd/bcmutils.c
15884 --- linux.old/drivers/net/hnd/bcmutils.c 1970-01-01 01:00:00.000000000 +0100
15885 +++ linux.dev/drivers/net/hnd/bcmutils.c 2005-11-08 12:52:21.836276500 +0100
15888 + * Misc useful OS-independent routines.
15890 + * Copyright 2005, Broadcom Corporation
15891 + * All Rights Reserved.
15893 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
15894 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
15895 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
15896 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
15900 +#include <typedefs.h>
15903 +#include <sbutils.h>
15904 +#include <bcmnvram.h>
15906 +#include <stdio.h>
15907 +#include <string.h>
15909 +#include <bcmutils.h>
15910 +#include <bcmendian.h>
15911 +#include <bcmdevs.h>
15914 +/* copy a pkt buffer chain into a buffer */
15916 +pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf)
15921 + len = 4096; /* "infinite" */
15923 + /* skip 'offset' bytes */
15924 + for (; p && offset; p = PKTNEXT(osh, p)) {
15925 + if (offset < (uint)PKTLEN(osh, p))
15927 + offset -= PKTLEN(osh, p);
15933 + /* copy the data */
15934 + for (; p && len; p = PKTNEXT(osh, p)) {
15935 + n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len);
15936 + bcopy(PKTDATA(osh, p) + offset, buf, n);
15946 +/* return total length of buffer chain */
15948 +pkttotlen(osl_t *osh, void *p)
15953 + for (; p; p = PKTNEXT(osh, p))
15954 + total += PKTLEN(osh, p);
15959 +pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[])
15961 + q->head = q->tail = NULL;
15962 + q->maxlen = maxlen;
15965 + q->priority = TRUE;
15966 + bcopy(prio_map, q->prio_map, sizeof(q->prio_map));
15969 + q->priority = FALSE;
15972 +/* should always check pktq_full before calling pktenq */
15974 +pktenq(struct pktq *q, void *p, bool lifo)
15976 + void *next, *prev;
15978 + /* allow 10 pkts slack */
15979 + ASSERT(q->len < (q->maxlen + 10));
15981 + /* Queueing chains not allowed */
15982 + ASSERT(PKTLINK(p) == NULL);
15984 + /* Queue is empty */
15985 + if (q->tail == NULL) {
15986 + ASSERT(q->head == NULL);
15987 + q->head = q->tail = p;
15990 + /* Insert at head or tail */
15991 + else if (q->priority == FALSE) {
15992 + /* Insert at head (LIFO) */
15994 + PKTSETLINK(p, q->head);
15997 + /* Insert at tail (FIFO) */
15999 + ASSERT(PKTLINK(q->tail) == NULL);
16000 + PKTSETLINK(q->tail, p);
16001 + PKTSETLINK(p, NULL);
16006 + /* Insert by priority */
16008 + /* legal priorities 0-7 */
16009 + ASSERT(PKTPRIO(p) <= MAXPRIO);
16013 + /* Shortcut to insertion at tail */
16014 + if (_pktq_pri(q, PKTPRIO(p)) < _pktq_pri(q, PKTPRIO(q->tail)) ||
16015 + (!lifo && _pktq_pri(q, PKTPRIO(p)) <= _pktq_pri(q, PKTPRIO(q->tail)))) {
16019 + /* Insert at head or in the middle */
16024 + /* Walk the queue */
16025 + for (; next; prev = next, next = PKTLINK(next)) {
16026 + /* Priority queue invariant */
16027 + ASSERT(!prev || _pktq_pri(q, PKTPRIO(prev)) >= _pktq_pri(q, PKTPRIO(next)));
16028 + /* Insert at head of string of packets of same priority (LIFO) */
16030 + if (_pktq_pri(q, PKTPRIO(p)) >= _pktq_pri(q, PKTPRIO(next)))
16033 + /* Insert at tail of string of packets of same priority (FIFO) */
16035 + if (_pktq_pri(q, PKTPRIO(p)) > _pktq_pri(q, PKTPRIO(next)))
16039 + /* Insert at tail */
16040 + if (next == NULL) {
16041 + ASSERT(PKTLINK(q->tail) == NULL);
16042 + PKTSETLINK(q->tail, p);
16043 + PKTSETLINK(p, NULL);
16046 + /* Insert in the middle */
16048 + PKTSETLINK(prev, p);
16049 + PKTSETLINK(p, next);
16051 + /* Insert at head */
16053 + PKTSETLINK(p, q->head);
16058 + /* List invariants after insertion */
16060 + ASSERT(PKTLINK(q->tail) == NULL);
16065 +/* dequeue packet at head */
16067 +pktdeq(struct pktq *q)
16071 + if ((p = q->head)) {
16073 + q->head = PKTLINK(p);
16074 + PKTSETLINK(p, NULL);
16076 + if (q->head == NULL)
16080 + ASSERT(q->tail == NULL);
16086 +/* dequeue packet at tail */
16088 +pktdeqtail(struct pktq *q)
16091 + void *next, *prev;
16093 + if (q->head == q->tail) { /* last packet on queue or queue empty */
16095 + q->head = q->tail = NULL;
16100 + /* start walk at head */
16104 + /* Walk the queue to find prev of q->tail */
16105 + for (; next; prev = next, next = PKTLINK(next)) {
16106 + if (next == q->tail)
16112 + PKTSETLINK(prev, NULL);
16120 +unsigned char bcm_ctype[] = {
16121 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */
16122 + _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 */
16123 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */
16124 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */
16125 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */
16126 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */
16127 + _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */
16128 + _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */
16129 + _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 */
16130 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */
16131 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */
16132 + _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */
16133 + _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 */
16134 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */
16135 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */
16136 + _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */
16137 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
16138 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
16139 + _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 */
16140 + _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 */
16141 + _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 */
16142 + _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 */
16143 + _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 */
16144 + _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 */
16148 +bcm_toupper(uchar c)
16150 + if (bcm_islower(c))
16156 +bcm_strtoul(char *cp, char **endp, uint base)
16158 + ulong result, value;
16163 + while (bcm_isspace(*cp))
16166 + if (cp[0] == '+')
16168 + else if (cp[0] == '-') {
16174 + if (cp[0] == '0') {
16175 + if ((cp[1] == 'x') || (cp[1] == 'X')) {
16184 + } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) {
16190 + while (bcm_isxdigit(*cp) &&
16191 + (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) {
16192 + result = result*base + value;
16197 + result = (ulong)(result * -1);
16200 + *endp = (char *)cp;
16212 + while (bcm_isdigit(*s))
16213 + n = (n * 10) + *s++ - '0';
16217 +/* return pointer to location of substring 'needle' in 'haystack' */
16219 +bcmstrstr(char *haystack, char *needle)
16224 + if ((haystack == NULL) || (needle == NULL))
16225 + return (haystack);
16227 + nlen = strlen(needle);
16228 + len = strlen(haystack) - nlen + 1;
16230 + for (i = 0; i < len; i++)
16231 + if (bcmp(needle, &haystack[i], nlen) == 0)
16232 + return (&haystack[i]);
16237 +bcmstrcat(char *dest, const char *src)
16239 + strcpy(&dest[strlen(dest)], src);
16243 +#if defined(CONFIG_USBRNDIS_RETAIL) || defined(NDIS_MINIPORT_DRIVER)
16244 +/* registry routine buffer preparation utility functions:
16245 + * parameter order is like strncpy, but returns count
16246 + * of bytes copied. Minimum bytes copied is null char(1)/wchar(2)
16256 + ulong copyct = 1;
16259 + if (abuflen == 0)
16262 + /* wbuflen is in bytes */
16263 + wbuflen /= sizeof(ushort);
16265 + for (i = 0; i < wbuflen; ++i) {
16266 + if (--abuflen == 0)
16268 + *abuf++ = (char) *wbuf++;
16278 +bcm_ether_ntoa(char *ea, char *buf)
16280 + sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x",
16281 + (uchar)ea[0]&0xff, (uchar)ea[1]&0xff, (uchar)ea[2]&0xff,
16282 + (uchar)ea[3]&0xff, (uchar)ea[4]&0xff, (uchar)ea[5]&0xff);
16286 +/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
16288 +bcm_ether_atoe(char *p, char *ea)
16293 + ea[i++] = (char) bcm_strtoul(p, &p, 16);
16294 + if (!*p++ || i == 6)
16302 +bcm_mdelay(uint ms)
16306 + for (i = 0; i < ms; i++) {
16312 + * Search the name=value vars for a specific one and return its value.
16313 + * Returns NULL if not found.
16316 +getvar(char *vars, char *name)
16321 + len = strlen(name);
16323 + /* first look in vars[] */
16324 + for (s = vars; s && *s; ) {
16325 + if ((bcmp(s, name, len) == 0) && (s[len] == '='))
16326 + return (&s[len+1]);
16332 + /* then query nvram */
16333 + return (BCMINIT(nvram_get)(name));
16337 + * Search the vars for a specific one and return its value as
16338 + * an integer. Returns 0 if not found.
16341 +getintvar(char *vars, char *name)
16345 + if ((val = getvar(vars, name)) == NULL)
16348 + return (bcm_strtoul(val, NULL, 0));
16352 +/* Search for token in comma separated token-string */
16354 +findmatch(char *string, char *name)
16359 + len = strlen(name);
16360 + while ((c = strchr(string, ',')) != NULL) {
16361 + if (len == (uint)(c - string) && !strncmp(string, name, len))
16366 + return (!strcmp(string, name));
16369 +/* Return gpio pin number assigned to the named pin */
16371 +* Variable should be in format:
16373 +* gpio<N>=pin_name,pin_name
16375 +* This format allows multiple features to share the gpio with mutual
16378 +* 'def_pin' is returned if a specific gpio is not defined for the requested functionality
16379 +* and if def_pin is not used by others.
16382 +getgpiopin(char *vars, char *pin_name, uint def_pin)
16384 + char name[] = "gpioXXXX";
16388 + /* Go thru all possibilities till a match in pin name */
16389 + for (pin = 0; pin < GPIO_NUMPINS; pin ++) {
16390 + sprintf(name, "gpio%d", pin);
16391 + val = getvar(vars, name);
16392 + if (val && findmatch(val, pin_name))
16396 + if (def_pin != GPIO_PIN_NOTDEFINED) {
16397 + /* make sure the default pin is not used by someone else */
16398 + sprintf(name, "gpio%d", def_pin);
16399 + if (getvar(vars, name)) {
16400 + def_pin = GPIO_PIN_NOTDEFINED;
16408 +static char bcm_undeferrstr[BCME_STRLEN];
16410 +static const char *bcmerrorstrtable[] = \
16412 + "Undefined error", /* BCME_ERROR */
16413 + "Bad Argument", /* BCME_BADARG*/
16414 + "Bad Option", /* BCME_BADOPTION*/
16415 + "Not up", /* BCME_NOTUP */
16416 + "Not down", /* BCME_NOTDOWN */
16417 + "Not AP", /* BCME_NOTAP */
16418 + "Not STA", /* BCME_NOTSTA */
16419 + "Bad Key Index", /* BCME_BADKEYIDX */
16420 + "Radio Off", /* BCME_RADIOOFF */
16421 + "Not band locked", /* BCME_NOTBANDLOCKED */
16422 + "No clock", /* BCME_NOCLK */
16423 + "Bad Rate valueset", /* BCME_BADRATESET */
16424 + "Bad Band", /* BCME_BADBAND */
16425 + "Buffer too short", /* BCME_BUFTOOSHORT */
16426 + "Buffer too length", /* BCME_BUFTOOLONG */
16427 + "Busy", /* BCME_BUSY */
16428 + "Not Associated", /* BCME_NOTASSOCIATED */
16429 + "Bad SSID len", /* BCME_BADSSIDLEN */
16430 + "Out of Range Channel", /* BCME_OUTOFRANGECHAN */
16431 + "Bad Channel", /* BCME_BADCHAN */
16432 + "Bad Address", /* BCME_BADADDR */
16433 + "Not Enough Resources", /* BCME_NORESOURCE */
16434 + "Unsupported", /* BCME_UNSUPPORTED */
16435 + "Bad length", /* BCME_BADLENGTH */
16436 + "Not Ready", /* BCME_NOTREADY */
16437 + "Not Permitted", /* BCME_EPERM */
16438 + "No Memory", /* BCME_NOMEM */
16439 + "Associated", /* BCME_ASSOCIATED */
16440 + "Not In Range", /* BCME_RANGE */
16441 + "Not Found" /* BCME_NOTFOUND */
16444 +/* Convert the Error codes into related Error strings */
16446 +bcmerrorstr(int bcmerror)
16448 + int abs_bcmerror;
16450 + abs_bcmerror = ABS(bcmerror);
16452 + /* check if someone added a bcmerror code but forgot to add errorstring */
16453 + ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(bcmerrorstrtable) - 1));
16454 + if ( (bcmerror > 0) || (abs_bcmerror > ABS(BCME_LAST))) {
16455 + sprintf(bcm_undeferrstr, "undefined Error %d", bcmerror);
16456 + return bcm_undeferrstr;
16459 + ASSERT((strlen((char*)bcmerrorstrtable[abs_bcmerror])) < BCME_STRLEN);
16461 + return bcmerrorstrtable[abs_bcmerror];
16463 +#endif /* #ifdef BCMDRIVER */
16466 +/*******************************************************************************
16469 + * Computes a crc8 over the input data using the polynomial:
16471 + * x^8 + x^7 +x^6 + x^4 + x^2 + 1
16473 + * The caller provides the initial value (either CRC8_INIT_VALUE
16474 + * or the previous returned value) to allow for processing of
16475 + * discontiguous blocks of data. When generating the CRC the
16476 + * caller is responsible for complementing the final return value
16477 + * and inserting it into the byte stream. When checking, a final
16478 + * return value of CRC8_GOOD_VALUE indicates a valid CRC.
16480 + * Reference: Dallas Semiconductor Application Note 27
16481 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
16482 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
16483 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
16485 + ******************************************************************************/
16487 +static uint8 crc8_table[256] = {
16488 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
16489 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
16490 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
16491 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
16492 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
16493 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
16494 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
16495 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
16496 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
16497 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
16498 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
16499 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
16500 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
16501 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
16502 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
16503 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
16504 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
16505 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
16506 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
16507 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
16508 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
16509 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
16510 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
16511 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
16512 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
16513 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
16514 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
16515 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
16516 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
16517 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
16518 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
16519 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
16522 +#define CRC_INNER_LOOP(n, c, x) \
16523 + (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff]
16527 + uint8 *pdata, /* pointer to array of data to process */
16528 + uint nbytes, /* number of input data bytes to process */
16529 + uint8 crc /* either CRC8_INIT_VALUE or previous return value */
16532 + /* hard code the crc loop instead of using CRC_INNER_LOOP macro
16533 + * to avoid the undefined and unnecessary (uint8 >> 8) operation. */
16534 + while (nbytes-- > 0)
16535 + crc = crc8_table[(crc ^ *pdata++) & 0xff];
16540 +/*******************************************************************************
16543 + * Computes a crc16 over the input data using the polynomial:
16545 + * x^16 + x^12 +x^5 + 1
16547 + * The caller provides the initial value (either CRC16_INIT_VALUE
16548 + * or the previous returned value) to allow for processing of
16549 + * discontiguous blocks of data. When generating the CRC the
16550 + * caller is responsible for complementing the final return value
16551 + * and inserting it into the byte stream. When checking, a final
16552 + * return value of CRC16_GOOD_VALUE indicates a valid CRC.
16554 + * Reference: Dallas Semiconductor Application Note 27
16555 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
16556 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
16557 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
16559 + ******************************************************************************/
16561 +static uint16 crc16_table[256] = {
16562 + 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
16563 + 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
16564 + 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
16565 + 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
16566 + 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
16567 + 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
16568 + 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
16569 + 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
16570 + 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
16571 + 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
16572 + 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
16573 + 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
16574 + 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
16575 + 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
16576 + 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
16577 + 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
16578 + 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
16579 + 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
16580 + 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
16581 + 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
16582 + 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
16583 + 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
16584 + 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
16585 + 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
16586 + 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
16587 + 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
16588 + 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
16589 + 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
16590 + 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
16591 + 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
16592 + 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
16593 + 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
16598 + uint8 *pdata, /* pointer to array of data to process */
16599 + uint nbytes, /* number of input data bytes to process */
16600 + uint16 crc /* either CRC16_INIT_VALUE or previous return value */
16603 + while (nbytes-- > 0)
16604 + CRC_INNER_LOOP(16, crc, *pdata++);
16608 +static uint32 crc32_table[256] = {
16609 + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
16610 + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
16611 + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
16612 + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
16613 + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
16614 + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
16615 + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
16616 + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
16617 + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
16618 + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
16619 + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
16620 + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
16621 + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
16622 + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
16623 + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
16624 + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
16625 + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
16626 + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
16627 + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
16628 + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
16629 + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
16630 + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
16631 + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
16632 + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
16633 + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
16634 + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
16635 + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
16636 + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
16637 + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
16638 + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
16639 + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
16640 + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
16641 + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
16642 + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
16643 + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
16644 + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
16645 + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
16646 + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
16647 + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
16648 + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
16649 + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
16650 + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
16651 + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
16652 + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
16653 + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
16654 + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
16655 + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
16656 + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
16657 + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
16658 + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
16659 + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
16660 + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
16661 + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
16662 + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
16663 + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
16664 + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
16665 + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
16666 + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
16667 + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
16668 + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
16669 + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
16670 + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
16671 + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
16672 + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
16677 + uint8 *pdata, /* pointer to array of data to process */
16678 + uint nbytes, /* number of input data bytes to process */
16679 + uint32 crc /* either CRC32_INIT_VALUE or previous return value */
16685 + ulong *tptr = (ulong *)tmp;
16687 + /* in case the beginning of the buffer isn't aligned */
16688 + pend = (uint8 *)((uint)(pdata + 3) & 0xfffffffc);
16689 + nbytes -= (pend - pdata);
16690 + while (pdata < pend)
16691 + CRC_INNER_LOOP(32, crc, *pdata++);
16693 + /* handle bulk of data as 32-bit words */
16694 + pend = pdata + (nbytes & 0xfffffffc);
16695 + while (pdata < pend) {
16696 + tptr = *((ulong *) pdata);
16697 + *((ulong *) pdata) += 1;
16698 + CRC_INNER_LOOP(32, crc, tmp[0]);
16699 + CRC_INNER_LOOP(32, crc, tmp[1]);
16700 + CRC_INNER_LOOP(32, crc, tmp[2]);
16701 + CRC_INNER_LOOP(32, crc, tmp[3]);
16704 + /* 1-3 bytes at end of buffer */
16705 + pend = pdata + (nbytes & 0x03);
16706 + while (pdata < pend)
16707 + CRC_INNER_LOOP(32, crc, *pdata++);
16709 + pend = pdata + nbytes;
16710 + while (pdata < pend)
16711 + CRC_INNER_LOOP(32, crc, *pdata++);
16719 +#define CBUFSIZ (CLEN+4)
16722 +void testcrc32(void)
16726 + uint len[CNBUFS];
16728 + uint32 crc32tv[CNBUFS] =
16729 + {0xd2cb1faa, 0xd385c8fa, 0xf5b4f3f3, 0x55789e20, 0x00343110};
16731 + ASSERT((buf = MALLOC(CBUFSIZ*CNBUFS)) != NULL);
16733 + /* step through all possible alignments */
16734 + for (l=0;l<=4;l++) {
16735 + for (j=0; j<CNBUFS; j++) {
16737 + for (k=0; k<len[j]; k++)
16738 + *(buf + j*CBUFSIZ + (k+l)) = (j+k) & 0xff;
16741 + for (j=0; j<CNBUFS; j++) {
16742 + crcr = crc32(buf + j*CBUFSIZ + l, len[j], CRC32_INIT_VALUE);
16743 + ASSERT(crcr == crc32tv[j]);
16747 + MFREE(buf, CBUFSIZ*CNBUFS);
16754 + * Advance from the current 1-byte tag/1-byte length/variable-length value
16755 + * triple, to the next, returning a pointer to the next.
16756 + * If the current or next TLV is invalid (does not fit in given buffer length),
16757 + * NULL is returned.
16758 + * *buflen is not modified if the TLV elt parameter is invalid, or is decremented
16759 + * by the TLV paramter's length if it is valid.
16762 +bcm_next_tlv(bcm_tlv_t *elt, int *buflen)
16766 + /* validate current elt */
16767 + if (!bcm_valid_tlv(elt, *buflen))
16770 + /* advance to next elt */
16772 + elt = (bcm_tlv_t*)(elt->data + len);
16773 + *buflen -= (2 + len);
16775 + /* validate next elt */
16776 + if (!bcm_valid_tlv(elt, *buflen))
16783 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
16784 + * triples, returning a pointer to the substring whose first element
16788 +bcm_parse_tlvs(void *buf, int buflen, uint key)
16793 + elt = (bcm_tlv_t*)buf;
16796 + /* find tagged parameter */
16797 + while (totlen >= 2) {
16798 + int len = elt->len;
16800 + /* validate remaining totlen */
16801 + if ((elt->id == key) && (totlen >= (len + 2)))
16804 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
16805 + totlen -= (len + 2);
16812 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
16813 + * triples, returning a pointer to the substring whose first element
16814 + * matches tag. Stop parsing when we see an element whose ID is greater
16815 + * than the target key.
16818 +bcm_parse_ordered_tlvs(void *buf, int buflen, uint key)
16823 + elt = (bcm_tlv_t*)buf;
16826 + /* find tagged parameter */
16827 + while (totlen >= 2) {
16828 + uint id = elt->id;
16829 + int len = elt->len;
16831 + /* Punt if we start seeing IDs > than target key */
16835 + /* validate remaining totlen */
16836 + if ((id == key) && (totlen >= (len + 2)))
16839 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
16840 + totlen -= (len + 2);
16844 +/* routine to dump fields in a fileddesc structure */
16847 +bcmdumpfields(readreg_rtn read_rtn, void *arg0, void *arg1, struct fielddesc *fielddesc_array, char *buf, uint32 bufsize)
16851 + struct fielddesc *cur_ptr;
16854 + cur_ptr = fielddesc_array;
16856 + while (bufsize > (filled_len + 64)) {
16857 + if (cur_ptr->nameandfmt == NULL)
16859 + len = sprintf(buf, cur_ptr->nameandfmt, read_rtn(arg0, arg1, cur_ptr->offset));
16861 + filled_len += len;
16864 + return filled_len;
16868 +bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen)
16872 + len = strlen(name) + 1;
16874 + if ((len + datalen) > buflen)
16877 + strcpy(buf, name);
16879 + /* append data onto the end of the name string */
16880 + memcpy(&buf[len], data, datalen);
16886 +/* Quarter dBm units to mW
16887 + * Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153
16888 + * Table is offset so the last entry is largest mW value that fits in
16892 +#define QDBM_OFFSET 153
16893 +#define QDBM_TABLE_LEN 40
16895 +/* Smallest mW value that will round up to the first table entry, QDBM_OFFSET.
16896 + * Value is ( mW(QDBM_OFFSET - 1) + mW(QDBM_OFFSET) ) / 2
16898 +#define QDBM_TABLE_LOW_BOUND 6493
16900 +/* Largest mW value that will round down to the last table entry,
16901 + * QDBM_OFFSET + QDBM_TABLE_LEN-1.
16902 + * Value is ( mW(QDBM_OFFSET + QDBM_TABLE_LEN - 1) + mW(QDBM_OFFSET + QDBM_TABLE_LEN) ) / 2.
16904 +#define QDBM_TABLE_HIGH_BOUND 64938
16906 +static const uint16 nqdBm_to_mW_map[QDBM_TABLE_LEN] = {
16907 +/* qdBm: +0 +1 +2 +3 +4 +5 +6 +7 */
16908 +/* 153: */ 6683, 7079, 7499, 7943, 8414, 8913, 9441, 10000,
16909 +/* 161: */ 10593, 11220, 11885, 12589, 13335, 14125, 14962, 15849,
16910 +/* 169: */ 16788, 17783, 18836, 19953, 21135, 22387, 23714, 25119,
16911 +/* 177: */ 26607, 28184, 29854, 31623, 33497, 35481, 37584, 39811,
16912 +/* 185: */ 42170, 44668, 47315, 50119, 53088, 56234, 59566, 63096
16916 +bcm_qdbm_to_mw(uint8 qdbm)
16919 + int idx = qdbm - QDBM_OFFSET;
16921 + if (idx > QDBM_TABLE_LEN) {
16922 + /* clamp to max uint16 mW value */
16926 + /* scale the qdBm index up to the range of the table 0-40
16927 + * where an offset of 40 qdBm equals a factor of 10 mW.
16929 + while (idx < 0) {
16934 + /* return the mW value scaled down to the correct factor of 10,
16935 + * adding in factor/2 to get proper rounding. */
16936 + return ((nqdBm_to_mW_map[idx] + factor/2) / factor);
16940 +bcm_mw_to_qdbm(uint16 mw)
16944 + uint mw_uint = mw;
16947 + /* handle boundary case */
16948 + if (mw_uint <= 1)
16951 + offset = QDBM_OFFSET;
16953 + /* move mw into the range of the table */
16954 + while (mw_uint < QDBM_TABLE_LOW_BOUND) {
16959 + for (qdbm = 0; qdbm < QDBM_TABLE_LEN-1; qdbm++) {
16960 + boundary = nqdBm_to_mW_map[qdbm] + (nqdBm_to_mW_map[qdbm+1] - nqdBm_to_mW_map[qdbm])/2;
16961 + if (mw_uint < boundary) break;
16964 + qdbm += (uint8)offset;
16968 diff -urN linux.old/drivers/net/hnd/hnddma.c linux.dev/drivers/net/hnd/hnddma.c
16969 --- linux.old/drivers/net/hnd/hnddma.c 1970-01-01 01:00:00.000000000 +0100
16970 +++ linux.dev/drivers/net/hnd/hnddma.c 2005-11-08 16:07:38.846817500 +0100
16973 + * Generic Broadcom Home Networking Division (HND) DMA module.
16974 + * This supports the following chips: BCM42xx, 44xx, 47xx .
16976 + * Copyright 2005, Broadcom Corporation
16977 + * All Rights Reserved.
16979 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
16980 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
16981 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
16982 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
16987 +#include <typedefs.h>
16989 +#include <bcmendian.h>
16990 +#include <sbconfig.h>
16991 +#include <bcmutils.h>
16992 +#include <bcmdevs.h>
16993 +#include <sbutils.h>
16995 +struct dma_info; /* forward declaration */
16996 +#define di_t struct dma_info
16998 +#include <sbhnddma.h>
16999 +#include <hnddma.h>
17002 +#define DMA_ERROR(args)
17003 +#define DMA_TRACE(args)
17005 +/* default dma message level (if input msg_level pointer is null in dma_attach()) */
17006 +static uint dma_msg_level =
17009 +#define MAXNAMEL 8
17011 +/* dma engine software state */
17012 +typedef struct dma_info {
17013 + hnddma_t hnddma; /* exported structure */
17014 + uint *msg_level; /* message level pointer */
17015 + char name[MAXNAMEL]; /* callers name for diag msgs */
17017 + void *osh; /* os handle */
17018 + sb_t *sbh; /* sb handle */
17020 + bool dma64; /* dma64 enabled */
17021 + bool addrext; /* this dma engine supports DmaExtendedAddrChanges */
17023 + dma32regs_t *d32txregs; /* 32 bits dma tx engine registers */
17024 + dma32regs_t *d32rxregs; /* 32 bits dma rx engine registers */
17025 + dma64regs_t *d64txregs; /* 64 bits dma tx engine registers */
17026 + dma64regs_t *d64rxregs; /* 64 bits dma rx engine registers */
17028 + uint32 dma64align; /* either 8k or 4k depends on number of dd */
17029 + dma32dd_t *txd32; /* pointer to dma32 tx descriptor ring */
17030 + dma64dd_t *txd64; /* pointer to dma64 tx descriptor ring */
17031 + uint ntxd; /* # tx descriptors tunable */
17032 + uint txin; /* index of next descriptor to reclaim */
17033 + uint txout; /* index of next descriptor to post */
17034 + uint txavail; /* # free tx descriptors */
17035 + void **txp; /* pointer to parallel array of pointers to packets */
17036 + ulong txdpa; /* physical address of descriptor ring */
17037 + uint txdalign; /* #bytes added to alloc'd mem to align txd */
17038 + uint txdalloc; /* #bytes allocated for the ring */
17040 + dma32dd_t *rxd32; /* pointer to dma32 rx descriptor ring */
17041 + dma64dd_t *rxd64; /* pointer to dma64 rx descriptor ring */
17042 + uint nrxd; /* # rx descriptors tunable */
17043 + uint rxin; /* index of next descriptor to reclaim */
17044 + uint rxout; /* index of next descriptor to post */
17045 + void **rxp; /* pointer to parallel array of pointers to packets */
17046 + ulong rxdpa; /* physical address of descriptor ring */
17047 + uint rxdalign; /* #bytes added to alloc'd mem to align rxd */
17048 + uint rxdalloc; /* #bytes allocated for the ring */
17051 + uint rxbufsize; /* rx buffer size in bytes */
17052 + uint nrxpost; /* # rx buffers to keep posted */
17053 + uint rxoffset; /* rxcontrol offset */
17054 + uint ddoffsetlow; /* add to get dma address of descriptor ring, low 32 bits */
17055 + uint ddoffsethigh; /* add to get dma address of descriptor ring, high 32 bits */
17056 + uint dataoffsetlow; /* add to get dma address of data buffer, low 32 bits */
17057 + uint dataoffsethigh; /* add to get dma address of data buffer, high 32 bits */
17061 +#define DMA64_ENAB(di) ((di)->dma64)
17063 +#define DMA64_ENAB(di) (0)
17066 +/* descriptor bumping macros */
17067 +#define XXD(x, n) ((x) & ((n) - 1))
17068 +#define TXD(x) XXD((x), di->ntxd)
17069 +#define RXD(x) XXD((x), di->nrxd)
17070 +#define NEXTTXD(i) TXD(i + 1)
17071 +#define PREVTXD(i) TXD(i - 1)
17072 +#define NEXTRXD(i) RXD(i + 1)
17073 +#define NTXDACTIVE(h, t) TXD(t - h)
17074 +#define NRXDACTIVE(h, t) RXD(t - h)
17076 +/* macros to convert between byte offsets and indexes */
17077 +#define B2I(bytes, type) ((bytes) / sizeof(type))
17078 +#define I2B(index, type) ((index) * sizeof(type))
17080 +#define PCI32ADDR_HIGH 0xc0000000 /* address[31:30] */
17081 +#define PCI32ADDR_HIGH_SHIFT 30
17085 +static bool dma_isaddrext(dma_info_t *di);
17086 +static bool dma_alloc(dma_info_t *di, uint direction);
17088 +static bool dma32_alloc(dma_info_t *di, uint direction);
17089 +static void dma32_txreset(dma_info_t *di);
17090 +static void dma32_rxreset(dma_info_t *di);
17091 +static bool dma32_txsuspendedidle(dma_info_t *di);
17092 +static int dma32_txfast(dma_info_t *di, void *p0, uint32 coreflags);
17093 +static void* dma32_getnexttxp(dma_info_t *di, bool forceall);
17094 +static void* dma32_getnextrxp(dma_info_t *di, bool forceall);
17095 +static void dma32_txrotate(di_t *di);
17097 +/* prototype or stubs */
17099 +static bool dma64_alloc(dma_info_t *di, uint direction);
17100 +static void dma64_txreset(dma_info_t *di);
17101 +static void dma64_rxreset(dma_info_t *di);
17102 +static bool dma64_txsuspendedidle(dma_info_t *di);
17103 +static int dma64_txfast(dma_info_t *di, void *p0, uint32 coreflags);
17104 +static void* dma64_getnexttxp(dma_info_t *di, bool forceall);
17105 +static void* dma64_getnextrxp(dma_info_t *di, bool forceall);
17106 +static void dma64_txrotate(di_t *di);
17108 +static bool dma64_alloc(dma_info_t *di, uint direction) { return TRUE; }
17109 +static void dma64_txreset(dma_info_t *di) {}
17110 +static void dma64_rxreset(dma_info_t *di) {}
17111 +static bool dma64_txsuspendedidle(dma_info_t *di) { return TRUE;}
17112 +static int dma64_txfast(dma_info_t *di, void *p0, uint32 coreflags) { return 0; }
17113 +static void* dma64_getnexttxp(dma_info_t *di, bool forceall) { return NULL; }
17114 +static void* dma64_getnextrxp(dma_info_t *di, bool forceall) { return NULL; }
17115 +static void dma64_txrotate(di_t *di) { return; }
17118 +/* old dmaregs struct for compatibility */
17119 +typedef volatile struct {
17120 + /* transmit channel */
17121 + uint32 xmtcontrol; /* enable, et al */
17122 + uint32 xmtaddr; /* descriptor ring base address (4K aligned) */
17123 + uint32 xmtptr; /* last descriptor posted to chip */
17124 + uint32 xmtstatus; /* current active descriptor, et al */
17126 + /* receive channel */
17127 + uint32 rcvcontrol; /* enable, et al */
17128 + uint32 rcvaddr; /* descriptor ring base address (4K aligned) */
17129 + uint32 rcvptr; /* last descriptor posted to chip */
17130 + uint32 rcvstatus; /* current active descriptor, et al */
17138 +static compat_data *ugly_hack = NULL;
17141 +dma_attold(void *drv, void *osh, char *name, dmaregs_t *regs, uint ntxd, uint nrxd,
17142 + uint rxbufsize, uint nrxpost, uint rxoffset, uint ddoffset, uint dataoffset, uint *msg_level)
17144 + dma32regs_t *dtx = regs;
17145 + dma32regs_t *drx = dtx + 1;
17147 + ugly_hack = kmalloc(sizeof(ugly_hack), GFP_KERNEL);
17148 + ugly_hack->ddoffset = ddoffset;
17149 + ugly_hack->dataoffset = dataoffset;
17150 + dma_attach((osl_t *) osh, name, NULL, dtx, drx, ntxd, nrxd, rxbufsize, nrxpost, rxoffset, msg_level);
17151 + ugly_hack = NULL;
17156 +dma_attach(osl_t *osh, char *name, sb_t *sbh, void *dmaregstx, void *dmaregsrx,
17157 + uint ntxd, uint nrxd, uint rxbufsize, uint nrxpost, uint rxoffset, uint *msg_level)
17162 + /* allocate private info structure */
17163 + if ((di = MALLOC(osh, sizeof (dma_info_t))) == NULL) {
17166 + bzero((char*)di, sizeof (dma_info_t));
17168 + di->msg_level = msg_level ? msg_level : &dma_msg_level;
17171 + di->dma64 = ((sb_coreflagshi(sbh, 0, 0) & SBTMH_DMA64) == SBTMH_DMA64);
17175 + DMA_ERROR(("dma_attach: driver doesn't have the capability to support 64 bits DMA\n"));
17180 + /* check arguments */
17181 + ASSERT(ISPOWEROF2(ntxd));
17182 + ASSERT(ISPOWEROF2(nrxd));
17184 + ASSERT(dmaregsrx == NULL);
17186 + ASSERT(dmaregstx == NULL);
17189 + /* init dma reg pointer */
17191 + ASSERT(ntxd <= D64MAXDD);
17192 + ASSERT(nrxd <= D64MAXDD);
17193 + di->d64txregs = (dma64regs_t *)dmaregstx;
17194 + di->d64rxregs = (dma64regs_t *)dmaregsrx;
17196 + di->dma64align = D64RINGALIGN;
17197 + if ((ntxd < D64MAXDD / 2) && (nrxd < D64MAXDD / 2)) {
17198 + /* for smaller dd table, HW relax the alignment requirement */
17199 + di->dma64align = D64RINGALIGN / 2;
17202 + ASSERT(ntxd <= D32MAXDD);
17203 + ASSERT(nrxd <= D32MAXDD);
17204 + di->d32txregs = (dma32regs_t *)dmaregstx;
17205 + di->d32rxregs = (dma32regs_t *)dmaregsrx;
17209 + /* make a private copy of our callers name */
17210 + strncpy(di->name, name, MAXNAMEL);
17211 + di->name[MAXNAMEL-1] = '\0';
17216 + /* save tunables */
17219 + di->rxbufsize = rxbufsize;
17220 + di->nrxpost = nrxpost;
17221 + di->rxoffset = rxoffset;
17224 + * figure out the DMA physical address offset for dd and data
17225 + * for old chips w/o sb, use zero
17226 + * for new chips w sb,
17227 + * PCI/PCIE: they map silicon backplace address to zero based memory, need offset
17228 + * Other bus: use zero
17229 + * SB_BUS BIGENDIAN kludge: use sdram swapped region for data buffer, not descriptor
17231 + di->ddoffsetlow = 0;
17232 + di->dataoffsetlow = 0;
17233 + if (ugly_hack != NULL) {
17234 + di->ddoffsetlow = ugly_hack->ddoffset;
17235 + di->dataoffsetlow = ugly_hack->dataoffset;
17236 + di->ddoffsethigh = 0;
17237 + di->dataoffsethigh = 0;
17238 + } else if (sbh != NULL) {
17239 + if (sbh->bustype == PCI_BUS) { /* for pci bus, add offset */
17240 + if ((sbh->buscoretype == SB_PCIE) && di->dma64){
17241 + di->ddoffsetlow = 0;
17242 + di->ddoffsethigh = SB_PCIE_DMA_H32;
17244 + di->ddoffsetlow = SB_PCI_DMA;
17245 + di->ddoffsethigh = 0;
17247 + di->dataoffsetlow = di->ddoffsetlow;
17248 + di->dataoffsethigh = di->ddoffsethigh;
17250 +#if defined(__mips__) && defined(IL_BIGENDIAN)
17251 + /* use sdram swapped region for data buffers but not dma descriptors */
17252 + di->dataoffsetlow = di->dataoffsetlow + SB_SDRAM_SWAPPED;
17256 + di->addrext = ((ugly_hack == NULL) ? dma_isaddrext(di) : 0);
17258 + DMA_TRACE(("%s: dma_attach: osh %p ntxd %d nrxd %d rxbufsize %d nrxpost %d rxoffset %d ddoffset 0x%x dataoffset 0x%x\n",
17259 + name, osh, ntxd, nrxd, rxbufsize, nrxpost, rxoffset, di->ddoffsetlow, di->dataoffsetlow));
17261 + /* allocate tx packet pointer vector */
17263 + size = ntxd * sizeof (void*);
17264 + if ((di->txp = MALLOC(osh, size)) == NULL) {
17265 + DMA_ERROR(("%s: dma_attach: out of tx memory, malloced %d bytes\n", di->name, MALLOCED(osh)));
17268 + bzero((char*)di->txp, size);
17271 + /* allocate rx packet pointer vector */
17273 + size = nrxd * sizeof (void*);
17274 + if ((di->rxp = MALLOC(osh, size)) == NULL) {
17275 + DMA_ERROR(("%s: dma_attach: out of rx memory, malloced %d bytes\n", di->name, MALLOCED(osh)));
17278 + bzero((char*)di->rxp, size);
17281 + /* allocate transmit descriptor ring, only need ntxd descriptors but it must be aligned */
17283 + if (!dma_alloc(di, DMA_TX))
17287 + /* allocate receive descriptor ring, only need nrxd descriptors but it must be aligned */
17289 + if (!dma_alloc(di, DMA_RX))
17293 + if ((di->ddoffsetlow == SB_PCI_DMA) && (di->txdpa > SB_PCI_DMA_SZ) && !di->addrext) {
17294 + DMA_ERROR(("%s: dma_attach: txdpa 0x%lx: addrext not supported\n", di->name, di->txdpa));
17297 + if ((di->ddoffsetlow == SB_PCI_DMA) && (di->rxdpa > SB_PCI_DMA_SZ) && !di->addrext) {
17298 + DMA_ERROR(("%s: dma_attach: rxdpa 0x%lx: addrext not supported\n", di->name, di->rxdpa));
17302 + return ((void*)di);
17305 + dma_detach((void*)di);
17310 +dma_alloc(dma_info_t *di, uint direction)
17312 + if (DMA64_ENAB(di)) {
17313 + return dma64_alloc(di, direction);
17315 + return dma32_alloc(di, direction);
17319 +/* may be called with core in reset */
17321 +dma_detach(dma_info_t *di)
17326 + DMA_TRACE(("%s: dma_detach\n", di->name));
17328 + /* shouldn't be here if descriptors are unreclaimed */
17329 + ASSERT(di->txin == di->txout);
17330 + ASSERT(di->rxin == di->rxout);
17332 + /* free dma descriptor rings */
17334 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->txd32 - di->txdalign), di->txdalloc, (di->txdpa - di->txdalign));
17336 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->rxd32 - di->rxdalign), di->rxdalloc, (di->rxdpa - di->rxdalign));
17338 + /* free packet pointer vectors */
17340 + MFREE(di->osh, (void*)di->txp, (di->ntxd * sizeof (void*)));
17342 + MFREE(di->osh, (void*)di->rxp, (di->nrxd * sizeof (void*)));
17344 + /* free our private info structure */
17345 + MFREE(di->osh, (void*)di, sizeof (dma_info_t));
17348 +/* return TRUE if this dma engine supports DmaExtendedAddrChanges, otherwise FALSE */
17350 +dma_isaddrext(dma_info_t *di)
17354 + if (DMA64_ENAB(di)) {
17355 + OR_REG(&di->d64txregs->control, D64_XC_AE);
17356 + w = R_REG(&di->d32txregs->control);
17357 + AND_REG(&di->d32txregs->control, ~D64_XC_AE);
17358 + return ((w & XC_AE) == D64_XC_AE);
17360 + OR_REG(&di->d32txregs->control, XC_AE);
17361 + w = R_REG(&di->d32txregs->control);
17362 + AND_REG(&di->d32txregs->control, ~XC_AE);
17363 + return ((w & XC_AE) == XC_AE);
17368 +dma_txreset(dma_info_t *di)
17370 + DMA_TRACE(("%s: dma_txreset\n", di->name));
17372 + if (DMA64_ENAB(di))
17373 + dma64_txreset(di);
17375 + dma32_txreset(di);
17379 +dma_rxreset(dma_info_t *di)
17381 + DMA_TRACE(("%s: dma_rxreset\n", di->name));
17383 + if (DMA64_ENAB(di))
17384 + dma64_rxreset(di);
17386 + dma32_rxreset(di);
17389 +/* initialize descriptor table base address */
17391 +dma_ddtable_init(dma_info_t *di, uint direction, ulong pa)
17393 + if (DMA64_ENAB(di)) {
17394 + if (direction == DMA_TX) {
17395 + W_REG(&di->d64txregs->addrlow, pa + di->ddoffsetlow);
17396 + W_REG(&di->d64txregs->addrhigh, di->ddoffsethigh);
17398 + W_REG(&di->d64rxregs->addrlow, pa + di->ddoffsetlow);
17399 + W_REG(&di->d64rxregs->addrhigh, di->ddoffsethigh);
17402 + uint32 offset = di->ddoffsetlow;
17403 + if ((offset != SB_PCI_DMA) || !(pa & PCI32ADDR_HIGH)) {
17404 + if (direction == DMA_TX)
17405 + W_REG(&di->d32txregs->addr, (pa + offset));
17407 + W_REG(&di->d32rxregs->addr, (pa + offset));
17409 + /* dma32 address extension */
17411 + ASSERT(di->addrext);
17412 + ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT;
17414 + if (direction == DMA_TX) {
17415 + W_REG(&di->d32txregs->addr, ((pa & ~PCI32ADDR_HIGH) + offset));
17416 + SET_REG(&di->d32txregs->control, XC_AE, (ae << XC_AE_SHIFT));
17418 + W_REG(&di->d32rxregs->addr, ((pa & ~PCI32ADDR_HIGH) + offset));
17419 + SET_REG(&di->d32rxregs->control, RC_AE, (ae << RC_AE_SHIFT));
17425 +/* init the tx or rx descriptor */
17426 +static INLINE void
17427 +dma32_dd_upd(dma_info_t *di, dma32dd_t *ddring, ulong pa, uint outidx, uint32 *ctrl)
17429 + uint offset = di->dataoffsetlow;
17431 + if ((offset != SB_PCI_DMA) || !(pa & PCI32ADDR_HIGH)) {
17432 + W_SM(&ddring[outidx].addr, BUS_SWAP32(pa + offset));
17433 + W_SM(&ddring[outidx].ctrl, BUS_SWAP32(*ctrl));
17435 + /* address extension */
17437 + ASSERT(di->addrext);
17438 + ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT;
17440 + *ctrl |= (ae << CTRL_AE_SHIFT);
17441 + W_SM(&ddring[outidx].addr, BUS_SWAP32((pa & ~PCI32ADDR_HIGH) + offset));
17442 + W_SM(&ddring[outidx].ctrl, BUS_SWAP32(*ctrl));
17446 +/* init the tx or rx descriptor */
17447 +static INLINE void
17448 +dma64_dd_upd(dma_info_t *di, dma64dd_t *ddring, ulong pa, uint outidx, uint32 *flags, uint32 bufcount)
17450 + uint32 bufaddr_low = pa + di->dataoffsetlow;
17451 + uint32 bufaddr_high = 0 + di->dataoffsethigh;
17453 + uint32 ctrl2 = bufcount & D64_CTRL2_BC_MASK;
17455 + W_SM(&ddring[outidx].addrlow, BUS_SWAP32(bufaddr_low));
17456 + W_SM(&ddring[outidx].addrhigh, BUS_SWAP32(bufaddr_high));
17457 + W_SM(&ddring[outidx].ctrl1, BUS_SWAP32(*flags));
17458 + W_SM(&ddring[outidx].ctrl2, BUS_SWAP32(ctrl2));
17462 +dma_txinit(dma_info_t *di)
17464 + DMA_TRACE(("%s: dma_txinit\n", di->name));
17466 + di->txin = di->txout = 0;
17467 + di->txavail = di->ntxd - 1;
17469 + /* clear tx descriptor ring */
17470 + if (DMA64_ENAB(di)) {
17471 + BZERO_SM((void*)di->txd64, (di->ntxd * sizeof (dma64dd_t)));
17472 + W_REG(&di->d64txregs->control, XC_XE);
17473 + dma_ddtable_init(di, DMA_TX, di->txdpa);
17475 + BZERO_SM((void*)di->txd32, (di->ntxd * sizeof (dma32dd_t)));
17476 + W_REG(&di->d32txregs->control, XC_XE);
17477 + dma_ddtable_init(di, DMA_TX, di->txdpa);
17482 +dma_txenabled(dma_info_t *di)
17486 + /* If the chip is dead, it is not enabled :-) */
17487 + if (DMA64_ENAB(di)) {
17488 + xc = R_REG(&di->d64txregs->control);
17489 + return ((xc != 0xffffffff) && (xc & D64_XC_XE));
17491 + xc = R_REG(&di->d32txregs->control);
17492 + return ((xc != 0xffffffff) && (xc & XC_XE));
17497 +dma_txsuspend(dma_info_t *di)
17499 + DMA_TRACE(("%s: dma_txsuspend\n", di->name));
17500 + if (DMA64_ENAB(di))
17501 + OR_REG(&di->d64txregs->control, D64_XC_SE);
17503 + OR_REG(&di->d32txregs->control, XC_SE);
17507 +dma_txresume(dma_info_t *di)
17509 + DMA_TRACE(("%s: dma_txresume\n", di->name));
17510 + if (DMA64_ENAB(di))
17511 + AND_REG(&di->d64txregs->control, ~D64_XC_SE);
17513 + AND_REG(&di->d32txregs->control, ~XC_SE);
17517 +dma_txsuspendedidle(dma_info_t *di)
17519 + if (DMA64_ENAB(di))
17520 + return dma64_txsuspendedidle(di);
17522 + return dma32_txsuspendedidle(di);
17526 +dma_txsuspended(dma_info_t *di)
17528 + if (DMA64_ENAB(di))
17529 + return ((R_REG(&di->d64txregs->control) & D64_XC_SE) == D64_XC_SE);
17531 + return ((R_REG(&di->d32txregs->control) & XC_SE) == XC_SE);
17535 +dma_txstopped(dma_info_t *di)
17537 + if (DMA64_ENAB(di))
17538 + return ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == D64_XS0_XS_STOPPED);
17540 + return ((R_REG(&di->d32txregs->status) & XS_XS_MASK) == XS_XS_STOPPED);
17544 +dma_rxstopped(dma_info_t *di)
17546 + if (DMA64_ENAB(di))
17547 + return ((R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK) == D64_RS0_RS_STOPPED);
17549 + return ((R_REG(&di->d32rxregs->status) & RS_RS_MASK) == RS_RS_STOPPED);
17553 +dma_fifoloopbackenable(dma_info_t *di)
17555 + DMA_TRACE(("%s: dma_fifoloopbackenable\n", di->name));
17556 + if (DMA64_ENAB(di))
17557 + OR_REG(&di->d64txregs->control, D64_XC_LE);
17559 + OR_REG(&di->d32txregs->control, XC_LE);
17563 +dma_rxinit(dma_info_t *di)
17565 + DMA_TRACE(("%s: dma_rxinit\n", di->name));
17567 + di->rxin = di->rxout = 0;
17569 + /* clear rx descriptor ring */
17570 + if (DMA64_ENAB(di)) {
17571 + BZERO_SM((void*)di->rxd64, (di->nrxd * sizeof (dma64dd_t)));
17572 + dma_rxenable(di);
17573 + dma_ddtable_init(di, DMA_RX, di->rxdpa);
17575 + BZERO_SM((void*)di->rxd32, (di->nrxd * sizeof (dma32dd_t)));
17576 + dma_rxenable(di);
17577 + dma_ddtable_init(di, DMA_RX, di->rxdpa);
17582 +dma_rxenable(dma_info_t *di)
17584 + DMA_TRACE(("%s: dma_rxenable\n", di->name));
17585 + if (DMA64_ENAB(di))
17586 + W_REG(&di->d64rxregs->control, ((di->rxoffset << D64_RC_RO_SHIFT) | D64_RC_RE));
17588 + W_REG(&di->d32rxregs->control, ((di->rxoffset << RC_RO_SHIFT) | RC_RE));
17592 +dma_rxenabled(dma_info_t *di)
17596 + if (DMA64_ENAB(di)) {
17597 + rc = R_REG(&di->d64rxregs->control);
17598 + return ((rc != 0xffffffff) && (rc & D64_RC_RE));
17600 + rc = R_REG(&di->d32rxregs->control);
17601 + return ((rc != 0xffffffff) && (rc & RC_RE));
17606 +/* !! tx entry routine */
17608 +dma_txfast(dma_info_t *di, void *p0, uint32 coreflags)
17610 + if (DMA64_ENAB(di)) {
17611 + return dma64_txfast(di, p0, coreflags);
17613 + return dma32_txfast(di, p0, coreflags);
17617 +/* !! rx entry routine, returns a pointer to the next frame received, or NULL if there are no more */
17619 +dma_rx(dma_info_t *di)
17625 + while ((p = dma_getnextrxp(di, FALSE))) {
17626 + /* skip giant packets which span multiple rx descriptors */
17627 + if (skiplen > 0) {
17628 + skiplen -= di->rxbufsize;
17631 + PKTFREE(di->osh, p, FALSE);
17635 + len = ltoh16(*(uint16*)(PKTDATA(di->osh, p)));
17636 + DMA_TRACE(("%s: dma_rx len %d\n", di->name, len));
17638 + /* bad frame length check */
17639 + if (len > (di->rxbufsize - di->rxoffset)) {
17640 + DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len));
17642 + skiplen = len - (di->rxbufsize - di->rxoffset);
17643 + PKTFREE(di->osh, p, FALSE);
17644 + di->hnddma.rxgiants++;
17648 + /* set actual length */
17649 + PKTSETLEN(di->osh, p, (di->rxoffset + len));
17657 +/* post receive buffers */
17659 +dma_rxfill(dma_info_t *di)
17662 + uint rxin, rxout;
17670 + * Determine how many receive buffers we're lacking
17671 + * from the full complement, allocate, initialize,
17672 + * and post them, then update the chip rx lastdscr.
17676 + rxout = di->rxout;
17677 + rxbufsize = di->rxbufsize;
17679 + n = di->nrxpost - NRXDACTIVE(rxin, rxout);
17681 + DMA_TRACE(("%s: dma_rxfill: post %d\n", di->name, n));
17683 + for (i = 0; i < n; i++) {
17684 + if ((p = PKTGET(di->osh, rxbufsize, FALSE)) == NULL) {
17685 + DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", di->name));
17686 + di->hnddma.rxnobuf++;
17690 + /* Do a cached write instead of uncached write since DMA_MAP
17691 + * will flush the cache. */
17692 + *(uint32*)(PKTDATA(di->osh, p)) = 0;
17694 + pa = (uint32) DMA_MAP(di->osh, PKTDATA(di->osh, p), rxbufsize, DMA_RX, p);
17695 + ASSERT(ISALIGNED(pa, 4));
17697 + /* save the free packet pointer */
17698 + ASSERT(di->rxp[rxout] == NULL);
17699 + di->rxp[rxout] = p;
17701 + if (DMA64_ENAB(di)) {
17702 + /* prep the descriptor control value */
17703 + if (rxout == (di->nrxd - 1))
17706 + dma64_dd_upd(di, di->rxd64, pa, rxout, &ctrl, rxbufsize);
17708 + /* prep the descriptor control value */
17709 + ctrl = rxbufsize;
17710 + if (rxout == (di->nrxd - 1))
17711 + ctrl |= CTRL_EOT;
17712 + dma32_dd_upd(di, di->rxd32, pa, rxout, &ctrl);
17715 + rxout = NEXTRXD(rxout);
17718 + di->rxout = rxout;
17720 + /* update the chip lastdscr pointer */
17721 + if (DMA64_ENAB(di)) {
17722 + W_REG(&di->d64rxregs->ptr, I2B(rxout, dma64dd_t));
17724 + W_REG(&di->d32rxregs->ptr, I2B(rxout, dma32dd_t));
17729 +dma_txreclaim(dma_info_t *di, bool forceall)
17733 + DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, forceall ? "all" : ""));
17735 + while ((p = dma_getnexttxp(di, forceall)))
17736 + PKTFREE(di->osh, p, TRUE);
17740 + * Reclaim next completed txd (txds if using chained buffers) and
17741 + * return associated packet.
17742 + * If 'force' is true, reclaim txd(s) and return associated packet
17743 + * regardless of the value of the hardware "curr" pointer.
17746 +dma_getnexttxp(dma_info_t *di, bool forceall)
17748 + if (DMA64_ENAB(di)) {
17749 + return dma64_getnexttxp(di, forceall);
17751 + return dma32_getnexttxp(di, forceall);
17755 +/* like getnexttxp but no reclaim */
17757 +dma_peeknexttxp(dma_info_t *di)
17761 + if (DMA64_ENAB(di)) {
17762 + end = B2I(R_REG(&di->d64txregs->status0) & D64_XS0_CD_MASK, dma64dd_t);
17764 + end = B2I(R_REG(&di->d32txregs->status) & XS_CD_MASK, dma32dd_t);
17767 + for (i = di->txin; i != end; i = NEXTTXD(i))
17769 + return (di->txp[i]);
17775 + * Rotate all active tx dma ring entries "forward" by (ActiveDescriptor - txin).
17778 +dma_txrotate(di_t *di)
17780 + if (DMA64_ENAB(di)) {
17781 + dma64_txrotate(di);
17783 + dma32_txrotate(di);
17788 +dma_rxreclaim(dma_info_t *di)
17792 + DMA_TRACE(("%s: dma_rxreclaim\n", di->name));
17794 + while ((p = dma_getnextrxp(di, TRUE)))
17795 + PKTFREE(di->osh, p, FALSE);
17799 +dma_getnextrxp(dma_info_t *di, bool forceall)
17801 + if (DMA64_ENAB(di)) {
17802 + return dma64_getnextrxp(di, forceall);
17804 + return dma32_getnextrxp(di, forceall);
17809 +dma_getvar(dma_info_t *di, char *name)
17811 + if (!strcmp(name, "&txavail"))
17812 + return ((uintptr) &di->txavail);
17820 +dma_txblock(dma_info_t *di)
17826 +dma_txunblock(dma_info_t *di)
17828 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
17832 +dma_txactive(dma_info_t *di)
17834 + return (NTXDACTIVE(di->txin, di->txout));
17838 +dma_rxpiomode(dma32regs_t *regs)
17840 + W_REG(®s->control, RC_FM);
17844 +dma_txpioloopback(dma32regs_t *regs)
17846 + OR_REG(®s->control, XC_LE);
17852 +/*** 32 bits DMA non-inline functions ***/
17854 +dma32_alloc(dma_info_t *di, uint direction)
17860 + ddlen = sizeof (dma32dd_t);
17862 + size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen);
17864 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, D32RINGALIGN))
17865 + size += D32RINGALIGN;
17868 + if (direction == DMA_TX) {
17869 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->txdpa)) == NULL) {
17870 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name));
17874 + di->txd32 = (dma32dd_t*) ROUNDUP((uintptr)va, D32RINGALIGN);
17875 + di->txdalign = (uint)((int8*)di->txd32 - (int8*)va);
17876 + di->txdpa += di->txdalign;
17877 + di->txdalloc = size;
17878 + ASSERT(ISALIGNED((uintptr)di->txd32, D32RINGALIGN));
17880 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->rxdpa)) == NULL) {
17881 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name));
17884 + di->rxd32 = (dma32dd_t*) ROUNDUP((uintptr)va, D32RINGALIGN);
17885 + di->rxdalign = (uint)((int8*)di->rxd32 - (int8*)va);
17886 + di->rxdpa += di->rxdalign;
17887 + di->rxdalloc = size;
17888 + ASSERT(ISALIGNED((uintptr)di->rxd32, D32RINGALIGN));
17895 +dma32_txreset(dma_info_t *di)
17899 + /* suspend tx DMA first */
17900 + W_REG(&di->d32txregs->control, XC_SE);
17901 + SPINWAIT((status = (R_REG(&di->d32txregs->status) & XS_XS_MASK)) != XS_XS_DISABLED &&
17902 + status != XS_XS_IDLE &&
17903 + status != XS_XS_STOPPED,
17906 + W_REG(&di->d32txregs->control, 0);
17907 + SPINWAIT((status = (R_REG(&di->d32txregs->status) & XS_XS_MASK)) != XS_XS_DISABLED,
17910 + if (status != XS_XS_DISABLED) {
17911 + DMA_ERROR(("%s: dma_txreset: dma cannot be stopped\n", di->name));
17914 + /* wait for the last transaction to complete */
17919 +dma32_rxreset(dma_info_t *di)
17923 + W_REG(&di->d32rxregs->control, 0);
17924 + SPINWAIT((status = (R_REG(&di->d32rxregs->status) & RS_RS_MASK)) != RS_RS_DISABLED,
17927 + if (status != RS_RS_DISABLED) {
17928 + DMA_ERROR(("%s: dma_rxreset: dma cannot be stopped\n", di->name));
17933 +dma32_txsuspendedidle(dma_info_t *di)
17935 + if (!(R_REG(&di->d32txregs->control) & XC_SE))
17938 + if ((R_REG(&di->d32txregs->status) & XS_XS_MASK) != XS_XS_IDLE)
17942 + return ((R_REG(&di->d32txregs->status) & XS_XS_MASK) == XS_XS_IDLE);
17946 + * supports full 32bit dma engine buffer addressing so
17947 + * dma buffers can cross 4 Kbyte page boundaries.
17950 +dma32_txfast(dma_info_t *di, void *p0, uint32 coreflags)
17959 + DMA_TRACE(("%s: dma_txfast\n", di->name));
17961 + txout = di->txout;
17965 + * Walk the chain of packet buffers
17966 + * allocating and initializing transmit descriptor entries.
17968 + for (p = p0; p; p = next) {
17969 + data = PKTDATA(di->osh, p);
17970 + len = PKTLEN(di->osh, p);
17971 + next = PKTNEXT(di->osh, p);
17973 + /* return nonzero if out of tx descriptors */
17974 + if (NEXTTXD(txout) == di->txin)
17980 + /* get physical address of buffer start */
17981 + pa = (uint32) DMA_MAP(di->osh, data, len, DMA_TX, p);
17983 + /* build the descriptor control value */
17984 + ctrl = len & CTRL_BC_MASK;
17986 + ctrl |= coreflags;
17989 + ctrl |= CTRL_SOF;
17990 + if (next == NULL)
17991 + ctrl |= (CTRL_IOC | CTRL_EOF);
17992 + if (txout == (di->ntxd - 1))
17993 + ctrl |= CTRL_EOT;
17995 + if (DMA64_ENAB(di)) {
17996 + dma64_dd_upd(di, di->txd64, pa, txout, &ctrl, len);
17998 + dma32_dd_upd(di, di->txd32, pa, txout, &ctrl);
18001 + ASSERT(di->txp[txout] == NULL);
18003 + txout = NEXTTXD(txout);
18006 + /* if last txd eof not set, fix it */
18007 + if (!(ctrl & CTRL_EOF))
18008 + W_SM(&di->txd32[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF));
18010 + /* save the packet */
18011 + di->txp[PREVTXD(txout)] = p0;
18013 + /* bump the tx descriptor index */
18014 + di->txout = txout;
18016 + /* kick the chip */
18017 + if (DMA64_ENAB(di)) {
18018 + W_REG(&di->d64txregs->ptr, I2B(txout, dma64dd_t));
18020 + W_REG(&di->d32txregs->ptr, I2B(txout, dma32dd_t));
18023 + /* tx flow control */
18024 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18029 + DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name));
18030 + PKTFREE(di->osh, p0, TRUE);
18032 + di->hnddma.txnobuf++;
18037 +dma32_getnexttxp(dma_info_t *di, bool forceall)
18039 + uint start, end, i;
18042 + DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, forceall ? "all" : ""));
18046 + start = di->txin;
18050 + end = B2I(R_REG(&di->d32txregs->status) & XS_CD_MASK, dma32dd_t);
18052 + if ((start == 0) && (end > di->txout))
18055 + for (i = start; i != end && !txp; i = NEXTTXD(i)) {
18056 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->txd32[i].addr)) - di->dataoffsetlow),
18057 + (BUS_SWAP32(R_SM(&di->txd32[i].ctrl)) & CTRL_BC_MASK), DMA_TX, di->txp[i]);
18059 + W_SM(&di->txd32[i].addr, 0xdeadbeef);
18060 + txp = di->txp[i];
18061 + di->txp[i] = NULL;
18066 + /* tx flow control */
18067 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18073 + DMA_ERROR(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n",
18074 + start, end, di->txout, forceall));
18080 +dma32_getnextrxp(dma_info_t *di, bool forceall)
18085 + /* if forcing, dma engine must be disabled */
18086 + ASSERT(!forceall || !dma_rxenabled(di));
18090 + /* return if no packets posted */
18091 + if (i == di->rxout)
18094 + /* ignore curr if forceall */
18095 + if (!forceall && (i == B2I(R_REG(&di->d32rxregs->status) & RS_CD_MASK, dma32dd_t)))
18098 + /* get the packet pointer that corresponds to the rx descriptor */
18099 + rxp = di->rxp[i];
18101 + di->rxp[i] = NULL;
18103 + /* clear this packet from the descriptor ring */
18104 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->rxd32[i].addr)) - di->dataoffsetlow),
18105 + di->rxbufsize, DMA_RX, rxp);
18106 + W_SM(&di->rxd32[i].addr, 0xdeadbeef);
18108 + di->rxin = NEXTRXD(i);
18114 +dma32_txrotate(di_t *di)
18121 + uint first, last;
18123 + ASSERT(dma_txsuspendedidle(di));
18125 + nactive = dma_txactive(di);
18126 + ad = B2I(((R_REG(&di->d32txregs->status) & XS_AD_MASK) >> XS_AD_SHIFT), dma32dd_t);
18127 + rot = TXD(ad - di->txin);
18129 + ASSERT(rot < di->ntxd);
18131 + /* full-ring case is a lot harder - don't worry about this */
18132 + if (rot >= (di->ntxd - nactive)) {
18133 + DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name));
18137 + first = di->txin;
18138 + last = PREVTXD(di->txout);
18140 + /* move entries starting at last and moving backwards to first */
18141 + for (old = last; old != PREVTXD(first); old = PREVTXD(old)) {
18142 + new = TXD(old + rot);
18145 + * Move the tx dma descriptor.
18146 + * EOT is set only in the last entry in the ring.
18148 + w = R_SM(&di->txd32[old].ctrl) & ~CTRL_EOT;
18149 + if (new == (di->ntxd - 1))
18151 + W_SM(&di->txd32[new].ctrl, w);
18152 + W_SM(&di->txd32[new].addr, R_SM(&di->txd32[old].addr));
18154 + /* zap the old tx dma descriptor address field */
18155 + W_SM(&di->txd32[old].addr, 0xdeadbeef);
18157 + /* move the corresponding txp[] entry */
18158 + ASSERT(di->txp[new] == NULL);
18159 + di->txp[new] = di->txp[old];
18160 + di->txp[old] = NULL;
18163 + /* update txin and txout */
18165 + di->txout = TXD(di->txout + rot);
18166 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18168 + /* kick the chip */
18169 + W_REG(&di->d32txregs->ptr, I2B(di->txout, dma32dd_t));
18172 +/*** 64 bits DMA non-inline functions ***/
18177 +dma64_alloc(dma_info_t *di, uint direction)
18181 + uint32 alignbytes;
18184 + ddlen = sizeof (dma64dd_t);
18186 + size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen);
18188 + alignbytes = di->dma64align;
18190 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, alignbytes))
18191 + size += alignbytes;
18194 + if (direction == DMA_TX) {
18195 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->txdpa)) == NULL) {
18196 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name));
18200 + di->txd64 = (dma64dd_t*) ROUNDUP((uintptr)va, alignbytes);
18201 + di->txdalign = (uint)((int8*)di->txd64 - (int8*)va);
18202 + di->txdpa += di->txdalign;
18203 + di->txdalloc = size;
18204 + ASSERT(ISALIGNED((uintptr)di->txd64, alignbytes));
18206 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->rxdpa)) == NULL) {
18207 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name));
18210 + di->rxd64 = (dma64dd_t*) ROUNDUP((uintptr)va, alignbytes);
18211 + di->rxdalign = (uint)((int8*)di->rxd64 - (int8*)va);
18212 + di->rxdpa += di->rxdalign;
18213 + di->rxdalloc = size;
18214 + ASSERT(ISALIGNED((uintptr)di->rxd64, alignbytes));
18221 +dma64_txreset(dma_info_t *di)
18225 + /* suspend tx DMA first */
18226 + W_REG(&di->d64txregs->control, D64_XC_SE);
18227 + SPINWAIT((status = (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED &&
18228 + status != D64_XS0_XS_IDLE &&
18229 + status != D64_XS0_XS_STOPPED,
18232 + W_REG(&di->d64txregs->control, 0);
18233 + SPINWAIT((status = (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED,
18236 + if (status != D64_XS0_XS_DISABLED) {
18237 + DMA_ERROR(("%s: dma_txreset: dma cannot be stopped\n", di->name));
18240 + /* wait for the last transaction to complete */
18245 +dma64_rxreset(dma_info_t *di)
18249 + W_REG(&di->d64rxregs->control, 0);
18250 + SPINWAIT((status = (R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK)) != D64_RS0_RS_DISABLED,
18253 + if (status != D64_RS0_RS_DISABLED) {
18254 + DMA_ERROR(("%s: dma_rxreset: dma cannot be stopped\n", di->name));
18259 +dma64_txsuspendedidle(dma_info_t *di)
18262 + if (!(R_REG(&di->d64txregs->control) & D64_XC_SE))
18265 + if ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == D64_XS0_XS_IDLE)
18272 + * supports full 32bit dma engine buffer addressing so
18273 + * dma buffers can cross 4 Kbyte page boundaries.
18276 +dma64_txfast(dma_info_t *di, void *p0, uint32 coreflags)
18285 + DMA_TRACE(("%s: dma_txfast\n", di->name));
18287 + txout = di->txout;
18291 + * Walk the chain of packet buffers
18292 + * allocating and initializing transmit descriptor entries.
18294 + for (p = p0; p; p = next) {
18295 + data = PKTDATA(di->osh, p);
18296 + len = PKTLEN(di->osh, p);
18297 + next = PKTNEXT(di->osh, p);
18299 + /* return nonzero if out of tx descriptors */
18300 + if (NEXTTXD(txout) == di->txin)
18306 + /* get physical address of buffer start */
18307 + pa = (uint32) DMA_MAP(di->osh, data, len, DMA_TX, p);
18309 + flags = coreflags;
18312 + flags |= D64_CTRL1_SOF;
18313 + if (next == NULL)
18314 + flags |= (D64_CTRL1_IOC | D64_CTRL1_EOF);
18315 + if (txout == (di->ntxd - 1))
18316 + flags |= D64_CTRL1_EOT;
18318 + dma64_dd_upd(di, di->txd64, pa, txout, &flags, len);
18320 + ASSERT(di->txp[txout] == NULL);
18322 + txout = NEXTTXD(txout);
18325 + /* if last txd eof not set, fix it */
18326 + if (!(flags & D64_CTRL1_EOF))
18327 + W_SM(&di->txd64[PREVTXD(txout)].ctrl1, BUS_SWAP32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF));
18329 + /* save the packet */
18330 + di->txp[PREVTXD(txout)] = p0;
18332 + /* bump the tx descriptor index */
18333 + di->txout = txout;
18335 + /* kick the chip */
18336 + W_REG(&di->d64txregs->ptr, I2B(txout, dma64dd_t));
18338 + /* tx flow control */
18339 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18344 + DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name));
18345 + PKTFREE(di->osh, p0, TRUE);
18347 + di->hnddma.txnobuf++;
18352 +dma64_getnexttxp(dma_info_t *di, bool forceall)
18354 + uint start, end, i;
18357 + DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, forceall ? "all" : ""));
18361 + start = di->txin;
18365 + end = B2I(R_REG(&di->d64txregs->status0) & D64_XS0_CD_MASK, dma64dd_t);
18367 + if ((start == 0) && (end > di->txout))
18370 + for (i = start; i != end && !txp; i = NEXTTXD(i)) {
18371 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->txd64[i].addrlow)) - di->dataoffsetlow),
18372 + (BUS_SWAP32(R_SM(&di->txd64[i].ctrl2)) & D64_CTRL2_BC_MASK), DMA_TX, di->txp[i]);
18374 + W_SM(&di->txd64[i].addrlow, 0xdeadbeef);
18375 + W_SM(&di->txd64[i].addrhigh, 0xdeadbeef);
18377 + txp = di->txp[i];
18378 + di->txp[i] = NULL;
18383 + /* tx flow control */
18384 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18390 + DMA_ERROR(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n",
18391 + start, end, di->txout, forceall));
18397 +dma64_getnextrxp(dma_info_t *di, bool forceall)
18402 + /* if forcing, dma engine must be disabled */
18403 + ASSERT(!forceall || !dma_rxenabled(di));
18407 + /* return if no packets posted */
18408 + if (i == di->rxout)
18411 + /* ignore curr if forceall */
18412 + if (!forceall && (i == B2I(R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK, dma64dd_t)))
18415 + /* get the packet pointer that corresponds to the rx descriptor */
18416 + rxp = di->rxp[i];
18418 + di->rxp[i] = NULL;
18420 + /* clear this packet from the descriptor ring */
18421 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->rxd64[i].addrlow)) - di->dataoffsetlow),
18422 + di->rxbufsize, DMA_RX, rxp);
18424 + W_SM(&di->rxd64[i].addrlow, 0xdeadbeef);
18425 + W_SM(&di->rxd64[i].addrhigh, 0xdeadbeef);
18427 + di->rxin = NEXTRXD(i);
18433 +dma64_txrotate(di_t *di)
18440 + uint first, last;
18442 + ASSERT(dma_txsuspendedidle(di));
18444 + nactive = dma_txactive(di);
18445 + ad = B2I((R_REG(&di->d64txregs->status1) & D64_XS1_AD_MASK), dma64dd_t);
18446 + rot = TXD(ad - di->txin);
18448 + ASSERT(rot < di->ntxd);
18450 + /* full-ring case is a lot harder - don't worry about this */
18451 + if (rot >= (di->ntxd - nactive)) {
18452 + DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name));
18456 + first = di->txin;
18457 + last = PREVTXD(di->txout);
18459 + /* move entries starting at last and moving backwards to first */
18460 + for (old = last; old != PREVTXD(first); old = PREVTXD(old)) {
18461 + new = TXD(old + rot);
18464 + * Move the tx dma descriptor.
18465 + * EOT is set only in the last entry in the ring.
18467 + w = R_SM(&di->txd64[old].ctrl1) & ~D64_CTRL1_EOT;
18468 + if (new == (di->ntxd - 1))
18469 + w |= D64_CTRL1_EOT;
18470 + W_SM(&di->txd64[new].ctrl1, w);
18472 + w = R_SM(&di->txd64[old].ctrl2);
18473 + W_SM(&di->txd64[new].ctrl2, w);
18475 + W_SM(&di->txd64[new].addrlow, R_SM(&di->txd64[old].addrlow));
18476 + W_SM(&di->txd64[new].addrhigh, R_SM(&di->txd64[old].addrhigh));
18478 + /* zap the old tx dma descriptor address field */
18479 + W_SM(&di->txd64[old].addrlow, 0xdeadbeef);
18480 + W_SM(&di->txd64[old].addrhigh, 0xdeadbeef);
18482 + /* move the corresponding txp[] entry */
18483 + ASSERT(di->txp[new] == NULL);
18484 + di->txp[new] = di->txp[old];
18485 + di->txp[old] = NULL;
18488 + /* update txin and txout */
18490 + di->txout = TXD(di->txout + rot);
18491 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18493 + /* kick the chip */
18494 + W_REG(&di->d64txregs->ptr, I2B(di->txout, dma64dd_t));
18499 diff -urN linux.old/drivers/net/hnd/linux_osl.c linux.dev/drivers/net/hnd/linux_osl.c
18500 --- linux.old/drivers/net/hnd/linux_osl.c 1970-01-01 01:00:00.000000000 +0100
18501 +++ linux.dev/drivers/net/hnd/linux_osl.c 2005-11-07 23:38:26.782893500 +0100
18504 + * Linux OS Independent Layer
18506 + * Copyright 2005, Broadcom Corporation
18507 + * All Rights Reserved.
18509 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
18510 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
18511 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
18512 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
18519 +#include <typedefs.h>
18520 +#include <bcmendian.h>
18521 +#include <linux/module.h>
18522 +#include <linuxver.h>
18524 +#include <bcmutils.h>
18525 +#include <linux/delay.h>
18527 +#include <asm/paccess.h>
18529 +#include <pcicfg.h>
18531 +#define PCI_CFG_RETRY 10
18533 +#define OS_HANDLE_MAGIC 0x1234abcd
18534 +#define BCM_MEM_FILENAME_LEN 24
18536 +typedef struct bcm_mem_link {
18537 + struct bcm_mem_link *prev;
18538 + struct bcm_mem_link *next;
18541 + char file[BCM_MEM_FILENAME_LEN];
18544 +struct os_handle {
18549 + bcm_mem_link_t *dbgmem_list;
18552 +static int16 linuxbcmerrormap[] = \
18554 + -EINVAL, /* BCME_ERROR */
18555 + -EINVAL, /* BCME_BADARG*/
18556 + -EINVAL, /* BCME_BADOPTION*/
18557 + -EINVAL, /* BCME_NOTUP */
18558 + -EINVAL, /* BCME_NOTDOWN */
18559 + -EINVAL, /* BCME_NOTAP */
18560 + -EINVAL, /* BCME_NOTSTA */
18561 + -EINVAL, /* BCME_BADKEYIDX */
18562 + -EINVAL, /* BCME_RADIOOFF */
18563 + -EINVAL, /* BCME_NOTBANDLOCKED */
18564 + -EINVAL, /* BCME_NOCLK */
18565 + -EINVAL, /* BCME_BADRATESET */
18566 + -EINVAL, /* BCME_BADBAND */
18567 + -E2BIG, /* BCME_BUFTOOSHORT */
18568 + -E2BIG, /* BCME_BUFTOOLONG */
18569 + -EBUSY, /* BCME_BUSY */
18570 + -EINVAL, /* BCME_NOTASSOCIATED */
18571 + -EINVAL, /* BCME_BADSSIDLEN */
18572 + -EINVAL, /* BCME_OUTOFRANGECHAN */
18573 + -EINVAL, /* BCME_BADCHAN */
18574 + -EFAULT, /* BCME_BADADDR */
18575 + -ENOMEM, /* BCME_NORESOURCE */
18576 + -EOPNOTSUPP, /* BCME_UNSUPPORTED */
18577 + -EMSGSIZE, /* BCME_BADLENGTH */
18578 + -EINVAL, /* BCME_NOTREADY */
18579 + -EPERM, /* BCME_NOTPERMITTED */
18580 + -ENOMEM, /* BCME_NOMEM */
18581 + -EINVAL, /* BCME_ASSOCIATED */
18582 + -ERANGE, /* BCME_RANGE */
18583 + -EINVAL /* BCME_NOTFOUND */
18586 +/* translate bcmerrors into linux errors*/
18588 +osl_error(int bcmerror)
18590 + int abs_bcmerror;
18591 + int array_size = ARRAYSIZE(linuxbcmerrormap);
18593 + abs_bcmerror = ABS(bcmerror);
18595 + if (bcmerror > 0)
18596 + abs_bcmerror = 0;
18598 + else if (abs_bcmerror >= array_size)
18599 + abs_bcmerror = BCME_ERROR;
18601 + return linuxbcmerrormap[abs_bcmerror];
18605 +osl_attach(void *pdev)
18609 + osh = kmalloc(sizeof(osl_t), GFP_ATOMIC);
18613 + * check the cases where
18614 + * 1.Error code Added to bcmerror table, but forgot to add it to the OS
18615 + * dependent error code
18616 + * 2. Error code is added to the bcmerror table, but forgot to add the
18617 + * corresponding errorstring(dummy call to bcmerrorstr)
18620 + ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1));
18622 + osh->magic = OS_HANDLE_MAGIC;
18623 + osh->malloced = 0;
18625 + osh->dbgmem_list = NULL;
18626 + osh->pdev = pdev;
18632 +osl_detach(osl_t *osh)
18634 + ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC));
18639 +osl_pktget(osl_t *osh, uint len, bool send)
18641 + struct sk_buff *skb;
18643 + if ((skb = dev_alloc_skb(len)) == NULL)
18646 + skb_put(skb, len);
18648 + /* ensure the cookie field is cleared */
18649 + PKTSETCOOKIE(skb, NULL);
18651 + return ((void*) skb);
18655 +osl_pktfree(void *p)
18657 + struct sk_buff *skb, *nskb;
18659 + skb = (struct sk_buff*) p;
18661 + /* perversion: we use skb->next to chain multi-skb packets */
18663 + nskb = skb->next;
18664 + skb->next = NULL;
18665 + if (skb->destructor) {
18666 + /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if destructor exists */
18667 + dev_kfree_skb_any(skb);
18669 + /* can free immediately (even in_irq()) if destructor does not exist */
18670 + dev_kfree_skb(skb);
18677 +osl_pci_read_config(osl_t *osh, uint offset, uint size)
18680 + uint retry=PCI_CFG_RETRY;
18682 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18684 + /* only 4byte access supported */
18685 + ASSERT(size == 4);
18688 + pci_read_config_dword(osh->pdev, offset, &val);
18689 + if (val != 0xffffffff)
18691 + } while (retry--);
18698 +osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val)
18700 + uint retry=PCI_CFG_RETRY;
18702 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18704 + /* only 4byte access supported */
18705 + ASSERT(size == 4);
18708 + pci_write_config_dword(osh->pdev, offset, val);
18709 + if (offset!=PCI_BAR0_WIN)
18711 + if (osl_pci_read_config(osh,offset,size) == val)
18713 + } while (retry--);
18717 +/* return bus # for the pci device pointed by osh->pdev */
18719 +osl_pci_bus(osl_t *osh)
18721 + ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev);
18723 + return ((struct pci_dev *)osh->pdev)->bus->number;
18726 +/* return slot # for the pci device pointed by osh->pdev */
18728 +osl_pci_slot(osl_t *osh)
18730 + ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev);
18732 + return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn);
18736 +osl_pcmcia_attr(osl_t *osh, uint offset, char *buf, int size, bool write)
18741 +osl_pcmcia_read_attr(osl_t *osh, uint offset, void *buf, int size)
18743 + osl_pcmcia_attr(osh, offset, (char *) buf, size, FALSE);
18747 +osl_pcmcia_write_attr(osl_t *osh, uint offset, void *buf, int size)
18749 + osl_pcmcia_attr(osh, offset, (char *) buf, size, TRUE);
18756 +osl_debug_malloc(osl_t *osh, uint size, int line, char* file)
18758 + bcm_mem_link_t *p;
18763 + if ((p = (bcm_mem_link_t*)osl_malloc(osh, sizeof(bcm_mem_link_t) + size)) == NULL)
18769 + basename = strrchr(file, '/');
18770 + /* skip the '/' */
18777 + strncpy(p->file, basename, BCM_MEM_FILENAME_LEN);
18778 + p->file[BCM_MEM_FILENAME_LEN - 1] = '\0';
18780 + /* link this block */
18782 + p->next = osh->dbgmem_list;
18784 + p->next->prev = p;
18785 + osh->dbgmem_list = p;
18791 +osl_debug_mfree(osl_t *osh, void *addr, uint size, int line, char* file)
18793 + bcm_mem_link_t *p = (bcm_mem_link_t *)((int8*)addr - sizeof(bcm_mem_link_t));
18795 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18797 + if (p->size == 0) {
18798 + printk("osl_debug_mfree: double free on addr 0x%x size %d at line %d file %s\n",
18799 + (uint)addr, size, line, file);
18804 + if (p->size != size) {
18805 + printk("osl_debug_mfree: dealloc size %d does not match alloc size %d on addr 0x%x at line %d file %s\n",
18806 + size, p->size, (uint)addr, line, file);
18807 + ASSERT(p->size == size);
18811 + /* unlink this block */
18813 + p->prev->next = p->next;
18815 + p->next->prev = p->prev;
18816 + if (osh->dbgmem_list == p)
18817 + osh->dbgmem_list = p->next;
18818 + p->next = p->prev = NULL;
18820 + osl_mfree(osh, p, size + sizeof(bcm_mem_link_t));
18824 +osl_debug_memdump(osl_t *osh, char *buf, uint sz)
18826 + bcm_mem_link_t *p;
18829 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18832 + buf += sprintf(buf, " Address\tSize\tFile:line\n");
18833 + for (p = osh->dbgmem_list; p && ((buf - obuf) < (sz - 128)); p = p->next)
18834 + buf += sprintf(buf, "0x%08x\t%5d\t%s:%d\n",
18835 + (int)p + sizeof(bcm_mem_link_t), p->size, p->file, p->line);
18840 +#endif /* BCMDBG_MEM */
18843 +osl_malloc(osl_t *osh, uint size)
18847 + /* only ASSERT if osh is defined */
18849 + ASSERT(osh->magic == OS_HANDLE_MAGIC);
18851 + if ((addr = kmalloc(size, GFP_ATOMIC)) == NULL) {
18857 + osh->malloced += size;
18863 +osl_mfree(osl_t *osh, void *addr, uint size)
18866 + ASSERT(osh->magic == OS_HANDLE_MAGIC);
18867 + osh->malloced -= size;
18873 +osl_malloced(osl_t *osh)
18875 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18876 + return (osh->malloced);
18879 +uint osl_malloc_failed(osl_t *osh)
18881 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18882 + return (osh->failed);
18886 +osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap)
18888 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18890 + return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap));
18894 +osl_dma_free_consistent(osl_t *osh, void *va, uint size, ulong pa)
18896 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18898 + pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
18902 +osl_dma_map(osl_t *osh, void *va, uint size, int direction)
18906 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18907 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
18908 + return (pci_map_single(osh->pdev, va, size, dir));
18912 +osl_dma_unmap(osl_t *osh, uint pa, uint size, int direction)
18916 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18917 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
18918 + pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
18921 +#if defined(BINOSL)
18923 +osl_assert(char *exp, char *file, int line)
18925 + char tempbuf[255];
18927 + sprintf(tempbuf, "assertion \"%s\" failed: file \"%s\", line %d\n", exp, file, line);
18930 +#endif /* BCMDBG || BINOSL */
18933 +osl_delay(uint usec)
18937 + while (usec > 0) {
18938 + d = MIN(usec, 1000);
18945 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
18950 +osl_printf(const char *format, ...)
18956 + /* sprintf into a local buffer because there *is* no "vprintk()".. */
18957 + va_start(args, format);
18958 + len = vsprintf(buf, format, args);
18961 + if (len > sizeof (buf)) {
18962 + printk("osl_printf: buffer overrun\n");
18966 + return (printk(buf));
18970 +osl_sprintf(char *buf, const char *format, ...)
18975 + va_start(args, format);
18976 + rc = vsprintf(buf, format, args);
18982 +osl_strcmp(const char *s1, const char *s2)
18984 + return (strcmp(s1, s2));
18988 +osl_strncmp(const char *s1, const char *s2, uint n)
18990 + return (strncmp(s1, s2, n));
18994 +osl_strlen(const char *s)
18996 + return (strlen(s));
19000 +osl_strcpy(char *d, const char *s)
19002 + return (strcpy(d, s));
19006 +osl_strncpy(char *d, const char *s, uint n)
19008 + return (strncpy(d, s, n));
19012 +bcopy(const void *src, void *dst, int len)
19014 + memcpy(dst, src, len);
19018 +bcmp(const void *b1, const void *b2, int len)
19020 + return (memcmp(b1, b2, len));
19024 +bzero(void *b, int len)
19026 + memset(b, '\0', len);
19030 +osl_readl(volatile uint32 *r)
19032 + return (readl(r));
19036 +osl_readw(volatile uint16 *r)
19038 + return (readw(r));
19042 +osl_readb(volatile uint8 *r)
19044 + return (readb(r));
19048 +osl_writel(uint32 v, volatile uint32 *r)
19054 +osl_writew(uint16 v, volatile uint16 *r)
19060 +osl_writeb(uint8 v, volatile uint8 *r)
19066 +osl_uncached(void *va)
19069 + return ((void*)KSEG1ADDR(va));
19071 + return ((void*)va);
19076 +osl_getcycles(void)
19081 + cycles = read_c0_count() * 2;
19082 +#elif defined(__i386__)
19091 +osl_reg_map(uint32 pa, uint size)
19093 + return (ioremap_nocache((unsigned long)pa, (unsigned long)size));
19097 +osl_reg_unmap(void *va)
19103 +osl_busprobe(uint32 *val, uint32 addr)
19106 + return get_dbe(*val, (uint32*)addr);
19108 + *val = readl(addr);
19114 +osl_pktdata(osl_t *osh, void *skb)
19116 + return (((struct sk_buff*)skb)->data);
19120 +osl_pktlen(osl_t *osh, void *skb)
19122 + return (((struct sk_buff*)skb)->len);
19126 +osl_pktheadroom(osl_t *osh, void *skb)
19128 + return (uint) skb_headroom((struct sk_buff *) skb);
19132 +osl_pkttailroom(osl_t *osh, void *skb)
19134 + return (uint) skb_tailroom((struct sk_buff *) skb);
19138 +osl_pktnext(osl_t *osh, void *skb)
19140 + return (((struct sk_buff*)skb)->next);
19144 +osl_pktsetnext(void *skb, void *x)
19146 + ((struct sk_buff*)skb)->next = (struct sk_buff*)x;
19150 +osl_pktsetlen(osl_t *osh, void *skb, uint len)
19152 + __skb_trim((struct sk_buff*)skb, len);
19156 +osl_pktpush(osl_t *osh, void *skb, int bytes)
19158 + return (skb_push((struct sk_buff*)skb, bytes));
19162 +osl_pktpull(osl_t *osh, void *skb, int bytes)
19164 + return (skb_pull((struct sk_buff*)skb, bytes));
19168 +osl_pktdup(osl_t *osh, void *skb)
19170 + return (skb_clone((struct sk_buff*)skb, GFP_ATOMIC));
19174 +osl_pktcookie(void *skb)
19176 + return ((void*)((struct sk_buff*)skb)->csum);
19180 +osl_pktsetcookie(void *skb, void *x)
19182 + ((struct sk_buff*)skb)->csum = (uint)x;
19186 +osl_pktlink(void *skb)
19188 + return (((struct sk_buff*)skb)->prev);
19192 +osl_pktsetlink(void *skb, void *x)
19194 + ((struct sk_buff*)skb)->prev = (struct sk_buff*)x;
19198 +osl_pktprio(void *skb)
19200 + return (((struct sk_buff*)skb)->priority);
19204 +osl_pktsetprio(void *skb, uint x)
19206 + ((struct sk_buff*)skb)->priority = x;
19210 +#endif /* BINOSL */
19211 diff -urN linux.old/drivers/net/hnd/sbutils.c linux.dev/drivers/net/hnd/sbutils.c
19212 --- linux.old/drivers/net/hnd/sbutils.c 1970-01-01 01:00:00.000000000 +0100
19213 +++ linux.dev/drivers/net/hnd/sbutils.c 2005-11-08 12:54:06.123274250 +0100
19216 + * Misc utility routines for accessing chip-specific features
19217 + * of the SiliconBackplane-based Broadcom chips.
19219 + * Copyright 2005, Broadcom Corporation
19220 + * All Rights Reserved.
19222 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
19223 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
19224 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
19225 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
19229 +#include <typedefs.h>
19231 +#include <sbutils.h>
19232 +#include <bcmutils.h>
19233 +#include <bcmdevs.h>
19234 +#include <sbconfig.h>
19235 +#include <sbchipc.h>
19236 +#include <sbpci.h>
19237 +#include <sbpcie.h>
19238 +#include <pcicfg.h>
19239 +#include <sbpcmcia.h>
19240 +#include <sbextif.h>
19241 +#include <bcmsrom.h>
19244 +#define SB_ERROR(args)
19247 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg);
19248 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg);
19249 +typedef bool (*sb_intrsenabled_t)(void *intr_arg);
19251 +/* misc sb info needed by some of the routines */
19252 +typedef struct sb_info {
19254 + struct sb_pub sb; /* back plane public state(must be first field of sb_info */
19256 + void *osh; /* osl os handle */
19257 + void *sdh; /* bcmsdh handle */
19259 + void *curmap; /* current regs va */
19260 + void *regs[SB_MAXCORES]; /* other regs va */
19262 + uint curidx; /* current core index */
19263 + uint dev_coreid; /* the core provides driver functions */
19265 + bool memseg; /* flag to toggle MEM_SEG register */
19267 + uint gpioidx; /* gpio control core index */
19268 + uint gpioid; /* gpio control coretype */
19270 + uint numcores; /* # discovered cores */
19271 + uint coreid[SB_MAXCORES]; /* id of each core */
19273 + void *intr_arg; /* interrupt callback function arg */
19274 + sb_intrsoff_t intrsoff_fn; /* function turns chip interrupts off */
19275 + sb_intrsrestore_t intrsrestore_fn; /* function restore chip interrupts */
19276 + sb_intrsenabled_t intrsenabled_fn; /* function to check if chip interrupts are enabled */
19280 +/* local prototypes */
19281 +static sb_info_t * BCMINIT(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
19282 + uint bustype, void *sdh, char **vars, int *varsz);
19283 +static void BCMINIT(sb_scan)(sb_info_t *si);
19284 +static uint sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val);
19285 +static uint _sb_coreidx(sb_info_t *si);
19286 +static uint sb_findcoreidx(sb_info_t *si, uint coreid, uint coreunit);
19287 +static uint BCMINIT(sb_pcidev2chip)(uint pcidev);
19288 +static uint BCMINIT(sb_chip2numcores)(uint chip);
19289 +static bool sb_ispcie(sb_info_t *si);
19290 +static bool sb_find_pci_capability(sb_info_t *si, uint8 req_cap_id, uchar *buf, uint32 *buflen);
19291 +static int sb_pci_fixcfg(sb_info_t *si);
19293 +/* routines to access mdio slave device registers */
19294 +static int sb_pcie_mdiowrite(sb_info_t *si, uint physmedia, uint readdr, uint val);
19295 +static void BCMINIT(sb_war30841)(sb_info_t *si);
19297 +/* delay needed between the mdio control/ mdiodata register data access */
19298 +#define PR28829_DELAY() OSL_DELAY(10)
19301 +/* global variable to indicate reservation/release of gpio's*/
19302 +static uint32 sb_gpioreservation = 0;
19304 +#define SB_INFO(sbh) (sb_info_t*)sbh
19305 +#define SET_SBREG(sbh, r, mask, val) W_SBREG((sbh), (r), ((R_SBREG((sbh), (r)) & ~(mask)) | (val)))
19306 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && ISALIGNED((x), SB_CORE_SIZE))
19307 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE))
19308 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF)
19309 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES)
19310 +#define BADIDX (SB_MAXCORES+1)
19313 +#define PCI(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCI))
19314 +#define PCIE(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCIE))
19317 +#define SONICS_2_2 (SBIDL_RV_2_2 >> SBIDL_RV_SHIFT)
19318 +#define SONICS_2_3 (SBIDL_RV_2_3 >> SBIDL_RV_SHIFT)
19320 +#define R_SBREG(sbh, sbr) sb_read_sbreg((sbh), (sbr))
19321 +#define W_SBREG(sbh, sbr, v) sb_write_sbreg((sbh), (sbr), (v))
19322 +#define AND_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) & (v)))
19323 +#define OR_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) | (v)))
19326 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/
19327 + * after core switching to avoid invalid register accesss inside ISR.
19329 +#define INTR_OFF(si, intr_val) \
19330 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
19331 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); }
19332 +#define INTR_RESTORE(si, intr_val) \
19333 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
19334 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
19336 +/* dynamic clock control defines */
19337 +#define LPOMINFREQ 25000 /* low power oscillator min */
19338 +#define LPOMAXFREQ 43000 /* low power oscillator max */
19339 +#define XTALMINFREQ 19800000 /* 20 MHz - 1% */
19340 +#define XTALMAXFREQ 20200000 /* 20 MHz + 1% */
19341 +#define PCIMINFREQ 25000000 /* 25 MHz */
19342 +#define PCIMAXFREQ 34000000 /* 33 MHz + fudge */
19344 +#define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */
19345 +#define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */
19347 +#define MIN_DUMPBUFLEN 32 /* debug */
19349 +/* different register spaces to access thr'u pcie indirect access*/
19350 +#define PCIE_CONFIGREGS 1
19351 +#define PCIE_PCIEREGS 2
19353 +/* GPIO Based LED powersave defines */
19354 +#define DEFAULT_GPIO_ONTIME 10
19355 +#define DEFAULT_GPIO_OFFTIME 90
19357 +#define DEFAULT_GPIOTIMERVAL ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME)
19360 +sb_read_sbreg(sb_info_t *si, volatile uint32 *sbr)
19363 + uint32 val, intr_val = 0;
19367 + * compact flash only has 11 bits address, while we needs 12 bits address.
19368 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
19369 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
19370 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
19373 + INTR_OFF(si, intr_val);
19375 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19376 + sbr = (uint32) ((uintptr) sbr & ~(1 << 11)); /* mask out bit 11*/
19379 + val = R_REG(sbr);
19383 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19384 + INTR_RESTORE(si, intr_val);
19391 +sb_write_sbreg(sb_info_t *si, volatile uint32 *sbr, uint32 v)
19394 + volatile uint32 dummy;
19395 + uint32 intr_val = 0;
19399 + * compact flash only has 11 bits address, while we needs 12 bits address.
19400 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
19401 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
19402 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
19405 + INTR_OFF(si, intr_val);
19407 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19408 + sbr = (uint32) ((uintptr) sbr & ~(1 << 11)); /* mask out bit 11*/
19411 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) {
19412 +#ifdef IL_BIGENDIAN
19413 + dummy = R_REG(sbr);
19414 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
19415 + dummy = R_REG(sbr);
19416 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
19418 + dummy = R_REG(sbr);
19419 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
19420 + dummy = R_REG(sbr);
19421 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
19428 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19429 + INTR_RESTORE(si, intr_val);
19434 + * Allocate a sb handle.
19435 + * devid - pci device id (used to determine chip#)
19436 + * osh - opaque OS handle
19437 + * regs - virtual address of initial core registers
19438 + * bustype - pci/pcmcia/sb/sdio/etc
19439 + * vars - pointer to a pointer area for "environment" variables
19440 + * varsz - pointer to int to return the size of the vars
19443 +BCMINITFN(sb_attach)(uint devid, osl_t *osh, void *regs,
19444 + uint bustype, void *sdh, char **vars, int *varsz)
19448 + /* alloc sb_info_t */
19449 + if ((si = MALLOC(osh, sizeof (sb_info_t))) == NULL) {
19450 + SB_ERROR(("sb_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh)));
19454 + if (BCMINIT(sb_doattach)(si, devid, osh, regs, bustype, sdh, vars, varsz) == NULL) {
19455 + MFREE(osh, si, sizeof (sb_info_t));
19458 + return (sb_t *)si;
19461 +/* Using sb_kattach depends on SB_BUS support, either implicit */
19462 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */
19463 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS)
19465 +/* global kernel resource */
19466 +static sb_info_t ksi;
19468 +/* generic kernel variant of sb_attach() */
19470 +BCMINITFN(sb_kattach)()
19474 + if (ksi.curmap == NULL) {
19477 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE);
19478 + cid = R_REG((uint32 *)regs);
19479 + if (((cid & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
19480 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) &&
19481 + ((cid & CID_REV_MASK) <= (3 << CID_REV_SHIFT))) {
19482 + uint32 *scc, val;
19484 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl));
19485 + val = R_REG(scc);
19486 + SB_ERROR((" initial scc = 0x%x\n", val));
19487 + val |= SCC_SS_XTAL;
19491 + if (BCMINIT(sb_doattach)(&ksi, BCM4710_DEVICE_ID, NULL, (void*)regs,
19492 + SB_BUS, NULL, NULL, NULL) == NULL) {
19497 + return (sb_t *)&ksi;
19501 +static sb_info_t *
19502 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
19503 + uint bustype, void *sdh, char **vars, int *varsz)
19510 + ASSERT(GOODREGS(regs));
19512 + bzero((uchar*)si, sizeof (sb_info_t));
19514 + si->sb.buscoreidx = si->gpioidx = BADIDX;
19517 + si->curmap = regs;
19520 + /* check to see if we are a sb core mimic'ing a pci core */
19521 + if (bustype == PCI_BUS) {
19522 + if (OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof (uint32)) == 0xffffffff)
19523 + bustype = SB_BUS;
19525 + bustype = PCI_BUS;
19528 + si->sb.bustype = bustype;
19529 + if (si->sb.bustype != BUSTYPE(si->sb.bustype)) {
19530 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n",
19531 + si->sb.bustype, BUSTYPE(si->sb.bustype)));
19535 + /* need to set memseg flag for CF card first before any sb registers access */
19536 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS)
19537 + si->memseg = TRUE;
19539 + /* kludge to enable the clock on the 4306 which lacks a slowclock */
19540 + if (BUSTYPE(si->sb.bustype) == PCI_BUS)
19541 + sb_clkctl_xtal(&si->sb, XTAL|PLL, ON);
19543 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
19544 + w = OSL_PCI_READ_CONFIG(osh, PCI_BAR0_WIN, sizeof (uint32));
19545 + if (!GOODCOREADDR(w))
19546 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32), SB_ENUM_BASE);
19549 + /* initialize current core index value */
19550 + si->curidx = _sb_coreidx(si);
19552 + if (si->curidx == BADIDX) {
19553 + SB_ERROR(("sb_doattach: bad core index\n"));
19557 + /* get sonics backplane revision */
19558 + sb = REGS2SB(si->curmap);
19559 + si->sb.sonicsrev = (R_SBREG(si, &(sb)->sbidlow) & SBIDL_RV_MASK) >> SBIDL_RV_SHIFT;
19561 + /* keep and reuse the initial register mapping */
19562 + origidx = si->curidx;
19563 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
19564 + si->regs[origidx] = regs;
19566 + /* is core-0 a chipcommon core? */
19567 + si->numcores = 1;
19568 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, 0);
19569 + if (sb_coreid(&si->sb) != SB_CC)
19572 + /* determine chip id and rev */
19574 + /* chip common core found! */
19575 + si->sb.chip = R_REG(&cc->chipid) & CID_ID_MASK;
19576 + si->sb.chiprev = (R_REG(&cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT;
19577 + si->sb.chippkg = (R_REG(&cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT;
19579 + /* The only pcmcia chip without a chipcommon core is a 4301 */
19580 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS)
19581 + devid = BCM4301_DEVICE_ID;
19583 + /* no chip common core -- must convert device id to chip id */
19584 + if ((si->sb.chip = BCMINIT(sb_pcidev2chip)(devid)) == 0) {
19585 + SB_ERROR(("sb_doattach: unrecognized device id 0x%04x\n", devid));
19586 + sb_setcoreidx(&si->sb, origidx);
19591 + /* get chipcommon rev */
19592 + si->sb.ccrev = cc ? (int)sb_corerev(&si->sb) : NOREV;
19594 + /* determine numcores */
19595 + if (cc && ((si->sb.ccrev == 4) || (si->sb.ccrev >= 6)))
19596 + si->numcores = (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT;
19598 + si->numcores = BCMINIT(sb_chip2numcores)(si->sb.chip);
19600 + /* return to original core */
19601 + sb_setcoreidx(&si->sb, origidx);
19603 + /* sanity checks */
19604 + ASSERT(si->sb.chip);
19606 + /* scan for cores */
19607 + BCMINIT(sb_scan)(si);
19609 + /* fixup necessary chip/core configurations */
19610 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
19611 + if (sb_pci_fixcfg(si)) {
19612 + SB_ERROR(("sb_doattach: sb_pci_fixcfg failed\n"));
19617 + /* srom_var_init() depends on sb_scan() info */
19618 + if (srom_var_init(si, si->sb.bustype, si->curmap, osh, vars, varsz)) {
19619 + SB_ERROR(("sb_doattach: srom_var_init failed: bad srom\n"));
19623 + if (cc == NULL) {
19625 + * The chip revision number is hardwired into all
19626 + * of the pci function config rev fields and is
19627 + * independent from the individual core revision numbers.
19628 + * For example, the "A0" silicon of each chip is chip rev 0.
19629 + * For PCMCIA we get it from the CIS instead.
19631 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) {
19633 + si->sb.chiprev = getintvar(*vars, "chiprev");
19634 + } else if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
19635 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_REV, sizeof (uint32));
19636 + si->sb.chiprev = w & 0xff;
19638 + si->sb.chiprev = 0;
19641 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) {
19642 + w = getintvar(*vars, "regwindowsz");
19643 + si->memseg = (w <= CFTABLE_REGWIN_2K) ? TRUE : FALSE;
19646 + /* gpio control core is required */
19647 + if (!GOODIDX(si->gpioidx)) {
19648 + SB_ERROR(("sb_doattach: gpio control core not found\n"));
19652 + /* get boardtype and boardrev */
19653 + switch (BUSTYPE(si->sb.bustype)) {
19655 + /* do a pci config read to get subsystem id and subvendor id */
19656 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_SVID, sizeof (uint32));
19657 + si->sb.boardvendor = w & 0xffff;
19658 + si->sb.boardtype = (w >> 16) & 0xffff;
19663 + si->sb.boardvendor = getintvar(*vars, "manfid");
19664 + si->sb.boardtype = getintvar(*vars, "prodid");
19669 + si->sb.boardvendor = VENDOR_BROADCOM;
19670 + if ((si->sb.boardtype = getintvar(NULL, "boardtype")) == 0)
19671 + si->sb.boardtype = 0xffff;
19675 + if (si->sb.boardtype == 0) {
19676 + SB_ERROR(("sb_doattach: unknown board type\n"));
19677 + ASSERT(si->sb.boardtype);
19680 + /* setup the GPIO based LED powersave register */
19681 + if (si->sb.ccrev >= 16) {
19682 + w = getintvar(*vars, "gpiotimerval");
19684 + w = DEFAULT_GPIOTIMERVAL;
19685 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), ~0, w);
19693 +sb_coreid(sb_t *sbh)
19698 + si = SB_INFO(sbh);
19699 + sb = REGS2SB(si->curmap);
19701 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT);
19705 +sb_coreidx(sb_t *sbh)
19709 + si = SB_INFO(sbh);
19710 + return (si->curidx);
19713 +/* return current index of core */
19715 +_sb_coreidx(sb_info_t *si)
19718 + uint32 sbaddr = 0;
19722 + switch (BUSTYPE(si->sb.bustype)) {
19724 + sb = REGS2SB(si->curmap);
19725 + sbaddr = sb_base(R_SBREG(si, &sb->sbadmatch0));
19729 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32));
19732 + case PCMCIA_BUS: {
19735 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
19736 + sbaddr = (uint)tmp << 12;
19737 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
19738 + sbaddr |= (uint)tmp << 16;
19739 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
19740 + sbaddr |= (uint)tmp << 24;
19746 + sbaddr = (uint32)si->curmap;
19748 +#endif /* BCMJTAG */
19754 + if (!GOODCOREADDR(sbaddr))
19757 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE);
19761 +sb_corevendor(sb_t *sbh)
19766 + si = SB_INFO(sbh);
19767 + sb = REGS2SB(si->curmap);
19769 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT);
19773 +sb_corerev(sb_t *sbh)
19779 + si = SB_INFO(sbh);
19780 + sb = REGS2SB(si->curmap);
19781 + sbidh = R_SBREG(si, &(sb)->sbidhigh);
19783 + return (SBCOREREV(sbidh));
19791 + si = SB_INFO(sbh);
19795 +#define SBTML_ALLOW (SBTML_PE | SBTML_FGC | SBTML_FL_MASK)
19797 +/* set/clear sbtmstatelow core-specific flags */
19799 +sb_coreflags(sb_t *sbh, uint32 mask, uint32 val)
19805 + si = SB_INFO(sbh);
19806 + sb = REGS2SB(si->curmap);
19808 + ASSERT((val & ~mask) == 0);
19809 + ASSERT((mask & ~SBTML_ALLOW) == 0);
19811 + /* mask and set */
19812 + if (mask || val) {
19813 + w = (R_SBREG(si, &sb->sbtmstatelow) & ~mask) | val;
19814 + W_SBREG(si, &sb->sbtmstatelow, w);
19817 + /* return the new value */
19818 + return (R_SBREG(si, &sb->sbtmstatelow) & SBTML_ALLOW);
19821 +/* set/clear sbtmstatehigh core-specific flags */
19823 +sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val)
19829 + si = SB_INFO(sbh);
19830 + sb = REGS2SB(si->curmap);
19832 + ASSERT((val & ~mask) == 0);
19833 + ASSERT((mask & ~SBTMH_FL_MASK) == 0);
19835 + /* mask and set */
19836 + if (mask || val) {
19837 + w = (R_SBREG(si, &sb->sbtmstatehigh) & ~mask) | val;
19838 + W_SBREG(si, &sb->sbtmstatehigh, w);
19841 + /* return the new value */
19842 + return (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_FL_MASK);
19845 +/* caller needs to take care of core-specific bist hazards */
19847 +sb_corebist(sb_t *sbh, uint coreid, uint coreunit)
19854 + si = SB_INFO(sbh);
19856 + coreidx = sb_findcoreidx(si, coreid, coreunit);
19857 + if (!GOODIDX(coreidx))
19858 + result = BCME_ERROR;
19860 + sblo = sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), 0, 0);
19861 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, (sblo | SBTML_FGC | SBTML_BE));
19863 + SPINWAIT(((sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTD) == 0), 100000);
19865 + if (sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTF)
19866 + result = BCME_ERROR;
19868 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, sblo);
19875 +sb_iscoreup(sb_t *sbh)
19880 + si = SB_INFO(sbh);
19881 + sb = REGS2SB(si->curmap);
19883 + return ((R_SBREG(si, &(sb)->sbtmstatelow) & (SBTML_RESET | SBTML_REJ_MASK | SBTML_CLK)) == SBTML_CLK);
19887 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation,
19888 + * switch back to the original core, and return the new value.
19891 +sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val)
19896 + uint intr_val = 0;
19898 + ASSERT(GOODIDX(coreidx));
19899 + ASSERT(regoff < SB_CORE_SIZE);
19900 + ASSERT((val & ~mask) == 0);
19902 + INTR_OFF(si, intr_val);
19904 + /* save current core index */
19905 + origidx = sb_coreidx(&si->sb);
19907 + /* switch core */
19908 + r = (uint32*) ((uchar*) sb_setcoreidx(&si->sb, coreidx) + regoff);
19910 + /* mask and set */
19911 + if (mask || val) {
19912 + if (regoff >= SBCONFIGOFF) {
19913 + w = (R_SBREG(si, r) & ~mask) | val;
19914 + W_SBREG(si, r, w);
19916 + w = (R_REG(r) & ~mask) | val;
19922 + if (regoff >= SBCONFIGOFF)
19923 + w = R_SBREG(si, r);
19927 + /* restore core index */
19928 + if (origidx != coreidx)
19929 + sb_setcoreidx(&si->sb, origidx);
19931 + INTR_RESTORE(si, intr_val);
19935 +#define DWORD_ALIGN(x) (x & ~(0x03))
19936 +#define BYTE_POS(x) (x & 0x3)
19937 +#define WORD_POS(x) (x & 0x1)
19939 +#define BYTE_SHIFT(x) (8 * BYTE_POS(x))
19940 +#define WORD_SHIFT(x) (16 * WORD_POS(x))
19942 +#define BYTE_VAL(a, x) ((a >> BYTE_SHIFT(x)) & 0xFF)
19943 +#define WORD_VAL(a, x) ((a >> WORD_SHIFT(x)) & 0xFFFF)
19945 +#define read_pci_cfg_byte(a) \
19946 + (BYTE_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xff)
19948 +#define read_pci_cfg_write(a) \
19949 + (WORD_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xffff)
19952 +/* return TRUE if requested capability exists in the PCI config space */
19954 +sb_find_pci_capability(sb_info_t *si, uint8 req_cap_id, uchar *buf, uint32 *buflen)
19961 + if (BUSTYPE(si->sb.bustype) != PCI_BUS)
19964 + /* check for Header type 0*/
19965 + byte_val = read_pci_cfg_byte(PCI_CFG_HDR);
19966 + if ((byte_val & 0x7f) != PCI_HEADER_NORMAL)
19969 + /* check if the capability pointer field exists */
19970 + byte_val = read_pci_cfg_byte(PCI_CFG_STAT);
19971 + if (!(byte_val & PCI_CAPPTR_PRESENT))
19974 + cap_ptr = read_pci_cfg_byte(PCI_CFG_CAPPTR);
19975 + /* check if the capability pointer is 0x00 */
19976 + if (cap_ptr == 0x00)
19980 + /* loop thr'u the capability list and see if the pcie capabilty exists */
19982 + cap_id = read_pci_cfg_byte(cap_ptr);
19984 + while (cap_id != req_cap_id) {
19985 + cap_ptr = read_pci_cfg_byte((cap_ptr+1));
19986 + if (cap_ptr == 0x00) break;
19987 + cap_id = read_pci_cfg_byte(cap_ptr);
19989 + if (cap_id != req_cap_id) {
19992 + /* found the caller requested capability */
19993 + if ((buf != NULL) && (buflen != NULL)) {
19994 + bufsize = *buflen;
19995 + if (!bufsize) goto end;
19997 + /* copy the cpability data excluding cap ID and next ptr */
19999 + if ((bufsize + cap_ptr) > SZPCR)
20000 + bufsize = SZPCR - cap_ptr;
20001 + *buflen = bufsize;
20002 + while (bufsize--) {
20003 + *buf = read_pci_cfg_byte(cap_ptr);
20012 +/* return TRUE if PCIE capability exists the pci config space */
20014 +sb_ispcie(sb_info_t *si)
20016 + return(sb_find_pci_capability(si, PCI_CAP_PCIECAP_ID, NULL, NULL));
20019 +/* scan the sb enumerated space to identify all cores */
20021 +BCMINITFN(sb_scan)(sb_info_t *si)
20034 + /* numcores should already be set */
20035 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES));
20037 + /* save current core index */
20038 + origidx = sb_coreidx(&si->sb);
20040 + si->sb.buscorerev = NOREV;
20041 + si->sb.buscoreidx = BADIDX;
20043 + si->gpioidx = BADIDX;
20045 + pci = pcie = FALSE;
20046 + pcirev = pcierev = NOREV;
20047 + pciidx = pcieidx = BADIDX;
20049 + for (i = 0; i < si->numcores; i++) {
20050 + sb_setcoreidx(&si->sb, i);
20051 + si->coreid[i] = sb_coreid(&si->sb);
20053 + if (si->coreid[i] == SB_PCI) {
20055 + pcirev = sb_corerev(&si->sb);
20057 + } else if (si->coreid[i] == SB_PCIE) {
20059 + pcierev = sb_corerev(&si->sb);
20061 + } else if (si->coreid[i] == SB_PCMCIA) {
20062 + si->sb.buscorerev = sb_corerev(&si->sb);
20063 + si->sb.buscoretype = si->coreid[i];
20064 + si->sb.buscoreidx = i;
20067 + if (pci && pcie) {
20068 + if (sb_ispcie(si))
20074 + si->sb.buscoretype = SB_PCI;
20075 + si->sb.buscorerev = pcirev;
20076 + si->sb.buscoreidx = pciidx;
20079 + si->sb.buscoretype = SB_PCIE;
20080 + si->sb.buscorerev = pcierev;
20081 + si->sb.buscoreidx = pcieidx;
20085 + * Find the gpio "controlling core" type and index.
20087 + * - if there's a chip common core - use that
20088 + * - else if there's a pci core (rev >= 2) - use that
20089 + * - else there had better be an extif core (4710 only)
20091 + if (GOODIDX(sb_findcoreidx(si, SB_CC, 0))) {
20092 + si->gpioidx = sb_findcoreidx(si, SB_CC, 0);
20093 + si->gpioid = SB_CC;
20094 + } else if (PCI(si) && (si->sb.buscorerev >= 2)) {
20095 + si->gpioidx = si->sb.buscoreidx;
20096 + si->gpioid = SB_PCI;
20097 + } else if (sb_findcoreidx(si, SB_EXTIF, 0)) {
20098 + si->gpioidx = sb_findcoreidx(si, SB_EXTIF, 0);
20099 + si->gpioid = SB_EXTIF;
20101 + ASSERT(si->gpioidx != BADIDX);
20103 + /* return to original core index */
20104 + sb_setcoreidx(&si->sb, origidx);
20107 +/* may be called with core in reset */
20109 +sb_detach(sb_t *sbh)
20114 + si = SB_INFO(sbh);
20119 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
20120 + for (idx = 0; idx < SB_MAXCORES; idx++)
20121 + if (si->regs[idx]) {
20122 + REG_UNMAP(si->regs[idx]);
20123 + si->regs[idx] = NULL;
20127 + MFREE(si->osh, si, sizeof (sb_info_t));
20130 +/* use pci dev id to determine chip id for chips not having a chipcommon core */
20132 +BCMINITFN(sb_pcidev2chip)(uint pcidev)
20134 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID))
20135 + return (BCM4710_DEVICE_ID);
20136 + if ((pcidev >= BCM4402_DEVICE_ID) && (pcidev <= BCM4402_V90_ID))
20137 + return (BCM4402_DEVICE_ID);
20138 + if (pcidev == BCM4401_ENET_ID)
20139 + return (BCM4402_DEVICE_ID);
20140 + if ((pcidev >= BCM4307_V90_ID) && (pcidev <= BCM4307_D11B_ID))
20141 + return (BCM4307_DEVICE_ID);
20142 + if (pcidev == BCM4301_DEVICE_ID)
20143 + return (BCM4301_DEVICE_ID);
20148 +/* convert chip number to number of i/o cores */
20150 +BCMINITFN(sb_chip2numcores)(uint chip)
20152 + if (chip == BCM4710_DEVICE_ID)
20154 + if (chip == BCM4402_DEVICE_ID)
20156 + if ((chip == BCM4301_DEVICE_ID) || (chip == BCM4307_DEVICE_ID))
20158 + if (chip == BCM4306_DEVICE_ID) /* < 4306c0 */
20160 + if (chip == BCM4704_DEVICE_ID)
20162 + if (chip == BCM5365_DEVICE_ID)
20165 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip));
20170 +/* return index of coreid or BADIDX if not found */
20172 +sb_findcoreidx( sb_info_t *si, uint coreid, uint coreunit)
20179 + for (i = 0; i < si->numcores; i++)
20180 + if (si->coreid[i] == coreid) {
20181 + if (found == coreunit)
20190 + * this function changes logical "focus" to the indiciated core,
20191 + * must be called with interrupt off.
20192 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
20195 +sb_setcoreidx(sb_t *sbh, uint coreidx)
20201 + si = SB_INFO(sbh);
20203 + if (coreidx >= si->numcores)
20207 + * If the user has provided an interrupt mask enabled function,
20208 + * then assert interrupts are disabled before switching the core.
20210 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg));
20212 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE);
20214 + switch (BUSTYPE(si->sb.bustype)) {
20216 + /* map new one */
20217 + if (!si->regs[coreidx]) {
20218 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE);
20219 + ASSERT(GOODREGS(si->regs[coreidx]));
20221 + si->curmap = si->regs[coreidx];
20225 + /* point bar0 window */
20226 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr);
20230 + tmp = (sbaddr >> 12) & 0x0f;
20231 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
20232 + tmp = (sbaddr >> 16) & 0xff;
20233 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
20234 + tmp = (sbaddr >> 24) & 0xff;
20235 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
20239 + /* map new one */
20240 + if (!si->regs[coreidx]) {
20241 + si->regs[coreidx] = (void *)sbaddr;
20242 + ASSERT(GOODREGS(si->regs[coreidx]));
20244 + si->curmap = si->regs[coreidx];
20246 +#endif /* BCMJTAG */
20249 + si->curidx = coreidx;
20251 + return (si->curmap);
20255 + * this function changes logical "focus" to the indiciated core,
20256 + * must be called with interrupt off.
20257 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
20260 +sb_setcore(sb_t *sbh, uint coreid, uint coreunit)
20265 + si = SB_INFO(sbh);
20266 + idx = sb_findcoreidx(si, coreid, coreunit);
20267 + if (!GOODIDX(idx))
20270 + return (sb_setcoreidx(sbh, idx));
20273 +/* return chip number */
20275 +BCMINITFN(sb_chip)(sb_t *sbh)
20279 + si = SB_INFO(sbh);
20280 + return (si->sb.chip);
20283 +/* return chip revision number */
20285 +BCMINITFN(sb_chiprev)(sb_t *sbh)
20289 + si = SB_INFO(sbh);
20290 + return (si->sb.chiprev);
20293 +/* return chip common revision number */
20295 +BCMINITFN(sb_chipcrev)(sb_t *sbh)
20299 + si = SB_INFO(sbh);
20300 + return (si->sb.ccrev);
20303 +/* return chip package option */
20305 +BCMINITFN(sb_chippkg)(sb_t *sbh)
20309 + si = SB_INFO(sbh);
20310 + return (si->sb.chippkg);
20313 +/* return PCI core rev. */
20315 +BCMINITFN(sb_pcirev)(sb_t *sbh)
20319 + si = SB_INFO(sbh);
20320 + return (si->sb.buscorerev);
20324 +BCMINITFN(sb_war16165)(sb_t *sbh)
20328 + si = SB_INFO(sbh);
20330 + return (PCI(si) && (si->sb.buscorerev <= 10));
20334 +BCMINITFN(sb_war30841)(sb_info_t *si)
20336 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_TIMER1, 0x8128);
20337 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_CDR, 0x0100);
20338 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466);
20341 +/* return PCMCIA core rev. */
20343 +BCMINITFN(sb_pcmciarev)(sb_t *sbh)
20347 + si = SB_INFO(sbh);
20348 + return (si->sb.buscorerev);
20351 +/* return board vendor id */
20353 +BCMINITFN(sb_boardvendor)(sb_t *sbh)
20357 + si = SB_INFO(sbh);
20358 + return (si->sb.boardvendor);
20361 +/* return boardtype */
20363 +BCMINITFN(sb_boardtype)(sb_t *sbh)
20368 + si = SB_INFO(sbh);
20370 + if (BUSTYPE(si->sb.bustype) == SB_BUS && si->sb.boardtype == 0xffff) {
20371 + /* boardtype format is a hex string */
20372 + si->sb.boardtype = getintvar(NULL, "boardtype");
20374 + /* backward compatibility for older boardtype string format */
20375 + if ((si->sb.boardtype == 0) && (var = getvar(NULL, "boardtype"))) {
20376 + if (!strcmp(var, "bcm94710dev"))
20377 + si->sb.boardtype = BCM94710D_BOARD;
20378 + else if (!strcmp(var, "bcm94710ap"))
20379 + si->sb.boardtype = BCM94710AP_BOARD;
20380 + else if (!strcmp(var, "bu4710"))
20381 + si->sb.boardtype = BU4710_BOARD;
20382 + else if (!strcmp(var, "bcm94702mn"))
20383 + si->sb.boardtype = BCM94702MN_BOARD;
20384 + else if (!strcmp(var, "bcm94710r1"))
20385 + si->sb.boardtype = BCM94710R1_BOARD;
20386 + else if (!strcmp(var, "bcm94710r4"))
20387 + si->sb.boardtype = BCM94710R4_BOARD;
20388 + else if (!strcmp(var, "bcm94702cpci"))
20389 + si->sb.boardtype = BCM94702CPCI_BOARD;
20390 + else if (!strcmp(var, "bcm95380_rr"))
20391 + si->sb.boardtype = BCM95380RR_BOARD;
20395 + return (si->sb.boardtype);
20398 +/* return bus type of sbh device */
20404 + si = SB_INFO(sbh);
20405 + return (si->sb.bustype);
20408 +/* return bus core type */
20410 +sb_buscoretype(sb_t *sbh)
20414 + si = SB_INFO(sbh);
20416 + return (si->sb.buscoretype);
20419 +/* return bus core revision */
20421 +sb_buscorerev(sb_t *sbh)
20424 + si = SB_INFO(sbh);
20426 + return (si->sb.buscorerev);
20429 +/* return list of found cores */
20431 +sb_corelist(sb_t *sbh, uint coreid[])
20435 + si = SB_INFO(sbh);
20437 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof (uint)));
20438 + return (si->numcores);
20441 +/* return current register mapping */
20443 +sb_coreregs(sb_t *sbh)
20447 + si = SB_INFO(sbh);
20448 + ASSERT(GOODREGS(si->curmap));
20450 + return (si->curmap);
20454 +/* do buffered registers update */
20456 +sb_commit(sb_t *sbh)
20460 + uint intr_val = 0;
20462 + si = SB_INFO(sbh);
20464 + origidx = si->curidx;
20465 + ASSERT(GOODIDX(origidx));
20467 + INTR_OFF(si, intr_val);
20469 + /* switch over to chipcommon core if there is one, else use pci */
20470 + if (si->sb.ccrev != NOREV) {
20471 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0);
20473 + /* do the buffer registers update */
20474 + W_REG(&ccregs->broadcastaddress, SB_COMMIT);
20475 + W_REG(&ccregs->broadcastdata, 0x0);
20476 + } else if (PCI(si)) {
20477 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0);
20479 + /* do the buffer registers update */
20480 + W_REG(&pciregs->bcastaddr, SB_COMMIT);
20481 + W_REG(&pciregs->bcastdata, 0x0);
20485 + /* restore core index */
20486 + sb_setcoreidx(sbh, origidx);
20487 + INTR_RESTORE(si, intr_val);
20490 +/* reset and re-enable a core */
20492 +sb_core_reset(sb_t *sbh, uint32 bits)
20496 + volatile uint32 dummy;
20498 + si = SB_INFO(sbh);
20499 + ASSERT(GOODREGS(si->curmap));
20500 + sb = REGS2SB(si->curmap);
20503 + * Must do the disable sequence first to work for arbitrary current core state.
20505 + sb_core_disable(sbh, bits);
20508 + * Now do the initialization sequence.
20511 + /* set reset while enabling the clock and forcing them on throughout the core */
20512 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits));
20513 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20516 + if (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_SERR) {
20517 + W_SBREG(si, &sb->sbtmstatehigh, 0);
20519 + if ((dummy = R_SBREG(si, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) {
20520 + AND_SBREG(si, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO));
20523 + /* clear reset and allow it to propagate throughout the core */
20524 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits));
20525 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20528 + /* leave clock enabled */
20529 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_CLK | bits));
20530 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20535 +sb_core_tofixup(sb_t *sbh)
20540 + si = SB_INFO(sbh);
20542 + if ( (BUSTYPE(si->sb.bustype) != PCI_BUS) || PCIE(si) || (PCI(si) && (si->sb.buscorerev >= 5)) )
20545 + ASSERT(GOODREGS(si->curmap));
20546 + sb = REGS2SB(si->curmap);
20548 + if (BUSTYPE(si->sb.bustype) == SB_BUS) {
20549 + SET_SBREG(si, &sb->sbimconfiglow,
20550 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
20551 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3);
20553 + if (sb_coreid(sbh) == SB_PCI) {
20554 + SET_SBREG(si, &sb->sbimconfiglow,
20555 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
20556 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
20558 + SET_SBREG(si, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0);
20566 + * Set the initiator timeout for the "master core".
20567 + * The master core is defined to be the core in control
20568 + * of the chip and so it issues accesses to non-memory
20569 + * locations (Because of dma *any* core can access memeory).
20571 + * The routine uses the bus to decide who is the master:
20573 + * JTAG_BUS => chipc
20574 + * PCI_BUS => pci or pcie
20575 + * PCMCIA_BUS => pcmcia
20576 + * SDIO_BUS => pcmcia
20578 + * This routine exists so callers can disable initiator
20579 + * timeouts so accesses to very slow devices like otp
20580 + * won't cause an abort. The routine allows arbitrary
20581 + * settings of the service and request timeouts, though.
20583 + * Returns the timeout state before changing it or -1
20587 +#define TO_MASK (SBIMCL_RTO_MASK | SBIMCL_STO_MASK)
20590 +sb_set_initiator_to(sb_t *sbh, uint32 to)
20593 + uint origidx, idx;
20594 + uint intr_val = 0;
20595 + uint32 tmp, ret = 0xffffffff;
20598 + si = SB_INFO(sbh);
20600 + if ((to & ~TO_MASK) != 0)
20603 + /* Figure out the master core */
20605 + switch (BUSTYPE(si->sb.bustype)) {
20607 + idx = si->sb.buscoreidx;
20614 + idx = sb_findcoreidx(si, SB_PCMCIA, 0);
20617 + if ((idx = sb_findcoreidx(si, SB_MIPS33, 0)) == BADIDX)
20618 + idx = sb_findcoreidx(si, SB_MIPS, 0);
20623 + if (idx == BADIDX)
20626 + INTR_OFF(si, intr_val);
20627 + origidx = sb_coreidx(sbh);
20629 + sb = REGS2SB(sb_setcoreidx(sbh, idx));
20631 + tmp = R_SBREG(si, &sb->sbimconfiglow);
20632 + ret = tmp & TO_MASK;
20633 + W_SBREG(si, &sb->sbimconfiglow, (tmp & ~TO_MASK) | to);
20636 + sb_setcoreidx(sbh, origidx);
20637 + INTR_RESTORE(si, intr_val);
20642 +sb_core_disable(sb_t *sbh, uint32 bits)
20645 + volatile uint32 dummy;
20649 + si = SB_INFO(sbh);
20651 + ASSERT(GOODREGS(si->curmap));
20652 + sb = REGS2SB(si->curmap);
20654 + /* if core is already in reset, just return */
20655 + if (R_SBREG(si, &sb->sbtmstatelow) & SBTML_RESET)
20658 + /* reject value changed between sonics 2.2 and 2.3 */
20659 + if (si->sb.sonicsrev == SONICS_2_2)
20660 + rej = (1 << SBTML_REJ_SHIFT);
20662 + rej = (2 << SBTML_REJ_SHIFT);
20664 + /* if clocks are not enabled, put into reset and return */
20665 + if ((R_SBREG(si, &sb->sbtmstatelow) & SBTML_CLK) == 0)
20668 + /* set target reject and spin until busy is clear (preserve core-specific bits) */
20669 + OR_SBREG(si, &sb->sbtmstatelow, rej);
20670 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20672 + SPINWAIT((R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
20674 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT) {
20675 + OR_SBREG(si, &sb->sbimstate, SBIM_RJ);
20676 + dummy = R_SBREG(si, &sb->sbimstate);
20678 + SPINWAIT((R_SBREG(si, &sb->sbimstate) & SBIM_BY), 100000);
20681 + /* set reset and reject while enabling the clocks */
20682 + W_SBREG(si, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | rej | SBTML_RESET));
20683 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20686 + /* don't forget to clear the initiator reject bit */
20687 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT)
20688 + AND_SBREG(si, &sb->sbimstate, ~SBIM_RJ);
20691 + /* leave reset and reject asserted */
20692 + W_SBREG(si, &sb->sbtmstatelow, (bits | rej | SBTML_RESET));
20696 +/* set chip watchdog reset timer to fire in 'ticks' backplane cycles */
20698 +sb_watchdog(sb_t *sbh, uint ticks)
20700 + sb_info_t *si = SB_INFO(sbh);
20702 + /* instant NMI */
20703 + switch (si->gpioid) {
20705 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, watchdog), ~0, ticks);
20708 + sb_corereg(si, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks);
20713 +/* initialize the pcmcia core */
20715 +sb_pcmcia_init(sb_t *sbh)
20720 + si = SB_INFO(sbh);
20722 + /* enable d11 mac interrupts */
20723 + if (si->sb.chip == BCM4301_DEVICE_ID) {
20724 + /* Have to use FCR2 in 4301 */
20725 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
20726 + cor |= COR_IRQEN | COR_FUNEN;
20727 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
20729 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
20730 + cor |= COR_IRQEN | COR_FUNEN;
20731 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
20738 + * Configure the pci core for pci client (NIC) action
20739 + * coremask is the bitvec of cores by index to be enabled.
20742 +sb_pci_setup(sb_t *sbh, uint coremask)
20746 + sbpciregs_t *pciregs;
20752 + si = SB_INFO(sbh);
20754 + /* if not pci bus, we're done */
20755 + if (BUSTYPE(si->sb.bustype) != PCI_BUS)
20758 + ASSERT(PCI(si) || PCIE(si));
20759 + ASSERT(si->sb.buscoreidx != BADIDX);
20761 + /* get current core index */
20762 + idx = si->curidx;
20764 + /* we interrupt on this backplane flag number */
20765 + ASSERT(GOODREGS(si->curmap));
20766 + sb = REGS2SB(si->curmap);
20767 + sbflag = R_SBREG(si, &sb->sbtpsflag) & SBTPS_NUM0_MASK;
20769 + /* switch over to pci core */
20770 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->sb.buscoreidx);
20771 + sb = REGS2SB(pciregs);
20774 + * Enable sb->pci interrupts. Assume
20775 + * PCI rev 2.3 support was added in pci core rev 6 and things changed..
20777 + if (PCIE(si) || (PCI(si) && ((si->sb.buscorerev) >= 6))) {
20778 + /* pci config write to set this core bit in PCIIntMask */
20779 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32));
20780 + w |= (coremask << PCI_SBIM_SHIFT);
20781 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w);
20783 + /* set sbintvec bit for our flag number */
20784 + OR_SBREG(si, &sb->sbintvec, (1 << sbflag));
20788 + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST));
20789 + if (si->sb.buscorerev >= 11)
20790 + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI);
20791 + if (si->sb.buscorerev < 5) {
20792 + SET_SBREG(si, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
20793 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
20798 + if (PCIE(si) && (si->sb.buscorerev == 0)) {
20799 + reg_val = sb_pcie_readreg((void *)sbh, (void *)PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG);
20801 + sb_pcie_writereg((void *)sbh, (void *)PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG, reg_val);
20803 + reg_val = sb_pcie_readreg((void *)sbh, (void *)PCIE_PCIEREGS, PCIE_DLLP_LCREG);
20804 + reg_val &= ~(0x40);
20805 + sb_pcie_writereg(sbh, (void *)PCIE_PCIEREGS, PCIE_DLLP_LCREG, reg_val);
20807 + BCMINIT(sb_war30841)(si);
20810 + /* switch back to previous core */
20811 + sb_setcoreidx(sbh, idx);
20815 +sb_base(uint32 admatch)
20820 + type = admatch & SBAM_TYPE_MASK;
20821 + ASSERT(type < 3);
20826 + base = admatch & SBAM_BASE0_MASK;
20827 + } else if (type == 1) {
20828 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20829 + base = admatch & SBAM_BASE1_MASK;
20830 + } else if (type == 2) {
20831 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20832 + base = admatch & SBAM_BASE2_MASK;
20839 +sb_size(uint32 admatch)
20844 + type = admatch & SBAM_TYPE_MASK;
20845 + ASSERT(type < 3);
20850 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1);
20851 + } else if (type == 1) {
20852 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20853 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1);
20854 + } else if (type == 2) {
20855 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20856 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1);
20862 +/* return the core-type instantiation # of the current core */
20864 +sb_coreunit(sb_t *sbh)
20872 + si = SB_INFO(sbh);
20875 + idx = si->curidx;
20877 + ASSERT(GOODREGS(si->curmap));
20878 + coreid = sb_coreid(sbh);
20880 + /* count the cores of our type */
20881 + for (i = 0; i < idx; i++)
20882 + if (si->coreid[i] == coreid)
20885 + return (coreunit);
20888 +static INLINE uint32
20892 + case CC_F6_2: return 2;
20893 + case CC_F6_3: return 3;
20894 + case CC_F6_4: return 4;
20895 + case CC_F6_5: return 5;
20896 + case CC_F6_6: return 6;
20897 + case CC_F6_7: return 7;
20898 + default: return 0;
20902 +/* calculate the speed the SB would run at given a set of clockcontrol values */
20904 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m)
20906 + uint32 n1, n2, clock, m1, m2, m3, mc;
20908 + n1 = n & CN_N1_MASK;
20909 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT;
20911 + if (pll_type == PLL_TYPE6) {
20912 + if (m & CC_T6_MMASK)
20916 + } else if ((pll_type == PLL_TYPE1) ||
20917 + (pll_type == PLL_TYPE3) ||
20918 + (pll_type == PLL_TYPE4) ||
20919 + (pll_type == PLL_TYPE7)) {
20920 + n1 = factor6(n1);
20921 + n2 += CC_F5_BIAS;
20922 + } else if (pll_type == PLL_TYPE2) {
20923 + n1 += CC_T2_BIAS;
20924 + n2 += CC_T2_BIAS;
20925 + ASSERT((n1 >= 2) && (n1 <= 7));
20926 + ASSERT((n2 >= 5) && (n2 <= 23));
20927 + } else if (pll_type == PLL_TYPE5) {
20928 + return (100000000);
20931 + /* PLL types 3 and 7 use BASE2 (25Mhz) */
20932 + if ((pll_type == PLL_TYPE3) ||
20933 + (pll_type == PLL_TYPE7)) {
20934 + clock = CC_CLOCK_BASE2 * n1 * n2;
20937 + clock = CC_CLOCK_BASE1 * n1 * n2;
20942 + m1 = m & CC_M1_MASK;
20943 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT;
20944 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT;
20945 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT;
20947 + if ((pll_type == PLL_TYPE1) ||
20948 + (pll_type == PLL_TYPE3) ||
20949 + (pll_type == PLL_TYPE4) ||
20950 + (pll_type == PLL_TYPE7)) {
20951 + m1 = factor6(m1);
20952 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3))
20953 + m2 += CC_F5_BIAS;
20955 + m2 = factor6(m2);
20956 + m3 = factor6(m3);
20959 + case CC_MC_BYPASS: return (clock);
20960 + case CC_MC_M1: return (clock / m1);
20961 + case CC_MC_M1M2: return (clock / (m1 * m2));
20962 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3));
20963 + case CC_MC_M1M3: return (clock / (m1 * m3));
20964 + default: return (0);
20967 + ASSERT(pll_type == PLL_TYPE2);
20969 + m1 += CC_T2_BIAS;
20970 + m2 += CC_T2M2_BIAS;
20971 + m3 += CC_T2_BIAS;
20972 + ASSERT((m1 >= 2) && (m1 <= 7));
20973 + ASSERT((m2 >= 3) && (m2 <= 10));
20974 + ASSERT((m3 >= 2) && (m3 <= 7));
20976 + if ((mc & CC_T2MC_M1BYP) == 0)
20978 + if ((mc & CC_T2MC_M2BYP) == 0)
20980 + if ((mc & CC_T2MC_M3BYP) == 0)
20987 +/* returns the current speed the SB is running at */
20989 +sb_clock(sb_t *sbh)
20992 + extifregs_t *eir;
20996 + uint32 pll_type, rate;
20997 + uint intr_val = 0;
20999 + si = SB_INFO(sbh);
21000 + idx = si->curidx;
21001 + pll_type = PLL_TYPE1;
21003 + INTR_OFF(si, intr_val);
21005 + /* switch to extif or chipc core */
21006 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
21007 + n = R_REG(&eir->clockcontrol_n);
21008 + m = R_REG(&eir->clockcontrol_sb);
21009 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
21010 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
21011 + n = R_REG(&cc->clockcontrol_n);
21012 + if (pll_type == PLL_TYPE6)
21013 + m = R_REG(&cc->clockcontrol_mips);
21014 + else if (pll_type == PLL_TYPE3)
21016 + // Added by Chen-I for 5365
21017 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
21018 + m = R_REG(&cc->clockcontrol_sb);
21020 + m = R_REG(&cc->clockcontrol_m2);
21023 + m = R_REG(&cc->clockcontrol_sb);
21025 + INTR_RESTORE(si, intr_val);
21029 + // Added by Chen-I for 5365
21030 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
21032 + rate = 100000000;
21036 + /* calculate rate */
21037 + rate = sb_clock_rate(pll_type, n, m);
21038 + if (pll_type == PLL_TYPE3)
21042 + /* switch back to previous core */
21043 + sb_setcoreidx(sbh, idx);
21045 + INTR_RESTORE(si, intr_val);
21050 +/* change logical "focus" to the gpio core for optimized access */
21052 +sb_gpiosetcore(sb_t *sbh)
21056 + si = SB_INFO(sbh);
21058 + return (sb_setcoreidx(sbh, si->gpioidx));
21061 +/* mask&set gpiocontrol bits */
21063 +sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
21068 + si = SB_INFO(sbh);
21071 + /* gpios could be shared on router platforms */
21072 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
21073 + mask = priority ? (sb_gpioreservation & mask) :
21074 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
21078 + switch (si->gpioid) {
21080 + regoff = OFFSETOF(chipcregs_t, gpiocontrol);
21084 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol);
21091 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
21094 +/* mask&set gpio output enable bits */
21096 +sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
21101 + si = SB_INFO(sbh);
21104 + /* gpios could be shared on router platforms */
21105 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
21106 + mask = priority ? (sb_gpioreservation & mask) :
21107 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
21111 + switch (si->gpioid) {
21113 + regoff = OFFSETOF(chipcregs_t, gpioouten);
21117 + regoff = OFFSETOF(sbpciregs_t, gpioouten);
21121 + regoff = OFFSETOF(extifregs_t, gpio[0].outen);
21125 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
21128 +/* mask&set gpio output bits */
21130 +sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
21135 + si = SB_INFO(sbh);
21138 + /* gpios could be shared on router platforms */
21139 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
21140 + mask = priority ? (sb_gpioreservation & mask) :
21141 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
21145 + switch (si->gpioid) {
21147 + regoff = OFFSETOF(chipcregs_t, gpioout);
21151 + regoff = OFFSETOF(sbpciregs_t, gpioout);
21155 + regoff = OFFSETOF(extifregs_t, gpio[0].out);
21159 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
21162 +/* reserve one gpio */
21164 +sb_gpioreserve(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
21168 + si = SB_INFO(sbh);
21170 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
21171 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
21172 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
21175 + /* make sure only one bit is set */
21176 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
21177 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
21181 + /* already reserved */
21182 + if (sb_gpioreservation & gpio_bitmask)
21184 + /* set reservation */
21185 + sb_gpioreservation |= gpio_bitmask;
21187 + return sb_gpioreservation;
21190 +/* release one gpio */
21192 + * releasing the gpio doesn't change the current value on the GPIO last write value
21193 + * persists till some one overwrites it
21197 +sb_gpiorelease(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
21201 + si = SB_INFO(sbh);
21203 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
21204 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
21205 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
21208 + /* make sure only one bit is set */
21209 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
21210 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
21214 + /* already released */
21215 + if (!(sb_gpioreservation & gpio_bitmask))
21218 + /* clear reservation */
21219 + sb_gpioreservation &= ~gpio_bitmask;
21221 + return sb_gpioreservation;
21224 +/* return the current gpioin register value */
21226 +sb_gpioin(sb_t *sbh)
21231 + si = SB_INFO(sbh);
21234 + switch (si->gpioid) {
21236 + regoff = OFFSETOF(chipcregs_t, gpioin);
21240 + regoff = OFFSETOF(sbpciregs_t, gpioin);
21244 + regoff = OFFSETOF(extifregs_t, gpioin);
21248 + return (sb_corereg(si, si->gpioidx, regoff, 0, 0));
21251 +/* mask&set gpio interrupt polarity bits */
21253 +sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
21258 + si = SB_INFO(sbh);
21261 + /* gpios could be shared on router platforms */
21262 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
21263 + mask = priority ? (sb_gpioreservation & mask) :
21264 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
21268 + switch (si->gpioid) {
21270 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity);
21274 + /* pci gpio implementation does not support interrupt polarity */
21279 + regoff = OFFSETOF(extifregs_t, gpiointpolarity);
21283 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
21286 +/* mask&set gpio interrupt mask bits */
21288 +sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
21293 + si = SB_INFO(sbh);
21296 + /* gpios could be shared on router platforms */
21297 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
21298 + mask = priority ? (sb_gpioreservation & mask) :
21299 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
21303 + switch (si->gpioid) {
21305 + regoff = OFFSETOF(chipcregs_t, gpiointmask);
21309 + /* pci gpio implementation does not support interrupt mask */
21314 + regoff = OFFSETOF(extifregs_t, gpiointmask);
21318 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
21321 +/* assign the gpio to an led */
21323 +sb_gpioled(sb_t *sbh, uint32 mask, uint32 val)
21327 + si = SB_INFO(sbh);
21328 + if (si->sb.ccrev < 16)
21331 + /* gpio led powersave reg */
21332 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimeroutmask), mask, val));
21335 +/* mask&set gpio timer val */
21337 +sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 gpiotimerval)
21340 + si = SB_INFO(sbh);
21342 + if (si->sb.ccrev < 16)
21345 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), mask, gpiotimerval));
21349 +/* return the slow clock source - LPO, XTAL, or PCI */
21351 +sb_slowclk_src(sb_info_t *si)
21356 + ASSERT(sb_coreid(&si->sb) == SB_CC);
21358 + if (si->sb.ccrev < 6) {
21359 + if ((BUSTYPE(si->sb.bustype) == PCI_BUS)
21360 + && (OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32)) & PCI_CFG_GPIO_SCS))
21361 + return (SCC_SS_PCI);
21363 + return (SCC_SS_XTAL);
21364 + } else if (si->sb.ccrev < 10) {
21365 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
21366 + return (R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK);
21367 + } else /* Insta-clock */
21368 + return (SCC_SS_XTAL);
21371 +/* return the ILP (slowclock) min or max frequency */
21373 +sb_slowclk_freq(sb_info_t *si, bool max)
21380 + ASSERT(sb_coreid(&si->sb) == SB_CC);
21382 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
21384 + /* shouldn't be here unless we've established the chip has dynamic clk control */
21385 + ASSERT(R_REG(&cc->capabilities) & CAP_PWR_CTL);
21387 + slowclk = sb_slowclk_src(si);
21388 + if (si->sb.ccrev < 6) {
21389 + if (slowclk == SCC_SS_PCI)
21390 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64));
21392 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32));
21393 + } else if (si->sb.ccrev < 10) {
21394 + div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
21395 + if (slowclk == SCC_SS_LPO)
21396 + return (max? LPOMAXFREQ : LPOMINFREQ);
21397 + else if (slowclk == SCC_SS_XTAL)
21398 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div));
21399 + else if (slowclk == SCC_SS_PCI)
21400 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div));
21404 + /* Chipc rev 10 is InstaClock */
21405 + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT;
21406 + div = 4 * (div + 1);
21407 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div));
21413 +sb_clkctl_setdelay(sb_info_t *si, void *chipcregs)
21415 + chipcregs_t * cc;
21416 + uint slowmaxfreq, pll_delay, slowclk;
21417 + uint pll_on_delay, fref_sel_delay;
21419 + pll_delay = PLL_DELAY;
21421 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay
21422 + * since the xtal will also be powered down by dynamic clk control logic.
21424 + slowclk = sb_slowclk_src(si);
21425 + if (slowclk != SCC_SS_XTAL)
21426 + pll_delay += XTAL_ON_DELAY;
21428 + /* Starting with 4318 it is ILP that is used for the delays */
21429 + slowmaxfreq = sb_slowclk_freq(si, (si->sb.ccrev >= 10) ? FALSE : TRUE);
21431 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
21432 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
21434 + cc = (chipcregs_t *)chipcregs;
21435 + W_REG(&cc->pll_on_delay, pll_on_delay);
21436 + W_REG(&cc->fref_sel_delay, fref_sel_delay);
21440 +sb_pwrctl_slowclk(void *sbh, bool set, uint *div)
21445 + uint intr_val = 0;
21448 + si = SB_INFO(sbh);
21450 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
21451 + if (si->sb.ccrev < 6)
21454 + /* chipcommon cores rev10 are a whole new ball game */
21455 + if (si->sb.ccrev >= 10)
21458 + if (set && ((*div % 4) || (*div < 4)))
21461 + INTR_OFF(si, intr_val);
21462 + origidx = si->curidx;
21463 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
21464 + ASSERT(cc != NULL);
21466 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) {
21472 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, ((*div / 4 - 1) << SCC_CD_SHIFT));
21473 + sb_clkctl_setdelay(sbh, (void *)cc);
21475 + *div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
21478 + sb_setcoreidx(sbh, origidx);
21479 + INTR_RESTORE(si, intr_val);
21483 +/* initialize power control delay registers */
21484 +void sb_clkctl_init(sb_t *sbh)
21490 + si = SB_INFO(sbh);
21492 + origidx = si->curidx;
21494 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
21497 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
21500 + /* 4317pc does not work with SlowClock less than 5 MHz */
21501 + if ((BUSTYPE(si->sb.bustype) == PCMCIA_BUS) && (si->sb.ccrev >= 6) && (si->sb.ccrev < 10))
21502 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, (ILP_DIV_5MHZ << SCC_CD_SHIFT));
21504 + /* set all Instaclk chip ILP to 1 MHz */
21505 + else if (si->sb.ccrev >= 10)
21506 + SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
21508 + sb_clkctl_setdelay(si, (void *)cc);
21511 + sb_setcoreidx(sbh, origidx);
21513 +void sb_pwrctl_init(sb_t *sbh)
21515 +sb_clkctl_init(sbh);
21517 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */
21519 +sb_clkctl_fast_pwrup_delay(sb_t *sbh)
21524 + uint slowminfreq;
21526 + uint intr_val = 0;
21528 + si = SB_INFO(sbh);
21530 + origidx = si->curidx;
21532 + INTR_OFF(si, intr_val);
21534 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
21537 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
21540 + slowminfreq = sb_slowclk_freq(si, FALSE);
21541 + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq;
21544 + sb_setcoreidx(sbh, origidx);
21545 + INTR_RESTORE(si, intr_val);
21546 + return (fpdelay);
21548 +uint16 sb_pwrctl_fast_pwrup_delay(sb_t *sbh)
21550 +return sb_clkctl_fast_pwrup_delay(sbh);
21552 +/* turn primary xtal and/or pll off/on */
21554 +sb_clkctl_xtal(sb_t *sbh, uint what, bool on)
21557 + uint32 in, out, outen;
21559 + si = SB_INFO(sbh);
21561 + switch (BUSTYPE(si->sb.bustype)) {
21570 + /* pcie core doesn't have any mapping to control the xtal pu */
21574 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof (uint32));
21575 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
21576 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32));
21579 + * Avoid glitching the clock if GPRS is already using it.
21580 + * We can't actually read the state of the PLLPD so we infer it
21581 + * by the value of XTAL_PU which *is* readable via gpioin.
21583 + if (on && (in & PCI_CFG_GPIO_XTAL))
21587 + outen |= PCI_CFG_GPIO_XTAL;
21589 + outen |= PCI_CFG_GPIO_PLL;
21592 + /* turn primary xtal on */
21593 + if (what & XTAL) {
21594 + out |= PCI_CFG_GPIO_XTAL;
21596 + out |= PCI_CFG_GPIO_PLL;
21597 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
21598 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
21599 + OSL_DELAY(XTAL_ON_DELAY);
21602 + /* turn pll on */
21603 + if (what & PLL) {
21604 + out &= ~PCI_CFG_GPIO_PLL;
21605 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
21610 + out &= ~PCI_CFG_GPIO_XTAL;
21612 + out |= PCI_CFG_GPIO_PLL;
21613 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
21614 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
21624 +int sb_pwrctl_xtal(sb_t *sbh, uint what, bool on)
21626 +return sb_clkctl_xtal(sbh,what,on);
21629 +/* set dynamic clk control mode (forceslow, forcefast, dynamic) */
21630 +/* returns true if ignore pll off is set and false if it is not */
21632 +sb_clkctl_clk(sb_t *sbh, uint mode)
21638 + bool forcefastclk=FALSE;
21639 + uint intr_val = 0;
21641 + si = SB_INFO(sbh);
21643 + /* chipcommon cores prior to rev6 don't support dynamic clock control */
21644 + if (si->sb.ccrev < 6)
21647 + /* chipcommon cores rev10 are a whole new ball game */
21648 + if (si->sb.ccrev >= 10)
21651 + INTR_OFF(si, intr_val);
21653 + origidx = si->curidx;
21655 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
21656 + ASSERT(cc != NULL);
21658 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
21662 + case CLK_FAST: /* force fast (pll) clock */
21663 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */
21664 + sb_clkctl_xtal(&si->sb, XTAL, ON);
21666 + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
21669 + case CLK_DYNAMIC: /* enable dynamic clock control */
21670 + scc = R_REG(&cc->slow_clk_ctl);
21671 + scc &= ~(SCC_FS | SCC_IP | SCC_XC);
21672 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
21674 + W_REG(&cc->slow_clk_ctl, scc);
21676 + /* for dynamic control, we have to release our xtal_pu "force on" */
21677 + if (scc & SCC_XC)
21678 + sb_clkctl_xtal(&si->sb, XTAL, OFF);
21685 + /* Is the h/w forcing the use of the fast clk */
21686 + forcefastclk = (bool)((R_REG(&cc->slow_clk_ctl) & SCC_IP) == SCC_IP);
21689 + sb_setcoreidx(sbh, origidx);
21690 + INTR_RESTORE(si, intr_val);
21691 + return (forcefastclk);
21694 +bool sb_pwrctl_clk(sb_t *sbh, uint mode)
21696 +return sb_clkctl_clk(sbh, mode);
21698 +/* register driver interrupt disabling and restoring callback functions */
21700 +sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg)
21704 + si = SB_INFO(sbh);
21705 + si->intr_arg = intr_arg;
21706 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn;
21707 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn;
21708 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn;
21709 + /* save current core id. when this function called, the current core
21710 + * must be the core which provides driver functions(il, et, wl, etc.)
21712 + si->dev_coreid = si->coreid[si->curidx];
21717 +sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
21718 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif)
21720 + uint vendor, core, unit;
21721 + uint chip, chippkg;
21723 + uint8 class, subclass, progif;
21725 + vendor = sb_corevendor(sbh);
21726 + core = sb_coreid(sbh);
21727 + unit = sb_coreunit(sbh);
21729 + chip = BCMINIT(sb_chip)(sbh);
21730 + chippkg = BCMINIT(sb_chippkg)(sbh);
21734 + /* Known vendor translations */
21735 + switch (vendor) {
21736 + case SB_VEND_BCM:
21737 + vendor = VENDOR_BROADCOM;
21741 + /* Determine class based on known core codes */
21744 + class = PCI_CLASS_NET;
21745 + subclass = PCI_NET_ETHER;
21746 + core = BCM47XX_ILINE_ID;
21749 + class = PCI_CLASS_NET;
21750 + subclass = PCI_NET_ETHER;
21751 + core = BCM47XX_ENET_ID;
21755 + class = PCI_CLASS_MEMORY;
21756 + subclass = PCI_MEMORY_RAM;
21760 + class = PCI_CLASS_BRIDGE;
21761 + subclass = PCI_BRIDGE_PCI;
21765 + class = PCI_CLASS_CPU;
21766 + subclass = PCI_CPU_MIPS;
21769 + class = PCI_CLASS_COMM;
21770 + subclass = PCI_COMM_MODEM;
21771 + core = BCM47XX_V90_ID;
21774 + class = PCI_CLASS_SERIAL;
21775 + subclass = PCI_SERIAL_USB;
21776 + progif = 0x10; /* OHCI */
21777 + core = BCM47XX_USB_ID;
21780 + class = PCI_CLASS_SERIAL;
21781 + subclass = PCI_SERIAL_USB;
21782 + progif = 0x10; /* OHCI */
21783 + core = BCM47XX_USBH_ID;
21786 + class = PCI_CLASS_SERIAL;
21787 + subclass = PCI_SERIAL_USB;
21788 + core = BCM47XX_USBD_ID;
21791 + class = PCI_CLASS_CRYPT;
21792 + subclass = PCI_CRYPT_NETWORK;
21793 + core = BCM47XX_IPSEC_ID;
21796 + class = PCI_CLASS_NET;
21797 + subclass = PCI_NET_OTHER;
21798 + core = BCM47XX_ROBO_ID;
21802 + class = PCI_CLASS_MEMORY;
21803 + subclass = PCI_MEMORY_FLASH;
21806 + class = PCI_CLASS_NET;
21807 + subclass = PCI_NET_OTHER;
21808 + /* Let an nvram variable override this */
21809 + sprintf(varname, "wl%did", unit);
21810 + if ((core = getintvar(NULL, varname)) == 0) {
21811 + if (chip == BCM4712_DEVICE_ID) {
21812 + if (chippkg == BCM4712SMALL_PKG_ID)
21813 + core = BCM4306_D11G_ID;
21815 + core = BCM4306_D11DUAL_ID;
21821 + class = subclass = progif = 0xff;
21825 + *pcivendor = (uint16)vendor;
21826 + *pcidevice = (uint16)core;
21827 + *pciclass = class;
21828 + *pcisubclass = subclass;
21829 + *pciprogif = progif;
21835 +/* use the mdio interface to write to mdio slaves */
21837 +sb_pcie_mdiowrite(sb_info_t *si, uint physmedia, uint regaddr, uint val)
21841 + sbpcieregs_t *pcieregs;
21843 + pcieregs = (sbpcieregs_t*) sb_setcoreidx(&si->sb, si->sb.buscoreidx);
21844 + ASSERT (pcieregs);
21846 + /* enable mdio access to SERDES */
21847 + W_REG((&pcieregs->mdiocontrol), MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL);
21849 + mdiodata = MDIODATA_START | MDIODATA_WRITE |
21850 + (physmedia << MDIODATA_DEVADDR_SHF) |
21851 + (regaddr << MDIODATA_REGADDR_SHF) | MDIODATA_TA | val;
21853 + W_REG((&pcieregs->mdiodata), mdiodata);
21857 + /* retry till the transaction is complete */
21858 + while ( i < 10 ) {
21859 + if (R_REG(&(pcieregs->mdiocontrol)) & MDIOCTL_ACCESS_DONE) {
21860 + /* Disable mdio access to SERDES */
21861 + W_REG((&pcieregs->mdiocontrol), 0);
21868 + SB_ERROR(("sb_pcie_mdiowrite: timed out\n"));
21869 + /* Disable mdio access to SERDES */
21870 + W_REG((&pcieregs->mdiocontrol), 0);
21876 +/* indirect way to read pcie config regs*/
21878 +sb_pcie_readreg(void *sb, void* arg1, uint offset)
21882 + uint retval = 0xFFFFFFFF;
21883 + sbpcieregs_t *pcieregs;
21886 + sbh = (sb_t *)sb;
21887 + si = SB_INFO(sbh);
21888 + ASSERT (PCIE(si));
21890 + pcieregs = (sbpcieregs_t *)sb_setcore(sbh, SB_PCIE, 0);
21891 + ASSERT (pcieregs);
21893 + addrtype = (uint)((uintptr)arg1);
21894 + switch(addrtype) {
21895 + case PCIE_CONFIGREGS:
21896 + W_REG((&pcieregs->configaddr),offset);
21897 + retval = R_REG(&(pcieregs->configdata));
21899 + case PCIE_PCIEREGS:
21900 + W_REG(&(pcieregs->pcieaddr),offset);
21901 + retval = R_REG(&(pcieregs->pciedata));
21910 +/* indirect way to write pcie config/mdio/pciecore regs*/
21912 +sb_pcie_writereg(sb_t *sbh, void *arg1, uint offset, uint val)
21915 + sbpcieregs_t *pcieregs;
21918 + si = SB_INFO(sbh);
21919 + ASSERT (PCIE(si));
21921 + pcieregs = (sbpcieregs_t *)sb_setcore(sbh, SB_PCIE, 0);
21922 + ASSERT (pcieregs);
21924 + addrtype = (uint)((uintptr)arg1);
21926 + switch(addrtype) {
21927 + case PCIE_CONFIGREGS:
21928 + W_REG((&pcieregs->configaddr),offset);
21929 + W_REG((&pcieregs->configdata),val);
21931 + case PCIE_PCIEREGS:
21932 + W_REG((&pcieregs->pcieaddr),offset);
21933 + W_REG((&pcieregs->pciedata),val);
21943 +/* Build device path. Support SB, PCI, and JTAG for now. */
21945 +sb_devpath(sb_t *sbh, char *path, int size)
21948 + ASSERT(size >= SB_DEVPATH_BUFSZ);
21950 + switch (BUSTYPE((SB_INFO(sbh))->sb.bustype)) {
21953 + sprintf(path, "sb/%u/", sb_coreidx(sbh));
21956 + ASSERT((SB_INFO(sbh))->osh);
21957 + sprintf(path, "pci/%u/%u/", OSL_PCI_BUS((SB_INFO(sbh))->osh),
21958 + OSL_PCI_SLOT((SB_INFO(sbh))->osh));
21961 + SB_ERROR(("sb_devpath: OSL_PCMCIA_BUS() not implemented, bus 1 assumed\n"));
21962 + SB_ERROR(("sb_devpath: OSL_PCMCIA_SLOT() not implemented, slot 1 assumed\n"));
21963 + sprintf(path, "pc/%u/%u/", 1, 1);
21966 + SB_ERROR(("sb_devpath: device 0 assumed\n"));
21967 + sprintf(path, "sd/%u/", sb_coreidx(sbh));
21977 +/* Fix chip's configuration. The current core may be changed upon return */
21979 +sb_pci_fixcfg(sb_info_t *si)
21981 + uint origidx, pciidx;
21982 + sbpciregs_t *pciregs;
21983 + sbpcieregs_t *pcieregs;
21984 + uint16 val16, *reg16;
21985 + char name[SB_DEVPATH_BUFSZ+16], *value;
21986 + char devpath[SB_DEVPATH_BUFSZ];
21988 + ASSERT(BUSTYPE(si->sb.bustype) == PCI_BUS);
21990 + /* Fix PCI(e) SROM shadow area */
21991 + /* save the current index */
21992 + origidx = sb_coreidx(&si->sb);
21994 + /* check 'pi' is correct and fix it if not */
21995 + if (si->sb.buscoretype == SB_PCIE) {
21996 + pcieregs = (sbpcieregs_t *)sb_setcore(&si->sb, SB_PCIE, 0);
21997 + ASSERT(pcieregs);
21998 + reg16 = &pcieregs->sprom[SRSH_PI_OFFSET];
22000 + else if (si->sb.buscoretype == SB_PCI) {
22001 + pciregs = (sbpciregs_t *)sb_setcore(&si->sb, SB_PCI, 0);
22003 + reg16 = &pciregs->sprom[SRSH_PI_OFFSET];
22009 + pciidx = sb_coreidx(&si->sb);
22010 + val16 = R_REG(reg16);
22011 + if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (uint16)pciidx) {
22012 + val16 = (uint16)(pciidx << SRSH_PI_SHIFT) | (val16 & ~SRSH_PI_MASK);
22013 + W_REG(reg16, val16);
22016 + /* restore the original index */
22017 + sb_setcoreidx(&si->sb, origidx);
22019 + /* Fix bar0window */
22020 + /* !do it last, it changes the current core! */
22021 + if (sb_devpath(&si->sb, devpath, sizeof(devpath)))
22023 + sprintf(name, "%sb0w", devpath);
22024 + if ((value = getvar(NULL, name))) {
22025 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof(uint32),
22026 + bcm_strtoul(value, NULL, 16));
22027 + /* update curidx since the current core is changed */
22028 + si->curidx = _sb_coreidx(si);
22029 + if (si->curidx == BADIDX) {
22030 + SB_ERROR(("sb_pci_fixcfg: bad core index\n"));
22038 diff -urN linux.old/drivers/net/hnd/shared_ksyms.sh linux.dev/drivers/net/hnd/shared_ksyms.sh
22039 --- linux.old/drivers/net/hnd/shared_ksyms.sh 1970-01-01 01:00:00.000000000 +0100
22040 +++ linux.dev/drivers/net/hnd/shared_ksyms.sh 2005-11-07 21:57:07.917590250 +0100
22044 +# Copyright 2004, Broadcom Corporation
22045 +# All Rights Reserved.
22047 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
22048 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
22049 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
22050 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
22052 +# $Id: shared_ksyms.sh,v 1.1 2005/03/16 13:50:00 wbx Exp $
22056 +#include <linux/config.h>
22057 +#include <linux/module.h>
22060 +for file in $* ; do
22061 + ${NM} $file | sed -ne 's/[0-9A-Fa-f]* [DT] \([^ ]*\)/extern void \1; EXPORT_SYMBOL(\1);/p'
22063 diff -urN linux.old/drivers/net/wireless/Config.in linux.dev/drivers/net/wireless/Config.in
22064 --- linux.old/drivers/net/wireless/Config.in 2005-11-07 23:12:51.258929250 +0100
22065 +++ linux.dev/drivers/net/wireless/Config.in 2005-11-07 21:57:07.941591750 +0100
22069 if [ "$CONFIG_PCI" = "y" ]; then
22070 + dep_tristate ' Proprietary Broadcom BCM43xx 802.11 Wireless support' CONFIG_WL
22071 dep_tristate ' Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.) (EXPERIMENTAL)' CONFIG_PLX_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
22072 dep_tristate ' Hermes in TMD7160/NCP130 based PCI adaptor support (Pheecom WL-PCI etc.) (EXPERIMENTAL)' CONFIG_TMD_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
22073 dep_tristate ' Prism 2.5 PCI 802.11b adaptor support (EXPERIMENTAL)' CONFIG_PCI_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
22074 diff -urN linux.old/drivers/net/wl/Makefile linux.dev/drivers/net/wl/Makefile
22075 --- linux.old/drivers/net/wl/Makefile 1970-01-01 01:00:00.000000000 +0100
22076 +++ linux.dev/drivers/net/wl/Makefile 2005-11-07 21:57:07.941591750 +0100
22079 +# Makefile for the Broadcom wl driver
22081 +# Copyright 2004, Broadcom Corporation
22082 +# All Rights Reserved.
22084 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
22085 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
22086 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
22087 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
22089 +# $Id: Makefile,v 1.2 2005/03/29 03:32:18 mbm Exp $
22091 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include
22095 +obj-y := apsta_aeskeywrap.o apsta_aes.o apsta_bcmwpa.o apsta_d11ucode.o
22096 +obj-y += apsta_hmac.o apsta_md5.o apsta_passhash.o apsta_prf.o apsta_rc4.o
22097 +obj-y += apsta_rijndael-alg-fst.o apsta_sha1.o apsta_tkhash.o apsta_wlc_led.o
22098 +obj-y += apsta_wlc_phy.o apsta_wlc_rate.o apsta_wlc_security.o
22099 +obj-y += apsta_wlc_sup.o apsta_wlc_wet.o apsta_wl_linux.o apsta_wlc.o
22101 +obj-m := $(O_TARGET)
22103 +include $(TOPDIR)/Rules.make
22104 diff -urN linux.old/drivers/parport/Config.in linux.dev/drivers/parport/Config.in
22105 --- linux.old/drivers/parport/Config.in 2005-11-07 23:12:51.306932250 +0100
22106 +++ linux.dev/drivers/parport/Config.in 2005-11-07 21:57:07.941591750 +0100
22108 tristate 'Parallel port support' CONFIG_PARPORT
22109 if [ "$CONFIG_PARPORT" != "n" ]; then
22110 dep_tristate ' PC-style hardware' CONFIG_PARPORT_PC $CONFIG_PARPORT
22111 + dep_tristate ' Asus WL500g parallel port' CONFIG_PARPORT_SPLINK $CONFIG_PARPORT
22112 if [ "$CONFIG_PARPORT_PC" != "n" -a "$CONFIG_SERIAL" != "n" ]; then
22113 if [ "$CONFIG_SERIAL" = "m" ]; then
22114 define_tristate CONFIG_PARPORT_PC_CML1 m
22115 diff -urN linux.old/drivers/parport/Makefile linux.dev/drivers/parport/Makefile
22116 --- linux.old/drivers/parport/Makefile 2005-11-07 23:12:51.318933000 +0100
22117 +++ linux.dev/drivers/parport/Makefile 2005-11-07 21:57:07.941591750 +0100
22120 obj-$(CONFIG_PARPORT) += parport.o
22121 obj-$(CONFIG_PARPORT_PC) += parport_pc.o
22122 +obj-$(CONFIG_PARPORT_SPLINK) += parport_splink.o
22123 obj-$(CONFIG_PARPORT_PC_PCMCIA) += parport_cs.o
22124 obj-$(CONFIG_PARPORT_AMIGA) += parport_amiga.o
22125 obj-$(CONFIG_PARPORT_MFC3) += parport_mfc3.o
22126 diff -urN linux.old/drivers/parport/parport_splink.c linux.dev/drivers/parport/parport_splink.c
22127 --- linux.old/drivers/parport/parport_splink.c 1970-01-01 01:00:00.000000000 +0100
22128 +++ linux.dev/drivers/parport/parport_splink.c 2005-11-07 21:57:07.941591750 +0100
22130 +/* Low-level parallel port routines for the ASUS WL-500g built-in port
22132 + * Author: Nuno Grilo <nuno.grilo@netcabo.pt>
22133 + * Based on parport_pc source
22136 +#include <linux/config.h>
22137 +#include <linux/module.h>
22138 +#include <linux/init.h>
22139 +#include <linux/ioport.h>
22140 +#include <linux/kernel.h>
22141 +#include <linux/slab.h>
22142 +#include <linux/parport.h>
22143 +#include <linux/parport_pc.h>
22145 +#define SPLINK_ADDRESS 0xBF800010
22150 +#define DPRINTK printk
22152 +#define DPRINTK(stuff...)
22156 +/* __parport_splink_frob_control differs from parport_splink_frob_control in that
22157 + * it doesn't do any extra masking. */
22158 +static __inline__ unsigned char __parport_splink_frob_control (struct parport *p,
22159 + unsigned char mask,
22160 + unsigned char val)
22162 + struct parport_pc_private *priv = p->physport->private_data;
22163 + unsigned char *io = (unsigned char *) p->base;
22164 + unsigned char ctr = priv->ctr;
22165 +#ifdef DEBUG_PARPORT
22166 + printk (KERN_DEBUG
22167 + "__parport_splink_frob_control(%02x,%02x): %02x -> %02x\n",
22168 + mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
22170 + ctr = (ctr & ~mask) ^ val;
22171 + ctr &= priv->ctr_writable; /* only write writable bits. */
22173 + priv->ctr = ctr; /* Update soft copy */
22179 +static void parport_splink_data_forward (struct parport *p)
22181 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
22182 + __parport_splink_frob_control (p, 0x20, 0);
22185 +static void parport_splink_data_reverse (struct parport *p)
22187 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
22188 + __parport_splink_frob_control (p, 0x20, 0x20);
22192 +static void parport_splink_interrupt(int irq, void *dev_id, struct pt_regs *regs)
22194 + DPRINTK(KERN_DEBUG "parport_splink: IRQ handler called\n");
22195 + parport_generic_irq(irq, (struct parport *) dev_id, regs);
22199 +static void parport_splink_enable_irq(struct parport *p)
22201 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_enable_irq called\n");
22202 + __parport_splink_frob_control (p, 0x10, 0x10);
22205 +static void parport_splink_disable_irq(struct parport *p)
22207 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_disable_irq called\n");
22208 + __parport_splink_frob_control (p, 0x10, 0);
22211 +static void parport_splink_init_state(struct pardevice *dev, struct parport_state *s)
22213 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_init_state called\n");
22214 + s->u.pc.ctr = 0xc | (dev->irq_func ? 0x10 : 0x0);
22215 + if (dev->irq_func &&
22216 + dev->port->irq != PARPORT_IRQ_NONE)
22217 + /* Set ackIntEn */
22218 + s->u.pc.ctr |= 0x10;
22221 +static void parport_splink_save_state(struct parport *p, struct parport_state *s)
22223 + const struct parport_pc_private *priv = p->physport->private_data;
22224 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_save_state called\n");
22225 + s->u.pc.ctr = priv->ctr;
22228 +static void parport_splink_restore_state(struct parport *p, struct parport_state *s)
22230 + struct parport_pc_private *priv = p->physport->private_data;
22231 + unsigned char *io = (unsigned char *) p->base;
22232 + unsigned char ctr = s->u.pc.ctr;
22234 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_restore_state called\n");
22239 +static void parport_splink_setup_interrupt(void) {
22243 +static void parport_splink_write_data(struct parport *p, unsigned char d) {
22244 + DPRINTK(KERN_DEBUG "parport_splink: write data called\n");
22245 + unsigned char *io = (unsigned char *) p->base;
22249 +static unsigned char parport_splink_read_data(struct parport *p) {
22250 + DPRINTK(KERN_DEBUG "parport_splink: read data called\n");
22251 + unsigned char *io = (unsigned char *) p->base;
22255 +static void parport_splink_write_control(struct parport *p, unsigned char d)
22257 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
22258 + PARPORT_CONTROL_AUTOFD |
22259 + PARPORT_CONTROL_INIT |
22260 + PARPORT_CONTROL_SELECT);
22262 + DPRINTK(KERN_DEBUG "parport_splink: write control called\n");
22263 + /* Take this out when drivers have adapted to the newer interface. */
22265 + printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
22266 + p->name, p->cad->name);
22267 + parport_splink_data_reverse (p);
22270 + __parport_splink_frob_control (p, wm, d & wm);
22273 +static unsigned char parport_splink_read_control(struct parport *p)
22275 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
22276 + PARPORT_CONTROL_AUTOFD |
22277 + PARPORT_CONTROL_INIT |
22278 + PARPORT_CONTROL_SELECT);
22279 + DPRINTK(KERN_DEBUG "parport_splink: read control called\n");
22280 + const struct parport_pc_private *priv = p->physport->private_data;
22281 + return priv->ctr & wm; /* Use soft copy */
22284 +static unsigned char parport_splink_frob_control (struct parport *p, unsigned char mask,
22285 + unsigned char val)
22287 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
22288 + PARPORT_CONTROL_AUTOFD |
22289 + PARPORT_CONTROL_INIT |
22290 + PARPORT_CONTROL_SELECT);
22292 + DPRINTK(KERN_DEBUG "parport_splink: frob control called\n");
22293 + /* Take this out when drivers have adapted to the newer interface. */
22294 + if (mask & 0x20) {
22295 + printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
22296 + p->name, p->cad->name,
22297 + (val & 0x20) ? "reverse" : "forward");
22299 + parport_splink_data_reverse (p);
22301 + parport_splink_data_forward (p);
22304 + /* Restrict mask and val to control lines. */
22308 + return __parport_splink_frob_control (p, mask, val);
22311 +static unsigned char parport_splink_read_status(struct parport *p)
22313 + DPRINTK(KERN_DEBUG "parport_splink: read status called\n");
22314 + unsigned char *io = (unsigned char *) p->base;
22318 +static void parport_splink_inc_use_count(void)
22321 + MOD_INC_USE_COUNT;
22325 +static void parport_splink_dec_use_count(void)
22328 + MOD_DEC_USE_COUNT;
22332 +static struct parport_operations parport_splink_ops =
22334 + parport_splink_write_data,
22335 + parport_splink_read_data,
22337 + parport_splink_write_control,
22338 + parport_splink_read_control,
22339 + parport_splink_frob_control,
22341 + parport_splink_read_status,
22343 + parport_splink_enable_irq,
22344 + parport_splink_disable_irq,
22346 + parport_splink_data_forward,
22347 + parport_splink_data_reverse,
22349 + parport_splink_init_state,
22350 + parport_splink_save_state,
22351 + parport_splink_restore_state,
22353 + parport_splink_inc_use_count,
22354 + parport_splink_dec_use_count,
22356 + parport_ieee1284_epp_write_data,
22357 + parport_ieee1284_epp_read_data,
22358 + parport_ieee1284_epp_write_addr,
22359 + parport_ieee1284_epp_read_addr,
22361 + parport_ieee1284_ecp_write_data,
22362 + parport_ieee1284_ecp_read_data,
22363 + parport_ieee1284_ecp_write_addr,
22365 + parport_ieee1284_write_compat,
22366 + parport_ieee1284_read_nibble,
22367 + parport_ieee1284_read_byte,
22370 +/* --- Initialisation code -------------------------------- */
22372 +static struct parport *parport_splink_probe_port (unsigned long int base)
22374 + struct parport_pc_private *priv;
22375 + struct parport_operations *ops;
22376 + struct parport *p;
22378 + if (check_mem_region(base, 3)) {
22379 + printk (KERN_DEBUG "parport (0x%lx): iomem region not available\n", base);
22382 + priv = kmalloc (sizeof (struct parport_pc_private), GFP_KERNEL);
22384 + printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base);
22387 + ops = kmalloc (sizeof (struct parport_operations), GFP_KERNEL);
22389 + printk (KERN_DEBUG "parport (0x%lx): no memory for ops!\n",
22394 + memcpy (ops, &parport_splink_ops, sizeof (struct parport_operations));
22396 + priv->ctr_writable = 0xff;
22398 + if (!(p = parport_register_port(base, PARPORT_IRQ_NONE,
22399 + PARPORT_DMA_NONE, ops))) {
22400 + printk (KERN_DEBUG "parport (0x%lx): registration failed!\n",
22407 + p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;
22408 + p->size = (p->modes & PARPORT_MODE_EPP)?8:3;
22409 + p->private_data = priv;
22411 + parport_proc_register(p);
22412 + request_mem_region (p->base, 3, p->name);
22414 + /* Done probing. Now put the port into a sensible start-up state. */
22415 + parport_splink_write_data(p, 0);
22416 + parport_splink_data_forward (p);
22418 + /* Now that we've told the sharing engine about the port, and
22419 + found out its characteristics, let the high-level drivers
22420 + know about it. */
22421 + parport_announce_port (p);
22423 + DPRINTK(KERN_DEBUG "parport (0x%lx): init ok!\n",
22428 +static void parport_splink_unregister_port(struct parport *p) {
22429 + struct parport_pc_private *priv = p->private_data;
22430 + struct parport_operations *ops = p->ops;
22432 + if (p->irq != PARPORT_IRQ_NONE)
22433 + free_irq(p->irq, p);
22434 + release_mem_region(p->base, 3);
22435 + parport_proc_unregister(p);
22437 + parport_unregister_port(p);
22442 +int parport_splink_init(void)
22446 + DPRINTK(KERN_DEBUG "parport_splink init called\n");
22447 + parport_splink_setup_interrupt();
22448 + ret = !parport_splink_probe_port(SPLINK_ADDRESS);
22453 +void parport_splink_cleanup(void) {
22454 + struct parport *p = parport_enumerate(), *tmp;
22455 + DPRINTK(KERN_DEBUG "parport_splink cleanup called\n");
22457 + if (p->modes & PARPORT_MODE_PCSPP) {
22460 + parport_splink_unregister_port(p);
22467 +MODULE_AUTHOR("Nuno Grilo <nuno.grilo@netcabo.pt>");
22468 +MODULE_DESCRIPTION("Parport Driver for ASUS WL-500g router builtin Port");
22469 +MODULE_SUPPORTED_DEVICE("ASUS WL-500g builtin Parallel Port");
22470 +MODULE_LICENSE("GPL");
22472 +module_init(parport_splink_init)
22473 +module_exit(parport_splink_cleanup)
22475 diff -urN linux.old/drivers/pcmcia/Makefile linux.dev/drivers/pcmcia/Makefile
22476 --- linux.old/drivers/pcmcia/Makefile 2005-11-07 23:12:51.350935000 +0100
22477 +++ linux.dev/drivers/pcmcia/Makefile 2005-11-07 21:57:07.941591750 +0100
22479 au1000_ss-objs-$(CONFIG_MIPS_HYDROGEN3) += au1000_hydrogen3.o
22480 au1000_ss-objs-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o
22482 +obj-$(CONFIG_PCMCIA_BCM4710) += bcm4710_ss.o
22483 +bcm4710_ss-objs := bcm4710_generic.o
22484 +bcm4710_ss-objs += bcm4710_pcmcia.o
22486 obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o
22487 obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o
22488 obj-$(CONFIG_PCMCIA_SIBYTE) += sibyte_generic.o
22489 @@ -112,5 +116,8 @@
22490 au1x00_ss.o: $(au1000_ss-objs-y)
22491 $(LD) -r -o $@ $(au1000_ss-objs-y)
22493 +bcm4710_ss.o: $(bcm4710_ss-objs)
22494 + $(LD) -r -o $@ $(bcm4710_ss-objs)
22496 yenta_socket.o: $(yenta_socket-objs)
22497 $(LD) $(LD_RFLAG) -r -o $@ $(yenta_socket-objs)
22498 diff -urN linux.old/drivers/pcmcia/bcm4710_generic.c linux.dev/drivers/pcmcia/bcm4710_generic.c
22499 --- linux.old/drivers/pcmcia/bcm4710_generic.c 1970-01-01 01:00:00.000000000 +0100
22500 +++ linux.dev/drivers/pcmcia/bcm4710_generic.c 2005-11-07 21:57:07.945592000 +0100
22504 + * bcm47xx pcmcia driver
22506 + * Copyright 2004, Broadcom Corporation
22507 + * All Rights Reserved.
22509 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
22510 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
22511 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
22512 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
22514 + * Based on sa1100_generic.c from www.handhelds.org,
22515 + * and au1000_generic.c from oss.sgi.com.
22517 + * $Id: bcm4710_generic.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
22519 +#include <linux/module.h>
22520 +#include <linux/init.h>
22521 +#include <linux/config.h>
22522 +#include <linux/delay.h>
22523 +#include <linux/ioport.h>
22524 +#include <linux/kernel.h>
22525 +#include <linux/tqueue.h>
22526 +#include <linux/timer.h>
22527 +#include <linux/mm.h>
22528 +#include <linux/proc_fs.h>
22529 +#include <linux/version.h>
22530 +#include <linux/types.h>
22531 +#include <linux/vmalloc.h>
22533 +#include <pcmcia/version.h>
22534 +#include <pcmcia/cs_types.h>
22535 +#include <pcmcia/cs.h>
22536 +#include <pcmcia/ss.h>
22537 +#include <pcmcia/bulkmem.h>
22538 +#include <pcmcia/cistpl.h>
22539 +#include <pcmcia/bus_ops.h>
22540 +#include "cs_internal.h"
22542 +#include <asm/io.h>
22543 +#include <asm/irq.h>
22544 +#include <asm/system.h>
22546 +#include <typedefs.h>
22547 +#include <bcm4710.h>
22548 +#include <sbextif.h>
22550 +#include "bcm4710pcmcia.h"
22552 +#ifdef PCMCIA_DEBUG
22553 +static int pc_debug = PCMCIA_DEBUG;
22556 +MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm47xx Socket Controller");
22558 +/* This structure maintains housekeeping state for each socket, such
22559 + * as the last known values of the card detect pins, or the Card Services
22560 + * callback value associated with the socket:
22562 +static struct bcm47xx_pcmcia_socket *pcmcia_socket;
22563 +static int socket_count;
22566 +/* Returned by the low-level PCMCIA interface: */
22567 +static struct pcmcia_low_level *pcmcia_low_level;
22569 +/* Event poll timer structure */
22570 +static struct timer_list poll_timer;
22573 +/* Prototypes for routines which are used internally: */
22575 +static int bcm47xx_pcmcia_driver_init(void);
22576 +static void bcm47xx_pcmcia_driver_shutdown(void);
22577 +static void bcm47xx_pcmcia_task_handler(void *data);
22578 +static void bcm47xx_pcmcia_poll_event(unsigned long data);
22579 +static void bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs);
22580 +static struct tq_struct bcm47xx_pcmcia_task;
22582 +#ifdef CONFIG_PROC_FS
22583 +static int bcm47xx_pcmcia_proc_status(char *buf, char **start,
22584 + off_t pos, int count, int *eof, void *data);
22588 +/* Prototypes for operations which are exported to the
22589 + * in-kernel PCMCIA core:
22592 +static int bcm47xx_pcmcia_init(unsigned int sock);
22593 +static int bcm47xx_pcmcia_suspend(unsigned int sock);
22594 +static int bcm47xx_pcmcia_register_callback(unsigned int sock,
22595 + void (*handler)(void *, unsigned int), void *info);
22596 +static int bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap);
22597 +static int bcm47xx_pcmcia_get_status(unsigned int sock, u_int *value);
22598 +static int bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state);
22599 +static int bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state);
22600 +static int bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *io);
22601 +static int bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *io);
22602 +static int bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *mem);
22603 +static int bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *mem);
22604 +#ifdef CONFIG_PROC_FS
22605 +static void bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base);
22608 +static struct pccard_operations bcm47xx_pcmcia_operations = {
22609 + bcm47xx_pcmcia_init,
22610 + bcm47xx_pcmcia_suspend,
22611 + bcm47xx_pcmcia_register_callback,
22612 + bcm47xx_pcmcia_inquire_socket,
22613 + bcm47xx_pcmcia_get_status,
22614 + bcm47xx_pcmcia_get_socket,
22615 + bcm47xx_pcmcia_set_socket,
22616 + bcm47xx_pcmcia_get_io_map,
22617 + bcm47xx_pcmcia_set_io_map,
22618 + bcm47xx_pcmcia_get_mem_map,
22619 + bcm47xx_pcmcia_set_mem_map,
22620 +#ifdef CONFIG_PROC_FS
22621 + bcm47xx_pcmcia_proc_setup
22627 + * bcm47xx_pcmcia_driver_init()
22629 + * This routine performs a basic sanity check to ensure that this
22630 + * kernel has been built with the appropriate board-specific low-level
22631 + * PCMCIA support, performs low-level PCMCIA initialization, registers
22632 + * this socket driver with Card Services, and then spawns the daemon
22633 + * thread which is the real workhorse of the socket driver.
22635 + * Please see linux/Documentation/arm/SA1100/PCMCIA for more information
22636 + * on the low-level kernel interface.
22638 + * Returns: 0 on success, -1 on error
22640 +static int __init bcm47xx_pcmcia_driver_init(void)
22643 + struct pcmcia_init pcmcia_init;
22644 + struct pcmcia_state state;
22646 + unsigned long tmp;
22649 + printk("\nBCM47XX PCMCIA (CS release %s)\n", CS_RELEASE);
22651 + CardServices(GetCardServicesInfo, &info);
22653 + if (info.Revision != CS_RELEASE_CODE) {
22654 + printk(KERN_ERR "Card Services release codes do not match\n");
22658 +#ifdef CONFIG_BCM4710
22659 + pcmcia_low_level=&bcm4710_pcmcia_ops;
22661 +#error Unsupported Broadcom BCM47XX board.
22664 + pcmcia_init.handler=bcm47xx_pcmcia_interrupt;
22666 + if ((socket_count = pcmcia_low_level->init(&pcmcia_init)) < 0) {
22667 + printk(KERN_ERR "Unable to initialize PCMCIA service.\n");
22670 + printk("\t%d PCMCIA sockets initialized.\n", socket_count);
22674 + kmalloc(sizeof(struct bcm47xx_pcmcia_socket) * socket_count,
22676 + memset(pcmcia_socket, 0,
22677 + sizeof(struct bcm47xx_pcmcia_socket) * socket_count);
22678 + if (!pcmcia_socket) {
22679 + printk(KERN_ERR "Card Services can't get memory \n");
22683 + for (i = 0; i < socket_count; i++) {
22684 + if (pcmcia_low_level->socket_state(i, &state) < 0) {
22685 + printk(KERN_ERR "Unable to get PCMCIA status\n");
22688 + pcmcia_socket[i].k_state = state;
22689 + pcmcia_socket[i].cs_state.csc_mask = SS_DETECT;
22692 + pcmcia_socket[i].virt_io =
22693 + (unsigned long)ioremap_nocache(EXTIF_PCMCIA_IOBASE(BCM4710_EXTIF), 0x1000);
22694 + /* Substract ioport base which gets added by in/out */
22695 + pcmcia_socket[i].virt_io -= mips_io_port_base;
22696 + pcmcia_socket[i].phys_attr =
22697 + (unsigned long)EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF);
22698 + pcmcia_socket[i].phys_mem =
22699 + (unsigned long)EXTIF_PCMCIA_MEMBASE(BCM4710_EXTIF);
22701 + printk(KERN_ERR "bcm4710: socket 1 not supported\n");
22706 + /* Only advertise as many sockets as we can detect: */
22707 + if (register_ss_entry(socket_count, &bcm47xx_pcmcia_operations) < 0) {
22708 + printk(KERN_ERR "Unable to register socket service routine\n");
22712 + /* Start the event poll timer.
22713 + * It will reschedule by itself afterwards.
22715 + bcm47xx_pcmcia_poll_event(0);
22717 + DEBUG(1, "bcm4710: initialization complete\n");
22722 +module_init(bcm47xx_pcmcia_driver_init);
22726 + * bcm47xx_pcmcia_driver_shutdown()
22728 + * Invokes the low-level kernel service to free IRQs associated with this
22729 + * socket controller and reset GPIO edge detection.
22731 +static void __exit bcm47xx_pcmcia_driver_shutdown(void)
22735 + del_timer_sync(&poll_timer);
22736 + unregister_ss_entry(&bcm47xx_pcmcia_operations);
22737 + pcmcia_low_level->shutdown();
22738 + flush_scheduled_tasks();
22739 + for (i = 0; i < socket_count; i++) {
22740 + if (pcmcia_socket[i].virt_io)
22741 + iounmap((void *)pcmcia_socket[i].virt_io);
22742 + if (pcmcia_socket[i].phys_attr)
22743 + iounmap((void *)pcmcia_socket[i].phys_attr);
22744 + if (pcmcia_socket[i].phys_mem)
22745 + iounmap((void *)pcmcia_socket[i].phys_mem);
22747 + DEBUG(1, "bcm4710: shutdown complete\n");
22750 +module_exit(bcm47xx_pcmcia_driver_shutdown);
22753 + * bcm47xx_pcmcia_init()
22754 + * We perform all of the interesting initialization tasks in
22755 + * bcm47xx_pcmcia_driver_init().
22759 +static int bcm47xx_pcmcia_init(unsigned int sock)
22761 + DEBUG(1, "%s(): initializing socket %u\n", __FUNCTION__, sock);
22767 + * bcm47xx_pcmcia_suspend()
22769 + * We don't currently perform any actions on a suspend.
22773 +static int bcm47xx_pcmcia_suspend(unsigned int sock)
22775 + DEBUG(1, "%s(): suspending socket %u\n", __FUNCTION__, sock);
22782 + * bcm47xx_pcmcia_events()
22784 + * Helper routine to generate a Card Services event mask based on
22785 + * state information obtained from the kernel low-level PCMCIA layer
22786 + * in a recent (and previous) sampling. Updates `prev_state'.
22788 + * Returns: an event mask for the given socket state.
22790 +static inline unsigned
22791 +bcm47xx_pcmcia_events(struct pcmcia_state *state,
22792 + struct pcmcia_state *prev_state,
22793 + unsigned int mask, unsigned int flags)
22795 + unsigned int events=0;
22797 + if (state->bvd1 != prev_state->bvd1) {
22799 + DEBUG(3, "%s(): card BVD1 value %u\n", __FUNCTION__, state->bvd1);
22801 + events |= mask & (flags & SS_IOCARD) ? SS_STSCHG : SS_BATDEAD;
22804 + if (state->bvd2 != prev_state->bvd2) {
22806 + DEBUG(3, "%s(): card BVD2 value %u\n", __FUNCTION__, state->bvd2);
22808 + events |= mask & (flags & SS_IOCARD) ? 0 : SS_BATWARN;
22811 + if (state->detect != prev_state->detect) {
22813 + DEBUG(3, "%s(): card detect value %u\n", __FUNCTION__, state->detect);
22815 + events |= mask & SS_DETECT;
22819 + if (state->ready != prev_state->ready) {
22821 + DEBUG(3, "%s(): card ready value %u\n", __FUNCTION__, state->ready);
22823 + events |= mask & ((flags & SS_IOCARD) ? 0 : SS_READY);
22826 + if (events != 0) {
22827 + DEBUG(2, "events: %s%s%s%s%s\n",
22828 + (events & SS_DETECT) ? "DETECT " : "",
22829 + (events & SS_READY) ? "READY " : "",
22830 + (events & SS_BATDEAD) ? "BATDEAD " : "",
22831 + (events & SS_BATWARN) ? "BATWARN " : "",
22832 + (events & SS_STSCHG) ? "STSCHG " : "");
22835 + *prev_state=*state;
22841 + * bcm47xx_pcmcia_task_handler()
22843 + * Processes serviceable socket events using the "eventd" thread context.
22845 + * Event processing (specifically, the invocation of the Card Services event
22846 + * callback) occurs in this thread rather than in the actual interrupt
22847 + * handler due to the use of scheduling operations in the PCMCIA core.
22849 +static void bcm47xx_pcmcia_task_handler(void *data)
22851 + struct pcmcia_state state;
22852 + int i, events, irq_status;
22854 + DEBUG(4, "%s(): entering PCMCIA monitoring thread\n", __FUNCTION__);
22856 + for (i = 0; i < socket_count; i++) {
22857 + if ((irq_status = pcmcia_low_level->socket_state(i, &state)) < 0)
22858 + printk(KERN_ERR "Error in kernel low-level PCMCIA service.\n");
22860 + events = bcm47xx_pcmcia_events(&state,
22861 + &pcmcia_socket[i].k_state,
22862 + pcmcia_socket[i].cs_state.csc_mask,
22863 + pcmcia_socket[i].cs_state.flags);
22865 + if (pcmcia_socket[i].handler != NULL) {
22866 + pcmcia_socket[i].handler(pcmcia_socket[i].handler_info,
22872 +static struct tq_struct bcm47xx_pcmcia_task = {
22873 + routine: bcm47xx_pcmcia_task_handler
22878 + * bcm47xx_pcmcia_poll_event()
22880 + * Let's poll for events in addition to IRQs since IRQ only is unreliable...
22882 +static void bcm47xx_pcmcia_poll_event(unsigned long dummy)
22884 + DEBUG(4, "%s(): polling for events\n", __FUNCTION__);
22886 + poll_timer.function = bcm47xx_pcmcia_poll_event;
22887 + poll_timer.expires = jiffies + BCM47XX_PCMCIA_POLL_PERIOD;
22888 + add_timer(&poll_timer);
22889 + schedule_task(&bcm47xx_pcmcia_task);
22894 + * bcm47xx_pcmcia_interrupt()
22896 + * Service routine for socket driver interrupts (requested by the
22897 + * low-level PCMCIA init() operation via bcm47xx_pcmcia_thread()).
22899 + * The actual interrupt-servicing work is performed by
22900 + * bcm47xx_pcmcia_task(), largely because the Card Services event-
22901 + * handling code performs scheduling operations which cannot be
22902 + * executed from within an interrupt context.
22905 +bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs)
22907 + DEBUG(3, "%s(): servicing IRQ %d\n", __FUNCTION__, irq);
22908 + schedule_task(&bcm47xx_pcmcia_task);
22913 + * bcm47xx_pcmcia_register_callback()
22915 + * Implements the register_callback() operation for the in-kernel
22916 + * PCMCIA service (formerly SS_RegisterCallback in Card Services). If
22917 + * the function pointer `handler' is not NULL, remember the callback
22918 + * location in the state for `sock', and increment the usage counter
22919 + * for the driver module. (The callback is invoked from the interrupt
22920 + * service routine, bcm47xx_pcmcia_interrupt(), to notify Card Services
22921 + * of interesting events.) Otherwise, clear the callback pointer in the
22922 + * socket state and decrement the module usage count.
22927 +bcm47xx_pcmcia_register_callback(unsigned int sock,
22928 + void (*handler)(void *, unsigned int), void *info)
22930 + if (handler == NULL) {
22931 + pcmcia_socket[sock].handler = NULL;
22932 + MOD_DEC_USE_COUNT;
22934 + MOD_INC_USE_COUNT;
22935 + pcmcia_socket[sock].handler = handler;
22936 + pcmcia_socket[sock].handler_info = info;
22943 + * bcm47xx_pcmcia_inquire_socket()
22945 + * Implements the inquire_socket() operation for the in-kernel PCMCIA
22946 + * service (formerly SS_InquireSocket in Card Services). Of note is
22947 + * the setting of the SS_CAP_PAGE_REGS bit in the `features' field of
22948 + * `cap' to "trick" Card Services into tolerating large "I/O memory"
22949 + * addresses. Also set is SS_CAP_STATIC_MAP, which disables the memory
22950 + * resource database check. (Mapped memory is set up within the socket
22951 + * driver itself.)
22953 + * In conjunction with the STATIC_MAP capability is a new field,
22954 + * `io_offset', recommended by David Hinds. Rather than go through
22955 + * the SetIOMap interface (which is not quite suited for communicating
22956 + * window locations up from the socket driver), we just pass up
22957 + * an offset which is applied to client-requested base I/O addresses
22958 + * in alloc_io_space().
22960 + * Returns: 0 on success, -1 if no pin has been configured for `sock'
22963 +bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap)
22965 + struct pcmcia_irq_info irq_info;
22967 + if (sock >= socket_count) {
22968 + printk(KERN_ERR "bcm47xx: socket %u not configured\n", sock);
22972 + /* SS_CAP_PAGE_REGS: used by setup_cis_mem() in cistpl.c to set the
22973 + * force_low argument to validate_mem() in rsrc_mgr.c -- since in
22974 + * general, the mapped * addresses of the PCMCIA memory regions
22975 + * will not be within 0xffff, setting force_low would be
22978 + * SS_CAP_STATIC_MAP: don't bother with the (user-configured) memory
22979 + * resource database; we instead pass up physical address ranges
22980 + * and allow other parts of Card Services to deal with remapping.
22982 + * SS_CAP_PCCARD: we can deal with 16-bit PCMCIA & CF cards, but
22983 + * not 32-bit CardBus devices.
22985 + cap->features = (SS_CAP_PAGE_REGS | SS_CAP_STATIC_MAP | SS_CAP_PCCARD);
22987 + irq_info.sock = sock;
22988 + irq_info.irq = -1;
22990 + if (pcmcia_low_level->get_irq_info(&irq_info) < 0) {
22991 + printk(KERN_ERR "Error obtaining IRQ info socket %u\n", sock);
22995 + cap->irq_mask = 0;
22996 + cap->map_size = PAGE_SIZE;
22997 + cap->pci_irq = irq_info.irq;
22998 + cap->io_offset = pcmcia_socket[sock].virt_io;
23005 + * bcm47xx_pcmcia_get_status()
23007 + * Implements the get_status() operation for the in-kernel PCMCIA
23008 + * service (formerly SS_GetStatus in Card Services). Essentially just
23009 + * fills in bits in `status' according to internal driver state or
23010 + * the value of the voltage detect chipselect register.
23012 + * As a debugging note, during card startup, the PCMCIA core issues
23013 + * three set_socket() commands in a row the first with RESET deasserted,
23014 + * the second with RESET asserted, and the last with RESET deasserted
23015 + * again. Following the third set_socket(), a get_status() command will
23016 + * be issued. The kernel is looking for the SS_READY flag (see
23017 + * setup_socket(), reset_socket(), and unreset_socket() in cs.c).
23022 +bcm47xx_pcmcia_get_status(unsigned int sock, unsigned int *status)
23024 + struct pcmcia_state state;
23027 + if ((pcmcia_low_level->socket_state(sock, &state)) < 0) {
23028 + printk(KERN_ERR "Unable to get PCMCIA status from kernel.\n");
23032 + pcmcia_socket[sock].k_state = state;
23034 + *status = state.detect ? SS_DETECT : 0;
23036 + *status |= state.ready ? SS_READY : 0;
23038 + /* The power status of individual sockets is not available
23039 + * explicitly from the hardware, so we just remember the state
23040 + * and regurgitate it upon request:
23042 + *status |= pcmcia_socket[sock].cs_state.Vcc ? SS_POWERON : 0;
23044 + if (pcmcia_socket[sock].cs_state.flags & SS_IOCARD)
23045 + *status |= state.bvd1 ? SS_STSCHG : 0;
23047 + if (state.bvd1 == 0)
23048 + *status |= SS_BATDEAD;
23049 + else if (state.bvd2 == 0)
23050 + *status |= SS_BATWARN;
23053 + *status |= state.vs_3v ? SS_3VCARD : 0;
23055 + *status |= state.vs_Xv ? SS_XVCARD : 0;
23057 + DEBUG(2, "\tstatus: %s%s%s%s%s%s%s%s\n",
23058 + (*status&SS_DETECT)?"DETECT ":"",
23059 + (*status&SS_READY)?"READY ":"",
23060 + (*status&SS_BATDEAD)?"BATDEAD ":"",
23061 + (*status&SS_BATWARN)?"BATWARN ":"",
23062 + (*status&SS_POWERON)?"POWERON ":"",
23063 + (*status&SS_STSCHG)?"STSCHG ":"",
23064 + (*status&SS_3VCARD)?"3VCARD ":"",
23065 + (*status&SS_XVCARD)?"XVCARD ":"");
23072 + * bcm47xx_pcmcia_get_socket()
23074 + * Implements the get_socket() operation for the in-kernel PCMCIA
23075 + * service (formerly SS_GetSocket in Card Services). Not a very
23076 + * exciting routine.
23081 +bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state)
23083 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
23085 + /* This information was given to us in an earlier call to set_socket(),
23086 + * so we're just regurgitating it here:
23088 + *state = pcmcia_socket[sock].cs_state;
23094 + * bcm47xx_pcmcia_set_socket()
23096 + * Implements the set_socket() operation for the in-kernel PCMCIA
23097 + * service (formerly SS_SetSocket in Card Services). We more or
23098 + * less punt all of this work and let the kernel handle the details
23099 + * of power configuration, reset, &c. We also record the value of
23100 + * `state' in order to regurgitate it to the PCMCIA core later.
23105 +bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state)
23107 + struct pcmcia_configure configure;
23109 + DEBUG(2, "\tmask: %s%s%s%s%s%s\n\tflags: %s%s%s%s%s%s\n"
23110 + "\tVcc %d Vpp %d irq %d\n",
23111 + (state->csc_mask == 0) ? "<NONE>" : "",
23112 + (state->csc_mask & SS_DETECT) ? "DETECT " : "",
23113 + (state->csc_mask & SS_READY) ? "READY " : "",
23114 + (state->csc_mask & SS_BATDEAD) ? "BATDEAD " : "",
23115 + (state->csc_mask & SS_BATWARN) ? "BATWARN " : "",
23116 + (state->csc_mask & SS_STSCHG) ? "STSCHG " : "",
23117 + (state->flags == 0) ? "<NONE>" : "",
23118 + (state->flags & SS_PWR_AUTO) ? "PWR_AUTO " : "",
23119 + (state->flags & SS_IOCARD) ? "IOCARD " : "",
23120 + (state->flags & SS_RESET) ? "RESET " : "",
23121 + (state->flags & SS_SPKR_ENA) ? "SPKR_ENA " : "",
23122 + (state->flags & SS_OUTPUT_ENA) ? "OUTPUT_ENA " : "",
23123 + state->Vcc, state->Vpp, state->io_irq);
23125 + configure.sock = sock;
23126 + configure.vcc = state->Vcc;
23127 + configure.vpp = state->Vpp;
23128 + configure.output = (state->flags & SS_OUTPUT_ENA) ? 1 : 0;
23129 + configure.speaker = (state->flags & SS_SPKR_ENA) ? 1 : 0;
23130 + configure.reset = (state->flags & SS_RESET) ? 1 : 0;
23132 + if (pcmcia_low_level->configure_socket(&configure) < 0) {
23133 + printk(KERN_ERR "Unable to configure socket %u\n", sock);
23137 + pcmcia_socket[sock].cs_state = *state;
23143 + * bcm47xx_pcmcia_get_io_map()
23145 + * Implements the get_io_map() operation for the in-kernel PCMCIA
23146 + * service (formerly SS_GetIOMap in Card Services). Just returns an
23147 + * I/O map descriptor which was assigned earlier by a set_io_map().
23149 + * Returns: 0 on success, -1 if the map index was out of range
23152 +bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *map)
23154 + DEBUG(2, "bcm47xx_pcmcia_get_io_map: sock %d\n", sock);
23156 + if (map->map >= MAX_IO_WIN) {
23157 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23158 + __FUNCTION__, map->map);
23162 + *map = pcmcia_socket[sock].io_map[map->map];
23168 + * bcm47xx_pcmcia_set_io_map()
23170 + * Implements the set_io_map() operation for the in-kernel PCMCIA
23171 + * service (formerly SS_SetIOMap in Card Services). We configure
23172 + * the map speed as requested, but override the address ranges
23173 + * supplied by Card Services.
23175 + * Returns: 0 on success, -1 on error
23178 +bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *map)
23180 + unsigned int speed;
23181 + unsigned long start;
23183 + DEBUG(2, "\tmap %u speed %u\n\tstart 0x%08lx stop 0x%08lx\n"
23184 + "\tflags: %s%s%s%s%s%s%s%s\n",
23185 + map->map, map->speed, map->start, map->stop,
23186 + (map->flags == 0) ? "<NONE>" : "",
23187 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
23188 + (map->flags & MAP_16BIT) ? "16BIT " : "",
23189 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
23190 + (map->flags & MAP_0WS) ? "0WS " : "",
23191 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
23192 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "",
23193 + (map->flags & MAP_PREFETCH) ? "PREFETCH " : "");
23195 + if (map->map >= MAX_IO_WIN) {
23196 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23197 + __FUNCTION__, map->map);
23201 + if (map->flags & MAP_ACTIVE) {
23202 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_IO_SPEED;
23203 + pcmcia_socket[sock].speed_io = speed;
23206 + start = map->start;
23208 + if (map->stop == 1) {
23209 + map->stop = PAGE_SIZE - 1;
23212 + map->start = pcmcia_socket[sock].virt_io;
23213 + map->stop = map->start + (map->stop - start);
23214 + pcmcia_socket[sock].io_map[map->map] = *map;
23215 + DEBUG(2, "set_io_map %d start %x stop %x\n",
23216 + map->map, map->start, map->stop);
23222 + * bcm47xx_pcmcia_get_mem_map()
23224 + * Implements the get_mem_map() operation for the in-kernel PCMCIA
23225 + * service (formerly SS_GetMemMap in Card Services). Just returns a
23226 + * memory map descriptor which was assigned earlier by a
23227 + * set_mem_map() request.
23229 + * Returns: 0 on success, -1 if the map index was out of range
23232 +bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *map)
23234 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
23236 + if (map->map >= MAX_WIN) {
23237 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23238 + __FUNCTION__, map->map);
23242 + *map = pcmcia_socket[sock].mem_map[map->map];
23248 + * bcm47xx_pcmcia_set_mem_map()
23250 + * Implements the set_mem_map() operation for the in-kernel PCMCIA
23251 + * service (formerly SS_SetMemMap in Card Services). We configure
23252 + * the map speed as requested, but override the address ranges
23253 + * supplied by Card Services.
23255 + * Returns: 0 on success, -1 on error
23258 +bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *map)
23260 + unsigned int speed;
23261 + unsigned long start;
23264 + if (map->map >= MAX_WIN) {
23265 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23266 + __FUNCTION__, map->map);
23270 + DEBUG(2, "\tmap %u speed %u\n\tsys_start %#lx\n"
23271 + "\tsys_stop %#lx\n\tcard_start %#x\n"
23272 + "\tflags: %s%s%s%s%s%s%s%s\n",
23273 + map->map, map->speed, map->sys_start, map->sys_stop,
23274 + map->card_start, (map->flags == 0) ? "<NONE>" : "",
23275 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
23276 + (map->flags & MAP_16BIT) ? "16BIT " : "",
23277 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
23278 + (map->flags & MAP_0WS) ? "0WS " : "",
23279 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
23280 + (map->flags & MAP_ATTRIB) ? "ATTRIB " : "",
23281 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "");
23283 + if (map->flags & MAP_ACTIVE) {
23284 + /* When clients issue RequestMap, the access speed is not always
23285 + * properly configured:
23287 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_MEM_SPEED;
23290 + if (map->flags & MAP_ATTRIB) {
23291 + pcmcia_socket[sock].speed_attr = speed;
23293 + pcmcia_socket[sock].speed_mem = speed;
23297 + save_flags(flags);
23299 + start = map->sys_start;
23301 + if (map->sys_stop == 0)
23302 + map->sys_stop = PAGE_SIZE - 1;
23304 + if (map->flags & MAP_ATTRIB) {
23305 + map->sys_start = pcmcia_socket[sock].phys_attr +
23308 + map->sys_start = pcmcia_socket[sock].phys_mem +
23312 + map->sys_stop = map->sys_start + (map->sys_stop - start);
23313 + pcmcia_socket[sock].mem_map[map->map] = *map;
23314 + restore_flags(flags);
23315 + DEBUG(2, "set_mem_map %d start %x stop %x card_start %x\n",
23316 + map->map, map->sys_start, map->sys_stop,
23317 + map->card_start);
23322 +#if defined(CONFIG_PROC_FS)
23325 + * bcm47xx_pcmcia_proc_setup()
23327 + * Implements the proc_setup() operation for the in-kernel PCMCIA
23328 + * service (formerly SS_ProcSetup in Card Services).
23330 + * Returns: 0 on success, -1 on error
23333 +bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base)
23335 + struct proc_dir_entry *entry;
23337 + if ((entry = create_proc_entry("status", 0, base)) == NULL) {
23338 + printk(KERN_ERR "Unable to install \"status\" procfs entry\n");
23342 + entry->read_proc = bcm47xx_pcmcia_proc_status;
23343 + entry->data = (void *)sock;
23348 + * bcm47xx_pcmcia_proc_status()
23350 + * Implements the /proc/bus/pccard/??/status file.
23352 + * Returns: the number of characters added to the buffer
23355 +bcm47xx_pcmcia_proc_status(char *buf, char **start, off_t pos,
23356 + int count, int *eof, void *data)
23359 + unsigned int sock = (unsigned int)data;
23361 + p += sprintf(p, "k_flags : %s%s%s%s%s%s%s\n",
23362 + pcmcia_socket[sock].k_state.detect ? "detect " : "",
23363 + pcmcia_socket[sock].k_state.ready ? "ready " : "",
23364 + pcmcia_socket[sock].k_state.bvd1 ? "bvd1 " : "",
23365 + pcmcia_socket[sock].k_state.bvd2 ? "bvd2 " : "",
23366 + pcmcia_socket[sock].k_state.wrprot ? "wrprot " : "",
23367 + pcmcia_socket[sock].k_state.vs_3v ? "vs_3v " : "",
23368 + pcmcia_socket[sock].k_state.vs_Xv ? "vs_Xv " : "");
23370 + p += sprintf(p, "status : %s%s%s%s%s%s%s%s%s\n",
23371 + pcmcia_socket[sock].k_state.detect ? "SS_DETECT " : "",
23372 + pcmcia_socket[sock].k_state.ready ? "SS_READY " : "",
23373 + pcmcia_socket[sock].cs_state.Vcc ? "SS_POWERON " : "",
23374 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ? "SS_IOCARD " : "",
23375 + (pcmcia_socket[sock].cs_state.flags & SS_IOCARD &&
23376 + pcmcia_socket[sock].k_state.bvd1) ? "SS_STSCHG " : "",
23377 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
23378 + (pcmcia_socket[sock].k_state.bvd1 == 0)) ? "SS_BATDEAD " : "",
23379 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
23380 + (pcmcia_socket[sock].k_state.bvd2 == 0)) ? "SS_BATWARN " : "",
23381 + pcmcia_socket[sock].k_state.vs_3v ? "SS_3VCARD " : "",
23382 + pcmcia_socket[sock].k_state.vs_Xv ? "SS_XVCARD " : "");
23384 + p += sprintf(p, "mask : %s%s%s%s%s\n",
23385 + pcmcia_socket[sock].cs_state.csc_mask & SS_DETECT ? "SS_DETECT " : "",
23386 + pcmcia_socket[sock].cs_state.csc_mask & SS_READY ? "SS_READY " : "",
23387 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATDEAD ? "SS_BATDEAD " : "",
23388 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATWARN ? "SS_BATWARN " : "",
23389 + pcmcia_socket[sock].cs_state.csc_mask & SS_STSCHG ? "SS_STSCHG " : "");
23391 + p += sprintf(p, "cs_flags : %s%s%s%s%s\n",
23392 + pcmcia_socket[sock].cs_state.flags & SS_PWR_AUTO ?
23393 + "SS_PWR_AUTO " : "",
23394 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ?
23395 + "SS_IOCARD " : "",
23396 + pcmcia_socket[sock].cs_state.flags & SS_RESET ?
23397 + "SS_RESET " : "",
23398 + pcmcia_socket[sock].cs_state.flags & SS_SPKR_ENA ?
23399 + "SS_SPKR_ENA " : "",
23400 + pcmcia_socket[sock].cs_state.flags & SS_OUTPUT_ENA ?
23401 + "SS_OUTPUT_ENA " : "");
23403 + p += sprintf(p, "Vcc : %d\n", pcmcia_socket[sock].cs_state.Vcc);
23404 + p += sprintf(p, "Vpp : %d\n", pcmcia_socket[sock].cs_state.Vpp);
23405 + p += sprintf(p, "irq : %d\n", pcmcia_socket[sock].cs_state.io_irq);
23406 + p += sprintf(p, "I/O : %u\n", pcmcia_socket[sock].speed_io);
23407 + p += sprintf(p, "attribute: %u\n", pcmcia_socket[sock].speed_attr);
23408 + p += sprintf(p, "common : %u\n", pcmcia_socket[sock].speed_mem);
23413 +#endif /* defined(CONFIG_PROC_FS) */
23414 diff -urN linux.old/drivers/pcmcia/bcm4710_pcmcia.c linux.dev/drivers/pcmcia/bcm4710_pcmcia.c
23415 --- linux.old/drivers/pcmcia/bcm4710_pcmcia.c 1970-01-01 01:00:00.000000000 +0100
23416 +++ linux.dev/drivers/pcmcia/bcm4710_pcmcia.c 2005-11-07 21:57:07.945592000 +0100
23419 + * BCM4710 specific pcmcia routines.
23421 + * Copyright 2004, Broadcom Corporation
23422 + * All Rights Reserved.
23424 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
23425 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
23426 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
23427 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
23429 + * $Id: bcm4710_pcmcia.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
23431 +#include <linux/module.h>
23432 +#include <linux/init.h>
23433 +#include <linux/config.h>
23434 +#include <linux/delay.h>
23435 +#include <linux/ioport.h>
23436 +#include <linux/kernel.h>
23437 +#include <linux/tqueue.h>
23438 +#include <linux/timer.h>
23439 +#include <linux/mm.h>
23440 +#include <linux/proc_fs.h>
23441 +#include <linux/version.h>
23442 +#include <linux/types.h>
23443 +#include <linux/pci.h>
23445 +#include <pcmcia/version.h>
23446 +#include <pcmcia/cs_types.h>
23447 +#include <pcmcia/cs.h>
23448 +#include <pcmcia/ss.h>
23449 +#include <pcmcia/bulkmem.h>
23450 +#include <pcmcia/cistpl.h>
23451 +#include <pcmcia/bus_ops.h>
23452 +#include "cs_internal.h"
23454 +#include <asm/io.h>
23455 +#include <asm/irq.h>
23456 +#include <asm/system.h>
23459 +#include <typedefs.h>
23460 +#include <bcmdevs.h>
23461 +#include <bcm4710.h>
23462 +#include <sbconfig.h>
23463 +#include <sbextif.h>
23465 +#include "bcm4710pcmcia.h"
23467 +/* Use a static var for irq dev_id */
23468 +static int bcm47xx_pcmcia_dev_id;
23470 +/* Do we think we have a card or not? */
23471 +static int bcm47xx_pcmcia_present = 0;
23474 +static void bcm4710_pcmcia_reset(void)
23476 + extifregs_t *eir;
23478 + uint32 out0, out1, outen;
23481 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
23485 + /* Use gpio7 to reset the pcmcia slot */
23486 + outen = readl(&eir->gpio[0].outen);
23487 + outen |= BCM47XX_PCMCIA_RESET;
23488 + out0 = readl(&eir->gpio[0].out);
23489 + out0 &= ~(BCM47XX_PCMCIA_RESET);
23490 + out1 = out0 | BCM47XX_PCMCIA_RESET;
23492 + writel(out0, &eir->gpio[0].out);
23493 + writel(outen, &eir->gpio[0].outen);
23495 + writel(out1, &eir->gpio[0].out);
23497 + writel(out0, &eir->gpio[0].out);
23499 + restore_flags(s);
23503 +static int bcm4710_pcmcia_init(struct pcmcia_init *init)
23505 + struct pci_dev *pdev;
23506 + extifregs_t *eir;
23507 + uint32 outen, intp, intm, tmp;
23510 + extern unsigned long bcm4710_cpu_cycle;
23513 + if (!(pdev = pci_find_device(VENDOR_BROADCOM, SB_EXTIF, NULL))) {
23514 + printk(KERN_ERR "bcm4710_pcmcia: extif not found\n");
23517 + eir = (extifregs_t *) ioremap_nocache(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
23519 + /* Initialize the pcmcia i/f: 16bit no swap */
23520 + writel(CF_EM_PCMCIA | CF_DS | CF_EN, &eir->pcmcia_config);
23524 + /* Set the timing for memory accesses */
23525 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
23526 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
23527 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
23528 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
23529 + writel(tmp, &eir->pcmcia_memwait); /* 0x01020a0c for a 100Mhz clock */
23531 + /* Set the timing for I/O accesses */
23532 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
23533 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
23534 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
23535 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
23536 + writel(tmp, &eir->pcmcia_iowait); /* 0x01020a0c for a 100Mhz clock */
23538 + /* Set the timing for attribute accesses */
23539 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
23540 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
23541 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
23542 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
23543 + writel(tmp, &eir->pcmcia_attrwait); /* 0x01020a0c for a 100Mhz clock */
23546 + /* Make sure gpio0 and gpio5 are inputs */
23547 + outen = readl(&eir->gpio[0].outen);
23548 + outen &= ~(BCM47XX_PCMCIA_WP | BCM47XX_PCMCIA_STSCHG | BCM47XX_PCMCIA_RESET);
23549 + writel(outen, &eir->gpio[0].outen);
23551 + /* Issue a reset to the pcmcia socket */
23552 + bcm4710_pcmcia_reset();
23554 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
23555 + /* Setup gpio5 to be the STSCHG interrupt */
23556 + intp = readl(&eir->gpiointpolarity);
23557 + writel(intp | BCM47XX_PCMCIA_STSCHG, &eir->gpiointpolarity); /* Active low */
23558 + intm = readl(&eir->gpiointmask);
23559 + writel(intm | BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Enable it */
23562 + DEBUG(2, "bcm4710_pcmcia after reset:\n");
23563 + DEBUG(2, "\textstatus\t= 0x%08x:\n", readl(&eir->extstatus));
23564 + DEBUG(2, "\tpcmcia_config\t= 0x%08x:\n", readl(&eir->pcmcia_config));
23565 + DEBUG(2, "\tpcmcia_memwait\t= 0x%08x:\n", readl(&eir->pcmcia_memwait));
23566 + DEBUG(2, "\tpcmcia_attrwait\t= 0x%08x:\n", readl(&eir->pcmcia_attrwait));
23567 + DEBUG(2, "\tpcmcia_iowait\t= 0x%08x:\n", readl(&eir->pcmcia_iowait));
23568 + DEBUG(2, "\tgpioin\t\t= 0x%08x:\n", readl(&eir->gpioin));
23569 + DEBUG(2, "\tgpio_outen0\t= 0x%08x:\n", readl(&eir->gpio[0].outen));
23570 + DEBUG(2, "\tgpio_out0\t= 0x%08x:\n", readl(&eir->gpio[0].out));
23571 + DEBUG(2, "\tgpiointpolarity\t= 0x%08x:\n", readl(&eir->gpiointpolarity));
23572 + DEBUG(2, "\tgpiointmask\t= 0x%08x:\n", readl(&eir->gpiointmask));
23574 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
23575 + /* Request pcmcia interrupt */
23576 + rc = request_irq(BCM47XX_PCMCIA_IRQ, init->handler, SA_INTERRUPT,
23577 + "PCMCIA Interrupt", &bcm47xx_pcmcia_dev_id);
23580 + attrsp = (uint16 *)ioremap_nocache(EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF), 0x1000);
23581 + tmp = readw(&attrsp[0]);
23582 + DEBUG(2, "\tattr[0] = 0x%04x\n", tmp);
23583 + if ((tmp == 0x7fff) || (tmp == 0x7f00)) {
23584 + bcm47xx_pcmcia_present = 0;
23586 + bcm47xx_pcmcia_present = 1;
23589 + /* There's only one socket */
23593 +static int bcm4710_pcmcia_shutdown(void)
23595 + extifregs_t *eir;
23598 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
23600 + /* Disable the pcmcia i/f */
23601 + writel(0, &eir->pcmcia_config);
23603 + /* Reset gpio's */
23604 + intm = readl(&eir->gpiointmask);
23605 + writel(intm & ~BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Disable it */
23607 + free_irq(BCM47XX_PCMCIA_IRQ, &bcm47xx_pcmcia_dev_id);
23613 +bcm4710_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
23615 + extifregs_t *eir;
23617 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
23621 + printk(KERN_ERR "bcm4710 socket_state bad sock %d\n", sock);
23625 + if (bcm47xx_pcmcia_present) {
23626 + state->detect = 1;
23627 + state->ready = 1;
23630 + state->wrprot = (readl(&eir->gpioin) & BCM47XX_PCMCIA_WP) == BCM47XX_PCMCIA_WP;
23631 + state->vs_3v = 0;
23632 + state->vs_Xv = 0;
23634 + state->detect = 0;
23635 + state->ready = 0;
23642 +static int bcm4710_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
23644 + if (info->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
23646 + info->irq = BCM47XX_PCMCIA_IRQ;
23653 +bcm4710_pcmcia_configure_socket(const struct pcmcia_configure *configure)
23655 + if (configure->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
23658 + DEBUG(2, "Vcc %dV Vpp %dV output %d speaker %d reset %d\n", configure->vcc,
23659 + configure->vpp, configure->output, configure->speaker, configure->reset);
23661 + if ((configure->vcc != 50) || (configure->vpp != 50)) {
23662 + printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc,
23666 + if (configure->reset) {
23667 + /* Issue a reset to the pcmcia socket */
23668 + DEBUG(1, "%s: Reseting socket\n", __FUNCTION__);
23669 + bcm4710_pcmcia_reset();
23676 +struct pcmcia_low_level bcm4710_pcmcia_ops = {
23677 + bcm4710_pcmcia_init,
23678 + bcm4710_pcmcia_shutdown,
23679 + bcm4710_pcmcia_socket_state,
23680 + bcm4710_pcmcia_get_irq_info,
23681 + bcm4710_pcmcia_configure_socket
23684 diff -urN linux.old/drivers/pcmcia/bcm4710pcmcia.h linux.dev/drivers/pcmcia/bcm4710pcmcia.h
23685 --- linux.old/drivers/pcmcia/bcm4710pcmcia.h 1970-01-01 01:00:00.000000000 +0100
23686 +++ linux.dev/drivers/pcmcia/bcm4710pcmcia.h 2005-11-07 21:57:07.945592000 +0100
23690 + * bcm47xx pcmcia driver
23692 + * Copyright 2004, Broadcom Corporation
23693 + * All Rights Reserved.
23695 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
23696 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
23697 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
23698 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
23700 + * Based on sa1100.h and include/asm-arm/arch-sa1100/pcmica.h
23701 + * from www.handhelds.org,
23702 + * and au1000_generic.c from oss.sgi.com.
23704 + * $Id: bcm4710pcmcia.h,v 1.1 2005/03/16 13:50:00 wbx Exp $
23707 +#if !defined(_BCM4710PCMCIA_H)
23708 +#define _BCM4710PCMCIA_H
23710 +#include <pcmcia/cs_types.h>
23711 +#include <pcmcia/ss.h>
23712 +#include <pcmcia/bulkmem.h>
23713 +#include <pcmcia/cistpl.h>
23714 +#include "cs_internal.h"
23717 +/* The 47xx can only support one socket */
23718 +#define BCM47XX_PCMCIA_MAX_SOCK 1
23720 +/* In the bcm947xx gpio's are used for some pcmcia functions */
23721 +#define BCM47XX_PCMCIA_WP 0x01 /* Bit 0 is WP input */
23722 +#define BCM47XX_PCMCIA_STSCHG 0x20 /* Bit 5 is STSCHG input/interrupt */
23723 +#define BCM47XX_PCMCIA_RESET 0x80 /* Bit 7 is RESET */
23725 +#define BCM47XX_PCMCIA_IRQ 2
23727 +/* The socket driver actually works nicely in interrupt-driven form,
23728 + * so the (relatively infrequent) polling is "just to be sure."
23730 +#define BCM47XX_PCMCIA_POLL_PERIOD (2 * HZ)
23732 +#define BCM47XX_PCMCIA_IO_SPEED (255)
23733 +#define BCM47XX_PCMCIA_MEM_SPEED (300)
23736 +struct pcmcia_state {
23737 + unsigned detect: 1,
23747 +struct pcmcia_configure {
23748 + unsigned sock: 8,
23756 +struct pcmcia_irq_info {
23757 + unsigned int sock;
23758 + unsigned int irq;
23761 +/* This structure encapsulates per-socket state which we might need to
23762 + * use when responding to a Card Services query of some kind.
23764 +struct bcm47xx_pcmcia_socket {
23765 + socket_state_t cs_state;
23766 + struct pcmcia_state k_state;
23767 + unsigned int irq;
23768 + void (*handler)(void *, unsigned int);
23769 + void *handler_info;
23770 + pccard_io_map io_map[MAX_IO_WIN];
23771 + pccard_mem_map mem_map[MAX_WIN];
23772 + ioaddr_t virt_io, phys_attr, phys_mem;
23773 + unsigned short speed_io, speed_attr, speed_mem;
23776 +struct pcmcia_init {
23777 + void (*handler)(int irq, void *dev, struct pt_regs *regs);
23780 +struct pcmcia_low_level {
23781 + int (*init)(struct pcmcia_init *);
23782 + int (*shutdown)(void);
23783 + int (*socket_state)(unsigned sock, struct pcmcia_state *);
23784 + int (*get_irq_info)(struct pcmcia_irq_info *);
23785 + int (*configure_socket)(const struct pcmcia_configure *);
23788 +extern struct pcmcia_low_level bcm47xx_pcmcia_ops;
23790 +/* I/O pins replacing memory pins
23791 + * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75)
23793 + * These signals change meaning when going from memory-only to
23794 + * memory-or-I/O interface:
23796 +#define iostschg bvd1
23797 +#define iospkr bvd2
23801 + * Declaration for implementation specific low_level operations.
23803 +extern struct pcmcia_low_level bcm4710_pcmcia_ops;
23805 +#endif /* !defined(_BCM4710PCMCIA_H) */
23806 diff -urN linux.old/include/asm-mips/bootinfo.h linux.dev/include/asm-mips/bootinfo.h
23807 --- linux.old/include/asm-mips/bootinfo.h 2005-11-07 23:12:51.434940250 +0100
23808 +++ linux.dev/include/asm-mips/bootinfo.h 2005-11-07 21:57:07.945592000 +0100
23810 #define MACH_GROUP_HP_LJ 20 /* Hewlett Packard LaserJet */
23811 #define MACH_GROUP_LASAT 21
23812 #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
23813 +#define MACH_GROUP_BRCM 23 /* Broadcom */
23816 * Valid machtype values for group unknown (low order halfword of mips_machtype)
23817 @@ -197,6 +198,15 @@
23818 #define MACH_TANBAC_TB0229 7 /* TANBAC TB0229 (VR4131DIMM) */
23821 + * Valid machtypes for group Broadcom
23823 +#define MACH_BCM93725 0
23824 +#define MACH_BCM93725_VJ 1
23825 +#define MACH_BCM93730 2
23826 +#define MACH_BCM947XX 3
23827 +#define MACH_BCM933XX 4
23830 * Valid machtype for group TITAN
23832 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
23833 diff -urN linux.old/include/asm-mips/cpu.h linux.dev/include/asm-mips/cpu.h
23834 --- linux.old/include/asm-mips/cpu.h 2005-11-07 23:12:51.434940250 +0100
23835 +++ linux.dev/include/asm-mips/cpu.h 2005-11-07 21:57:07.965593250 +0100
23840 +#define PRID_COPT_MASK 0xff000000
23841 +#define PRID_COMP_MASK 0x00ff0000
23842 +#define PRID_IMP_MASK 0x0000ff00
23843 +#define PRID_REV_MASK 0x000000ff
23845 #define PRID_COMP_LEGACY 0x000000
23846 #define PRID_COMP_MIPS 0x010000
23847 #define PRID_COMP_BROADCOM 0x020000
23849 #define PRID_IMP_RM7000 0x2700
23850 #define PRID_IMP_NEVADA 0x2800 /* RM5260 ??? */
23851 #define PRID_IMP_RM9000 0x3400
23852 +#define PRID_IMP_BCM4710 0x4000
23853 #define PRID_IMP_R5432 0x5400
23854 #define PRID_IMP_R5500 0x5500
23855 #define PRID_IMP_4KC 0x8000
23856 @@ -66,10 +72,16 @@
23857 #define PRID_IMP_4KEC 0x8400
23858 #define PRID_IMP_4KSC 0x8600
23859 #define PRID_IMP_25KF 0x8800
23860 +#define PRID_IMP_BCM3302 0x9000
23861 +#define PRID_IMP_BCM3303 0x9100
23862 #define PRID_IMP_24K 0x9300
23864 #define PRID_IMP_UNKNOWN 0xff00
23866 +#define BCM330X(id) \
23867 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
23868 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
23871 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
23873 @@ -174,7 +186,9 @@
23874 #define CPU_AU1550 57
23876 #define CPU_AU1200 59
23877 -#define CPU_LAST 59
23878 +#define CPU_BCM4710 60
23879 +#define CPU_BCM3302 61
23880 +#define CPU_LAST 61
23883 * ISA Level encodings
23884 diff -urN linux.old/include/asm-mips/r4kcache.h linux.dev/include/asm-mips/r4kcache.h
23885 --- linux.old/include/asm-mips/r4kcache.h 2005-11-07 23:12:51.438940500 +0100
23886 +++ linux.dev/include/asm-mips/r4kcache.h 2005-11-07 21:57:08.161605500 +0100
23887 @@ -658,4 +658,17 @@
23888 cache128_unroll32(addr|ws,Index_Writeback_Inv_SD);
23891 +extern inline void fill_icache_line(unsigned long addr)
23893 + __asm__ __volatile__(
23894 + ".set noreorder\n\t"
23896 + "cache %1, (%0)\n\t"
23904 #endif /* __ASM_R4KCACHE_H */
23905 diff -urN linux.old/include/asm-mips/serial.h linux.dev/include/asm-mips/serial.h
23906 --- linux.old/include/asm-mips/serial.h 2005-11-07 23:12:51.442940750 +0100
23907 +++ linux.dev/include/asm-mips/serial.h 2005-11-07 21:57:07.993595000 +0100
23908 @@ -223,6 +223,13 @@
23909 #define TXX927_SERIAL_PORT_DEFNS
23912 +#ifdef CONFIG_BCM947XX
23913 +/* reserve 4 ports to be configured at runtime */
23914 +#define BCM947XX_SERIAL_PORT_DEFNS { 0, }, { 0, }, { 0, }, { 0, },
23916 +#define BCM947XX_SERIAL_PORT_DEFNS
23919 #ifdef CONFIG_HAVE_STD_PC_SERIAL_PORT
23920 #define STD_SERIAL_PORT_DEFNS \
23921 /* UART CLK PORT IRQ FLAGS */ \
23922 @@ -470,6 +477,7 @@
23923 #define SERIAL_PORT_DFNS \
23924 ATLAS_SERIAL_PORT_DEFNS \
23925 AU1000_SERIAL_PORT_DEFNS \
23926 + BCM947XX_SERIAL_PORT_DEFNS \
23927 COBALT_SERIAL_PORT_DEFNS \
23928 DDB5477_SERIAL_PORT_DEFNS \
23929 EV96100_SERIAL_PORT_DEFNS \
23930 diff -urN linux.old/init/do_mounts.c linux.dev/init/do_mounts.c
23931 --- linux.old/init/do_mounts.c 2005-11-07 23:12:51.458941750 +0100
23932 +++ linux.dev/init/do_mounts.c 2005-11-07 21:57:07.993595000 +0100
23933 @@ -254,7 +254,13 @@
23934 { "ftlb", 0x2c08 },
23935 { "ftlc", 0x2c10 },
23936 { "ftld", 0x2c18 },
23937 +#if defined(CONFIG_MTD_BLOCK) || defined(CONFIG_MTD_BLOCK_RO)
23938 { "mtdblock", 0x1f00 },
23939 + { "mtdblock0",0x1f00 },
23940 + { "mtdblock1",0x1f01 },
23941 + { "mtdblock2",0x1f02 },
23942 + { "mtdblock3",0x1f03 },