1 diff -Nur linux-2.4.32/arch/mips/bcm947xx/cfe_env.c linux-2.4.32-brcm/arch/mips/bcm947xx/cfe_env.c
2 --- linux-2.4.32/arch/mips/bcm947xx/cfe_env.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/cfe_env.c 2005-12-19 01:56:35.104829500 +0100
6 + * NVRAM variable manipulation (Linux kernel half)
8 + * Copyright 2001-2003, Broadcom Corporation
9 + * All Rights Reserved.
11 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
12 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
19 +#include <linux/config.h>
20 +#include <linux/init.h>
21 +#include <linux/module.h>
22 +#include <linux/kernel.h>
23 +#include <linux/string.h>
25 +#include <asm/uaccess.h>
27 +#include <typedefs.h>
29 +#include <bcmendian.h>
30 +#include <bcmutils.h>
32 +#define NVRAM_SIZE (0x1ff0)
33 +static char _nvdata[NVRAM_SIZE] __initdata;
34 +static char _valuestr[256] __initdata;
37 + * TLV types. These codes are used in the "type-length-value"
38 + * encoding of the items stored in the NVRAM device (flash or EEPROM)
40 + * The layout of the flash/nvram is as follows:
42 + * <type> <length> <data ...> <type> <length> <data ...> <type_end>
44 + * The type code of "ENV_TLV_TYPE_END" marks the end of the list.
45 + * The "length" field marks the length of the data section, not
46 + * including the type and length fields.
48 + * Environment variables are stored as follows:
50 + * <type_env> <length> <flags> <name> = <value>
52 + * If bit 0 (low bit) is set, the length is an 8-bit value.
53 + * If bit 0 (low bit) is clear, the length is a 16-bit value
55 + * Bit 7 set indicates "user" TLVs. In this case, bit 0 still
56 + * indicates the size of the length field.
58 + * Flags are from the constants below:
61 +#define ENV_LENGTH_16BITS 0x00 /* for low bit */
62 +#define ENV_LENGTH_8BITS 0x01
64 +#define ENV_TYPE_USER 0x80
66 +#define ENV_CODE_SYS(n,l) (((n)<<1)|(l))
67 +#define ENV_CODE_USER(n,l) ((((n)<<1)|(l)) | ENV_TYPE_USER)
70 + * The actual TLV types we support
73 +#define ENV_TLV_TYPE_END 0x00
74 +#define ENV_TLV_TYPE_ENV ENV_CODE_SYS(0,ENV_LENGTH_8BITS)
77 + * Environment variable flags
80 +#define ENV_FLG_NORMAL 0x00 /* normal read/write */
81 +#define ENV_FLG_BUILTIN 0x01 /* builtin - not stored in flash */
82 +#define ENV_FLG_READONLY 0x02 /* read-only - cannot be changed */
84 +#define ENV_FLG_MASK 0xFF /* mask of attributes we keep */
85 +#define ENV_FLG_ADMIN 0x100 /* lets us internally override permissions */
88 +/* *********************************************************************
89 + * _nvram_read(buffer,offset,length)
91 + * Read data from the NVRAM device
94 + * buffer - destination buffer
95 + * offset - offset of data to read
96 + * length - number of bytes to read
99 + * number of bytes read, or <0 if error occured
100 + ********************************************************************* */
102 +_nvram_read(unsigned char *nv_buf, unsigned char *buffer, int offset, int length)
105 + if (offset > NVRAM_SIZE)
108 + for ( i = 0; i < length; i++) {
109 + buffer[i] = ((volatile unsigned char*)nv_buf)[offset + i];
116 +_strnchr(const char *dest,int c,size_t cnt)
118 + while (*dest && (cnt > 0)) {
119 + if (*dest == c) return (char *) dest;
129 + * Core support API: Externally visible.
133 + * Get the value of an NVRAM variable
134 + * @param name name of variable to get
135 + * @return value of variable or NULL if undefined
139 +cfe_env_get(unsigned char *nv_buf, char* name)
142 + unsigned char *buffer;
143 + unsigned char *ptr;
144 + unsigned char *envval;
145 + unsigned int reclen;
146 + unsigned int rectype;
151 + buffer = &_nvdata[0];
156 + /* Read the record type and length */
157 + if (_nvram_read(nv_buf, ptr,offset,1) != 1) {
161 + while ((*ptr != ENV_TLV_TYPE_END) && (size > 1)) {
163 + /* Adjust pointer for TLV type */
169 + * Read the length. It can be either 1 or 2 bytes
170 + * depending on the code
172 + if (rectype & ENV_LENGTH_8BITS) {
173 + /* Read the record type and length - 8 bits */
174 + if (_nvram_read(nv_buf, ptr,offset,1) != 1) {
182 + /* Read the record type and length - 16 bits, MSB first */
183 + if (_nvram_read(nv_buf, ptr,offset,2) != 2) {
186 + reclen = (((unsigned int) *(ptr)) << 8) + (unsigned int) *(ptr+1);
192 + break; /* should not happen, bad NVRAM */
195 + case ENV_TLV_TYPE_ENV:
196 + /* Read the TLV data */
197 + if (_nvram_read(nv_buf, ptr,offset,reclen) != reclen)
200 + envval = (unsigned char *) _strnchr(ptr,'=',(reclen-1));
203 + memcpy(_valuestr,envval,(reclen-1)-(envval-ptr));
204 + _valuestr[(reclen-1)-(envval-ptr)] = '\0';
206 + printk(KERN_INFO "NVRAM:%s=%s\n", ptr, _valuestr);
208 + if(!strcmp(ptr, name)){
211 + if((strlen(ptr) > 1) && !strcmp(&ptr[1], name))
217 + /* Unknown TLV type, skip it. */
222 + * Advance to next TLV
225 + size -= (int)reclen;
228 + /* Read the next record type */
230 + if (_nvram_read(nv_buf, ptr,offset,1) != 1)
239 diff -Nur linux-2.4.32/arch/mips/bcm947xx/compressed/Makefile linux-2.4.32-brcm/arch/mips/bcm947xx/compressed/Makefile
240 --- linux-2.4.32/arch/mips/bcm947xx/compressed/Makefile 1970-01-01 01:00:00.000000000 +0100
241 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/compressed/Makefile 2005-12-16 23:39:10.668819500 +0100
244 +# Makefile for Broadcom BCM947XX boards
246 +# Copyright 2001-2003, Broadcom Corporation
247 +# All Rights Reserved.
249 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
250 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
251 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
252 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
254 +# $Id: Makefile,v 1.2 2005/04/02 12:12:57 wbx Exp $
257 +OBJCOPY_ARGS = -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
258 +SYSTEM ?= $(TOPDIR)/vmlinux
262 +# Don't build dependencies, this may die if $(CC) isn't gcc
265 +# Create a gzipped version named vmlinuz for compatibility
270 + $(OBJCOPY) $(OBJCOPY_ARGS) $< $@
275 + rm -f vmlinuz piggy
276 diff -Nur linux-2.4.32/arch/mips/bcm947xx/generic/int-handler.S linux-2.4.32-brcm/arch/mips/bcm947xx/generic/int-handler.S
277 --- linux-2.4.32/arch/mips/bcm947xx/generic/int-handler.S 1970-01-01 01:00:00.000000000 +0100
278 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/generic/int-handler.S 2005-12-16 23:39:10.668819500 +0100
281 + * Generic interrupt handler for Broadcom MIPS boards
283 + * Copyright 2004, Broadcom Corporation
284 + * All Rights Reserved.
286 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
287 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
288 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
289 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
291 + * $Id: int-handler.S,v 1.1 2005/03/16 13:50:00 wbx Exp $
294 +#include <linux/config.h>
296 +#include <asm/asm.h>
297 +#include <asm/mipsregs.h>
298 +#include <asm/regdef.h>
299 +#include <asm/stackframe.h>
304 + * 0 Software (ignored)
305 + * 1 Software (ignored)
306 + * 2 Combined hardware interrupt (hw0)
318 + NESTED(brcmIRQ, PT_SIZE, sp)
324 + jal brcm_irq_dispatch
331 diff -Nur linux-2.4.32/arch/mips/bcm947xx/generic/irq.c linux-2.4.32-brcm/arch/mips/bcm947xx/generic/irq.c
332 --- linux-2.4.32/arch/mips/bcm947xx/generic/irq.c 1970-01-01 01:00:00.000000000 +0100
333 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/generic/irq.c 2005-12-16 23:39:10.668819500 +0100
336 + * Generic interrupt control functions for Broadcom MIPS boards
338 + * Copyright 2004, Broadcom Corporation
339 + * All Rights Reserved.
341 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
342 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
343 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
344 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
346 + * $Id: irq.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
349 +#include <linux/config.h>
350 +#include <linux/init.h>
351 +#include <linux/kernel.h>
352 +#include <linux/types.h>
353 +#include <linux/interrupt.h>
354 +#include <linux/irq.h>
356 +#include <asm/irq.h>
357 +#include <asm/mipsregs.h>
358 +#include <asm/gdb-stub.h>
360 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
362 +extern asmlinkage void brcmIRQ(void);
363 +extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs);
366 +brcm_irq_dispatch(struct pt_regs *regs)
370 + cause = read_c0_cause() &
374 +#ifdef CONFIG_KERNPROF
375 + change_c0_status(cause | 1, 1);
377 + clear_c0_status(cause);
380 + if (cause & CAUSEF_IP7)
382 + if (cause & CAUSEF_IP2)
384 + if (cause & CAUSEF_IP3)
386 + if (cause & CAUSEF_IP4)
388 + if (cause & CAUSEF_IP5)
390 + if (cause & CAUSEF_IP6)
395 +enable_brcm_irq(unsigned int irq)
398 + set_c0_status(1 << (irq + 8));
400 + set_c0_status(IE_IRQ0);
404 +disable_brcm_irq(unsigned int irq)
407 + clear_c0_status(1 << (irq + 8));
409 + clear_c0_status(IE_IRQ0);
413 +ack_brcm_irq(unsigned int irq)
415 + /* Already done in brcm_irq_dispatch */
419 +startup_brcm_irq(unsigned int irq)
421 + enable_brcm_irq(irq);
423 + return 0; /* never anything pending */
427 +end_brcm_irq(unsigned int irq)
429 + if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
430 + enable_brcm_irq(irq);
433 +static struct hw_interrupt_type brcm_irq_type = {
435 + startup: startup_brcm_irq,
436 + shutdown: disable_brcm_irq,
437 + enable: enable_brcm_irq,
438 + disable: disable_brcm_irq,
449 + for (i = 0; i < NR_IRQS; i++) {
450 + irq_desc[i].status = IRQ_DISABLED;
451 + irq_desc[i].action = 0;
452 + irq_desc[i].depth = 1;
453 + irq_desc[i].handler = &brcm_irq_type;
456 + set_except_vector(0, brcmIRQ);
457 + change_c0_status(ST0_IM, ALLINTS);
459 +#ifdef CONFIG_REMOTE_DEBUG
460 + printk("Breaking into debugger...\n");
465 diff -Nur linux-2.4.32/arch/mips/bcm947xx/generic/Makefile linux-2.4.32-brcm/arch/mips/bcm947xx/generic/Makefile
466 --- linux-2.4.32/arch/mips/bcm947xx/generic/Makefile 1970-01-01 01:00:00.000000000 +0100
467 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/generic/Makefile 2005-12-16 23:39:10.668819500 +0100
470 +# Makefile for the BCM947xx specific kernel interface routines
475 + $(CPP) $(AFLAGS) $< -o $*.s
477 + $(CC) $(AFLAGS) -c $< -o $*.o
481 +obj-y := int-handler.o irq.o
483 +include $(TOPDIR)/Rules.make
484 diff -Nur linux-2.4.32/arch/mips/bcm947xx/gpio.c linux-2.4.32-brcm/arch/mips/bcm947xx/gpio.c
485 --- linux-2.4.32/arch/mips/bcm947xx/gpio.c 1970-01-01 01:00:00.000000000 +0100
486 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/gpio.c 2005-12-16 23:39:10.668819500 +0100
491 + * Copyright 2005, Broadcom Corporation
492 + * All Rights Reserved.
494 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
495 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
496 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
497 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
502 +#include <linux/module.h>
503 +#include <linux/init.h>
504 +#include <linux/fs.h>
505 +#include <linux/miscdevice.h>
506 +#include <asm/uaccess.h>
508 +#include <typedefs.h>
509 +#include <bcmutils.h>
510 +#include <sbutils.h>
511 +#include <bcmdevs.h>
513 +static sb_t *gpio_sbh;
514 +static int gpio_major;
515 +static devfs_handle_t gpio_dir;
518 + devfs_handle_t handle;
523 + { "control", NULL }
527 +gpio_open(struct inode *inode, struct file * file)
529 + if (MINOR(inode->i_rdev) > ARRAYSIZE(gpio_file))
537 +gpio_release(struct inode *inode, struct file * file)
544 +gpio_read(struct file *file, char *buf, size_t count, loff_t *ppos)
548 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
550 + val = sb_gpioin(gpio_sbh);
553 + val = sb_gpioout(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY);
556 + val = sb_gpioouten(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY);
559 + val = sb_gpiocontrol(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY);
565 + if (put_user(val, (u32 *) buf))
568 + return sizeof(val);
572 +gpio_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
576 + if (get_user(val, (u32 *) buf))
579 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
583 + sb_gpioout(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY);
586 + sb_gpioouten(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY);
589 + sb_gpiocontrol(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY);
595 + return sizeof(val);
598 +static struct file_operations gpio_fops = {
599 + owner: THIS_MODULE,
601 + release: gpio_release,
611 + if (!(gpio_sbh = sb_kattach()))
614 + sb_gpiosetcore(gpio_sbh);
616 + if ((gpio_major = devfs_register_chrdev(0, "gpio", &gpio_fops)) < 0)
619 + gpio_dir = devfs_mk_dir(NULL, "gpio", NULL);
621 + for (i = 0; i < ARRAYSIZE(gpio_file); i++) {
622 + gpio_file[i].handle = devfs_register(gpio_dir,
624 + DEVFS_FL_DEFAULT, gpio_major, i,
625 + S_IFCHR | S_IRUGO | S_IWUGO,
637 + for (i = 0; i < ARRAYSIZE(gpio_file); i++)
638 + devfs_unregister(gpio_file[i].handle);
639 + devfs_unregister(gpio_dir);
640 + devfs_unregister_chrdev(gpio_major, "gpio");
641 + sb_detach(gpio_sbh);
644 +module_init(gpio_init);
645 +module_exit(gpio_exit);
646 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmdevs.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmdevs.h
647 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmdevs.h 1970-01-01 01:00:00.000000000 +0100
648 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmdevs.h 2005-12-16 23:39:10.672819750 +0100
651 + * Broadcom device-specific manifest constants.
653 + * Copyright 2005, Broadcom Corporation
654 + * All Rights Reserved.
656 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
657 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
658 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
659 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
667 +/* Known PCI vendor Id's */
668 +#define VENDOR_EPIGRAM 0xfeda
669 +#define VENDOR_BROADCOM 0x14e4
670 +#define VENDOR_3COM 0x10b7
671 +#define VENDOR_NETGEAR 0x1385
672 +#define VENDOR_DIAMOND 0x1092
673 +#define VENDOR_DELL 0x1028
674 +#define VENDOR_HP 0x0e11
675 +#define VENDOR_APPLE 0x106b
677 +/* PCI Device Id's */
678 +#define BCM4210_DEVICE_ID 0x1072 /* never used */
679 +#define BCM4211_DEVICE_ID 0x4211
680 +#define BCM4230_DEVICE_ID 0x1086 /* never used */
681 +#define BCM4231_DEVICE_ID 0x4231
683 +#define BCM4410_DEVICE_ID 0x4410 /* bcm44xx family pci iline */
684 +#define BCM4430_DEVICE_ID 0x4430 /* bcm44xx family cardbus iline */
685 +#define BCM4412_DEVICE_ID 0x4412 /* bcm44xx family pci enet */
686 +#define BCM4432_DEVICE_ID 0x4432 /* bcm44xx family cardbus enet */
688 +#define BCM3352_DEVICE_ID 0x3352 /* bcm3352 device id */
689 +#define BCM3360_DEVICE_ID 0x3360 /* bcm3360 device id */
691 +#define EPI41210_DEVICE_ID 0xa0fa /* bcm4210 */
692 +#define EPI41230_DEVICE_ID 0xa10e /* bcm4230 */
694 +#define BCM47XX_ILINE_ID 0x4711 /* 47xx iline20 */
695 +#define BCM47XX_V90_ID 0x4712 /* 47xx v90 codec */
696 +#define BCM47XX_ENET_ID 0x4713 /* 47xx enet */
697 +#define BCM47XX_EXT_ID 0x4714 /* 47xx external i/f */
698 +#define BCM47XX_USB_ID 0x4715 /* 47xx usb */
699 +#define BCM47XX_USBH_ID 0x4716 /* 47xx usb host */
700 +#define BCM47XX_USBD_ID 0x4717 /* 47xx usb device */
701 +#define BCM47XX_IPSEC_ID 0x4718 /* 47xx ipsec */
702 +#define BCM47XX_ROBO_ID 0x4719 /* 47xx/53xx roboswitch core */
703 +#define BCM47XX_USB20H_ID 0x471a /* 47xx usb 2.0 host */
704 +#define BCM47XX_USB20D_ID 0x471b /* 47xx usb 2.0 device */
706 +#define BCM4710_DEVICE_ID 0x4710 /* 4710 primary function 0 */
708 +#define BCM4610_DEVICE_ID 0x4610 /* 4610 primary function 0 */
709 +#define BCM4610_ILINE_ID 0x4611 /* 4610 iline100 */
710 +#define BCM4610_V90_ID 0x4612 /* 4610 v90 codec */
711 +#define BCM4610_ENET_ID 0x4613 /* 4610 enet */
712 +#define BCM4610_EXT_ID 0x4614 /* 4610 external i/f */
713 +#define BCM4610_USB_ID 0x4615 /* 4610 usb */
715 +#define BCM4402_DEVICE_ID 0x4402 /* 4402 primary function 0 */
716 +#define BCM4402_ENET_ID 0x4402 /* 4402 enet */
717 +#define BCM4402_V90_ID 0x4403 /* 4402 v90 codec */
718 +#define BCM4401_ENET_ID 0x170c /* 4401b0 production enet cards */
720 +#define BCM4301_DEVICE_ID 0x4301 /* 4301 primary function 0 */
721 +#define BCM4301_D11B_ID 0x4301 /* 4301 802.11b */
723 +#define BCM4307_DEVICE_ID 0x4307 /* 4307 primary function 0 */
724 +#define BCM4307_V90_ID 0x4305 /* 4307 v90 codec */
725 +#define BCM4307_ENET_ID 0x4306 /* 4307 enet */
726 +#define BCM4307_D11B_ID 0x4307 /* 4307 802.11b */
728 +#define BCM4306_DEVICE_ID 0x4306 /* 4306 chipcommon chipid */
729 +#define BCM4306_D11G_ID 0x4320 /* 4306 802.11g */
730 +#define BCM4306_D11G_ID2 0x4325
731 +#define BCM4306_D11A_ID 0x4321 /* 4306 802.11a */
732 +#define BCM4306_UART_ID 0x4322 /* 4306 uart */
733 +#define BCM4306_V90_ID 0x4323 /* 4306 v90 codec */
734 +#define BCM4306_D11DUAL_ID 0x4324 /* 4306 dual A+B */
736 +#define BCM4309_PKG_ID 1 /* 4309 package id */
738 +#define BCM4303_D11B_ID 0x4303 /* 4303 802.11b */
739 +#define BCM4303_PKG_ID 2 /* 4303 package id */
741 +#define BCM4310_DEVICE_ID 0x4310 /* 4310 chipcommon chipid */
742 +#define BCM4310_D11B_ID 0x4311 /* 4310 802.11b */
743 +#define BCM4310_UART_ID 0x4312 /* 4310 uart */
744 +#define BCM4310_ENET_ID 0x4313 /* 4310 enet */
745 +#define BCM4310_USB_ID 0x4315 /* 4310 usb */
747 +#define BCMGPRS_UART_ID 0x4333 /* Uart id used by 4306/gprs card */
748 +#define BCMGPRS2_UART_ID 0x4344 /* Uart id used by 4306/gprs card */
751 +#define BCM4704_DEVICE_ID 0x4704 /* 4704 chipcommon chipid */
752 +#define BCM4704_ENET_ID 0x4706 /* 4704 enet (Use 47XX_ENET_ID instead!) */
754 +#define BCM4317_DEVICE_ID 0x4317 /* 4317 chip common chipid */
756 +#define BCM4318_DEVICE_ID 0x4318 /* 4318 chip common chipid */
757 +#define BCM4318_D11G_ID 0x4318 /* 4318 801.11b/g id */
758 +#define BCM4318_D11DUAL_ID 0x4319 /* 4318 801.11a/b/g id */
759 +#define BCM4318_JTAGM_ID 0x4331 /* 4318 jtagm device id */
761 +#define FPGA_JTAGM_ID 0x4330 /* ??? */
764 +#define BCM4710_SDRAM 0x00000000 /* Physical SDRAM */
765 +#define BCM4710_PCI_MEM 0x08000000 /* Host Mode PCI memory access space (64 MB) */
766 +#define BCM4710_PCI_CFG 0x0c000000 /* Host Mode PCI configuration space (64 MB) */
767 +#define BCM4710_PCI_DMA 0x40000000 /* Client Mode PCI memory access space (1 GB) */
768 +#define BCM4710_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
769 +#define BCM4710_ENUM 0x18000000 /* Beginning of core enumeration space */
771 +/* Core register space */
772 +#define BCM4710_REG_SDRAM 0x18000000 /* SDRAM core registers */
773 +#define BCM4710_REG_ILINE20 0x18001000 /* InsideLine20 core registers */
774 +#define BCM4710_REG_EMAC0 0x18002000 /* Ethernet MAC 0 core registers */
775 +#define BCM4710_REG_CODEC 0x18003000 /* Codec core registers */
776 +#define BCM4710_REG_USB 0x18004000 /* USB core registers */
777 +#define BCM4710_REG_PCI 0x18005000 /* PCI core registers */
778 +#define BCM4710_REG_MIPS 0x18006000 /* MIPS core registers */
779 +#define BCM4710_REG_EXTIF 0x18007000 /* External Interface core registers */
780 +#define BCM4710_REG_EMAC1 0x18008000 /* Ethernet MAC 1 core registers */
782 +#define BCM4710_EXTIF 0x1f000000 /* External Interface base address */
783 +#define BCM4710_PCMCIA_MEM 0x1f000000 /* External Interface PCMCIA memory access */
784 +#define BCM4710_PCMCIA_IO 0x1f100000 /* PCMCIA I/O access */
785 +#define BCM4710_PCMCIA_CONF 0x1f200000 /* PCMCIA configuration */
786 +#define BCM4710_PROG 0x1f800000 /* Programable interface */
787 +#define BCM4710_FLASH 0x1fc00000 /* Flash */
789 +#define BCM4710_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
791 +#define BCM4710_UART (BCM4710_REG_EXTIF + 0x00000300)
793 +#define BCM4710_EUART (BCM4710_EXTIF + 0x00800000)
794 +#define BCM4710_LED (BCM4710_EXTIF + 0x00900000)
796 +#define BCM4712_DEVICE_ID 0x4712 /* 4712 chipcommon chipid */
797 +#define BCM4712_MIPS_ID 0x4720 /* 4712 base devid */
798 +#define BCM4712LARGE_PKG_ID 0 /* 340pin 4712 package id */
799 +#define BCM4712SMALL_PKG_ID 1 /* 200pin 4712 package id */
800 +#define BCM4712MID_PKG_ID 2 /* 225pin 4712 package id */
802 +#define SDIOH_FPGA_ID 0x4380 /* sdio host fpga */
804 +#define BCM5365_DEVICE_ID 0x5365 /* 5365 chipcommon chipid */
805 +#define BCM5350_DEVICE_ID 0x5350 /* bcm5350 chipcommon chipid */
806 +#define BCM5352_DEVICE_ID 0x5352 /* bcm5352 chipcommon chipid */
808 +#define BCM4320_DEVICE_ID 0x4320 /* bcm4320 chipcommon chipid */
810 +/* PCMCIA vendor Id's */
812 +#define VENDOR_BROADCOM_PCMCIA 0x02d0
814 +/* SDIO vendor Id's */
815 +#define VENDOR_BROADCOM_SDIO 0x00BF
819 +#define BFL_BTCOEXIST 0x0001 /* This board implements Bluetooth coexistance */
820 +#define BFL_PACTRL 0x0002 /* This board has gpio 9 controlling the PA */
821 +#define BFL_AIRLINEMODE 0x0004 /* This board implements gpio13 radio disable indication */
822 +#define BFL_ENETROBO 0x0010 /* This board has robo switch or core */
823 +#define BFL_CCKHIPWR 0x0040 /* Can do high-power CCK transmission */
824 +#define BFL_ENETADM 0x0080 /* This board has ADMtek switch */
825 +#define BFL_ENETVLAN 0x0100 /* This board has vlan capability */
826 +#define BFL_AFTERBURNER 0x0200 /* This board supports Afterburner mode */
827 +#define BFL_NOPCI 0x0400 /* This board leaves PCI floating */
828 +#define BFL_FEM 0x0800 /* This board supports the Front End Module */
829 +#define BFL_EXTLNA 0x1000 /* This board has an external LNA */
830 +#define BFL_HGPA 0x2000 /* This board has a high gain PA */
831 +#define BFL_BTCMOD 0x4000 /* This board' BTCOEXIST is in the alternate gpios */
832 +#define BFL_ALTIQ 0x8000 /* Alternate I/Q settings */
834 +/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */
835 +#define BOARD_GPIO_HWRAD_B 0x010 /* bit 4 is HWRAD input on 4301 */
836 +#define BOARD_GPIO_BTCMOD_IN 0x010 /* bit 4 is the alternate BT Coexistance Input */
837 +#define BOARD_GPIO_BTCMOD_OUT 0x020 /* bit 5 is the alternate BT Coexistance Out */
838 +#define BOARD_GPIO_BTC_IN 0x080 /* bit 7 is BT Coexistance Input */
839 +#define BOARD_GPIO_BTC_OUT 0x100 /* bit 8 is BT Coexistance Out */
840 +#define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */
841 +#define PCI_CFG_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */
842 +#define PCI_CFG_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */
843 +#define PCI_CFG_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
844 +#define PCI_CFG_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
847 +#define SB_BUS 0 /* Silicon Backplane */
848 +#define PCI_BUS 1 /* PCI target */
849 +#define PCMCIA_BUS 2 /* PCMCIA target */
850 +#define SDIO_BUS 3 /* SDIO target */
851 +#define JTAG_BUS 4 /* JTAG */
853 +/* Allows optimization for single-bus support */
855 +#define BUSTYPE(bus) (BCMBUSTYPE)
857 +#define BUSTYPE(bus) (bus)
860 +/* power control defines */
861 +#define PLL_DELAY 150 /* us pll on delay */
862 +#define FREF_DELAY 200 /* us fref change delay */
863 +#define MIN_SLOW_CLK 32 /* us Slow clock period */
864 +#define XTAL_ON_DELAY 1000 /* us crystal power-on delay */
866 +/* Reference Board Types */
868 +#define BU4710_BOARD 0x0400
869 +#define VSIM4710_BOARD 0x0401
870 +#define QT4710_BOARD 0x0402
872 +#define BU4610_BOARD 0x0403
873 +#define VSIM4610_BOARD 0x0404
875 +#define BU4307_BOARD 0x0405
876 +#define BCM94301CB_BOARD 0x0406
877 +#define BCM94301PC_BOARD 0x0406 /* Pcmcia 5v card */
878 +#define BCM94301MP_BOARD 0x0407
879 +#define BCM94307MP_BOARD 0x0408
880 +#define BCMAP4307_BOARD 0x0409
882 +#define BU4309_BOARD 0x040a
883 +#define BCM94309CB_BOARD 0x040b
884 +#define BCM94309MP_BOARD 0x040c
885 +#define BCM4309AP_BOARD 0x040d
887 +#define BCM94302MP_BOARD 0x040e
889 +#define VSIM4310_BOARD 0x040f
890 +#define BU4711_BOARD 0x0410
891 +#define BCM94310U_BOARD 0x0411
892 +#define BCM94310AP_BOARD 0x0412
893 +#define BCM94310MP_BOARD 0x0414
895 +#define BU4306_BOARD 0x0416
896 +#define BCM94306CB_BOARD 0x0417
897 +#define BCM94306MP_BOARD 0x0418
899 +#define BCM94710D_BOARD 0x041a
900 +#define BCM94710R1_BOARD 0x041b
901 +#define BCM94710R4_BOARD 0x041c
902 +#define BCM94710AP_BOARD 0x041d
905 +#define BU2050_BOARD 0x041f
908 +#define BCM94309G_BOARD 0x0421
910 +#define BCM94301PC3_BOARD 0x0422 /* Pcmcia 3.3v card */
912 +#define BU4704_BOARD 0x0423
913 +#define BU4702_BOARD 0x0424
915 +#define BCM94306PC_BOARD 0x0425 /* pcmcia 3.3v 4306 card */
917 +#define BU4317_BOARD 0x0426
920 +#define BCM94702MN_BOARD 0x0428
922 +/* BCM4702 1U CompactPCI Board */
923 +#define BCM94702CPCI_BOARD 0x0429
925 +/* BCM4702 with BCM95380 VLAN Router */
926 +#define BCM95380RR_BOARD 0x042a
928 +/* cb4306 with SiGe PA */
929 +#define BCM94306CBSG_BOARD 0x042b
931 +/* mp4301 with 2050 radio */
932 +#define BCM94301MPL_BOARD 0x042c
934 +/* cb4306 with SiGe PA */
935 +#define PCSG94306_BOARD 0x042d
937 +/* bu4704 with sdram */
938 +#define BU4704SD_BOARD 0x042e
940 +/* Dual 11a/11g Router */
941 +#define BCM94704AGR_BOARD 0x042f
943 +/* 11a-only minipci */
944 +#define BCM94308MP_BOARD 0x0430
948 +/* BCM94317 boards */
949 +#define BCM94317CB_BOARD 0x0440
950 +#define BCM94317MP_BOARD 0x0441
951 +#define BCM94317PCMCIA_BOARD 0x0442
952 +#define BCM94317SDIO_BOARD 0x0443
954 +#define BU4712_BOARD 0x0444
955 +#define BU4712SD_BOARD 0x045d
956 +#define BU4712L_BOARD 0x045f
958 +/* BCM4712 boards */
959 +#define BCM94712AP_BOARD 0x0445
960 +#define BCM94712P_BOARD 0x0446
962 +/* BCM4318 boards */
963 +#define BU4318_BOARD 0x0447
964 +#define CB4318_BOARD 0x0448
965 +#define MPG4318_BOARD 0x0449
966 +#define MP4318_BOARD 0x044a
967 +#define SD4318_BOARD 0x044b
969 +/* BCM63XX boards */
970 +#define BCM96338_BOARD 0x6338
971 +#define BCM96345_BOARD 0x6345
972 +#define BCM96348_BOARD 0x6348
974 +/* Another mp4306 with SiGe */
975 +#define BCM94306P_BOARD 0x044c
977 +/* CF-like 4317 modules */
978 +#define BCM94317CF_BOARD 0x044d
981 +#define BCM94303MP_BOARD 0x044e
984 +#define BCM94306MPSGH_BOARD 0x044f
986 +/* BRCM 4306 w/ Front End Modules */
987 +#define BCM94306MPM 0x0450
988 +#define BCM94306MPL 0x0453
991 +#define BCM94712AGR_BOARD 0x0451
993 +/* The real CF 4317 board */
994 +#define CFI4317_BOARD 0x0452
997 +#define PC4303_BOARD 0x0454
1000 +#define BCM95350K_BOARD 0x0455
1003 +#define BCM95350R_BOARD 0x0456
1006 +#define BCM94306MPLNA_BOARD 0x0457
1009 +#define BU4320_BOARD 0x0458
1010 +#define BU4320S_BOARD 0x0459
1011 +#define BCM94320PH_BOARD 0x045a
1014 +#define BCM94306MPH_BOARD 0x045b
1017 +#define BCM94306PCIV_BOARD 0x045c
1019 +#define BU4712SD_BOARD 0x045d
1021 +#define BCM94320PFLSH_BOARD 0x045e
1023 +#define BU4712L_BOARD 0x045f
1024 +#define BCM94712LGR_BOARD 0x0460
1025 +#define BCM94320R_BOARD 0x0461
1027 +#define BU5352_BOARD 0x0462
1029 +#define BCM94318MPGH_BOARD 0x0463
1032 +#define BCM95352GR_BOARD 0x0467
1035 +#define BCM95351AGR_BOARD 0x0470
1037 +/* # of GPIO pins */
1038 +#define GPIO_NUMPINS 16
1040 +#endif /* _BCMDEVS_H */
1041 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmendian.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmendian.h
1042 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmendian.h 1970-01-01 01:00:00.000000000 +0100
1043 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmendian.h 2005-12-16 23:39:10.672819750 +0100
1046 + * local version of endian.h - byte order defines
1048 + * Copyright 2005, Broadcom Corporation
1049 + * All Rights Reserved.
1051 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1052 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1053 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1054 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1059 +#ifndef _BCMENDIAN_H_
1060 +#define _BCMENDIAN_H_
1062 +#include <typedefs.h>
1064 +/* Byte swap a 16 bit value */
1065 +#define BCMSWAP16(val) \
1067 + (((uint16)(val) & (uint16)0x00ffU) << 8) | \
1068 + (((uint16)(val) & (uint16)0xff00U) >> 8) ))
1070 +/* Byte swap a 32 bit value */
1071 +#define BCMSWAP32(val) \
1073 + (((uint32)(val) & (uint32)0x000000ffUL) << 24) | \
1074 + (((uint32)(val) & (uint32)0x0000ff00UL) << 8) | \
1075 + (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) | \
1076 + (((uint32)(val) & (uint32)0xff000000UL) >> 24) ))
1078 +/* 2 Byte swap a 32 bit value */
1079 +#define BCMSWAP32BY16(val) \
1081 + (((uint32)(val) & (uint32)0x0000ffffUL) << 16) | \
1082 + (((uint32)(val) & (uint32)0xffff0000UL) >> 16) ))
1085 +static INLINE uint16
1086 +bcmswap16(uint16 val)
1088 + return BCMSWAP16(val);
1091 +static INLINE uint32
1092 +bcmswap32(uint32 val)
1094 + return BCMSWAP32(val);
1097 +static INLINE uint32
1098 +bcmswap32by16(uint32 val)
1100 + return BCMSWAP32BY16(val);
1103 +/* buf - start of buffer of shorts to swap */
1104 +/* len - byte length of buffer */
1106 +bcmswap16_buf(uint16 *buf, uint len)
1111 + *buf = bcmswap16(*buf);
1117 +#ifndef IL_BIGENDIAN
1118 +#define HTON16(i) BCMSWAP16(i)
1119 +#define hton16(i) bcmswap16(i)
1120 +#define hton32(i) bcmswap32(i)
1121 +#define ntoh16(i) bcmswap16(i)
1122 +#define ntoh32(i) bcmswap32(i)
1123 +#define ltoh16(i) (i)
1124 +#define ltoh32(i) (i)
1125 +#define htol16(i) (i)
1126 +#define htol32(i) (i)
1128 +#define HTON16(i) (i)
1129 +#define hton16(i) (i)
1130 +#define hton32(i) (i)
1131 +#define ntoh16(i) (i)
1132 +#define ntoh32(i) (i)
1133 +#define ltoh16(i) bcmswap16(i)
1134 +#define ltoh32(i) bcmswap32(i)
1135 +#define htol16(i) bcmswap16(i)
1136 +#define htol32(i) bcmswap32(i)
1140 +#ifndef IL_BIGENDIAN
1141 +#define ltoh16_buf(buf, i)
1142 +#define htol16_buf(buf, i)
1144 +#define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
1145 +#define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
1149 +* load 16-bit value from unaligned little endian byte array.
1151 +static INLINE uint16
1152 +ltoh16_ua(uint8 *bytes)
1154 + return (bytes[1]<<8)+bytes[0];
1158 +* load 32-bit value from unaligned little endian byte array.
1160 +static INLINE uint32
1161 +ltoh32_ua(uint8 *bytes)
1163 + return (bytes[3]<<24)+(bytes[2]<<16)+(bytes[1]<<8)+bytes[0];
1167 +* load 16-bit value from unaligned big(network) endian byte array.
1169 +static INLINE uint16
1170 +ntoh16_ua(uint8 *bytes)
1172 + return (bytes[0]<<8)+bytes[1];
1176 +* load 32-bit value from unaligned big(network) endian byte array.
1178 +static INLINE uint32
1179 +ntoh32_ua(uint8 *bytes)
1181 + return (bytes[0]<<24)+(bytes[1]<<16)+(bytes[2]<<8)+bytes[3];
1184 +#define ltoh_ua(ptr) ( \
1185 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
1186 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] : \
1187 + (((uint8 *)ptr)[3]<<24)+(((uint8 *)ptr)[2]<<16)+(((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] \
1190 +#define ntoh_ua(ptr) ( \
1191 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
1192 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[0]<<8)+((uint8 *)ptr)[1] : \
1193 + (((uint8 *)ptr)[0]<<24)+(((uint8 *)ptr)[1]<<16)+(((uint8 *)ptr)[2]<<8)+((uint8 *)ptr)[3] \
1196 +#endif /* _BCMENDIAN_H_ */
1197 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmenet47xx.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmenet47xx.h
1198 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmenet47xx.h 1970-01-01 01:00:00.000000000 +0100
1199 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmenet47xx.h 2005-12-16 23:39:10.700821500 +0100
1202 + * Hardware-specific definitions for
1203 + * Broadcom BCM47XX 10/100 Mbps Ethernet cores.
1205 + * Copyright 2005, Broadcom Corporation
1206 + * All Rights Reserved.
1208 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1209 + * the contents of this file may not be disclosed to third parties, copied
1210 + * or duplicated in any form, in whole or in part, without the prior
1211 + * written permission of Broadcom Corporation.
1215 +#ifndef _bcmenet_47xx_h_
1216 +#define _bcmenet_47xx_h_
1218 +#include <bcmenetmib.h>
1219 +#include <bcmenetrxh.h>
1220 +#include <bcmenetphy.h>
1222 +#define BCMENET_NFILTERS 64 /* # ethernet address filter entries */
1223 +#define BCMENET_MCHASHBASE 0x200 /* multicast hash filter base address */
1224 +#define BCMENET_MCHASHSIZE 256 /* multicast hash filter size in bytes */
1225 +#define BCMENET_MAX_DMA 4096 /* chip has 12 bits of DMA addressing */
1227 +/* power management event wakeup pattern constants */
1228 +#define BCMENET_NPMP 4 /* chip supports 4 wakeup patterns */
1229 +#define BCMENET_PMPBASE 0x400 /* wakeup pattern base address */
1230 +#define BCMENET_PMPSIZE 0x80 /* 128bytes each pattern */
1231 +#define BCMENET_PMMBASE 0x600 /* wakeup mask base address */
1232 +#define BCMENET_PMMSIZE 0x10 /* 128bits each mask */
1234 +/* cpp contortions to concatenate w/arg prescan */
1236 +#define _PADLINE(line) pad ## line
1237 +#define _XSTR(line) _PADLINE(line)
1238 +#define PAD _XSTR(__LINE__)
1242 + * Host Interface Registers
1244 +typedef volatile struct _bcmenettregs {
1245 + /* Device and Power Control */
1246 + uint32 devcontrol;
1248 + uint32 biststatus;
1249 + uint32 wakeuplength;
1252 + /* Interrupt Control */
1258 + /* Ethernet MAC Address Filtering Control */
1260 + uint32 enetftaddr;
1261 + uint32 enetftdata;
1264 + /* Ethernet MAC Control */
1265 + uint32 emactxmaxburstlen;
1266 + uint32 emacrxmaxburstlen;
1267 + uint32 emaccontrol;
1268 + uint32 emacflowcontrol;
1272 + /* DMA Lazy Interrupt Control */
1273 + uint32 intrecvlazy;
1277 + dma32regp_t dmaregs;
1278 + dma32diag_t dmafifo;
1281 + /* EMAC Registers */
1283 + uint32 rxmaxlength;
1284 + uint32 txmaxlength;
1286 + uint32 mdiocontrol;
1288 + uint32 emacintmask;
1289 + uint32 emacintstatus;
1292 + uint32 camcontrol;
1293 + uint32 enetcontrol;
1295 + uint32 txwatermark;
1296 + uint32 mibcontrol;
1299 + /* EMAC MIB counters */
1304 + /* Sonics SiliconBackplane config registers */
1305 + sbconfig_t sbconfig;
1308 +/* device control */
1309 +#define DC_PM ((uint32)1 << 7) /* pattern filtering enable */
1310 +#define DC_IP ((uint32)1 << 10) /* internal ephy present (rev >= 1) */
1311 +#define DC_ER ((uint32)1 << 15) /* ephy reset */
1312 +#define DC_MP ((uint32)1 << 16) /* mii phy mode enable */
1313 +#define DC_CO ((uint32)1 << 17) /* mii phy mode: enable clocks */
1314 +#define DC_PA_MASK 0x7c0000 /* mii phy mode: mdc/mdio phy address */
1315 +#define DC_PA_SHIFT 18
1316 +#define DC_FS_MASK 0x03800000 /* fifo size (rev >= 8) */
1317 +#define DC_FS_SHIFT 23
1318 +#define DC_FS_4K 0 /* 4Kbytes */
1319 +#define DC_FS_512 1 /* 512bytes */
1321 +/* wakeup length */
1322 +#define WL_P0_MASK 0x7f /* pattern 0 */
1323 +#define WL_D0 ((uint32)1 << 7)
1324 +#define WL_P1_MASK 0x7f00 /* pattern 1 */
1325 +#define WL_P1_SHIFT 8
1326 +#define WL_D1 ((uint32)1 << 15)
1327 +#define WL_P2_MASK 0x7f0000 /* pattern 2 */
1328 +#define WL_P2_SHIFT 16
1329 +#define WL_D2 ((uint32)1 << 23)
1330 +#define WL_P3_MASK 0x7f000000 /* pattern 3 */
1331 +#define WL_P3_SHIFT 24
1332 +#define WL_D3 ((uint32)1 << 31)
1334 +/* intstatus and intmask */
1335 +#define I_PME ((uint32)1 << 6) /* power management event */
1336 +#define I_TO ((uint32)1 << 7) /* general purpose timeout */
1337 +#define I_PC ((uint32)1 << 10) /* descriptor error */
1338 +#define I_PD ((uint32)1 << 11) /* data error */
1339 +#define I_DE ((uint32)1 << 12) /* descriptor protocol error */
1340 +#define I_RU ((uint32)1 << 13) /* receive descriptor underflow */
1341 +#define I_RO ((uint32)1 << 14) /* receive fifo overflow */
1342 +#define I_XU ((uint32)1 << 15) /* transmit fifo underflow */
1343 +#define I_RI ((uint32)1 << 16) /* receive interrupt */
1344 +#define I_XI ((uint32)1 << 24) /* transmit interrupt */
1345 +#define I_EM ((uint32)1 << 26) /* emac interrupt */
1346 +#define I_MW ((uint32)1 << 27) /* mii write */
1347 +#define I_MR ((uint32)1 << 28) /* mii read */
1350 +#define EMC_CG ((uint32)1 << 0) /* crc32 generation enable */
1351 +#define EMC_EP ((uint32)1 << 2) /* onchip ephy: powerdown (rev >= 1) */
1352 +#define EMC_ED ((uint32)1 << 3) /* onchip ephy: energy detected (rev >= 1) */
1353 +#define EMC_LC_MASK 0xe0 /* onchip ephy: led control (rev >= 1) */
1354 +#define EMC_LC_SHIFT 5
1356 +/* emacflowcontrol */
1357 +#define EMF_RFH_MASK 0xff /* rx fifo hi water mark */
1358 +#define EMF_PG ((uint32)1 << 15) /* enable pause frame generation */
1360 +/* interrupt receive lazy */
1361 +#define IRL_TO_MASK 0x00ffffff /* timeout */
1362 +#define IRL_FC_MASK 0xff000000 /* frame count */
1363 +#define IRL_FC_SHIFT 24 /* frame count */
1365 +/* emac receive config */
1366 +#define ERC_DB ((uint32)1 << 0) /* disable broadcast */
1367 +#define ERC_AM ((uint32)1 << 1) /* accept all multicast */
1368 +#define ERC_RDT ((uint32)1 << 2) /* receive disable while transmitting */
1369 +#define ERC_PE ((uint32)1 << 3) /* promiscuous enable */
1370 +#define ERC_LE ((uint32)1 << 4) /* loopback enable */
1371 +#define ERC_FE ((uint32)1 << 5) /* enable flow control */
1372 +#define ERC_UF ((uint32)1 << 6) /* accept unicast flow control frame */
1373 +#define ERC_RF ((uint32)1 << 7) /* reject filter */
1374 +#define ERC_CA ((uint32)1 << 8) /* cam absent */
1376 +/* emac mdio control */
1377 +#define MC_MF_MASK 0x7f /* mdc frequency */
1378 +#define MC_PE ((uint32)1 << 7) /* mii preamble enable */
1380 +/* emac mdio data */
1381 +#define MD_DATA_MASK 0xffff /* r/w data */
1382 +#define MD_TA_MASK 0x30000 /* turnaround value */
1383 +#define MD_TA_SHIFT 16
1384 +#define MD_TA_VALID (2 << MD_TA_SHIFT) /* valid ta */
1385 +#define MD_RA_MASK 0x7c0000 /* register address */
1386 +#define MD_RA_SHIFT 18
1387 +#define MD_PMD_MASK 0xf800000 /* physical media device */
1388 +#define MD_PMD_SHIFT 23
1389 +#define MD_OP_MASK 0x30000000 /* opcode */
1390 +#define MD_OP_SHIFT 28
1391 +#define MD_OP_WRITE (1 << MD_OP_SHIFT) /* write op */
1392 +#define MD_OP_READ (2 << MD_OP_SHIFT) /* read op */
1393 +#define MD_SB_MASK 0xc0000000 /* start bits */
1394 +#define MD_SB_SHIFT 30
1395 +#define MD_SB_START (0x1 << MD_SB_SHIFT) /* start of frame */
1397 +/* emac intstatus and intmask */
1398 +#define EI_MII ((uint32)1 << 0) /* mii mdio interrupt */
1399 +#define EI_MIB ((uint32)1 << 1) /* mib interrupt */
1400 +#define EI_FLOW ((uint32)1 << 2) /* flow control interrupt */
1402 +/* emac cam data high */
1403 +#define CD_V ((uint32)1 << 16) /* valid bit */
1405 +/* emac cam control */
1406 +#define CC_CE ((uint32)1 << 0) /* cam enable */
1407 +#define CC_MS ((uint32)1 << 1) /* mask select */
1408 +#define CC_RD ((uint32)1 << 2) /* read */
1409 +#define CC_WR ((uint32)1 << 3) /* write */
1410 +#define CC_INDEX_MASK 0x3f0000 /* index */
1411 +#define CC_INDEX_SHIFT 16
1412 +#define CC_CB ((uint32)1 << 31) /* cam busy */
1414 +/* emac ethernet control */
1415 +#define EC_EE ((uint32)1 << 0) /* emac enable */
1416 +#define EC_ED ((uint32)1 << 1) /* emac disable */
1417 +#define EC_ES ((uint32)1 << 2) /* emac soft reset */
1418 +#define EC_EP ((uint32)1 << 3) /* external phy select */
1420 +/* emac transmit control */
1421 +#define EXC_FD ((uint32)1 << 0) /* full duplex */
1422 +#define EXC_FM ((uint32)1 << 1) /* flowmode */
1423 +#define EXC_SB ((uint32)1 << 2) /* single backoff enable */
1424 +#define EXC_SS ((uint32)1 << 3) /* small slottime */
1426 +/* emac mib control */
1427 +#define EMC_RZ ((uint32)1 << 0) /* autoclear on read */
1429 +#endif /* _bcmenet_47xx_h_ */
1430 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmenetmib.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmenetmib.h
1431 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmenetmib.h 1970-01-01 01:00:00.000000000 +0100
1432 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmenetmib.h 2005-12-16 23:39:10.700821500 +0100
1435 + * Hardware-specific MIB definition for
1436 + * Broadcom Home Networking Division
1437 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1439 + * Copyright 2005, Broadcom Corporation
1440 + * All Rights Reserved.
1442 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1443 + * the contents of this file may not be disclosed to third parties, copied
1444 + * or duplicated in any form, in whole or in part, without the prior
1445 + * written permission of Broadcom Corporation.
1449 +#ifndef _bcmenetmib_h_
1450 +#define _bcmenetmib_h_
1452 +/* cpp contortions to concatenate w/arg prescan */
1454 +#define _PADLINE(line) pad ## line
1455 +#define _XSTR(line) _PADLINE(line)
1456 +#define PAD _XSTR(__LINE__)
1460 + * EMAC MIB Registers
1462 +typedef volatile struct {
1463 + uint32 tx_good_octets;
1464 + uint32 tx_good_pkts;
1467 + uint32 tx_broadcast_pkts;
1468 + uint32 tx_multicast_pkts;
1470 + uint32 tx_len_65_to_127;
1471 + uint32 tx_len_128_to_255;
1472 + uint32 tx_len_256_to_511;
1473 + uint32 tx_len_512_to_1023;
1474 + uint32 tx_len_1024_to_max;
1475 + uint32 tx_jabber_pkts;
1476 + uint32 tx_oversize_pkts;
1477 + uint32 tx_fragment_pkts;
1478 + uint32 tx_underruns;
1479 + uint32 tx_total_cols;
1480 + uint32 tx_single_cols;
1481 + uint32 tx_multiple_cols;
1482 + uint32 tx_excessive_cols;
1483 + uint32 tx_late_cols;
1484 + uint32 tx_defered;
1485 + uint32 tx_carrier_lost;
1486 + uint32 tx_pause_pkts;
1489 + uint32 rx_good_octets;
1490 + uint32 rx_good_pkts;
1493 + uint32 rx_broadcast_pkts;
1494 + uint32 rx_multicast_pkts;
1496 + uint32 rx_len_65_to_127;
1497 + uint32 rx_len_128_to_255;
1498 + uint32 rx_len_256_to_511;
1499 + uint32 rx_len_512_to_1023;
1500 + uint32 rx_len_1024_to_max;
1501 + uint32 rx_jabber_pkts;
1502 + uint32 rx_oversize_pkts;
1503 + uint32 rx_fragment_pkts;
1504 + uint32 rx_missed_pkts;
1505 + uint32 rx_crc_align_errs;
1506 + uint32 rx_undersize;
1507 + uint32 rx_crc_errs;
1508 + uint32 rx_align_errs;
1509 + uint32 rx_symbol_errs;
1510 + uint32 rx_pause_pkts;
1511 + uint32 rx_nonpause_pkts;
1514 +#endif /* _bcmenetmib_h_ */
1515 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmenetphy.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmenetphy.h
1516 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmenetphy.h 1970-01-01 01:00:00.000000000 +0100
1517 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmenetphy.h 2005-12-16 23:39:10.700821500 +0100
1520 + * Misc Broadcom BCM47XX MDC/MDIO enet phy definitions.
1522 + * Copyright 2005, Broadcom Corporation
1523 + * All Rights Reserved.
1525 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1526 + * the contents of this file may not be disclosed to third parties, copied
1527 + * or duplicated in any form, in whole or in part, without the prior
1528 + * written permission of Broadcom Corporation.
1532 +#ifndef _bcmenetphy_h_
1533 +#define _bcmenetphy_h_
1536 +#define MAXEPHY 32 /* mdio phy addresses are 5bit quantities */
1537 +#define EPHY_MASK 0x1f
1538 +#define EPHY_NONE 31 /* nvram: no phy present at all */
1539 +#define EPHY_NOREG 30 /* nvram: no local phy regs */
1541 +/* just a few phy registers */
1542 +#define CTL_RESET (1 << 15) /* reset */
1543 +#define CTL_LOOP (1 << 14) /* loopback */
1544 +#define CTL_SPEED (1 << 13) /* speed selection 0=10, 1=100 */
1545 +#define CTL_ANENAB (1 << 12) /* autonegotiation enable */
1546 +#define CTL_RESTART (1 << 9) /* restart autonegotiation */
1547 +#define CTL_DUPLEX (1 << 8) /* duplex mode 0=half, 1=full */
1549 +#define ADV_10FULL (1 << 6) /* autonegotiate advertise 10full */
1550 +#define ADV_10HALF (1 << 5) /* autonegotiate advertise 10half */
1551 +#define ADV_100FULL (1 << 8) /* autonegotiate advertise 100full */
1552 +#define ADV_100HALF (1 << 7) /* autonegotiate advertise 100half */
1554 +/* link partner ability register */
1555 +#define LPA_SLCT 0x001f /* same as advertise selector */
1556 +#define LPA_10HALF 0x0020 /* can do 10mbps half-duplex */
1557 +#define LPA_10FULL 0x0040 /* can do 10mbps full-duplex */
1558 +#define LPA_100HALF 0x0080 /* can do 100mbps half-duplex */
1559 +#define LPA_100FULL 0x0100 /* can do 100mbps full-duplex */
1560 +#define LPA_100BASE4 0x0200 /* can do 100mbps 4k packets */
1561 +#define LPA_RESV 0x1c00 /* unused */
1562 +#define LPA_RFAULT 0x2000 /* link partner faulted */
1563 +#define LPA_LPACK 0x4000 /* link partner acked us */
1564 +#define LPA_NPAGE 0x8000 /* next page bit */
1566 +#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
1567 +#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
1569 +#define STAT_REMFAULT (1 << 4) /* remote fault */
1570 +#define STAT_LINK (1 << 2) /* link status */
1571 +#define STAT_JAB (1 << 1) /* jabber detected */
1572 +#define AUX_FORCED (1 << 2) /* forced 10/100 */
1573 +#define AUX_SPEED (1 << 1) /* speed 0=10mbps 1=100mbps */
1574 +#define AUX_DUPLEX (1 << 0) /* duplex 0=half 1=full */
1576 +#endif /* _bcmenetphy_h_ */
1577 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmenetrxh.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmenetrxh.h
1578 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmenetrxh.h 1970-01-01 01:00:00.000000000 +0100
1579 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmenetrxh.h 2005-12-16 23:39:10.700821500 +0100
1582 + * Hardware-specific Receive Data Header for the
1583 + * Broadcom Home Networking Division
1584 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1586 + * Copyright 2005, Broadcom Corporation
1587 + * All Rights Reserved.
1589 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1590 + * the contents of this file may not be disclosed to third parties, copied
1591 + * or duplicated in any form, in whole or in part, without the prior
1592 + * written permission of Broadcom Corporation.
1596 +#ifndef _bcmenetrxh_h_
1597 +#define _bcmenetrxh_h_
1600 + * The Ethernet MAC core returns an 8-byte Receive Frame Data Header
1601 + * with every frame consisting of
1602 + * 16bits of frame length, followed by
1603 + * 16bits of EMAC rx descriptor info, followed by 32bits of undefined.
1605 +typedef volatile struct {
1611 +#define RXHDR_LEN 28
1613 +#define RXF_L ((uint16)1 << 11) /* last buffer in a frame */
1614 +#define RXF_MISS ((uint16)1 << 7) /* received due to promisc mode */
1615 +#define RXF_BRDCAST ((uint16)1 << 6) /* dest is broadcast address */
1616 +#define RXF_MULT ((uint16)1 << 5) /* dest is multicast address */
1617 +#define RXF_LG ((uint16)1 << 4) /* frame length > rxmaxlength */
1618 +#define RXF_NO ((uint16)1 << 3) /* odd number of nibbles */
1619 +#define RXF_RXER ((uint16)1 << 2) /* receive symbol error */
1620 +#define RXF_CRC ((uint16)1 << 1) /* crc error */
1621 +#define RXF_OV ((uint16)1 << 0) /* fifo overflow */
1623 +#endif /* _bcmenetrxh_h_ */
1624 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmnvram.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmnvram.h
1625 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmnvram.h 1970-01-01 01:00:00.000000000 +0100
1626 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmnvram.h 2005-12-16 23:39:10.700821500 +0100
1629 + * NVRAM variable manipulation
1631 + * Copyright 2005, Broadcom Corporation
1632 + * All Rights Reserved.
1634 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1635 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1636 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1637 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1642 +#ifndef _bcmnvram_h_
1643 +#define _bcmnvram_h_
1645 +#ifndef _LANGUAGE_ASSEMBLY
1647 +#include <typedefs.h>
1649 +struct nvram_header {
1652 + uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
1653 + uint32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
1654 + uint32 config_ncdl; /* ncdl values for memc */
1657 +struct nvram_tuple {
1660 + struct nvram_tuple *next;
1664 + * Initialize NVRAM access. May be unnecessary or undefined on certain
1667 +extern int BCMINIT(nvram_init)(void *sbh);
1670 + * Disable NVRAM access. May be unnecessary or undefined on certain
1673 +extern void BCMINIT(nvram_exit)(void *sbh);
1676 + * Get the value of an NVRAM variable. The pointer returned may be
1677 + * invalid after a set.
1678 + * @param name name of variable to get
1679 + * @return value of variable or NULL if undefined
1681 +extern char * BCMINIT(nvram_get)(const char *name);
1684 + * Read the reset GPIO value from the nvram and set the GPIO
1687 +extern int BCMINITFN(nvram_resetgpio_init)(void *sbh);
1690 + * Get the value of an NVRAM variable.
1691 + * @param name name of variable to get
1692 + * @return value of variable or NUL if undefined
1694 +#define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "")
1697 + * Match an NVRAM variable.
1698 + * @param name name of variable to match
1699 + * @param match value to compare against value of variable
1700 + * @return TRUE if variable is defined and its value is string equal
1701 + * to match or FALSE otherwise
1704 +nvram_match(char *name, char *match) {
1705 + const char *value = BCMINIT(nvram_get)(name);
1706 + return (value && !strcmp(value, match));
1710 + * Inversely match an NVRAM variable.
1711 + * @param name name of variable to match
1712 + * @param match value to compare against value of variable
1713 + * @return TRUE if variable is defined and its value is not string
1714 + * equal to invmatch or FALSE otherwise
1717 +nvram_invmatch(char *name, char *invmatch) {
1718 + const char *value = BCMINIT(nvram_get)(name);
1719 + return (value && strcmp(value, invmatch));
1723 + * Set the value of an NVRAM variable. The name and value strings are
1724 + * copied into private storage. Pointers to previously set values
1725 + * may become invalid. The new value may be immediately
1726 + * retrieved but will not be permanently stored until a commit.
1727 + * @param name name of variable to set
1728 + * @param value value of variable
1729 + * @return 0 on success and errno on failure
1731 +extern int BCMINIT(nvram_set)(const char *name, const char *value);
1734 + * Unset an NVRAM variable. Pointers to previously set values
1735 + * remain valid until a set.
1736 + * @param name name of variable to unset
1737 + * @return 0 on success and errno on failure
1738 + * NOTE: use nvram_commit to commit this change to flash.
1740 +extern int BCMINIT(nvram_unset)(const char *name);
1743 + * Commit NVRAM variables to permanent storage. All pointers to values
1744 + * may be invalid after a commit.
1745 + * NVRAM values are undefined after a commit.
1746 + * @return 0 on success and errno on failure
1748 +extern int BCMINIT(nvram_commit)(void);
1751 + * Get all NVRAM variables (format name=value\0 ... \0\0).
1752 + * @param buf buffer to store variables
1753 + * @param count size of buffer in bytes
1754 + * @return 0 on success and errno on failure
1756 +extern int BCMINIT(nvram_getall)(char *buf, int count);
1758 +#endif /* _LANGUAGE_ASSEMBLY */
1760 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
1761 +#define NVRAM_VERSION 1
1762 +#define NVRAM_HEADER_SIZE 20
1763 +#define NVRAM_SPACE 0x8000
1765 +#define NVRAM_MAX_VALUE_LEN 255
1766 +#define NVRAM_MAX_PARAM_LEN 64
1768 +#endif /* _bcmnvram_h_ */
1769 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmparams.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmparams.h
1770 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmparams.h 1970-01-01 01:00:00.000000000 +0100
1771 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmparams.h 2005-12-16 23:39:10.700821500 +0100
1774 + * Misc system wide parameters.
1776 + * Copyright 2005, Broadcom Corporation
1777 + * All Rights Reserved.
1779 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1780 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1781 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1782 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1786 +#ifndef _bcmparams_h_
1787 +#define _bcmparams_h_
1789 +#define VLAN_MAXVID 15 /* Max. VLAN ID supported/allowed */
1791 +#define VLAN_NUMPRIS 8 /* # of prio, start from 0 */
1793 +#define DEV_NUMIFS 16 /* Max. # of devices/interfaces supported */
1795 +#define WL_MAXBSSCFG 16 /* maximum number of BSS Configs we can configure */
1798 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmsrom.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmsrom.h
1799 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmsrom.h 1970-01-01 01:00:00.000000000 +0100
1800 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmsrom.h 2005-12-16 23:39:10.704821750 +0100
1803 + * Misc useful routines to access NIC local SROM/OTP .
1805 + * Copyright 2005, Broadcom Corporation
1806 + * All Rights Reserved.
1808 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1809 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1810 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1811 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1816 +#ifndef _bcmsrom_h_
1817 +#define _bcmsrom_h_
1819 +extern int srom_var_init(void *sbh, uint bus, void *curmap, osl_t *osh, char **vars, int *count);
1821 +extern int srom_read(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
1822 +extern int srom_write(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
1824 +#endif /* _bcmsrom_h_ */
1825 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmutils.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmutils.h
1826 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmutils.h 1970-01-01 01:00:00.000000000 +0100
1827 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bcmutils.h 2005-12-16 23:39:10.704821750 +0100
1830 + * Misc useful os-independent macros and functions.
1832 + * Copyright 2005, Broadcom Corporation
1833 + * All Rights Reserved.
1835 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1836 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1837 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1838 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1842 +#ifndef _bcmutils_h_
1843 +#define _bcmutils_h_
1845 +/*** driver-only section ***/
1849 +#define _BCM_U 0x01 /* upper */
1850 +#define _BCM_L 0x02 /* lower */
1851 +#define _BCM_D 0x04 /* digit */
1852 +#define _BCM_C 0x08 /* cntrl */
1853 +#define _BCM_P 0x10 /* punct */
1854 +#define _BCM_S 0x20 /* white space (space/lf/tab) */
1855 +#define _BCM_X 0x40 /* hex digit */
1856 +#define _BCM_SP 0x80 /* hard space (0x20) */
1858 +#define GPIO_PIN_NOTDEFINED 0x20
1860 +extern unsigned char bcm_ctype[];
1861 +#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
1863 +#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
1864 +#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
1865 +#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0)
1866 +#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0)
1867 +#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
1868 +#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0)
1869 +#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
1870 +#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0)
1871 +#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0)
1872 +#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0)
1873 +#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
1876 + * Spin at most 'us' microseconds while 'exp' is true.
1877 + * Caller should explicitly test 'exp' when this completes
1878 + * and take appropriate error action if 'exp' is still true.
1880 +#define SPINWAIT(exp, us) { \
1881 + uint countdown = (us) + 9; \
1882 + while ((exp) && (countdown >= 10)) {\
1884 + countdown -= 10; \
1888 +/* generic osl packet queue */
1890 + void *head; /* first packet to dequeue */
1891 + void *tail; /* last packet to dequeue */
1892 + uint len; /* number of queued packets */
1893 + uint maxlen; /* maximum number of queued packets */
1894 + bool priority; /* enqueue by packet priority */
1895 + uint8 prio_map[MAXPRIO+1]; /* user priority to packet enqueue policy map */
1897 +#define DEFAULT_QLEN 128
1899 +#define pktq_len(q) ((q)->len)
1900 +#define pktq_avail(q) ((q)->maxlen - (q)->len)
1901 +#define pktq_head(q) ((q)->head)
1902 +#define pktq_full(q) ((q)->len >= (q)->maxlen)
1903 +#define _pktq_pri(q, pri) ((q)->prio_map[pri])
1904 +#define pktq_tailpri(q) ((q)->tail ? _pktq_pri(q, PKTPRIO((q)->tail)) : _pktq_pri(q, 0))
1908 +extern uint pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf);
1909 +extern uint pkttotlen(osl_t *osh, void *);
1910 +extern void pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[]);
1911 +extern void pktenq(struct pktq *q, void *p, bool lifo);
1912 +extern void *pktdeq(struct pktq *q);
1913 +extern void *pktdeqtail(struct pktq *q);
1915 +extern uint bcm_atoi(char *s);
1916 +extern uchar bcm_toupper(uchar c);
1917 +extern ulong bcm_strtoul(char *cp, char **endp, uint base);
1918 +extern char *bcmstrstr(char *haystack, char *needle);
1919 +extern char *bcmstrcat(char *dest, const char *src);
1920 +extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen);
1921 +/* ethernet address */
1922 +extern char *bcm_ether_ntoa(char *ea, char *buf);
1923 +extern int bcm_ether_atoe(char *p, char *ea);
1925 +extern void bcm_mdelay(uint ms);
1926 +/* variable access */
1927 +extern char *getvar(char *vars, char *name);
1928 +extern int getintvar(char *vars, char *name);
1929 +extern uint getgpiopin(char *vars, char *pin_name, uint def_pin);
1930 +#define bcmlog(fmt, a1, a2)
1931 +#define bcmdumplog(buf, size) *buf = '\0'
1932 +#define bcmdumplogent(buf, idx) -1
1934 +#endif /* #ifdef BCMDRIVER */
1936 +/*** driver/apps-shared section ***/
1938 +#define BCME_STRLEN 64
1939 +#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST))
1943 + * error codes could be added but the defined ones shouldn't be changed/deleted
1944 + * these error codes are exposed to the user code
1945 + * when ever a new error code is added to this list
1946 + * please update errorstring table with the related error string and
1947 + * update osl files with os specific errorcode map
1950 +#define BCME_ERROR -1 /* Error generic */
1951 +#define BCME_BADARG -2 /* Bad Argument */
1952 +#define BCME_BADOPTION -3 /* Bad option */
1953 +#define BCME_NOTUP -4 /* Not up */
1954 +#define BCME_NOTDOWN -5 /* Not down */
1955 +#define BCME_NOTAP -6 /* Not AP */
1956 +#define BCME_NOTSTA -7 /* Not STA */
1957 +#define BCME_BADKEYIDX -8 /* BAD Key Index */
1958 +#define BCME_RADIOOFF -9 /* Radio Off */
1959 +#define BCME_NOTBANDLOCKED -10 /* Not bandlocked */
1960 +#define BCME_NOCLK -11 /* No Clock*/
1961 +#define BCME_BADRATESET -12 /* BAD RateSet*/
1962 +#define BCME_BADBAND -13 /* BAD Band */
1963 +#define BCME_BUFTOOSHORT -14 /* Buffer too short */
1964 +#define BCME_BUFTOOLONG -15 /* Buffer too Long */
1965 +#define BCME_BUSY -16 /* Busy*/
1966 +#define BCME_NOTASSOCIATED -17 /* Not associated*/
1967 +#define BCME_BADSSIDLEN -18 /* BAD SSID Len */
1968 +#define BCME_OUTOFRANGECHAN -19 /* Out of Range Channel*/
1969 +#define BCME_BADCHAN -20 /* BAD Channel */
1970 +#define BCME_BADADDR -21 /* BAD Address*/
1971 +#define BCME_NORESOURCE -22 /* No resources*/
1972 +#define BCME_UNSUPPORTED -23 /* Unsupported*/
1973 +#define BCME_BADLEN -24 /* Bad Length*/
1974 +#define BCME_NOTREADY -25 /* Not ready Yet*/
1975 +#define BCME_EPERM -26 /* Not Permitted */
1976 +#define BCME_NOMEM -27 /* No Memory */
1977 +#define BCME_ASSOCIATED -28 /* Associated */
1978 +#define BCME_RANGE -29 /* Range Error*/
1979 +#define BCME_NOTFOUND -30 /* Not found */
1980 +#define BCME_LAST BCME_NOTFOUND
1983 +#define ABS(a) (((a)<0)?-(a):(a))
1987 +#define MIN(a, b) (((a)<(b))?(a):(b))
1991 +#define MAX(a, b) (((a)>(b))?(a):(b))
1994 +#define CEIL(x, y) (((x) + ((y)-1)) / (y))
1995 +#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
1996 +#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0)
1997 +#define ISPOWEROF2(x) ((((x)-1)&(x))==0)
1998 +#define VALID_MASK(mask) !((mask) & ((mask) + 1))
1999 +#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member)
2000 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
2002 +/* bit map related macros */
2004 +#define NBBY 8 /* 8 bits per byte */
2005 +#define setbit(a,i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
2006 +#define clrbit(a,i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
2007 +#define isset(a,i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY)))
2008 +#define isclr(a,i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
2011 +#define NBITS(type) (sizeof(type) * 8)
2012 +#define NBITVAL(bits) (1 << (bits))
2013 +#define MAXBITVAL(bits) ((1 << (bits)) - 1)
2016 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
2017 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
2018 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
2019 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
2020 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
2021 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
2023 +/* bcm_format_flags() bit description structure */
2024 +typedef struct bcm_bit_desc {
2029 +/* tag_ID/length/value_buffer tuple */
2030 +typedef struct bcm_tlv {
2036 +/* Check that bcm_tlv_t fits into the given buflen */
2037 +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len))
2039 +/* buffer length for ethernet address from bcm_ether_ntoa() */
2040 +#define ETHER_ADDR_STR_LEN 18
2042 +/* unaligned load and store macros */
2043 +#ifdef IL_BIGENDIAN
2044 +static INLINE uint32
2045 +load32_ua(uint8 *a)
2047 + return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
2051 +store32_ua(uint8 *a, uint32 v)
2053 + a[0] = (v >> 24) & 0xff;
2054 + a[1] = (v >> 16) & 0xff;
2055 + a[2] = (v >> 8) & 0xff;
2059 +static INLINE uint16
2060 +load16_ua(uint8 *a)
2062 + return ((a[0] << 8) | a[1]);
2066 +store16_ua(uint8 *a, uint16 v)
2068 + a[0] = (v >> 8) & 0xff;
2074 +static INLINE uint32
2075 +load32_ua(uint8 *a)
2077 + return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
2081 +store32_ua(uint8 *a, uint32 v)
2083 + a[3] = (v >> 24) & 0xff;
2084 + a[2] = (v >> 16) & 0xff;
2085 + a[1] = (v >> 8) & 0xff;
2089 +static INLINE uint16
2090 +load16_ua(uint8 *a)
2092 + return ((a[1] << 8) | a[0]);
2096 +store16_ua(uint8 *a, uint16 v)
2098 + a[1] = (v >> 8) & 0xff;
2106 +extern uint8 hndcrc8(uint8 *p, uint nbytes, uint8 crc);
2107 +extern uint16 hndcrc16(uint8 *p, uint nbytes, uint16 crc);
2108 +extern uint32 hndcrc32(uint8 *p, uint nbytes, uint32 crc);
2111 +extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
2112 +extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
2113 +extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
2116 +extern const char *bcmerrorstr(int bcmerror);
2118 +/* multi-bool data type: set of bools, mbool is true if any is set */
2119 +typedef uint32 mbool;
2120 +#define mboolset(mb, bit) (mb |= bit) /* set one bool */
2121 +#define mboolclr(mb, bit) (mb &= ~bit) /* clear one bool */
2122 +#define mboolisset(mb, bit) ((mb & bit) != 0) /* TRUE if one bool is set */
2123 +#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val)))
2125 +/* power conversion */
2126 +extern uint16 bcm_qdbm_to_mw(uint8 qdbm);
2127 +extern uint8 bcm_mw_to_qdbm(uint16 mw);
2129 +/* generic datastruct to help dump routines */
2136 +typedef uint32 (*readreg_rtn)(void *arg0, void *arg1, uint32 offset);
2137 +extern uint bcmdumpfields(readreg_rtn func_ptr, void *arg0, void *arg1, struct fielddesc *str, char *buf, uint32 bufsize);
2139 +extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len);
2141 +#endif /* _bcmutils_h_ */
2142 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bitfuncs.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/bitfuncs.h
2143 --- linux-2.4.32/arch/mips/bcm947xx/include/bitfuncs.h 1970-01-01 01:00:00.000000000 +0100
2144 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/bitfuncs.h 2005-12-16 23:39:10.704821750 +0100
2147 + * bit manipulation utility functions
2149 + * Copyright 2005, Broadcom Corporation
2150 + * All Rights Reserved.
2152 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2153 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2154 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2155 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2159 +#ifndef _BITFUNCS_H
2160 +#define _BITFUNCS_H
2162 +#include <typedefs.h>
2164 +/* local prototypes */
2165 +static INLINE uint32 find_msbit(uint32 x);
2169 + * find_msbit: returns index of most significant set bit in x, with index
2170 + * range defined as 0-31. NOTE: returns zero if input is zero.
2173 +#if defined(USE_PENTIUM_BSR) && defined(__GNUC__)
2176 + * Implementation for Pentium processors and gcc. Note that this
2177 + * instruction is actually very slow on some processors (e.g., family 5,
2178 + * model 2, stepping 12, "Pentium 75 - 200"), so we use the generic
2179 + * implementation instead.
2181 +static INLINE uint32 find_msbit(uint32 x)
2184 + __asm__("bsrl %1,%0"
2193 + * Generic Implementation
2196 +#define DB_POW_MASK16 0xffff0000
2197 +#define DB_POW_MASK8 0x0000ff00
2198 +#define DB_POW_MASK4 0x000000f0
2199 +#define DB_POW_MASK2 0x0000000c
2200 +#define DB_POW_MASK1 0x00000002
2202 +static INLINE uint32 find_msbit(uint32 x)
2204 + uint32 temp_x = x;
2206 + if (temp_x & DB_POW_MASK16) {
2210 + if (temp_x & DB_POW_MASK8) {
2214 + if (temp_x & DB_POW_MASK4) {
2218 + if (temp_x & DB_POW_MASK2) {
2222 + if (temp_x & DB_POW_MASK1) {
2230 +#endif /* _BITFUNCS_H */
2231 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/cfe_osl.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/cfe_osl.h
2232 --- linux-2.4.32/arch/mips/bcm947xx/include/cfe_osl.h 1970-01-01 01:00:00.000000000 +0100
2233 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/cfe_osl.h 2005-12-16 23:39:10.704821750 +0100
2236 + * CFE boot loader OS Abstraction Layer.
2238 + * Copyright 2005, Broadcom Corporation
2239 + * All Rights Reserved.
2241 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
2242 + * the contents of this file may not be disclosed to third parties, copied
2243 + * or duplicated in any form, in whole or in part, without the prior
2244 + * written permission of Broadcom Corporation.
2249 +#ifndef _cfe_osl_h_
2250 +#define _cfe_osl_h_
2252 +#include <lib_types.h>
2253 +#include <lib_string.h>
2254 +#include <lib_printf.h>
2255 +#include <lib_malloc.h>
2256 +#include <cpu_config.h>
2257 +#include <cfe_timer.h>
2258 +#include <cfe_iocb.h>
2259 +#include <cfe_devfuncs.h>
2260 +#include <addrspace.h>
2262 +#include <typedefs.h>
2265 +extern int (*xprinthook)(const char *str);
2266 +#define puts(str) do { if (xprinthook) xprinthook(str); } while (0)
2268 +/* assert and panic */
2269 +#define ASSERT(exp) do {} while (0)
2271 +/* PCMCIA attribute space access macros */
2272 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
2274 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
2277 +/* PCI configuration space access macros */
2278 +#define OSL_PCI_READ_CONFIG(loc, offset, size) \
2279 + (offset == 8 ? 0 : 0xffffffff)
2280 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) \
2283 +/* PCI device bus # and slot # */
2284 +#define OSL_PCI_BUS(osh) (0)
2285 +#define OSL_PCI_SLOT(osh) (0)
2287 +/* register access macros */
2288 +#define wreg32(r, v) (*(volatile uint32*)(r) = (uint32)(v))
2289 +#define rreg32(r) (*(volatile uint32*)(r))
2290 +#ifdef IL_BIGENDIAN
2291 +#define wreg16(r, v) (*(volatile uint16*)((ulong)(r)^2) = (uint16)(v))
2292 +#define rreg16(r) (*(volatile uint16*)((ulong)(r)^2))
2293 +#define wreg8(r, v) (*(volatile uint8*)((ulong)(r)^3) = (uint8)(v))
2294 +#define rreg8(r) (*(volatile uint8*)((ulong)(r)^3))
2296 +#define wreg16(r, v) (*(volatile uint16*)(r) = (uint16)(v))
2297 +#define rreg16(r) (*(volatile uint16*)(r))
2298 +#define wreg8(r, v) (*(volatile uint8*)(r) = (uint8)(v))
2299 +#define rreg8(r) (*(volatile uint8*)(r))
2301 +#define R_REG(r) ({ \
2302 + __typeof(*(r)) __osl_v; \
2303 + switch (sizeof(*(r))) { \
2304 + case sizeof(uint8): __osl_v = rreg8((r)); break; \
2305 + case sizeof(uint16): __osl_v = rreg16((r)); break; \
2306 + case sizeof(uint32): __osl_v = rreg32((r)); break; \
2310 +#define W_REG(r, v) do { \
2311 + switch (sizeof(*(r))) { \
2312 + case sizeof(uint8): wreg8((r), (v)); break; \
2313 + case sizeof(uint16): wreg16((r), (v)); break; \
2314 + case sizeof(uint32): wreg32((r), (v)); break; \
2317 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
2318 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
2320 +/* bcopy, bcmp, and bzero */
2321 +#define bcmp(b1, b2, len) lib_memcmp((b1), (b2), (len))
2323 +#define osl_attach(pdev) ((osl_t*)pdev)
2324 +#define osl_detach(osh)
2326 +/* general purpose memory allocation */
2327 +#define MALLOC(osh, size) KMALLOC((size),0)
2328 +#define MFREE(osh, addr, size) KFREE((addr))
2329 +#define MALLOCED(osh) (0)
2330 +#define MALLOC_DUMP(osh, buf, sz)
2331 +#define MALLOC_FAILED(osh) (0)
2333 +/* uncached virtual address */
2334 +#define OSL_UNCACHED(va) ((void*)UNCADDR((ulong)(va)))
2336 +/* host/bus architecture-specific address byte swap */
2337 +#define BUS_SWAP32(v) (v)
2339 +/* get processor cycle count */
2340 +#define OSL_GETCYCLES(x) ((x) = 0)
2342 +/* microsecond delay */
2343 +#define OSL_DELAY(usec) cfe_usleep((cfe_cpu_speed/CPUCFG_CYCLESPERCPUTICK/1000000*(usec)))
2345 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
2347 +/* map/unmap physical to virtual I/O */
2348 +#define REG_MAP(pa, size) ((void*)UNCADDR((ulong)(pa)))
2349 +#define REG_UNMAP(va) do {} while (0)
2351 +/* dereference an address that may cause a bus exception */
2352 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (uint32)(addr))
2353 +extern int osl_busprobe(uint32 *val, uint32 addr);
2355 +/* allocate/free shared (dma-able) consistent (uncached) memory */
2356 +#define DMA_CONSISTENT_ALIGN 4096
2357 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
2358 + osl_dma_alloc_consistent((size), (pap))
2359 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
2360 + osl_dma_free_consistent((void*)(va))
2361 +extern void *osl_dma_alloc_consistent(uint size, ulong *pap);
2362 +extern void osl_dma_free_consistent(void *va);
2364 +/* map/unmap direction */
2368 +/* map/unmap shared (dma-able) memory */
2369 +#define DMA_MAP(osh, va, size, direction, lb) ({ \
2370 + cfe_flushcache(CFE_CACHE_FLUSH_D); \
2371 + PHYSADDR((ulong)(va)); \
2373 +#define DMA_UNMAP(osh, pa, size, direction, p) \
2376 +/* shared (dma-able) memory access macros */
2377 +#define R_SM(r) *(r)
2378 +#define W_SM(r, v) (*(r) = (v))
2379 +#define BZERO_SM(r, len) lib_memset((r), '\0', (len))
2381 +/* generic packet structure */
2382 +#define LBUFSZ 4096
2383 +#define LBDATASZ (LBUFSZ - sizeof(struct lbuf))
2385 + struct lbuf *next; /* pointer to next lbuf if in a chain */
2386 + struct lbuf *link; /* pointer to next lbuf if in a list */
2387 + uchar *head; /* start of buffer */
2388 + uchar *end; /* end of buffer */
2389 + uchar *data; /* start of data */
2390 + uchar *tail; /* end of data */
2391 + uint len; /* nbytes of data */
2392 + void *cookie; /* generic cookie */
2395 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
2396 +#define PKTBUFSZ 2048
2398 +/* packet primitives */
2399 +#define PKTGET(osh, len, send) ((void*)osl_pktget((len)))
2400 +#define PKTFREE(osh, lb, send) osl_pktfree((struct lbuf*)(lb))
2401 +#define PKTDATA(osh, lb) (((struct lbuf*)(lb))->data)
2402 +#define PKTLEN(osh, lb) (((struct lbuf*)(lb))->len)
2403 +#define PKTHEADROOM(osh, lb) (PKTDATA(osh,lb)-(((struct lbuf*)(lb))->head))
2404 +#define PKTTAILROOM(osh, lb) ((((struct lbuf*)(lb))->end)-(((struct lbuf*)(lb))->tail))
2405 +#define PKTNEXT(osh, lb) (((struct lbuf*)(lb))->next)
2406 +#define PKTSETNEXT(lb, x) (((struct lbuf*)(lb))->next = (struct lbuf*)(x))
2407 +#define PKTSETLEN(osh, lb, len) osl_pktsetlen((struct lbuf*)(lb), (len))
2408 +#define PKTPUSH(osh, lb, bytes) osl_pktpush((struct lbuf*)(lb), (bytes))
2409 +#define PKTPULL(osh, lb, bytes) osl_pktpull((struct lbuf*)(lb), (bytes))
2410 +#define PKTDUP(osh, lb) osl_pktdup((struct lbuf*)(lb))
2411 +#define PKTCOOKIE(lb) (((struct lbuf*)(lb))->cookie)
2412 +#define PKTSETCOOKIE(lb, x) (((struct lbuf*)(lb))->cookie = (void*)(x))
2413 +#define PKTLINK(lb) (((struct lbuf*)(lb))->link)
2414 +#define PKTSETLINK(lb, x) (((struct lbuf*)(lb))->link = (struct lbuf*)(x))
2415 +#define PKTPRIO(lb) (0)
2416 +#define PKTSETPRIO(lb, x) do {} while (0)
2417 +extern struct lbuf *osl_pktget(uint len);
2418 +extern void osl_pktfree(struct lbuf *lb);
2419 +extern void osl_pktsetlen(struct lbuf *lb, uint len);
2420 +extern uchar *osl_pktpush(struct lbuf *lb, uint bytes);
2421 +extern uchar *osl_pktpull(struct lbuf *lb, uint bytes);
2422 +extern struct lbuf *osl_pktdup(struct lbuf *lb);
2423 +extern int osl_error(int bcmerror);
2425 +#endif /* _cfe_osl_h_ */
2426 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/epivers.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/epivers.h
2427 --- linux-2.4.32/arch/mips/bcm947xx/include/epivers.h 1970-01-01 01:00:00.000000000 +0100
2428 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/epivers.h 2005-12-16 23:39:10.704821750 +0100
2431 + * Copyright 2005, Broadcom Corporation
2432 + * All Rights Reserved.
2434 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2435 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2436 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2437 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2443 +#ifndef _epivers_h_
2444 +#define _epivers_h_
2447 +#include <linux/config.h>
2450 +/* Vendor Name, ASCII, 32 chars max */
2452 +#define HPNA_VENDOR COMPANYNAME
2454 +#define HPNA_VENDOR "Broadcom Corporation"
2457 +/* Driver Date, ASCII, 32 chars max */
2458 +#define HPNA_DRV_BUILD_DATE __DATE__
2460 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2461 +#define HPNA_HW_MFG_DATE "Not Specified"
2463 +/* See documentation for Device Type values, 32 values max */
2464 +#ifndef HPNA_DEV_TYPE
2466 +#if defined(CONFIG_BRCM_VJ)
2467 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2469 +#elif defined(CONFIG_BCRM_93725)
2470 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2473 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2477 +#endif /* !HPNA_DEV_TYPE */
2480 +#define EPI_MAJOR_VERSION 3
2482 +#define EPI_MINOR_VERSION 130
2484 +#define EPI_RC_NUMBER 20
2486 +#define EPI_INCREMENTAL_NUMBER 0
2488 +#define EPI_BUILD_NUMBER 0
2490 +#define EPI_VERSION 3,130,20,0
2492 +#define EPI_VERSION_NUM 0x03821400
2494 +/* Driver Version String, ASCII, 32 chars max */
2495 +#define EPI_VERSION_STR "3.130.20.0"
2496 +#define EPI_ROUTER_VERSION_STR "3.131.20.0"
2498 +#endif /* _epivers_h_ */
2499 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/epivers.h.in linux-2.4.32-brcm/arch/mips/bcm947xx/include/epivers.h.in
2500 --- linux-2.4.32/arch/mips/bcm947xx/include/epivers.h.in 1970-01-01 01:00:00.000000000 +0100
2501 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/epivers.h.in 2005-12-16 23:39:10.704821750 +0100
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.
2516 +#ifndef _epivers_h_
2517 +#define _epivers_h_
2520 +#include <linux/config.h>
2523 +/* Vendor Name, ASCII, 32 chars max */
2525 +#define HPNA_VENDOR COMPANYNAME
2527 +#define HPNA_VENDOR "Broadcom Corporation"
2530 +/* Driver Date, ASCII, 32 chars max */
2531 +#define HPNA_DRV_BUILD_DATE __DATE__
2533 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2534 +#define HPNA_HW_MFG_DATE "Not Specified"
2536 +/* See documentation for Device Type values, 32 values max */
2537 +#ifndef HPNA_DEV_TYPE
2539 +#if defined(CONFIG_BRCM_VJ)
2540 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2542 +#elif defined(CONFIG_BCRM_93725)
2543 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2546 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2550 +#endif /* !HPNA_DEV_TYPE */
2553 +#define EPI_MAJOR_VERSION @EPI_MAJOR_VERSION@
2555 +#define EPI_MINOR_VERSION @EPI_MINOR_VERSION@
2557 +#define EPI_RC_NUMBER @EPI_RC_NUMBER@
2559 +#define EPI_INCREMENTAL_NUMBER @EPI_INCREMENTAL_NUMBER@
2561 +#define EPI_BUILD_NUMBER @EPI_BUILD_NUMBER@
2563 +#define EPI_VERSION @EPI_VERSION@
2565 +#define EPI_VERSION_NUM @EPI_VERSION_NUM@
2567 +/* Driver Version String, ASCII, 32 chars max */
2568 +#define EPI_VERSION_STR "@EPI_VERSION_STR@"
2569 +#define EPI_ROUTER_VERSION_STR "@EPI_ROUTER_VERSION_STR@"
2571 +#endif /* _epivers_h_ */
2572 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/etsockio.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/etsockio.h
2573 --- linux-2.4.32/arch/mips/bcm947xx/include/etsockio.h 1970-01-01 01:00:00.000000000 +0100
2574 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/etsockio.h 2005-12-16 23:39:10.704821750 +0100
2577 + * Driver-specific socket ioctls
2578 + * used by BSD, Linux, and PSOS
2579 + * Broadcom BCM44XX 10/100Mbps Ethernet Device Driver
2581 + * Copyright 2005, Broadcom Corporation
2582 + * All Rights Reserved.
2584 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2585 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2586 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2587 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2592 +#ifndef _etsockio_h_
2593 +#define _etsockio_h_
2595 +/* THESE MUST BE CONTIGUOUS AND CONSISTENT WITH VALUES IN ETC.H */
2599 +#define SIOCSETCUP (SIOCDEVPRIVATE + 0)
2600 +#define SIOCSETCDOWN (SIOCDEVPRIVATE + 1)
2601 +#define SIOCSETCLOOP (SIOCDEVPRIVATE + 2)
2602 +#define SIOCGETCDUMP (SIOCDEVPRIVATE + 3)
2603 +#define SIOCSETCSETMSGLEVEL (SIOCDEVPRIVATE + 4)
2604 +#define SIOCSETCPROMISC (SIOCDEVPRIVATE + 5)
2605 +#define SIOCSETCTXDOWN (SIOCDEVPRIVATE + 6) /* obsolete */
2606 +#define SIOCSETCSPEED (SIOCDEVPRIVATE + 7)
2607 +#define SIOCTXGEN (SIOCDEVPRIVATE + 8)
2608 +#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
2609 +#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
2610 +#define SIOCSETCQOS (SIOCDEVPRIVATE + 11)
2614 +#define SIOCSETCUP _IOWR('e', 130 + 0, struct ifreq)
2615 +#define SIOCSETCDOWN _IOWR('e', 130 + 1, struct ifreq)
2616 +#define SIOCSETCLOOP _IOWR('e', 130 + 2, struct ifreq)
2617 +#define SIOCGETCDUMP _IOWR('e', 130 + 3, struct ifreq)
2618 +#define SIOCSETCSETMSGLEVEL _IOWR('e', 130 + 4, struct ifreq)
2619 +#define SIOCSETCPROMISC _IOWR('e', 130 + 5, struct ifreq)
2620 +#define SIOCSETCTXDOWN _IOWR('e', 130 + 6, struct ifreq) /* obsolete */
2621 +#define SIOCSETCSPEED _IOWR('e', 130 + 7, struct ifreq)
2622 +#define SIOCTXGEN _IOWR('e', 130 + 8, struct ifreq)
2626 +/* arg to SIOCTXGEN */
2628 + uint32 num; /* number of frames to send */
2629 + uint32 delay; /* delay in microseconds between sending each */
2630 + uint32 size; /* size of ether frame to send */
2631 + uchar buf[1514]; /* starting ether frame data */
2635 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/flash.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/flash.h
2636 --- linux-2.4.32/arch/mips/bcm947xx/include/flash.h 1970-01-01 01:00:00.000000000 +0100
2637 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/flash.h 2005-12-16 23:39:10.704821750 +0100
2640 + * flash.h: Common definitions for flash access.
2642 + * Copyright 2005, Broadcom Corporation
2643 + * All Rights Reserved.
2645 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2646 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2647 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2648 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2653 +/* Types of flashes we know about */
2654 +typedef enum _flash_type {OLD, BSC, SCS, AMD, SST, SFLASH} flash_type_t;
2656 +/* Commands to write/erase the flases */
2657 +typedef struct _flash_cmds{
2658 + flash_type_t type;
2661 + uint16 erase_block;
2662 + uint16 erase_chip;
2663 + uint16 write_word;
2669 + uint16 read_array;
2672 +#define UNLOCK_CMD_WORDS 2
2674 +typedef struct _unlock_cmd {
2675 + uint addr[UNLOCK_CMD_WORDS];
2676 + uint16 cmd[UNLOCK_CMD_WORDS];
2679 +/* Flash descriptors */
2680 +typedef struct _flash_desc {
2681 + uint16 mfgid; /* Manufacturer Id */
2682 + uint16 devid; /* Device Id */
2683 + uint size; /* Total size in bytes */
2684 + uint width; /* Device width in bytes */
2685 + flash_type_t type; /* Device type old, S, J */
2686 + uint bsize; /* Block size */
2687 + uint nb; /* Number of blocks */
2688 + uint ff; /* First full block */
2689 + uint lf; /* Last full block */
2690 + uint nsub; /* Number of subblocks */
2691 + uint *subblocks; /* Offsets for subblocks */
2692 + char *desc; /* Description */
2696 +#ifdef DECLARE_FLASHES
2697 +flash_cmds_t sflash_cmd_t =
2698 + { SFLASH, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2700 +flash_cmds_t flash_cmds[] = {
2701 +/* type needu preera eraseb erasech write wbuf clcsr rdcsr rdid confrm read */
2702 + { BSC, 0, 0x00, 0x20, 0x00, 0x40, 0x00, 0x50, 0x70, 0x90, 0xd0, 0xff },
2703 + { SCS, 0, 0x00, 0x20, 0x00, 0x40, 0xe8, 0x50, 0x70, 0x90, 0xd0, 0xff },
2704 + { AMD, 1, 0x80, 0x30, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
2705 + { SST, 1, 0x80, 0x50, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
2709 +unlock_cmd_t unlock_cmd_amd = {
2711 +/* addr: */ { 0x0aa8, 0x0556},
2713 +/* addr: */ { 0x0aaa, 0x0554},
2715 +/* data: */ { 0xaa, 0x55}
2718 +unlock_cmd_t unlock_cmd_sst = {
2720 +/* addr: */ { 0xaaa8, 0x5556},
2722 +/* addr: */ { 0xaaaa, 0x5554},
2724 +/* data: */ { 0xaa, 0x55}
2727 +#define AMD_CMD 0xaaa
2728 +#define SST_CMD 0xaaaa
2730 +/* intel unlock block cmds */
2731 +#define INTEL_UNLOCK1 0x60
2732 +#define INTEL_UNLOCK2 0xD0
2734 +/* Just eight blocks of 8KB byte each */
2736 +uint blk8x8k[] = { 0x00000000,
2747 +/* Funky AMD arrangement for 29xx800's */
2748 +uint amd800[] = { 0x00000000, /* 16KB */
2749 + 0x00004000, /* 32KB */
2750 + 0x0000c000, /* 8KB */
2751 + 0x0000e000, /* 8KB */
2752 + 0x00010000, /* 8KB */
2753 + 0x00012000, /* 8KB */
2754 + 0x00014000, /* 32KB */
2755 + 0x0001c000, /* 16KB */
2759 +/* AMD arrangement for 29xx160's */
2760 +uint amd4112[] = { 0x00000000, /* 32KB */
2761 + 0x00008000, /* 8KB */
2762 + 0x0000a000, /* 8KB */
2763 + 0x0000c000, /* 16KB */
2766 +uint amd2114[] = { 0x00000000, /* 16KB */
2767 + 0x00004000, /* 8KB */
2768 + 0x00006000, /* 8KB */
2769 + 0x00008000, /* 32KB */
2774 +flash_desc_t sflash_desc =
2775 + { 0, 0, 0, 0, SFLASH, 0, 0, 0, 0, 0, NULL, "SFLASH" };
2777 +flash_desc_t flashes[] = {
2778 + { 0x00b0, 0x00d0, 0x0200000, 2, SCS, 0x10000, 32, 0, 31, 0, NULL, "Intel 28F160S3/5 1Mx16" },
2779 + { 0x00b0, 0x00d4, 0x0400000, 2, SCS, 0x10000, 64, 0, 63, 0, NULL, "Intel 28F320S3/5 2Mx16" },
2780 + { 0x0089, 0x8890, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160B3 1Mx16 TopB" },
2781 + { 0x0089, 0x8891, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160B3 1Mx16 BotB" },
2782 + { 0x0089, 0x8896, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320B3 2Mx16 TopB" },
2783 + { 0x0089, 0x8897, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320B3 2Mx16 BotB" },
2784 + { 0x0089, 0x8898, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640B3 4Mx16 TopB" },
2785 + { 0x0089, 0x8899, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640B3 4Mx16 BotB" },
2786 + { 0x0089, 0x88C2, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160C3 1Mx16 TopB" },
2787 + { 0x0089, 0x88C3, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160C3 1Mx16 BotB" },
2788 + { 0x0089, 0x88C4, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320C3 2Mx16 TopB" },
2789 + { 0x0089, 0x88C5, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320C3 2Mx16 BotB" },
2790 + { 0x0089, 0x88CC, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640C3 4Mx16 TopB" },
2791 + { 0x0089, 0x88CD, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640C3 4Mx16 BotB" },
2792 + { 0x0089, 0x0014, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J5 2Mx16" },
2793 + { 0x0089, 0x0015, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J5 4Mx16" },
2794 + { 0x0089, 0x0016, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J3 2Mx16" },
2795 + { 0x0089, 0x0017, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J3 4Mx16" },
2796 + { 0x0089, 0x0018, 0x1000000, 2, SCS, 0x20000, 128, 0, 127, 0, NULL, "Intel 28F128J3 8Mx16" },
2797 + { 0x00b0, 0x00e3, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Sharp 28F320BJE 2Mx16 BotB" },
2798 + { 0x0001, 0x224a, 0x0100000, 2, AMD, 0x10000, 16, 0, 13, 8, amd800, "AMD 29DL800BT 512Kx16 TopB" },
2799 + { 0x0001, 0x22cb, 0x0100000, 2, AMD, 0x10000, 16, 2, 15, 8, amd800, "AMD 29DL800BB 512Kx16 BotB" },
2800 + { 0x0001, 0x22c4, 0x0200000, 2, AMD, 0x10000, 32, 0, 30, 4, amd2114, "AMD 29lv160DT 1Mx16 TopB" },
2801 + { 0x0001, 0x2249, 0x0200000, 2, AMD, 0x10000, 32, 1, 31, 4, amd4112, "AMD 29lv160DB 1Mx16 BotB" },
2802 + { 0x0001, 0x22f6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320DT 2Mx16 TopB" },
2803 + { 0x0001, 0x22f9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320DB 2Mx16 BotB" },
2804 + { 0x0001, 0x227e, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320MT 2Mx16 TopB" },
2805 + { 0x0001, 0x2200, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320MB 2Mx16 BotB" },
2806 + { 0x0020, 0x22CA, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "ST 29w320DT 2Mx16 TopB" },
2807 + { 0x0020, 0x22CB, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "ST 29w320DB 2Mx16 BotB" },
2808 + { 0x00C2, 0x00A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
2809 + { 0x00C2, 0x00A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
2810 + { 0x0004, 0x22F6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MBM29LV320TE 2Mx16 TopB" },
2811 + { 0x0004, 0x22F9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MBM29LV320BE 2Mx16 BotB" },
2812 + { 0x0098, 0x009A, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "TC58FVT321 2Mx16 TopB" },
2813 + { 0x0098, 0x009C, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "TC58FVB321 2Mx16 BotB" },
2814 + { 0x00C2, 0x22A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
2815 + { 0x00C2, 0x22A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
2816 + { 0x00BF, 0x2783, 0x0400000, 2, SST, 0x10000, 64, 0, 63, 0, NULL, "SST39VF320 2Mx16" },
2817 + { 0, 0, 0, 0, OLD, 0, 0, 0, 0, 0, NULL, NULL },
2822 +extern flash_cmds_t flash_cmds[];
2823 +extern unlock_cmd_t unlock_cmd;
2824 +extern flash_desc_t flashes[];
2827 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/flashutl.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/flashutl.h
2828 --- linux-2.4.32/arch/mips/bcm947xx/include/flashutl.h 1970-01-01 01:00:00.000000000 +0100
2829 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/flashutl.h 2005-12-16 23:39:10.708822000 +0100
2832 + * BCM47XX FLASH driver interface
2834 + * Copyright 2005, Broadcom Corporation
2835 + * All Rights Reserved.
2837 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2838 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2839 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2840 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2844 +#ifndef _flashutl_h_
2845 +#define _flashutl_h_
2848 +#ifndef _LANGUAGE_ASSEMBLY
2850 +int sysFlashInit(char *flash_str);
2851 +int sysFlashRead(uint off, uchar *dst, uint bytes);
2852 +int sysFlashWrite(uint off, uchar *src, uint bytes);
2853 +void nvWrite(unsigned short *data, unsigned int len);
2855 +#endif /* _LANGUAGE_ASSEMBLY */
2857 +#endif /* _flashutl_h_ */
2858 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/hnddma.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/hnddma.h
2859 --- linux-2.4.32/arch/mips/bcm947xx/include/hnddma.h 1970-01-01 01:00:00.000000000 +0100
2860 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/hnddma.h 2005-12-16 23:39:10.708822000 +0100
2863 + * Generic Broadcom Home Networking Division (HND) DMA engine SW interface
2864 + * This supports the following chips: BCM42xx, 44xx, 47xx .
2866 + * Copyright 2005, Broadcom Corporation
2867 + * All Rights Reserved.
2869 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2870 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2871 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2872 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2879 +/* export structure */
2880 +typedef volatile struct {
2881 + /* rx error counters */
2882 + uint rxgiants; /* rx giant frames */
2883 + uint rxnobuf; /* rx out of dma descriptors */
2884 + /* tx error counters */
2885 + uint txnobuf; /* tx out of dma descriptors */
2897 +extern void * dma_attach(osl_t *osh, char *name, sb_t *sbh, void *dmaregstx, void *dmaregsrx,
2898 + uint ntxd, uint nrxd, uint rxbufsize, uint nrxpost, uint rxoffset, uint *msg_level);
2899 +extern void dma_detach(di_t *di);
2900 +extern void dma_txreset(di_t *di);
2901 +extern void dma_rxreset(di_t *di);
2902 +extern void dma_txinit(di_t *di);
2903 +extern bool dma_txenabled(di_t *di);
2904 +extern void dma_rxinit(di_t *di);
2905 +extern void dma_rxenable(di_t *di);
2906 +extern bool dma_rxenabled(di_t *di);
2907 +extern void dma_txsuspend(di_t *di);
2908 +extern void dma_txresume(di_t *di);
2909 +extern bool dma_txsuspended(di_t *di);
2910 +extern bool dma_txsuspendedidle(di_t *di);
2911 +extern bool dma_txstopped(di_t *di);
2912 +extern bool dma_rxstopped(di_t *di);
2913 +extern int dma_txfast(di_t *di, void *p, uint32 coreflags);
2914 +extern void dma_fifoloopbackenable(di_t *di);
2915 +extern void *dma_rx(di_t *di);
2916 +extern void dma_rxfill(di_t *di);
2917 +extern void dma_txreclaim(di_t *di, bool forceall);
2918 +extern void dma_rxreclaim(di_t *di);
2919 +extern uintptr dma_getvar(di_t *di, char *name);
2920 +extern void *dma_getnexttxp(di_t *di, bool forceall);
2921 +extern void *dma_peeknexttxp(di_t *di);
2922 +extern void *dma_getnextrxp(di_t *di, bool forceall);
2923 +extern void dma_txblock(di_t *di);
2924 +extern void dma_txunblock(di_t *di);
2925 +extern uint dma_txactive(di_t *di);
2926 +extern void dma_txrotate(di_t *di);
2928 +extern void dma_rxpiomode(dma32regs_t *);
2929 +extern void dma_txpioloopback(dma32regs_t *);
2932 +#endif /* _hnddma_h_ */
2933 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/hndmips.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/hndmips.h
2934 --- linux-2.4.32/arch/mips/bcm947xx/include/hndmips.h 1970-01-01 01:00:00.000000000 +0100
2935 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/hndmips.h 2005-12-16 23:39:10.708822000 +0100
2938 + * Alternate include file for HND sbmips.h since CFE also ships with
2941 + * Copyright 2005, Broadcom Corporation
2942 + * All Rights Reserved.
2944 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2945 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2946 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2947 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2952 +#include "sbmips.h"
2953 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/linux_osl.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/linux_osl.h
2954 --- linux-2.4.32/arch/mips/bcm947xx/include/linux_osl.h 1970-01-01 01:00:00.000000000 +0100
2955 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/linux_osl.h 2005-12-16 23:39:10.708822000 +0100
2958 + * Linux OS Independent Layer
2960 + * Copyright 2005, Broadcom Corporation
2961 + * All Rights Reserved.
2963 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2964 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2965 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2966 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2971 +#ifndef _linux_osl_h_
2972 +#define _linux_osl_h_
2974 +#include <typedefs.h>
2976 +/* use current 2.4.x calling conventions */
2977 +#include <linuxver.h>
2979 +/* assert and panic */
2981 +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
2982 +#if GCC_VERSION > 30100
2983 +#define ASSERT(exp) do {} while (0)
2985 +/* ASSERT could causes segmentation fault on GCC3.1, use empty instead*/
2986 +#define ASSERT(exp)
2990 +/* microsecond delay */
2991 +#define OSL_DELAY(usec) osl_delay(usec)
2992 +extern void osl_delay(uint usec);
2994 +/* PCMCIA attribute space access macros */
2995 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
2996 +struct pcmcia_dev {
2997 + dev_link_t link; /* PCMCIA device pointer */
2998 + dev_node_t node; /* PCMCIA node structure */
2999 + void *base; /* Mapped attribute memory window */
3000 + size_t size; /* Size of window */
3001 + void *drv; /* Driver data */
3004 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
3005 + osl_pcmcia_read_attr((osh), (offset), (buf), (size))
3006 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
3007 + osl_pcmcia_write_attr((osh), (offset), (buf), (size))
3008 +extern void osl_pcmcia_read_attr(osl_t *osh, uint offset, void *buf, int size);
3009 +extern void osl_pcmcia_write_attr(osl_t *osh, uint offset, void *buf, int size);
3011 +/* PCI configuration space access macros */
3012 +#define OSL_PCI_READ_CONFIG(osh, offset, size) \
3013 + osl_pci_read_config((osh), (offset), (size))
3014 +#define OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
3015 + osl_pci_write_config((osh), (offset), (size), (val))
3016 +extern uint32 osl_pci_read_config(osl_t *osh, uint size, uint offset);
3017 +extern void osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val);
3019 +/* PCI device bus # and slot # */
3020 +#define OSL_PCI_BUS(osh) osl_pci_bus(osh)
3021 +#define OSL_PCI_SLOT(osh) osl_pci_slot(osh)
3022 +extern uint osl_pci_bus(osl_t *osh);
3023 +extern uint osl_pci_slot(osl_t *osh);
3025 +/* OSL initialization */
3026 +extern osl_t *osl_attach(void *pdev);
3027 +extern void osl_detach(osl_t *osh);
3029 +/* host/bus architecture-specific byte swap */
3030 +#define BUS_SWAP32(v) (v)
3032 +/* general purpose memory allocation */
3034 +#if defined(BCMDBG_MEM)
3036 +#define MALLOC(osh, size) osl_debug_malloc((osh), (size), __LINE__, __FILE__)
3037 +#define MFREE(osh, addr, size) osl_debug_mfree((osh), (addr), (size), __LINE__, __FILE__)
3038 +#define MALLOCED(osh) osl_malloced((osh))
3039 +#define MALLOC_DUMP(osh, buf, sz) osl_debug_memdump((osh), (buf), (sz))
3040 +extern void *osl_debug_malloc(osl_t *osh, uint size, int line, char* file);
3041 +extern void osl_debug_mfree(osl_t *osh, void *addr, uint size, int line, char* file);
3042 +extern char *osl_debug_memdump(osl_t *osh, char *buf, uint sz);
3046 +#define MALLOC(osh, size) osl_malloc((osh), (size))
3047 +#define MFREE(osh, addr, size) osl_mfree((osh), (addr), (size))
3048 +#define MALLOCED(osh) osl_malloced((osh))
3050 +#endif /* BCMDBG_MEM */
3052 +#define MALLOC_FAILED(osh) osl_malloc_failed((osh))
3054 +extern void *osl_malloc(osl_t *osh, uint size);
3055 +extern void osl_mfree(osl_t *osh, void *addr, uint size);
3056 +extern uint osl_malloced(osl_t *osh);
3057 +extern uint osl_malloc_failed(osl_t *osh);
3059 +/* allocate/free shared (dma-able) consistent memory */
3060 +#define DMA_CONSISTENT_ALIGN PAGE_SIZE
3061 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
3062 + osl_dma_alloc_consistent((osh), (size), (pap))
3063 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
3064 + osl_dma_free_consistent((osh), (void*)(va), (size), (pa))
3065 +extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap);
3066 +extern void osl_dma_free_consistent(osl_t *osh, void *va, uint size, ulong pa);
3068 +/* map/unmap direction */
3072 +/* map/unmap shared (dma-able) memory */
3073 +#define DMA_MAP(osh, va, size, direction, p) \
3074 + osl_dma_map((osh), (va), (size), (direction))
3075 +#define DMA_UNMAP(osh, pa, size, direction, p) \
3076 + osl_dma_unmap((osh), (pa), (size), (direction))
3077 +extern uint osl_dma_map(osl_t *osh, void *va, uint size, int direction);
3078 +extern void osl_dma_unmap(osl_t *osh, uint pa, uint size, int direction);
3080 +/* register access macros */
3081 +#if defined(BCMJTAG)
3082 +#include <bcmjtag.h>
3083 +#define R_REG(r) bcmjtag_read(NULL, (uint32)(r), sizeof (*(r)))
3084 +#define W_REG(r, v) bcmjtag_write(NULL, (uint32)(r), (uint32)(v), sizeof (*(r)))
3088 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
3089 + * Macros expand to calls to functions defined in linux_osl.c .
3093 +/* string library, kernel mode */
3094 +#define printf(fmt, args...) printk(fmt, ## args)
3095 +#include <linux/kernel.h>
3096 +#include <linux/string.h>
3098 +/* register access macros */
3099 +#if !defined(BCMJTAG)
3100 +#ifndef IL_BIGENDIAN
3101 +#define R_REG(r) ( \
3102 + sizeof(*(r)) == sizeof(uint8) ? readb((volatile uint8*)(r)) : \
3103 + sizeof(*(r)) == sizeof(uint16) ? readw((volatile uint16*)(r)) : \
3104 + readl((volatile uint32*)(r)) \
3106 +#define W_REG(r, v) do { \
3107 + switch (sizeof(*(r))) { \
3108 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)(r)); break; \
3109 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)(r)); break; \
3110 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
3113 +#else /* IL_BIGENDIAN */
3114 +#define R_REG(r) ({ \
3115 + __typeof(*(r)) __osl_v; \
3116 + switch (sizeof(*(r))) { \
3117 + case sizeof(uint8): __osl_v = readb((volatile uint8*)((uint32)r^3)); break; \
3118 + case sizeof(uint16): __osl_v = readw((volatile uint16*)((uint32)r^2)); break; \
3119 + case sizeof(uint32): __osl_v = readl((volatile uint32*)(r)); break; \
3123 +#define W_REG(r, v) do { \
3124 + switch (sizeof(*(r))) { \
3125 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)((uint32)r^3)); break; \
3126 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)((uint32)r^2)); break; \
3127 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
3133 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3134 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3136 +/* bcopy, bcmp, and bzero */
3137 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
3138 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
3139 +#define bzero(b, len) memset((b), '\0', (len))
3141 +/* uncached virtual address */
3143 +#define OSL_UNCACHED(va) KSEG1ADDR((va))
3144 +#include <asm/addrspace.h>
3146 +#define OSL_UNCACHED(va) (va)
3149 +/* get processor cycle count */
3151 +#define OSL_GETCYCLES(x) ((x) = read_c0_count() * 2)
3152 +#elif defined(__i386__)
3153 +#define OSL_GETCYCLES(x) rdtscl((x))
3155 +#define OSL_GETCYCLES(x) ((x) = 0)
3158 +/* dereference an address that may cause a bus exception */
3160 +#if defined(MODULE) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17))
3161 +#define BUSPROBE(val, addr) panic("get_dbe() will not fixup a bus exception when compiled into a module")
3163 +#define BUSPROBE(val, addr) get_dbe((val), (addr))
3164 +#include <asm/paccess.h>
3167 +#define BUSPROBE(val, addr) ({ (val) = R_REG((addr)); 0; })
3170 +/* map/unmap physical to virtual I/O */
3171 +#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), (unsigned long)(size))
3172 +#define REG_UNMAP(va) iounmap((void *)(va))
3174 +/* shared (dma-able) memory access macros */
3175 +#define R_SM(r) *(r)
3176 +#define W_SM(r, v) (*(r) = (v))
3177 +#define BZERO_SM(r, len) memset((r), '\0', (len))
3179 +/* packet primitives */
3180 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
3181 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
3182 +#define PKTDATA(osh, skb) (((struct sk_buff*)(skb))->data)
3183 +#define PKTLEN(osh, skb) (((struct sk_buff*)(skb))->len)
3184 +#define PKTHEADROOM(osh, skb) (PKTDATA(osh,skb)-(((struct sk_buff*)(skb))->head))
3185 +#define PKTTAILROOM(osh, skb) ((((struct sk_buff*)(skb))->end)-(((struct sk_buff*)(skb))->tail))
3186 +#define PKTNEXT(osh, skb) (((struct sk_buff*)(skb))->next)
3187 +#define PKTSETNEXT(skb, x) (((struct sk_buff*)(skb))->next = (struct sk_buff*)(x))
3188 +#define PKTSETLEN(osh, skb, len) __skb_trim((struct sk_buff*)(skb), (len))
3189 +#define PKTPUSH(osh, skb, bytes) skb_push((struct sk_buff*)(skb), (bytes))
3190 +#define PKTPULL(osh, skb, bytes) skb_pull((struct sk_buff*)(skb), (bytes))
3191 +#define PKTDUP(osh, skb) skb_clone((struct sk_buff*)(skb), GFP_ATOMIC)
3192 +#define PKTCOOKIE(skb) ((void*)((struct sk_buff*)(skb))->csum)
3193 +#define PKTSETCOOKIE(skb, x) (((struct sk_buff*)(skb))->csum = (uint)(x))
3194 +#define PKTLINK(skb) (((struct sk_buff*)(skb))->prev)
3195 +#define PKTSETLINK(skb, x) (((struct sk_buff*)(skb))->prev = (struct sk_buff*)(x))
3196 +#define PKTPRIO(skb) (((struct sk_buff*)(skb))->priority)
3197 +#define PKTSETPRIO(skb, x) (((struct sk_buff*)(skb))->priority = (x))
3198 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
3199 +extern void osl_pktfree(void *skb);
3203 +/* string library */
3206 +#define printf(fmt, args...) osl_printf((fmt), ## args)
3208 +#define sprintf(buf, fmt, args...) osl_sprintf((buf), (fmt), ## args)
3210 +#define strcmp(s1, s2) osl_strcmp((s1), (s2))
3212 +#define strncmp(s1, s2, n) osl_strncmp((s1), (s2), (n))
3214 +#define strlen(s) osl_strlen((s))
3216 +#define strcpy(d, s) osl_strcpy((d), (s))
3218 +#define strncpy(d, s, n) osl_strncpy((d), (s), (n))
3220 +extern int osl_printf(const char *format, ...);
3221 +extern int osl_sprintf(char *buf, const char *format, ...);
3222 +extern int osl_strcmp(const char *s1, const char *s2);
3223 +extern int osl_strncmp(const char *s1, const char *s2, uint n);
3224 +extern int osl_strlen(const char *s);
3225 +extern char* osl_strcpy(char *d, const char *s);
3226 +extern char* osl_strncpy(char *d, const char *s, uint n);
3228 +/* register access macros */
3229 +#if !defined(BCMJTAG)
3230 +#define R_REG(r) ( \
3231 + sizeof(*(r)) == sizeof(uint8) ? osl_readb((volatile uint8*)(r)) : \
3232 + sizeof(*(r)) == sizeof(uint16) ? osl_readw((volatile uint16*)(r)) : \
3233 + osl_readl((volatile uint32*)(r)) \
3235 +#define W_REG(r, v) do { \
3236 + switch (sizeof(*(r))) { \
3237 + case sizeof(uint8): osl_writeb((uint8)(v), (volatile uint8*)(r)); break; \
3238 + case sizeof(uint16): osl_writew((uint16)(v), (volatile uint16*)(r)); break; \
3239 + case sizeof(uint32): osl_writel((uint32)(v), (volatile uint32*)(r)); break; \
3244 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3245 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3246 +extern uint8 osl_readb(volatile uint8 *r);
3247 +extern uint16 osl_readw(volatile uint16 *r);
3248 +extern uint32 osl_readl(volatile uint32 *r);
3249 +extern void osl_writeb(uint8 v, volatile uint8 *r);
3250 +extern void osl_writew(uint16 v, volatile uint16 *r);
3251 +extern void osl_writel(uint32 v, volatile uint32 *r);
3253 +/* bcopy, bcmp, and bzero */
3254 +extern void bcopy(const void *src, void *dst, int len);
3255 +extern int bcmp(const void *b1, const void *b2, int len);
3256 +extern void bzero(void *b, int len);
3258 +/* uncached virtual address */
3259 +#define OSL_UNCACHED(va) osl_uncached((va))
3260 +extern void *osl_uncached(void *va);
3262 +/* get processor cycle count */
3263 +#define OSL_GETCYCLES(x) ((x) = osl_getcycles())
3264 +extern uint osl_getcycles(void);
3266 +/* dereference an address that may target abort */
3267 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (addr))
3268 +extern int osl_busprobe(uint32 *val, uint32 addr);
3270 +/* map/unmap physical to virtual */
3271 +#define REG_MAP(pa, size) osl_reg_map((pa), (size))
3272 +#define REG_UNMAP(va) osl_reg_unmap((va))
3273 +extern void *osl_reg_map(uint32 pa, uint size);
3274 +extern void osl_reg_unmap(void *va);
3276 +/* shared (dma-able) memory access macros */
3277 +#define R_SM(r) *(r)
3278 +#define W_SM(r, v) (*(r) = (v))
3279 +#define BZERO_SM(r, len) bzero((r), (len))
3281 +/* packet primitives */
3282 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
3283 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
3284 +#define PKTDATA(osh, skb) osl_pktdata((osh), (skb))
3285 +#define PKTLEN(osh, skb) osl_pktlen((osh), (skb))
3286 +#define PKTHEADROOM(osh, skb) osl_pktheadroom((osh), (skb))
3287 +#define PKTTAILROOM(osh, skb) osl_pkttailroom((osh), (skb))
3288 +#define PKTNEXT(osh, skb) osl_pktnext((osh), (skb))
3289 +#define PKTSETNEXT(skb, x) osl_pktsetnext((skb), (x))
3290 +#define PKTSETLEN(osh, skb, len) osl_pktsetlen((osh), (skb), (len))
3291 +#define PKTPUSH(osh, skb, bytes) osl_pktpush((osh), (skb), (bytes))
3292 +#define PKTPULL(osh, skb, bytes) osl_pktpull((osh), (skb), (bytes))
3293 +#define PKTDUP(osh, skb) osl_pktdup((osh), (skb))
3294 +#define PKTCOOKIE(skb) osl_pktcookie((skb))
3295 +#define PKTSETCOOKIE(skb, x) osl_pktsetcookie((skb), (x))
3296 +#define PKTLINK(skb) osl_pktlink((skb))
3297 +#define PKTSETLINK(skb, x) osl_pktsetlink((skb), (x))
3298 +#define PKTPRIO(skb) osl_pktprio((skb))
3299 +#define PKTSETPRIO(skb, x) osl_pktsetprio((skb), (x))
3300 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
3301 +extern void osl_pktfree(void *skb);
3302 +extern uchar *osl_pktdata(osl_t *osh, void *skb);
3303 +extern uint osl_pktlen(osl_t *osh, void *skb);
3304 +extern uint osl_pktheadroom(osl_t *osh, void *skb);
3305 +extern uint osl_pkttailroom(osl_t *osh, void *skb);
3306 +extern void *osl_pktnext(osl_t *osh, void *skb);
3307 +extern void osl_pktsetnext(void *skb, void *x);
3308 +extern void osl_pktsetlen(osl_t *osh, void *skb, uint len);
3309 +extern uchar *osl_pktpush(osl_t *osh, void *skb, int bytes);
3310 +extern uchar *osl_pktpull(osl_t *osh, void *skb, int bytes);
3311 +extern void *osl_pktdup(osl_t *osh, void *skb);
3312 +extern void *osl_pktcookie(void *skb);
3313 +extern void osl_pktsetcookie(void *skb, void *x);
3314 +extern void *osl_pktlink(void *skb);
3315 +extern void osl_pktsetlink(void *skb, void *x);
3316 +extern uint osl_pktprio(void *skb);
3317 +extern void osl_pktsetprio(void *skb, uint x);
3319 +#endif /* BINOSL */
3321 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
3322 +extern int osl_error(int bcmerror);
3324 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
3325 +#define PKTBUFSZ 2048
3327 +#endif /* _linux_osl_h_ */
3328 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/linuxver.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/linuxver.h
3329 --- linux-2.4.32/arch/mips/bcm947xx/include/linuxver.h 1970-01-01 01:00:00.000000000 +0100
3330 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/linuxver.h 2005-12-16 23:39:10.748824500 +0100
3333 + * Linux-specific abstractions to gain some independence from linux kernel versions.
3334 + * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
3336 + * Copyright 2005, Broadcom Corporation
3337 + * All Rights Reserved.
3339 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3340 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3341 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3342 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3347 +#ifndef _linuxver_h_
3348 +#define _linuxver_h_
3350 +#include <linux/config.h>
3351 +#include <linux/version.h>
3353 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
3354 +/* __NO_VERSION__ must be defined for all linkables except one in 2.2 */
3355 +#ifdef __UNDEF_NO_VERSION__
3356 +#undef __NO_VERSION__
3358 +#define __NO_VERSION__
3362 +#if defined(MODULE) && defined(MODVERSIONS)
3363 +#include <linux/modversions.h>
3366 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
3367 +#include <linux/moduleparam.h>
3371 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
3372 +#define module_param(_name_, _type_, _perm_) MODULE_PARM(_name_, "i")
3373 +#define module_param_string(_name_, _string_, _size_, _perm_) MODULE_PARM(_string_, "c" __MODULE_STRING(_size_))
3376 +/* linux/malloc.h is deprecated, use linux/slab.h instead. */
3377 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9))
3378 +#include <linux/malloc.h>
3380 +#include <linux/slab.h>
3383 +#include <linux/types.h>
3384 +#include <linux/init.h>
3385 +#include <linux/mm.h>
3386 +#include <linux/string.h>
3387 +#include <linux/pci.h>
3388 +#include <linux/interrupt.h>
3389 +#include <linux/netdevice.h>
3390 +#include <asm/io.h>
3392 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41))
3393 +#include <linux/workqueue.h>
3395 +#include <linux/tqueue.h>
3396 +#ifndef work_struct
3397 +#define work_struct tq_struct
3400 +#define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
3402 +#ifndef schedule_work
3403 +#define schedule_work(_work) schedule_task((_work))
3405 +#ifndef flush_scheduled_work
3406 +#define flush_scheduled_work() flush_scheduled_tasks()
3410 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
3411 +/* Some distributions have their own 2.6.x compatibility layers */
3413 +typedef void irqreturn_t;
3415 +#define IRQ_HANDLED
3416 +#define IRQ_RETVAL(x)
3419 +typedef irqreturn_t (*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs);
3422 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
3424 +#include <pcmcia/version.h>
3425 +#include <pcmcia/cs_types.h>
3426 +#include <pcmcia/cs.h>
3427 +#include <pcmcia/cistpl.h>
3428 +#include <pcmcia/cisreg.h>
3429 +#include <pcmcia/ds.h>
3431 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,69))
3432 +/* In 2.5 (as of 2.5.69 at least) there is a cs_error exported which
3433 + * does this, but it's not in 2.4 so we do our own for now. */
3435 +cs_error(client_handle_t handle, int func, int ret)
3437 + error_info_t err = { func, ret };
3438 + CardServices(ReportError, handle, &err);
3442 +#endif /* CONFIG_PCMCIA */
3451 +#define __devinit __init
3453 +#ifndef __devinitdata
3454 +#define __devinitdata
3456 +#ifndef __devexit_p
3457 +#define __devexit_p(x) x
3460 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
3462 +#define pci_get_drvdata(dev) (dev)->sysdata
3463 +#define pci_set_drvdata(dev, value) (dev)->sysdata=(value)
3466 + * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
3469 +struct pci_device_id {
3470 + unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
3471 + unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
3472 + unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
3473 + unsigned long driver_data; /* Data private to the driver */
3476 +struct pci_driver {
3477 + struct list_head node;
3479 + const struct pci_device_id *id_table; /* NULL if wants all devices */
3480 + int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
3481 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
3482 + void (*suspend)(struct pci_dev *dev); /* Device suspended */
3483 + void (*resume)(struct pci_dev *dev); /* Device woken up */
3486 +#define MODULE_DEVICE_TABLE(type, name)
3487 +#define PCI_ANY_ID (~0)
3490 +#define pci_module_init pci_register_driver
3491 +extern int pci_register_driver(struct pci_driver *drv);
3492 +extern void pci_unregister_driver(struct pci_driver *drv);
3494 +#endif /* PCI registration */
3496 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
3498 +#define module_init(x) int init_module(void) { return x(); }
3499 +#define module_exit(x) void cleanup_module(void) { x(); }
3501 +#define module_init(x) __initcall(x);
3502 +#define module_exit(x) __exitcall(x);
3506 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,48))
3507 +#define list_for_each(pos, head) \
3508 + for (pos = (head)->next; pos != (head); pos = pos->next)
3511 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,13))
3512 +#define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
3513 +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,44))
3514 +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
3517 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,23))
3518 +#define pci_enable_device(dev) do { } while (0)
3521 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,14))
3522 +#define net_device device
3525 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,42))
3530 + * See linux/Documentation/DMA-mapping.txt
3533 +#ifndef PCI_DMA_TODEVICE
3534 +#define PCI_DMA_TODEVICE 1
3535 +#define PCI_DMA_FROMDEVICE 2
3538 +typedef u32 dma_addr_t;
3540 +/* Pure 2^n version of get_order */
3541 +static inline int get_order(unsigned long size)
3545 + size = (size-1) >> (PAGE_SHIFT-1);
3554 +static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
3555 + dma_addr_t *dma_handle)
3558 + int gfp = GFP_ATOMIC | GFP_DMA;
3560 + ret = (void *)__get_free_pages(gfp, get_order(size));
3562 + if (ret != NULL) {
3563 + memset(ret, 0, size);
3564 + *dma_handle = virt_to_bus(ret);
3568 +static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
3569 + void *vaddr, dma_addr_t dma_handle)
3571 + free_pages((unsigned long)vaddr, get_order(size));
3574 +extern uint pci_map_single(void *dev, void *va, uint size, int direction);
3575 +extern void pci_unmap_single(void *dev, uint pa, uint size, int direction);
3577 +#define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
3578 +#define pci_unmap_single(cookie, address, size, dir)
3581 +#endif /* DMA mapping */
3583 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43))
3585 +#define dev_kfree_skb_any(a) dev_kfree_skb(a)
3586 +#define netif_down(dev) do { (dev)->start = 0; } while(0)
3588 +/* pcmcia-cs provides its own netdevice compatibility layer */
3589 +#ifndef _COMPAT_NETDEVICE_H
3594 + * For pre-softnet kernels we need to tell the upper layer not to
3595 + * re-enter start_xmit() while we are in there. However softnet
3596 + * guarantees not to enter while we are in there so there is no need
3597 + * to do the netif_stop_queue() dance unless the transmit queue really
3598 + * gets stuck. This should also improve performance according to tests
3599 + * done by Aman Singla.
3602 +#define dev_kfree_skb_irq(a) dev_kfree_skb(a)
3603 +#define netif_wake_queue(dev) do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while(0)
3604 +#define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy)
3606 +static inline void netif_start_queue(struct net_device *dev)
3609 + dev->interrupt = 0;
3613 +#define netif_queue_stopped(dev) (dev)->tbusy
3614 +#define netif_running(dev) (dev)->start
3616 +#endif /* _COMPAT_NETDEVICE_H */
3618 +#define netif_device_attach(dev) netif_start_queue(dev)
3619 +#define netif_device_detach(dev) netif_stop_queue(dev)
3621 +/* 2.4.x renamed bottom halves to tasklets */
3622 +#define tasklet_struct tq_struct
3623 +static inline void tasklet_schedule(struct tasklet_struct *tasklet)
3625 + queue_task(tasklet, &tq_immediate);
3626 + mark_bh(IMMEDIATE_BH);
3629 +static inline void tasklet_init(struct tasklet_struct *tasklet,
3630 + void (*func)(unsigned long),
3631 + unsigned long data)
3633 + tasklet->next = NULL;
3634 + tasklet->sync = 0;
3635 + tasklet->routine = (void (*)(void *))func;
3636 + tasklet->data = (void *)data;
3638 +#define tasklet_kill(tasklet) {do{} while(0);}
3640 +/* 2.4.x introduced del_timer_sync() */
3641 +#define del_timer_sync(timer) del_timer(timer)
3645 +#define netif_down(dev)
3647 +#endif /* SoftNet */
3649 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3))
3652 + * Emit code to initialise a tq_struct's routine and data pointers
3654 +#define PREPARE_TQUEUE(_tq, _routine, _data) \
3656 + (_tq)->routine = _routine; \
3657 + (_tq)->data = _data; \
3661 + * Emit code to initialise all of a tq_struct
3663 +#define INIT_TQUEUE(_tq, _routine, _data) \
3665 + INIT_LIST_HEAD(&(_tq)->list); \
3666 + (_tq)->sync = 0; \
3667 + PREPARE_TQUEUE((_tq), (_routine), (_data)); \
3672 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6))
3674 +/* Power management related routines */
3677 +pci_save_state(struct pci_dev *dev, u32 *buffer)
3681 + for (i = 0; i < 16; i++)
3682 + pci_read_config_dword(dev, i * 4,&buffer[i]);
3688 +pci_restore_state(struct pci_dev *dev, u32 *buffer)
3693 + for (i = 0; i < 16; i++)
3694 + pci_write_config_dword(dev,i * 4, buffer[i]);
3697 + * otherwise, write the context information we know from bootup.
3698 + * This works around a problem where warm-booting from Windows
3699 + * combined with a D3(hot)->D0 transition causes PCI config
3700 + * header data to be forgotten.
3703 + for (i = 0; i < 6; i ++)
3704 + pci_write_config_dword(dev,
3705 + PCI_BASE_ADDRESS_0 + (i * 4),
3706 + pci_resource_start(dev, i));
3707 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
3712 +#endif /* PCI power management */
3714 +/* Old cp0 access macros deprecated in 2.4.19 */
3715 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19))
3716 +#define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
3719 +/* Module refcount handled internally in 2.6.x */
3720 +#ifndef SET_MODULE_OWNER
3721 +#define SET_MODULE_OWNER(dev) do {} while (0)
3722 +#define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
3723 +#define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
3725 +#define OLD_MOD_INC_USE_COUNT do {} while (0)
3726 +#define OLD_MOD_DEC_USE_COUNT do {} while (0)
3729 +#ifndef SET_NETDEV_DEV
3730 +#define SET_NETDEV_DEV(net, pdev) do {} while (0)
3733 +#ifndef HAVE_FREE_NETDEV
3734 +#define free_netdev(dev) kfree(dev)
3737 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
3738 +/* struct packet_type redefined in 2.6.x */
3739 +#define af_packet_priv data
3742 +#endif /* _linuxver_h_ */
3743 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/min_osl.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/min_osl.h
3744 --- linux-2.4.32/arch/mips/bcm947xx/include/min_osl.h 1970-01-01 01:00:00.000000000 +0100
3745 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/min_osl.h 2005-12-16 23:39:10.748824500 +0100
3748 + * HND Minimal OS Abstraction Layer.
3750 + * Copyright 2005, Broadcom Corporation
3751 + * All Rights Reserved.
3753 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3754 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3755 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3756 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3761 +#ifndef _min_osl_h_
3762 +#define _min_osl_h_
3764 +#include <typedefs.h>
3765 +#include <sbconfig.h>
3766 +#include <mipsinc.h>
3768 +/* Cache support */
3769 +extern void caches_on(void);
3770 +extern void blast_dcache(void);
3771 +extern void blast_icache(void);
3774 +extern void putc(int c);
3776 +/* lib functions */
3777 +extern int printf(const char *fmt, ...);
3778 +extern int sprintf(char *buf, const char *fmt, ...);
3779 +extern int strcmp(const char *s1, const char *s2);
3780 +extern int strncmp(const char *s1, const char *s2, uint n);
3781 +extern char *strcpy(char *dest, const char *src);
3782 +extern char *strncpy(char *dest, const char *src, uint n);
3783 +extern uint strlen(const char *s);
3784 +extern char *strchr(const char *str,int c);
3785 +extern char *strrchr(const char *str, int c);
3786 +extern char *strcat(char *d, const char *s);
3787 +extern void *memset(void *dest, int c, uint n);
3788 +extern void *memcpy(void *dest, const void *src, uint n);
3789 +extern int memcmp(const void *s1, const void *s2, uint n);
3790 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
3791 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
3792 +#define bzero(b, len) memset((b), '\0', (len))
3794 +/* assert & debugging */
3795 +#define ASSERT(exp) do {} while (0)
3797 +/* PCMCIA attribute space access macros */
3798 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
3800 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
3803 +/* PCI configuration space access macros */
3804 +#define OSL_PCI_READ_CONFIG(loc, offset, size) \
3805 + (offset == 8 ? 0 : 0xffffffff)
3806 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) \
3809 +/* PCI device bus # and slot # */
3810 +#define OSL_PCI_BUS(osh) (0)
3811 +#define OSL_PCI_SLOT(osh) (0)
3813 +/* register access macros */
3814 +#define wreg32(r, v) (*(volatile uint32*)(r) = (uint32)(v))
3815 +#define rreg32(r) (*(volatile uint32*)(r))
3816 +#define wreg16(r, v) (*(volatile uint16*)(r) = (uint16)(v))
3817 +#define rreg16(r) (*(volatile uint16*)(r))
3818 +#define wreg8(r, v) (*(volatile uint8*)(r) = (uint8)(v))
3819 +#define rreg8(r) (*(volatile uint8*)(r))
3820 +#define R_REG(r) ({ \
3821 + __typeof(*(r)) __osl_v; \
3822 + switch (sizeof(*(r))) { \
3823 + case sizeof(uint8): __osl_v = rreg8((r)); break; \
3824 + case sizeof(uint16): __osl_v = rreg16((r)); break; \
3825 + case sizeof(uint32): __osl_v = rreg32((r)); break; \
3829 +#define W_REG(r, v) do { \
3830 + switch (sizeof(*(r))) { \
3831 + case sizeof(uint8): wreg8((r), (v)); break; \
3832 + case sizeof(uint16): wreg16((r), (v)); break; \
3833 + case sizeof(uint32): wreg32((r), (v)); break; \
3836 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
3837 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
3839 +/* general purpose memory allocation */
3840 +#define MALLOC(osh, size) malloc(size)
3841 +#define MFREE(osh, addr, size) free(addr)
3842 +#define MALLOCED(osh) 0
3843 +#define MALLOC_FAILED(osh) 0
3844 +#define MALLOC_DUMP(osh, buf, sz)
3845 +extern int free(void *ptr);
3846 +extern void *malloc(uint size);
3848 +/* uncached virtual address */
3849 +#define OSL_UNCACHED(va) ((void*)KSEG1ADDR((ulong)(va)))
3851 +/* host/bus architecture-specific address byte swap */
3852 +#define BUS_SWAP32(v) (v)
3854 +/* microsecond delay */
3855 +#define OSL_DELAY(usec) udelay(usec)
3856 +extern void udelay(uint32 usec);
3858 +/* map/unmap physical to virtual I/O */
3859 +#define REG_MAP(pa, size) ((void*)KSEG1ADDR((ulong)(pa)))
3860 +#define REG_UNMAP(va) do {} while (0)
3862 +/* dereference an address that may cause a bus exception */
3863 +#define BUSPROBE(val, addr) (uint32 *)(addr) = (val)
3866 +#define osl_attach(pdev) ((osl_t*)pdev)
3867 +#define osl_detach(osh)
3868 +extern void *osl_init(void);
3869 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
3870 +extern int osl_error(int);
3872 +#endif /* _min_osl_h_ */
3873 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/mipsinc.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/mipsinc.h
3874 --- linux-2.4.32/arch/mips/bcm947xx/include/mipsinc.h 1970-01-01 01:00:00.000000000 +0100
3875 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/mipsinc.h 2005-12-16 23:39:10.748824500 +0100
3878 + * HND Run Time Environment for standalone MIPS programs.
3880 + * Copyright 2005, Broadcom Corporation
3881 + * All Rights Reserved.
3883 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3884 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3885 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3886 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3897 +#ifdef _LANGUAGE_ASSEMBLY
3900 + * Symbolic register names for 32 bit ABI
3902 +#define zero $0 /* wired zero */
3903 +#define AT $1 /* assembler temp - uppercase because of ".set at" */
3904 +#define v0 $2 /* return value */
3906 +#define a0 $4 /* argument registers */
3910 +#define t0 $8 /* caller saved */
3918 +#define s0 $16 /* callee saved */
3926 +#define t8 $24 /* caller saved */
3928 +#define jp $25 /* PIC jump register */
3929 +#define k0 $26 /* kernel scratch */
3931 +#define gp $28 /* global pointer */
3932 +#define sp $29 /* stack pointer */
3933 +#define fp $30 /* frame pointer */
3934 +#define s8 $30 /* same like fp! */
3935 +#define ra $31 /* return address */
3944 +#define C0_TLBLO0 $2
3945 +#define C0_TLBLO C0_TLBLO0
3946 +#define C0_TLBLO1 $3
3947 +#define C0_CTEXT $4
3948 +#define C0_PGMASK $5
3949 +#define C0_WIRED $6
3950 +#define C0_BADVADDR $8
3951 +#define C0_COUNT $9
3952 +#define C0_TLBHI $10
3953 +#define C0_COMPARE $11
3955 +#define C0_STATUS C0_SR
3956 +#define C0_CAUSE $13
3958 +#define C0_PRID $15
3959 +#define C0_CONFIG $16
3960 +#define C0_LLADDR $17
3961 +#define C0_WATCHLO $18
3962 +#define C0_WATCHHI $19
3963 +#define C0_XCTEXT $20
3964 +#define C0_DIAGNOSTIC $22
3965 +#define C0_BROADCOM C0_DIAGNOSTIC
3966 +#define C0_PERFORMANCE $25
3968 +#define C0_CACHEERR $27
3969 +#define C0_TAGLO $28
3970 +#define C0_TAGHI $29
3971 +#define C0_ERREPC $30
3972 +#define C0_DESAVE $31
3975 + * LEAF - declare leaf routine
3977 +#define LEAF(symbol) \
3980 + .type symbol,@function; \
3982 +symbol: .frame sp,0,ra
3985 + * END - mark end of function
3987 +#define END(function) \
3989 + .size function,.-function
3996 + * The following macros are especially useful for __asm__
3997 + * inline assembler.
4000 +#define __STR(x) #x
4003 +#define STR(x) __STR(x)
4006 +#define _ULCAST_ (unsigned long)
4013 +#define C0_INX 0 /* CP0: TLB Index */
4014 +#define C0_RAND 1 /* CP0: TLB Random */
4015 +#define C0_TLBLO0 2 /* CP0: TLB EntryLo0 */
4016 +#define C0_TLBLO C0_TLBLO0 /* CP0: TLB EntryLo0 */
4017 +#define C0_TLBLO1 3 /* CP0: TLB EntryLo1 */
4018 +#define C0_CTEXT 4 /* CP0: Context */
4019 +#define C0_PGMASK 5 /* CP0: TLB PageMask */
4020 +#define C0_WIRED 6 /* CP0: TLB Wired */
4021 +#define C0_BADVADDR 8 /* CP0: Bad Virtual Address */
4022 +#define C0_COUNT 9 /* CP0: Count */
4023 +#define C0_TLBHI 10 /* CP0: TLB EntryHi */
4024 +#define C0_COMPARE 11 /* CP0: Compare */
4025 +#define C0_SR 12 /* CP0: Processor Status */
4026 +#define C0_STATUS C0_SR /* CP0: Processor Status */
4027 +#define C0_CAUSE 13 /* CP0: Exception Cause */
4028 +#define C0_EPC 14 /* CP0: Exception PC */
4029 +#define C0_PRID 15 /* CP0: Processor Revision Indentifier */
4030 +#define C0_CONFIG 16 /* CP0: Config */
4031 +#define C0_LLADDR 17 /* CP0: LLAddr */
4032 +#define C0_WATCHLO 18 /* CP0: WatchpointLo */
4033 +#define C0_WATCHHI 19 /* CP0: WatchpointHi */
4034 +#define C0_XCTEXT 20 /* CP0: XContext */
4035 +#define C0_DIAGNOSTIC 22 /* CP0: Diagnostic */
4036 +#define C0_BROADCOM C0_DIAGNOSTIC /* CP0: Broadcom Register */
4037 +#define C0_PERFORMANCE 25 /* CP0: Performance Counter/Control Registers */
4038 +#define C0_ECC 26 /* CP0: ECC */
4039 +#define C0_CACHEERR 27 /* CP0: CacheErr */
4040 +#define C0_TAGLO 28 /* CP0: TagLo */
4041 +#define C0_TAGHI 29 /* CP0: TagHi */
4042 +#define C0_ERREPC 30 /* CP0: ErrorEPC */
4043 +#define C0_DESAVE 31 /* CP0: DebugSave */
4045 +#endif /* _LANGUAGE_ASSEMBLY */
4048 + * Memory segments (32bit kernel mode addresses)
4055 +#define KUSEG 0x00000000
4056 +#define KSEG0 0x80000000
4057 +#define KSEG1 0xa0000000
4058 +#define KSEG2 0xc0000000
4059 +#define KSEG3 0xe0000000
4060 +#define PHYSADDR_MASK 0x1fffffff
4063 + * Map an address to a certain kernel segment
4071 +#define PHYSADDR(a) (_ULCAST_(a) & PHYSADDR_MASK)
4072 +#define KSEG0ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG0)
4073 +#define KSEG1ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG1)
4074 +#define KSEG2ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG2)
4075 +#define KSEG3ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG3)
4078 +#ifndef Index_Invalidate_I
4080 + * Cache Operations
4082 +#define Index_Invalidate_I 0x00
4083 +#define Index_Writeback_Inv_D 0x01
4084 +#define Index_Invalidate_SI 0x02
4085 +#define Index_Writeback_Inv_SD 0x03
4086 +#define Index_Load_Tag_I 0x04
4087 +#define Index_Load_Tag_D 0x05
4088 +#define Index_Load_Tag_SI 0x06
4089 +#define Index_Load_Tag_SD 0x07
4090 +#define Index_Store_Tag_I 0x08
4091 +#define Index_Store_Tag_D 0x09
4092 +#define Index_Store_Tag_SI 0x0A
4093 +#define Index_Store_Tag_SD 0x0B
4094 +#define Create_Dirty_Excl_D 0x0d
4095 +#define Create_Dirty_Excl_SD 0x0f
4096 +#define Hit_Invalidate_I 0x10
4097 +#define Hit_Invalidate_D 0x11
4098 +#define Hit_Invalidate_SI 0x12
4099 +#define Hit_Invalidate_SD 0x13
4100 +#define Fill_I 0x14
4101 +#define Hit_Writeback_Inv_D 0x15
4102 + /* 0x16 is unused */
4103 +#define Hit_Writeback_Inv_SD 0x17
4104 +#define R5K_Page_Invalidate_S 0x17
4105 +#define Hit_Writeback_I 0x18
4106 +#define Hit_Writeback_D 0x19
4107 + /* 0x1a is unused */
4108 +#define Hit_Writeback_SD 0x1b
4109 + /* 0x1c is unused */
4110 + /* 0x1e is unused */
4111 +#define Hit_Set_Virtual_SI 0x1e
4112 +#define Hit_Set_Virtual_SD 0x1f
4117 + * R4x00 interrupt enable / cause bits
4119 +#define IE_SW0 (_ULCAST_(1) << 8)
4120 +#define IE_SW1 (_ULCAST_(1) << 9)
4121 +#define IE_IRQ0 (_ULCAST_(1) << 10)
4122 +#define IE_IRQ1 (_ULCAST_(1) << 11)
4123 +#define IE_IRQ2 (_ULCAST_(1) << 12)
4124 +#define IE_IRQ3 (_ULCAST_(1) << 13)
4125 +#define IE_IRQ4 (_ULCAST_(1) << 14)
4126 +#define IE_IRQ5 (_ULCAST_(1) << 15)
4130 + * Bitfields in the mips32 cp0 status register
4132 +#define ST0_IE 0x00000001
4133 +#define ST0_EXL 0x00000002
4134 +#define ST0_ERL 0x00000004
4135 +#define ST0_UM 0x00000010
4136 +#define ST0_SWINT0 0x00000100
4137 +#define ST0_SWINT1 0x00000200
4138 +#define ST0_HWINT0 0x00000400
4139 +#define ST0_HWINT1 0x00000800
4140 +#define ST0_HWINT2 0x00001000
4141 +#define ST0_HWINT3 0x00002000
4142 +#define ST0_HWINT4 0x00004000
4143 +#define ST0_HWINT5 0x00008000
4144 +#define ST0_IM 0x0000ff00
4145 +#define ST0_NMI 0x00080000
4146 +#define ST0_SR 0x00100000
4147 +#define ST0_TS 0x00200000
4148 +#define ST0_BEV 0x00400000
4149 +#define ST0_RE 0x02000000
4150 +#define ST0_RP 0x08000000
4151 +#define ST0_CU 0xf0000000
4152 +#define ST0_CU0 0x10000000
4153 +#define ST0_CU1 0x20000000
4154 +#define ST0_CU2 0x40000000
4155 +#define ST0_CU3 0x80000000
4160 + * Bitfields in the mips32 cp0 cause register
4162 +#define C_EXC 0x0000007c
4163 +#define C_EXC_SHIFT 2
4164 +#define C_INT 0x0000ff00
4165 +#define C_INT_SHIFT 8
4166 +#define C_SW0 (_ULCAST_(1) << 8)
4167 +#define C_SW1 (_ULCAST_(1) << 9)
4168 +#define C_IRQ0 (_ULCAST_(1) << 10)
4169 +#define C_IRQ1 (_ULCAST_(1) << 11)
4170 +#define C_IRQ2 (_ULCAST_(1) << 12)
4171 +#define C_IRQ3 (_ULCAST_(1) << 13)
4172 +#define C_IRQ4 (_ULCAST_(1) << 14)
4173 +#define C_IRQ5 (_ULCAST_(1) << 15)
4174 +#define C_WP 0x00400000
4175 +#define C_IV 0x00800000
4176 +#define C_CE 0x30000000
4177 +#define C_CE_SHIFT 28
4178 +#define C_BD 0x80000000
4180 +/* Values in C_EXC */
4195 +#define EXC_WATCH 23
4196 +#define EXC_MCHK 24
4200 + * Bits in the cp0 config register.
4202 +#define CONF_CM_CACHABLE_NO_WA 0
4203 +#define CONF_CM_CACHABLE_WA 1
4204 +#define CONF_CM_UNCACHED 2
4205 +#define CONF_CM_CACHABLE_NONCOHERENT 3
4206 +#define CONF_CM_CACHABLE_CE 4
4207 +#define CONF_CM_CACHABLE_COW 5
4208 +#define CONF_CM_CACHABLE_CUW 6
4209 +#define CONF_CM_CACHABLE_ACCELERATED 7
4210 +#define CONF_CM_CMASK 7
4211 +#define CONF_CU (_ULCAST_(1) << 3)
4212 +#define CONF_DB (_ULCAST_(1) << 4)
4213 +#define CONF_IB (_ULCAST_(1) << 5)
4214 +#define CONF_SE (_ULCAST_(1) << 12)
4215 +#define CONF_SC (_ULCAST_(1) << 17)
4216 +#define CONF_AC (_ULCAST_(1) << 23)
4217 +#define CONF_HALT (_ULCAST_(1) << 25)
4221 + * Bits in the cp0 config register select 1.
4223 +#define CONF1_FP 0x00000001 /* FPU present */
4224 +#define CONF1_EP 0x00000002 /* EJTAG present */
4225 +#define CONF1_CA 0x00000004 /* mips16 implemented */
4226 +#define CONF1_WR 0x00000008 /* Watch registers present */
4227 +#define CONF1_PC 0x00000010 /* Performance counters present */
4228 +#define CONF1_DA_SHIFT 7 /* D$ associativity */
4229 +#define CONF1_DA_MASK 0x00000380
4230 +#define CONF1_DA_BASE 1
4231 +#define CONF1_DL_SHIFT 10 /* D$ line size */
4232 +#define CONF1_DL_MASK 0x00001c00
4233 +#define CONF1_DL_BASE 2
4234 +#define CONF1_DS_SHIFT 13 /* D$ sets/way */
4235 +#define CONF1_DS_MASK 0x0000e000
4236 +#define CONF1_DS_BASE 64
4237 +#define CONF1_IA_SHIFT 16 /* I$ associativity */
4238 +#define CONF1_IA_MASK 0x00070000
4239 +#define CONF1_IA_BASE 1
4240 +#define CONF1_IL_SHIFT 19 /* I$ line size */
4241 +#define CONF1_IL_MASK 0x00380000
4242 +#define CONF1_IL_BASE 2
4243 +#define CONF1_IS_SHIFT 22 /* Instruction cache sets/way */
4244 +#define CONF1_IS_MASK 0x01c00000
4245 +#define CONF1_IS_BASE 64
4246 +#define CONF1_MS_MASK 0x7e000000 /* Number of tlb entries */
4247 +#define CONF1_MS_SHIFT 25
4249 +/* PRID register */
4250 +#define PRID_COPT_MASK 0xff000000
4251 +#define PRID_COMP_MASK 0x00ff0000
4252 +#define PRID_IMP_MASK 0x0000ff00
4253 +#define PRID_REV_MASK 0x000000ff
4255 +#define PRID_COMP_LEGACY 0x000000
4256 +#define PRID_COMP_MIPS 0x010000
4257 +#define PRID_COMP_BROADCOM 0x020000
4258 +#define PRID_COMP_ALCHEMY 0x030000
4259 +#define PRID_COMP_SIBYTE 0x040000
4260 +#define PRID_IMP_BCM4710 0x4000
4261 +#define PRID_IMP_BCM3302 0x9000
4262 +#define PRID_IMP_BCM3303 0x9100
4264 +#define PRID_IMP_UNKNOWN 0xff00
4266 +#define BCM330X(id) \
4267 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
4268 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
4270 +/* Bits in C0_BROADCOM */
4271 +#define BRCM_PFC_AVAIL 0x20000000 /* PFC is available */
4272 +#define BRCM_DC_ENABLE 0x40000000 /* Enable Data $ */
4273 +#define BRCM_IC_ENABLE 0x80000000 /* Enable Instruction $ */
4274 +#define BRCM_PFC_ENABLE 0x00400000 /* Obsolete? Enable PFC (at least on 4310) */
4276 +/* PreFetch Cache aka Read Ahead Cache */
4278 +#define PFC_CR0 0xff400000 /* control reg 0 */
4279 +#define PFC_CR1 0xff400004 /* control reg 1 */
4281 +/* PFC operations */
4282 +#define PFC_I 0x00000001 /* Enable PFC use for instructions */
4283 +#define PFC_D 0x00000002 /* Enable PFC use for data */
4284 +#define PFC_PFI 0x00000004 /* Enable seq. prefetch for instructions */
4285 +#define PFC_PFD 0x00000008 /* Enable seq. prefetch for data */
4286 +#define PFC_CINV 0x00000010 /* Enable selective (i/d) cacheop flushing */
4287 +#define PFC_NCH 0x00000020 /* Disable flushing based on cacheops */
4288 +#define PFC_DPF 0x00000040 /* Enable directional prefetching */
4289 +#define PFC_FLUSH 0x00000100 /* Flush the PFC */
4290 +#define PFC_BRR 0x40000000 /* Bus error indication */
4291 +#define PFC_PWR 0x80000000 /* Disable power saving (clock gating) */
4293 +/* Handy defaults */
4294 +#define PFC_DISABLED 0
4295 +#define PFC_AUTO 0xffffffff /* auto select the default mode */
4296 +#define PFC_INST (PFC_I | PFC_PFI | PFC_CINV)
4297 +#define PFC_INST_NOPF (PFC_I | PFC_CINV)
4298 +#define PFC_DATA (PFC_D | PFC_PFD | PFC_CINV)
4299 +#define PFC_DATA_NOPF (PFC_D | PFC_CINV)
4300 +#define PFC_I_AND_D (PFC_INST | PFC_DATA)
4301 +#define PFC_I_AND_D_NOPF (PFC_INST_NOPF | PFC_DATA_NOPF)
4305 + * These are the UART port assignments, expressed as offsets from the base
4306 + * register. These assignments should hold for any serial port based on
4307 + * a 8250, 16450, or 16550(A).
4310 +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */
4311 +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
4312 +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
4313 +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */
4314 +#define UART_LCR 3 /* Out: Line Control Register */
4315 +#define UART_MCR 4 /* Out: Modem Control Register */
4316 +#define UART_LSR 5 /* In: Line Status Register */
4317 +#define UART_MSR 6 /* In: Modem Status Register */
4318 +#define UART_SCR 7 /* I/O: Scratch Register */
4319 +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
4320 +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
4321 +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
4322 +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
4323 +#define UART_LSR_RXRDY 0x01 /* Receiver ready */
4326 +#ifndef _LANGUAGE_ASSEMBLY
4329 + * Macros to access the system control coprocessor
4332 +#define MFC0(source, sel) \
4335 + __asm__ __volatile__( \
4336 + ".set\tnoreorder\n\t" \
4337 + ".set\tnoat\n\t" \
4338 + ".word\t"STR(0x40010000 | ((source)<<11) | (sel))"\n\t" \
4339 + "move\t%0,$1\n\t" \
4348 +#define MTC0(source, sel, value) \
4350 + __asm__ __volatile__( \
4351 + ".set\tnoreorder\n\t" \
4352 + ".set\tnoat\n\t" \
4353 + "move\t$1,%z0\n\t" \
4354 + ".word\t"STR(0x40810000 | ((source)<<11) | (sel))"\n\t" \
4362 +#define get_c0_count() \
4365 + __asm__ __volatile__( \
4366 + ".set\tnoreorder\n\t" \
4367 + ".set\tnoat\n\t" \
4368 + "mfc0\t%0,$9\n\t" \
4375 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize)
4377 + uint lsz, sets, ways;
4379 + /* Instruction Cache Size = Associativity * Line Size * Sets Per Way */
4380 + if ((lsz = ((config1 & CONF1_IL_MASK) >> CONF1_IL_SHIFT)))
4381 + lsz = CONF1_IL_BASE << lsz;
4382 + sets = CONF1_IS_BASE << ((config1 & CONF1_IS_MASK) >> CONF1_IS_SHIFT);
4383 + ways = CONF1_IA_BASE + ((config1 & CONF1_IA_MASK) >> CONF1_IA_SHIFT);
4384 + *size = lsz * sets * ways;
4388 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize)
4390 + uint lsz, sets, ways;
4392 + /* Data Cache Size = Associativity * Line Size * Sets Per Way */
4393 + if ((lsz = ((config1 & CONF1_DL_MASK) >> CONF1_DL_SHIFT)))
4394 + lsz = CONF1_DL_BASE << lsz;
4395 + sets = CONF1_DS_BASE << ((config1 & CONF1_DS_MASK) >> CONF1_DS_SHIFT);
4396 + ways = CONF1_DA_BASE + ((config1 & CONF1_DA_MASK) >> CONF1_DA_SHIFT);
4397 + *size = lsz * sets * ways;
4401 +#define cache_op(base, op) \
4402 + __asm__ __volatile__(" \
4412 +#define cache_unroll4(base, delta, op) \
4413 + __asm__ __volatile__(" \
4417 + cache %1,delta(%0); \
4418 + cache %1,(2 * delta)(%0); \
4419 + cache %1,(3 * delta)(%0); \
4426 +#endif /* !_LANGUAGE_ASSEMBLY */
4428 +#endif /* _MISPINC_H */
4429 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/nvports.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/nvports.h
4430 --- linux-2.4.32/arch/mips/bcm947xx/include/nvports.h 1970-01-01 01:00:00.000000000 +0100
4431 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/nvports.h 2005-12-16 23:39:10.748824500 +0100
4434 + * BCM53xx RoboSwitch utility functions
4436 + * Copyright (C) 2002 Broadcom Corporation
4440 +#ifndef _nvports_h_
4441 +#define _nvports_h_
4443 +#define uint32 unsigned long
4444 +#define uint16 unsigned short
4445 +#define uint unsigned int
4446 +#define uint8 unsigned char
4447 +#define uint64 unsigned long long
4459 +typedef struct _PORT_ATTRIBS
4467 +nvExistsPortAttrib(char *attrib, uint portno);
4470 +nvExistsAnyForcePortAttrib(uint portno);
4473 +nvSetPortAttrib(char *attrib, uint portno);
4476 +nvUnsetPortAttrib(char *attrib, uint portno);
4479 +nvUnsetAllForcePortAttrib(uint portno);
4481 +extern PORT_ATTRIBS
4482 +nvGetSwitchPortAttribs(uint portno);
4484 +#endif /* _nvports_h_ */
4488 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/osl.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/osl.h
4489 --- linux-2.4.32/arch/mips/bcm947xx/include/osl.h 1970-01-01 01:00:00.000000000 +0100
4490 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/osl.h 2005-12-16 23:39:10.748824500 +0100
4493 + * OS Abstraction Layer
4495 + * Copyright 2005, Broadcom Corporation
4496 + * All Rights Reserved.
4498 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4499 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4500 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4501 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4508 +/* osl handle type forward declaration */
4509 +typedef struct os_handle osl_t;
4512 +#include <linux_osl.h>
4513 +#elif defined(NDIS)
4514 +#include <ndis_osl.h>
4515 +#elif defined(_CFE_)
4516 +#include <cfe_osl.h>
4517 +#elif defined(_HNDRTE_)
4518 +#include <hndrte_osl.h>
4519 +#elif defined(_MINOSL_)
4520 +#include <min_osl.h>
4522 +#include <pmon_osl.h>
4523 +#elif defined(MACOSX)
4524 +#include <macosx_osl.h>
4526 +#error "Unsupported OSL requested"
4530 +#define SET_REG(r, mask, val) W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
4531 +#define MAXPRIO 7 /* 0-7 */
4533 +#endif /* _osl_h_ */
4534 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/pcicfg.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/pcicfg.h
4535 --- linux-2.4.32/arch/mips/bcm947xx/include/pcicfg.h 1970-01-01 01:00:00.000000000 +0100
4536 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/pcicfg.h 2005-12-16 23:39:10.752824750 +0100
4539 + * pcicfg.h: PCI configuration constants and structures.
4541 + * Copyright 2005, Broadcom Corporation
4542 + * All Rights Reserved.
4544 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
4545 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
4546 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
4547 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
4555 +/* The following inside ifndef's so we don't collide with NTDDK.H */
4556 +#ifndef PCI_MAX_BUS
4557 +#define PCI_MAX_BUS 0x100
4559 +#ifndef PCI_MAX_DEVICES
4560 +#define PCI_MAX_DEVICES 0x20
4562 +#ifndef PCI_MAX_FUNCTION
4563 +#define PCI_MAX_FUNCTION 0x8
4566 +#ifndef PCI_INVALID_VENDORID
4567 +#define PCI_INVALID_VENDORID 0xffff
4569 +#ifndef PCI_INVALID_DEVICEID
4570 +#define PCI_INVALID_DEVICEID 0xffff
4574 +/* Convert between bus-slot-function-register and config addresses */
4576 +#define PCICFG_BUS_SHIFT 16 /* Bus shift */
4577 +#define PCICFG_SLOT_SHIFT 11 /* Slot shift */
4578 +#define PCICFG_FUN_SHIFT 8 /* Function shift */
4579 +#define PCICFG_OFF_SHIFT 0 /* Register shift */
4581 +#define PCICFG_BUS_MASK 0xff /* Bus mask */
4582 +#define PCICFG_SLOT_MASK 0x1f /* Slot mask */
4583 +#define PCICFG_FUN_MASK 7 /* Function mask */
4584 +#define PCICFG_OFF_MASK 0xff /* Bus mask */
4586 +#define PCI_CONFIG_ADDR(b, s, f, o) \
4587 + ((((b) & PCICFG_BUS_MASK) << PCICFG_BUS_SHIFT) \
4588 + | (((s) & PCICFG_SLOT_MASK) << PCICFG_SLOT_SHIFT) \
4589 + | (((f) & PCICFG_FUN_MASK) << PCICFG_FUN_SHIFT) \
4590 + | (((o) & PCICFG_OFF_MASK) << PCICFG_OFF_SHIFT))
4592 +#define PCI_CONFIG_BUS(a) (((a) >> PCICFG_BUS_SHIFT) & PCICFG_BUS_MASK)
4593 +#define PCI_CONFIG_SLOT(a) (((a) >> PCICFG_SLOT_SHIFT) & PCICFG_SLOT_MASK)
4594 +#define PCI_CONFIG_FUN(a) (((a) >> PCICFG_FUN_SHIFT) & PCICFG_FUN_MASK)
4595 +#define PCI_CONFIG_OFF(a) (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK)
4597 +/* PCIE Config space accessing MACROS*/
4599 +#define PCIECFG_BUS_SHIFT 24 /* Bus shift */
4600 +#define PCIECFG_SLOT_SHIFT 19 /* Slot/Device shift */
4601 +#define PCIECFG_FUN_SHIFT 16 /* Function shift */
4602 +#define PCIECFG_OFF_SHIFT 0 /* Register shift */
4604 +#define PCIECFG_BUS_MASK 0xff /* Bus mask */
4605 +#define PCIECFG_SLOT_MASK 0x1f /* Slot/Device mask */
4606 +#define PCIECFG_FUN_MASK 7 /* Function mask */
4607 +#define PCIECFG_OFF_MASK 0x3ff /* Register mask */
4609 +#define PCIE_CONFIG_ADDR(b, s, f, o) \
4610 + ((((b) & PCIECFG_BUS_MASK) << PCIECFG_BUS_SHIFT) \
4611 + | (((s) & PCIECFG_SLOT_MASK) << PCIECFG_SLOT_SHIFT) \
4612 + | (((f) & PCIECFG_FUN_MASK) << PCIECFG_FUN_SHIFT) \
4613 + | (((o) & PCIECFG_OFF_MASK) << PCIECFG_OFF_SHIFT))
4615 +#define PCIE_CONFIG_BUS(a) (((a) >> PCIECFG_BUS_SHIFT) & PCIECFG_BUS_MASK)
4616 +#define PCIE_CONFIG_SLOT(a) (((a) >> PCIECFG_SLOT_SHIFT) & PCIECFG_SLOT_MASK)
4617 +#define PCIE_CONFIG_FUN(a) (((a) >> PCIECFG_FUN_SHIFT) & PCIECFG_FUN_MASK)
4618 +#define PCIE_CONFIG_OFF(a) (((a) >> PCIECFG_OFF_SHIFT) & PCIECFG_OFF_MASK)
4621 +/* The actual config space */
4623 +#define PCI_BAR_MAX 6
4625 +#define PCI_ROM_BAR 8
4627 +#define PCR_RSVDA_MAX 2
4629 +/* pci config status reg has a bit to indicate that capability ptr is present*/
4631 +#define PCI_CAPPTR_PRESENT 0x0010
4633 +typedef struct _pci_config_regs {
4634 + unsigned short vendor;
4635 + unsigned short device;
4636 + unsigned short command;
4637 + unsigned short status;
4638 + unsigned char rev_id;
4639 + unsigned char prog_if;
4640 + unsigned char sub_class;
4641 + unsigned char base_class;
4642 + unsigned char cache_line_size;
4643 + unsigned char latency_timer;
4644 + unsigned char header_type;
4645 + unsigned char bist;
4646 + unsigned long base[PCI_BAR_MAX];
4647 + unsigned long cardbus_cis;
4648 + unsigned short subsys_vendor;
4649 + unsigned short subsys_id;
4650 + unsigned long baserom;
4651 + unsigned long rsvd_a[PCR_RSVDA_MAX];
4652 + unsigned char int_line;
4653 + unsigned char int_pin;
4654 + unsigned char min_gnt;
4655 + unsigned char max_lat;
4656 + unsigned char dev_dep[192];
4659 +#define SZPCR (sizeof (pci_config_regs))
4660 +#define MINSZPCR 64 /* offsetof (dev_dep[0] */
4662 +/* A structure for the config registers is nice, but in most
4663 + * systems the config space is not memory mapped, so we need
4664 + * filed offsetts. :-(
4666 +#define PCI_CFG_VID 0
4667 +#define PCI_CFG_DID 2
4668 +#define PCI_CFG_CMD 4
4669 +#define PCI_CFG_STAT 6
4670 +#define PCI_CFG_REV 8
4671 +#define PCI_CFG_PROGIF 9
4672 +#define PCI_CFG_SUBCL 0xa
4673 +#define PCI_CFG_BASECL 0xb
4674 +#define PCI_CFG_CLSZ 0xc
4675 +#define PCI_CFG_LATTIM 0xd
4676 +#define PCI_CFG_HDR 0xe
4677 +#define PCI_CFG_BIST 0xf
4678 +#define PCI_CFG_BAR0 0x10
4679 +#define PCI_CFG_BAR1 0x14
4680 +#define PCI_CFG_BAR2 0x18
4681 +#define PCI_CFG_BAR3 0x1c
4682 +#define PCI_CFG_BAR4 0x20
4683 +#define PCI_CFG_BAR5 0x24
4684 +#define PCI_CFG_CIS 0x28
4685 +#define PCI_CFG_SVID 0x2c
4686 +#define PCI_CFG_SSID 0x2e
4687 +#define PCI_CFG_ROMBAR 0x30
4688 +#define PCI_CFG_CAPPTR 0x34
4689 +#define PCI_CFG_INT 0x3c
4690 +#define PCI_CFG_PIN 0x3d
4691 +#define PCI_CFG_MINGNT 0x3e
4692 +#define PCI_CFG_MAXLAT 0x3f
4694 +/* Classes and subclasses */
4697 + PCI_CLASS_OLD = 0,
4700 + PCI_CLASS_DISPLAY,
4710 + PCI_CLASS_INTELLIGENT = 0xe,
4711 + PCI_CLASS_SATELLITE,
4723 + PCI_DASDI_OTHER = 0x80
4724 +} pci_dasdi_subclasses;
4731 + PCI_NET_OTHER = 0x80
4732 +} pci_net_subclasses;
4738 + PCI_DISPLAY_OTHER = 0x80
4739 +} pci_display_subclasses;
4745 + PCI_MEDIA_OTHER = 0x80
4746 +} pci_mmedia_subclasses;
4751 + PCI_MEMORY_OTHER = 0x80
4752 +} pci_memory_subclasses;
4760 + PCI_BRIDGE_PCMCIA,
4762 + PCI_BRIDGE_CARDBUS,
4763 + PCI_BRIDGE_RACEWAY,
4764 + PCI_BRIDGE_OTHER = 0x80
4765 +} pci_bridge_subclasses;
4769 + PCI_COMM_PARALLEL,
4770 + PCI_COMM_MULTIUART,
4772 + PCI_COMM_OTHER = 0x80
4773 +} pci_comm_subclasses;
4780 + PCI_BASE_PCI_HOTPLUG,
4781 + PCI_BASE_OTHER = 0x80
4782 +} pci_base_subclasses;
4788 + PCI_INPUT_SCANNER,
4789 + PCI_INPUT_GAMEPORT,
4790 + PCI_INPUT_OTHER = 0x80
4791 +} pci_input_subclasses;
4795 + PCI_DOCK_OTHER = 0x80
4796 +} pci_dock_subclasses;
4802 + PCI_CPU_ALPHA = 0x10,
4803 + PCI_CPU_POWERPC = 0x20,
4804 + PCI_CPU_MIPS = 0x30,
4805 + PCI_CPU_COPROC = 0x40,
4806 + PCI_CPU_OTHER = 0x80
4807 +} pci_cpu_subclasses;
4810 + PCI_SERIAL_IEEE1394,
4811 + PCI_SERIAL_ACCESS,
4816 + PCI_SERIAL_OTHER = 0x80
4817 +} pci_serial_subclasses;
4820 + PCI_INTELLIGENT_I2O,
4821 +} pci_intelligent_subclasses;
4825 + PCI_SATELLITE_AUDIO,
4826 + PCI_SATELLITE_VOICE,
4827 + PCI_SATELLITE_DATA,
4828 + PCI_SATELLITE_OTHER = 0x80
4829 +} pci_satellite_subclasses;
4832 + PCI_CRYPT_NETWORK,
4833 + PCI_CRYPT_ENTERTAINMENT,
4834 + PCI_CRYPT_OTHER = 0x80
4835 +} pci_crypt_subclasses;
4839 + PCI_DSP_OTHER = 0x80
4840 +} pci_dsp_subclasses;
4844 + PCI_HEADER_NORMAL,
4845 + PCI_HEADER_BRIDGE,
4846 + PCI_HEADER_CARDBUS
4847 +} pci_header_types;
4850 +/* Overlay for a PCI-to-PCI bridge */
4852 +#define PPB_RSVDA_MAX 2
4853 +#define PPB_RSVDD_MAX 8
4855 +typedef struct _ppb_config_regs {
4856 + unsigned short vendor;
4857 + unsigned short device;
4858 + unsigned short command;
4859 + unsigned short status;
4860 + unsigned char rev_id;
4861 + unsigned char prog_if;
4862 + unsigned char sub_class;
4863 + unsigned char base_class;
4864 + unsigned char cache_line_size;
4865 + unsigned char latency_timer;
4866 + unsigned char header_type;
4867 + unsigned char bist;
4868 + unsigned long rsvd_a[PPB_RSVDA_MAX];
4869 + unsigned char prim_bus;
4870 + unsigned char sec_bus;
4871 + unsigned char sub_bus;
4872 + unsigned char sec_lat;
4873 + unsigned char io_base;
4874 + unsigned char io_lim;
4875 + unsigned short sec_status;
4876 + unsigned short mem_base;
4877 + unsigned short mem_lim;
4878 + unsigned short pf_mem_base;
4879 + unsigned short pf_mem_lim;
4880 + unsigned long pf_mem_base_hi;
4881 + unsigned long pf_mem_lim_hi;
4882 + unsigned short io_base_hi;
4883 + unsigned short io_lim_hi;
4884 + unsigned short subsys_vendor;
4885 + unsigned short subsys_id;
4886 + unsigned long rsvd_b;
4887 + unsigned char rsvd_c;
4888 + unsigned char int_pin;
4889 + unsigned short bridge_ctrl;
4890 + unsigned char chip_ctrl;
4891 + unsigned char diag_ctrl;
4892 + unsigned short arb_ctrl;
4893 + unsigned long rsvd_d[PPB_RSVDD_MAX];
4894 + unsigned char dev_dep[192];
4898 +/* PCI CAPABILITY DEFINES */
4899 +#define PCI_CAP_POWERMGMTCAP_ID 0x01
4900 +#define PCI_CAP_MSICAP_ID 0x05
4901 +#define PCI_CAP_PCIECAP_ID 0x10
4903 +/* Data structure to define the Message Signalled Interrupt facility
4904 + * Valid for PCI and PCIE configurations */
4905 +typedef struct _pciconfig_cap_msi {
4906 + unsigned char capID;
4907 + unsigned char nextptr;
4908 + unsigned short msgctrl;
4909 + unsigned int msgaddr;
4910 +} pciconfig_cap_msi;
4912 +/* Data structure to define the Power managment facility
4913 + * Valid for PCI and PCIE configurations */
4914 +typedef struct _pciconfig_cap_pwrmgmt {
4915 + unsigned char capID;
4916 + unsigned char nextptr;
4917 + unsigned short pme_cap;
4918 + unsigned short pme_sts_ctrl;
4919 + unsigned char pme_bridge_ext;
4920 + unsigned char data;
4921 +} pciconfig_cap_pwrmgmt;
4923 +/* Data structure to define the PCIE capability */
4924 +typedef struct _pciconfig_cap_pcie {
4925 + unsigned char capID;
4926 + unsigned char nextptr;
4927 + unsigned short pcie_cap;
4928 + unsigned int dev_cap;
4929 + unsigned short dev_ctrl;
4930 + unsigned short dev_status;
4931 + unsigned int link_cap;
4932 + unsigned short link_ctrl;
4933 + unsigned short link_status;
4934 +} pciconfig_cap_pcie;
4936 +/* PCIE Enhanced CAPABILITY DEFINES */
4937 +#define PCIE_EXTCFG_OFFSET 0x100
4938 +#define PCIE_ADVERRREP_CAPID 0x0001
4939 +#define PCIE_VC_CAPID 0x0002
4940 +#define PCIE_DEVSNUM_CAPID 0x0003
4941 +#define PCIE_PWRBUDGET_CAPID 0x0004
4943 +/* Header to define the PCIE specific capabilities in the extended config space */
4944 +typedef struct _pcie_enhanced_caphdr {
4945 + unsigned short capID;
4946 + unsigned short cap_ver : 4;
4947 + unsigned short next_ptr : 12;
4948 +} pcie_enhanced_caphdr;
4951 +/* Everything below is BRCM HND proprietary */
4953 +#define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */
4954 +#define PCI_BAR1_WIN 0x84 /* backplane addres space accessed by BAR1 */
4955 +#define PCI_SPROM_CONTROL 0x88 /* sprom property control */
4956 +#define PCI_BAR1_CONTROL 0x8c /* BAR1 region burst control */
4957 +#define PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */
4958 +#define PCI_INT_MASK 0x94 /* mask of PCI and other cores interrupts */
4959 +#define PCI_TO_SB_MB 0x98 /* signal backplane interrupts */
4960 +#define PCI_BACKPLANE_ADDR 0xA0 /* address an arbitrary location on the system backplane */
4961 +#define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address register */
4962 +#define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */
4963 +#define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */
4964 +#define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */
4966 +#define PCI_BAR0_SPROM_OFFSET (4 * 1024) /* bar0 + 4K accesses external sprom */
4967 +#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) /* bar0 + 6K accesses pci core registers */
4969 +/* PCI_INT_STATUS */
4970 +#define PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */
4973 +#define PCI_SBIM_SHIFT 8 /* backplane core interrupt mask bits offset */
4974 +#define PCI_SBIM_MASK 0xff00 /* backplane core interrupt mask */
4975 +#define PCI_SBIM_MASK_SERR 0x4 /* backplane SBErr interrupt mask */
4977 +/* PCI_SPROM_CONTROL */
4978 +#define SPROM_BLANK 0x04 /* indicating a blank sprom */
4979 +#define SPROM_WRITEEN 0x10 /* sprom write enable */
4980 +#define SPROM_BOOTROM_WE 0x20 /* external bootrom write enable */
4982 +#define SPROM_SIZE 256 /* sprom size in 16-bit */
4983 +#define SPROM_CRC_RANGE 64 /* crc cover range in 16-bit */
4985 +/* PCI_CFG_CMD_STAT */
4986 +#define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */
4989 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/pmon_osl.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/pmon_osl.h
4990 --- linux-2.4.32/arch/mips/bcm947xx/include/pmon_osl.h 1970-01-01 01:00:00.000000000 +0100
4991 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/pmon_osl.h 2005-12-16 23:39:10.752824750 +0100
4994 + * MIPS PMON boot loader OS Abstraction Layer.
4996 + * Copyright 2005, Broadcom Corporation
4997 + * All Rights Reserved.
4999 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
5000 + * the contents of this file may not be disclosed to third parties, copied
5001 + * or duplicated in any form, in whole or in part, without the prior
5002 + * written permission of Broadcom Corporation.
5006 +#ifndef _pmon_osl_h_
5007 +#define _pmon_osl_h_
5009 +#include <typedefs.h>
5011 +#include <string.h>
5012 +#include <utypes.h>
5014 +extern int printf(char *fmt,...);
5015 +extern int sprintf(char *dst,char *fmt,...);
5017 +#define OSL_UNCACHED(va) phy2k1(log2phy((va)))
5018 +#define REG_MAP(pa, size) phy2k1((pa))
5019 +#define REG_UNMAP(va) /* nop */
5021 +/* Common macros */
5023 +#define BUSPROBE(val, addr) ((val) = *(addr))
5025 +#define ASSERT(exp)
5027 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) bzero(buf, size)
5028 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size)
5031 +#define OSL_PCI_READ_CONFIG(loc, offset, size) ((offset == 8)? 0: 0xffffffff)
5032 +#define OSL_PCI_WRITE_CONFIG(loc, offset, size, val) ASSERT(0)
5034 +#define wreg32(r,v) (*(volatile uint32 *)(r) = (v))
5035 +#define rreg32(r) (*(volatile uint32 *)(r))
5036 +#ifdef IL_BIGENDIAN
5037 +#define wreg16(r,v) (*(volatile uint16 *)((uint32)r^2) = (v))
5038 +#define rreg16(r) (*(volatile uint16 *)((uint32)r^2))
5040 +#define wreg16(r,v) (*(volatile uint16 *)(r) = (v))
5041 +#define rreg16(r) (*(volatile uint16 *)(r))
5044 +#include <memory.h>
5045 +#define bcopy(src, dst, len) memcpy(dst, src, len)
5046 +#define bcmp(b1, b2, len) memcmp(b1, b2, len)
5047 +#define bzero(b, len) memset(b, '\0', len)
5049 +/* register access macros */
5050 +#define R_REG(r) ((sizeof *(r) == sizeof (uint32))? rreg32(r): rreg16(r))
5051 +#define W_REG(r,v) ((sizeof *(r) == sizeof (uint32))? wreg32(r,(uint32)v): wreg16(r,(uint16)v))
5052 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
5053 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
5055 +#define R_SM(r) *(r)
5056 +#define W_SM(r, v) (*(r) = (v))
5057 +#define BZERO_SM(r, len) memset(r, '\0', len)
5059 +/* Host/Bus architecture specific swap. Noop for little endian systems, possible swap on big endian */
5060 +#define BUS_SWAP32(v) (v)
5062 +#define OSL_DELAY(usec) delay_us(usec)
5063 +extern void delay_us(uint usec);
5065 +#define OSL_GETCYCLES(x) ((x) = 0)
5067 +#define osl_attach(pdev) (pdev)
5068 +#define osl_detach(osh)
5070 +#define MALLOC(osh, size) malloc(size)
5071 +#define MFREE(osh, addr, size) free(addr)
5072 +#define MALLOCED(osh) (0)
5073 +#define MALLOC_DUMP(osh, buf, sz)
5074 +#define MALLOC_FAILED(osh)
5075 +extern void *malloc();
5076 +extern void free(void *addr);
5078 +#define DMA_CONSISTENT_ALIGN sizeof (int)
5079 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) et_dma_alloc_consistent(osh, size, pap)
5080 +#define DMA_FREE_CONSISTENT(osh, va, size, pa)
5081 +extern void* et_dma_alloc_consistent(void *osh, uint size, ulong *pap);
5085 +#define DMA_MAP(osh, va, size, direction, p) osl_dma_map(osh, (void*)va, size, direction)
5086 +#define DMA_UNMAP(osh, pa, size, direction, p) /* nop */
5087 +extern void* osl_dma_map(void *osh, void *va, uint size, uint direction);
5090 + struct lbuf *next; /* pointer to next lbuf on freelist */
5091 + uchar *buf; /* pointer to buffer */
5092 + uint len; /* nbytes of data */
5095 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
5096 +#define PKTBUFSZ 2048
5098 +/* packet primitives */
5099 +#define PKTGET(drv, len, send) et_pktget(drv, len, send)
5100 +#define PKTFREE(drv, lb, send) et_pktfree(drv, (struct lbuf*)lb, send)
5101 +#define PKTDATA(drv, lb) ((uchar*)OSL_UNCACHED(((struct lbuf*)lb)->buf))
5102 +#define PKTLEN(drv, lb) ((struct lbuf*)lb)->len
5103 +#define PKTHEADROOM(drv, lb) (0)
5104 +#define PKTTAILROOM(drv, lb) (0)
5105 +#define PKTNEXT(drv, lb) NULL
5106 +#define PKTSETNEXT(lb, x) ASSERT(0)
5107 +#define PKTSETLEN(drv, lb, bytes) ((struct lbuf*)lb)->len = bytes
5108 +#define PKTPUSH(drv, lb, bytes) ASSERT(0)
5109 +#define PKTPULL(drv, lb, bytes) ASSERT(0)
5110 +#define PKTDUP(drv, lb) ASSERT(0)
5111 +#define PKTLINK(lb) ((struct lbuf*)lb)->next
5112 +#define PKTSETLINK(lb, x) ((struct lbuf*)lb)->next = (struct lbuf*)x
5113 +#define PKTPRIO(lb) (0)
5114 +#define PKTSETPRIO(lb, x) do {} while (0)
5115 +extern void *et_pktget(void *drv, uint len, bool send);
5116 +extern void et_pktfree(void *drv, struct lbuf *lb, bool send);
5118 +#endif /* _pmon_osl_h_ */
5119 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/proto/802.11.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/802.11.h
5120 --- linux-2.4.32/arch/mips/bcm947xx/include/proto/802.11.h 1970-01-01 01:00:00.000000000 +0100
5121 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/802.11.h 2005-12-16 23:39:10.752824750 +0100
5124 + * Copyright 2005, Broadcom Corporation
5125 + * All Rights Reserved.
5127 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5128 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5129 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5130 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5132 + * Fundamental types and constants relating to 802.11
5140 +#ifndef _TYPEDEFS_H_
5141 +#include <typedefs.h>
5144 +#ifndef _NET_ETHERNET_H_
5145 +#include <proto/ethernet.h>
5148 +#include <proto/wpa.h>
5151 +/* enable structure packing */
5152 +#if defined(__GNUC__)
5153 +#define PACKED __attribute__((packed))
5159 +#define DOT11_TU_TO_US 1024 /* 802.11 Time Unit is 1024 microseconds */
5161 +/* Generic 802.11 frame constants */
5162 +#define DOT11_A3_HDR_LEN 24
5163 +#define DOT11_A4_HDR_LEN 30
5164 +#define DOT11_MAC_HDR_LEN DOT11_A3_HDR_LEN
5165 +#define DOT11_FCS_LEN 4
5166 +#define DOT11_ICV_LEN 4
5167 +#define DOT11_ICV_AES_LEN 8
5168 +#define DOT11_QOS_LEN 2
5170 +#define DOT11_KEY_INDEX_SHIFT 6
5171 +#define DOT11_IV_LEN 4
5172 +#define DOT11_IV_TKIP_LEN 8
5173 +#define DOT11_IV_AES_OCB_LEN 4
5174 +#define DOT11_IV_AES_CCM_LEN 8
5177 +#define DOT11_MAX_MPDU_BODY_LEN 2304
5178 +/* A4 header + QoS + CCMP + PDU + ICV + FCS = 2352 */
5179 +#define DOT11_MAX_MPDU_LEN (DOT11_A4_HDR_LEN + \
5181 + DOT11_IV_AES_CCM_LEN + \
5182 + DOT11_MAX_MPDU_BODY_LEN + \
5186 +#define DOT11_MAX_SSID_LEN 32
5188 +/* dot11RTSThreshold */
5189 +#define DOT11_DEFAULT_RTS_LEN 2347
5190 +#define DOT11_MAX_RTS_LEN 2347
5192 +/* dot11FragmentationThreshold */
5193 +#define DOT11_MIN_FRAG_LEN 256
5194 +#define DOT11_MAX_FRAG_LEN 2346 /* Max frag is also limited by aMPDUMaxLength of the attached PHY */
5195 +#define DOT11_DEFAULT_FRAG_LEN 2346
5197 +/* dot11BeaconPeriod */
5198 +#define DOT11_MIN_BEACON_PERIOD 1
5199 +#define DOT11_MAX_BEACON_PERIOD 0xFFFF
5201 +/* dot11DTIMPeriod */
5202 +#define DOT11_MIN_DTIM_PERIOD 1
5203 +#define DOT11_MAX_DTIM_PERIOD 0xFF
5205 +/* 802.2 LLC/SNAP header used by 802.11 per 802.1H */
5206 +#define DOT11_LLC_SNAP_HDR_LEN 8
5207 +#define DOT11_OUI_LEN 3
5208 +struct dot11_llc_snap_header {
5209 + uint8 dsap; /* always 0xAA */
5210 + uint8 ssap; /* always 0xAA */
5211 + uint8 ctl; /* always 0x03 */
5212 + uint8 oui[DOT11_OUI_LEN]; /* RFC1042: 0x00 0x00 0x00
5213 + Bridge-Tunnel: 0x00 0x00 0xF8 */
5214 + uint16 type; /* ethertype */
5217 +/* RFC1042 header used by 802.11 per 802.1H */
5218 +#define RFC1042_HDR_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN)
5220 +/* Generic 802.11 MAC header */
5222 + * N.B.: This struct reflects the full 4 address 802.11 MAC header.
5223 + * The fields are defined such that the shorter 1, 2, and 3
5224 + * address headers just use the first k fields.
5226 +struct dot11_header {
5227 + uint16 fc; /* frame control */
5228 + uint16 durid; /* duration/ID */
5229 + struct ether_addr a1; /* address 1 */
5230 + struct ether_addr a2; /* address 2 */
5231 + struct ether_addr a3; /* address 3 */
5232 + uint16 seq; /* sequence control */
5233 + struct ether_addr a4; /* address 4 */
5236 +/* Control frames */
5238 +struct dot11_rts_frame {
5239 + uint16 fc; /* frame control */
5240 + uint16 durid; /* duration/ID */
5241 + struct ether_addr ra; /* receiver address */
5242 + struct ether_addr ta; /* transmitter address */
5244 +#define DOT11_RTS_LEN 16
5246 +struct dot11_cts_frame {
5247 + uint16 fc; /* frame control */
5248 + uint16 durid; /* duration/ID */
5249 + struct ether_addr ra; /* receiver address */
5251 +#define DOT11_CTS_LEN 10
5253 +struct dot11_ack_frame {
5254 + uint16 fc; /* frame control */
5255 + uint16 durid; /* duration/ID */
5256 + struct ether_addr ra; /* receiver address */
5258 +#define DOT11_ACK_LEN 10
5260 +struct dot11_ps_poll_frame {
5261 + uint16 fc; /* frame control */
5262 + uint16 durid; /* AID */
5263 + struct ether_addr bssid; /* receiver address, STA in AP */
5264 + struct ether_addr ta; /* transmitter address */
5266 +#define DOT11_PS_POLL_LEN 16
5268 +struct dot11_cf_end_frame {
5269 + uint16 fc; /* frame control */
5270 + uint16 durid; /* duration/ID */
5271 + struct ether_addr ra; /* receiver address */
5272 + struct ether_addr bssid; /* transmitter address, STA in AP */
5274 +#define DOT11_CS_END_LEN 16
5276 +/* Management frame header */
5277 +struct dot11_management_header {
5278 + uint16 fc; /* frame control */
5279 + uint16 durid; /* duration/ID */
5280 + struct ether_addr da; /* receiver address */
5281 + struct ether_addr sa; /* transmitter address */
5282 + struct ether_addr bssid; /* BSS ID */
5283 + uint16 seq; /* sequence control */
5285 +#define DOT11_MGMT_HDR_LEN 24
5287 +/* Management frame payloads */
5289 +struct dot11_bcn_prb {
5290 + uint32 timestamp[2];
5291 + uint16 beacon_interval;
5292 + uint16 capability;
5294 +#define DOT11_BCN_PRB_LEN 12
5296 +struct dot11_auth {
5297 + uint16 alg; /* algorithm */
5298 + uint16 seq; /* sequence control */
5299 + uint16 status; /* status code */
5301 +#define DOT11_AUTH_FIXED_LEN 6 /* length of auth frame without challenge info elt */
5303 +struct dot11_assoc_req {
5304 + uint16 capability; /* capability information */
5305 + uint16 listen; /* listen interval */
5307 +#define DOT11_ASSOC_REQ_FIXED_LEN 4 /* length of assoc frame without info elts */
5309 +struct dot11_reassoc_req {
5310 + uint16 capability; /* capability information */
5311 + uint16 listen; /* listen interval */
5312 + struct ether_addr ap; /* Current AP address */
5314 +#define DOT11_REASSOC_REQ_FIXED_LEN 10 /* length of assoc frame without info elts */
5316 +struct dot11_assoc_resp {
5317 + uint16 capability; /* capability information */
5318 + uint16 status; /* status code */
5319 + uint16 aid; /* association ID */
5322 +struct dot11_action_measure {
5328 +#define DOT11_ACTION_MEASURE_LEN 3
5330 +struct dot11_action_switch_channel {
5333 + uint8 data[5]; /* for switch IE */
5337 + 802.11h related definitions.
5343 +} dot11_power_cnst_t;
5348 +} dot11_power_cap_t;
5356 +#define DOT11_MNG_IE_TPC_REPORT_LEN 2 /* length of IE data, not including 2 byte header */
5361 + uint8 first_channel;
5362 + uint8 num_channels;
5363 +} dot11_supp_channels_t;
5365 +/* csa mode type */
5366 +#define DOT11_CSA_MODE_ADVISORY 0
5367 +#define DOT11_CSA_MODE_NO_TX 1
5368 +struct dot11_channel_switch {
5375 +typedef struct dot11_channel_switch dot11_channel_switch_t;
5377 +/* length of IE data, not including 2 byte header */
5378 +#define DOT11_SWITCH_IE_LEN 3
5380 +/* 802.11h Measurement Request/Report IEs */
5381 +/* Measurement Type field */
5382 +#define DOT11_MEASURE_TYPE_BASIC 0
5383 +#define DOT11_MEASURE_TYPE_CCA 1
5384 +#define DOT11_MEASURE_TYPE_RPI 2
5386 +/* Measurement Mode field */
5388 +/* Measurement Request Modes */
5389 +#define DOT11_MEASURE_MODE_ENABLE (1<<1)
5390 +#define DOT11_MEASURE_MODE_REQUEST (1<<2)
5391 +#define DOT11_MEASURE_MODE_REPORT (1<<3)
5392 +/* Measurement Report Modes */
5393 +#define DOT11_MEASURE_MODE_LATE (1<<0)
5394 +#define DOT11_MEASURE_MODE_INCAPABLE (1<<1)
5395 +#define DOT11_MEASURE_MODE_REFUSED (1<<2)
5396 +/* Basic Measurement Map bits */
5397 +#define DOT11_MEASURE_BASIC_MAP_BSS ((uint8)(1<<0))
5398 +#define DOT11_MEASURE_BASIC_MAP_OFDM ((uint8)(1<<1))
5399 +#define DOT11_MEASURE_BASIC_MAP_UKNOWN ((uint8)(1<<2))
5400 +#define DOT11_MEASURE_BASIC_MAP_RADAR ((uint8)(1<<3))
5401 +#define DOT11_MEASURE_BASIC_MAP_UNMEAS ((uint8)(1<<4))
5410 + uint8 start_time[8];
5412 +} dot11_meas_req_t;
5413 +#define DOT11_MNG_IE_MREQ_LEN 14
5414 +/* length of Measure Request IE data not including variable len */
5415 +#define DOT11_MNG_IE_MREQ_FIXED_LEN 3
5417 +struct dot11_meas_rep {
5427 + uint8 start_time[8];
5434 +typedef struct dot11_meas_rep dot11_meas_rep_t;
5436 +/* length of Measure Report IE data not including variable len */
5437 +#define DOT11_MNG_IE_MREP_FIXED_LEN 3
5439 +struct dot11_meas_rep_basic {
5441 + uint8 start_time[8];
5445 +typedef struct dot11_meas_rep_basic dot11_meas_rep_basic_t;
5446 +#define DOT11_MEASURE_BASIC_REP_LEN 12
5448 +struct dot11_quiet {
5451 + uint8 count; /* TBTTs until beacon interval in quiet starts */
5452 + uint8 period; /* Beacon intervals between periodic quiet periods ? */
5453 + uint16 duration;/* Length of quiet period, in TU's */
5454 + uint16 offset; /* TU's offset from TBTT in Count field */
5456 +typedef struct dot11_quiet dot11_quiet_t;
5461 +} chan_map_tuple_t;
5466 + uint8 eaddr[ETHER_ADDR_LEN];
5468 + chan_map_tuple_t map[1];
5469 +} dot11_ibss_dfs_t;
5472 +#define WME_OUI "\x00\x50\xf2"
5475 +#define WME_SUBTYPE_IE 0 /* Information Element */
5476 +#define WME_SUBTYPE_PARAM_IE 1 /* Parameter Element */
5477 +#define WME_SUBTYPE_TSPEC 2 /* Traffic Specification */
5479 +/* WME Access Category Indices (ACIs) */
5480 +#define AC_BE 0 /* Best Effort */
5481 +#define AC_BK 1 /* Background */
5482 +#define AC_VI 2 /* Video */
5483 +#define AC_VO 3 /* Voice */
5486 +/* WME Information Element (IE) */
5494 +typedef struct wme_ie wme_ie_t;
5495 +#define WME_IE_LEN 7
5497 +struct wme_acparam {
5500 + uint16 TXOP; /* stored in network order (ls octet first) */
5502 +typedef struct wme_acparam wme_acparam_t;
5504 +/* WME Parameter Element (PE) */
5505 +struct wme_params {
5512 + wme_acparam_t acparam[4];
5514 +typedef struct wme_params wme_params_t;
5515 +#define WME_PARAMS_IE_LEN 24
5518 +#define WME_COUNT_MASK 0x0f
5520 +#define WME_AIFS_MASK 0x0f
5521 +#define WME_ACM_MASK 0x10
5522 +#define WME_ACI_MASK 0x60
5523 +#define WME_ACI_SHIFT 5
5525 +#define WME_CWMIN_MASK 0x0f
5526 +#define WME_CWMAX_MASK 0xf0
5527 +#define WME_CWMAX_SHIFT 4
5529 +#define WME_TXOP_UNITS 32
5531 +/* AP: default params to be announced in the Beacon Frames/Probe Responses Table 12 WME Draft*/
5532 +/* AP: default params to be Used in the AP Side Table 14 WME Draft January 2004 802.11-03-504r5 */
5533 +#define WME_AC_BK_ACI_STA 0x27
5534 +#define WME_AC_BK_ECW_STA 0xA4
5535 +#define WME_AC_BK_TXOP_STA 0x0000
5536 +#define WME_AC_BE_ACI_STA 0x03
5537 +#define WME_AC_BE_ECW_STA 0xA4
5538 +#define WME_AC_BE_TXOP_STA 0x0000
5539 +#define WME_AC_VI_ACI_STA 0x42
5540 +#define WME_AC_VI_ECW_STA 0x43
5541 +#define WME_AC_VI_TXOP_STA 0x005e
5542 +#define WME_AC_VO_ACI_STA 0x62
5543 +#define WME_AC_VO_ECW_STA 0x32
5544 +#define WME_AC_VO_TXOP_STA 0x002f
5546 +#define WME_AC_BK_ACI_AP 0x27
5547 +#define WME_AC_BK_ECW_AP 0xA4
5548 +#define WME_AC_BK_TXOP_AP 0x0000
5549 +#define WME_AC_BE_ACI_AP 0x03
5550 +#define WME_AC_BE_ECW_AP 0x64
5551 +#define WME_AC_BE_TXOP_AP 0x0000
5552 +#define WME_AC_VI_ACI_AP 0x41
5553 +#define WME_AC_VI_ECW_AP 0x43
5554 +#define WME_AC_VI_TXOP_AP 0x005e
5555 +#define WME_AC_VO_ACI_AP 0x61
5556 +#define WME_AC_VO_ECW_AP 0x32
5557 +#define WME_AC_VO_TXOP_AP 0x002f
5559 +/* WME Traffic Specification (TSPEC) element */
5560 +#define WME_SUBTYPE_TSPEC 2
5561 +#define WME_TSPEC_HDR_LEN 2
5562 +#define WME_TSPEC_BODY_OFF 2
5564 + uint8 oui[DOT11_OUI_LEN]; /* WME_OUI */
5565 + uint8 type; /* WME_TYPE */
5566 + uint8 subtype; /* WME_SUBTYPE_TSPEC */
5567 + uint8 version; /* WME_VERSION */
5568 + uint16 ts_info; /* TS Info */
5569 + uint16 nom_msdu_size; /* (Nominal or fixed) MSDU Size (bytes) */
5570 + uint16 max_msdu_size; /* Maximum MSDU Size (bytes) */
5571 + uint32 min_service_interval; /* Minimum Service Interval (us) */
5572 + uint32 max_service_interval; /* Maximum Service Interval (us) */
5573 + uint32 inactivity_interval; /* Inactivity Interval (us) */
5574 + uint32 service_start; /* Service Start Time (us) */
5575 + uint32 min_rate; /* Minimum Data Rate (bps) */
5576 + uint32 mean_rate; /* Mean Data Rate (bps) */
5577 + uint32 max_burst_size; /* Maximum Burst Size (bytes) */
5578 + uint32 min_phy_rate; /* Minimum PHY Rate (bps) */
5579 + uint32 peak_rate; /* Peak Data Rate (bps) */
5580 + uint32 delay_bound; /* Delay Bound (us) */
5581 + uint16 surplus_bandwidth; /* Surplus Bandwidth Allowance Factor */
5582 + uint16 medium_time; /* Medium Time (32 us/s periods) */
5584 +typedef struct wme_tspec wme_tspec_t;
5585 +#define WME_TSPEC_LEN 56 /* not including 2-byte header */
5588 +/* 802.1D priority is duplicated - bits 13-11 AND bits 3-1 */
5589 +#define TS_INFO_PRIO_SHIFT_HI 11
5590 +#define TS_INFO_PRIO_MASK_HI (0x7 << TS_INFO_PRIO_SHIFT_HI)
5591 +#define TS_INFO_PRIO_SHIFT_LO 1
5592 +#define TS_INFO_PRIO_MASK_LO (0x7 << TS_INFO_PRIO_SHIFT_LO)
5593 +#define TS_INFO_CONTENTION_SHIFT 7
5594 +#define TS_INFO_CONTENTION_MASK (0x1 << TS_INFO_CONTENTION_SHIFT)
5595 +#define TS_INFO_DIRECTION_SHIFT 5
5596 +#define TS_INFO_DIRECTION_MASK (0x3 << TS_INFO_DIRECTION_SHIFT)
5597 +#define TS_INFO_UPLINK (0 << TS_INFO_DIRECTION_SHIFT)
5598 +#define TS_INFO_DOWNLINK (1 << TS_INFO_DIRECTION_SHIFT)
5599 +#define TS_INFO_BIDIRECTIONAL (3 << TS_INFO_DIRECTION_SHIFT)
5601 +/* nom_msdu_size */
5602 +#define FIXED_MSDU_SIZE 0x8000 /* MSDU size is fixed */
5603 +#define MSDU_SIZE_MASK 0x7fff /* (Nominal or fixed) MSDU size */
5605 +/* surplus_bandwidth */
5606 +/* Represented as 3 bits of integer, binary point, 13 bits fraction */
5607 +#define INTEGER_SHIFT 13
5608 +#define FRACTION_MASK 0x1FFF
5610 +/* Management Notification Frame */
5611 +struct dot11_management_notification {
5612 + uint8 category; /* DOT11_ACTION_NOTIFICATION */
5616 + uint8 data[1]; /* Elements */
5618 +#define DOT11_MGMT_NOTIFICATION_LEN 4 /* Fixed length */
5620 +/* WME Action Codes */
5621 +#define WME_SETUP_REQUEST 0
5622 +#define WME_SETUP_RESPONSE 1
5623 +#define WME_TEARDOWN 2
5625 +/* WME Setup Response Status Codes */
5626 +#define WME_ADMISSION_ACCEPTED 0
5627 +#define WME_INVALID_PARAMETERS 1
5628 +#define WME_ADMISSION_REFUSED 3
5630 +/* Macro to take a pointer to a beacon or probe response
5631 + * header and return the char* pointer to the SSID info element
5633 +#define BCN_PRB_SSID(hdr) ((char*)(hdr) + DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_LEN)
5635 +/* Authentication frame payload constants */
5636 +#define DOT11_OPEN_SYSTEM 0
5637 +#define DOT11_SHARED_KEY 1
5638 +#define DOT11_CHALLENGE_LEN 128
5640 +/* Frame control macros */
5641 +#define FC_PVER_MASK 0x3
5642 +#define FC_PVER_SHIFT 0
5643 +#define FC_TYPE_MASK 0xC
5644 +#define FC_TYPE_SHIFT 2
5645 +#define FC_SUBTYPE_MASK 0xF0
5646 +#define FC_SUBTYPE_SHIFT 4
5647 +#define FC_TODS 0x100
5648 +#define FC_TODS_SHIFT 8
5649 +#define FC_FROMDS 0x200
5650 +#define FC_FROMDS_SHIFT 9
5651 +#define FC_MOREFRAG 0x400
5652 +#define FC_MOREFRAG_SHIFT 10
5653 +#define FC_RETRY 0x800
5654 +#define FC_RETRY_SHIFT 11
5655 +#define FC_PM 0x1000
5656 +#define FC_PM_SHIFT 12
5657 +#define FC_MOREDATA 0x2000
5658 +#define FC_MOREDATA_SHIFT 13
5659 +#define FC_WEP 0x4000
5660 +#define FC_WEP_SHIFT 14
5661 +#define FC_ORDER 0x8000
5662 +#define FC_ORDER_SHIFT 15
5664 +/* sequence control macros */
5665 +#define SEQNUM_SHIFT 4
5666 +#define FRAGNUM_MASK 0xF
5668 +/* Frame Control type/subtype defs */
5671 +#define FC_TYPE_MNG 0
5672 +#define FC_TYPE_CTL 1
5673 +#define FC_TYPE_DATA 2
5675 +/* Management Subtypes */
5676 +#define FC_SUBTYPE_ASSOC_REQ 0
5677 +#define FC_SUBTYPE_ASSOC_RESP 1
5678 +#define FC_SUBTYPE_REASSOC_REQ 2
5679 +#define FC_SUBTYPE_REASSOC_RESP 3
5680 +#define FC_SUBTYPE_PROBE_REQ 4
5681 +#define FC_SUBTYPE_PROBE_RESP 5
5682 +#define FC_SUBTYPE_BEACON 8
5683 +#define FC_SUBTYPE_ATIM 9
5684 +#define FC_SUBTYPE_DISASSOC 10
5685 +#define FC_SUBTYPE_AUTH 11
5686 +#define FC_SUBTYPE_DEAUTH 12
5687 +#define FC_SUBTYPE_ACTION 13
5689 +/* Control Subtypes */
5690 +#define FC_SUBTYPE_PS_POLL 10
5691 +#define FC_SUBTYPE_RTS 11
5692 +#define FC_SUBTYPE_CTS 12
5693 +#define FC_SUBTYPE_ACK 13
5694 +#define FC_SUBTYPE_CF_END 14
5695 +#define FC_SUBTYPE_CF_END_ACK 15
5697 +/* Data Subtypes */
5698 +#define FC_SUBTYPE_DATA 0
5699 +#define FC_SUBTYPE_DATA_CF_ACK 1
5700 +#define FC_SUBTYPE_DATA_CF_POLL 2
5701 +#define FC_SUBTYPE_DATA_CF_ACK_POLL 3
5702 +#define FC_SUBTYPE_NULL 4
5703 +#define FC_SUBTYPE_CF_ACK 5
5704 +#define FC_SUBTYPE_CF_POLL 6
5705 +#define FC_SUBTYPE_CF_ACK_POLL 7
5706 +#define FC_SUBTYPE_QOS_DATA 8
5707 +#define FC_SUBTYPE_QOS_NULL 12
5709 +/* type-subtype combos */
5710 +#define FC_KIND_MASK (FC_TYPE_MASK | FC_SUBTYPE_MASK)
5712 +#define FC_KIND(t, s) (((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT))
5714 +#define FC_ASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_REQ)
5715 +#define FC_ASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_RESP)
5716 +#define FC_REASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_REQ)
5717 +#define FC_REASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_RESP)
5718 +#define FC_PROBE_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_REQ)
5719 +#define FC_PROBE_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_RESP)
5720 +#define FC_BEACON FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_BEACON)
5721 +#define FC_DISASSOC FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DISASSOC)
5722 +#define FC_AUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_AUTH)
5723 +#define FC_DEAUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DEAUTH)
5724 +#define FC_ACTION FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ACTION)
5726 +#define FC_PS_POLL FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_PS_POLL)
5727 +#define FC_RTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_RTS)
5728 +#define FC_CTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTS)
5729 +#define FC_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_ACK)
5730 +#define FC_CF_END FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END)
5731 +#define FC_CF_END_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END_ACK)
5733 +#define FC_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA)
5734 +#define FC_NULL_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_NULL)
5735 +#define FC_DATA_CF_ACK FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA_CF_ACK)
5736 +#define FC_QOS_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_DATA)
5737 +#define FC_QOS_NULL FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_NULL)
5739 +/* QoS Control Field */
5742 +#define QOS_PRIO_SHIFT 0
5743 +#define QOS_PRIO_MASK 0x0007
5744 +#define QOS_PRIO(qos) (((qos) & QOS_PRIO_MASK) >> QOS_PRIO_SHIFT)
5746 +#define QOS_TID_SHIFT 0
5747 +#define QOS_TID_MASK 0x000f
5748 +#define QOS_TID(qos) (((qos) & QOS_TID_MASK) >> QOS_TID_SHIFT)
5750 +/* Ack Policy (0 means Acknowledge) */
5751 +#define QOS_ACK_SHIFT 5
5752 +#define QOS_ACK_MASK 0x0060
5753 +#define QOS_ACK(qos) (((qos) & QOS_ACK_MASK) >> QOS_ACK_SHIFT)
5755 +/* Management Frames */
5757 +/* Management Frame Constants */
5760 +#define DOT11_MNG_AUTH_ALGO_LEN 2
5761 +#define DOT11_MNG_AUTH_SEQ_LEN 2
5762 +#define DOT11_MNG_BEACON_INT_LEN 2
5763 +#define DOT11_MNG_CAP_LEN 2
5764 +#define DOT11_MNG_AP_ADDR_LEN 6
5765 +#define DOT11_MNG_LISTEN_INT_LEN 2
5766 +#define DOT11_MNG_REASON_LEN 2
5767 +#define DOT11_MNG_AID_LEN 2
5768 +#define DOT11_MNG_STATUS_LEN 2
5769 +#define DOT11_MNG_TIMESTAMP_LEN 8
5771 +/* DUR/ID field in assoc resp is 0xc000 | AID */
5772 +#define DOT11_AID_MASK 0x3fff
5775 +#define DOT11_RC_RESERVED 0
5776 +#define DOT11_RC_UNSPECIFIED 1 /* Unspecified reason */
5777 +#define DOT11_RC_AUTH_INVAL 2 /* Previous authentication no longer valid */
5778 +#define DOT11_RC_DEAUTH_LEAVING 3 /* Deauthenticated because sending station is
5779 + leaving (or has left) IBSS or ESS */
5780 +#define DOT11_RC_INACTIVITY 4 /* Disassociated due to inactivity */
5781 +#define DOT11_RC_BUSY 5 /* Disassociated because AP is unable to handle
5782 + all currently associated stations */
5783 +#define DOT11_RC_INVAL_CLASS_2 6 /* Class 2 frame received from
5784 + nonauthenticated station */
5785 +#define DOT11_RC_INVAL_CLASS_3 7 /* Class 3 frame received from
5786 + nonassociated station */
5787 +#define DOT11_RC_DISASSOC_LEAVING 8 /* Disassociated because sending station is
5788 + leaving (or has left) BSS */
5789 +#define DOT11_RC_NOT_AUTH 9 /* Station requesting (re)association is
5790 + not authenticated with responding station */
5791 +#define DOT11_RC_MAX 23 /* Reason codes > 23 are reserved */
5794 +#define DOT11_STATUS_SUCCESS 0 /* Successful */
5795 +#define DOT11_STATUS_FAILURE 1 /* Unspecified failure */
5796 +#define DOT11_STATUS_CAP_MISMATCH 10 /* Cannot support all requested capabilities
5797 + in the Capability Information field */
5798 +#define DOT11_STATUS_REASSOC_FAIL 11 /* Reassociation denied due to inability to
5799 + confirm that association exists */
5800 +#define DOT11_STATUS_ASSOC_FAIL 12 /* Association denied due to reason outside
5801 + the scope of this standard */
5802 +#define DOT11_STATUS_AUTH_MISMATCH 13 /* Responding station does not support the
5803 + specified authentication algorithm */
5804 +#define DOT11_STATUS_AUTH_SEQ 14 /* Received an Authentication frame with
5805 + authentication transaction sequence number
5806 + out of expected sequence */
5807 +#define DOT11_STATUS_AUTH_CHALLENGE_FAIL 15 /* Authentication rejected because of challenge failure */
5808 +#define DOT11_STATUS_AUTH_TIMEOUT 16 /* Authentication rejected due to timeout waiting
5809 + for next frame in sequence */
5810 +#define DOT11_STATUS_ASSOC_BUSY_FAIL 17 /* Association denied because AP is unable to
5811 + handle additional associated stations */
5812 +#define DOT11_STATUS_ASSOC_RATE_MISMATCH 18 /* Association denied due to requesting station
5813 + not supporting all of the data rates in the
5814 + BSSBasicRateSet parameter */
5815 +#define DOT11_STATUS_ASSOC_SHORT_REQUIRED 19 /* Association denied due to requesting station
5816 + not supporting the Short Preamble option */
5817 +#define DOT11_STATUS_ASSOC_PBCC_REQUIRED 20 /* Association denied due to requesting station
5818 + not supporting the PBCC Modulation option */
5819 +#define DOT11_STATUS_ASSOC_AGILITY_REQUIRED 21 /* Association denied due to requesting station
5820 + not supporting the Channel Agility option */
5821 +#define DOT11_STATUS_ASSOC_SPECTRUM_REQUIRED 22 /* Association denied because Spectrum Management
5822 + capability is required. */
5823 +#define DOT11_STATUS_ASSOC_BAD_POWER_CAP 23 /* Association denied because the info in the
5824 + Power Cap element is unacceptable. */
5825 +#define DOT11_STATUS_ASSOC_BAD_SUP_CHANNELS 24 /* Association denied because the info in the
5826 + Supported Channel element is unacceptable */
5827 +#define DOT11_STATUS_ASSOC_SHORTSLOT_REQUIRED 25 /* Association denied due to requesting station
5828 + not supporting the Short Slot Time option */
5829 +#define DOT11_STATUS_ASSOC_ERPBCC_REQUIRED 26 /* Association denied due to requesting station
5830 + not supporting the ER-PBCC Modulation option */
5831 +#define DOT11_STATUS_ASSOC_DSSOFDM_REQUIRED 27 /* Association denied due to requesting station
5832 + not supporting the DSS-OFDM option */
5834 +/* Info Elts, length of INFORMATION portion of Info Elts */
5835 +#define DOT11_MNG_DS_PARAM_LEN 1
5836 +#define DOT11_MNG_IBSS_PARAM_LEN 2
5838 +/* TIM Info element has 3 bytes fixed info in INFORMATION field,
5839 + * followed by 1 to 251 bytes of Partial Virtual Bitmap */
5840 +#define DOT11_MNG_TIM_FIXED_LEN 3
5841 +#define DOT11_MNG_TIM_DTIM_COUNT 0
5842 +#define DOT11_MNG_TIM_DTIM_PERIOD 1
5843 +#define DOT11_MNG_TIM_BITMAP_CTL 2
5844 +#define DOT11_MNG_TIM_PVB 3
5847 +#define TLV_TAG_OFF 0
5848 +#define TLV_LEN_OFF 1
5849 +#define TLV_HDR_LEN 2
5850 +#define TLV_BODY_OFF 2
5852 +/* Management Frame Information Element IDs */
5853 +#define DOT11_MNG_SSID_ID 0
5854 +#define DOT11_MNG_RATES_ID 1
5855 +#define DOT11_MNG_FH_PARMS_ID 2
5856 +#define DOT11_MNG_DS_PARMS_ID 3
5857 +#define DOT11_MNG_CF_PARMS_ID 4
5858 +#define DOT11_MNG_TIM_ID 5
5859 +#define DOT11_MNG_IBSS_PARMS_ID 6
5860 +#define DOT11_MNG_COUNTRY_ID 7
5861 +#define DOT11_MNG_HOPPING_PARMS_ID 8
5862 +#define DOT11_MNG_HOPPING_TABLE_ID 9
5863 +#define DOT11_MNG_REQUEST_ID 10
5864 +#define DOT11_MNG_CHALLENGE_ID 16
5865 +#define DOT11_MNG_PWR_CONSTRAINT_ID 32 /* 11H PowerConstraint */
5866 +#define DOT11_MNG_PWR_CAP_ID 33 /* 11H PowerCapability */
5867 +#define DOT11_MNG_TPC_REQUEST_ID 34 /* 11H TPC Request */
5868 +#define DOT11_MNG_TPC_REPORT_ID 35 /* 11H TPC Report */
5869 +#define DOT11_MNG_SUPP_CHANNELS_ID 36 /* 11H Supported Channels */
5870 +#define DOT11_MNG_CHANNEL_SWITCH_ID 37 /* 11H ChannelSwitch Announcement*/
5871 +#define DOT11_MNG_MEASURE_REQUEST_ID 38 /* 11H MeasurementRequest */
5872 +#define DOT11_MNG_MEASURE_REPORT_ID 39 /* 11H MeasurementReport */
5873 +#define DOT11_MNG_QUIET_ID 40 /* 11H Quiet */
5874 +#define DOT11_MNG_IBSS_DFS_ID 41 /* 11H IBSS_DFS */
5875 +#define DOT11_MNG_ERP_ID 42
5876 +#define DOT11_MNG_NONERP_ID 47
5878 +#define DOT11_MNG_RSN_ID 48
5879 +#endif /* BCMWPA2 */
5880 +#define DOT11_MNG_EXT_RATES_ID 50
5881 +#define DOT11_MNG_WPA_ID 221
5882 +#define DOT11_MNG_PROPR_ID 221
5884 +/* ERP info element bit values */
5885 +#define DOT11_MNG_ERP_LEN 1 /* ERP is currently 1 byte long */
5886 +#define DOT11_MNG_NONERP_PRESENT 0x01 /* NonERP (802.11b) STAs are present in the BSS */
5887 +#define DOT11_MNG_USE_PROTECTION 0x02 /* Use protection mechanisms for ERP-OFDM frames */
5888 +#define DOT11_MNG_BARKER_PREAMBLE 0x04 /* Short Preambles: 0 == allowed, 1 == not allowed */
5890 +/* Capability Information Field */
5891 +#define DOT11_CAP_ESS 0x0001
5892 +#define DOT11_CAP_IBSS 0x0002
5893 +#define DOT11_CAP_POLLABLE 0x0004
5894 +#define DOT11_CAP_POLL_RQ 0x0008
5895 +#define DOT11_CAP_PRIVACY 0x0010
5896 +#define DOT11_CAP_SHORT 0x0020
5897 +#define DOT11_CAP_PBCC 0x0040
5898 +#define DOT11_CAP_AGILITY 0x0080
5899 +#define DOT11_CAP_SPECTRUM 0x0100
5900 +#define DOT11_CAP_SHORTSLOT 0x0400
5901 +#define DOT11_CAP_CCK_OFDM 0x2000
5903 +/* Action Frame Constants */
5904 +#define DOT11_ACTION_CAT_ERR_MASK 0x80
5905 +#define DOT11_ACTION_CAT_SPECT_MNG 0x00
5906 +#define DOT11_ACTION_NOTIFICATION 0x11 /* 17 */
5908 +#define DOT11_ACTION_ID_M_REQ 0
5909 +#define DOT11_ACTION_ID_M_REP 1
5910 +#define DOT11_ACTION_ID_TPC_REQ 2
5911 +#define DOT11_ACTION_ID_TPC_REP 3
5912 +#define DOT11_ACTION_ID_CHANNEL_SWITCH 4
5914 +/* MLME Enumerations */
5915 +#define DOT11_BSSTYPE_INFRASTRUCTURE 0
5916 +#define DOT11_BSSTYPE_INDEPENDENT 1
5917 +#define DOT11_BSSTYPE_ANY 2
5918 +#define DOT11_SCANTYPE_ACTIVE 0
5919 +#define DOT11_SCANTYPE_PASSIVE 1
5921 +/* 802.11 A PHY constants */
5922 +#define APHY_SLOT_TIME 9
5923 +#define APHY_SIFS_TIME 16
5924 +#define APHY_DIFS_TIME (APHY_SIFS_TIME + (2 * APHY_SLOT_TIME))
5925 +#define APHY_PREAMBLE_TIME 16
5926 +#define APHY_SIGNAL_TIME 4
5927 +#define APHY_SYMBOL_TIME 4
5928 +#define APHY_SERVICE_NBITS 16
5929 +#define APHY_TAIL_NBITS 6
5930 +#define APHY_CWMIN 15
5932 +/* 802.11 B PHY constants */
5933 +#define BPHY_SLOT_TIME 20
5934 +#define BPHY_SIFS_TIME 10
5935 +#define BPHY_DIFS_TIME 50
5936 +#define BPHY_PLCP_TIME 192
5937 +#define BPHY_PLCP_SHORT_TIME 96
5938 +#define BPHY_CWMIN 31
5940 +/* 802.11 G constants */
5941 +#define DOT11_OFDM_SIGNAL_EXTENSION 6
5943 +#define PHY_CWMAX 1023
5945 +#define DOT11_MAXNUMFRAGS 16 /* max # fragments per MSDU */
5947 +/* dot11Counters Table - 802.11 spec., Annex D */
5948 +typedef struct d11cnt {
5949 + uint32 txfrag; /* dot11TransmittedFragmentCount */
5950 + uint32 txmulti; /* dot11MulticastTransmittedFrameCount */
5951 + uint32 txfail; /* dot11FailedCount */
5952 + uint32 txretry; /* dot11RetryCount */
5953 + uint32 txretrie; /* dot11MultipleRetryCount */
5954 + uint32 rxdup; /* dot11FrameduplicateCount */
5955 + uint32 txrts; /* dot11RTSSuccessCount */
5956 + uint32 txnocts; /* dot11RTSFailureCount */
5957 + uint32 txnoack; /* dot11ACKFailureCount */
5958 + uint32 rxfrag; /* dot11ReceivedFragmentCount */
5959 + uint32 rxmulti; /* dot11MulticastReceivedFrameCount */
5960 + uint32 rxcrc; /* dot11FCSErrorCount */
5961 + uint32 txfrmsnt; /* dot11TransmittedFrameCount */
5962 + uint32 rxundec; /* dot11WEPUndecryptableCount */
5966 +#define BRCM_OUI "\x00\x10\x18"
5968 +/* BRCM info element */
5970 + uchar id; /* 221, DOT11_MNG_PROPR_ID */
5974 + uchar assoc; /* # of assoc STAs */
5975 + uchar flags; /* misc flags */
5977 +#define BRCM_IE_LEN 8
5978 +typedef struct brcm_ie brcm_ie_t;
5979 +#define BRCM_IE_VER 2
5980 +#define BRCM_IE_LEGACY_AES_VER 1
5982 +/* brcm_ie flags */
5983 +#define BRF_ABCAP 0x1 /* afterburner capable */
5984 +#define BRF_ABRQRD 0x2 /* afterburner requested */
5985 +#define BRF_LZWDS 0x4 /* lazy wds enabled */
5986 +#define BRF_ABCOUNTER_MASK 0xf0 /* afterburner wds "state" counter */
5987 +#define BRF_ABCOUNTER_SHIFT 4
5989 +#define AB_WDS_TIMEOUT_MAX 15 /* afterburner wds Max count indicating not locally capable */
5990 +#define AB_WDS_TIMEOUT_MIN 1 /* afterburner wds, use zero count as indicating "downrev" */
5993 +/* OUI for BRCM proprietary IE */
5994 +#define BRCM_PROP_OUI "\x00\x90\x4C"
5996 +/* Vendor IE structure */
6001 + uchar data [1]; /* Variable size data */
6003 +typedef struct vndr_ie vndr_ie_t;
6005 +#define VNDR_IE_HDR_LEN 2 /* id + len field */
6006 +#define VNDR_IE_MIN_LEN 3 /* size of the oui field */
6007 +#define VNDR_IE_MAX_LEN 256
6009 +/* WPA definitions */
6010 +#define WPA_VERSION 1
6011 +#define WPA_OUI "\x00\x50\xF2"
6014 +#define WPA2_VERSION 1
6015 +#define WPA2_VERSION_LEN 2
6016 +#define WPA2_OUI "\x00\x0F\xAC"
6017 +#endif /* BCMWPA2 */
6019 +#define WPA_OUI_LEN 3
6021 +/* RSN authenticated key managment suite */
6022 +#define RSN_AKM_NONE 0 /* None (IBSS) */
6023 +#define RSN_AKM_UNSPECIFIED 1 /* Over 802.1x */
6024 +#define RSN_AKM_PSK 2 /* Pre-shared Key */
6027 +/* Key related defines */
6028 +#define DOT11_MAX_DEFAULT_KEYS 4 /* number of default keys */
6029 +#define DOT11_MAX_KEY_SIZE 32 /* max size of any key */
6030 +#define DOT11_MAX_IV_SIZE 16 /* max size of any IV */
6031 +#define DOT11_EXT_IV_FLAG (1<<5) /* flag to indicate IV is > 4 bytes */
6033 +#define WEP1_KEY_SIZE 5 /* max size of any WEP key */
6034 +#define WEP1_KEY_HEX_SIZE 10 /* size of WEP key in hex. */
6035 +#define WEP128_KEY_SIZE 13 /* max size of any WEP key */
6036 +#define WEP128_KEY_HEX_SIZE 26 /* size of WEP key in hex. */
6037 +#define TKIP_MIC_SIZE 8 /* size of TKIP MIC */
6038 +#define TKIP_EOM_SIZE 7 /* max size of TKIP EOM */
6039 +#define TKIP_EOM_FLAG 0x5a /* TKIP EOM flag byte */
6040 +#define TKIP_KEY_SIZE 32 /* size of any TKIP key */
6041 +#define TKIP_MIC_AUTH_TX 16 /* offset to Authenticator MIC TX key */
6042 +#define TKIP_MIC_AUTH_RX 24 /* offset to Authenticator MIC RX key */
6043 +#define TKIP_MIC_SUP_RX 16 /* offset to Supplicant MIC RX key */
6044 +#define TKIP_MIC_SUP_TX 24 /* offset to Supplicant MIC TX key */
6045 +#define AES_KEY_SIZE 16 /* size of AES key */
6048 +#if !defined(__GNUC__)
6052 +#endif /* _802_11_H_ */
6053 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/proto/bcmeth.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/bcmeth.h
6054 --- linux-2.4.32/arch/mips/bcm947xx/include/proto/bcmeth.h 1970-01-01 01:00:00.000000000 +0100
6055 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/bcmeth.h 2005-12-16 23:39:10.756825000 +0100
6058 + * Broadcom Ethernettype protocol definitions
6060 + * Copyright 2005, Broadcom Corporation
6061 + * All Rights Reserved.
6063 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6064 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6065 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6066 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6071 + * Broadcom Ethernet protocol defines
6078 +/* enable structure packing */
6079 +#if defined(__GNUC__)
6080 +#define PACKED __attribute__((packed))
6086 +/* ETHER_TYPE_BRCM is defined in ethernet.h */
6089 + * Following the 2byte BRCM ether_type is a 16bit BRCM subtype field
6090 + * in one of two formats: (only subtypes 32768-65535 are in use now)
6092 + * subtypes 0-32767:
6093 + * 8 bit subtype (0-127)
6094 + * 8 bit length in bytes (0-255)
6096 + * subtypes 32768-65535:
6097 + * 16 bit big-endian subtype
6098 + * 16 bit big-endian length in bytes (0-65535)
6100 + * length is the number of additional bytes beyond the 4 or 6 byte header
6102 + * Reserved values:
6104 + * 5-15 reserved for iLine protocol assignments
6105 + * 17-126 reserved, assignable
6108 + * 32769-65534 reserved, assignable
6113 + * While adding the subtypes and their specific processing code make sure
6114 + * bcmeth_bcm_hdr_t is the first data structure in the user specific data structure definition
6117 +#define BCMILCP_SUBTYPE_RATE 1
6118 +#define BCMILCP_SUBTYPE_LINK 2
6119 +#define BCMILCP_SUBTYPE_CSA 3
6120 +#define BCMILCP_SUBTYPE_LARQ 4
6121 +#define BCMILCP_SUBTYPE_VENDOR 5
6122 +#define BCMILCP_SUBTYPE_FLH 17
6124 +#define BCMILCP_SUBTYPE_VENDOR_LONG 32769
6125 +#define BCMILCP_SUBTYPE_CERT 32770
6126 +#define BCMILCP_SUBTYPE_SES 32771
6129 +#define BCMILCP_BCM_SUBTYPE_RESERVED 0
6130 +#define BCMILCP_BCM_SUBTYPE_EVENT 1
6131 +#define BCMILCP_BCM_SUBTYPE_SES 2
6133 +The EAPOL type is not used anymore. Instead EAPOL messages are now embedded
6134 +within BCMILCP_BCM_SUBTYPE_EVENT type messages
6136 +/*#define BCMILCP_BCM_SUBTYPE_EAPOL 3*/
6138 +#define BCMILCP_BCM_SUBTYPEHDR_MINLENGTH 8
6139 +#define BCMILCP_BCM_SUBTYPEHDR_VERSION 0
6141 +/* These fields are stored in network order */
6142 +typedef struct bcmeth_hdr
6144 + uint16 subtype; /* Vendor specific..32769*/
6146 + uint8 version; /* Version is 0*/
6147 + uint8 oui[3]; /* Broadcom OUI*/
6148 + /* user specific Data */
6149 + uint16 usr_subtype;
6150 +} PACKED bcmeth_hdr_t;
6155 +#if !defined(__GNUC__)
6160 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/proto/bcmip.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/bcmip.h
6161 --- linux-2.4.32/arch/mips/bcm947xx/include/proto/bcmip.h 1970-01-01 01:00:00.000000000 +0100
6162 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/bcmip.h 2005-12-16 23:39:10.756825000 +0100
6165 + * Copyright 2005, Broadcom Corporation
6166 + * All Rights Reserved.
6168 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
6169 + * the contents of this file may not be disclosed to third parties, copied
6170 + * or duplicated in any form, in whole or in part, without the prior
6171 + * written permission of Broadcom Corporation.
6173 + * Fundamental constants relating to IP Protocol
6182 +#define IPV4_VERIHL_OFFSET 0 /* version and ihl byte offset */
6183 +#define IPV4_TOS_OFFSET 1 /* TOS offset */
6184 +#define IPV4_PROT_OFFSET 9 /* protocol type offset */
6185 +#define IPV4_CHKSUM_OFFSET 10 /* IP header checksum offset */
6186 +#define IPV4_SRC_IP_OFFSET 12 /* src IP addr offset */
6187 +#define IPV4_DEST_IP_OFFSET 16 /* dest IP addr offset */
6189 +#define IPV4_VER_MASK 0xf0
6190 +#define IPV4_IHL_MASK 0x0f
6192 +#define IPV4_PROT_UDP 17 /* UDP protocol type */
6194 +#define IPV4_ADDR_LEN 4 /* IP v4 address length */
6196 +#define IPV4_VER_NUM 0x40 /* IP v4 version number */
6198 +/* NULL IP address check */
6199 +#define IPV4_ISNULLADDR(a) ((((uint8 *)(a))[0] + ((uint8 *)(a))[1] + \
6200 + ((uint8 *)(a))[2] + ((uint8 *)(a))[3]) == 0)
6202 +#define IPV4_ADDR_STR_LEN 16
6204 +#endif /* #ifndef _bcmip_h_ */
6206 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/proto/ethernet.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/ethernet.h
6207 --- linux-2.4.32/arch/mips/bcm947xx/include/proto/ethernet.h 1970-01-01 01:00:00.000000000 +0100
6208 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/ethernet.h 2005-12-16 23:39:10.756825000 +0100
6210 +/*******************************************************************************
6212 + * Copyright 2005, Broadcom Corporation
6213 + * All Rights Reserved.
6215 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6216 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6217 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6218 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6219 + * From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
6220 + ******************************************************************************/
6222 +#ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
6223 +#define _NET_ETHERNET_H_
6225 +#ifndef _TYPEDEFS_H_
6226 +#include "typedefs.h"
6229 +/* enable structure packing */
6230 +#if defined(__GNUC__)
6231 +#define PACKED __attribute__((packed))
6238 + * The number of bytes in an ethernet (MAC) address.
6240 +#define ETHER_ADDR_LEN 6
6243 + * The number of bytes in the type field.
6245 +#define ETHER_TYPE_LEN 2
6248 + * The number of bytes in the trailing CRC field.
6250 +#define ETHER_CRC_LEN 4
6253 + * The length of the combined header.
6255 +#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
6258 + * The minimum packet length.
6260 +#define ETHER_MIN_LEN 64
6263 + * The minimum packet user data length.
6265 +#define ETHER_MIN_DATA 46
6268 + * The maximum packet length.
6270 +#define ETHER_MAX_LEN 1518
6273 + * The maximum packet user data length.
6275 +#define ETHER_MAX_DATA 1500
6278 +#define ETHER_TYPE_IP 0x0800 /* IP */
6279 +#define ETHER_TYPE_ARP 0x0806 /* ARP */
6280 +#define ETHER_TYPE_8021Q 0x8100 /* 802.1Q */
6281 +#define ETHER_TYPE_BRCM 0x886c /* Broadcom Corp. */
6282 +#define ETHER_TYPE_802_1X 0x888e /* 802.1x */
6283 +#define ETHER_TYPE_802_1X_PREAUTH 0x88c7 /* 802.1x preauthentication*/
6285 +/* Broadcom subtype follows ethertype; First 2 bytes are reserved; Next 2 are subtype; */
6286 +#define ETHER_BRCM_SUBTYPE_LEN 4 /* Broadcom 4 byte subtype */
6287 +#define ETHER_BRCM_CRAM 0x1 /* Broadcom subtype cram protocol */
6290 +#define ETHER_DEST_OFFSET 0 /* dest address offset */
6291 +#define ETHER_SRC_OFFSET 6 /* src address offset */
6292 +#define ETHER_TYPE_OFFSET 12 /* ether type offset */
6295 + * A macro to validate a length with
6297 +#define ETHER_IS_VALID_LEN(foo) \
6298 + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
6301 +#ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
6303 + * Structure of a 10Mb/s Ethernet header.
6305 +struct ether_header {
6306 + uint8 ether_dhost[ETHER_ADDR_LEN];
6307 + uint8 ether_shost[ETHER_ADDR_LEN];
6308 + uint16 ether_type;
6312 + * Structure of a 48-bit Ethernet address.
6314 +struct ether_addr {
6315 + uint8 octet[ETHER_ADDR_LEN];
6320 + * Takes a pointer, sets locally admininistered
6321 + * address bit in the 48-bit Ethernet address.
6323 +#define ETHER_SET_LOCALADDR(ea) ( ((uint8 *)(ea))[0] = \
6324 + (((uint8 *)(ea))[0] | 2) )
6327 + * Takes a pointer, returns true if a 48-bit multicast address
6328 + * (including broadcast, since it is all ones)
6330 +#define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
6333 +/* compare two ethernet addresses - assumes the pointers can be referenced as shorts */
6334 +#define ether_cmp(a, b) ( \
6335 + !(((short*)a)[0] == ((short*)b)[0]) | \
6336 + !(((short*)a)[1] == ((short*)b)[1]) | \
6337 + !(((short*)a)[2] == ((short*)b)[2]))
6339 +/* copy an ethernet address - assumes the pointers can be referenced as shorts */
6340 +#define ether_copy(s, d) { \
6341 + ((short*)d)[0] = ((short*)s)[0]; \
6342 + ((short*)d)[1] = ((short*)s)[1]; \
6343 + ((short*)d)[2] = ((short*)s)[2]; }
6346 + * Takes a pointer, returns true if a 48-bit broadcast (all ones)
6348 +#define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \
6349 + ((uint8 *)(ea))[1] & \
6350 + ((uint8 *)(ea))[2] & \
6351 + ((uint8 *)(ea))[3] & \
6352 + ((uint8 *)(ea))[4] & \
6353 + ((uint8 *)(ea))[5]) == 0xff)
6355 +static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
6358 + * Takes a pointer, returns true if a 48-bit null address (all zeros)
6360 +#define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \
6361 + ((uint8 *)(ea))[1] | \
6362 + ((uint8 *)(ea))[2] | \
6363 + ((uint8 *)(ea))[3] | \
6364 + ((uint8 *)(ea))[4] | \
6365 + ((uint8 *)(ea))[5]) == 0)
6367 +/* Differentiated Services Codepoint - upper 6 bits of tos in iphdr */
6368 +#define DSCP_MASK 0xFC /* upper 6 bits */
6369 +#define DSCP_SHIFT 2
6370 +#define DSCP_WME_PRI_MASK 0xE0 /* upper 3 bits */
6371 +#define DSCP_WME_PRI_SHIFT 5
6374 +#if !defined(__GNUC__)
6378 +#endif /* _NET_ETHERNET_H_ */
6379 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/proto/vlan.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/vlan.h
6380 --- linux-2.4.32/arch/mips/bcm947xx/include/proto/vlan.h 1970-01-01 01:00:00.000000000 +0100
6381 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/vlan.h 2005-12-16 23:39:10.756825000 +0100
6384 + * 802.1Q VLAN protocol definitions
6386 + * Copyright 2005, Broadcom Corporation
6387 + * All Rights Reserved.
6389 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6390 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6391 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6392 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6400 +/* enable structure packing */
6401 +#if defined(__GNUC__)
6402 +#define PACKED __attribute__((packed))
6408 +#define VLAN_VID_MASK 0xfff /* low 12 bits are vlan id */
6409 +#define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */
6410 +#define VLAN_PRI_SHIFT 13 /* user priority */
6412 +#define VLAN_PRI_MASK 7 /* 3 bits of priority */
6414 +#define VLAN_TAG_LEN 4
6415 +#define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN)
6417 +struct ethervlan_header {
6418 + uint8 ether_dhost[ETHER_ADDR_LEN];
6419 + uint8 ether_shost[ETHER_ADDR_LEN];
6420 + uint16 vlan_type; /* 0x8100 */
6421 + uint16 vlan_tag; /* priority, cfi and vid */
6422 + uint16 ether_type;
6425 +#define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN)
6428 +#if !defined(__GNUC__)
6432 +#endif /* _vlan_h_ */
6433 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/proto/wpa.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/wpa.h
6434 --- linux-2.4.32/arch/mips/bcm947xx/include/proto/wpa.h 1970-01-01 01:00:00.000000000 +0100
6435 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/proto/wpa.h 2005-12-16 23:39:10.756825000 +0100
6438 + * Fundamental types and constants relating to WPA
6440 + * Copyright 2005, Broadcom Corporation
6441 + * All Rights Reserved.
6443 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6444 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6445 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6446 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6451 +#ifndef _proto_wpa_h_
6452 +#define _proto_wpa_h_
6454 +#include <typedefs.h>
6455 +#include <proto/ethernet.h>
6457 +/* enable structure packing */
6458 +#if defined(__GNUC__)
6459 +#define PACKED __attribute__((packed))
6467 +/* 10 and 11 are from TGh. */
6468 +#define DOT11_RC_BAD_PC 10 /* Unacceptable power capability element */
6469 +#define DOT11_RC_BAD_CHANNELS 11 /* Unacceptable supported channels element */
6471 +/* 13 through 23 taken from P802.11i/D3.0, November 2002 */
6472 +#define DOT11_RC_INVALID_WPA_IE 13 /* Invalid info. element */
6473 +#define DOT11_RC_MIC_FAILURE 14 /* Michael failure */
6474 +#define DOT11_RC_4WH_TIMEOUT 15 /* 4-way handshake timeout */
6475 +#define DOT11_RC_GTK_UPDATE_TIMEOUT 16 /* Group key update timeout */
6476 +#define DOT11_RC_WPA_IE_MISMATCH 17 /* WPA IE in 4-way handshake differs from (re-)assoc. request/probe response */
6477 +#define DOT11_RC_INVALID_MC_CIPHER 18 /* Invalid multicast cipher */
6478 +#define DOT11_RC_INVALID_UC_CIPHER 19 /* Invalid unicast cipher */
6479 +#define DOT11_RC_INVALID_AKMP 20 /* Invalid authenticated key management protocol */
6480 +#define DOT11_RC_BAD_WPA_VERSION 21 /* Unsupported WPA version */
6481 +#define DOT11_RC_INVALID_WPA_CAP 22 /* Invalid WPA IE capabilities */
6482 +#define DOT11_RC_8021X_AUTH_FAIL 23 /* 802.1X authentication failure */
6484 +#define WPA2_PMKID_LEN 16
6486 +/* WPA IE fixed portion */
6489 + uint8 tag; /* TAG */
6490 + uint8 length; /* TAG length */
6491 + uint8 oui[3]; /* IE OUI */
6492 + uint8 oui_type; /* OUI type */
6496 + } PACKED version; /* IE version */
6497 +} PACKED wpa_ie_fixed_t;
6498 +#define WPA_IE_OUITYPE_LEN 4
6499 +#define WPA_IE_FIXED_LEN 8
6500 +#define WPA_IE_TAG_FIXED_LEN 6
6503 + uint8 tag; /* TAG */
6504 + uint8 length; /* TAG length */
6508 + } PACKED version; /* IE version */
6509 +} PACKED wpa_rsn_ie_fixed_t;
6510 +#define WPA_RSN_IE_FIXED_LEN 4
6511 +#define WPA_RSN_IE_TAG_FIXED_LEN 2
6512 +typedef uint8 wpa_pmkid_t[WPA2_PMKID_LEN];
6514 +/* WPA suite/multicast suite */
6519 +} PACKED wpa_suite_t, wpa_suite_mcast_t;
6520 +#define WPA_SUITE_LEN 4
6522 +/* WPA unicast suite list/key management suite list */
6529 + wpa_suite_t list[1];
6530 +} PACKED wpa_suite_ucast_t, wpa_suite_auth_key_mgmt_t;
6531 +#define WPA_IE_SUITE_COUNT_LEN 2
6538 + wpa_pmkid_t list[1];
6539 +} PACKED wpa_pmkid_list_t;
6541 +/* WPA cipher suites */
6542 +#define WPA_CIPHER_NONE 0 /* None */
6543 +#define WPA_CIPHER_WEP_40 1 /* WEP (40-bit) */
6544 +#define WPA_CIPHER_TKIP 2 /* TKIP: default for WPA */
6545 +#define WPA_CIPHER_AES_OCB 3 /* AES (OCB) */
6546 +#define WPA_CIPHER_AES_CCM 4 /* AES (CCM) */
6547 +#define WPA_CIPHER_WEP_104 5 /* WEP (104-bit) */
6549 +#define IS_WPA_CIPHER(cipher) ((cipher) == WPA_CIPHER_NONE || \
6550 + (cipher) == WPA_CIPHER_WEP_40 || \
6551 + (cipher) == WPA_CIPHER_WEP_104 || \
6552 + (cipher) == WPA_CIPHER_TKIP || \
6553 + (cipher) == WPA_CIPHER_AES_OCB || \
6554 + (cipher) == WPA_CIPHER_AES_CCM)
6556 +/* WPA TKIP countermeasures parameters */
6557 +#define WPA_TKIP_CM_DETECT 60 /* multiple MIC failure window (seconds) */
6558 +#define WPA_TKIP_CM_BLOCK 60 /* countermeasures active window (seconds) */
6560 +/* WPA capabilities defined in 802.11i */
6561 +#define WPA_CAP_4_REPLAY_CNTRS 2
6562 +#define WPA_CAP_16_REPLAY_CNTRS 3
6563 +#define WPA_CAP_REPLAY_CNTR_SHIFT 2
6564 +#define WPA_CAP_REPLAY_CNTR_MASK 0x000c
6566 +/* WPA Specific defines */
6567 +#define WPA_CAP_LEN 2
6569 +#define WPA_CAP_WPA2_PREAUTH 1
6572 +#if !defined(__GNUC__)
6576 +#endif /* _proto_wpa_h_ */
6577 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/rts/crc.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/rts/crc.h
6578 --- linux-2.4.32/arch/mips/bcm947xx/include/rts/crc.h 1970-01-01 01:00:00.000000000 +0100
6579 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/rts/crc.h 2005-12-16 23:39:10.928835750 +0100
6581 +/*******************************************************************************
6583 + * Copyright 2005, Broadcom Corporation
6584 + * All Rights Reserved.
6586 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6587 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6588 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6589 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6590 + * crc.h - a function to compute crc for iLine10 headers
6591 + ******************************************************************************/
6593 +#ifndef _RTS_CRC_H_
6594 +#define _RTS_CRC_H_ 1
6596 +#include "typedefs.h"
6603 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
6604 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
6605 +#define HCS_GOOD_VALUE 0x39 /* Good final header checksum value */
6607 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
6608 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
6610 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
6611 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
6613 +void hcs(uint8 *, uint);
6614 +uint8 crc8(uint8 *, uint, uint8);
6615 +uint16 crc16(uint8 *, uint, uint16);
6616 +uint32 crc32(uint8 *, uint, uint32);
6618 +/* macros for common usage */
6620 +#define APPEND_CRC8(pbytes, nbytes) \
6622 + uint8 tmp = crc8(pbytes, nbytes, CRC8_INIT_VALUE) ^ 0xff; \
6623 + (pbytes)[(nbytes)] = tmp; \
6627 +#define APPEND_CRC16(pbytes, nbytes) \
6629 + uint16 tmp = crc16(pbytes, nbytes, CRC16_INIT_VALUE) ^ 0xffff; \
6630 + (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
6631 + (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
6635 +#define APPEND_CRC32(pbytes, nbytes) \
6637 + uint32 tmp = crc32(pbytes, nbytes, CRC32_INIT_VALUE) ^ 0xffffffff; \
6638 + (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
6639 + (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
6640 + (pbytes)[(nbytes) + 2] = (tmp >> 16) & 0xff; \
6641 + (pbytes)[(nbytes) + 3] = (tmp >> 24) & 0xff; \
6649 +#endif /* _RTS_CRC_H_ */
6650 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbchipc.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbchipc.h
6651 --- linux-2.4.32/arch/mips/bcm947xx/include/sbchipc.h 1970-01-01 01:00:00.000000000 +0100
6652 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbchipc.h 2005-12-16 23:39:10.932836000 +0100
6655 + * SiliconBackplane Chipcommon core hardware definitions.
6657 + * The chipcommon core provides chip identification, SB control,
6658 + * jtag, 0/1/2 uarts, clock frequency control, a watchdog interrupt timer,
6659 + * gpio interface, extbus, and support for serial and parallel flashes.
6662 + * Copyright 2005, Broadcom Corporation
6663 + * All Rights Reserved.
6665 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6666 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6667 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6668 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6676 +#ifndef _LANGUAGE_ASSEMBLY
6678 +/* cpp contortions to concatenate w/arg prescan */
6680 +#define _PADLINE(line) pad ## line
6681 +#define _XSTR(line) _PADLINE(line)
6682 +#define PAD _XSTR(__LINE__)
6685 +typedef volatile struct {
6686 + uint32 chipid; /* 0x0 */
6687 + uint32 capabilities;
6688 + uint32 corecontrol; /* corerev >= 1 */
6692 + uint32 otpstatus; /* 0x10, corerev >= 10 */
6693 + uint32 otpcontrol;
6697 + /* Interrupt control */
6698 + uint32 intstatus; /* 0x20 */
6700 + uint32 chipcontrol; /* 0x28, rev >= 11 */
6701 + uint32 chipstatus; /* 0x2c, rev >= 11 */
6704 + uint32 jtagcmd; /* 0x30, rev >= 10 */
6709 + /* serial flash interface registers */
6710 + uint32 flashcontrol; /* 0x40 */
6711 + uint32 flashaddress;
6715 + /* Silicon backplane configuration broadcast control */
6716 + uint32 broadcastaddress; /* 0x50 */
6717 + uint32 broadcastdata;
6720 + /* gpio - cleared only by power-on-reset */
6721 + uint32 gpioin; /* 0x60 */
6724 + uint32 gpiocontrol;
6725 + uint32 gpiointpolarity;
6726 + uint32 gpiointmask;
6729 + /* Watchdog timer */
6730 + uint32 watchdog; /* 0x80 */
6733 + /*GPIO based LED powersave registers corerev >= 16*/
6734 + uint32 gpiotimerval; /*0x88 */
6735 + uint32 gpiotimeroutmask;
6737 + /* clock control */
6738 + uint32 clockcontrol_n; /* 0x90 */
6739 + uint32 clockcontrol_sb; /* aka m0 */
6740 + uint32 clockcontrol_pci; /* aka m1 */
6741 + uint32 clockcontrol_m2; /* mii/uart/mipsref */
6742 + uint32 clockcontrol_mips; /* aka m3 */
6743 + uint32 clkdiv; /* corerev >= 3 */
6746 + /* pll delay registers (corerev >= 4) */
6747 + uint32 pll_on_delay; /* 0xb0 */
6748 + uint32 fref_sel_delay;
6749 + uint32 slow_clk_ctl; /* 5 < corerev < 10 */
6752 + /* Instaclock registers (corerev >= 10) */
6753 + uint32 system_clk_ctl; /* 0xc0 */
6754 + uint32 clkstatestretch;
6757 + /* ExtBus control registers (corerev >= 3) */
6758 + uint32 pcmcia_config; /* 0x100 */
6759 + uint32 pcmcia_memwait;
6760 + uint32 pcmcia_attrwait;
6761 + uint32 pcmcia_iowait;
6762 + uint32 ide_config;
6763 + uint32 ide_memwait;
6764 + uint32 ide_attrwait;
6765 + uint32 ide_iowait;
6766 + uint32 prog_config;
6767 + uint32 prog_waitcount;
6768 + uint32 flash_config;
6769 + uint32 flash_waitcount;
6773 + uint8 uart0data; /* 0x300 */
6780 + uint8 uart0scratch;
6781 + uint8 PAD[248]; /* corerev >= 1 */
6783 + uint8 uart1data; /* 0x400 */
6790 + uint8 uart1scratch;
6793 +#endif /* _LANGUAGE_ASSEMBLY */
6795 +#define CC_CHIPID 0
6796 +#define CC_CAPABILITIES 4
6797 +#define CC_JTAGCMD 0x30
6798 +#define CC_JTAGIR 0x34
6799 +#define CC_JTAGDR 0x38
6800 +#define CC_JTAGCTRL 0x3c
6801 +#define CC_WATCHDOG 0x80
6802 +#define CC_CLKC_N 0x90
6803 +#define CC_CLKC_M0 0x94
6804 +#define CC_CLKC_M1 0x98
6805 +#define CC_CLKC_M2 0x9c
6806 +#define CC_CLKC_M3 0xa0
6807 +#define CC_CLKDIV 0xa4
6808 +#define CC_SYS_CLK_CTL 0xc0
6809 +#define CC_OTP 0x800
6812 +#define CID_ID_MASK 0x0000ffff /* Chip Id mask */
6813 +#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */
6814 +#define CID_REV_SHIFT 16 /* Chip Revision shift */
6815 +#define CID_PKG_MASK 0x00f00000 /* Package Option mask */
6816 +#define CID_PKG_SHIFT 20 /* Package Option shift */
6817 +#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */
6818 +#define CID_CC_SHIFT 24
6821 +#define CAP_UARTS_MASK 0x00000003 /* Number of uarts */
6822 +#define CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */
6823 +#define CAP_UCLKSEL 0x00000018 /* UARTs clock select */
6824 +#define CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */
6825 +#define CAP_UARTGPIO 0x00000020 /* UARTs own Gpio's 15:12 */
6826 +#define CAP_EXTBUS 0x00000040 /* External bus present */
6827 +#define CAP_FLASH_MASK 0x00000700 /* Type of flash */
6828 +#define CAP_PLL_MASK 0x00038000 /* Type of PLL */
6829 +#define CAP_PWR_CTL 0x00040000 /* Power control */
6830 +#define CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */
6831 +#define CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */
6832 +#define CAP_OTPSIZE_BASE 5 /* OTP Size base */
6833 +#define CAP_JTAGP 0x00400000 /* JTAG Master Present */
6834 +#define CAP_ROM 0x00800000 /* Internal boot rom active */
6837 +#define PLL_NONE 0x00000000
6838 +#define PLL_TYPE1 0x00010000 /* 48Mhz base, 3 dividers */
6839 +#define PLL_TYPE2 0x00020000 /* 48Mhz, 4 dividers */
6840 +#define PLL_TYPE3 0x00030000 /* 25Mhz, 2 dividers */
6841 +#define PLL_TYPE4 0x00008000 /* 48Mhz, 4 dividers */
6842 +#define PLL_TYPE5 0x00018000 /* 25Mhz, 4 dividers */
6843 +#define PLL_TYPE6 0x00028000 /* 100/200 or 120/240 only */
6844 +#define PLL_TYPE7 0x00038000 /* 25Mhz, 4 dividers */
6847 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */
6848 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
6850 +/* Fields in the otpstatus register */
6851 +#define OTPS_PROGFAIL 0x80000000
6852 +#define OTPS_PROTECT 0x00000007
6853 +#define OTPS_HW_PROTECT 0x00000001
6854 +#define OTPS_SW_PROTECT 0x00000002
6855 +#define OTPS_CID_PROTECT 0x00000004
6857 +/* Fields in the otpcontrol register */
6858 +#define OTPC_RECWAIT 0xff000000
6859 +#define OTPC_PROGWAIT 0x00ffff00
6860 +#define OTPC_PRW_SHIFT 8
6861 +#define OTPC_MAXFAIL 0x00000038
6862 +#define OTPC_VSEL 0x00000006
6863 +#define OTPC_SELVL 0x00000001
6865 +/* Fields in otpprog */
6866 +#define OTPP_COL_MASK 0x000000ff
6867 +#define OTPP_ROW_MASK 0x0000ff00
6868 +#define OTPP_ROW_SHIFT 8
6869 +#define OTPP_READERR 0x10000000
6870 +#define OTPP_VALUE 0x20000000
6871 +#define OTPP_VALUE_SHIFT 29
6872 +#define OTPP_READ 0x40000000
6873 +#define OTPP_START 0x80000000
6874 +#define OTPP_BUSY 0x80000000
6877 +#define JCMD_START 0x80000000
6878 +#define JCMD_BUSY 0x80000000
6879 +#define JCMD_PAUSE 0x40000000
6880 +#define JCMD0_ACC_MASK 0x0000f000
6881 +#define JCMD0_ACC_IRDR 0x00000000
6882 +#define JCMD0_ACC_DR 0x00001000
6883 +#define JCMD0_ACC_IR 0x00002000
6884 +#define JCMD0_ACC_RESET 0x00003000
6885 +#define JCMD0_ACC_IRPDR 0x00004000
6886 +#define JCMD0_ACC_PDR 0x00005000
6887 +#define JCMD0_IRW_MASK 0x00000f00
6888 +#define JCMD_ACC_MASK 0x000f0000 /* Changes for corerev 11 */
6889 +#define JCMD_ACC_IRDR 0x00000000
6890 +#define JCMD_ACC_DR 0x00010000
6891 +#define JCMD_ACC_IR 0x00020000
6892 +#define JCMD_ACC_RESET 0x00030000
6893 +#define JCMD_ACC_IRPDR 0x00040000
6894 +#define JCMD_ACC_PDR 0x00050000
6895 +#define JCMD_IRW_MASK 0x00001f00
6896 +#define JCMD_IRW_SHIFT 8
6897 +#define JCMD_DRW_MASK 0x0000003f
6900 +#define JCTRL_FORCE_CLK 4 /* Force clock */
6901 +#define JCTRL_EXT_EN 2 /* Enable external targets */
6902 +#define JCTRL_EN 1 /* Enable Jtag master */
6904 +/* Fields in clkdiv */
6905 +#define CLKD_SFLASH 0x0f000000
6906 +#define CLKD_SFLASH_SHIFT 24
6907 +#define CLKD_OTP 0x000f0000
6908 +#define CLKD_OTP_SHIFT 16
6909 +#define CLKD_JTAG 0x00000f00
6910 +#define CLKD_JTAG_SHIFT 8
6911 +#define CLKD_UART 0x000000ff
6913 +/* intstatus/intmask */
6914 +#define CI_GPIO 0x00000001 /* gpio intr */
6915 +#define CI_EI 0x00000002 /* ro: ext intr pin (corerev >= 3) */
6916 +#define CI_WDRESET 0x80000000 /* watchdog reset occurred */
6919 +#define SCC_SS_MASK 0x00000007 /* slow clock source mask */
6920 +#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */
6921 +#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */
6922 +#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */
6923 +#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */
6924 +#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */
6925 +#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */
6926 +#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */
6927 +#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */
6928 +#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */
6929 +#define SCC_CD_MASK 0xffff0000 /* ClockDivider (SlowClk = 1/(4+divisor)) */
6930 +#define SCC_CD_SHIFT 16
6932 +/* system_clk_ctl */
6933 +#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */
6934 +#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */
6935 +#define SYCC_FP 0x00000004 /* ForcePLLOn */
6936 +#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */
6937 +#define SYCC_HR 0x00000010 /* Force HT */
6938 +#define SYCC_CD_MASK 0xffff0000 /* ClkDiv (ILP = 1/(4+divisor)) */
6939 +#define SYCC_CD_SHIFT 16
6942 +#define GPIO_ONTIME_SHIFT 16
6944 +/* clockcontrol_n */
6945 +#define CN_N1_MASK 0x3f /* n1 control */
6946 +#define CN_N2_MASK 0x3f00 /* n2 control */
6947 +#define CN_N2_SHIFT 8
6948 +#define CN_PLLC_MASK 0xf0000 /* pll control */
6949 +#define CN_PLLC_SHIFT 16
6951 +/* clockcontrol_sb/pci/uart */
6952 +#define CC_M1_MASK 0x3f /* m1 control */
6953 +#define CC_M2_MASK 0x3f00 /* m2 control */
6954 +#define CC_M2_SHIFT 8
6955 +#define CC_M3_MASK 0x3f0000 /* m3 control */
6956 +#define CC_M3_SHIFT 16
6957 +#define CC_MC_MASK 0x1f000000 /* mux control */
6958 +#define CC_MC_SHIFT 24
6960 +/* N3M Clock control magic field values */
6961 +#define CC_F6_2 0x02 /* A factor of 2 in */
6962 +#define CC_F6_3 0x03 /* 6-bit fields like */
6963 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
6964 +#define CC_F6_5 0x09
6965 +#define CC_F6_6 0x11
6966 +#define CC_F6_7 0x21
6968 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
6970 +#define CC_MC_BYPASS 0x08
6971 +#define CC_MC_M1 0x04
6972 +#define CC_MC_M1M2 0x02
6973 +#define CC_MC_M1M2M3 0x01
6974 +#define CC_MC_M1M3 0x11
6976 +/* Type 2 Clock control magic field values */
6977 +#define CC_T2_BIAS 2 /* n1, n2, m1 & m3 bias */
6978 +#define CC_T2M2_BIAS 3 /* m2 bias */
6980 +#define CC_T2MC_M1BYP 1
6981 +#define CC_T2MC_M2BYP 2
6982 +#define CC_T2MC_M3BYP 4
6984 +/* Type 6 Clock control magic field values */
6985 +#define CC_T6_MMASK 1 /* bits of interest in m */
6986 +#define CC_T6_M0 120000000 /* sb clock for m = 0 */
6987 +#define CC_T6_M1 100000000 /* sb clock for m = 1 */
6988 +#define SB2MIPS_T6(sb) (2 * (sb))
6990 +/* Common clock base */
6991 +#define CC_CLOCK_BASE1 24000000 /* Half the clock freq */
6992 +#define CC_CLOCK_BASE2 12500000 /* Alternate crystal on some PLL's */
6994 +/* Clock control values for 200Mhz in 5350 */
6995 +#define CLKC_5350_N 0x0311
6996 +#define CLKC_5350_M 0x04020009
6998 +/* Flash types in the chipcommon capabilities register */
6999 +#define FLASH_NONE 0x000 /* No flash */
7000 +#define SFLASH_ST 0x100 /* ST serial flash */
7001 +#define SFLASH_AT 0x200 /* Atmel serial flash */
7002 +#define PFLASH 0x700 /* Parallel flash */
7004 +/* Bits in the config registers */
7005 +#define CC_CFG_EN 0x0001 /* Enable */
7006 +#define CC_CFG_EM_MASK 0x000e /* Extif Mode */
7007 +#define CC_CFG_EM_ASYNC 0x0002 /* Async/Parallel flash */
7008 +#define CC_CFG_EM_SYNC 0x0004 /* Synchronous */
7009 +#define CC_CFG_EM_PCMCIA 0x0008 /* PCMCIA */
7010 +#define CC_CFG_EM_IDE 0x000a /* IDE */
7011 +#define CC_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
7012 +#define CC_CFG_CD_MASK 0x0060 /* Sync: Clock divisor */
7013 +#define CC_CFG_CE 0x0080 /* Sync: Clock enable */
7014 +#define CC_CFG_SB 0x0100 /* Sync: Size/Bytestrobe */
7016 +/* Start/busy bit in flashcontrol */
7017 +#define SFLASH_START 0x80000000
7018 +#define SFLASH_BUSY SFLASH_START
7020 +/* flashcontrol opcodes for ST flashes */
7021 +#define SFLASH_ST_WREN 0x0006 /* Write Enable */
7022 +#define SFLASH_ST_WRDIS 0x0004 /* Write Disable */
7023 +#define SFLASH_ST_RDSR 0x0105 /* Read Status Register */
7024 +#define SFLASH_ST_WRSR 0x0101 /* Write Status Register */
7025 +#define SFLASH_ST_READ 0x0303 /* Read Data Bytes */
7026 +#define SFLASH_ST_PP 0x0302 /* Page Program */
7027 +#define SFLASH_ST_SE 0x02d8 /* Sector Erase */
7028 +#define SFLASH_ST_BE 0x00c7 /* Bulk Erase */
7029 +#define SFLASH_ST_DP 0x00b9 /* Deep Power-down */
7030 +#define SFLASH_ST_RES 0x03ab /* Read Electronic Signature */
7032 +/* Status register bits for ST flashes */
7033 +#define SFLASH_ST_WIP 0x01 /* Write In Progress */
7034 +#define SFLASH_ST_WEL 0x02 /* Write Enable Latch */
7035 +#define SFLASH_ST_BP_MASK 0x1c /* Block Protect */
7036 +#define SFLASH_ST_BP_SHIFT 2
7037 +#define SFLASH_ST_SRWD 0x80 /* Status Register Write Disable */
7039 +/* flashcontrol opcodes for Atmel flashes */
7040 +#define SFLASH_AT_READ 0x07e8
7041 +#define SFLASH_AT_PAGE_READ 0x07d2
7042 +#define SFLASH_AT_BUF1_READ
7043 +#define SFLASH_AT_BUF2_READ
7044 +#define SFLASH_AT_STATUS 0x01d7
7045 +#define SFLASH_AT_BUF1_WRITE 0x0384
7046 +#define SFLASH_AT_BUF2_WRITE 0x0387
7047 +#define SFLASH_AT_BUF1_ERASE_PROGRAM 0x0283
7048 +#define SFLASH_AT_BUF2_ERASE_PROGRAM 0x0286
7049 +#define SFLASH_AT_BUF1_PROGRAM 0x0288
7050 +#define SFLASH_AT_BUF2_PROGRAM 0x0289
7051 +#define SFLASH_AT_PAGE_ERASE 0x0281
7052 +#define SFLASH_AT_BLOCK_ERASE 0x0250
7053 +#define SFLASH_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382
7054 +#define SFLASH_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385
7055 +#define SFLASH_AT_BUF1_LOAD 0x0253
7056 +#define SFLASH_AT_BUF2_LOAD 0x0255
7057 +#define SFLASH_AT_BUF1_COMPARE 0x0260
7058 +#define SFLASH_AT_BUF2_COMPARE 0x0261
7059 +#define SFLASH_AT_BUF1_REPROGRAM 0x0258
7060 +#define SFLASH_AT_BUF2_REPROGRAM 0x0259
7062 +/* Status register bits for Atmel flashes */
7063 +#define SFLASH_AT_READY 0x80
7064 +#define SFLASH_AT_MISMATCH 0x40
7065 +#define SFLASH_AT_ID_MASK 0x38
7066 +#define SFLASH_AT_ID_SHIFT 3
7069 +#define OTP_HW_REGION OTPS_HW_PROTECT
7070 +#define OTP_SW_REGION OTPS_SW_PROTECT
7071 +#define OTP_CID_REGION OTPS_CID_PROTECT
7073 +/* OTP regions (Byte offsets from otp size) */
7074 +#define OTP_SWLIM_OFF (-8)
7075 +#define OTP_CIDBASE_OFF 0
7076 +#define OTP_CIDLIM_OFF 8
7078 +/* Predefined OTP words (Word offset from otp size) */
7079 +#define OTP_BOUNDARY_OFF (-4)
7080 +#define OTP_HWSIGN_OFF (-3)
7081 +#define OTP_SWSIGN_OFF (-2)
7082 +#define OTP_CIDSIGN_OFF (-1)
7084 +#define OTP_CID_OFF 0
7085 +#define OTP_PKG_OFF 1
7086 +#define OTP_FID_OFF 2
7087 +#define OTP_RSV_OFF 3
7088 +#define OTP_LIM_OFF 4
7090 +#define OTP_SIGNATURE 0x578a
7091 +#define OTP_MAGIC 0x4e56
7093 +#endif /* _SBCHIPC_H */
7094 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbconfig.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbconfig.h
7095 --- linux-2.4.32/arch/mips/bcm947xx/include/sbconfig.h 1970-01-01 01:00:00.000000000 +0100
7096 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbconfig.h 2005-12-16 23:39:10.932836000 +0100
7099 + * Broadcom SiliconBackplane hardware register definitions.
7101 + * Copyright 2005, Broadcom Corporation
7102 + * All Rights Reserved.
7104 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7105 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7106 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7107 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7111 +#ifndef _SBCONFIG_H
7112 +#define _SBCONFIG_H
7114 +/* cpp contortions to concatenate w/arg prescan */
7116 +#define _PADLINE(line) pad ## line
7117 +#define _XSTR(line) _PADLINE(line)
7118 +#define PAD _XSTR(__LINE__)
7122 + * SiliconBackplane Address Map.
7123 + * All regions may not exist on all chips.
7125 +#define SB_SDRAM_BASE 0x00000000 /* Physical SDRAM */
7126 +#define SB_PCI_MEM 0x08000000 /* Host Mode sb2pcitranslation0 (64 MB) */
7127 +#define SB_PCI_CFG 0x0c000000 /* Host Mode sb2pcitranslation1 (64 MB) */
7128 +#define SB_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
7129 +#define SB_ENUM_BASE 0x18000000 /* Enumeration space base */
7130 +#define SB_ENUM_LIM 0x18010000 /* Enumeration space limit */
7132 +#define SB_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
7133 +#define SB_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
7135 +#define SB_EXTIF_BASE 0x1f000000 /* External Interface region base address */
7136 +#define SB_FLASH1 0x1fc00000 /* Flash Region 1 */
7137 +#define SB_FLASH1_SZ 0x00400000 /* Size of Flash Region 1 */
7139 +#define SB_PCI_DMA 0x40000000 /* Client Mode sb2pcitranslation2 (1 GB) */
7140 +#define SB_PCI_DMA_SZ 0x40000000 /* Client Mode sb2pcitranslation2 size in bytes */
7141 +#define SB_PCIE_DMA_L32 0x00000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */
7142 +#define SB_PCIE_DMA_H32 0x80000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */
7143 +#define SB_EUART (SB_EXTIF_BASE + 0x00800000)
7144 +#define SB_LED (SB_EXTIF_BASE + 0x00900000)
7147 +/* enumeration space related defs */
7148 +#define SB_CORE_SIZE 0x1000 /* each core gets 4Kbytes for registers */
7149 +#define SB_MAXCORES ((SB_ENUM_LIM - SB_ENUM_BASE)/SB_CORE_SIZE)
7150 +#define SBCONFIGOFF 0xf00 /* core sbconfig regs are top 256bytes of regs */
7151 +#define SBCONFIGSIZE 256 /* sizeof (sbconfig_t) */
7154 +#define SB_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
7157 + * Sonics Configuration Space Registers.
7159 +#define SBIPSFLAG 0x08
7160 +#define SBTPSFLAG 0x18
7161 +#define SBTMERRLOGA 0x48 /* sonics >= 2.3 */
7162 +#define SBTMERRLOG 0x50 /* sonics >= 2.3 */
7163 +#define SBADMATCH3 0x60
7164 +#define SBADMATCH2 0x68
7165 +#define SBADMATCH1 0x70
7166 +#define SBIMSTATE 0x90
7167 +#define SBINTVEC 0x94
7168 +#define SBTMSTATELOW 0x98
7169 +#define SBTMSTATEHIGH 0x9c
7170 +#define SBBWA0 0xa0
7171 +#define SBIMCONFIGLOW 0xa8
7172 +#define SBIMCONFIGHIGH 0xac
7173 +#define SBADMATCH0 0xb0
7174 +#define SBTMCONFIGLOW 0xb8
7175 +#define SBTMCONFIGHIGH 0xbc
7176 +#define SBBCONFIG 0xc0
7177 +#define SBBSTATE 0xc8
7178 +#define SBACTCNFG 0xd8
7179 +#define SBFLAGST 0xe8
7180 +#define SBIDLOW 0xf8
7181 +#define SBIDHIGH 0xfc
7183 +#ifndef _LANGUAGE_ASSEMBLY
7185 +typedef volatile struct _sbconfig {
7187 + uint32 sbipsflag; /* initiator port ocp slave flag */
7189 + uint32 sbtpsflag; /* target port ocp slave flag */
7191 + uint32 sbtmerrloga; /* (sonics >= 2.3) */
7193 + uint32 sbtmerrlog; /* (sonics >= 2.3) */
7195 + uint32 sbadmatch3; /* address match3 */
7197 + uint32 sbadmatch2; /* address match2 */
7199 + uint32 sbadmatch1; /* address match1 */
7201 + uint32 sbimstate; /* initiator agent state */
7202 + uint32 sbintvec; /* interrupt mask */
7203 + uint32 sbtmstatelow; /* target state */
7204 + uint32 sbtmstatehigh; /* target state */
7205 + uint32 sbbwa0; /* bandwidth allocation table0 */
7207 + uint32 sbimconfiglow; /* initiator configuration */
7208 + uint32 sbimconfighigh; /* initiator configuration */
7209 + uint32 sbadmatch0; /* address match0 */
7211 + uint32 sbtmconfiglow; /* target configuration */
7212 + uint32 sbtmconfighigh; /* target configuration */
7213 + uint32 sbbconfig; /* broadcast configuration */
7215 + uint32 sbbstate; /* broadcast state */
7217 + uint32 sbactcnfg; /* activate configuration */
7219 + uint32 sbflagst; /* current sbflags */
7221 + uint32 sbidlow; /* identification */
7222 + uint32 sbidhigh; /* identification */
7225 +#endif /* _LANGUAGE_ASSEMBLY */
7228 +#define SBIPS_INT1_MASK 0x3f /* which sbflags get routed to mips interrupt 1 */
7229 +#define SBIPS_INT1_SHIFT 0
7230 +#define SBIPS_INT2_MASK 0x3f00 /* which sbflags get routed to mips interrupt 2 */
7231 +#define SBIPS_INT2_SHIFT 8
7232 +#define SBIPS_INT3_MASK 0x3f0000 /* which sbflags get routed to mips interrupt 3 */
7233 +#define SBIPS_INT3_SHIFT 16
7234 +#define SBIPS_INT4_MASK 0x3f000000 /* which sbflags get routed to mips interrupt 4 */
7235 +#define SBIPS_INT4_SHIFT 24
7238 +#define SBTPS_NUM0_MASK 0x3f /* interrupt sbFlag # generated by this core */
7239 +#define SBTPS_F0EN0 0x40 /* interrupt is always sent on the backplane */
7242 +#define SBTMEL_CM 0x00000007 /* command */
7243 +#define SBTMEL_CI 0x0000ff00 /* connection id */
7244 +#define SBTMEL_EC 0x0f000000 /* error code */
7245 +#define SBTMEL_ME 0x80000000 /* multiple error */
7248 +#define SBIM_PC 0xf /* pipecount */
7249 +#define SBIM_AP_MASK 0x30 /* arbitration policy */
7250 +#define SBIM_AP_BOTH 0x00 /* use both timeslaces and token */
7251 +#define SBIM_AP_TS 0x10 /* use timesliaces only */
7252 +#define SBIM_AP_TK 0x20 /* use token only */
7253 +#define SBIM_AP_RSV 0x30 /* reserved */
7254 +#define SBIM_IBE 0x20000 /* inbanderror */
7255 +#define SBIM_TO 0x40000 /* timeout */
7256 +#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */
7257 +#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */
7260 +#define SBTML_RESET 0x1 /* reset */
7261 +#define SBTML_REJ_MASK 0x6 /* reject */
7262 +#define SBTML_REJ_SHIFT 1
7263 +#define SBTML_CLK 0x10000 /* clock enable */
7264 +#define SBTML_FGC 0x20000 /* force gated clocks on */
7265 +#define SBTML_FL_MASK 0x3ffc0000 /* core-specific flags */
7266 +#define SBTML_PE 0x40000000 /* pme enable */
7267 +#define SBTML_BE 0x80000000 /* bist enable */
7269 +/* sbtmstatehigh */
7270 +#define SBTMH_SERR 0x1 /* serror */
7271 +#define SBTMH_INT 0x2 /* interrupt */
7272 +#define SBTMH_BUSY 0x4 /* busy */
7273 +#define SBTMH_TO 0x00000020 /* timeout (sonics >= 2.3) */
7274 +#define SBTMH_FL_MASK 0x1fff0000 /* core-specific flags */
7275 +#define SBTMH_DMA64 0x10000000 /* supports DMA with 64-bit addresses */
7276 +#define SBTMH_GCR 0x20000000 /* gated clock request */
7277 +#define SBTMH_BISTF 0x40000000 /* bist failed */
7278 +#define SBTMH_BISTD 0x80000000 /* bist done */
7282 +#define SBBWA_TAB0_MASK 0xffff /* lookup table 0 */
7283 +#define SBBWA_TAB1_MASK 0xffff /* lookup table 1 */
7284 +#define SBBWA_TAB1_SHIFT 16
7286 +/* sbimconfiglow */
7287 +#define SBIMCL_STO_MASK 0x7 /* service timeout */
7288 +#define SBIMCL_RTO_MASK 0x70 /* request timeout */
7289 +#define SBIMCL_RTO_SHIFT 4
7290 +#define SBIMCL_CID_MASK 0xff0000 /* connection id */
7291 +#define SBIMCL_CID_SHIFT 16
7293 +/* sbimconfighigh */
7294 +#define SBIMCH_IEM_MASK 0xc /* inband error mode */
7295 +#define SBIMCH_TEM_MASK 0x30 /* timeout error mode */
7296 +#define SBIMCH_TEM_SHIFT 4
7297 +#define SBIMCH_BEM_MASK 0xc0 /* bus error mode */
7298 +#define SBIMCH_BEM_SHIFT 6
7301 +#define SBAM_TYPE_MASK 0x3 /* address type */
7302 +#define SBAM_AD64 0x4 /* reserved */
7303 +#define SBAM_ADINT0_MASK 0xf8 /* type0 size */
7304 +#define SBAM_ADINT0_SHIFT 3
7305 +#define SBAM_ADINT1_MASK 0x1f8 /* type1 size */
7306 +#define SBAM_ADINT1_SHIFT 3
7307 +#define SBAM_ADINT2_MASK 0x1f8 /* type2 size */
7308 +#define SBAM_ADINT2_SHIFT 3
7309 +#define SBAM_ADEN 0x400 /* enable */
7310 +#define SBAM_ADNEG 0x800 /* negative decode */
7311 +#define SBAM_BASE0_MASK 0xffffff00 /* type0 base address */
7312 +#define SBAM_BASE0_SHIFT 8
7313 +#define SBAM_BASE1_MASK 0xfffff000 /* type1 base address for the core */
7314 +#define SBAM_BASE1_SHIFT 12
7315 +#define SBAM_BASE2_MASK 0xffff0000 /* type2 base address for the core */
7316 +#define SBAM_BASE2_SHIFT 16
7318 +/* sbtmconfiglow */
7319 +#define SBTMCL_CD_MASK 0xff /* clock divide */
7320 +#define SBTMCL_CO_MASK 0xf800 /* clock offset */
7321 +#define SBTMCL_CO_SHIFT 11
7322 +#define SBTMCL_IF_MASK 0xfc0000 /* interrupt flags */
7323 +#define SBTMCL_IF_SHIFT 18
7324 +#define SBTMCL_IM_MASK 0x3000000 /* interrupt mode */
7325 +#define SBTMCL_IM_SHIFT 24
7327 +/* sbtmconfighigh */
7328 +#define SBTMCH_BM_MASK 0x3 /* busy mode */
7329 +#define SBTMCH_RM_MASK 0x3 /* retry mode */
7330 +#define SBTMCH_RM_SHIFT 2
7331 +#define SBTMCH_SM_MASK 0x30 /* stop mode */
7332 +#define SBTMCH_SM_SHIFT 4
7333 +#define SBTMCH_EM_MASK 0x300 /* sb error mode */
7334 +#define SBTMCH_EM_SHIFT 8
7335 +#define SBTMCH_IM_MASK 0xc00 /* int mode */
7336 +#define SBTMCH_IM_SHIFT 10
7339 +#define SBBC_LAT_MASK 0x3 /* sb latency */
7340 +#define SBBC_MAX0_MASK 0xf0000 /* maxccntr0 */
7341 +#define SBBC_MAX0_SHIFT 16
7342 +#define SBBC_MAX1_MASK 0xf00000 /* maxccntr1 */
7343 +#define SBBC_MAX1_SHIFT 20
7346 +#define SBBS_SRD 0x1 /* st reg disable */
7347 +#define SBBS_HRD 0x2 /* hold reg disable */
7350 +#define SBIDL_CS_MASK 0x3 /* config space */
7351 +#define SBIDL_AR_MASK 0x38 /* # address ranges supported */
7352 +#define SBIDL_AR_SHIFT 3
7353 +#define SBIDL_SYNCH 0x40 /* sync */
7354 +#define SBIDL_INIT 0x80 /* initiator */
7355 +#define SBIDL_MINLAT_MASK 0xf00 /* minimum backplane latency */
7356 +#define SBIDL_MINLAT_SHIFT 8
7357 +#define SBIDL_MAXLAT 0xf000 /* maximum backplane latency */
7358 +#define SBIDL_MAXLAT_SHIFT 12
7359 +#define SBIDL_FIRST 0x10000 /* this initiator is first */
7360 +#define SBIDL_CW_MASK 0xc0000 /* cycle counter width */
7361 +#define SBIDL_CW_SHIFT 18
7362 +#define SBIDL_TP_MASK 0xf00000 /* target ports */
7363 +#define SBIDL_TP_SHIFT 20
7364 +#define SBIDL_IP_MASK 0xf000000 /* initiator ports */
7365 +#define SBIDL_IP_SHIFT 24
7366 +#define SBIDL_RV_MASK 0xf0000000 /* sonics backplane revision code */
7367 +#define SBIDL_RV_SHIFT 28
7368 +#define SBIDL_RV_2_2 0x00000000 /* version 2.2 or earlier */
7369 +#define SBIDL_RV_2_3 0x10000000 /* version 2.3 */
7372 +#define SBIDH_RC_MASK 0x000f /* revision code */
7373 +#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */
7374 +#define SBIDH_RCE_SHIFT 8
7375 +#define SBCOREREV(sbidh) \
7376 + ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | ((sbidh) & SBIDH_RC_MASK))
7377 +#define SBIDH_CC_MASK 0x8ff0 /* core code */
7378 +#define SBIDH_CC_SHIFT 4
7379 +#define SBIDH_VC_MASK 0xffff0000 /* vendor code */
7380 +#define SBIDH_VC_SHIFT 16
7382 +#define SB_COMMIT 0xfd8 /* update buffered registers value */
7385 +#define SB_VEND_BCM 0x4243 /* Broadcom's SB vendor code */
7388 +#define SB_CC 0x800 /* chipcommon core */
7389 +#define SB_ILINE20 0x801 /* iline20 core */
7390 +#define SB_SDRAM 0x803 /* sdram core */
7391 +#define SB_PCI 0x804 /* pci core */
7392 +#define SB_MIPS 0x805 /* mips core */
7393 +#define SB_ENET 0x806 /* enet mac core */
7394 +#define SB_CODEC 0x807 /* v90 codec core */
7395 +#define SB_USB 0x808 /* usb 1.1 host/device core */
7396 +#define SB_ADSL 0x809 /* ADSL core */
7397 +#define SB_ILINE100 0x80a /* iline100 core */
7398 +#define SB_IPSEC 0x80b /* ipsec core */
7399 +#define SB_PCMCIA 0x80d /* pcmcia core */
7400 +#define SB_SOCRAM 0x80e /* internal memory core */
7401 +#define SB_MEMC 0x80f /* memc sdram core */
7402 +#define SB_EXTIF 0x811 /* external interface core */
7403 +#define SB_D11 0x812 /* 802.11 MAC core */
7404 +#define SB_MIPS33 0x816 /* mips3302 core */
7405 +#define SB_USB11H 0x817 /* usb 1.1 host core */
7406 +#define SB_USB11D 0x818 /* usb 1.1 device core */
7407 +#define SB_USB20H 0x819 /* usb 2.0 host core */
7408 +#define SB_USB20D 0x81a /* usb 2.0 device core */
7409 +#define SB_SDIOH 0x81b /* sdio host core */
7410 +#define SB_ROBO 0x81c /* roboswitch core */
7411 +#define SB_ATA100 0x81d /* parallel ATA core */
7412 +#define SB_SATAXOR 0x81e /* serial ATA & XOR DMA core */
7413 +#define SB_GIGETH 0x81f /* gigabit ethernet core */
7414 +#define SB_PCIE 0x820 /* pci express core */
7415 +#define SB_SRAMC 0x822 /* SRAM controller core */
7416 +#define SB_MINIMAC 0x823 /* MINI MAC/phy core */
7418 +#define SB_CC_IDX 0 /* chipc, when present, is always core 0 */
7420 +/* Not really related to Silicon Backplane, but a couple of software
7421 + * conventions for the use the flash space:
7424 +/* Minumum amount of flash we support */
7425 +#define FLASH_MIN 0x00020000 /* Minimum flash size */
7427 +/* A boot/binary may have an embedded block that describes its size */
7428 +#define BISZ_OFFSET 0x3e0 /* At this offset into the binary */
7429 +#define BISZ_MAGIC 0x4249535a /* Marked with this value: 'BISZ' */
7430 +#define BISZ_MAGIC_IDX 0 /* Word 0: magic */
7431 +#define BISZ_TXTST_IDX 1 /* 1: text start */
7432 +#define BISZ_TXTEND_IDX 2 /* 2: text start */
7433 +#define BISZ_DATAST_IDX 3 /* 3: text start */
7434 +#define BISZ_DATAEND_IDX 4 /* 4: text start */
7435 +#define BISZ_BSSST_IDX 5 /* 5: text start */
7436 +#define BISZ_BSSEND_IDX 6 /* 6: text start */
7437 +#define BISZ_SIZE 7 /* descriptor size in 32-bit intergers */
7439 +#endif /* _SBCONFIG_H */
7440 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbextif.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbextif.h
7441 --- linux-2.4.32/arch/mips/bcm947xx/include/sbextif.h 1970-01-01 01:00:00.000000000 +0100
7442 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbextif.h 2005-12-16 23:39:10.932836000 +0100
7445 + * Hardware-specific External Interface I/O core definitions
7446 + * for the BCM47xx family of SiliconBackplane-based chips.
7448 + * The External Interface core supports a total of three external chip selects
7449 + * supporting external interfaces. One of the external chip selects is
7450 + * used for Flash, one is used for PCMCIA, and the other may be
7451 + * programmed to support either a synchronous interface or an
7452 + * asynchronous interface. The asynchronous interface can be used to
7453 + * support external devices such as UARTs and the BCM2019 Bluetooth
7454 + * baseband processor.
7455 + * The external interface core also contains 2 on-chip 16550 UARTs, clock
7456 + * frequency control, a watchdog interrupt timer, and a GPIO interface.
7458 + * Copyright 2005, Broadcom Corporation
7459 + * All Rights Reserved.
7461 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7462 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7463 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7464 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7471 +/* external interface address space */
7472 +#define EXTIF_PCMCIA_MEMBASE(x) (x)
7473 +#define EXTIF_PCMCIA_IOBASE(x) ((x) + 0x100000)
7474 +#define EXTIF_PCMCIA_CFGBASE(x) ((x) + 0x200000)
7475 +#define EXTIF_CFGIF_BASE(x) ((x) + 0x800000)
7476 +#define EXTIF_FLASH_BASE(x) ((x) + 0xc00000)
7478 +/* cpp contortions to concatenate w/arg prescan */
7480 +#define _PADLINE(line) pad ## line
7481 +#define _XSTR(line) _PADLINE(line)
7482 +#define PAD _XSTR(__LINE__)
7486 + * The multiple instances of output and output enable registers
7487 + * are present to allow driver software for multiple cores to control
7488 + * gpio outputs without needing to share a single register pair.
7494 +#define NGPIOUSER 5
7496 +typedef volatile struct {
7497 + uint32 corecontrol;
7501 + /* pcmcia control registers */
7502 + uint32 pcmcia_config;
7503 + uint32 pcmcia_memwait;
7504 + uint32 pcmcia_attrwait;
7505 + uint32 pcmcia_iowait;
7507 + /* programmable interface control registers */
7508 + uint32 prog_config;
7509 + uint32 prog_waitcount;
7511 + /* flash control registers */
7512 + uint32 flash_config;
7513 + uint32 flash_waitcount;
7518 + /* clock control */
7519 + uint32 clockcontrol_n;
7520 + uint32 clockcontrol_sb;
7521 + uint32 clockcontrol_pci;
7522 + uint32 clockcontrol_mii;
7527 + struct gpiouser gpio[NGPIOUSER];
7529 + uint32 ejtagouten;
7530 + uint32 gpiointpolarity;
7531 + uint32 gpiointmask;
7548 + uint8 uartscratch;
7553 +#define CC_UE (1 << 0) /* uart enable */
7556 +#define ES_EM (1 << 0) /* endian mode (ro) */
7557 +#define ES_EI (1 << 1) /* external interrupt pin (ro) */
7558 +#define ES_GI (1 << 2) /* gpio interrupt pin (ro) */
7560 +/* gpio bit mask */
7561 +#define GPIO_BIT0 (1 << 0)
7562 +#define GPIO_BIT1 (1 << 1)
7563 +#define GPIO_BIT2 (1 << 2)
7564 +#define GPIO_BIT3 (1 << 3)
7565 +#define GPIO_BIT4 (1 << 4)
7566 +#define GPIO_BIT5 (1 << 5)
7567 +#define GPIO_BIT6 (1 << 6)
7568 +#define GPIO_BIT7 (1 << 7)
7571 +/* pcmcia/prog/flash_config */
7572 +#define CF_EN (1 << 0) /* enable */
7573 +#define CF_EM_MASK 0xe /* mode */
7574 +#define CF_EM_SHIFT 1
7575 +#define CF_EM_FLASH 0x0 /* flash/asynchronous mode */
7576 +#define CF_EM_SYNC 0x2 /* synchronous mode */
7577 +#define CF_EM_PCMCIA 0x4 /* pcmcia mode */
7578 +#define CF_DS (1 << 4) /* destsize: 0=8bit, 1=16bit */
7579 +#define CF_BS (1 << 5) /* byteswap */
7580 +#define CF_CD_MASK 0xc0 /* clock divider */
7581 +#define CF_CD_SHIFT 6
7582 +#define CF_CD_DIV2 0x0 /* backplane/2 */
7583 +#define CF_CD_DIV3 0x40 /* backplane/3 */
7584 +#define CF_CD_DIV4 0x80 /* backplane/4 */
7585 +#define CF_CE (1 << 8) /* clock enable */
7586 +#define CF_SB (1 << 9) /* size/bytestrobe (synch only) */
7588 +/* pcmcia_memwait */
7589 +#define PM_W0_MASK 0x3f /* waitcount0 */
7590 +#define PM_W1_MASK 0x1f00 /* waitcount1 */
7591 +#define PM_W1_SHIFT 8
7592 +#define PM_W2_MASK 0x1f0000 /* waitcount2 */
7593 +#define PM_W2_SHIFT 16
7594 +#define PM_W3_MASK 0x1f000000 /* waitcount3 */
7595 +#define PM_W3_SHIFT 24
7597 +/* pcmcia_attrwait */
7598 +#define PA_W0_MASK 0x3f /* waitcount0 */
7599 +#define PA_W1_MASK 0x1f00 /* waitcount1 */
7600 +#define PA_W1_SHIFT 8
7601 +#define PA_W2_MASK 0x1f0000 /* waitcount2 */
7602 +#define PA_W2_SHIFT 16
7603 +#define PA_W3_MASK 0x1f000000 /* waitcount3 */
7604 +#define PA_W3_SHIFT 24
7606 +/* pcmcia_iowait */
7607 +#define PI_W0_MASK 0x3f /* waitcount0 */
7608 +#define PI_W1_MASK 0x1f00 /* waitcount1 */
7609 +#define PI_W1_SHIFT 8
7610 +#define PI_W2_MASK 0x1f0000 /* waitcount2 */
7611 +#define PI_W2_SHIFT 16
7612 +#define PI_W3_MASK 0x1f000000 /* waitcount3 */
7613 +#define PI_W3_SHIFT 24
7615 +/* prog_waitcount */
7616 +#define PW_W0_MASK 0x0000001f /* waitcount0 */
7617 +#define PW_W1_MASK 0x00001f00 /* waitcount1 */
7618 +#define PW_W1_SHIFT 8
7619 +#define PW_W2_MASK 0x001f0000 /* waitcount2 */
7620 +#define PW_W2_SHIFT 16
7621 +#define PW_W3_MASK 0x1f000000 /* waitcount3 */
7622 +#define PW_W3_SHIFT 24
7624 +#define PW_W0 0x0000000c
7625 +#define PW_W1 0x00000a00
7626 +#define PW_W2 0x00020000
7627 +#define PW_W3 0x01000000
7629 +/* flash_waitcount */
7630 +#define FW_W0_MASK 0x1f /* waitcount0 */
7631 +#define FW_W1_MASK 0x1f00 /* waitcount1 */
7632 +#define FW_W1_SHIFT 8
7633 +#define FW_W2_MASK 0x1f0000 /* waitcount2 */
7634 +#define FW_W2_SHIFT 16
7635 +#define FW_W3_MASK 0x1f000000 /* waitcount3 */
7636 +#define FW_W3_SHIFT 24
7639 +#define WATCHDOG_CLOCK 48000000 /* Hz */
7641 +/* clockcontrol_n */
7642 +#define CN_N1_MASK 0x3f /* n1 control */
7643 +#define CN_N2_MASK 0x3f00 /* n2 control */
7644 +#define CN_N2_SHIFT 8
7646 +/* clockcontrol_sb/pci/mii */
7647 +#define CC_M1_MASK 0x3f /* m1 control */
7648 +#define CC_M2_MASK 0x3f00 /* m2 control */
7649 +#define CC_M2_SHIFT 8
7650 +#define CC_M3_MASK 0x3f0000 /* m3 control */
7651 +#define CC_M3_SHIFT 16
7652 +#define CC_MC_MASK 0x1f000000 /* mux control */
7653 +#define CC_MC_SHIFT 24
7655 +/* Clock control default values */
7656 +#define CC_DEF_N 0x0009 /* Default values for bcm4710 */
7657 +#define CC_DEF_100 0x04020011
7658 +#define CC_DEF_33 0x11030011
7659 +#define CC_DEF_25 0x11050011
7661 +/* Clock control values for 125Mhz */
7662 +#define CC_125_N 0x0802
7663 +#define CC_125_M 0x04020009
7664 +#define CC_125_M25 0x11090009
7665 +#define CC_125_M33 0x11090005
7667 +/* Clock control magic field values */
7668 +#define CC_F6_2 0x02 /* A factor of 2 in */
7669 +#define CC_F6_3 0x03 /* 6-bit fields like */
7670 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
7671 +#define CC_F6_5 0x09
7672 +#define CC_F6_6 0x11
7673 +#define CC_F6_7 0x21
7675 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
7677 +#define CC_MC_BYPASS 0x08
7678 +#define CC_MC_M1 0x04
7679 +#define CC_MC_M1M2 0x02
7680 +#define CC_MC_M1M2M3 0x01
7681 +#define CC_MC_M1M3 0x11
7683 +#define CC_CLOCK_BASE 24000000 /* Half the clock freq. in the 4710 */
7685 +#endif /* _SBEXTIF_H */
7686 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbhnddma.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbhnddma.h
7687 --- linux-2.4.32/arch/mips/bcm947xx/include/sbhnddma.h 1970-01-01 01:00:00.000000000 +0100
7688 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbhnddma.h 2005-12-16 23:39:10.932836000 +0100
7691 + * Generic Broadcom Home Networking Division (HND) DMA engine HW interface
7692 + * This supports the following chips: BCM42xx, 44xx, 47xx .
7694 + * Copyright 2005, Broadcom Corporation
7695 + * All Rights Reserved.
7697 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7698 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7699 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7700 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7704 +#ifndef _sbhnddma_h_
7705 +#define _sbhnddma_h_
7708 +/* 2byte-wide pio register set per channel(xmt or rcv) */
7709 +typedef volatile struct {
7710 + uint16 fifocontrol;
7712 + uint16 fifofree; /* only valid in xmt channel, not in rcv channel */
7716 +/* a pair of pio channels(tx and rx) */
7717 +typedef volatile struct {
7722 +/* 4byte-wide pio register set per channel(xmt or rcv) */
7723 +typedef volatile struct {
7724 + uint32 fifocontrol;
7728 +/* a pair of pio channels(tx and rx) */
7729 +typedef volatile struct {
7737 + * support two DMA engines: 32 bits address or 64 bit addressing
7738 + * basic DMA register set is per channel(transmit or receive)
7739 + * a pair of channels is defined for convenience
7743 +/*** 32 bits addressing ***/
7745 +/* dma registers per channel(xmt or rcv) */
7746 +typedef volatile struct {
7747 + uint32 control; /* enable, et al */
7748 + uint32 addr; /* descriptor ring base address (4K aligned) */
7749 + uint32 ptr; /* last descriptor posted to chip */
7750 + uint32 status; /* current active descriptor, et al */
7753 +typedef volatile struct {
7754 + dma32regs_t xmt; /* dma tx channel */
7755 + dma32regs_t rcv; /* dma rx channel */
7758 +typedef volatile struct { /* diag access */
7759 + uint32 fifoaddr; /* diag address */
7760 + uint32 fifodatalow; /* low 32bits of data */
7761 + uint32 fifodatahigh; /* high 32bits of data */
7762 + uint32 pad; /* reserved */
7767 + * Descriptors are only read by the hardware, never written back.
7769 +typedef volatile struct {
7770 + uint32 ctrl; /* misc control bits & bufcount */
7771 + uint32 addr; /* data buffer address */
7775 + * Each descriptor ring must be 4096byte aligned, and fit within a single 4096byte page.
7777 +#define D32MAXRINGSZ 4096
7778 +#define D32RINGALIGN 4096
7779 +#define D32MAXDD (D32MAXRINGSZ / sizeof (dma32dd_t))
7781 +/* transmit channel control */
7782 +#define XC_XE ((uint32)1 << 0) /* transmit enable */
7783 +#define XC_SE ((uint32)1 << 1) /* transmit suspend request */
7784 +#define XC_LE ((uint32)1 << 2) /* loopback enable */
7785 +#define XC_FL ((uint32)1 << 4) /* flush request */
7786 +#define XC_AE ((uint32)3 << 16) /* address extension bits */
7787 +#define XC_AE_SHIFT 16
7789 +/* transmit descriptor table pointer */
7790 +#define XP_LD_MASK 0xfff /* last valid descriptor */
7792 +/* transmit channel status */
7793 +#define XS_CD_MASK 0x0fff /* current descriptor pointer */
7794 +#define XS_XS_MASK 0xf000 /* transmit state */
7795 +#define XS_XS_SHIFT 12
7796 +#define XS_XS_DISABLED 0x0000 /* disabled */
7797 +#define XS_XS_ACTIVE 0x1000 /* active */
7798 +#define XS_XS_IDLE 0x2000 /* idle wait */
7799 +#define XS_XS_STOPPED 0x3000 /* stopped */
7800 +#define XS_XS_SUSP 0x4000 /* suspend pending */
7801 +#define XS_XE_MASK 0xf0000 /* transmit errors */
7802 +#define XS_XE_SHIFT 16
7803 +#define XS_XE_NOERR 0x00000 /* no error */
7804 +#define XS_XE_DPE 0x10000 /* descriptor protocol error */
7805 +#define XS_XE_DFU 0x20000 /* data fifo underrun */
7806 +#define XS_XE_BEBR 0x30000 /* bus error on buffer read */
7807 +#define XS_XE_BEDA 0x40000 /* bus error on descriptor access */
7808 +#define XS_AD_MASK 0xfff00000 /* active descriptor */
7809 +#define XS_AD_SHIFT 20
7811 +/* receive channel control */
7812 +#define RC_RE ((uint32)1 << 0) /* receive enable */
7813 +#define RC_RO_MASK 0xfe /* receive frame offset */
7814 +#define RC_RO_SHIFT 1
7815 +#define RC_FM ((uint32)1 << 8) /* direct fifo receive (pio) mode */
7816 +#define RC_AE ((uint32)3 << 16) /* address extension bits */
7817 +#define RC_AE_SHIFT 16
7819 +/* receive descriptor table pointer */
7820 +#define RP_LD_MASK 0xfff /* last valid descriptor */
7822 +/* receive channel status */
7823 +#define RS_CD_MASK 0x0fff /* current descriptor pointer */
7824 +#define RS_RS_MASK 0xf000 /* receive state */
7825 +#define RS_RS_SHIFT 12
7826 +#define RS_RS_DISABLED 0x0000 /* disabled */
7827 +#define RS_RS_ACTIVE 0x1000 /* active */
7828 +#define RS_RS_IDLE 0x2000 /* idle wait */
7829 +#define RS_RS_STOPPED 0x3000 /* reserved */
7830 +#define RS_RE_MASK 0xf0000 /* receive errors */
7831 +#define RS_RE_SHIFT 16
7832 +#define RS_RE_NOERR 0x00000 /* no error */
7833 +#define RS_RE_DPE 0x10000 /* descriptor protocol error */
7834 +#define RS_RE_DFO 0x20000 /* data fifo overflow */
7835 +#define RS_RE_BEBW 0x30000 /* bus error on buffer write */
7836 +#define RS_RE_BEDA 0x40000 /* bus error on descriptor access */
7837 +#define RS_AD_MASK 0xfff00000 /* active descriptor */
7838 +#define RS_AD_SHIFT 20
7841 +#define FA_OFF_MASK 0xffff /* offset */
7842 +#define FA_SEL_MASK 0xf0000 /* select */
7843 +#define FA_SEL_SHIFT 16
7844 +#define FA_SEL_XDD 0x00000 /* transmit dma data */
7845 +#define FA_SEL_XDP 0x10000 /* transmit dma pointers */
7846 +#define FA_SEL_RDD 0x40000 /* receive dma data */
7847 +#define FA_SEL_RDP 0x50000 /* receive dma pointers */
7848 +#define FA_SEL_XFD 0x80000 /* transmit fifo data */
7849 +#define FA_SEL_XFP 0x90000 /* transmit fifo pointers */
7850 +#define FA_SEL_RFD 0xc0000 /* receive fifo data */
7851 +#define FA_SEL_RFP 0xd0000 /* receive fifo pointers */
7852 +#define FA_SEL_RSD 0xe0000 /* receive frame status data */
7853 +#define FA_SEL_RSP 0xf0000 /* receive frame status pointers */
7855 +/* descriptor control flags */
7856 +#define CTRL_BC_MASK 0x1fff /* buffer byte count */
7857 +#define CTRL_AE ((uint32)3 << 16) /* address extension bits */
7858 +#define CTRL_AE_SHIFT 16
7859 +#define CTRL_EOT ((uint32)1 << 28) /* end of descriptor table */
7860 +#define CTRL_IOC ((uint32)1 << 29) /* interrupt on completion */
7861 +#define CTRL_EOF ((uint32)1 << 30) /* end of frame */
7862 +#define CTRL_SOF ((uint32)1 << 31) /* start of frame */
7864 +/* control flags in the range [27:20] are core-specific and not defined here */
7865 +#define CTRL_CORE_MASK 0x0ff00000
7867 +/*** 64 bits addressing ***/
7869 +/* dma registers per channel(xmt or rcv) */
7870 +typedef volatile struct {
7871 + uint32 control; /* enable, et al */
7872 + uint32 ptr; /* last descriptor posted to chip */
7873 + uint32 addrlow; /* descriptor ring base address low 32-bits (8K aligned) */
7874 + uint32 addrhigh; /* descriptor ring base address bits 63:32 (8K aligned) */
7875 + uint32 status0; /* current descriptor, xmt state */
7876 + uint32 status1; /* active descriptor, xmt error */
7879 +typedef volatile struct {
7880 + dma64regs_t tx; /* dma64 tx channel */
7881 + dma64regs_t rx; /* dma64 rx channel */
7884 +typedef volatile struct { /* diag access */
7885 + uint32 fifoaddr; /* diag address */
7886 + uint32 fifodatalow; /* low 32bits of data */
7887 + uint32 fifodatahigh; /* high 32bits of data */
7888 + uint32 pad; /* reserved */
7893 + * Descriptors are only read by the hardware, never written back.
7895 +typedef volatile struct {
7896 + uint32 ctrl1; /* misc control bits & bufcount */
7897 + uint32 ctrl2; /* buffer count and address extension */
7898 + uint32 addrlow; /* memory address of the first byte of the date buffer, bits 31:0 */
7899 + uint32 addrhigh; /* memory address of the first byte of the date buffer, bits 63:32 */
7903 + * Each descriptor ring must be 8kB aligned, and fit within a contiguous 8kB physical addresss.
7905 +#define D64MAXRINGSZ 8192
7906 +#define D64RINGALIGN 8192
7907 +#define D64MAXDD (D64MAXRINGSZ / sizeof (dma64dd_t))
7909 +/* transmit channel control */
7910 +#define D64_XC_XE 0x00000001 /* transmit enable */
7911 +#define D64_XC_SE 0x00000002 /* transmit suspend request */
7912 +#define D64_XC_LE 0x00000004 /* loopback enable */
7913 +#define D64_XC_FL 0x00000010 /* flush request */
7914 +#define D64_XC_AE 0x00110000 /* address extension bits */
7915 +#define D64_XC_AE_SHIFT 16
7917 +/* transmit descriptor table pointer */
7918 +#define D64_XP_LD_MASK 0x00000fff /* last valid descriptor */
7920 +/* transmit channel status */
7921 +#define D64_XS0_CD_MASK 0x00001fff /* current descriptor pointer */
7922 +#define D64_XS0_XS_MASK 0xf0000000 /* transmit state */
7923 +#define D64_XS0_XS_SHIFT 28
7924 +#define D64_XS0_XS_DISABLED 0x00000000 /* disabled */
7925 +#define D64_XS0_XS_ACTIVE 0x10000000 /* active */
7926 +#define D64_XS0_XS_IDLE 0x20000000 /* idle wait */
7927 +#define D64_XS0_XS_STOPPED 0x30000000 /* stopped */
7928 +#define D64_XS0_XS_SUSP 0x40000000 /* suspend pending */
7930 +#define D64_XS1_AD_MASK 0x0001ffff /* active descriptor */
7931 +#define D64_XS1_XE_MASK 0xf0000000 /* transmit errors */
7932 +#define D64_XS1_XE_SHIFT 28
7933 +#define D64_XS1_XE_NOERR 0x00000000 /* no error */
7934 +#define D64_XS1_XE_DPE 0x10000000 /* descriptor protocol error */
7935 +#define D64_XS1_XE_DFU 0x20000000 /* data fifo underrun */
7936 +#define D64_XS1_XE_DTE 0x30000000 /* data transfer error */
7937 +#define D64_XS1_XE_DESRE 0x40000000 /* descriptor read error */
7938 +#define D64_XS1_XE_COREE 0x50000000 /* core error */
7940 +/* receive channel control */
7941 +#define D64_RC_RE 0x00000001 /* receive enable */
7942 +#define D64_RC_RO_MASK 0x000000fe /* receive frame offset */
7943 +#define D64_RC_RO_SHIFT 1
7944 +#define D64_RC_FM 0x00000100 /* direct fifo receive (pio) mode */
7945 +#define D64_RC_AE 0x00110000 /* address extension bits */
7946 +#define D64_RC_AE_SHIFT 16
7948 +/* receive descriptor table pointer */
7949 +#define D64_RP_LD_MASK 0x00000fff /* last valid descriptor */
7951 +/* receive channel status */
7952 +#define D64_RS0_CD_MASK 0x00001fff /* current descriptor pointer */
7953 +#define D64_RS0_RS_MASK 0xf0000000 /* receive state */
7954 +#define D64_RS0_RS_SHIFT 28
7955 +#define D64_RS0_RS_DISABLED 0x00000000 /* disabled */
7956 +#define D64_RS0_RS_ACTIVE 0x10000000 /* active */
7957 +#define D64_RS0_RS_IDLE 0x20000000 /* idle wait */
7958 +#define D64_RS0_RS_STOPPED 0x30000000 /* stopped */
7959 +#define D64_RS0_RS_SUSP 0x40000000 /* suspend pending */
7961 +#define D64_RS1_AD_MASK 0x0001ffff /* active descriptor */
7962 +#define D64_RS1_RE_MASK 0xf0000000 /* receive errors */
7963 +#define D64_RS1_RE_SHIFT 28
7964 +#define D64_RS1_RE_NOERR 0x00000000 /* no error */
7965 +#define D64_RS1_RE_DPO 0x10000000 /* descriptor protocol error */
7966 +#define D64_RS1_RE_DFU 0x20000000 /* data fifo overflow */
7967 +#define D64_RS1_RE_DTE 0x30000000 /* data transfer error */
7968 +#define D64_RS1_RE_DESRE 0x40000000 /* descriptor read error */
7969 +#define D64_RS1_RE_COREE 0x50000000 /* core error */
7972 +#define D64_FA_OFF_MASK 0xffff /* offset */
7973 +#define D64_FA_SEL_MASK 0xf0000 /* select */
7974 +#define D64_FA_SEL_SHIFT 16
7975 +#define D64_FA_SEL_XDD 0x00000 /* transmit dma data */
7976 +#define D64_FA_SEL_XDP 0x10000 /* transmit dma pointers */
7977 +#define D64_FA_SEL_RDD 0x40000 /* receive dma data */
7978 +#define D64_FA_SEL_RDP 0x50000 /* receive dma pointers */
7979 +#define D64_FA_SEL_XFD 0x80000 /* transmit fifo data */
7980 +#define D64_FA_SEL_XFP 0x90000 /* transmit fifo pointers */
7981 +#define D64_FA_SEL_RFD 0xc0000 /* receive fifo data */
7982 +#define D64_FA_SEL_RFP 0xd0000 /* receive fifo pointers */
7983 +#define D64_FA_SEL_RSD 0xe0000 /* receive frame status data */
7984 +#define D64_FA_SEL_RSP 0xf0000 /* receive frame status pointers */
7986 +/* descriptor control flags 1 */
7987 +#define D64_CTRL1_EOT ((uint32)1 << 28) /* end of descriptor table */
7988 +#define D64_CTRL1_IOC ((uint32)1 << 29) /* interrupt on completion */
7989 +#define D64_CTRL1_EOF ((uint32)1 << 30) /* end of frame */
7990 +#define D64_CTRL1_SOF ((uint32)1 << 31) /* start of frame */
7992 +/* descriptor control flags 2 */
7993 +#define D64_CTRL2_BC_MASK 0x00007fff /* buffer byte count mask */
7994 +#define D64_CTRL2_AE 0x00110000 /* address extension bits */
7995 +#define D64_CTRL2_AE_SHIFT 16
7997 +/* control flags in the range [27:20] are core-specific and not defined here */
7998 +#define D64_CTRL_CORE_MASK 0x0ff00000
8001 +#endif /* _sbhnddma_h_ */
8002 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbmemc.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbmemc.h
8003 --- linux-2.4.32/arch/mips/bcm947xx/include/sbmemc.h 1970-01-01 01:00:00.000000000 +0100
8004 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbmemc.h 2005-12-16 23:39:10.932836000 +0100
8007 + * BCM47XX Sonics SiliconBackplane DDR/SDRAM controller core hardware definitions.
8009 + * Copyright 2005, Broadcom Corporation
8010 + * All Rights Reserved.
8012 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8013 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8014 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8015 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8023 +#ifdef _LANGUAGE_ASSEMBLY
8025 +#define MEMC_CONTROL 0x00
8026 +#define MEMC_CONFIG 0x04
8027 +#define MEMC_REFRESH 0x08
8028 +#define MEMC_BISTSTAT 0x0c
8029 +#define MEMC_MODEBUF 0x10
8030 +#define MEMC_BKCLS 0x14
8031 +#define MEMC_PRIORINV 0x18
8032 +#define MEMC_DRAMTIM 0x1c
8033 +#define MEMC_INTSTAT 0x20
8034 +#define MEMC_INTMASK 0x24
8035 +#define MEMC_INTINFO 0x28
8036 +#define MEMC_NCDLCTL 0x30
8037 +#define MEMC_RDNCDLCOR 0x34
8038 +#define MEMC_WRNCDLCOR 0x38
8039 +#define MEMC_MISCDLYCTL 0x3c
8040 +#define MEMC_DQSGATENCDL 0x40
8041 +#define MEMC_SPARE 0x44
8042 +#define MEMC_TPADDR 0x48
8043 +#define MEMC_TPDATA 0x4c
8044 +#define MEMC_BARRIER 0x50
8045 +#define MEMC_CORE 0x54
8050 +/* Sonics side: MEMC core registers */
8051 +typedef volatile struct sbmemcregs {
8067 + uint32 miscdlyctl;
8068 + uint32 dqsgatencdl;
8078 +/* MEMC Core Init values (OCP ID 0x80f) */
8081 +#define MEMC_SD_CONFIG_INIT 0x00048000
8082 +#define MEMC_SD_DRAMTIM2_INIT 0x000754d8
8083 +#define MEMC_SD_DRAMTIM3_INIT 0x000754da
8084 +#define MEMC_SD_RDNCDLCOR_INIT 0x00000000
8085 +#define MEMC_SD_WRNCDLCOR_INIT 0x49351200
8086 +#define MEMC_SD1_WRNCDLCOR_INIT 0x14500200 /* For corerev 1 (4712) */
8087 +#define MEMC_SD_MISCDLYCTL_INIT 0x00061c1b
8088 +#define MEMC_SD1_MISCDLYCTL_INIT 0x00021416 /* For corerev 1 (4712) */
8089 +#define MEMC_SD_CONTROL_INIT0 0x00000002
8090 +#define MEMC_SD_CONTROL_INIT1 0x00000008
8091 +#define MEMC_SD_CONTROL_INIT2 0x00000004
8092 +#define MEMC_SD_CONTROL_INIT3 0x00000010
8093 +#define MEMC_SD_CONTROL_INIT4 0x00000001
8094 +#define MEMC_SD_MODEBUF_INIT 0x00000000
8095 +#define MEMC_SD_REFRESH_INIT 0x0000840f
8098 +/* This is for SDRM8X8X4 */
8099 +#define MEMC_SDR_INIT 0x0008
8100 +#define MEMC_SDR_MODE 0x32
8101 +#define MEMC_SDR_NCDL 0x00020032
8102 +#define MEMC_SDR1_NCDL 0x0002020f /* For corerev 1 (4712) */
8105 +#define MEMC_CONFIG_INIT 0x00048000
8106 +#define MEMC_DRAMTIM2_INIT 0x000754d8
8107 +#define MEMC_DRAMTIM25_INIT 0x000754d9
8108 +#define MEMC_RDNCDLCOR_INIT 0x00000000
8109 +#define MEMC_RDNCDLCOR_SIMINIT 0xf6f6f6f6 /* For hdl sim */
8110 +#define MEMC_WRNCDLCOR_INIT 0x49351200
8111 +#define MEMC_1_WRNCDLCOR_INIT 0x14500200
8112 +#define MEMC_DQSGATENCDL_INIT 0x00030000
8113 +#define MEMC_MISCDLYCTL_INIT 0x21061c1b
8114 +#define MEMC_1_MISCDLYCTL_INIT 0x21021400
8115 +#define MEMC_NCDLCTL_INIT 0x00002001
8116 +#define MEMC_CONTROL_INIT0 0x00000002
8117 +#define MEMC_CONTROL_INIT1 0x00000008
8118 +#define MEMC_MODEBUF_INIT0 0x00004000
8119 +#define MEMC_CONTROL_INIT2 0x00000010
8120 +#define MEMC_MODEBUF_INIT1 0x00000100
8121 +#define MEMC_CONTROL_INIT3 0x00000010
8122 +#define MEMC_CONTROL_INIT4 0x00000008
8123 +#define MEMC_REFRESH_INIT 0x0000840f
8124 +#define MEMC_CONTROL_INIT5 0x00000004
8125 +#define MEMC_MODEBUF_INIT2 0x00000000
8126 +#define MEMC_CONTROL_INIT6 0x00000010
8127 +#define MEMC_CONTROL_INIT7 0x00000001
8130 +/* This is for DDRM16X16X2 */
8131 +#define MEMC_DDR_INIT 0x0009
8132 +#define MEMC_DDR_MODE 0x62
8133 +#define MEMC_DDR_NCDL 0x0005050a
8134 +#define MEMC_DDR1_NCDL 0x00000a0a /* For corerev 1 (4712) */
8136 +/* mask for sdr/ddr calibration registers */
8137 +#define MEMC_RDNCDLCOR_RD_MASK 0x000000ff
8138 +#define MEMC_WRNCDLCOR_WR_MASK 0x000000ff
8139 +#define MEMC_DQSGATENCDL_G_MASK 0x000000ff
8141 +/* masks for miscdlyctl registers */
8142 +#define MEMC_MISC_SM_MASK 0x30000000
8143 +#define MEMC_MISC_SM_SHIFT 28
8144 +#define MEMC_MISC_SD_MASK 0x0f000000
8145 +#define MEMC_MISC_SD_SHIFT 24
8147 +/* hw threshhold for calculating wr/rd for sdr memc */
8148 +#define MEMC_CD_THRESHOLD 128
8150 +/* Low bit of init register says if memc is ddr or sdr */
8151 +#define MEMC_CONFIG_DDR 0x00000001
8153 +#endif /* _SBMEMC_H */
8154 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbmips.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbmips.h
8155 --- linux-2.4.32/arch/mips/bcm947xx/include/sbmips.h 1970-01-01 01:00:00.000000000 +0100
8156 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbmips.h 2005-12-16 23:39:10.936836250 +0100
8159 + * Broadcom SiliconBackplane MIPS definitions
8161 + * SB MIPS cores are custom MIPS32 processors with SiliconBackplane
8162 + * OCP interfaces. The CP0 processor ID is 0x00024000, where bits
8163 + * 23:16 mean Broadcom and bits 15:8 mean a MIPS core with an OCP
8164 + * interface. The core revision is stored in the SB ID register in SB
8165 + * configuration space.
8167 + * Copyright 2005, Broadcom Corporation
8168 + * All Rights Reserved.
8170 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8171 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8172 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8173 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8181 +#include <mipsinc.h>
8183 +#ifndef _LANGUAGE_ASSEMBLY
8185 +/* cpp contortions to concatenate w/arg prescan */
8187 +#define _PADLINE(line) pad ## line
8188 +#define _XSTR(line) _PADLINE(line)
8189 +#define PAD _XSTR(__LINE__)
8192 +typedef volatile struct {
8193 + uint32 corecontrol;
8195 + uint32 biststatus;
8202 +extern uint32 sb_flag(sb_t *sbh);
8203 +extern uint sb_irq(sb_t *sbh);
8205 +extern void BCMINIT(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift));
8207 +extern void *sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap);
8208 +extern void sb_jtagm_disable(void *h);
8209 +extern uint32 jtag_rwreg(void *h, uint32 ir, uint32 dr);
8210 +extern void BCMINIT(sb_mips_init)(sb_t *sbh);
8211 +extern uint32 BCMINIT(sb_mips_clock)(sb_t *sbh);
8212 +extern bool BCMINIT(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock);
8213 +extern void BCMINIT(enable_pfc)(uint32 mode);
8214 +extern uint32 BCMINIT(sb_memc_get_ncdl)(sb_t *sbh);
8217 +#endif /* _LANGUAGE_ASSEMBLY */
8219 +#endif /* _SBMIPS_H */
8220 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbpcie.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbpcie.h
8221 --- linux-2.4.32/arch/mips/bcm947xx/include/sbpcie.h 1970-01-01 01:00:00.000000000 +0100
8222 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbpcie.h 2005-12-16 23:39:10.936836250 +0100
8225 + * BCM43XX SiliconBackplane PCIE core hardware definitions.
8228 + * Copyright 2005, Broadcom Corporation
8229 + * All Rights Reserved.
8231 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8232 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8233 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8234 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8240 +/* cpp contortions to concatenate w/arg prescan */
8242 +#define _PADLINE(line) pad ## line
8243 +#define _XSTR(line) _PADLINE(line)
8244 +#define PAD _XSTR(__LINE__)
8247 +/* PCIE Enumeration space offsets*/
8248 +#define PCIE_CORE_CONFIG_OFFSET 0x0
8249 +#define PCIE_FUNC0_CONFIG_OFFSET 0x400
8250 +#define PCIE_FUNC1_CONFIG_OFFSET 0x500
8251 +#define PCIE_FUNC2_CONFIG_OFFSET 0x600
8252 +#define PCIE_FUNC3_CONFIG_OFFSET 0x700
8253 +#define PCIE_SPROM_SHADOW_OFFSET 0x800
8254 +#define PCIE_SBCONFIG_OFFSET 0xE00
8256 +/* PCIE Bar0 Address Mapping. Each function maps 16KB config space */
8257 +#define PCIE_BAR0_WINMAPCORE_OFFSET 0x0
8258 +#define PCIE_BAR0_EXTSPROM_OFFSET 0x1000
8259 +#define PCIE_BAR0_PCIECORE_OFFSET 0x2000
8260 +#define PCIE_BAR0_CCCOREREG_OFFSET 0x3000
8262 +/* SB side: PCIE core and host control registers */
8263 +typedef struct sbpcieregs {
8266 + uint32 biststatus; /* bist Status: 0x00C*/
8268 + uint32 sbtopcimailbox; /* sb to pcie mailbox: 0x028*/
8270 + uint32 sbtopcie0; /* sb to pcie translation 0: 0x100 */
8271 + uint32 sbtopcie1; /* sb to pcie translation 1: 0x104 */
8272 + uint32 sbtopcie2; /* sb to pcie translation 2: 0x108 */
8275 + /* pcie core supports in direct access to config space */
8276 + uint32 configaddr; /* pcie config space access: Address field: 0x120*/
8277 + uint32 configdata; /* pcie config space access: Data field: 0x124*/
8279 + /* mdio access to serdes */
8280 + uint32 mdiocontrol; /* controls the mdio access: 0x128 */
8281 + uint32 mdiodata; /* Data to the mdio access: 0x12c */
8283 + /* pcie protocol phy/dllp/tlp register access mechanism*/
8284 + uint32 pcieaddr; /* address of the internal registeru: 0x130 */
8285 + uint32 pciedata; /* Data to/from the internal regsiter: 0x134 */
8288 + uint16 sprom[36]; /* SPROM shadow Area */
8291 +/* SB to PCIE translation masks */
8292 +#define SBTOPCIE0_MASK 0xfc000000
8293 +#define SBTOPCIE1_MASK 0xfc000000
8294 +#define SBTOPCIE2_MASK 0xc0000000
8296 +/* Access type bits (0:1)*/
8297 +#define SBTOPCIE_MEM 0
8298 +#define SBTOPCIE_IO 1
8299 +#define SBTOPCIE_CFG0 2
8300 +#define SBTOPCIE_CFG1 3
8302 +/*Prefetch enable bit 2*/
8303 +#define SBTOPCIE_PF 4
8305 +/*Write Burst enable for memory write bit 3*/
8306 +#define SBTOPCIE_WR_BURST 8
8308 +/* config access */
8309 +#define CONFIGADDR_FUNC_MASK 0x7000
8310 +#define CONFIGADDR_FUNC_SHF 12
8311 +#define CONFIGADDR_REG_MASK 0x0FFF
8312 +#define CONFIGADDR_REG_SHF 0
8314 +/* PCIE protocol regs Indirect Address */
8315 +#define PCIEADDR_PROT_MASK 0x300
8316 +#define PCIEADDR_PROT_SHF 8
8317 +#define PCIEADDR_PL_TLP 0
8318 +#define PCIEADDR_PL_DLLP 1
8319 +#define PCIEADDR_PL_PLP 2
8321 +/* PCIE protocol PHY diagnostic registers */
8322 +#define PCIE_PLP_MODEREG 0x200 /* Mode*/
8323 +#define PCIE_PLP_STATUSREG 0x204 /* Status*/
8324 +#define PCIE_PLP_LTSSMCTRLREG 0x208 /* LTSSM control */
8325 +#define PCIE_PLP_LTLINKNUMREG 0x20c /* Link Training Link number*/
8326 +#define PCIE_PLP_LTLANENUMREG 0x210 /* Link Training Lane number*/
8327 +#define PCIE_PLP_LTNFTSREG 0x214 /* Link Training N_FTS */
8328 +#define PCIE_PLP_ATTNREG 0x218 /* Attention */
8329 +#define PCIE_PLP_ATTNMASKREG 0x21C /* Attention Mask */
8330 +#define PCIE_PLP_RXERRCTR 0x220 /* Rx Error */
8331 +#define PCIE_PLP_RXFRMERRCTR 0x224 /* Rx Framing Error*/
8332 +#define PCIE_PLP_RXERRTHRESHREG 0x228 /* Rx Error threshold */
8333 +#define PCIE_PLP_TESTCTRLREG 0x22C /* Test Control reg*/
8334 +#define PCIE_PLP_SERDESCTRLOVRDREG 0x230 /* SERDES Control Override */
8335 +#define PCIE_PLP_TIMINGOVRDREG 0x234 /* Timing param override */
8336 +#define PCIE_PLP_RXTXSMDIAGREG 0x238 /* RXTX State Machine Diag*/
8337 +#define PCIE_PLP_LTSSMDIAGREG 0x23C /* LTSSM State Machine Diag*/
8339 +/* PCIE protocol DLLP diagnostic registers */
8340 +#define PCIE_DLLP_LCREG 0x100 /* Link Control*/
8341 +#define PCIE_DLLP_LSREG 0x104 /* Link Status */
8342 +#define PCIE_DLLP_LAREG 0x108 /* Link Attention*/
8343 +#define PCIE_DLLP_LAMASKREG 0x10C /* Link Attention Mask */
8344 +#define PCIE_DLLP_NEXTTXSEQNUMREG 0x110 /* Next Tx Seq Num*/
8345 +#define PCIE_DLLP_ACKEDTXSEQNUMREG 0x114 /* Acked Tx Seq Num*/
8346 +#define PCIE_DLLP_PURGEDTXSEQNUMREG 0x118 /* Purged Tx Seq Num*/
8347 +#define PCIE_DLLP_RXSEQNUMREG 0x11C /* Rx Sequence Number */
8348 +#define PCIE_DLLP_LRREG 0x120 /* Link Replay*/
8349 +#define PCIE_DLLP_LACKTOREG 0x124 /* Link Ack Timeout*/
8350 +#define PCIE_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold*/
8351 +#define PCIE_DLLP_RTRYWPREG 0x12C /* Retry buffer write ptr*/
8352 +#define PCIE_DLLP_RTRYRPREG 0x130 /* Retry buffer Read ptr*/
8353 +#define PCIE_DLLP_RTRYPPREG 0x134 /* Retry buffer Purged ptr*/
8354 +#define PCIE_DLLP_RTRRWREG 0x138 /* Retry buffer Read/Write*/
8355 +#define PCIE_DLLP_ECTHRESHREG 0x13C /* Error Count Threshold */
8356 +#define PCIE_DLLP_TLPERRCTRREG 0x140 /* TLP Error Counter */
8357 +#define PCIE_DLLP_ERRCTRREG 0x144 /* Error Counter*/
8358 +#define PCIE_DLLP_NAKRXCTRREG 0x148 /* NAK Received Counter*/
8359 +#define PCIE_DLLP_TESTREG 0x14C /* Test */
8360 +#define PCIE_DLLP_PKTBIST 0x150 /* Packet BIST*/
8362 +/* PCIE protocol TLP diagnostic registers */
8363 +#define PCIE_TLP_CONFIGREG 0x000 /* Configuration */
8364 +#define PCIE_TLP_WORKAROUNDSREG 0x004 /* TLP Workarounds */
8365 +#define PCIE_TLP_WRDMAUPPER 0x010 /* Write DMA Upper Address*/
8366 +#define PCIE_TLP_WRDMALOWER 0x014 /* Write DMA Lower Address*/
8367 +#define PCIE_TLP_WRDMAREQ_LBEREG 0x018 /* Write DMA Len/ByteEn Req*/
8368 +#define PCIE_TLP_RDDMAUPPER 0x01C /* Read DMA Upper Address*/
8369 +#define PCIE_TLP_RDDMALOWER 0x020 /* Read DMA Lower Address*/
8370 +#define PCIE_TLP_RDDMALENREG 0x024 /* Read DMA Len Req*/
8371 +#define PCIE_TLP_MSIDMAUPPER 0x028 /* MSI DMA Upper Address*/
8372 +#define PCIE_TLP_MSIDMALOWER 0x02C /* MSI DMA Lower Address*/
8373 +#define PCIE_TLP_MSIDMALENREG 0x030 /* MSI DMA Len Req*/
8374 +#define PCIE_TLP_SLVREQLENREG 0x034 /* Slave Request Len*/
8375 +#define PCIE_TLP_FCINPUTSREQ 0x038 /* Flow Control Inputs*/
8376 +#define PCIE_TLP_TXSMGRSREQ 0x03C /* Tx StateMachine and Gated Req*/
8377 +#define PCIE_TLP_ADRACKCNTARBLEN 0x040 /* Address Ack XferCnt and ARB Len*/
8378 +#define PCIE_TLP_DMACPLHDR0 0x044 /* DMA Completion Hdr 0*/
8379 +#define PCIE_TLP_DMACPLHDR1 0x048 /* DMA Completion Hdr 1*/
8380 +#define PCIE_TLP_DMACPLHDR2 0x04C /* DMA Completion Hdr 2*/
8381 +#define PCIE_TLP_DMACPLMISC0 0x050 /* DMA Completion Misc0 */
8382 +#define PCIE_TLP_DMACPLMISC1 0x054 /* DMA Completion Misc1 */
8383 +#define PCIE_TLP_DMACPLMISC2 0x058 /* DMA Completion Misc2 */
8384 +#define PCIE_TLP_SPTCTRLLEN 0x05C /* Split Controller Req len*/
8385 +#define PCIE_TLP_SPTCTRLMSIC0 0x060 /* Split Controller Misc 0*/
8386 +#define PCIE_TLP_SPTCTRLMSIC1 0x064 /* Split Controller Misc 1*/
8387 +#define PCIE_TLP_BUSDEVFUNC 0x068 /* Bus/Device/Func*/
8388 +#define PCIE_TLP_RESETCTR 0x06C /* Reset Counter*/
8389 +#define PCIE_TLP_RTRYBUF 0x070 /* Retry Buffer value*/
8390 +#define PCIE_TLP_TGTDEBUG1 0x074 /* Target Debug Reg1*/
8391 +#define PCIE_TLP_TGTDEBUG2 0x078 /* Target Debug Reg2*/
8392 +#define PCIE_TLP_TGTDEBUG3 0x07C /* Target Debug Reg3*/
8393 +#define PCIE_TLP_TGTDEBUG4 0x080 /* Target Debug Reg4*/
8396 +#define MDIOCTL_DIVISOR_MASK 0x7f /* clock to be used on MDIO */
8397 +#define MDIOCTL_DIVISOR_VAL 0x2
8398 +#define MDIOCTL_PREAM_EN 0x80 /* Enable preamble sequnce */
8399 +#define MDIOCTL_ACCESS_DONE 0x100 /* Tranaction complete */
8402 +#define MDIODATA_MASK 0x0000ffff /* data 2 bytes */
8403 +#define MDIODATA_TA 0x00020000 /* Turnaround */
8404 +#define MDIODATA_REGADDR_SHF 18 /* Regaddr shift */
8405 +#define MDIODATA_REGADDR_MASK 0x003c0000 /* Regaddr Mask */
8406 +#define MDIODATA_DEVADDR_SHF 22 /* Physmedia devaddr shift */
8407 +#define MDIODATA_DEVADDR_MASK 0x0fc00000 /* Physmedia devaddr Mask */
8408 +#define MDIODATA_WRITE 0x10000000 /* write Transaction */
8409 +#define MDIODATA_READ 0x20000000 /* Read Transaction */
8410 +#define MDIODATA_START 0x40000000 /* start of Transaction */
8412 +/* MDIO devices (SERDES modules) */
8413 +#define MDIODATA_DEV_PLL 0x1d /* SERDES PLL Dev */
8414 +#define MDIODATA_DEV_TX 0x1e /* SERDES TX Dev */
8415 +#define MDIODATA_DEV_RX 0x1f /* SERDES RX Dev */
8417 +/* SERDES registers */
8418 +#define SERDES_RX_TIMER1 2 /* Rx Timer1 */
8419 +#define SERDES_RX_CDR 6 /* CDR */
8420 +#define SERDES_RX_CDRBW 7 /* CDR BW */
8422 +#endif /* _SBPCIE_H */
8423 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbpci.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbpci.h
8424 --- linux-2.4.32/arch/mips/bcm947xx/include/sbpci.h 1970-01-01 01:00:00.000000000 +0100
8425 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbpci.h 2005-12-16 23:39:10.936836250 +0100
8428 + * BCM47XX Sonics SiliconBackplane PCI core hardware definitions.
8431 + * Copyright 2005, Broadcom Corporation
8432 + * All Rights Reserved.
8434 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8435 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8436 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8437 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8443 +/* cpp contortions to concatenate w/arg prescan */
8445 +#define _PADLINE(line) pad ## line
8446 +#define _XSTR(line) _PADLINE(line)
8447 +#define PAD _XSTR(__LINE__)
8450 +/* Sonics side: PCI core and host control registers */
8451 +typedef struct sbpciregs {
8452 + uint32 control; /* PCI control */
8454 + uint32 arbcontrol; /* PCI arbiter control */
8456 + uint32 intstatus; /* Interrupt status */
8457 + uint32 intmask; /* Interrupt mask */
8458 + uint32 sbtopcimailbox; /* Sonics to PCI mailbox */
8460 + uint32 bcastaddr; /* Sonics broadcast address */
8461 + uint32 bcastdata; /* Sonics broadcast data */
8463 + uint32 gpioin; /* ro: gpio input (>=rev2) */
8464 + uint32 gpioout; /* rw: gpio output (>=rev2) */
8465 + uint32 gpioouten; /* rw: gpio output enable (>= rev2) */
8466 + uint32 gpiocontrol; /* rw: gpio control (>= rev2) */
8468 + uint32 sbtopci0; /* Sonics to PCI translation 0 */
8469 + uint32 sbtopci1; /* Sonics to PCI translation 1 */
8470 + uint32 sbtopci2; /* Sonics to PCI translation 2 */
8472 + uint16 sprom[36]; /* SPROM shadow Area */
8477 +#define PCI_RST_OE 0x01 /* When set, drives PCI_RESET out to pin */
8478 +#define PCI_RST 0x02 /* Value driven out to pin */
8479 +#define PCI_CLK_OE 0x04 /* When set, drives clock as gated by PCI_CLK out to pin */
8480 +#define PCI_CLK 0x08 /* Gate for clock driven out to pin */
8482 +/* PCI arbiter control */
8483 +#define PCI_INT_ARB 0x01 /* When set, use an internal arbiter */
8484 +#define PCI_EXT_ARB 0x02 /* When set, use an external arbiter */
8485 +#define PCI_PARKID_MASK 0x06 /* Selects which agent is parked on an idle bus */
8486 +#define PCI_PARKID_SHIFT 1
8487 +#define PCI_PARKID_LAST 0 /* Last requestor */
8488 +#define PCI_PARKID_4710 1 /* 4710 */
8489 +#define PCI_PARKID_EXTREQ0 2 /* External requestor 0 */
8490 +#define PCI_PARKID_EXTREQ1 3 /* External requestor 1 */
8492 +/* Interrupt status/mask */
8493 +#define PCI_INTA 0x01 /* PCI INTA# is asserted */
8494 +#define PCI_INTB 0x02 /* PCI INTB# is asserted */
8495 +#define PCI_SERR 0x04 /* PCI SERR# has been asserted (write one to clear) */
8496 +#define PCI_PERR 0x08 /* PCI PERR# has been asserted (write one to clear) */
8497 +#define PCI_PME 0x10 /* PCI PME# is asserted */
8499 +/* (General) PCI/SB mailbox interrupts, two bits per pci function */
8500 +#define MAILBOX_F0_0 0x100 /* function 0, int 0 */
8501 +#define MAILBOX_F0_1 0x200 /* function 0, int 1 */
8502 +#define MAILBOX_F1_0 0x400 /* function 1, int 0 */
8503 +#define MAILBOX_F1_1 0x800 /* function 1, int 1 */
8504 +#define MAILBOX_F2_0 0x1000 /* function 2, int 0 */
8505 +#define MAILBOX_F2_1 0x2000 /* function 2, int 1 */
8506 +#define MAILBOX_F3_0 0x4000 /* function 3, int 0 */
8507 +#define MAILBOX_F3_1 0x8000 /* function 3, int 1 */
8509 +/* Sonics broadcast address */
8510 +#define BCAST_ADDR_MASK 0xff /* Broadcast register address */
8512 +/* Sonics to PCI translation types */
8513 +#define SBTOPCI0_MASK 0xfc000000
8514 +#define SBTOPCI1_MASK 0xfc000000
8515 +#define SBTOPCI2_MASK 0xc0000000
8516 +#define SBTOPCI_MEM 0
8517 +#define SBTOPCI_IO 1
8518 +#define SBTOPCI_CFG0 2
8519 +#define SBTOPCI_CFG1 3
8520 +#define SBTOPCI_PREF 0x4 /* prefetch enable */
8521 +#define SBTOPCI_BURST 0x8 /* burst enable */
8522 +#define SBTOPCI_RC_MASK 0x30 /* read command (>= rev11) */
8523 +#define SBTOPCI_RC_READ 0x00 /* memory read */
8524 +#define SBTOPCI_RC_READLINE 0x10 /* memory read line */
8525 +#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */
8527 +/* PCI core index in SROM shadow area */
8528 +#define SRSH_PI_OFFSET 0 /* first word */
8529 +#define SRSH_PI_MASK 0xf000 /* bit 15:12 */
8530 +#define SRSH_PI_SHIFT 12 /* bit 15:12 */
8532 +/* PCI side: Reserved PCI configuration registers (see pcicfg.h) */
8533 +#define cap_list rsvd_a[0]
8534 +#define bar0_window dev_dep[0x80 - 0x40]
8535 +#define bar1_window dev_dep[0x84 - 0x40]
8536 +#define sprom_control dev_dep[0x88 - 0x40]
8538 +#ifndef _LANGUAGE_ASSEMBLY
8540 +extern int sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
8541 +extern int sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
8542 +extern void sbpci_ban(uint16 core);
8543 +extern int sbpci_init(sb_t *sbh);
8544 +extern void sbpci_check(sb_t *sbh);
8546 +#endif /* !_LANGUAGE_ASSEMBLY */
8548 +#endif /* _SBPCI_H */
8549 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbpcmcia.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbpcmcia.h
8550 --- linux-2.4.32/arch/mips/bcm947xx/include/sbpcmcia.h 1970-01-01 01:00:00.000000000 +0100
8551 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbpcmcia.h 2005-12-16 23:39:10.936836250 +0100
8554 + * BCM43XX Sonics SiliconBackplane PCMCIA core hardware definitions.
8557 + * Copyright 2005, Broadcom Corporation
8558 + * All Rights Reserved.
8560 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8561 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8562 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8563 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8566 +#ifndef _SBPCMCIA_H
8567 +#define _SBPCMCIA_H
8570 +/* All the addresses that are offsets in attribute space are divided
8571 + * by two to account for the fact that odd bytes are invalid in
8572 + * attribute space and our read/write routines make the space appear
8573 + * as if they didn't exist. Still we want to show the original numbers
8574 + * as documented in the hnd_pcmcia core manual.
8577 +/* PCMCIA Function Configuration Registers */
8578 +#define PCMCIA_FCR (0x700 / 2)
8581 +#define FCR1_OFF (0x40 / 2)
8582 +#define FCR2_OFF (0x80 / 2)
8583 +#define FCR3_OFF (0xc0 / 2)
8585 +#define PCMCIA_FCR0 (0x700 / 2)
8586 +#define PCMCIA_FCR1 (0x740 / 2)
8587 +#define PCMCIA_FCR2 (0x780 / 2)
8588 +#define PCMCIA_FCR3 (0x7c0 / 2)
8590 +/* Standard PCMCIA FCR registers */
8592 +#define PCMCIA_COR 0
8594 +#define COR_RST 0x80
8595 +#define COR_LEV 0x40
8596 +#define COR_IRQEN 0x04
8597 +#define COR_BLREN 0x01
8598 +#define COR_FUNEN 0x01
8601 +#define PCICIA_FCSR (2 / 2)
8602 +#define PCICIA_PRR (4 / 2)
8603 +#define PCICIA_SCR (6 / 2)
8604 +#define PCICIA_ESR (8 / 2)
8607 +#define PCM_MEMOFF 0x0000
8608 +#define F0_MEMOFF 0x1000
8609 +#define F1_MEMOFF 0x2000
8610 +#define F2_MEMOFF 0x3000
8611 +#define F3_MEMOFF 0x4000
8613 +/* Memory base in the function fcr's */
8614 +#define MEM_ADDR0 (0x728 / 2)
8615 +#define MEM_ADDR1 (0x72a / 2)
8616 +#define MEM_ADDR2 (0x72c / 2)
8618 +/* PCMCIA base plus Srom access in fcr0: */
8619 +#define PCMCIA_ADDR0 (0x072e / 2)
8620 +#define PCMCIA_ADDR1 (0x0730 / 2)
8621 +#define PCMCIA_ADDR2 (0x0732 / 2)
8623 +#define MEM_SEG (0x0734 / 2)
8624 +#define SROM_CS (0x0736 / 2)
8625 +#define SROM_DATAL (0x0738 / 2)
8626 +#define SROM_DATAH (0x073a / 2)
8627 +#define SROM_ADDRL (0x073c / 2)
8628 +#define SROM_ADDRH (0x073e / 2)
8630 +/* Values for srom_cs: */
8631 +#define SROM_IDLE 0
8632 +#define SROM_WRITE 1
8633 +#define SROM_READ 2
8636 +#define SROM_DONE 8
8640 +/* The CIS stops where the FCRs start */
8641 +#define CIS_SIZE PCMCIA_FCR
8643 +/* Standard tuples we know about */
8645 +#define CISTPL_MANFID 0x20 /* Manufacturer and device id */
8646 +#define CISTPL_FUNCE 0x22 /* Function extensions */
8647 +#define CISTPL_CFTABLE 0x1b /* Config table entry */
8649 +/* Function extensions for LANs */
8651 +#define LAN_TECH 1 /* Technology type */
8652 +#define LAN_SPEED 2 /* Raw bit rate */
8653 +#define LAN_MEDIA 3 /* Transmission media */
8654 +#define LAN_NID 4 /* Node identification (aka MAC addr) */
8655 +#define LAN_CONN 5 /* Connector standard */
8659 +#define CFTABLE_REGWIN_2K 0x08 /* 2k reg windows size */
8660 +#define CFTABLE_REGWIN_4K 0x10 /* 4k reg windows size */
8661 +#define CFTABLE_REGWIN_8K 0x20 /* 8k reg windows size */
8663 +/* Vendor unique tuples are 0x80-0x8f. Within Broadcom we'll
8664 + * take one for HNBU, and use "extensions" (a la FUNCE) within it.
8667 +#define CISTPL_BRCM_HNBU 0x80
8669 +/* Subtypes of BRCM_HNBU: */
8671 +#define HNBU_SROMREV 0x00 /* A byte with sromrev, 1 if not present */
8672 +#define HNBU_CHIPID 0x01 /* Six bytes with PCI vendor &
8673 + * device id and chiprev
8675 +#define HNBU_BOARDREV 0x02 /* Two bytes board revision */
8676 +#define HNBU_PAPARMS 0x03 /* PA parameters: 1 (old), 8 (sreomrev == 1)
8677 + * or 9 (sromrev > 1) bytes */
8678 +#define HNBU_OEM 0x04 /* Eight bytes OEM data (sromrev == 1) */
8679 +#define HNBU_CC 0x05 /* Default country code (sromrev == 1) */
8680 +#define HNBU_AA 0x06 /* Antennas available */
8681 +#define HNBU_AG 0x07 /* Antenna gain */
8682 +#define HNBU_BOARDFLAGS 0x08 /* board flags (2 or 4 bytes) */
8683 +#define HNBU_LEDS 0x09 /* LED set */
8684 +#define HNBU_CCODE 0x0a /* Country code (2 bytes ascii + 1 byte cctl)
8687 +#define HNBU_CCKPO 0x0b /* 2 byte cck power offsets in rev 3 */
8688 +#define HNBU_OFDMPO 0x0c /* 4 byte 11g ofdm power offsets in rev 3 */
8692 +#define SBTML_INT_ACK 0x40000 /* ack the sb interrupt */
8693 +#define SBTML_INT_EN 0x20000 /* enable sb interrupt */
8695 +/* sbtmstatehigh */
8696 +#define SBTMH_INT_STATUS 0x40000 /* sb interrupt status */
8698 +#endif /* _SBPCMCIA_H */
8699 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbsdram.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbsdram.h
8700 --- linux-2.4.32/arch/mips/bcm947xx/include/sbsdram.h 1970-01-01 01:00:00.000000000 +0100
8701 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbsdram.h 2005-12-16 23:39:10.936836250 +0100
8704 + * BCM47XX Sonics SiliconBackplane SDRAM controller core hardware definitions.
8706 + * Copyright 2005, Broadcom Corporation
8707 + * All Rights Reserved.
8709 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8710 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8711 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8712 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8719 +#ifndef _LANGUAGE_ASSEMBLY
8721 +/* Sonics side: SDRAM core registers */
8722 +typedef volatile struct sbsdramregs {
8723 + uint32 initcontrol; /* Generates external SDRAM initialization sequence */
8724 + uint32 config; /* Initializes external SDRAM mode register */
8725 + uint32 refresh; /* Controls external SDRAM refresh rate */
8732 +/* SDRAM initialization control (initcontrol) register bits */
8733 +#define SDRAM_CBR 0x0001 /* Writing 1 generates refresh cycle and toggles bit */
8734 +#define SDRAM_PRE 0x0002 /* Writing 1 generates precharge cycle and toggles bit */
8735 +#define SDRAM_MRS 0x0004 /* Writing 1 generates mode register select cycle and toggles bit */
8736 +#define SDRAM_EN 0x0008 /* When set, enables access to SDRAM */
8737 +#define SDRAM_16Mb 0x0000 /* Use 16 Megabit SDRAM */
8738 +#define SDRAM_64Mb 0x0010 /* Use 64 Megabit SDRAM */
8739 +#define SDRAM_128Mb 0x0020 /* Use 128 Megabit SDRAM */
8740 +#define SDRAM_RSVMb 0x0030 /* Use special SDRAM */
8741 +#define SDRAM_RST 0x0080 /* Writing 1 causes soft reset of controller */
8742 +#define SDRAM_SELFREF 0x0100 /* Writing 1 enables self refresh mode */
8743 +#define SDRAM_PWRDOWN 0x0200 /* Writing 1 causes controller to power down */
8744 +#define SDRAM_32BIT 0x0400 /* When set, indicates 32 bit SDRAM interface */
8745 +#define SDRAM_9BITCOL 0x0800 /* When set, indicates 9 bit column */
8747 +/* SDRAM configuration (config) register bits */
8748 +#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
8749 +#define SDRAM_BURST8 0x0001 /* Use burst of 8 */
8750 +#define SDRAM_BURST4 0x0002 /* Use burst of 4 */
8751 +#define SDRAM_BURST2 0x0003 /* Use burst of 2 */
8752 +#define SDRAM_CAS3 0x0000 /* Use CAS latency of 3 */
8753 +#define SDRAM_CAS2 0x0004 /* Use CAS latency of 2 */
8755 +/* SDRAM refresh control (refresh) register bits */
8756 +#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
8757 +#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
8759 +/* SDRAM Core default Init values (OCP ID 0x803) */
8760 +#define SDRAM_INIT MEM4MX16X2
8761 +#define SDRAM_CONFIG SDRAM_BURSTFULL
8762 +#define SDRAM_REFRESH SDRAM_REF(0x40)
8764 +#define MEM1MX16 0x009 /* 2 MB */
8765 +#define MEM1MX16X2 0x409 /* 4 MB */
8766 +#define MEM2MX8X2 0x809 /* 4 MB */
8767 +#define MEM2MX8X4 0xc09 /* 8 MB */
8768 +#define MEM2MX32 0x439 /* 8 MB */
8769 +#define MEM4MX16 0x019 /* 8 MB */
8770 +#define MEM4MX16X2 0x419 /* 16 MB */
8771 +#define MEM8MX8X2 0x819 /* 16 MB */
8772 +#define MEM8MX16 0x829 /* 16 MB */
8773 +#define MEM4MX32 0x429 /* 16 MB */
8774 +#define MEM8MX8X4 0xc19 /* 32 MB */
8775 +#define MEM8MX16X2 0xc29 /* 32 MB */
8777 +#endif /* _SBSDRAM_H */
8778 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbsocram.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbsocram.h
8779 --- linux-2.4.32/arch/mips/bcm947xx/include/sbsocram.h 1970-01-01 01:00:00.000000000 +0100
8780 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbsocram.h 2005-12-16 23:39:10.936836250 +0100
8783 + * BCM47XX Sonics SiliconBackplane embedded ram core
8785 + * Copyright 2005, Broadcom Corporation
8786 + * All Rights Reserved.
8788 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8789 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8790 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8791 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8796 +#ifndef _SBSOCRAM_H
8797 +#define _SBSOCRAM_H
8799 +#define SOCRAM_MEMSIZE 0x00
8800 +#define SOCRAM_BISTSTAT 0x0c
8803 +#ifndef _LANGUAGE_ASSEMBLY
8805 +/* Memcsocram core registers */
8806 +typedef volatile struct sbsocramregs {
8813 +/* Them memory size is 2 to the power of the following
8814 + * base added to the contents of the memsize register.
8816 +#define SOCRAM_MEMSIZE_BASESHIFT 16
8818 +#endif /* _SBSOCRAM_H */
8819 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbutils.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbutils.h
8820 --- linux-2.4.32/arch/mips/bcm947xx/include/sbutils.h 1970-01-01 01:00:00.000000000 +0100
8821 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sbutils.h 2005-12-16 23:39:10.936836250 +0100
8824 + * Misc utility routines for accessing chip-specific features
8825 + * of Broadcom HNBU SiliconBackplane-based chips.
8827 + * Copyright 2005, Broadcom Corporation
8828 + * All Rights Reserved.
8830 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8831 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8832 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8833 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8838 +#ifndef _sbutils_h_
8839 +#define _sbutils_h_
8842 + * Datastructure to export all chip specific common variables
8843 + * public (read-only) portion of sbutils handle returned by
8844 + * sb_attach()/sb_kattach()
8849 + uint bustype; /* SB_BUS, PCI_BUS */
8850 + uint buscoretype; /* SB_PCI, SB_PCMCIA, SB_PCIE*/
8851 + uint buscorerev; /* buscore rev */
8852 + uint buscoreidx; /* buscore index */
8853 + int ccrev; /* chip common core rev */
8854 + uint boardtype; /* board type */
8855 + uint boardvendor; /* board vendor */
8856 + uint chip; /* chip number */
8857 + uint chiprev; /* chip revision */
8858 + uint chippkg; /* chip package option */
8859 + uint sonicsrev; /* sonics backplane rev */
8862 +typedef const struct sb_pub sb_t;
8865 + * Many of the routines below take an 'sbh' handle as their first arg.
8866 + * Allocate this by calling sb_attach(). Free it by calling sb_detach().
8867 + * At any one time, the sbh is logically focused on one particular sb core
8868 + * (the "current core").
8869 + * Use sb_setcore() or sb_setcoreidx() to change the association to another core.
8872 +/* exported externs */
8873 +extern sb_t * BCMINIT(sb_attach)(uint pcidev, osl_t *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz);
8874 +extern sb_t * BCMINIT(sb_kattach)(void);
8875 +extern void sb_detach(sb_t *sbh);
8876 +extern uint BCMINIT(sb_chip)(sb_t *sbh);
8877 +extern uint BCMINIT(sb_chiprev)(sb_t *sbh);
8878 +extern uint BCMINIT(sb_chipcrev)(sb_t *sbh);
8879 +extern uint BCMINIT(sb_chippkg)(sb_t *sbh);
8880 +extern uint BCMINIT(sb_pcirev)(sb_t *sbh);
8881 +extern bool BCMINIT(sb_war16165)(sb_t *sbh);
8882 +extern uint BCMINIT(sb_pcmciarev)(sb_t *sbh);
8883 +extern uint BCMINIT(sb_boardvendor)(sb_t *sbh);
8884 +extern uint BCMINIT(sb_boardtype)(sb_t *sbh);
8885 +extern uint sb_bus(sb_t *sbh);
8886 +extern uint sb_buscoretype(sb_t *sbh);
8887 +extern uint sb_buscorerev(sb_t *sbh);
8888 +extern uint sb_corelist(sb_t *sbh, uint coreid[]);
8889 +extern uint sb_coreid(sb_t *sbh);
8890 +extern uint sb_coreidx(sb_t *sbh);
8891 +extern uint sb_coreunit(sb_t *sbh);
8892 +extern uint sb_corevendor(sb_t *sbh);
8893 +extern uint sb_corerev(sb_t *sbh);
8894 +extern void *sb_osh(sb_t *sbh);
8895 +extern void *sb_coreregs(sb_t *sbh);
8896 +extern uint32 sb_coreflags(sb_t *sbh, uint32 mask, uint32 val);
8897 +extern uint32 sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val);
8898 +extern bool sb_iscoreup(sb_t *sbh);
8899 +extern void *sb_setcoreidx(sb_t *sbh, uint coreidx);
8900 +extern void *sb_setcore(sb_t *sbh, uint coreid, uint coreunit);
8901 +extern int sb_corebist(sb_t *sbh, uint coreid, uint coreunit);
8902 +extern void sb_commit(sb_t *sbh);
8903 +extern uint32 sb_base(uint32 admatch);
8904 +extern uint32 sb_size(uint32 admatch);
8905 +extern void sb_core_reset(sb_t *sbh, uint32 bits);
8906 +extern void sb_core_tofixup(sb_t *sbh);
8907 +extern void sb_core_disable(sb_t *sbh, uint32 bits);
8908 +extern uint32 sb_clock_rate(uint32 pll_type, uint32 n, uint32 m);
8909 +extern uint32 sb_clock(sb_t *sbh);
8910 +extern void sb_pci_setup(sb_t *sbh, uint coremask);
8911 +extern void sb_pcmcia_init(sb_t *sbh);
8912 +extern void sb_watchdog(sb_t *sbh, uint ticks);
8913 +extern void *sb_gpiosetcore(sb_t *sbh);
8914 +extern uint32 sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8915 +extern uint32 sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8916 +extern uint32 sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8917 +extern uint32 sb_gpioin(sb_t *sbh);
8918 +extern uint32 sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8919 +extern uint32 sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
8920 +extern uint32 sb_gpioled(sb_t *sbh, uint32 mask, uint32 val);
8921 +extern uint32 sb_gpioreserve(sb_t *sbh, uint32 gpio_num, uint8 priority);
8922 +extern uint32 sb_gpiorelease(sb_t *sbh, uint32 gpio_num, uint8 priority);
8924 +extern void sb_clkctl_init(sb_t *sbh);
8925 +extern uint16 sb_clkctl_fast_pwrup_delay(sb_t *sbh);
8926 +extern bool sb_clkctl_clk(sb_t *sbh, uint mode);
8927 +extern int sb_clkctl_xtal(sb_t *sbh, uint what, bool on);
8928 +extern void sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn,
8929 + void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg);
8930 +extern uint32 sb_set_initiator_to(sb_t *sbh, uint32 to);
8931 +extern void sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
8932 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif);
8933 +extern uint sb_pcie_readreg(void *sbh, void* arg1, uint offset);
8934 +extern uint sb_pcie_writereg(sb_t *sbh, void *arg1, uint offset, uint val);
8935 +extern uint32 sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 val);
8940 +* Build device path. Path size must be >= SB_DEVPATH_BUFSZ.
8941 +* The returned path is NULL terminated and has trailing '/'.
8942 +* Return 0 on success, nonzero otherwise.
8944 +extern int sb_devpath(sb_t *sbh, char *path, int size);
8946 +/* clkctl xtal what flags */
8947 +#define XTAL 0x1 /* primary crystal oscillator (2050) */
8948 +#define PLL 0x2 /* main chip pll */
8950 +/* clkctl clk mode */
8951 +#define CLK_FAST 0 /* force fast (pll) clock */
8952 +#define CLK_DYNAMIC 2 /* enable dynamic clock control */
8955 +/* GPIO usage priorities */
8956 +#define GPIO_DRV_PRIORITY 0
8957 +#define GPIO_APP_PRIORITY 1
8960 +#define SB_DEVPATH_BUFSZ 16 /* min buffer size in bytes */
8962 +#endif /* _sbutils_h_ */
8963 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sflash.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/sflash.h
8964 --- linux-2.4.32/arch/mips/bcm947xx/include/sflash.h 1970-01-01 01:00:00.000000000 +0100
8965 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/sflash.h 2005-12-16 23:39:10.936836250 +0100
8968 + * Broadcom SiliconBackplane chipcommon serial flash interface
8970 + * Copyright 2005, Broadcom Corporation
8971 + * All Rights Reserved.
8973 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8974 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8975 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8976 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8984 +#include <typedefs.h>
8985 +#include <sbchipc.h>
8988 + uint blocksize; /* Block size */
8989 + uint numblocks; /* Number of blocks */
8990 + uint32 type; /* Type */
8991 + uint size; /* Total size in bytes */
8994 +/* Utility functions */
8995 +extern int sflash_poll(chipcregs_t *cc, uint offset);
8996 +extern int sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf);
8997 +extern int sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
8998 +extern int sflash_erase(chipcregs_t *cc, uint offset);
8999 +extern int sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
9000 +extern struct sflash * sflash_init(chipcregs_t *cc);
9002 +#endif /* _sflash_h_ */
9003 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/trxhdr.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/trxhdr.h
9004 --- linux-2.4.32/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +0100
9005 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/trxhdr.h 2005-12-16 23:39:10.940836500 +0100
9008 + * TRX image file header format.
9010 + * Copyright 2005, Broadcom Corporation
9011 + * All Rights Reserved.
9013 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9014 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9015 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9016 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9021 +#include <typedefs.h>
9023 +#define TRX_MAGIC 0x30524448 /* "HDR0" */
9024 +#define TRX_VERSION 1
9025 +#define TRX_MAX_LEN 0x3A0000
9026 +#define TRX_NO_HEADER 1 /* Do not write TRX header */
9027 +#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
9028 +#define TRX_MAX_OFFSET 3
9030 +struct trx_header {
9031 + uint32 magic; /* "HDR0" */
9032 + uint32 len; /* Length of file including header */
9033 + uint32 crc32; /* 32-bit CRC from flag_version to end of file */
9034 + uint32 flag_version; /* 0:15 flags, 16:31 version */
9035 + uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
9038 +/* Compatibility */
9039 +typedef struct trx_header TRXHDR, *PTRXHDR;
9040 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/typedefs.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/typedefs.h
9041 --- linux-2.4.32/arch/mips/bcm947xx/include/typedefs.h 1970-01-01 01:00:00.000000000 +0100
9042 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/typedefs.h 2005-12-16 23:39:10.940836500 +0100
9045 + * Copyright 2005, Broadcom Corporation
9046 + * All Rights Reserved.
9048 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9049 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9050 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9051 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9055 +#ifndef _TYPEDEFS_H_
9056 +#define _TYPEDEFS_H_
9059 +/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
9060 + * typedef file "site_typedefs.h".
9062 + * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
9063 + * section of this file makes inferences about the compile environment
9064 + * based on defined symbols and possibly compiler pragmas.
9066 + * Following these two sections is the "Default Typedefs"
9067 + * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
9068 + * defined. This section has a default set of typedefs and a few
9069 + * proprocessor symbols (TRUE, FALSE, NULL, ...).
9072 +#ifdef SITE_TYPEDEFS
9074 +/*******************************************************************************
9075 + * Site Specific Typedefs
9076 + *******************************************************************************/
9078 +#include "site_typedefs.h"
9082 +/*******************************************************************************
9083 + * Inferred Typedefs
9084 + *******************************************************************************/
9086 +/* Infer the compile environment based on preprocessor symbols and pramas.
9087 + * Override type definitions as needed, and include configuration dependent
9088 + * header files to define types.
9093 +#define TYPEDEF_BOOL
9095 +#define FALSE false
9101 +#else /* ! __cplusplus */
9103 +#if defined(_WIN32)
9105 +#define TYPEDEF_BOOL
9106 +typedef unsigned char bool; /* consistent w/BOOL */
9108 +#endif /* _WIN32 */
9110 +#endif /* ! __cplusplus */
9112 +/* use the Windows ULONG_PTR type when compiling for 64 bit */
9113 +#if defined(_WIN64)
9114 +#include <basetsd.h>
9115 +#define TYPEDEF_UINTPTR
9116 +typedef ULONG_PTR uintptr;
9120 +typedef long unsigned int size_t;
9123 +#ifdef _MSC_VER /* Microsoft C */
9124 +#define TYPEDEF_INT64
9125 +#define TYPEDEF_UINT64
9126 +typedef signed __int64 int64;
9127 +typedef unsigned __int64 uint64;
9130 +#if defined(MACOSX) && defined(KERNEL)
9131 +#define TYPEDEF_BOOL
9136 +#define TYPEDEF_UINT
9137 +#define TYPEDEF_USHORT
9138 +#define TYPEDEF_ULONG
9141 +#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
9142 +#define TYPEDEF_UINT
9143 +#define TYPEDEF_USHORT
9147 +/* Do not support the (u)int64 types with strict ansi for GNU C */
9148 +#if defined(__GNUC__) && defined(__STRICT_ANSI__)
9149 +#define TYPEDEF_INT64
9150 +#define TYPEDEF_UINT64
9153 +/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
9154 + * for singned or unsigned */
9157 +#define TYPEDEF_INT64
9159 +#if defined(__STDC__)
9160 +#define TYPEDEF_UINT64
9166 +#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
9168 +/* pick up ushort & uint from standard types.h */
9169 +#if defined(linux) && defined(__KERNEL__)
9171 +#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
9175 +#include <sys/types.h>
9179 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */
9181 +#if defined(MACOSX) && defined(KERNEL)
9182 +#include <IOKit/IOTypes.h>
9186 +/* use the default typedefs in the next section of this file */
9187 +#define USE_TYPEDEF_DEFAULTS
9189 +#endif /* SITE_TYPEDEFS */
9192 +/*******************************************************************************
9193 + * Default Typedefs
9194 + *******************************************************************************/
9196 +#ifdef USE_TYPEDEF_DEFAULTS
9197 +#undef USE_TYPEDEF_DEFAULTS
9199 +#ifndef TYPEDEF_BOOL
9200 +typedef /*@abstract@*/ unsigned char bool;
9203 +/*----------------------- define uchar, ushort, uint, ulong ------------------*/
9205 +#ifndef TYPEDEF_UCHAR
9206 +typedef unsigned char uchar;
9209 +#ifndef TYPEDEF_USHORT
9210 +typedef unsigned short ushort;
9213 +#ifndef TYPEDEF_UINT
9214 +typedef unsigned int uint;
9217 +#ifndef TYPEDEF_ULONG
9218 +typedef unsigned long ulong;
9221 +/*----------------------- define [u]int8/16/32/64, uintptr --------------------*/
9223 +#ifndef TYPEDEF_UINT8
9224 +typedef unsigned char uint8;
9227 +#ifndef TYPEDEF_UINT16
9228 +typedef unsigned short uint16;
9231 +#ifndef TYPEDEF_UINT32
9232 +typedef unsigned int uint32;
9235 +#ifndef TYPEDEF_UINT64
9236 +typedef unsigned long long uint64;
9239 +#ifndef TYPEDEF_UINTPTR
9240 +typedef unsigned int uintptr;
9243 +#ifndef TYPEDEF_INT8
9244 +typedef signed char int8;
9247 +#ifndef TYPEDEF_INT16
9248 +typedef signed short int16;
9251 +#ifndef TYPEDEF_INT32
9252 +typedef signed int int32;
9255 +#ifndef TYPEDEF_INT64
9256 +typedef signed long long int64;
9259 +/*----------------------- define float32/64, float_t -----------------------*/
9261 +#ifndef TYPEDEF_FLOAT32
9262 +typedef float float32;
9265 +#ifndef TYPEDEF_FLOAT64
9266 +typedef double float64;
9270 + * abstracted floating point type allows for compile time selection of
9271 + * single or double precision arithmetic. Compiling with -DFLOAT32
9272 + * selects single precision; the default is double precision.
9275 +#ifndef TYPEDEF_FLOAT_T
9277 +#if defined(FLOAT32)
9278 +typedef float32 float_t;
9279 +#else /* default to double precision floating point */
9280 +typedef float64 float_t;
9283 +#endif /* TYPEDEF_FLOAT_T */
9285 +/*----------------------- define macro values -----------------------------*/
9309 +/* Reclaiming text and data :
9310 + The following macros specify special linker sections that can be reclaimed
9311 + after a system is considered 'up'.
9313 +#if defined(__GNUC__) && defined(BCMRECLAIM)
9314 +extern bool bcmreclaimed;
9315 +#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data##_ini
9316 +#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn##_ini
9317 +#define BCMINIT(_id) _id##_ini
9319 +#define BCMINITDATA(_data) _data
9320 +#define BCMINITFN(_fn) _fn
9321 +#define BCMINIT(_id) _id
9322 +#define bcmreclaimed 0
9325 +/*----------------------- define PTRSZ, INLINE ----------------------------*/
9328 +#define PTRSZ sizeof (char*)
9335 +#define INLINE __inline
9339 +#define INLINE __inline__
9345 +#endif /* _MSC_VER */
9347 +#endif /* INLINE */
9349 +#undef TYPEDEF_BOOL
9350 +#undef TYPEDEF_UCHAR
9351 +#undef TYPEDEF_USHORT
9352 +#undef TYPEDEF_UINT
9353 +#undef TYPEDEF_ULONG
9354 +#undef TYPEDEF_UINT8
9355 +#undef TYPEDEF_UINT16
9356 +#undef TYPEDEF_UINT32
9357 +#undef TYPEDEF_UINT64
9358 +#undef TYPEDEF_UINTPTR
9359 +#undef TYPEDEF_INT8
9360 +#undef TYPEDEF_INT16
9361 +#undef TYPEDEF_INT32
9362 +#undef TYPEDEF_INT64
9363 +#undef TYPEDEF_FLOAT32
9364 +#undef TYPEDEF_FLOAT64
9365 +#undef TYPEDEF_FLOAT_T
9367 +#endif /* USE_TYPEDEF_DEFAULTS */
9369 +#endif /* _TYPEDEFS_H_ */
9370 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/wlioctl.h linux-2.4.32-brcm/arch/mips/bcm947xx/include/wlioctl.h
9371 --- linux-2.4.32/arch/mips/bcm947xx/include/wlioctl.h 1970-01-01 01:00:00.000000000 +0100
9372 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/include/wlioctl.h 2005-12-16 23:39:10.940836500 +0100
9375 + * Custom OID/ioctl definitions for
9376 + * Broadcom 802.11abg Networking Device Driver
9378 + * Definitions subject to change without notice.
9380 + * Copyright 2005, Broadcom Corporation
9381 + * All Rights Reserved.
9383 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9384 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9385 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9386 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9391 +#ifndef _wlioctl_h_
9392 +#define _wlioctl_h_
9394 +#include <typedefs.h>
9395 +#include <proto/ethernet.h>
9396 +#include <proto/bcmeth.h>
9397 +#include <proto/bcmevent.h>
9398 +#include <proto/802.11.h>
9400 +/* require default structure packing */
9401 +#if !defined(__GNUC__)
9402 +#pragma pack(push,8)
9405 +#define WL_NUMRATES 255 /* max # of rates in a rateset */
9407 +typedef struct wl_rateset {
9408 + uint32 count; /* # rates in this set */
9409 + uint8 rates[WL_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */
9412 +#define WL_CHANSPEC_CHAN_MASK 0x0fff
9413 +#define WL_CHANSPEC_BAND_MASK 0xf000
9414 +#define WL_CHANSPEC_BAND_SHIFT 12
9415 +#define WL_CHANSPEC_BAND_A 0x1000
9416 +#define WL_CHANSPEC_BAND_B 0x2000
9419 + * Per-bss information structure.
9422 +#define WL_BSS_INFO_VERSION 107 /* current version of wl_bss_info struct */
9424 +typedef struct wl_bss_info {
9425 + uint32 version; /* version field */
9426 + uint32 length; /* byte length of data in this record, starting at version and including IEs */
9427 + struct ether_addr BSSID;
9428 + uint16 beacon_period; /* units are Kusec */
9429 + uint16 capability; /* Capability information */
9433 + uint count; /* # rates in this set */
9434 + uint8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */
9435 + } rateset; /* supported rates */
9436 + uint8 channel; /* Channel no. */
9437 + uint16 atim_window; /* units are Kusec */
9438 + uint8 dtim_period; /* DTIM period */
9439 + int16 RSSI; /* receive signal strength (in dBm) */
9440 + int8 phy_noise; /* noise (in dBm) */
9441 + uint32 ie_length; /* byte length of Information Elements */
9442 + /* variable length Information Elements */
9445 +typedef struct wlc_ssid {
9450 +typedef struct wl_scan_params {
9451 + wlc_ssid_t ssid; /* default is {0, ""} */
9452 + struct ether_addr bssid;/* default is bcast */
9453 + int8 bss_type; /* default is any, DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT */
9454 + int8 scan_type; /* -1 use default, DOT11_SCANTYPE_ACTIVE/PASSIVE */
9455 + int32 nprobes; /* -1 use default, number of probes per channel */
9456 + int32 active_time; /* -1 use default, dwell time per channel for active scanning */
9457 + int32 passive_time; /* -1 use default, dwell time per channel for passive scanning */
9458 + int32 home_time; /* -1 use default, dwell time for the home channel between channel scans */
9459 + int32 channel_num; /* 0 use default (all available channels), count of channels in channel_list */
9460 + uint16 channel_list[1]; /* list of chanspecs */
9461 +} wl_scan_params_t;
9462 +/* size of wl_scan_params not including variable length array */
9463 +#define WL_SCAN_PARAMS_FIXED_SIZE 64
9465 +typedef struct wl_scan_results {
9469 + wl_bss_info_t bss_info[1];
9470 +} wl_scan_results_t;
9471 +/* size of wl_scan_results not including variable length array */
9472 +#define WL_SCAN_RESULTS_FIXED_SIZE 12
9475 +typedef struct wl_uint32_list {
9476 + /* in - # of elements, out - # of entries */
9478 + /* variable length uint32 list */
9479 + uint32 element[1];
9480 +} wl_uint32_list_t;
9482 +#define WLC_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NULL */
9484 +typedef struct wl_channels_in_country {
9487 + char country_abbrev[WLC_CNTRY_BUF_SZ];
9489 + uint32 channel[1];
9490 +} wl_channels_in_country_t;
9492 +typedef struct wl_country_list {
9497 + char country_abbrev[1];
9498 +} wl_country_list_t;
9500 +#define WL_RM_TYPE_BASIC 1
9501 +#define WL_RM_TYPE_CCA 2
9502 +#define WL_RM_TYPE_RPI 3
9504 +#define WL_RM_FLAG_PARALLEL (1<<0)
9506 +#define WL_RM_FLAG_LATE (1<<1)
9507 +#define WL_RM_FLAG_INCAPABLE (1<<2)
9508 +#define WL_RM_FLAG_REFUSED (1<<3)
9510 +typedef struct wl_rm_req_elt {
9514 + uint32 token; /* token for this measurement */
9515 + uint32 tsf_h; /* TSF high 32-bits of Measurement start time */
9516 + uint32 tsf_l; /* TSF low 32-bits */
9517 + uint32 dur; /* TUs */
9520 +typedef struct wl_rm_req {
9521 + uint32 token; /* overall measurement set token */
9522 + uint32 count; /* number of measurement reqests */
9523 + wl_rm_req_elt_t req[1]; /* variable length block of requests */
9525 +#define WL_RM_REQ_FIXED_LEN 8
9527 +typedef struct wl_rm_rep_elt {
9531 + uint32 token; /* token for this measurement */
9532 + uint32 tsf_h; /* TSF high 32-bits of Measurement start time */
9533 + uint32 tsf_l; /* TSF low 32-bits */
9534 + uint32 dur; /* TUs */
9535 + uint32 len; /* byte length of data block */
9536 + uint8 data[1]; /* variable length data block */
9538 +#define WL_RM_REP_ELT_FIXED_LEN 24 /* length excluding data block */
9540 +#define WL_RPI_REP_BIN_NUM 8
9541 +typedef struct wl_rm_rpi_rep {
9542 + uint8 rpi[WL_RPI_REP_BIN_NUM];
9543 + int8 rpi_max[WL_RPI_REP_BIN_NUM];
9546 +typedef struct wl_rm_rep {
9547 + uint32 token; /* overall measurement set token */
9548 + uint32 len; /* length of measurement report block */
9549 + wl_rm_rep_elt_t rep[1]; /* variable length block of reports */
9551 +#define WL_RM_REP_FIXED_LEN 8
9554 +#if defined(BCMSUP_PSK)
9555 +typedef enum sup_auth_status {
9556 + WLC_SUP_DISCONNECTED = 0,
9557 + WLC_SUP_CONNECTING,
9558 + WLC_SUP_IDREQUIRED,
9559 + WLC_SUP_AUTHENTICATING,
9560 + WLC_SUP_AUTHENTICATED,
9561 + WLC_SUP_KEYXCHANGE,
9564 +} sup_auth_status_t;
9565 +#endif /* BCMCCX | BCMSUP_PSK */
9567 +/* Enumerate crypto algorithms */
9568 +#define CRYPTO_ALGO_OFF 0
9569 +#define CRYPTO_ALGO_WEP1 1
9570 +#define CRYPTO_ALGO_TKIP 2
9571 +#define CRYPTO_ALGO_WEP128 3
9572 +#define CRYPTO_ALGO_AES_CCM 4
9573 +#define CRYPTO_ALGO_AES_OCB_MSDU 5
9574 +#define CRYPTO_ALGO_AES_OCB_MPDU 6
9575 +#define CRYPTO_ALGO_NALG 7
9577 +#define WSEC_GEN_MIC_ERROR 0x0001
9578 +#define WSEC_GEN_REPLAY 0x0002
9580 +#define WL_SOFT_KEY (1 << 0) /* Indicates this key is using soft encrypt */
9581 +#define WL_PRIMARY_KEY (1 << 1) /* Indicates this key is the primary (ie tx) key */
9582 +#define WL_KF_RES_4 (1 << 4) /* Reserved for backward compat */
9583 +#define WL_KF_RES_5 (1 << 5) /* Reserved for backward compat */
9585 +typedef struct wl_wsec_key {
9586 + uint32 index; /* key index */
9587 + uint32 len; /* key length */
9588 + uint8 data[DOT11_MAX_KEY_SIZE]; /* key data */
9590 + uint32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
9591 + uint32 flags; /* misc flags */
9594 + int iv_initialized; /* has IV been initialized already? */
9598 + uint32 hi; /* upper 32 bits of IV */
9599 + uint16 lo; /* lower 16 bits of IV */
9602 + struct ether_addr ea; /* per station */
9606 +#define WSEC_MIN_PSK_LEN 8
9607 +#define WSEC_MAX_PSK_LEN 64
9609 +/* Flag for key material needing passhash'ing */
9610 +#define WSEC_PASSPHRASE (1<<0)
9612 +/* recepticle for WLC_SET_WSEC_PMK parameter */
9614 + ushort key_len; /* octets in key material */
9615 + ushort flags; /* key handling qualification */
9616 + uint8 key[WSEC_MAX_PSK_LEN]; /* PMK material */
9619 +/* wireless security bitvec */
9620 +#define WEP_ENABLED 0x0001
9621 +#define TKIP_ENABLED 0x0002
9622 +#define AES_ENABLED 0x0004
9623 +#define WSEC_SWFLAG 0x0008
9624 +#define SES_OW_ENABLED 0x0040 /* to go into transition mode without setting wep */
9626 +/* WPA authentication mode bitvec */
9627 +#define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */
9628 +#define WPA_AUTH_NONE 0x0001 /* none (IBSS) */
9629 +#define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */
9630 +#define WPA_AUTH_PSK 0x0004 /* Pre-shared key */
9631 +/*#define WPA_AUTH_8021X 0x0020*/ /* 802.1x, reserved */
9633 +#define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
9634 +#define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
9639 +#define MAXPMKID 16
9641 +typedef struct _pmkid
9643 + struct ether_addr BSSID;
9644 + uint8 PMKID[WPA2_PMKID_LEN];
9647 +typedef struct _pmkid_list
9653 +typedef struct _pmkid_cand {
9654 + struct ether_addr BSSID;
9658 +typedef struct _pmkid_cand_list {
9659 + uint32 npmkid_cand;
9660 + pmkid_cand_t pmkid_cand[1];
9661 +} pmkid_cand_list_t;
9664 +typedef struct wl_led_info {
9665 + uint32 index; /* led index */
9670 +typedef struct wlc_assoc_info {
9674 + struct dot11_assoc_req req;
9675 + struct ether_addr reassoc_bssid; /* used in reassoc's */
9676 + struct dot11_assoc_resp resp;
9679 +#define WLC_ASSOC_REQ_IS_REASSOC 0x01 /* assoc req was actually a reassoc */
9680 +/* srom read/write struct passed through ioctl */
9682 + uint byteoff; /* byte offset */
9683 + uint nbytes; /* number of bytes */
9687 +/* R_REG and W_REG struct passed through ioctl */
9689 + uint32 byteoff; /* byte offset of the field in d11regs_t */
9690 + uint32 val; /* read/write value of the field */
9691 + uint32 size; /* sizeof the field */
9692 + uint band; /* band (optional) */
9695 +/* Structure used by GET/SET_ATTEN ioctls */
9697 + uint16 auto_ctrl; /* 1: Automatic control, 0: overriden */
9698 + uint16 bb; /* Baseband attenuation */
9699 + uint16 radio; /* Radio attenuation */
9700 + uint16 txctl1; /* Radio TX_CTL1 value */
9703 +/* Used to get specific STA parameters */
9706 + struct ether_addr ea;
9710 +/* Event data type */
9711 +typedef struct wlc_event {
9712 + wl_event_msg_t event; /* encapsulated event */
9713 + struct ether_addr *addr; /* used to keep a trace of the potential present of
9714 + an address in wlc_event_msg_t */
9715 + void *data; /* used to hang additional data on an event */
9716 + struct wlc_event *next; /* enables ordered list of pending events */
9719 +#define BCM_MAC_STATUS_INDICATION (0x40010200L)
9722 + uint16 ver; /* version of this struct */
9723 + uint16 len; /* length in bytes of this structure */
9724 + uint16 cap; /* sta's advertized capabilities */
9725 + uint32 flags; /* flags defined below */
9726 + uint32 idle; /* time since data pkt rx'd from sta */
9727 + struct ether_addr ea; /* Station address */
9728 + wl_rateset_t rateset; /* rateset in use */
9729 + uint32 in; /* seconds elapsed since associated */
9730 + uint32 listen_interval_inms; /* Min Listen interval in ms for this STA*/
9733 +#define WL_STA_VER 2
9736 +#define WL_STA_BRCM 0x01
9737 +#define WL_STA_WME 0x02
9738 +#define WL_STA_ABCAP 0x04
9739 +#define WL_STA_AUTHE 0x08
9740 +#define WL_STA_ASSOC 0x10
9741 +#define WL_STA_AUTHO 0x20
9742 +#define WL_STA_WDS 0x40
9743 +#define WL_WDS_LINKUP 0x80
9747 + * Country locale determines which channels are available to us.
9749 +typedef enum _wlc_locale {
9750 + WLC_WW = 0, /* Worldwide */
9751 + WLC_THA, /* Thailand */
9752 + WLC_ISR, /* Israel */
9753 + WLC_JDN, /* Jordan */
9754 + WLC_PRC, /* China */
9755 + WLC_JPN, /* Japan */
9756 + WLC_FCC, /* USA */
9757 + WLC_EUR, /* Europe */
9758 + WLC_USL, /* US Low Band only */
9759 + WLC_JPH, /* Japan High Band only */
9760 + WLC_ALL, /* All the channels in this band */
9761 + WLC_11D, /* Represents locale recieved by 11d beacons */
9763 + WLC_UNDEFINED_LOCALE = 0xf
9766 +/* channel encoding */
9767 +typedef struct channel_info {
9769 + int target_channel;
9773 +/* For ioctls that take a list of MAC addresses */
9775 + uint count; /* number of MAC addresses */
9776 + struct ether_addr ea[1]; /* variable length array of MAC addresses */
9779 +/* get pkt count struct passed through ioctl */
9780 +typedef struct get_pktcnt {
9787 +/* Linux network driver ioctl encoding */
9788 +typedef struct wl_ioctl {
9789 + uint cmd; /* common ioctl definition */
9790 + void *buf; /* pointer to user buffer */
9791 + uint len; /* length of user buffer */
9792 + bool set; /* get or set request (optional) */
9793 + uint used; /* bytes read or written (optional) */
9794 + uint needed; /* bytes needed (optional) */
9798 + * Structure for passing hardware and software
9799 + * revision info up from the driver.
9801 +typedef struct wlc_rev_info {
9802 + uint vendorid; /* PCI vendor id */
9803 + uint deviceid; /* device id of chip */
9804 + uint radiorev; /* radio revision */
9805 + uint chiprev; /* chip revision */
9806 + uint corerev; /* core revision */
9807 + uint boardid; /* board identifier (usu. PCI sub-device id) */
9808 + uint boardvendor; /* board vendor (usu. PCI sub-vendor id) */
9809 + uint boardrev; /* board revision */
9810 + uint driverrev; /* driver version */
9811 + uint ucoderev; /* microcode version */
9812 + uint bus; /* bus type */
9813 + uint chipnum; /* chip number */
9816 +#define WL_BRAND_MAX 10
9817 +typedef struct wl_instance_info {
9819 + char brand[WL_BRAND_MAX];
9820 +} wl_instance_info_t;
9822 +/* check this magic number */
9823 +#define WLC_IOCTL_MAGIC 0x14e46c77
9825 +/* bump this number if you change the ioctl interface */
9826 +#define WLC_IOCTL_VERSION 1
9828 +#define WLC_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */
9829 +#define WLC_IOCTL_SMLEN 256 /* "small" length ioctl buffer required */
9831 +/* common ioctl definitions */
9832 +#define WLC_GET_MAGIC 0
9833 +#define WLC_GET_VERSION 1
9837 +#define WLC_GET_MSGLEVEL 7
9838 +#define WLC_SET_MSGLEVEL 8
9839 +#define WLC_GET_PROMISC 9
9840 +#define WLC_SET_PROMISC 10
9841 +#define WLC_GET_RATE 12
9842 +/* #define WLC_SET_RATE 13 */ /* no longer supported */
9843 +#define WLC_GET_INSTANCE 14
9844 +/* #define WLC_GET_FRAG 15 */ /* no longer supported */
9845 +/* #define WLC_SET_FRAG 16 */ /* no longer supported */
9846 +/* #define WLC_GET_RTS 17 */ /* no longer supported */
9847 +/* #define WLC_SET_RTS 18 */ /* no longer supported */
9848 +#define WLC_GET_INFRA 19
9849 +#define WLC_SET_INFRA 20
9850 +#define WLC_GET_AUTH 21
9851 +#define WLC_SET_AUTH 22
9852 +#define WLC_GET_BSSID 23
9853 +#define WLC_SET_BSSID 24
9854 +#define WLC_GET_SSID 25
9855 +#define WLC_SET_SSID 26
9856 +#define WLC_RESTART 27
9857 +#define WLC_GET_CHANNEL 29
9858 +#define WLC_SET_CHANNEL 30
9859 +#define WLC_GET_SRL 31
9860 +#define WLC_SET_SRL 32
9861 +#define WLC_GET_LRL 33
9862 +#define WLC_SET_LRL 34
9863 +#define WLC_GET_PLCPHDR 35
9864 +#define WLC_SET_PLCPHDR 36
9865 +#define WLC_GET_RADIO 37
9866 +#define WLC_SET_RADIO 38
9867 +#define WLC_GET_PHYTYPE 39
9868 +/* #define WLC_GET_WEP 42 */ /* no longer supported */
9869 +/* #define WLC_SET_WEP 43 */ /* no longer supported */
9870 +#define WLC_GET_KEY 44
9871 +#define WLC_SET_KEY 45
9872 +#define WLC_GET_REGULATORY 46
9873 +#define WLC_SET_REGULATORY 47
9874 +#define WLC_SCAN 50
9875 +#define WLC_SCAN_RESULTS 51
9876 +#define WLC_DISASSOC 52
9877 +#define WLC_REASSOC 53
9878 +#define WLC_GET_ROAM_TRIGGER 54
9879 +#define WLC_SET_ROAM_TRIGGER 55
9880 +#define WLC_GET_TXANT 61
9881 +#define WLC_SET_TXANT 62
9882 +#define WLC_GET_ANTDIV 63
9883 +#define WLC_SET_ANTDIV 64
9884 +/* #define WLC_GET_TXPWR 65 */ /* no longer supported */
9885 +/* #define WLC_SET_TXPWR 66 */ /* no longer supported */
9886 +#define WLC_GET_CLOSED 67
9887 +#define WLC_SET_CLOSED 68
9888 +#define WLC_GET_MACLIST 69
9889 +#define WLC_SET_MACLIST 70
9890 +#define WLC_GET_RATESET 71
9891 +#define WLC_SET_RATESET 72
9892 +#define WLC_GET_LOCALE 73
9893 +#define WLC_LONGTRAIN 74
9894 +#define WLC_GET_BCNPRD 75
9895 +#define WLC_SET_BCNPRD 76
9896 +#define WLC_GET_DTIMPRD 77
9897 +#define WLC_SET_DTIMPRD 78
9898 +#define WLC_GET_SROM 79
9899 +#define WLC_SET_SROM 80
9900 +#define WLC_GET_WEP_RESTRICT 81
9901 +#define WLC_SET_WEP_RESTRICT 82
9902 +#define WLC_GET_COUNTRY 83
9903 +#define WLC_SET_COUNTRY 84
9904 +#define WLC_GET_REVINFO 98
9905 +#define WLC_GET_MACMODE 105
9906 +#define WLC_SET_MACMODE 106
9907 +#define WLC_GET_GMODE 109
9908 +#define WLC_SET_GMODE 110
9909 +#define WLC_GET_CURR_RATESET 114 /* current rateset */
9910 +#define WLC_GET_SCANSUPPRESS 115
9911 +#define WLC_SET_SCANSUPPRESS 116
9912 +#define WLC_GET_AP 117
9913 +#define WLC_SET_AP 118
9914 +#define WLC_GET_EAP_RESTRICT 119
9915 +#define WLC_SET_EAP_RESTRICT 120
9916 +#define WLC_GET_WDSLIST 123
9917 +#define WLC_SET_WDSLIST 124
9918 +#define WLC_GET_RSSI 127
9919 +#define WLC_GET_WSEC 133
9920 +#define WLC_SET_WSEC 134
9921 +#define WLC_GET_BSS_INFO 136
9922 +#define WLC_GET_LAZYWDS 138
9923 +#define WLC_SET_LAZYWDS 139
9924 +#define WLC_GET_BANDLIST 140
9925 +#define WLC_GET_BAND 141
9926 +#define WLC_SET_BAND 142
9927 +#define WLC_GET_SHORTSLOT 144
9928 +#define WLC_GET_SHORTSLOT_OVERRIDE 145
9929 +#define WLC_SET_SHORTSLOT_OVERRIDE 146
9930 +#define WLC_GET_SHORTSLOT_RESTRICT 147
9931 +#define WLC_SET_SHORTSLOT_RESTRICT 148
9932 +#define WLC_GET_GMODE_PROTECTION 149
9933 +#define WLC_GET_GMODE_PROTECTION_OVERRIDE 150
9934 +#define WLC_SET_GMODE_PROTECTION_OVERRIDE 151
9935 +#define WLC_UPGRADE 152
9936 +/* #define WLC_GET_MRATE 153 */ /* no longer supported */
9937 +/* #define WLC_SET_MRATE 154 */ /* no longer supported */
9938 +#define WLC_GET_ASSOCLIST 159
9939 +#define WLC_GET_CLK 160
9940 +#define WLC_SET_CLK 161
9941 +#define WLC_GET_UP 162
9942 +#define WLC_OUT 163
9943 +#define WLC_GET_WPA_AUTH 164
9944 +#define WLC_SET_WPA_AUTH 165
9945 +#define WLC_GET_GMODE_PROTECTION_CONTROL 178
9946 +#define WLC_SET_GMODE_PROTECTION_CONTROL 179
9947 +#define WLC_GET_PHYLIST 180
9948 +#define WLC_GET_KEY_SEQ 183
9949 +#define WLC_GET_GMODE_PROTECTION_CTS 198
9950 +#define WLC_SET_GMODE_PROTECTION_CTS 199
9951 +#define WLC_GET_PIOMODE 203
9952 +#define WLC_SET_PIOMODE 204
9953 +#define WLC_SET_LED 209
9954 +#define WLC_GET_LED 210
9955 +#define WLC_GET_CHANNEL_SEL 215
9956 +#define WLC_START_CHANNEL_SEL 216
9957 +#define WLC_GET_VALID_CHANNELS 217
9958 +#define WLC_GET_FAKEFRAG 218
9959 +#define WLC_SET_FAKEFRAG 219
9960 +#define WLC_GET_WET 230
9961 +#define WLC_SET_WET 231
9962 +#define WLC_GET_KEY_PRIMARY 235
9963 +#define WLC_SET_KEY_PRIMARY 236
9964 +#define WLC_GET_RADAR 242
9965 +#define WLC_SET_RADAR 243
9966 +#define WLC_SET_SPECT_MANAGMENT 244
9967 +#define WLC_GET_SPECT_MANAGMENT 245
9968 +#define WLC_WDS_GET_REMOTE_HWADDR 246 /* currently handled in wl_linux.c/wl_vx.c */
9969 +#define WLC_SET_CS_SCAN_TIMER 248
9970 +#define WLC_GET_CS_SCAN_TIMER 249
9971 +#define WLC_SEND_PWR_CONSTRAINT 254
9972 +#define WLC_CURRENT_PWR 256
9973 +#define WLC_GET_CHANNELS_IN_COUNTRY 260
9974 +#define WLC_GET_COUNTRY_LIST 261
9975 +#define WLC_GET_VAR 262 /* get value of named variable */
9976 +#define WLC_SET_VAR 263 /* set named variable to value */
9977 +#define WLC_NVRAM_GET 264
9978 +#define WLC_NVRAM_SET 265
9979 +#define WLC_SET_WSEC_PMK 268
9980 +#define WLC_GET_AUTH_MODE 269
9981 +#define WLC_SET_AUTH_MODE 270
9982 +#define WLC_NDCONFIG_ITEM 273 /* currently handled in wl_oid.c */
9983 +#define WLC_NVOTPW 274
9984 +/* #define WLC_OTPW 275 */ /* no longer supported */
9985 +#define WLC_SET_LOCALE 278
9986 +#define WLC_LAST 279 /* do not change - use get_var/set_var */
9989 + * Minor kludge alert:
9990 + * Duplicate a few definitions that irelay requires from epiioctl.h here
9991 + * so caller doesn't have to include this file and epiioctl.h .
9992 + * If this grows any more, it would be time to move these irelay-specific
9993 + * definitions out of the epiioctl.h and into a separate driver common file.
9995 +#ifndef EPICTRL_COOKIE
9996 +#define EPICTRL_COOKIE 0xABADCEDE
9999 +/* vx wlc ioctl's offset */
10000 +#define CMN_IOCTL_OFF 0x180
10003 + * custom OID support
10005 + * 0xFF - implementation specific OID
10006 + * 0xE4 - first byte of Broadcom PCI vendor ID
10007 + * 0x14 - second byte of Broadcom PCI vendor ID
10008 + * 0xXX - the custom OID number
10011 +/* begin 0x1f values beyond the start of the ET driver range. */
10012 +#define WL_OID_BASE 0xFFE41420
10014 +/* NDIS overrides */
10015 +#define OID_WL_GETINSTANCE (WL_OID_BASE + WLC_GET_INSTANCE)
10016 +#define OID_WL_NDCONFIG_ITEM (WL_OID_BASE + WLC_NDCONFIG_ITEM)
10018 +#define WL_DECRYPT_STATUS_SUCCESS 1
10019 +#define WL_DECRYPT_STATUS_FAILURE 2
10020 +#define WL_DECRYPT_STATUS_UNKNOWN 3
10022 +/* allows user-mode app to poll the status of USB image upgrade */
10023 +#define WLC_UPGRADE_SUCCESS 0
10024 +#define WLC_UPGRADE_PENDING 1
10026 +#ifdef CONFIG_USBRNDIS_RETAIL
10027 +/* struct passed in for WLC_NDCONFIG_ITEM */
10031 +} ndconfig_item_t;
10034 +/* Bit masks for radio disabled status - returned by WL_GET_RADIO */
10035 +#define WL_RADIO_SW_DISABLE (1<<0)
10036 +#define WL_RADIO_HW_DISABLE (1<<1)
10037 +#define WL_RADIO_MPC_DISABLE (1<<2)
10038 +#define WL_RADIO_COUNTRY_DISABLE (1<<3) /* some countries don't support any 802.11 channel */
10040 +/* Override bit for WLC_SET_TXPWR. if set, ignore other level limits */
10041 +#define WL_TXPWR_OVERRIDE (1<<31)
10043 +/* "diag" iovar argument and error code */
10044 +#define WL_DIAG_INTERRUPT 1 /* d11 loopback interrupt test */
10045 +#define WL_DIAG_MEMORY 3 /* d11 memory test */
10046 +#define WL_DIAG_LED 4 /* LED test */
10047 +#define WL_DIAG_REG 5 /* d11/phy register test */
10048 +#define WL_DIAG_SROM 6 /* srom read/crc test */
10049 +#define WL_DIAG_DMA 7 /* DMA test */
10051 +#define WL_DIAGERR_SUCCESS 0
10052 +#define WL_DIAGERR_FAIL_TO_RUN 1 /* unable to run requested diag */
10053 +#define WL_DIAGERR_NOT_SUPPORTED 2 /* diag requested is not supported */
10054 +#define WL_DIAGERR_INTERRUPT_FAIL 3 /* loopback interrupt test failed */
10055 +#define WL_DIAGERR_LOOPBACK_FAIL 4 /* loopback data test failed */
10056 +#define WL_DIAGERR_SROM_FAIL 5 /* srom read failed */
10057 +#define WL_DIAGERR_SROM_BADCRC 6 /* srom crc failed */
10058 +#define WL_DIAGERR_REG_FAIL 7 /* d11/phy register test failed */
10059 +#define WL_DIAGERR_MEMORY_FAIL 8 /* d11 memory test failed */
10060 +#define WL_DIAGERR_NOMEM 9 /* diag test failed due to no memory */
10061 +#define WL_DIAGERR_DMA_FAIL 10 /* DMA test failed */
10064 +#define WL_SB_BUS 0 /* Silicon Backplane */
10065 +#define WL_PCI_BUS 1 /* PCI target */
10066 +#define WL_PCMCIA_BUS 2 /* PCMCIA target */
10069 +#define WLC_BAND_AUTO 0 /* auto-select */
10070 +#define WLC_BAND_A 1 /* "a" band (5 Ghz) */
10071 +#define WLC_BAND_B 2 /* "b" band (2.4 Ghz) */
10072 +#define WLC_BAND_ALL 3 /* all bands */
10074 +/* phy types (returned by WLC_GET_PHYTPE) */
10075 +#define WLC_PHY_TYPE_A 0
10076 +#define WLC_PHY_TYPE_B 1
10077 +#define WLC_PHY_TYPE_G 2
10078 +#define WLC_PHY_TYPE_NULL 0xf
10080 +/* MAC list modes */
10081 +#define WLC_MACMODE_DISABLED 0 /* MAC list disabled */
10082 +#define WLC_MACMODE_DENY 1 /* Deny specified (i.e. allow unspecified) */
10083 +#define WLC_MACMODE_ALLOW 2 /* Allow specified (i.e. deny unspecified) */
10088 +#define GMODE_LEGACY_B 0
10089 +#define GMODE_AUTO 1
10090 +#define GMODE_ONLY 2
10091 +#define GMODE_B_DEFERRED 3
10092 +#define GMODE_PERFORMANCE 4
10093 +#define GMODE_LRS 5
10094 +#define GMODE_MAX 6
10096 +/* values for PLCPHdr_override */
10097 +#define WLC_PLCP_AUTO -1
10098 +#define WLC_PLCP_SHORT 0
10099 +#define WLC_PLCP_LONG 1
10101 +/* values for g_protection_override */
10102 +#define WLC_G_PROTECTION_AUTO -1
10103 +#define WLC_G_PROTECTION_OFF 0
10104 +#define WLC_G_PROTECTION_ON 1
10106 +/* values for g_protection_control */
10107 +#define WLC_G_PROTECTION_CTL_OFF 0
10108 +#define WLC_G_PROTECTION_CTL_LOCAL 1
10109 +#define WLC_G_PROTECTION_CTL_OVERLAP 2
10111 +/* Values for PM */
10119 + int npulses; /* required number of pulses at n * t_int */
10120 + int ncontig; /* required number of pulses at t_int */
10121 + int min_pw; /* minimum pulse width (20 MHz clocks) */
10122 + int max_pw; /* maximum pulse width (20 MHz clocks) */
10123 + uint16 thresh0; /* Radar detection, thresh 0 */
10124 + uint16 thresh1; /* Radar detection, thresh 1 */
10125 +} wl_radar_args_t;
10127 +/* radar iovar SET defines */
10128 +#define WL_RADRA_DETECTOR_OFF 0 /* radar dector off */
10129 +#define WL_RADAR_DETECTOR_ON 1 /* radar detector on */
10130 +#define WL_RADAR_SIMULATED 2 /* force radar detector to declare detection once */
10132 +/* dfs_status iovar-related defines */
10134 +/* cac - channel availability check,
10135 + * ism - in-service monitoring
10136 + * csa - channel switching anouncement
10139 +/* cac state values */
10140 +#define WL_DFS_CACSTATE_IDLE 0 /* state for operating in non-radar channel */
10141 +#define WL_DFS_CACSTATE_PREISM_CAC 1 /* CAC in progress */
10142 +#define WL_DFS_CACSTATE_ISM 2 /* ISM in progress */
10143 +#define WL_DFS_CACSTATE_CSA 3 /* csa */
10144 +#define WL_DFS_CACSTATE_POSTISM_CAC 4 /* ISM CAC */
10145 +#define WL_DFS_CACSTATE_PREISM_OOC 5 /* PREISM OOC */
10146 +#define WL_DFS_CACSTATE_POSTISM_OOC 6 /* POSTISM OOC */
10147 +#define WL_DFS_CACSTATES 7 /* this many states exist */
10149 +/* data structure used in 'dfs_status' wl interface, which is used to query dfs status */
10151 + uint state; /* noted by WL_DFS_CACSTATE_XX. */
10152 + uint duration; /* time spent in ms in state. */
10153 + /* as dfs enters ISM state, it removes the operational channel from quiet channel list
10154 + * and notes the channel in channel_cleared. set to 0 if no channel is cleared
10156 + uint channel_cleared;
10157 +} wl_dfs_status_t;
10159 +#define NUM_PWRCTRL_RATES 12
10162 +/* 802.11h enforcement levels */
10163 +#define SPECT_MNGMT_OFF 0 /* 11h disabled */
10164 +#define SPECT_MNGMT_LOOSE 1 /* allow scan lists to contain non-11h AP */
10165 +#define SPECT_MNGMT_STRICT 2 /* prune out non-11h APs from scan list */
10166 +#define SPECT_MNGMT_11D 3 /* switch to 802.11D mode */
10168 +#define WL_CHAN_VALID_HW (1 << 0) /* valid with current HW */
10169 +#define WL_CHAN_VALID_SW (1 << 1) /* valid with current country setting */
10170 +#define WL_CHAN_BAND_A (1 << 2) /* A-band channel */
10171 +#define WL_CHAN_RADAR (1 << 3) /* radar sensitive channel */
10172 +#define WL_CHAN_INACTIVE (1 << 4) /* temporarily out of service due to radar */
10173 +#define WL_CHAN_RADAR_PASSIVE (1 << 5) /* radar channel is in passive mode */
10175 +#define WL_MPC_VAL 0x00400000
10176 +#define WL_APSTA_VAL 0x00800000
10177 +#define WL_DFS_VAL 0x01000000
10179 +/* max # of leds supported by GPIO (gpio pin# == led index#) */
10180 +#define WL_LED_NUMGPIO 16 /* gpio 0-15 */
10182 +/* led per-pin behaviors */
10183 +#define WL_LED_OFF 0 /* always off */
10184 +#define WL_LED_ON 1 /* always on */
10185 +#define WL_LED_ACTIVITY 2 /* activity */
10186 +#define WL_LED_RADIO 3 /* radio enabled */
10187 +#define WL_LED_ARADIO 4 /* 5 Ghz radio enabled */
10188 +#define WL_LED_BRADIO 5 /* 2.4Ghz radio enabled */
10189 +#define WL_LED_BGMODE 6 /* on if gmode, off if bmode */
10190 +#define WL_LED_WI1 7
10191 +#define WL_LED_WI2 8
10192 +#define WL_LED_WI3 9
10193 +#define WL_LED_ASSOC 10 /* associated state indicator */
10194 +#define WL_LED_INACTIVE 11 /* null behavior (clears default behavior) */
10195 +#define WL_LED_NUMBEHAVIOR 12
10197 +/* led behavior numeric value format */
10198 +#define WL_LED_BEH_MASK 0x7f /* behavior mask */
10199 +#define WL_LED_AL_MASK 0x80 /* activelow (polarity) bit */
10202 +/* WDS link local endpoint WPA role */
10203 +#define WL_WDS_WPA_ROLE_AUTH 0 /* authenticator */
10204 +#define WL_WDS_WPA_ROLE_SUP 1 /* supplicant */
10205 +#define WL_WDS_WPA_ROLE_AUTO 255 /* auto, based on mac addr value */
10207 +/* number of bytes needed to define a 128-bit mask for MAC event reporting */
10208 +#define WL_EVENTING_MASK_LEN 16
10210 +/* Structures and constants used for "vndr_ie" IOVar interface */
10211 +#define VNDR_IE_CMD_LEN 4 /* length of the set command string: "add", "del" (+ NULL) */
10213 +/* 802.11 Mgmt Packet flags */
10214 +#define VNDR_IE_BEACON_FLAG 0x1
10215 +#define VNDR_IE_PRBRSP_FLAG 0x2
10216 +#define VNDR_IE_ASSOCRSP_FLAG 0x4
10217 +#define VNDR_IE_AUTHRSP_FLAG 0x8
10220 + uint32 pktflag; /* bitmask indicating which packet(s) contain this IE */
10221 + vndr_ie_t vndr_ie_data; /* vendor IE data */
10225 + int iecount; /* number of entries in the vndr_ie_list[] array */
10226 + vndr_ie_info_t vndr_ie_list[1]; /* variable size list of vndr_ie_info_t structs */
10230 + char cmd[VNDR_IE_CMD_LEN]; /* vndr_ie IOVar set command : "add", "del" + NULL */
10231 + vndr_ie_buf_t vndr_ie_buffer; /* buffer containing Vendor IE list information */
10232 +} vndr_ie_setbuf_t;
10234 +/* join target preference types */
10235 +#define WL_JOIN_PREF_RSSI 1 /* by RSSI, mandatory */
10236 +#define WL_JOIN_PREF_WPA 2 /* by akm and ciphers, optional, RSN and WPA as values */
10237 +#define WL_JOIN_PREF_BAND 3 /* by 802.11 band, optional, WLC_BAND_XXXX as values */
10239 +/* band preference */
10240 +#define WLJP_BAND_ASSOC_PREF 255 /* use assoc preference settings */
10241 + /* others use WLC_BAND_XXXX as values */
10243 +/* any multicast cipher suite */
10244 +#define WL_WPA_ACP_MCS_ANY "\x00\x00\x00\x00"
10246 +#if !defined(__GNUC__)
10250 +#define NFIFO 6 /* # tx/rx fifopairs */
10252 +#define WL_CNT_T_VERSION 1 /* current version of wl_cnt_t struct */
10255 + uint16 version; /* see definition of WL_CNT_T_VERSION */
10256 + uint16 length; /* length of entire structure */
10258 + /* transmit stat counters */
10259 + uint32 txframe; /* tx data frames */
10260 + uint32 txbyte; /* tx data bytes */
10261 + uint32 txretrans; /* tx mac retransmits */
10262 + uint32 txerror; /* tx data errors */
10263 + uint32 txctl; /* tx management frames */
10264 + uint32 txprshort; /* tx short preamble frames */
10265 + uint32 txserr; /* tx status errors */
10266 + uint32 txnobuf; /* tx out of buffers errors */
10267 + uint32 txnoassoc; /* tx discard because we're not associated */
10268 + uint32 txrunt; /* tx runt frames */
10269 + uint32 txchit; /* tx header cache hit (fastpath) */
10270 + uint32 txcmiss; /* tx header cache miss (slowpath) */
10272 + /* transmit chip error counters */
10273 + uint32 txuflo; /* tx fifo underflows */
10274 + uint32 txphyerr; /* tx phy errors (indicated in tx status) */
10277 + /* receive stat counters */
10278 + uint32 rxframe; /* rx data frames */
10279 + uint32 rxbyte; /* rx data bytes */
10280 + uint32 rxerror; /* rx data errors */
10281 + uint32 rxctl; /* rx management frames */
10282 + uint32 rxnobuf; /* rx out of buffers errors */
10283 + uint32 rxnondata; /* rx non data frames in the data channel errors */
10284 + uint32 rxbadds; /* rx bad DS errors */
10285 + uint32 rxbadcm; /* rx bad control or management frames */
10286 + uint32 rxfragerr; /* rx fragmentation errors */
10287 + uint32 rxrunt; /* rx runt frames */
10288 + uint32 rxgiant; /* rx giant frames */
10289 + uint32 rxnoscb; /* rx no scb error */
10290 + uint32 rxbadproto; /* rx invalid frames */
10291 + uint32 rxbadsrcmac; /* rx frames with Invalid Src Mac*/
10292 + uint32 rxbadda; /* rx frames tossed for invalid da */
10293 + uint32 rxfilter; /* rx frames filtered out */
10295 + /* receive chip error counters */
10296 + uint32 rxoflo; /* rx fifo overflow errors */
10297 + uint32 rxuflo[NFIFO]; /* rx dma descriptor underflow errors */
10299 + uint32 d11cnt_txrts_off; /* d11cnt txrts value when reset d11cnt */
10300 + uint32 d11cnt_rxcrc_off; /* d11cnt rxcrc value when reset d11cnt */
10301 + uint32 d11cnt_txnocts_off; /* d11cnt txnocts value when reset d11cnt */
10303 + /* misc counters */
10304 + uint32 dmade; /* tx/rx dma descriptor errors */
10305 + uint32 dmada; /* tx/rx dma data errors */
10306 + uint32 dmape; /* tx/rx dma descriptor protocol errors */
10307 + uint32 reset; /* reset count */
10308 + uint32 tbtt; /* cnts the TBTT int's */
10311 + /* MAC counters: 32-bit version of d11.h's macstat_t */
10312 + uint32 txallfrm; /* total number of frames sent, incl. Data, ACK, RTS, CTS,
10313 + Control Management (includes retransmissions) */
10314 + uint32 txrtsfrm; /* number of RTS sent out by the MAC */
10315 + uint32 txctsfrm; /* number of CTS sent out by the MAC */
10316 + uint32 txackfrm; /* number of ACK frames sent out */
10317 + uint32 txdnlfrm; /* Not used */
10318 + uint32 txbcnfrm; /* beacons transmitted */
10319 + uint32 txfunfl[8]; /* per-fifo tx underflows */
10320 + uint32 txtplunfl; /* Template underflows (mac was too slow to transmit ACK/CTS or BCN) */
10321 + uint32 txphyerror; /* Transmit phy error, type of error is reported in tx-status for
10322 + driver enqueued frames*/
10323 + uint32 rxfrmtoolong; /* Received frame longer than legal limit (2346 bytes) */
10324 + uint32 rxfrmtooshrt; /* Received frame did not contain enough bytes for its frame type */
10325 + uint32 rxinvmachdr; /* Either the protocol version != 0 or frame type not
10326 + data/control/management*/
10327 + uint32 rxbadfcs; /* number of frames for which the CRC check failed in the MAC */
10328 + uint32 rxbadplcp; /* parity check of the PLCP header failed */
10329 + uint32 rxcrsglitch; /* PHY was able to correlate the preamble but not the header */
10330 + uint32 rxstrt; /* Number of received frames with a good PLCP (i.e. passing parity check) */
10331 + uint32 rxdfrmucastmbss; /* Number of received DATA frames with good FCS and matching RA */
10332 + uint32 rxmfrmucastmbss; /* number of received mgmt frames with good FCS and matching RA */
10333 + uint32 rxcfrmucast; /* number of received CNTRL frames with good FCS and matching RA */
10334 + uint32 rxrtsucast; /* number of unicast RTS addressed to the MAC (good FCS) */
10335 + uint32 rxctsucast; /* number of unicast CTS addressed to the MAC (good FCS)*/
10336 + uint32 rxackucast; /* number of ucast ACKS received (good FCS)*/
10337 + uint32 rxdfrmocast; /* number of received DATA frames with good FCS and not matching RA */
10338 + uint32 rxmfrmocast; /* number of received MGMT frames with good FCS and not matching RA */
10339 + uint32 rxcfrmocast; /* number of received CNTRL frame with good FCS and not matching RA */
10340 + uint32 rxrtsocast; /* number of received RTS not addressed to the MAC */
10341 + uint32 rxctsocast; /* number of received CTS not addressed to the MAC */
10342 + uint32 rxdfrmmcast; /* number of RX Data multicast frames received by the MAC */
10343 + uint32 rxmfrmmcast; /* number of RX Management multicast frames received by the MAC */
10344 + uint32 rxcfrmmcast; /* number of RX Control multicast frames received by the MAC (unlikely
10346 + uint32 rxbeaconmbss; /* beacons received from member of BSS */
10347 + uint32 rxdfrmucastobss; /* number of unicast frames addressed to the MAC from other BSS (WDS FRAME) */
10348 + uint32 rxbeaconobss; /* beacons received from other BSS */
10349 + uint32 rxrsptmout; /* Number of response timeouts for transmitted frames expecting a
10351 + uint32 bcntxcancl; /* transmit beacons cancelled due to receipt of beacon (IBSS) */
10352 + uint32 rxf0ovfl; /* Number of receive fifo 0 overflows */
10353 + uint32 rxf1ovfl; /* Number of receive fifo 1 overflows (obsolete) */
10354 + uint32 rxf2ovfl; /* Number of receive fifo 2 overflows (obsolete) */
10355 + uint32 txsfovfl; /* Number of transmit status fifo overflows (obsolete) */
10356 + uint32 pmqovfl; /* Number of PMQ overflows */
10357 + uint32 rxcgprqfrm; /* Number of received Probe requests that made it into the PRQ fifo */
10358 + uint32 rxcgprsqovfl; /* Rx Probe Request Que overflow in the AP */
10359 + uint32 txcgprsfail; /* Tx Probe Response Fail. AP sent probe response but did not get ACK */
10360 + uint32 txcgprssuc; /* Tx Probe Rresponse Success (ACK was received) */
10361 + uint32 prs_timeout; /* Number of probe requests that were dropped from the PRQ fifo because
10362 + a probe response could not be sent out within the time limit defined
10363 + in M_PRS_MAXTIME */
10364 + uint32 rxnack; /* Number of NACKS received (Afterburner) */
10365 + uint32 frmscons; /* Number of frames completed without transmission because of an
10366 + Afterburner re-queue */
10367 + uint32 txnack; /* Number of NACKs transmtitted (Afterburner) */
10368 + uint32 txglitch_nack; /* obsolete */
10369 + uint32 txburst; /* obsolete */
10370 + uint32 rxburst; /* obsolete */
10372 + /* 802.11 MIB counters, pp. 614 of 802.11 reaff doc. */
10373 + uint32 txfrag; /* dot11TransmittedFragmentCount */
10374 + uint32 txmulti; /* dot11MulticastTransmittedFrameCount */
10375 + uint32 txfail; /* dot11FailedCount */
10376 + uint32 txretry; /* dot11RetryCount */
10377 + uint32 txretrie; /* dot11MultipleRetryCount */
10378 + uint32 rxdup; /* dot11FrameduplicateCount */
10379 + uint32 txrts; /* dot11RTSSuccessCount */
10380 + uint32 txnocts; /* dot11RTSFailureCount */
10381 + uint32 txnoack; /* dot11ACKFailureCount */
10382 + uint32 rxfrag; /* dot11ReceivedFragmentCount */
10383 + uint32 rxmulti; /* dot11MulticastReceivedFrameCount */
10384 + uint32 rxcrc; /* dot11FCSErrorCount */
10385 + uint32 txfrmsnt; /* dot11TransmittedFrameCount (bogus MIB?) */
10386 + uint32 rxundec; /* dot11WEPUndecryptableCount */
10388 + /* WPA2 counters (see rxundec for DecryptFailureCount) */
10389 + uint32 tkipmicfaill; /* TKIPLocalMICFailures */
10390 + uint32 tkipcntrmsr; /* TKIPCounterMeasuresInvoked */
10391 + uint32 tkipreplay; /* TKIPReplays */
10392 + uint32 ccmpfmterr; /* CCMPFormatErrors */
10393 + uint32 ccmpreplay; /* CCMPReplays */
10394 + uint32 ccmpundec; /* CCMPDecryptErrors */
10395 + uint32 fourwayfail; /* FourWayHandshakeFailures */
10396 + uint32 wepundec; /* dot11WEPUndecryptableCount */
10397 + uint32 wepicverr; /* dot11WEPICVErrorCount */
10398 + uint32 decsuccess; /* DecryptSuccessCount */
10399 + uint32 tkipicverr; /* TKIPICVErrorCount */
10400 + uint32 wepexcluded; /* dot11WEPExcludedCount */
10403 +#endif /* _wlioctl_h_ */
10404 diff -Nur linux-2.4.32/arch/mips/bcm947xx/Makefile linux-2.4.32-brcm/arch/mips/bcm947xx/Makefile
10405 --- linux-2.4.32/arch/mips/bcm947xx/Makefile 1970-01-01 01:00:00.000000000 +0100
10406 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/Makefile 2005-12-19 01:56:51.733868750 +0100
10409 +# Makefile for the BCM947xx specific kernel interface routines
10413 +EXTRA_CFLAGS+=-I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
10415 +O_TARGET := bcm947xx.o
10417 +export-objs := nvram_linux.o setup.o
10418 +obj-y := prom.o setup.o time.o sbmips.o gpio.o
10419 +obj-y += nvram.o nvram_linux.o sflash.o cfe_env.o
10420 +obj-$(CONFIG_PCI) += sbpci.o pcibios.o
10422 +include $(TOPDIR)/Rules.make
10423 diff -Nur linux-2.4.32/arch/mips/bcm947xx/nvram.c linux-2.4.32-brcm/arch/mips/bcm947xx/nvram.c
10424 --- linux-2.4.32/arch/mips/bcm947xx/nvram.c 1970-01-01 01:00:00.000000000 +0100
10425 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/nvram.c 2005-12-19 01:05:00.079582750 +0100
10428 + * NVRAM variable manipulation (common)
10430 + * Copyright 2004, Broadcom Corporation
10431 + * All Rights Reserved.
10433 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10434 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10435 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10436 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10440 +#include <typedefs.h>
10442 +#include <bcmendian.h>
10443 +#include <bcmnvram.h>
10444 +#include <bcmutils.h>
10445 +#include <sbsdram.h>
10447 +extern struct nvram_tuple * BCMINIT(_nvram_realloc)(struct nvram_tuple *t, const char *name, const char *value);
10448 +extern void BCMINIT(_nvram_free)(struct nvram_tuple *t);
10449 +extern int BCMINIT(_nvram_read)(void *buf);
10451 +char * BCMINIT(_nvram_get)(const char *name);
10452 +int BCMINIT(_nvram_set)(const char *name, const char *value);
10453 +int BCMINIT(_nvram_unset)(const char *name);
10454 +int BCMINIT(_nvram_getall)(char *buf, int count);
10455 +int BCMINIT(_nvram_commit)(struct nvram_header *header);
10456 +int BCMINIT(_nvram_init)(void);
10457 +void BCMINIT(_nvram_exit)(void);
10459 +static struct nvram_tuple * BCMINITDATA(nvram_hash)[257];
10460 +static struct nvram_tuple * nvram_dead;
10462 +/* Free all tuples. Should be locked. */
10464 +BCMINITFN(nvram_free)(void)
10467 + struct nvram_tuple *t, *next;
10469 + /* Free hash table */
10470 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
10471 + for (t = BCMINIT(nvram_hash)[i]; t; t = next) {
10473 + BCMINIT(_nvram_free)(t);
10475 + BCMINIT(nvram_hash)[i] = NULL;
10478 + /* Free dead table */
10479 + for (t = nvram_dead; t; t = next) {
10481 + BCMINIT(_nvram_free)(t);
10483 + nvram_dead = NULL;
10485 + /* Indicate to per-port code that all tuples have been freed */
10486 + BCMINIT(_nvram_free)(NULL);
10490 +static INLINE uint
10491 +hash(const char *s)
10496 + hash = 31 * hash + *s++;
10501 +/* (Re)initialize the hash table. Should be locked. */
10503 +BCMINITFN(nvram_rehash)(struct nvram_header *header)
10505 + char buf[] = "0xXXXXXXXX", *name, *value, *end, *eq;
10507 + /* (Re)initialize hash table */
10508 + BCMINIT(nvram_free)();
10510 + /* Parse and set "name=value\0 ... \0\0" */
10511 + name = (char *) &header[1];
10512 + end = (char *) header + NVRAM_SPACE - 2;
10513 + end[0] = end[1] = '\0';
10514 + for (; *name; name = value + strlen(value) + 1) {
10515 + if (!(eq = strchr(name, '=')))
10519 + BCMINIT(_nvram_set)(name, value);
10523 + /* Set special SDRAM parameters */
10524 + if (!BCMINIT(_nvram_get)("sdram_init")) {
10525 + sprintf(buf, "0x%04X", (uint16)(header->crc_ver_init >> 16));
10526 + BCMINIT(_nvram_set)("sdram_init", buf);
10528 + if (!BCMINIT(_nvram_get)("sdram_config")) {
10529 + sprintf(buf, "0x%04X", (uint16)(header->config_refresh & 0xffff));
10530 + BCMINIT(_nvram_set)("sdram_config", buf);
10532 + if (!BCMINIT(_nvram_get)("sdram_refresh")) {
10533 + sprintf(buf, "0x%04X", (uint16)((header->config_refresh >> 16) & 0xffff));
10534 + BCMINIT(_nvram_set)("sdram_refresh", buf);
10536 + if (!BCMINIT(_nvram_get)("sdram_ncdl")) {
10537 + sprintf(buf, "0x%08X", header->config_ncdl);
10538 + BCMINIT(_nvram_set)("sdram_ncdl", buf);
10544 +/* Get the value of an NVRAM variable. Should be locked. */
10546 +BCMINITFN(_nvram_get)(const char *name)
10549 + struct nvram_tuple *t;
10555 + /* Hash the name */
10556 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
10558 + /* Find the associated tuple in the hash table */
10559 + for (t = BCMINIT(nvram_hash)[i]; t && strcmp(t->name, name); t = t->next);
10561 + value = t ? t->value : NULL;
10566 +/* Get the value of an NVRAM variable. Should be locked. */
10568 +BCMINITFN(_nvram_set)(const char *name, const char *value)
10571 + struct nvram_tuple *t, *u, **prev;
10573 + /* Hash the name */
10574 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
10576 + /* Find the associated tuple in the hash table */
10577 + for (prev = &BCMINIT(nvram_hash)[i], t = *prev; t && strcmp(t->name, name); prev = &t->next, t = *prev);
10579 + /* (Re)allocate tuple */
10580 + if (!(u = BCMINIT(_nvram_realloc)(t, name, value)))
10581 + return -12; /* -ENOMEM */
10583 + /* Value reallocated */
10587 + /* Move old tuple to the dead table */
10590 + t->next = nvram_dead;
10594 + /* Add new tuple to the hash table */
10595 + u->next = BCMINIT(nvram_hash)[i];
10596 + BCMINIT(nvram_hash)[i] = u;
10601 +/* Unset the value of an NVRAM variable. Should be locked. */
10603 +BCMINITFN(_nvram_unset)(const char *name)
10606 + struct nvram_tuple *t, **prev;
10611 + /* Hash the name */
10612 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
10614 + /* Find the associated tuple in the hash table */
10615 + for (prev = &BCMINIT(nvram_hash)[i], t = *prev; t && strcmp(t->name, name); prev = &t->next, t = *prev);
10617 + /* Move it to the dead table */
10620 + t->next = nvram_dead;
10627 +/* Get all NVRAM variables. Should be locked. */
10629 +BCMINITFN(_nvram_getall)(char *buf, int count)
10632 + struct nvram_tuple *t;
10635 + bzero(buf, count);
10637 + /* Write name=value\0 ... \0\0 */
10638 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
10639 + for (t = BCMINIT(nvram_hash)[i]; t; t = t->next) {
10640 + if ((count - len) > (strlen(t->name) + 1 + strlen(t->value) + 1))
10641 + len += sprintf(buf + len, "%s=%s", t->name, t->value) + 1;
10650 +/* Regenerate NVRAM. Should be locked. */
10652 +BCMINITFN(_nvram_commit)(struct nvram_header *header)
10654 + char *init, *config, *refresh, *ncdl;
10657 + struct nvram_tuple *t;
10658 + struct nvram_header tmp;
10661 + /* Regenerate header */
10662 + header->magic = NVRAM_MAGIC;
10663 + header->crc_ver_init = (NVRAM_VERSION << 8);
10664 + if (!(init = BCMINIT(_nvram_get)("sdram_init")) ||
10665 + !(config = BCMINIT(_nvram_get)("sdram_config")) ||
10666 + !(refresh = BCMINIT(_nvram_get)("sdram_refresh")) ||
10667 + !(ncdl = BCMINIT(_nvram_get)("sdram_ncdl"))) {
10668 + header->crc_ver_init |= SDRAM_INIT << 16;
10669 + header->config_refresh = SDRAM_CONFIG;
10670 + header->config_refresh |= SDRAM_REFRESH << 16;
10671 + header->config_ncdl = 0;
10673 + header->crc_ver_init |= (bcm_strtoul(init, NULL, 0) & 0xffff) << 16;
10674 + header->config_refresh = bcm_strtoul(config, NULL, 0) & 0xffff;
10675 + header->config_refresh |= (bcm_strtoul(refresh, NULL, 0) & 0xffff) << 16;
10676 + header->config_ncdl = bcm_strtoul(ncdl, NULL, 0);
10679 + /* Clear data area */
10680 + ptr = (char *) header + sizeof(struct nvram_header);
10681 + bzero(ptr, NVRAM_SPACE - sizeof(struct nvram_header));
10683 + /* Leave space for a double NUL at the end */
10684 + end = (char *) header + NVRAM_SPACE - 2;
10686 + /* Write out all tuples */
10687 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
10688 + for (t = BCMINIT(nvram_hash)[i]; t; t = t->next) {
10689 + if ((ptr + strlen(t->name) + 1 + strlen(t->value) + 1) > end)
10691 + ptr += sprintf(ptr, "%s=%s", t->name, t->value) + 1;
10695 + /* End with a double NUL */
10698 + /* Set new length */
10699 + header->len = ROUNDUP(ptr - (char *) header, 4);
10701 + /* Little-endian CRC8 over the last 11 bytes of the header */
10702 + tmp.crc_ver_init = htol32(header->crc_ver_init);
10703 + tmp.config_refresh = htol32(header->config_refresh);
10704 + tmp.config_ncdl = htol32(header->config_ncdl);
10705 + crc = hndcrc8((char *) &tmp + 9, sizeof(struct nvram_header) - 9, CRC8_INIT_VALUE);
10707 + /* Continue CRC8 over data bytes */
10708 + crc = hndcrc8((char *) &header[1], header->len - sizeof(struct nvram_header), crc);
10710 + /* Set new CRC8 */
10711 + header->crc_ver_init |= crc;
10713 + /* Reinitialize hash table */
10714 + return BCMINIT(nvram_rehash)(header);
10717 +/* Initialize hash table. Should be locked. */
10719 +BCMINITFN(_nvram_init)(void)
10721 + struct nvram_header *header;
10725 + /* get kernel osl handler */
10726 + osh = osl_attach(NULL);
10728 + if (!(header = (struct nvram_header *) MALLOC(osh, NVRAM_SPACE))) {
10729 + printf("nvram_init: out of memory, malloced %d bytes\n", MALLOCED(osh));
10730 + return -12; /* -ENOMEM */
10733 + if ((ret = BCMINIT(_nvram_read)(header)) == 0 &&
10734 + header->magic == NVRAM_MAGIC)
10735 + BCMINIT(nvram_rehash)(header);
10737 + MFREE(osh, header, NVRAM_SPACE);
10741 +/* Free hash table. Should be locked. */
10743 +BCMINITFN(_nvram_exit)(void)
10745 + BCMINIT(nvram_free)();
10747 diff -Nur linux-2.4.32/arch/mips/bcm947xx/nvram_linux.c linux-2.4.32-brcm/arch/mips/bcm947xx/nvram_linux.c
10748 --- linux-2.4.32/arch/mips/bcm947xx/nvram_linux.c 1970-01-01 01:00:00.000000000 +0100
10749 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/nvram_linux.c 2005-12-19 01:09:59.782313000 +0100
10752 + * NVRAM variable manipulation (Linux kernel half)
10754 + * Copyright 2005, Broadcom Corporation
10755 + * All Rights Reserved.
10757 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10758 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10759 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10760 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10764 +#include <linux/config.h>
10765 +#include <linux/init.h>
10766 +#include <linux/module.h>
10767 +#include <linux/kernel.h>
10768 +#include <linux/string.h>
10769 +#include <linux/interrupt.h>
10770 +#include <linux/spinlock.h>
10771 +#include <linux/slab.h>
10772 +#include <linux/bootmem.h>
10773 +#include <linux/wrapper.h>
10774 +#include <linux/fs.h>
10775 +#include <linux/miscdevice.h>
10776 +#include <linux/mtd/mtd.h>
10777 +#include <asm/addrspace.h>
10778 +#include <asm/io.h>
10779 +#include <asm/uaccess.h>
10781 +#include <typedefs.h>
10782 +#include <bcmendian.h>
10783 +#include <bcmnvram.h>
10784 +#include <bcmutils.h>
10785 +#include <sbconfig.h>
10786 +#include <sbchipc.h>
10787 +#include <sbutils.h>
10788 +#include <sbmips.h>
10789 +#include <sflash.h>
10791 +/* In BSS to minimize text size and page aligned so it can be mmap()-ed */
10792 +static char nvram_buf[NVRAM_SPACE] __attribute__((aligned(PAGE_SIZE)));
10796 +#define early_nvram_get(name) nvram_get(name)
10798 +#else /* !MODULE */
10800 +/* Global SB handle */
10801 +extern void *bcm947xx_sbh;
10802 +extern spinlock_t bcm947xx_sbh_lock;
10804 +static int cfe_env;
10805 +extern char *cfe_env_get(char *nv_buf, const char *name);
10808 +#define sbh bcm947xx_sbh
10809 +#define sbh_lock bcm947xx_sbh_lock
10811 +#define MB * 1024 * 1024
10813 +/* Probe for NVRAM header */
10814 +static void __init
10815 +early_nvram_init(void)
10817 + struct nvram_header *header;
10819 + struct sflash *info = NULL;
10821 + uint32 base, off, lim;
10824 + if ((cc = sb_setcore(sbh, SB_CC, 0)) != NULL) {
10825 + base = KSEG1ADDR(SB_FLASH2);
10826 + switch (readl(&cc->capabilities) & CAP_FLASH_MASK) {
10828 + lim = SB_FLASH2_SZ;
10833 + if ((info = sflash_init(cc)) == NULL)
10835 + lim = info->size;
10843 + /* extif assumed, Stop at 4 MB */
10844 + base = KSEG1ADDR(SB_FLASH1);
10845 + lim = SB_FLASH1_SZ;
10848 + /* XXX: hack for supporting the CFE environment stuff on WGT634U */
10849 + src = (u32 *) KSEG1ADDR(base + 8 * 1024 * 1024 - 0x2000);
10850 + dst = (u32 *) nvram_buf;
10851 + if ((lim == 0x02000000) && ((*src & 0xff00ff) == 0x000001)) {
10852 + printk("early_nvram_init: WGT634U NVRAM found.\n");
10854 + for (i = 0; i < 0x1ff0; i++) {
10855 + if (*src == 0xFFFFFFFF)
10864 + while (off <= lim) {
10865 + /* Windowed flash access */
10866 + header = (struct nvram_header *) KSEG1ADDR(base + off - NVRAM_SPACE);
10867 + if (header->magic == NVRAM_MAGIC)
10872 + /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
10873 + header = (struct nvram_header *) KSEG1ADDR(base + 4 KB);
10874 + if (header->magic == NVRAM_MAGIC)
10877 + header = (struct nvram_header *) KSEG1ADDR(base + 1 KB);
10878 + if (header->magic == NVRAM_MAGIC)
10881 + printk("early_nvram_init: NVRAM not found\n");
10885 + src = (u32 *) header;
10886 + dst = (u32 *) nvram_buf;
10887 + for (i = 0; i < sizeof(struct nvram_header); i += 4)
10889 + for (; i < header->len && i < NVRAM_SPACE; i += 4)
10890 + *dst++ = ltoh32(*src++);
10893 +/* Early (before mm or mtd) read-only access to NVRAM */
10894 +static char * __init
10895 +early_nvram_get(const char *name)
10897 + char *var, *value, *end, *eq;
10906 + if (!nvram_buf[0])
10907 + early_nvram_init();
10910 + return cfe_env_get(nvram_buf, name);
10912 + /* Look for name=value and return value */
10913 + var = &nvram_buf[sizeof(struct nvram_header)];
10914 + end = nvram_buf + sizeof(nvram_buf) - 2;
10915 + end[0] = end[1] = '\0';
10916 + for (; *var; var = value + strlen(value) + 1) {
10917 + if (!(eq = strchr(var, '=')))
10920 + if ((eq - var) == strlen(name) && strncmp(var, name, (eq - var)) == 0)
10927 +#endif /* !MODULE */
10929 +extern char * _nvram_get(const char *name);
10930 +extern int _nvram_set(const char *name, const char *value);
10931 +extern int _nvram_unset(const char *name);
10932 +extern int _nvram_getall(char *buf, int count);
10933 +extern int _nvram_commit(struct nvram_header *header);
10934 +extern int _nvram_init(void);
10935 +extern void _nvram_exit(void);
10938 +static spinlock_t nvram_lock = SPIN_LOCK_UNLOCKED;
10939 +static struct semaphore nvram_sem;
10940 +static unsigned long nvram_offset = 0;
10941 +static int nvram_major = -1;
10942 +static devfs_handle_t nvram_handle = NULL;
10943 +static struct mtd_info *nvram_mtd = NULL;
10946 +_nvram_read(char *buf)
10948 + struct nvram_header *header = (struct nvram_header *) buf;
10951 + if (!nvram_mtd ||
10952 + MTD_READ(nvram_mtd, nvram_mtd->size - NVRAM_SPACE, NVRAM_SPACE, &len, buf) ||
10953 + len != NVRAM_SPACE ||
10954 + header->magic != NVRAM_MAGIC) {
10955 + /* Maybe we can recover some data from early initialization */
10956 + memcpy(buf, nvram_buf, NVRAM_SPACE);
10962 +struct nvram_tuple *
10963 +_nvram_realloc(struct nvram_tuple *t, const char *name, const char *value)
10965 + if ((nvram_offset + strlen(value) + 1) > NVRAM_SPACE)
10969 + if (!(t = kmalloc(sizeof(struct nvram_tuple) + strlen(name) + 1, GFP_ATOMIC)))
10973 + t->name = (char *) &t[1];
10974 + strcpy(t->name, name);
10980 + if (!t->value || strcmp(t->value, value)) {
10981 + t->value = &nvram_buf[nvram_offset];
10982 + strcpy(t->value, value);
10983 + nvram_offset += strlen(value) + 1;
10990 +_nvram_free(struct nvram_tuple *t)
10993 + nvram_offset = 0;
10999 +nvram_set(const char *name, const char *value)
11001 + unsigned long flags;
11003 + struct nvram_header *header;
11005 + spin_lock_irqsave(&nvram_lock, flags);
11006 + if ((ret = _nvram_set(name, value))) {
11007 + /* Consolidate space and try again */
11008 + if ((header = kmalloc(NVRAM_SPACE, GFP_ATOMIC))) {
11009 + if (_nvram_commit(header) == 0)
11010 + ret = _nvram_set(name, value);
11014 + spin_unlock_irqrestore(&nvram_lock, flags);
11020 +real_nvram_get(const char *name)
11022 + unsigned long flags;
11025 + spin_lock_irqsave(&nvram_lock, flags);
11026 + value = _nvram_get(name);
11027 + spin_unlock_irqrestore(&nvram_lock, flags);
11033 +nvram_get(const char *name)
11035 + if (nvram_major >= 0)
11036 + return real_nvram_get(name);
11038 + return early_nvram_get(name);
11042 +nvram_unset(const char *name)
11044 + unsigned long flags;
11047 + spin_lock_irqsave(&nvram_lock, flags);
11048 + ret = _nvram_unset(name);
11049 + spin_unlock_irqrestore(&nvram_lock, flags);
11055 +erase_callback(struct erase_info *done)
11057 + wait_queue_head_t *wait_q = (wait_queue_head_t *) done->priv;
11062 +nvram_commit(void)
11065 + size_t erasesize, len;
11068 + struct nvram_header *header;
11069 + unsigned long flags;
11070 + u_int32_t offset;
11071 + DECLARE_WAITQUEUE(wait, current);
11072 + wait_queue_head_t wait_q;
11073 + struct erase_info erase;
11075 + if (!nvram_mtd) {
11076 + printk("nvram_commit: NVRAM not found\n");
11080 + if (in_interrupt()) {
11081 + printk("nvram_commit: not committing in interrupt\n");
11085 + /* Backup sector blocks to be erased */
11086 + erasesize = ROUNDUP(NVRAM_SPACE, nvram_mtd->erasesize);
11087 + if (!(buf = kmalloc(erasesize, GFP_KERNEL))) {
11088 + printk("nvram_commit: out of memory\n");
11092 + down(&nvram_sem);
11094 + if ((i = erasesize - NVRAM_SPACE) > 0) {
11095 + offset = nvram_mtd->size - erasesize;
11097 + ret = MTD_READ(nvram_mtd, offset, i, &len, buf);
11098 + if (ret || len != i) {
11099 + printk("nvram_commit: read error ret = %d, len = %d/%d\n", ret, len, i);
11103 + header = (struct nvram_header *)(buf + i);
11105 + offset = nvram_mtd->size - NVRAM_SPACE;
11106 + header = (struct nvram_header *)buf;
11109 + /* Regenerate NVRAM */
11110 + spin_lock_irqsave(&nvram_lock, flags);
11111 + ret = _nvram_commit(header);
11112 + spin_unlock_irqrestore(&nvram_lock, flags);
11116 + /* Erase sector blocks */
11117 + init_waitqueue_head(&wait_q);
11118 + for (; offset < nvram_mtd->size - NVRAM_SPACE + header->len; offset += nvram_mtd->erasesize) {
11119 + erase.mtd = nvram_mtd;
11120 + erase.addr = offset;
11121 + erase.len = nvram_mtd->erasesize;
11122 + erase.callback = erase_callback;
11123 + erase.priv = (u_long) &wait_q;
11125 + set_current_state(TASK_INTERRUPTIBLE);
11126 + add_wait_queue(&wait_q, &wait);
11128 + /* Unlock sector blocks */
11129 + if (nvram_mtd->unlock)
11130 + nvram_mtd->unlock(nvram_mtd, offset, nvram_mtd->erasesize);
11132 + if ((ret = MTD_ERASE(nvram_mtd, &erase))) {
11133 + set_current_state(TASK_RUNNING);
11134 + remove_wait_queue(&wait_q, &wait);
11135 + printk("nvram_commit: erase error\n");
11139 + /* Wait for erase to finish */
11141 + remove_wait_queue(&wait_q, &wait);
11144 + /* Write partition up to end of data area */
11145 + offset = nvram_mtd->size - erasesize;
11146 + i = erasesize - NVRAM_SPACE + header->len;
11147 + ret = MTD_WRITE(nvram_mtd, offset, i, &len, buf);
11148 + if (ret || len != i) {
11149 + printk("nvram_commit: write error\n");
11154 + offset = nvram_mtd->size - erasesize;
11155 + ret = MTD_READ(nvram_mtd, offset, 4, &len, buf);
11164 +nvram_getall(char *buf, int count)
11166 + unsigned long flags;
11169 + spin_lock_irqsave(&nvram_lock, flags);
11170 + ret = _nvram_getall(buf, count);
11171 + spin_unlock_irqrestore(&nvram_lock, flags);
11176 +EXPORT_SYMBOL(nvram_get);
11177 +EXPORT_SYMBOL(nvram_getall);
11178 +EXPORT_SYMBOL(nvram_set);
11179 +EXPORT_SYMBOL(nvram_unset);
11180 +EXPORT_SYMBOL(nvram_commit);
11182 +/* User mode interface below */
11185 +dev_nvram_read(struct file *file, char *buf, size_t count, loff_t *ppos)
11187 + char tmp[100], *name = tmp, *value;
11189 + unsigned long off;
11191 + if (count > sizeof(tmp)) {
11192 + if (!(name = kmalloc(count, GFP_KERNEL)))
11196 + if (copy_from_user(name, buf, count)) {
11201 + if (*name == '\0') {
11202 + /* Get all variables */
11203 + ret = nvram_getall(name, count);
11205 + if (copy_to_user(buf, name, count)) {
11212 + if (!(value = nvram_get(name))) {
11217 + /* Provide the offset into mmap() space */
11218 + off = (unsigned long) value - (unsigned long) nvram_buf;
11220 + if (put_user(off, (unsigned long *) buf)) {
11225 + ret = sizeof(unsigned long);
11228 + flush_cache_all();
11238 +dev_nvram_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
11240 + char tmp[100], *name = tmp, *value;
11243 + if (count > sizeof(tmp)) {
11244 + if (!(name = kmalloc(count, GFP_KERNEL)))
11248 + if (copy_from_user(name, buf, count)) {
11254 + name = strsep(&value, "=");
11256 + ret = nvram_set(name, value) ? : count;
11258 + ret = nvram_unset(name) ? : count;
11268 +dev_nvram_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
11270 + if (cmd != NVRAM_MAGIC)
11272 + return nvram_commit();
11276 +dev_nvram_mmap(struct file *file, struct vm_area_struct *vma)
11278 + unsigned long offset = virt_to_phys(nvram_buf);
11280 + if (remap_page_range(vma->vm_start, offset, vma->vm_end-vma->vm_start,
11281 + vma->vm_page_prot))
11288 +dev_nvram_open(struct inode *inode, struct file * file)
11290 + MOD_INC_USE_COUNT;
11295 +dev_nvram_release(struct inode *inode, struct file * file)
11297 + MOD_DEC_USE_COUNT;
11301 +static struct file_operations dev_nvram_fops = {
11302 + owner: THIS_MODULE,
11303 + open: dev_nvram_open,
11304 + release: dev_nvram_release,
11305 + read: dev_nvram_read,
11306 + write: dev_nvram_write,
11307 + ioctl: dev_nvram_ioctl,
11308 + mmap: dev_nvram_mmap,
11312 +dev_nvram_exit(void)
11315 + struct page *page, *end;
11317 + if (nvram_handle)
11318 + devfs_unregister(nvram_handle);
11320 + if (nvram_major >= 0)
11321 + devfs_unregister_chrdev(nvram_major, "nvram");
11324 + put_mtd_device(nvram_mtd);
11326 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
11328 + end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
11329 + for (page = virt_to_page(nvram_buf); page <= end; page++)
11330 + mem_map_unreserve(page);
11336 +dev_nvram_init(void)
11338 + int order = 0, ret = 0;
11339 + struct page *page, *end;
11342 + /* Allocate and reserve memory to mmap() */
11343 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
11345 + end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
11346 + for (page = virt_to_page(nvram_buf); page <= end; page++)
11347 + mem_map_reserve(page);
11350 + /* Find associated MTD device */
11351 + for (i = 0; i < MAX_MTD_DEVICES; i++) {
11352 + nvram_mtd = get_mtd_device(NULL, i);
11354 + if (!strcmp(nvram_mtd->name, "nvram") &&
11355 + nvram_mtd->size >= NVRAM_SPACE)
11357 + put_mtd_device(nvram_mtd);
11360 + if (i >= MAX_MTD_DEVICES)
11361 + nvram_mtd = NULL;
11364 + /* Initialize hash table lock */
11365 + spin_lock_init(&nvram_lock);
11367 + /* Initialize commit semaphore */
11368 + init_MUTEX(&nvram_sem);
11370 + /* Register char device */
11371 + if ((nvram_major = devfs_register_chrdev(0, "nvram", &dev_nvram_fops)) < 0) {
11372 + ret = nvram_major;
11376 + /* Initialize hash table */
11379 + /* Create /dev/nvram handle */
11380 + nvram_handle = devfs_register(NULL, "nvram", DEVFS_FL_NONE, nvram_major, 0,
11381 + S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, &dev_nvram_fops, NULL);
11383 + /* Set the SDRAM NCDL value into NVRAM if not already done */
11384 + if (getintvar(NULL, "sdram_ncdl") == 0) {
11385 + unsigned int ncdl;
11386 + char buf[] = "0x00000000";
11388 + if ((ncdl = sb_memc_get_ncdl(sbh))) {
11389 + sprintf(buf, "0x%08x", ncdl);
11390 + nvram_set("sdram_ncdl", buf);
11398 + dev_nvram_exit();
11402 +module_init(dev_nvram_init);
11403 +module_exit(dev_nvram_exit);
11404 diff -Nur linux-2.4.32/arch/mips/bcm947xx/pcibios.c linux-2.4.32-brcm/arch/mips/bcm947xx/pcibios.c
11405 --- linux-2.4.32/arch/mips/bcm947xx/pcibios.c 1970-01-01 01:00:00.000000000 +0100
11406 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/pcibios.c 2005-12-16 23:39:10.944836750 +0100
11409 + * Low-Level PCI and SB support for BCM47xx (Linux support code)
11411 + * Copyright 2005, Broadcom Corporation
11412 + * All Rights Reserved.
11414 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
11415 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11416 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11417 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11422 +#include <linux/config.h>
11423 +#include <linux/types.h>
11424 +#include <linux/kernel.h>
11425 +#include <linux/sched.h>
11426 +#include <linux/pci.h>
11427 +#include <linux/init.h>
11428 +#include <linux/delay.h>
11429 +#include <asm/io.h>
11430 +#include <asm/irq.h>
11431 +#include <asm/paccess.h>
11433 +#include <typedefs.h>
11434 +#include <bcmutils.h>
11435 +#include <sbconfig.h>
11436 +#include <sbutils.h>
11437 +#include <sbpci.h>
11438 +#include <pcicfg.h>
11439 +#include <bcmdevs.h>
11440 +#include <bcmnvram.h>
11442 +/* Global SB handle */
11443 +extern sb_t *bcm947xx_sbh;
11444 +extern spinlock_t bcm947xx_sbh_lock;
11447 +#define sbh bcm947xx_sbh
11448 +#define sbh_lock bcm947xx_sbh_lock
11451 +sbpci_read_config_byte(struct pci_dev *dev, int where, u8 *value)
11453 + unsigned long flags;
11456 + spin_lock_irqsave(&sbh_lock, flags);
11457 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
11458 + spin_unlock_irqrestore(&sbh_lock, flags);
11459 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11463 +sbpci_read_config_word(struct pci_dev *dev, int where, u16 *value)
11465 + unsigned long flags;
11468 + spin_lock_irqsave(&sbh_lock, flags);
11469 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
11470 + spin_unlock_irqrestore(&sbh_lock, flags);
11471 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11475 +sbpci_read_config_dword(struct pci_dev *dev, int where, u32 *value)
11477 + unsigned long flags;
11480 + spin_lock_irqsave(&sbh_lock, flags);
11481 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value));
11482 + spin_unlock_irqrestore(&sbh_lock, flags);
11483 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11487 +sbpci_write_config_byte(struct pci_dev *dev, int where, u8 value)
11489 + unsigned long flags;
11492 + spin_lock_irqsave(&sbh_lock, flags);
11493 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
11494 + spin_unlock_irqrestore(&sbh_lock, flags);
11495 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11499 +sbpci_write_config_word(struct pci_dev *dev, int where, u16 value)
11501 + unsigned long flags;
11504 + spin_lock_irqsave(&sbh_lock, flags);
11505 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
11506 + spin_unlock_irqrestore(&sbh_lock, flags);
11507 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11511 +sbpci_write_config_dword(struct pci_dev *dev, int where, u32 value)
11513 + unsigned long flags;
11516 + spin_lock_irqsave(&sbh_lock, flags);
11517 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value));
11518 + spin_unlock_irqrestore(&sbh_lock, flags);
11519 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11522 +static struct pci_ops pcibios_ops = {
11523 + sbpci_read_config_byte,
11524 + sbpci_read_config_word,
11525 + sbpci_read_config_dword,
11526 + sbpci_write_config_byte,
11527 + sbpci_write_config_word,
11528 + sbpci_write_config_dword
11533 +pcibios_init(void)
11537 + if (!(sbh = sb_kattach()))
11538 + panic("sb_kattach failed");
11539 + spin_lock_init(&sbh_lock);
11541 + spin_lock_irqsave(&sbh_lock, flags);
11543 + spin_unlock_irqrestore(&sbh_lock, flags);
11545 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
11547 + mdelay(300); //By Joey for Atheros Card
11549 + /* Scan the SB bus */
11550 + pci_scan_bus(0, &pcibios_ops, NULL);
11555 +pcibios_setup(char *str)
11557 + if (!strncmp(str, "ban=", 4)) {
11558 + sbpci_ban(simple_strtoul(str + 4, NULL, 0));
11565 +static u32 pci_iobase = 0x100;
11566 +static u32 pci_membase = SB_PCI_DMA;
11569 +pcibios_fixup_bus(struct pci_bus *b)
11571 + struct list_head *ln;
11572 + struct pci_dev *d;
11573 + struct resource *res;
11578 + printk("PCI: Fixing up bus %d\n", b->number);
11581 + if (b->number == 0) {
11582 + for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
11583 + d = pci_dev_b(ln);
11584 + /* Fix up interrupt lines */
11585 + pci_read_config_byte(d, PCI_INTERRUPT_LINE, &irq);
11586 + d->irq = irq + 2;
11587 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
11591 + /* Fix up external PCI */
11593 + for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
11594 + d = pci_dev_b(ln);
11595 + /* Fix up resource bases */
11596 + for (pos = 0; pos < 6; pos++) {
11597 + res = &d->resource[pos];
11598 + base = (res->flags & IORESOURCE_IO) ? &pci_iobase : &pci_membase;
11600 + size = res->end - res->start + 1;
11601 + if (*base & (size - 1))
11602 + *base = (*base + size) & ~(size - 1);
11603 + res->start = *base;
11604 + res->end = res->start + size - 1;
11606 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
11608 + /* Fix up PCI bridge BAR0 only */
11609 + if (b->number == 1 && PCI_SLOT(d->devfn) == 0)
11612 + /* Fix up interrupt lines */
11613 + if (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))
11614 + d->irq = (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))->irq;
11615 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
11621 +pcibios_assign_all_busses(void)
11627 +pcibios_align_resource(void *data, struct resource *res,
11628 + unsigned long size, unsigned long align)
11633 +pcibios_enable_resources(struct pci_dev *dev)
11635 + u16 cmd, old_cmd;
11637 + struct resource *r;
11639 + /* External PCI only */
11640 + if (dev->bus->number == 0)
11643 + pci_read_config_word(dev, PCI_COMMAND, &cmd);
11645 + for(idx=0; idx<6; idx++) {
11646 + r = &dev->resource[idx];
11647 + if (r->flags & IORESOURCE_IO)
11648 + cmd |= PCI_COMMAND_IO;
11649 + if (r->flags & IORESOURCE_MEM)
11650 + cmd |= PCI_COMMAND_MEMORY;
11652 + if (dev->resource[PCI_ROM_RESOURCE].start)
11653 + cmd |= PCI_COMMAND_MEMORY;
11654 + if (cmd != old_cmd) {
11655 + printk("PCI: Enabling device %s (%04x -> %04x)\n", dev->slot_name, old_cmd, cmd);
11656 + pci_write_config_word(dev, PCI_COMMAND, cmd);
11662 +pcibios_enable_device(struct pci_dev *dev, int mask)
11667 + /* External PCI device enable */
11668 + if (dev->bus->number != 0)
11669 + return pcibios_enable_resources(dev);
11671 + /* These cores come out of reset enabled */
11672 + if (dev->device == SB_MIPS ||
11673 + dev->device == SB_MIPS33 ||
11674 + dev->device == SB_EXTIF ||
11675 + dev->device == SB_CC)
11678 + spin_lock_irqsave(&sbh_lock, flags);
11679 + coreidx = sb_coreidx(sbh);
11680 + if (!sb_setcoreidx(sbh, PCI_SLOT(dev->devfn)))
11681 + return PCIBIOS_DEVICE_NOT_FOUND;
11684 + * The USB core requires a special bit to be set during core
11685 + * reset to enable host (OHCI) mode. Resetting the SB core in
11686 + * pcibios_enable_device() is a hack for compatibility with
11687 + * vanilla usb-ohci so that it does not have to know about
11688 + * SB. A driver that wants to use the USB core in device mode
11689 + * should know about SB and should reset the bit back to 0
11690 + * after calling pcibios_enable_device().
11692 + if (sb_coreid(sbh) == SB_USB) {
11693 + sb_core_disable(sbh, sb_coreflags(sbh, 0, 0));
11694 + sb_core_reset(sbh, 1 << 29);
11696 + sb_core_reset(sbh, 0);
11698 + sb_setcoreidx(sbh, coreidx);
11699 + spin_unlock_irqrestore(&sbh_lock, flags);
11705 +pcibios_update_resource(struct pci_dev *dev, struct resource *root,
11706 + struct resource *res, int resource)
11708 + unsigned long where, size;
11711 + /* External PCI only */
11712 + if (dev->bus->number == 0)
11715 + where = PCI_BASE_ADDRESS_0 + (resource * 4);
11716 + size = res->end - res->start;
11717 + pci_read_config_dword(dev, where, ®);
11718 + reg = (reg & size) | (((u32)(res->start - root->start)) & ~size);
11719 + pci_write_config_dword(dev, where, reg);
11722 +static void __init
11723 +quirk_sbpci_bridge(struct pci_dev *dev)
11725 + if (dev->bus->number != 1 || PCI_SLOT(dev->devfn) != 0)
11728 + printk("PCI: Fixing up bridge\n");
11730 + /* Enable PCI bridge bus mastering and memory space */
11731 + pci_set_master(dev);
11732 + pcibios_enable_resources(dev);
11734 + /* Enable PCI bridge BAR1 prefetch and burst */
11735 + pci_write_config_dword(dev, PCI_BAR1_CONTROL, 3);
11738 +struct pci_fixup pcibios_fixups[] = {
11739 + { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, quirk_sbpci_bridge },
11744 + * If we set up a device for bus mastering, we need to check the latency
11745 + * timer as certain crappy BIOSes forget to set it properly.
11747 +unsigned int pcibios_max_latency = 255;
11749 +void pcibios_set_master(struct pci_dev *dev)
11752 + pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
11754 + lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
11755 + else if (lat > pcibios_max_latency)
11756 + lat = pcibios_max_latency;
11759 + printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", dev->slot_name, lat);
11760 + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
11763 diff -Nur linux-2.4.32/arch/mips/bcm947xx/prom.c linux-2.4.32-brcm/arch/mips/bcm947xx/prom.c
11764 --- linux-2.4.32/arch/mips/bcm947xx/prom.c 1970-01-01 01:00:00.000000000 +0100
11765 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/prom.c 2005-12-16 23:39:10.944836750 +0100
11768 + * Early initialization code for BCM94710 boards
11770 + * Copyright 2004, Broadcom Corporation
11771 + * All Rights Reserved.
11773 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
11774 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11775 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11776 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11778 + * $Id: prom.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
11781 +#include <linux/config.h>
11782 +#include <linux/init.h>
11783 +#include <linux/kernel.h>
11784 +#include <linux/types.h>
11785 +#include <asm/bootinfo.h>
11788 +prom_init(int argc, const char **argv)
11790 + unsigned long mem;
11792 + mips_machgroup = MACH_GROUP_BRCM;
11793 + mips_machtype = MACH_BCM947XX;
11795 + /* Figure out memory size by finding aliases */
11796 + for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
11797 + if (*(unsigned long *)((unsigned long)(prom_init) + mem) ==
11798 + *(unsigned long *)(prom_init))
11801 + add_memory_region(0, mem, BOOT_MEM_RAM);
11805 +prom_free_prom_memory(void)
11808 diff -Nur linux-2.4.32/arch/mips/bcm947xx/sbmips.c linux-2.4.32-brcm/arch/mips/bcm947xx/sbmips.c
11809 --- linux-2.4.32/arch/mips/bcm947xx/sbmips.c 1970-01-01 01:00:00.000000000 +0100
11810 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/sbmips.c 2005-12-16 23:39:10.944836750 +0100
11813 + * BCM47XX Sonics SiliconBackplane MIPS core routines
11815 + * Copyright 2005, Broadcom Corporation
11816 + * All Rights Reserved.
11818 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
11819 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11820 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11821 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11826 +#include <typedefs.h>
11828 +#include <sbutils.h>
11829 +#include <bcmdevs.h>
11830 +#include <bcmnvram.h>
11831 +#include <bcmutils.h>
11832 +#include <hndmips.h>
11833 +#include <sbconfig.h>
11834 +#include <sbextif.h>
11835 +#include <sbchipc.h>
11836 +#include <sbmemc.h>
11837 +#include <mipsinc.h>
11838 +#include <sbutils.h>
11841 + * Returns TRUE if an external UART exists at the given base
11845 +BCMINITFN(serial_exists)(uint8 *regs)
11847 + uint8 save_mcr, status1;
11849 + save_mcr = R_REG(®s[UART_MCR]);
11850 + W_REG(®s[UART_MCR], UART_MCR_LOOP | 0x0a);
11851 + status1 = R_REG(®s[UART_MSR]) & 0xf0;
11852 + W_REG(®s[UART_MCR], save_mcr);
11854 + return (status1 == 0x90);
11858 + * Initializes UART access. The callback function will be called once
11859 + * per found UART.
11862 +BCMINITFN(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift))
11869 + if ((regs = sb_setcore(sbh, SB_EXTIF, 0))) {
11870 + extifregs_t *eir = (extifregs_t *) regs;
11873 + /* Determine external UART register base */
11874 + sb = (sbconfig_t *)((ulong) eir + SBCONFIGOFF);
11875 + base = EXTIF_CFGIF_BASE(sb_base(R_REG(&sb->sbadmatch1)));
11877 + /* Determine IRQ */
11878 + irq = sb_irq(sbh);
11880 + /* Disable GPIO interrupt initially */
11881 + W_REG(&eir->gpiointpolarity, 0);
11882 + W_REG(&eir->gpiointmask, 0);
11884 + /* Search for external UARTs */
11886 + for (i = 0; i < 2; i++) {
11887 + regs = (void *) REG_MAP(base + (i * 8), 8);
11888 + if (BCMINIT(serial_exists)(regs)) {
11889 + /* Set GPIO 1 to be the external UART IRQ */
11890 + W_REG(&eir->gpiointmask, 2);
11892 + add(regs, irq, 13500000, 0);
11896 + /* Add internal UART if enabled */
11897 + if (R_REG(&eir->corecontrol) & CC_UE)
11899 + add((void *) &eir->uartdata, irq, sb_clock(sbh), 2);
11900 + } else if ((regs = sb_setcore(sbh, SB_CC, 0))) {
11901 + chipcregs_t *cc = (chipcregs_t *) regs;
11902 + uint32 rev, cap, pll, baud_base, div;
11904 + /* Determine core revision and capabilities */
11905 + rev = sb_corerev(sbh);
11906 + cap = R_REG(&cc->capabilities);
11907 + pll = cap & CAP_PLL_MASK;
11909 + /* Determine IRQ */
11910 + irq = sb_irq(sbh);
11912 + if (pll == PLL_TYPE1) {
11914 + baud_base = sb_clock_rate(pll,
11915 + R_REG(&cc->clockcontrol_n),
11916 + R_REG(&cc->clockcontrol_m2));
11920 + /* Fixed ALP clock */
11921 + baud_base = 20000000;
11923 + /* Set the override bit so we don't divide it */
11924 + W_REG(&cc->corecontrol, CC_UARTCLKO);
11925 + } else if (rev >= 3) {
11926 + /* Internal backplane clock */
11927 + baud_base = sb_clock(sbh);
11928 + div = 2; /* Minimum divisor */
11929 + W_REG(&cc->clkdiv,
11930 + ((R_REG(&cc->clkdiv) & ~CLKD_UART) | div));
11932 + /* Fixed internal backplane clock */
11933 + baud_base = 88000000;
11937 + /* Clock source depends on strapping if UartClkOverride is unset */
11939 + ((R_REG(&cc->corecontrol) & CC_UARTCLKO) == 0)) {
11940 + if ((cap & CAP_UCLKSEL) == CAP_UINTCLK) {
11941 + /* Internal divided backplane clock */
11942 + baud_base /= div;
11944 + /* Assume external clock of 1.8432 MHz */
11945 + baud_base = 1843200;
11950 + /* Add internal UARTs */
11951 + n = cap & CAP_UARTS_MASK;
11952 + for (i = 0; i < n; i++) {
11953 + /* Register offset changed after revision 0 */
11955 + regs = (void *)((ulong) &cc->uart0data + (i * 256));
11957 + regs = (void *)((ulong) &cc->uart0data + (i * 8));
11960 + add(regs, irq, baud_base, 0);
11966 + * Initialize jtag master and return handle for
11967 + * jtag_rwreg. Returns NULL on failure.
11970 +sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap)
11974 + if ((regs = sb_setcore(sbh, SB_CC, 0)) != NULL) {
11975 + chipcregs_t *cc = (chipcregs_t *) regs;
11979 + * Determine jtagm availability from
11980 + * core revision and capabilities.
11982 + tmp = sb_corerev(sbh);
11984 + * Corerev 10 has jtagm, but the only chip
11985 + * with it does not have a mips, and
11986 + * the layout of the jtagcmd register is
11987 + * different. We'll only accept >= 11.
11992 + tmp = R_REG(&cc->capabilities);
11993 + if ((tmp & CAP_JTAGP) == 0)
11996 + /* Set clock divider if requested */
11998 + tmp = R_REG(&cc->clkdiv);
11999 + tmp = (tmp & ~CLKD_JTAG) |
12000 + ((clkd << CLKD_JTAG_SHIFT) & CLKD_JTAG);
12001 + W_REG(&cc->clkdiv, tmp);
12004 + /* Enable jtagm */
12005 + tmp = JCTRL_EN | (exttap ? JCTRL_EXT_EN : 0);
12006 + W_REG(&cc->jtagctrl, tmp);
12013 +sb_jtagm_disable(void *h)
12015 + chipcregs_t *cc = (chipcregs_t *)h;
12017 + W_REG(&cc->jtagctrl, R_REG(&cc->jtagctrl) & ~JCTRL_EN);
12021 + * Read/write a jtag register. Assumes a target with
12022 + * 8 bit IR and 32 bit DR.
12025 +#define DRWIDTH 32
12027 +jtag_rwreg(void *h, uint32 ir, uint32 dr)
12029 + chipcregs_t *cc = (chipcregs_t *) h;
12032 + W_REG(&cc->jtagir, ir);
12033 + W_REG(&cc->jtagdr, dr);
12034 + tmp = JCMD_START | JCMD_ACC_IRDR |
12035 + ((IRWIDTH - 1) << JCMD_IRW_SHIFT) |
12037 + W_REG(&cc->jtagcmd, tmp);
12038 + while (((tmp = R_REG(&cc->jtagcmd)) & JCMD_BUSY) == JCMD_BUSY) {
12039 + /* OSL_DELAY(1); */
12042 + tmp = R_REG(&cc->jtagdr);
12046 +/* Returns the SB interrupt flag of the current core. */
12048 +sb_flag(sb_t *sbh)
12053 + regs = sb_coreregs(sbh);
12054 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12056 + return (R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK);
12059 +static const uint32 sbips_int_mask[] = {
12067 +static const uint32 sbips_int_shift[] = {
12070 + SBIPS_INT2_SHIFT,
12071 + SBIPS_INT3_SHIFT,
12076 + * Returns the MIPS IRQ assignment of the current core. If unassigned,
12085 + uint32 flag, sbipsflag;
12088 + flag = sb_flag(sbh);
12090 + idx = sb_coreidx(sbh);
12092 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
12093 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
12094 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12096 + /* sbipsflag specifies which core is routed to interrupts 1 to 4 */
12097 + sbipsflag = R_REG(&sb->sbipsflag);
12098 + for (irq = 1; irq <= 4; irq++) {
12099 + if (((sbipsflag & sbips_int_mask[irq]) >> sbips_int_shift[irq]) == flag)
12106 + sb_setcoreidx(sbh, idx);
12111 +/* Clears the specified MIPS IRQ. */
12113 +BCMINITFN(sb_clearirq)(sb_t *sbh, uint irq)
12118 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
12119 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
12121 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12124 + W_REG(&sb->sbintvec, 0);
12126 + OR_REG(&sb->sbipsflag, sbips_int_mask[irq]);
12130 + * Assigns the specified MIPS IRQ to the specified core. Shared MIPS
12131 + * IRQ 0 may be assigned more than once.
12134 +BCMINITFN(sb_setirq)(sb_t *sbh, uint irq, uint coreid, uint coreunit)
12140 + regs = sb_setcore(sbh, coreid, coreunit);
12142 + flag = sb_flag(sbh);
12144 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
12145 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
12147 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12150 + OR_REG(&sb->sbintvec, 1 << flag);
12152 + flag <<= sbips_int_shift[irq];
12153 + ASSERT(!(flag & ~sbips_int_mask[irq]));
12154 + flag |= R_REG(&sb->sbipsflag) & ~sbips_int_mask[irq];
12155 + W_REG(&sb->sbipsflag, flag);
12160 + * Initializes clocks and interrupts. SB and NVRAM access must be
12161 + * initialized prior to calling.
12164 +BCMINITFN(sb_mips_init)(sb_t *sbh)
12166 + ulong hz, ns, tmp;
12167 + extifregs_t *eir;
12172 + /* Figure out current SB clock speed */
12173 + if ((hz = sb_clock(sbh)) == 0)
12175 + ns = 1000000000 / hz;
12177 + /* Setup external interface timing */
12178 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
12179 + /* Initialize extif so we can get to the LEDs and external UART */
12180 + W_REG(&eir->prog_config, CF_EN);
12182 + /* Set timing for the flash */
12183 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
12184 + tmp = tmp | (CEIL(40, ns) << FW_W1_SHIFT); /* W1 = 40nS */
12185 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
12186 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
12188 + /* Set programmable interface timing for external uart */
12189 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
12190 + tmp = tmp | (CEIL(20, ns) << FW_W2_SHIFT); /* W2 = 20nS */
12191 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */
12192 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
12193 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
12194 + } else if ((cc = sb_setcore(sbh, SB_CC, 0))) {
12195 + /* Set timing for the flash */
12196 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
12197 + tmp |= CEIL(10, ns) << FW_W1_SHIFT; /* W1 = 10nS */
12198 + tmp |= CEIL(120, ns); /* W0 = 120nS */
12200 + // Added by Chen-I for 5365
12201 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
12203 + W_REG(&cc->flash_waitcount, tmp);
12204 + W_REG(&cc->pcmcia_memwait, tmp);
12208 + if (sb_corerev(sbh) < 9)
12209 + W_REG(&cc->flash_waitcount, tmp);
12211 + if ((sb_corerev(sbh) < 9) ||
12212 + ((BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID) && BCMINIT(sb_chiprev)(sbh) == 0)) {
12213 + W_REG(&cc->pcmcia_memwait, tmp);
12218 + /* Chip specific initialization */
12219 + switch (BCMINIT(sb_chip)(sbh)) {
12220 + case BCM4710_DEVICE_ID:
12221 + /* Clear interrupt map */
12222 + for (irq = 0; irq <= 4; irq++)
12223 + BCMINIT(sb_clearirq)(sbh, irq);
12224 + BCMINIT(sb_setirq)(sbh, 0, SB_CODEC, 0);
12225 + BCMINIT(sb_setirq)(sbh, 0, SB_EXTIF, 0);
12226 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 1);
12227 + BCMINIT(sb_setirq)(sbh, 3, SB_ILINE20, 0);
12228 + BCMINIT(sb_setirq)(sbh, 4, SB_PCI, 0);
12230 + value = BCMINIT(nvram_get)("et0phyaddr");
12231 + if (value && !strcmp(value, "31")) {
12232 + /* Enable internal UART */
12233 + W_REG(&eir->corecontrol, CC_UE);
12234 + /* Give USB its own interrupt */
12235 + BCMINIT(sb_setirq)(sbh, 1, SB_USB, 0);
12237 + /* Disable internal UART */
12238 + W_REG(&eir->corecontrol, 0);
12239 + /* Give Ethernet its own interrupt */
12240 + BCMINIT(sb_setirq)(sbh, 1, SB_ENET, 0);
12241 + BCMINIT(sb_setirq)(sbh, 0, SB_USB, 0);
12244 + case BCM5350_DEVICE_ID:
12245 + /* Clear interrupt map */
12246 + for (irq = 0; irq <= 4; irq++)
12247 + BCMINIT(sb_clearirq)(sbh, irq);
12248 + BCMINIT(sb_setirq)(sbh, 0, SB_CC, 0);
12249 + BCMINIT(sb_setirq)(sbh, 1, SB_D11, 0);
12250 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 0);
12251 + BCMINIT(sb_setirq)(sbh, 3, SB_PCI, 0);
12252 + BCMINIT(sb_setirq)(sbh, 4, SB_USB, 0);
12258 +BCMINITFN(sb_mips_clock)(sb_t *sbh)
12260 + extifregs_t *eir;
12264 + uint32 pll_type, rate = 0;
12266 + /* get index of the current core */
12267 + idx = sb_coreidx(sbh);
12268 + pll_type = PLL_TYPE1;
12270 + /* switch to extif or chipc core */
12271 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
12272 + n = R_REG(&eir->clockcontrol_n);
12273 + m = R_REG(&eir->clockcontrol_sb);
12274 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
12275 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
12276 + n = R_REG(&cc->clockcontrol_n);
12277 + if ((pll_type == PLL_TYPE2) ||
12278 + (pll_type == PLL_TYPE4) ||
12279 + (pll_type == PLL_TYPE6) ||
12280 + (pll_type == PLL_TYPE7))
12281 + m = R_REG(&cc->clockcontrol_mips);
12282 + else if (pll_type == PLL_TYPE5) {
12283 + rate = 200000000;
12286 + else if (pll_type == PLL_TYPE3) {
12287 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) { /* 5365 is also type3 */
12288 + rate = 200000000;
12291 + m = R_REG(&cc->clockcontrol_m2); /* 5350 uses m2 to control mips */
12293 + m = R_REG(&cc->clockcontrol_sb);
12297 + // Added by Chen-I for 5365
12298 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
12299 + rate = 100000000;
12301 + /* calculate rate */
12302 + rate = sb_clock_rate(pll_type, n, m);
12304 + if (pll_type == PLL_TYPE6)
12305 + rate = SB2MIPS_T6(rate);
12308 + /* switch back to previous core */
12309 + sb_setcoreidx(sbh, idx);
12314 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
12317 +BCMINITFN(handler)(void)
12321 + ".set\tmips32\n\t"
12324 + /* Disable interrupts */
12325 + /* MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~(ALLINTS | STO_IE)); */
12326 + "mfc0 $15, $12\n\t"
12327 + /* Just a Hack to not to use reg 'at' which was causing problems on 4704 A2 */
12328 + "li $14, -31746\n\t"
12329 + "and $15, $15, $14\n\t"
12330 + "mtc0 $15, $12\n\t"
12338 +/* The following MUST come right after handler() */
12340 +BCMINITFN(afterhandler)(void)
12345 + * Set the MIPS, backplane and PCI clocks as closely as possible.
12348 +BCMINITFN(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock)
12350 + extifregs_t *eir = NULL;
12351 + chipcregs_t *cc = NULL;
12352 + mipsregs_t *mipsr = NULL;
12353 + volatile uint32 *clockcontrol_n, *clockcontrol_sb, *clockcontrol_pci, *clockcontrol_m2;
12354 + uint32 orig_n, orig_sb, orig_pci, orig_m2, orig_mips, orig_ratio_parm, orig_ratio_cfg;
12355 + uint32 pll_type, sync_mode;
12356 + uint ic_size, ic_lsize;
12359 + uint32 mipsclock;
12365 + static n3m_table_t BCMINITDATA(type1_table)[] = {
12366 + { 96000000, 0x0303, 0x04020011, 0x11030011, 0x11050011 }, /* 96.000 32.000 24.000 */
12367 + { 100000000, 0x0009, 0x04020011, 0x11030011, 0x11050011 }, /* 100.000 33.333 25.000 */
12368 + { 104000000, 0x0802, 0x04020011, 0x11050009, 0x11090009 }, /* 104.000 31.200 24.960 */
12369 + { 108000000, 0x0403, 0x04020011, 0x11050009, 0x02000802 }, /* 108.000 32.400 24.923 */
12370 + { 112000000, 0x0205, 0x04020011, 0x11030021, 0x02000403 }, /* 112.000 32.000 24.889 */
12371 + { 115200000, 0x0303, 0x04020009, 0x11030011, 0x11050011 }, /* 115.200 32.000 24.000 */
12372 + { 120000000, 0x0011, 0x04020011, 0x11050011, 0x11090011 }, /* 120.000 30.000 24.000 */
12373 + { 124800000, 0x0802, 0x04020009, 0x11050009, 0x11090009 }, /* 124.800 31.200 24.960 */
12374 + { 128000000, 0x0305, 0x04020011, 0x11050011, 0x02000305 }, /* 128.000 32.000 24.000 */
12375 + { 132000000, 0x0603, 0x04020011, 0x11050011, 0x02000305 }, /* 132.000 33.000 24.750 */
12376 + { 136000000, 0x0c02, 0x04020011, 0x11090009, 0x02000603 }, /* 136.000 32.640 24.727 */
12377 + { 140000000, 0x0021, 0x04020011, 0x11050021, 0x02000c02 }, /* 140.000 30.000 24.706 */
12378 + { 144000000, 0x0405, 0x04020011, 0x01020202, 0x11090021 }, /* 144.000 30.857 24.686 */
12379 + { 150857142, 0x0605, 0x04020021, 0x02000305, 0x02000605 }, /* 150.857 33.000 24.000 */
12380 + { 152000000, 0x0e02, 0x04020011, 0x11050021, 0x02000e02 }, /* 152.000 32.571 24.000 */
12381 + { 156000000, 0x0802, 0x04020005, 0x11050009, 0x11090009 }, /* 156.000 31.200 24.960 */
12382 + { 160000000, 0x0309, 0x04020011, 0x11090011, 0x02000309 }, /* 160.000 32.000 24.000 */
12383 + { 163200000, 0x0c02, 0x04020009, 0x11090009, 0x02000603 }, /* 163.200 32.640 24.727 */
12384 + { 168000000, 0x0205, 0x04020005, 0x11030021, 0x02000403 }, /* 168.000 32.000 24.889 */
12385 + { 176000000, 0x0602, 0x04020003, 0x11050005, 0x02000602 }, /* 176.000 33.000 24.000 */
12388 + uint32 mipsclock;
12390 + uint32 m2; /* that is the clockcontrol_m2 */
12392 + static type3_table_t type3_table[] = { /* for 5350, mips clock is always double sb clock */
12393 + { 150000000, 0x311, 0x4020005 },
12394 + { 200000000, 0x311, 0x4020003 },
12397 + uint32 mipsclock;
12404 + uint32 ratio_cfg;
12405 + uint32 ratio_parm;
12408 + static n4m_table_t BCMINITDATA(type2_table)[] = {
12409 + { 180000000, 80000000, 0x0403, 0x01010000, 0x01020300, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12410 + { 180000000, 90000000, 0x0403, 0x01000100, 0x01020300, 0x01000100, 0x05000100, 11, 0x0aaa0555 },
12411 + { 200000000, 100000000, 0x0303, 0x02010000, 0x02040001, 0x02010000, 0x06000001, 11, 0x0aaa0555 },
12412 + { 211200000, 105600000, 0x0902, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12413 + { 220800000, 110400000, 0x1500, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12414 + { 230400000, 115200000, 0x0604, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12415 + { 234000000, 104000000, 0x0b01, 0x01010000, 0x01010700, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12416 + { 240000000, 120000000, 0x0803, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12417 + { 252000000, 126000000, 0x0504, 0x01000100, 0x01020500, 0x01000100, 0x05000100, 11, 0x0aaa0555 },
12418 + { 264000000, 132000000, 0x0903, 0x01000200, 0x01020700, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
12419 + { 270000000, 120000000, 0x0703, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12420 + { 276000000, 122666666, 0x1500, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12421 + { 280000000, 140000000, 0x0503, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 },
12422 + { 288000000, 128000000, 0x0604, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12423 + { 288000000, 144000000, 0x0404, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 },
12424 + { 300000000, 133333333, 0x0803, 0x01010000, 0x01020600, 0x01020600, 0x05000100, 8, 0x012a00a9 },
12425 + { 300000000, 150000000, 0x0803, 0x01000100, 0x01020600, 0x01000100, 0x05000100, 11, 0x0aaa0555 }
12428 + static n4m_table_t BCMINITDATA(type4_table)[] = {
12429 + { 192000000, 96000000, 0x0702, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
12430 + { 198000000, 99000000, 0x0603, 0x11020005, 0x11030011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12431 + { 200000000, 100000000, 0x0009, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 },
12432 + { 204000000, 102000000, 0x0c02, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12433 + { 208000000, 104000000, 0x0802, 0x11030002, 0x11090005, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
12434 + { 210000000, 105000000, 0x0209, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12435 + { 216000000, 108000000, 0x0111, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12436 + { 224000000, 112000000, 0x0205, 0x11030002, 0x02002103, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
12437 + { 228000000, 101333333, 0x0e02, 0x11030003, 0x11210005, 0x01030305, 0x04000005, 8, 0x012a00a9 },
12438 + { 228000000, 114000000, 0x0e02, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12439 + { 240000000, 102857143, 0x0109, 0x04000021, 0x01050203, 0x11030021, 0x04000003, 13, 0x254a14a9 },
12440 + { 240000000, 120000000, 0x0109, 0x11030002, 0x01050203, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
12441 + { 252000000, 100800000, 0x0203, 0x04000009, 0x11050005, 0x02000209, 0x04000002, 9, 0x02520129 },
12442 + { 252000000, 126000000, 0x0203, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 },
12443 + { 264000000, 132000000, 0x0602, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 },
12444 + { 272000000, 116571428, 0x0c02, 0x04000021, 0x02000909, 0x02000221, 0x04000003, 13, 0x254a14a9 },
12445 + { 280000000, 120000000, 0x0209, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 },
12446 + { 288000000, 123428571, 0x0111, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 },
12447 + { 300000000, 120000000, 0x0009, 0x04000009, 0x01030203, 0x02000902, 0x04000002, 9, 0x02520129 },
12448 + { 300000000, 150000000, 0x0009, 0x04000005, 0x01030203, 0x04000005, 0x04000002, 11, 0x0aaa0555 }
12451 + static n4m_table_t BCMINITDATA(type7_table)[] = {
12452 + { 183333333, 91666666, 0x0605, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
12453 + { 187500000, 93750000, 0x0a03, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
12454 + { 196875000, 98437500, 0x1003, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12455 + { 200000000, 100000000, 0x0311, 0x04000011, 0x11030011, 0x04000009, 0x04000003, 11, 0x0aaa0555 },
12456 + { 200000000, 100000000, 0x0311, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 },
12457 + { 206250000, 103125000, 0x1103, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12458 + { 212500000, 106250000, 0x0c05, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12459 + { 215625000, 107812500, 0x1203, 0x11090009, 0x11050005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12460 + { 216666666, 108333333, 0x0805, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
12461 + { 225000000, 112500000, 0x0d03, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
12462 + { 233333333, 116666666, 0x0905, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
12463 + { 237500000, 118750000, 0x0e05, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
12464 + { 240000000, 120000000, 0x0b11, 0x11020009, 0x11210009, 0x11020009, 0x04000009, 11, 0x0aaa0555 },
12465 + { 250000000, 125000000, 0x0f03, 0x11020003, 0x11210003, 0x11020003, 0x04000003, 11, 0x0aaa0555 }
12468 + ulong start, end, dst;
12469 + bool ret = FALSE;
12471 + /* get index of the current core */
12472 + idx = sb_coreidx(sbh);
12473 + clockcontrol_m2 = NULL;
12475 + /* switch to extif or chipc core */
12476 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
12477 + pll_type = PLL_TYPE1;
12478 + clockcontrol_n = &eir->clockcontrol_n;
12479 + clockcontrol_sb = &eir->clockcontrol_sb;
12480 + clockcontrol_pci = &eir->clockcontrol_pci;
12481 + clockcontrol_m2 = &cc->clockcontrol_m2;
12482 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
12483 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
12484 + if (pll_type == PLL_TYPE6) {
12485 + clockcontrol_n = NULL;
12486 + clockcontrol_sb = NULL;
12487 + clockcontrol_pci = NULL;
12489 + clockcontrol_n = &cc->clockcontrol_n;
12490 + clockcontrol_sb = &cc->clockcontrol_sb;
12491 + clockcontrol_pci = &cc->clockcontrol_pci;
12492 + clockcontrol_m2 = &cc->clockcontrol_m2;
12497 + if (pll_type == PLL_TYPE6) {
12498 + /* Silence compilers */
12499 + orig_n = orig_sb = orig_pci = 0;
12501 + /* Store the current clock register values */
12502 + orig_n = R_REG(clockcontrol_n);
12503 + orig_sb = R_REG(clockcontrol_sb);
12504 + orig_pci = R_REG(clockcontrol_pci);
12507 + if (pll_type == PLL_TYPE1) {
12508 + /* Keep the current PCI clock if not specified */
12509 + if (pciclock == 0) {
12510 + pciclock = sb_clock_rate(pll_type, R_REG(clockcontrol_n), R_REG(clockcontrol_pci));
12511 + pciclock = (pciclock <= 25000000) ? 25000000 : 33000000;
12514 + /* Search for the closest MIPS clock less than or equal to a preferred value */
12515 + for (i = 0; i < ARRAYSIZE(BCMINIT(type1_table)); i++) {
12516 + ASSERT(BCMINIT(type1_table)[i].mipsclock ==
12517 + sb_clock_rate(pll_type, BCMINIT(type1_table)[i].n, BCMINIT(type1_table)[i].sb));
12518 + if (BCMINIT(type1_table)[i].mipsclock > mipsclock)
12528 + ASSERT(BCMINIT(type1_table)[i].mipsclock <= mipsclock);
12530 + /* No PLL change */
12531 + if ((orig_n == BCMINIT(type1_table)[i].n) &&
12532 + (orig_sb == BCMINIT(type1_table)[i].sb) &&
12533 + (orig_pci == BCMINIT(type1_table)[i].pci33))
12536 + /* Set the PLL controls */
12537 + W_REG(clockcontrol_n, BCMINIT(type1_table)[i].n);
12538 + W_REG(clockcontrol_sb, BCMINIT(type1_table)[i].sb);
12539 + if (pciclock == 25000000)
12540 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci25);
12542 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci33);
12545 + sb_watchdog(sbh, 1);
12548 + } else if ((pll_type == PLL_TYPE3) &&
12549 + (BCMINIT(sb_chip)(sbh) != BCM5365_DEVICE_ID)) {
12551 + /* Search for the closest MIPS clock less than or equal to a preferred value */
12553 + for (i = 0; i < ARRAYSIZE(type3_table); i++) {
12554 + if (type3_table[i].mipsclock > mipsclock)
12564 + ASSERT(type3_table[i].mipsclock <= mipsclock);
12566 + /* No PLL change */
12567 + orig_m2 = R_REG(&cc->clockcontrol_m2);
12568 + if ((orig_n == type3_table[i].n) &&
12569 + (orig_m2 == type3_table[i].m2)) {
12573 + /* Set the PLL controls */
12574 + W_REG(clockcontrol_n, type3_table[i].n);
12575 + W_REG(clockcontrol_m2, type3_table[i].m2);
12578 + sb_watchdog(sbh, 1);
12580 + } else if ((pll_type == PLL_TYPE2) ||
12581 + (pll_type == PLL_TYPE4) ||
12582 + (pll_type == PLL_TYPE6) ||
12583 + (pll_type == PLL_TYPE7)) {
12584 + n4m_table_t *table = NULL, *te;
12589 + orig_mips = R_REG(&cc->clockcontrol_mips);
12591 + if (pll_type == PLL_TYPE6) {
12592 + uint32 new_mips = 0;
12595 + if (mipsclock <= SB2MIPS_T6(CC_T6_M1))
12596 + new_mips = CC_T6_MMASK;
12598 + if (orig_mips == new_mips)
12601 + W_REG(&cc->clockcontrol_mips, new_mips);
12605 + if (pll_type == PLL_TYPE2) {
12606 + table = BCMINIT(type2_table);
12607 + tabsz = ARRAYSIZE(BCMINIT(type2_table));
12608 + } else if (pll_type == PLL_TYPE4) {
12609 + table = BCMINIT(type4_table);
12610 + tabsz = ARRAYSIZE(BCMINIT(type4_table));
12611 + } else if (pll_type == PLL_TYPE7) {
12612 + table = BCMINIT(type7_table);
12613 + tabsz = ARRAYSIZE(BCMINIT(type7_table));
12615 + ASSERT("No table for plltype" == NULL);
12617 + /* Store the current clock register values */
12618 + orig_m2 = R_REG(&cc->clockcontrol_m2);
12619 + orig_ratio_parm = 0;
12620 + orig_ratio_cfg = 0;
12622 + /* Look up current ratio */
12623 + for (i = 0; i < tabsz; i++) {
12624 + if ((orig_n == table[i].n) &&
12625 + (orig_sb == table[i].sb) &&
12626 + (orig_pci == table[i].pci33) &&
12627 + (orig_m2 == table[i].m2) &&
12628 + (orig_mips == table[i].m3)) {
12629 + orig_ratio_parm = table[i].ratio_parm;
12630 + orig_ratio_cfg = table[i].ratio_cfg;
12635 + /* Search for the closest MIPS clock greater or equal to a preferred value */
12636 + for (i = 0; i < tabsz; i++) {
12637 + ASSERT(table[i].mipsclock ==
12638 + sb_clock_rate(pll_type, table[i].n, table[i].m3));
12639 + if ((mipsclock <= table[i].mipsclock) &&
12640 + ((sbclock == 0) || (sbclock <= table[i].sbclock)))
12643 + if (i == tabsz) {
12651 + /* No PLL change */
12652 + if ((orig_n == te->n) &&
12653 + (orig_sb == te->sb) &&
12654 + (orig_pci == te->pci33) &&
12655 + (orig_m2 == te->m2) &&
12656 + (orig_mips == te->m3))
12659 + /* Set the PLL controls */
12660 + W_REG(clockcontrol_n, te->n);
12661 + W_REG(clockcontrol_sb, te->sb);
12662 + W_REG(clockcontrol_pci, te->pci33);
12663 + W_REG(&cc->clockcontrol_m2, te->m2);
12664 + W_REG(&cc->clockcontrol_mips, te->m3);
12666 + /* Set the chipcontrol bit to change mipsref to the backplane divider if needed */
12667 + if ((pll_type == PLL_TYPE7) &&
12668 + (te->sb != te->m2) &&
12669 + (sb_clock_rate(pll_type, te->n, te->m2) == 120000000))
12670 + W_REG(&cc->chipcontrol, R_REG(&cc->chipcontrol) | 0x100);
12672 + /* No ratio change */
12673 + if (orig_ratio_parm == te->ratio_parm)
12676 + icache_probe(MFC0(C0_CONFIG, 1), &ic_size, &ic_lsize);
12678 + /* Preload the code into the cache */
12679 + start = ((ulong) &&start_fill) & ~(ic_lsize - 1);
12680 + end = ((ulong) &&end_fill + (ic_lsize - 1)) & ~(ic_lsize - 1);
12681 + while (start < end) {
12682 + cache_op(start, Fill_I);
12683 + start += ic_lsize;
12686 + /* Copy the handler */
12687 + start = (ulong) &BCMINIT(handler);
12688 + end = (ulong) &BCMINIT(afterhandler);
12689 + dst = KSEG1ADDR(0x180);
12690 + for (i = 0; i < (end - start); i += 4)
12691 + *((ulong *)(dst + i)) = *((ulong *)(start + i));
12693 + /* Preload handler into the cache one line at a time */
12694 + for (i = 0; i < (end - start); i += 4)
12695 + cache_op(dst + i, Fill_I);
12697 + /* Clear BEV bit */
12698 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~ST0_BEV);
12700 + /* Enable interrupts */
12701 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) | (ALLINTS | ST0_IE));
12703 + /* Enable MIPS timer interrupt */
12704 + if (!(mipsr = sb_setcore(sbh, SB_MIPS, 0)) &&
12705 + !(mipsr = sb_setcore(sbh, SB_MIPS33, 0)))
12707 + W_REG(&mipsr->intmask, 1);
12710 + /* step 1, set clock ratios */
12711 + MTC0(C0_BROADCOM, 3, te->ratio_parm);
12712 + MTC0(C0_BROADCOM, 1, te->ratio_cfg);
12714 + /* step 2: program timer intr */
12715 + W_REG(&mipsr->timer, 100);
12716 + (void) R_REG(&mipsr->timer);
12718 + /* step 3, switch to async */
12719 + sync_mode = MFC0(C0_BROADCOM, 4);
12720 + MTC0(C0_BROADCOM, 4, 1 << 22);
12722 + /* step 4, set cfg active */
12723 + MTC0(C0_BROADCOM, 2, 0x9);
12726 + /* steps 5 & 6 */
12727 + __asm__ __volatile__ (
12728 + ".set\tmips3\n\t"
12733 + /* step 7, clear cfg_active */
12734 + MTC0(C0_BROADCOM, 2, 0);
12736 + /* Additional Step: set back to orig sync mode */
12737 + MTC0(C0_BROADCOM, 4, sync_mode);
12739 + /* step 8, fake soft reset */
12740 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | 4);
12743 + /* step 9 set watchdog timer */
12744 + sb_watchdog(sbh, 20);
12745 + (void) R_REG(&cc->chipid);
12748 + __asm__ __volatile__ (
12749 + ".set\tmips3\n\t"
12758 + /* switch back to previous core */
12759 + sb_setcoreidx(sbh, idx);
12765 + * This also must be run from the cache on 47xx
12766 + * so there are no mips core BIU ops in progress
12767 + * when the PFC is enabled.
12771 +BCMINITFN(_enable_pfc)(uint32 mode)
12773 + /* write range */
12774 + *(volatile uint32 *)PFC_CR1 = 0xffff0000;
12777 + *(volatile uint32 *)PFC_CR0 = mode;
12781 +BCMINITFN(enable_pfc)(uint32 mode)
12783 + ulong start, end;
12786 + /* If auto then choose the correct mode for this
12787 + platform, currently we only ever select one mode */
12788 + if (mode == PFC_AUTO)
12791 + /* enable prefetch cache if available */
12792 + if (MFC0(C0_BROADCOM, 0) & BRCM_PFC_AVAIL) {
12793 + start = (ulong) &BCMINIT(_enable_pfc);
12794 + end = (ulong) &BCMINIT(enable_pfc);
12796 + /* Preload handler into the cache one line at a time */
12797 + for (i = 0; i < (end - start); i += 4)
12798 + cache_op(start + i, Fill_I);
12800 + BCMINIT(_enable_pfc)(mode);
12804 +/* returns the ncdl value to be programmed into sdram_ncdl for calibration */
12806 +BCMINITFN(sb_memc_get_ncdl)(sb_t *sbh)
12808 + sbmemcregs_t *memc;
12810 + uint32 config, rd, wr, misc, dqsg, cd, sm, sd;
12813 + idx = sb_coreidx(sbh);
12815 + memc = (sbmemcregs_t *)sb_setcore(sbh, SB_MEMC, 0);
12819 + rev = sb_corerev(sbh);
12821 + config = R_REG(&memc->config);
12822 + wr = R_REG(&memc->wrncdlcor);
12823 + rd = R_REG(&memc->rdncdlcor);
12824 + misc = R_REG(&memc->miscdlyctl);
12825 + dqsg = R_REG(&memc->dqsgatencdl);
12827 + rd &= MEMC_RDNCDLCOR_RD_MASK;
12828 + wr &= MEMC_WRNCDLCOR_WR_MASK;
12829 + dqsg &= MEMC_DQSGATENCDL_G_MASK;
12831 + if (config & MEMC_CONFIG_DDR) {
12832 + ret = (wr << 16) | (rd << 8) | dqsg;
12837 + cd = (rd == MEMC_CD_THRESHOLD) ? rd : (wr + MEMC_CD_THRESHOLD);
12838 + sm = (misc & MEMC_MISC_SM_MASK) >> MEMC_MISC_SM_SHIFT;
12839 + sd = (misc & MEMC_MISC_SD_MASK) >> MEMC_MISC_SD_SHIFT;
12840 + ret = (sm << 16) | (sd << 8) | cd;
12844 + /* switch back to previous core */
12845 + sb_setcoreidx(sbh, idx);
12850 diff -Nur linux-2.4.32/arch/mips/bcm947xx/sbpci.c linux-2.4.32-brcm/arch/mips/bcm947xx/sbpci.c
12851 --- linux-2.4.32/arch/mips/bcm947xx/sbpci.c 1970-01-01 01:00:00.000000000 +0100
12852 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/sbpci.c 2005-12-16 23:39:10.948837000 +0100
12855 + * Low-Level PCI and SB support for BCM47xx
12857 + * Copyright 2005, Broadcom Corporation
12858 + * All Rights Reserved.
12860 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
12861 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
12862 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
12863 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
12868 +#include <typedefs.h>
12869 +#include <pcicfg.h>
12870 +#include <bcmdevs.h>
12871 +#include <sbconfig.h>
12873 +#include <sbutils.h>
12874 +#include <sbpci.h>
12875 +#include <bcmendian.h>
12876 +#include <bcmutils.h>
12877 +#include <bcmnvram.h>
12878 +#include <hndmips.h>
12880 +/* Can free sbpci_init() memory after boot */
12885 +/* Emulated configuration space */
12886 +static pci_config_regs sb_config_regs[SB_MAXCORES];
12888 +/* Banned cores */
12889 +static uint16 pci_ban[32] = { 0 };
12890 +static uint pci_banned = 0;
12892 +/* CardBus mode */
12893 +static bool cardbus = FALSE;
12895 +/* Disable PCI host core */
12896 +static bool pci_disabled = FALSE;
12899 + * Functions for accessing external PCI configuration space
12902 +/* Assume one-hot slot wiring */
12903 +#define PCI_SLOT_MAX 16
12906 +config_cmd(sb_t *sbh, uint bus, uint dev, uint func, uint off)
12909 + sbpciregs_t *regs;
12912 + /* CardBusMode supports only one device */
12913 + if (cardbus && dev > 1)
12916 + coreidx = sb_coreidx(sbh);
12917 + regs = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
12919 + /* Type 0 transaction */
12921 + /* Skip unwired slots */
12922 + if (dev < PCI_SLOT_MAX) {
12923 + /* Slide the PCI window to the appropriate slot */
12924 + W_REG(®s->sbtopci1, SBTOPCI_CFG0 | ((1 << (dev + 16)) & SBTOPCI1_MASK));
12925 + addr = SB_PCI_CFG | ((1 << (dev + 16)) & ~SBTOPCI1_MASK) |
12926 + (func << 8) | (off & ~3);
12930 + /* Type 1 transaction */
12932 + W_REG(®s->sbtopci1, SBTOPCI_CFG1);
12933 + addr = SB_PCI_CFG | (bus << 16) | (dev << 11) | (func << 8) | (off & ~3);
12936 + sb_setcoreidx(sbh, coreidx);
12942 +extpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12944 + uint32 addr, *reg = NULL, val;
12947 + if (pci_disabled ||
12948 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
12949 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
12950 + BUSPROBE(val, reg))
12951 + val = 0xffffffff;
12953 + val >>= 8 * (off & 3);
12955 + *((uint32 *) buf) = val;
12956 + else if (len == 2)
12957 + *((uint16 *) buf) = (uint16) val;
12958 + else if (len == 1)
12959 + *((uint8 *) buf) = (uint8) val;
12970 +extpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12972 + uint32 addr, *reg = NULL, val;
12975 + if (pci_disabled ||
12976 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
12977 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
12978 + BUSPROBE(val, reg))
12982 + val = *((uint32 *) buf);
12983 + else if (len == 2) {
12984 + val &= ~(0xffff << (8 * (off & 3)));
12985 + val |= *((uint16 *) buf) << (8 * (off & 3));
12986 + } else if (len == 1) {
12987 + val &= ~(0xff << (8 * (off & 3)));
12988 + val |= *((uint8 *) buf) << (8 * (off & 3));
13002 + * Functions for accessing translated SB configuration space
13006 +sb_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
13008 + pci_config_regs *cfg;
13010 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
13012 + cfg = &sb_config_regs[dev];
13014 + ASSERT(ISALIGNED(off, len));
13015 + ASSERT(ISALIGNED((uintptr)buf, len));
13018 + *((uint32 *) buf) = ltoh32(*((uint32 *)((ulong) cfg + off)));
13019 + else if (len == 2)
13020 + *((uint16 *) buf) = ltoh16(*((uint16 *)((ulong) cfg + off)));
13021 + else if (len == 1)
13022 + *((uint8 *) buf) = *((uint8 *)((ulong) cfg + off));
13030 +sb_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
13035 + pci_config_regs *cfg;
13037 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
13039 + cfg = &sb_config_regs[dev];
13041 + ASSERT(ISALIGNED(off, len));
13042 + ASSERT(ISALIGNED((uintptr)buf, len));
13044 + /* Emulate BAR sizing */
13045 + if (off >= OFFSETOF(pci_config_regs, base[0]) && off <= OFFSETOF(pci_config_regs, base[3]) &&
13046 + len == 4 && *((uint32 *) buf) == ~0) {
13047 + coreidx = sb_coreidx(sbh);
13048 + if ((regs = sb_setcoreidx(sbh, dev))) {
13049 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
13050 + /* Highest numbered address match register */
13051 + n = (R_REG(&sb->sbidlow) & SBIDL_AR_MASK) >> SBIDL_AR_SHIFT;
13052 + if (off == OFFSETOF(pci_config_regs, base[0]))
13053 + cfg->base[0] = ~(sb_size(R_REG(&sb->sbadmatch0)) - 1);
13054 + else if (off == OFFSETOF(pci_config_regs, base[1]) && n >= 1)
13055 + cfg->base[1] = ~(sb_size(R_REG(&sb->sbadmatch1)) - 1);
13056 + else if (off == OFFSETOF(pci_config_regs, base[2]) && n >= 2)
13057 + cfg->base[2] = ~(sb_size(R_REG(&sb->sbadmatch2)) - 1);
13058 + else if (off == OFFSETOF(pci_config_regs, base[3]) && n >= 3)
13059 + cfg->base[3] = ~(sb_size(R_REG(&sb->sbadmatch3)) - 1);
13061 + sb_setcoreidx(sbh, coreidx);
13066 + *((uint32 *)((ulong) cfg + off)) = htol32(*((uint32 *) buf));
13067 + else if (len == 2)
13068 + *((uint16 *)((ulong) cfg + off)) = htol16(*((uint16 *) buf));
13069 + else if (len == 1)
13070 + *((uint8 *)((ulong) cfg + off)) = *((uint8 *) buf);
13078 +sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
13081 + return sb_read_config(sbh, bus, dev, func, off, buf, len);
13083 + return extpci_read_config(sbh, bus, dev, func, off, buf, len);
13087 +sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
13090 + return sb_write_config(sbh, bus, dev, func, off, buf, len);
13092 + return extpci_write_config(sbh, bus, dev, func, off, buf, len);
13096 +sbpci_ban(uint16 core)
13098 + if (pci_banned < ARRAYSIZE(pci_ban))
13099 + pci_ban[pci_banned++] = core;
13103 +sbpci_init_pci(sb_t *sbh)
13105 + uint chip, chiprev, chippkg, host;
13106 + uint32 boardflags;
13107 + sbpciregs_t *pci;
13111 + chip = sb_chip(sbh);
13112 + chiprev = sb_chiprev(sbh);
13113 + chippkg = sb_chippkg(sbh);
13115 + if (!(pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0))) {
13116 + printf("PCI: no core\n");
13117 + pci_disabled = TRUE;
13120 + sb_core_reset(sbh, 0);
13122 + boardflags = (uint32) getintvar(NULL, "boardflags");
13124 + if ((chip == BCM4310_DEVICE_ID) && (chiprev == 0))
13125 + pci_disabled = TRUE;
13128 + * The 200-pin BCM4712 package does not bond out PCI. Even when
13129 + * PCI is bonded out, some boards may leave the pins
13132 + if (((chip == BCM4712_DEVICE_ID) &&
13133 + ((chippkg == BCM4712SMALL_PKG_ID) ||
13134 + (chippkg == BCM4712MID_PKG_ID))) ||
13135 + (boardflags & BFL_NOPCI))
13136 + pci_disabled = TRUE;
13139 + * If the PCI core should not be touched (disabled, not bonded
13140 + * out, or pins floating), do not even attempt to access core
13141 + * registers. Otherwise, try to determine if it is in host
13144 + if (pci_disabled)
13147 + host = !BUSPROBE(val, &pci->control);
13150 + /* Disable PCI interrupts in client mode */
13151 + sb = (sbconfig_t *)((ulong) pci + SBCONFIGOFF);
13152 + W_REG(&sb->sbintvec, 0);
13154 + /* Disable the PCI bridge in client mode */
13155 + sbpci_ban(SB_PCI);
13156 + printf("PCI: Disabled\n");
13158 + /* Reset the external PCI bus and enable the clock */
13159 + W_REG(&pci->control, 0x5); /* enable the tristate drivers */
13160 + W_REG(&pci->control, 0xd); /* enable the PCI clock */
13161 + OSL_DELAY(150); /* delay > 100 us */
13162 + W_REG(&pci->control, 0xf); /* deassert PCI reset */
13163 + W_REG(&pci->arbcontrol, PCI_INT_ARB); /* use internal arbiter */
13164 + OSL_DELAY(1); /* delay 1 us */
13166 + /* Enable CardBusMode */
13167 + cardbus = nvram_match("cardbus", "1");
13169 + printf("PCI: Enabling CardBus\n");
13170 + /* GPIO 1 resets the CardBus device on bcm94710ap */
13171 + sb_gpioout(sbh, 1, 1, GPIO_DRV_PRIORITY);
13172 + sb_gpioouten(sbh, 1, 1, GPIO_DRV_PRIORITY);
13173 + W_REG(&pci->sprom[0], R_REG(&pci->sprom[0]) | 0x400);
13176 + /* 64 MB I/O access window */
13177 + W_REG(&pci->sbtopci0, SBTOPCI_IO);
13178 + /* 64 MB configuration access window */
13179 + W_REG(&pci->sbtopci1, SBTOPCI_CFG0);
13180 + /* 1 GB memory access window */
13181 + W_REG(&pci->sbtopci2, SBTOPCI_MEM | SB_PCI_DMA);
13183 + /* Enable PCI bridge BAR0 prefetch and burst */
13185 + sbpci_write_config(sbh, 1, 0, 0, PCI_CFG_CMD, &val, sizeof(val));
13187 + /* Enable PCI interrupts */
13188 + W_REG(&pci->intmask, PCI_INTA);
13195 +sbpci_init_cores(sb_t *sbh)
13197 + uint chip, chiprev, chippkg, coreidx, i;
13199 + pci_config_regs *cfg;
13203 + uint16 vendor, core;
13204 + uint8 class, subclass, progif;
13206 + uint32 sbips_int_mask[] = { 0, SBIPS_INT1_MASK, SBIPS_INT2_MASK, SBIPS_INT3_MASK, SBIPS_INT4_MASK };
13207 + uint32 sbips_int_shift[] = { 0, 0, SBIPS_INT2_SHIFT, SBIPS_INT3_SHIFT, SBIPS_INT4_SHIFT };
13209 + chip = sb_chip(sbh);
13210 + chiprev = sb_chiprev(sbh);
13211 + chippkg = sb_chippkg(sbh);
13212 + coreidx = sb_coreidx(sbh);
13214 + /* Scan the SB bus */
13215 + bzero(sb_config_regs, sizeof(sb_config_regs));
13216 + for (cfg = sb_config_regs; cfg < &sb_config_regs[SB_MAXCORES]; cfg++) {
13217 + cfg->vendor = 0xffff;
13218 + if (!(regs = sb_setcoreidx(sbh, cfg - sb_config_regs)))
13220 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
13222 + /* Read ID register and parse vendor and core */
13223 + val = R_REG(&sb->sbidhigh);
13224 + vendor = (val & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT;
13225 + core = (val & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;
13228 + /* Check if this core is banned */
13229 + for (i = 0; i < pci_banned; i++)
13230 + if (core == pci_ban[i])
13232 + if (i < pci_banned)
13235 + /* Known vendor translations */
13236 + switch (vendor) {
13237 + case SB_VEND_BCM:
13238 + vendor = VENDOR_BROADCOM;
13242 + /* Determine class based on known core codes */
13245 + class = PCI_CLASS_NET;
13246 + subclass = PCI_NET_ETHER;
13247 + core = BCM47XX_ILINE_ID;
13249 + case SB_ILINE100:
13250 + class = PCI_CLASS_NET;
13251 + subclass = PCI_NET_ETHER;
13252 + core = BCM4610_ILINE_ID;
13255 + class = PCI_CLASS_NET;
13256 + subclass = PCI_NET_ETHER;
13257 + core = BCM47XX_ENET_ID;
13261 + class = PCI_CLASS_MEMORY;
13262 + subclass = PCI_MEMORY_RAM;
13265 + class = PCI_CLASS_BRIDGE;
13266 + subclass = PCI_BRIDGE_PCI;
13270 + class = PCI_CLASS_CPU;
13271 + subclass = PCI_CPU_MIPS;
13274 + class = PCI_CLASS_COMM;
13275 + subclass = PCI_COMM_MODEM;
13276 + core = BCM47XX_V90_ID;
13279 + class = PCI_CLASS_SERIAL;
13280 + subclass = PCI_SERIAL_USB;
13281 + progif = 0x10; /* OHCI */
13282 + core = BCM47XX_USB_ID;
13285 + class = PCI_CLASS_SERIAL;
13286 + subclass = PCI_SERIAL_USB;
13287 + progif = 0x10; /* OHCI */
13288 + core = BCM47XX_USBH_ID;
13291 + class = PCI_CLASS_SERIAL;
13292 + subclass = PCI_SERIAL_USB;
13293 + core = BCM47XX_USBD_ID;
13296 + class = PCI_CLASS_CRYPT;
13297 + subclass = PCI_CRYPT_NETWORK;
13298 + core = BCM47XX_IPSEC_ID;
13301 + class = PCI_CLASS_NET;
13302 + subclass = PCI_NET_OTHER;
13303 + core = BCM47XX_ROBO_ID;
13307 + class = PCI_CLASS_MEMORY;
13308 + subclass = PCI_MEMORY_FLASH;
13311 + class = PCI_CLASS_NET;
13312 + subclass = PCI_NET_OTHER;
13313 + /* Let an nvram variable override this */
13314 + sprintf(varname, "wl%did", wlidx);
13316 + if ((core = getintvar(NULL, varname)) == 0) {
13317 + if (chip == BCM4712_DEVICE_ID) {
13318 + if (chippkg == BCM4712SMALL_PKG_ID)
13319 + core = BCM4306_D11G_ID;
13321 + core = BCM4306_D11DUAL_ID;
13324 + core = BCM4310_D11B_ID;
13330 + class = subclass = progif = 0xff;
13334 + /* Supported translations */
13335 + cfg->vendor = htol16(vendor);
13336 + cfg->device = htol16(core);
13337 + cfg->rev_id = chiprev;
13338 + cfg->prog_if = progif;
13339 + cfg->sub_class = subclass;
13340 + cfg->base_class = class;
13341 + cfg->base[0] = htol32(sb_base(R_REG(&sb->sbadmatch0)));
13342 + cfg->base[1] = htol32(sb_base(R_REG(&sb->sbadmatch1)));
13343 + cfg->base[2] = htol32(sb_base(R_REG(&sb->sbadmatch2)));
13344 + cfg->base[3] = htol32(sb_base(R_REG(&sb->sbadmatch3)));
13345 + cfg->base[4] = 0;
13346 + cfg->base[5] = 0;
13347 + if (class == PCI_CLASS_BRIDGE && subclass == PCI_BRIDGE_PCI)
13348 + cfg->header_type = PCI_HEADER_BRIDGE;
13350 + cfg->header_type = PCI_HEADER_NORMAL;
13351 + /* Save core interrupt flag */
13352 + cfg->int_pin = R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK;
13353 + /* Default to MIPS shared interrupt 0 */
13354 + cfg->int_line = 0;
13355 + /* MIPS sbipsflag maps core interrupt flags to interrupts 1 through 4 */
13356 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
13357 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
13358 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
13359 + val = R_REG(&sb->sbipsflag);
13360 + for (cfg->int_line = 1; cfg->int_line <= 4; cfg->int_line++) {
13361 + if (((val & sbips_int_mask[cfg->int_line]) >> sbips_int_shift[cfg->int_line]) == cfg->int_pin)
13364 + if (cfg->int_line > 4)
13365 + cfg->int_line = 0;
13367 + /* Emulated core */
13368 + *((uint32 *) &cfg->sprom_control) = 0xffffffff;
13371 + sb_setcoreidx(sbh, coreidx);
13376 +sbpci_init(sb_t *sbh)
13378 + sbpci_init_pci(sbh);
13379 + sbpci_init_cores(sbh);
13384 +sbpci_check(sb_t *sbh)
13387 + sbpciregs_t *pci;
13389 + uint32 buf[64], *ptr, i;
13393 + coreidx = sb_coreidx(sbh);
13394 + pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
13396 + /* Clear the test array */
13397 + pa = (ulong) DMA_MAP(NULL, buf, sizeof(buf), DMA_RX, NULL);
13398 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]);
13399 + memset(ptr, 0, sizeof(buf));
13401 + /* Point PCI window 1 to memory */
13402 + sbtopci1 = R_REG(&pci->sbtopci1);
13403 + W_REG(&pci->sbtopci1, SBTOPCI_MEM | (pa & SBTOPCI1_MASK));
13405 + /* Fill the test array via PCI window 1 */
13406 + ptr = (uint32 *) REG_MAP(SB_PCI_CFG + (pa & ~SBTOPCI1_MASK), sizeof(buf));
13407 + for (i = 0; i < ARRAYSIZE(buf); i++) {
13408 + for (j = 0; j < 2; j++);
13409 + W_REG(&ptr[i], i);
13413 + /* Restore PCI window 1 */
13414 + W_REG(&pci->sbtopci1, sbtopci1);
13416 + /* Check the test array */
13417 + DMA_UNMAP(NULL, pa, sizeof(buf), DMA_RX, NULL);
13418 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]);
13419 + for (i = 0; i < ARRAYSIZE(buf); i++) {
13424 + /* Change the clock if the test fails */
13425 + if (i < ARRAYSIZE(buf)) {
13428 + cur = sb_clock(sbh);
13429 + printf("PCI: Test failed at %d MHz\n", (cur + 500000) / 1000000);
13430 + for (req = 104000000; req < 176000000; req += 4000000) {
13431 + printf("PCI: Resetting to %d MHz\n", (req + 500000) / 1000000);
13432 + /* This will only reset if the clocks are valid and have changed */
13433 + sb_mips_setclock(sbh, req, 0, 0);
13435 + /* Should not reach here */
13439 + sb_setcoreidx(sbh, coreidx);
13442 diff -Nur linux-2.4.32/arch/mips/bcm947xx/setup.c linux-2.4.32-brcm/arch/mips/bcm947xx/setup.c
13443 --- linux-2.4.32/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100
13444 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/setup.c 2005-12-20 00:29:40.187416500 +0100
13447 + * Generic setup routines for Broadcom MIPS boards
13449 + * Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
13451 + * This program is free software; you can redistribute it and/or modify it
13452 + * under the terms of the GNU General Public License as published by the
13453 + * Free Software Foundation; either version 2 of the License, or (at your
13454 + * option) any later version.
13456 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13457 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13458 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
13459 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
13460 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
13461 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
13462 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
13463 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13464 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
13465 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13467 + * You should have received a copy of the GNU General Public License along
13468 + * with this program; if not, write to the Free Software Foundation, Inc.,
13469 + * 675 Mass Ave, Cambridge, MA 02139, USA.
13472 + * Copyright 2005, Broadcom Corporation
13473 + * All Rights Reserved.
13475 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
13476 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13477 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
13478 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
13482 +#include <linux/config.h>
13483 +#include <linux/init.h>
13484 +#include <linux/kernel.h>
13485 +#include <linux/module.h>
13486 +#include <linux/serialP.h>
13487 +#include <linux/ide.h>
13488 +#include <asm/bootinfo.h>
13489 +#include <asm/cpu.h>
13490 +#include <asm/time.h>
13491 +#include <asm/reboot.h>
13493 +#include <typedefs.h>
13495 +#include <sbutils.h>
13496 +#include <bcmutils.h>
13497 +#include <bcmnvram.h>
13498 +#include <sbmips.h>
13499 +#include <trxhdr.h>
13501 +/* Global SB handle */
13502 +sb_t *bcm947xx_sbh = NULL;
13503 +spinlock_t bcm947xx_sbh_lock = SPIN_LOCK_UNLOCKED;
13506 +#define sbh bcm947xx_sbh
13507 +#define sbh_lock bcm947xx_sbh_lock
13509 +extern void bcm947xx_time_init(void);
13510 +extern void bcm947xx_timer_setup(struct irqaction *irq);
13512 +#ifdef CONFIG_REMOTE_DEBUG
13513 +extern void set_debug_traps(void);
13514 +extern void rs_kgdb_hook(struct serial_state *);
13515 +extern void breakpoint(void);
13518 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
13519 +extern struct ide_ops std_ide_ops;
13522 +/* Kernel command line */
13523 +char arcs_cmdline[CL_SIZE] __initdata = CONFIG_CMDLINE;
13526 +bcm947xx_machine_restart(char *command)
13528 + printk("Please stand by while rebooting the system...\n");
13530 + /* Set the watchdog timer to reset immediately */
13532 + sb_watchdog(sbh, 1);
13537 +bcm947xx_machine_halt(void)
13539 + printk("System halted\n");
13541 + /* Disable interrupts and watchdog and spin forever */
13543 + sb_watchdog(sbh, 0);
13547 +#ifdef CONFIG_SERIAL
13549 +static int ser_line = 0;
13558 +static serial_port ports[4];
13559 +static int num_ports = 0;
13562 +serial_add(void *regs, uint irq, uint baud_base, uint reg_shift)
13564 + ports[num_ports].regs = regs;
13565 + ports[num_ports].irq = irq;
13566 + ports[num_ports].baud_base = baud_base;
13567 + ports[num_ports].reg_shift = reg_shift;
13572 +do_serial_add(serial_port *port)
13578 + struct serial_struct s;
13580 + regs = port->regs;
13582 + baud_base = port->baud_base;
13583 + reg_shift = port->reg_shift;
13585 + memset(&s, 0, sizeof(s));
13587 + s.line = ser_line++;
13588 + s.iomem_base = regs;
13590 + s.baud_base = baud_base / 16;
13591 + s.flags = ASYNC_BOOT_AUTOCONF;
13592 + s.io_type = SERIAL_IO_MEM;
13593 + s.iomem_reg_shift = reg_shift;
13595 + if (early_serial_setup(&s) != 0) {
13596 + printk(KERN_ERR "Serial setup failed!\n");
13600 +#endif /* CONFIG_SERIAL */
13609 + /* Get global SB handle */
13610 + sbh = sb_kattach();
13612 + /* Initialize clocks and interrupts */
13613 + sb_mips_init(sbh);
13615 + if (BCM330X(current_cpu_data.processor_id) &&
13616 + (read_c0_diag() & BRCM_PFC_AVAIL)) {
13618 + * Now that the sbh is inited set the proper PFC value
13620 + printk("Setting the PFC to its default value\n");
13621 + enable_pfc(PFC_AUTO);
13625 +#ifdef CONFIG_SERIAL
13626 + sb_serial_init(sbh, serial_add);
13628 + /* reverse serial ports if nvram variable starts with console=ttyS1 */
13629 + /* Initialize UARTs */
13630 + s = nvram_get("kernel_args");
13632 + if (!strncmp(s, "console=ttyS1", 13)) {
13633 + for (i = num_ports; i; i--)
13634 + do_serial_add(&ports[i - 1]);
13636 + for (i = 0; i < num_ports; i++)
13637 + do_serial_add(&ports[i]);
13641 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
13642 + ide_ops = &std_ide_ops;
13645 + /* Override default command line arguments */
13646 + value = nvram_get("kernel_cmdline");
13647 + if (value && strlen(value) && strncmp(value, "empty", 5))
13648 + strncpy(arcs_cmdline, value, sizeof(arcs_cmdline));
13651 + /* Generic setup */
13652 + _machine_restart = bcm947xx_machine_restart;
13653 + _machine_halt = bcm947xx_machine_halt;
13654 + _machine_power_off = bcm947xx_machine_halt;
13656 + board_time_init = bcm947xx_time_init;
13657 + board_timer_setup = bcm947xx_timer_setup;
13661 +get_system_type(void)
13663 + static char s[32];
13665 + if (bcm947xx_sbh) {
13666 + sprintf(s, "Broadcom BCM%X chip rev %d", sb_chip(bcm947xx_sbh),
13667 + sb_chiprev(bcm947xx_sbh));
13671 + return "Broadcom BCM947XX";
13675 +bus_error_init(void)
13679 +EXPORT_SYMBOL(bcm947xx_sbh);
13680 diff -Nur linux-2.4.32/arch/mips/bcm947xx/sflash.c linux-2.4.32-brcm/arch/mips/bcm947xx/sflash.c
13681 --- linux-2.4.32/arch/mips/bcm947xx/sflash.c 1970-01-01 01:00:00.000000000 +0100
13682 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/sflash.c 2005-12-16 23:39:10.948837000 +0100
13685 + * Broadcom SiliconBackplane chipcommon serial flash interface
13687 + * Copyright 2005, Broadcom Corporation
13688 + * All Rights Reserved.
13690 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
13691 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13692 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
13693 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
13699 +#include <typedefs.h>
13700 +#include <sbconfig.h>
13701 +#include <sbchipc.h>
13702 +#include <mipsinc.h>
13703 +#include <bcmutils.h>
13704 +#include <bcmdevs.h>
13705 +#include <sflash.h>
13707 +/* Private global state */
13708 +static struct sflash sflash;
13710 +/* Issue a serial flash command */
13711 +static INLINE void
13712 +sflash_cmd(chipcregs_t *cc, uint opcode)
13714 + W_REG(&cc->flashcontrol, SFLASH_START | opcode);
13715 + while (R_REG(&cc->flashcontrol) & SFLASH_BUSY);
13718 +/* Initialize serial flash access */
13720 +sflash_init(chipcregs_t *cc)
13724 + bzero(&sflash, sizeof(sflash));
13726 + sflash.type = R_REG(&cc->capabilities) & CAP_FLASH_MASK;
13728 + switch (sflash.type) {
13730 + /* Probe for ST chips */
13731 + sflash_cmd(cc, SFLASH_ST_DP);
13732 + sflash_cmd(cc, SFLASH_ST_RES);
13733 + id = R_REG(&cc->flashdata);
13736 + /* ST M25P20 2 Mbit Serial Flash */
13737 + sflash.blocksize = 64 * 1024;
13738 + sflash.numblocks = 4;
13741 + /* ST M25P40 4 Mbit Serial Flash */
13742 + sflash.blocksize = 64 * 1024;
13743 + sflash.numblocks = 8;
13746 + /* ST M25P80 8 Mbit Serial Flash */
13747 + sflash.blocksize = 64 * 1024;
13748 + sflash.numblocks = 16;
13751 + /* ST M25P16 16 Mbit Serial Flash */
13752 + sflash.blocksize = 64 * 1024;
13753 + sflash.numblocks = 32;
13756 + /* ST M25P32 32 Mbit Serial Flash */
13757 + sflash.blocksize = 64 * 1024;
13758 + sflash.numblocks = 64;
13761 + W_REG(&cc->flashaddress, 1);
13762 + sflash_cmd(cc, SFLASH_ST_RES);
13763 + id2 = R_REG(&cc->flashdata);
13764 + if (id2 == 0x44) {
13765 + /* SST M25VF80 4 Mbit Serial Flash */
13766 + sflash.blocksize = 64 * 1024;
13767 + sflash.numblocks = 8;
13774 + /* Probe for Atmel chips */
13775 + sflash_cmd(cc, SFLASH_AT_STATUS);
13776 + id = R_REG(&cc->flashdata) & 0x3c;
13779 + /* Atmel AT45DB011 1Mbit Serial Flash */
13780 + sflash.blocksize = 256;
13781 + sflash.numblocks = 512;
13784 + /* Atmel AT45DB021 2Mbit Serial Flash */
13785 + sflash.blocksize = 256;
13786 + sflash.numblocks = 1024;
13789 + /* Atmel AT45DB041 4Mbit Serial Flash */
13790 + sflash.blocksize = 256;
13791 + sflash.numblocks = 2048;
13794 + /* Atmel AT45DB081 8Mbit Serial Flash */
13795 + sflash.blocksize = 256;
13796 + sflash.numblocks = 4096;
13799 + /* Atmel AT45DB161 16Mbit Serial Flash */
13800 + sflash.blocksize = 512;
13801 + sflash.numblocks = 4096;
13804 + /* Atmel AT45DB321 32Mbit Serial Flash */
13805 + sflash.blocksize = 512;
13806 + sflash.numblocks = 8192;
13809 + /* Atmel AT45DB642 64Mbit Serial Flash */
13810 + sflash.blocksize = 1024;
13811 + sflash.numblocks = 8192;
13817 + sflash.size = sflash.blocksize * sflash.numblocks;
13818 + return sflash.size ? &sflash : NULL;
13821 +/* Read len bytes starting at offset into buf. Returns number of bytes read. */
13823 +sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf)
13826 + uint32 *from, *to;
13831 + if ((offset + len) > sflash.size)
13834 + if ((len >= 4) && (offset & 3))
13835 + cnt = 4 - (offset & 3);
13836 + else if ((len >= 4) && ((uint32)buf & 3))
13837 + cnt = 4 - ((uint32)buf & 3);
13841 + from = (uint32 *)KSEG1ADDR(SB_FLASH2 + offset);
13842 + to = (uint32 *)buf;
13845 + bcopy(from, to, cnt);
13849 + while (cnt >= 4) {
13854 + return (len - cnt);
13857 +/* Poll for command completion. Returns zero when complete. */
13859 +sflash_poll(chipcregs_t *cc, uint offset)
13861 + if (offset >= sflash.size)
13864 + switch (sflash.type) {
13866 + /* Check for ST Write In Progress bit */
13867 + sflash_cmd(cc, SFLASH_ST_RDSR);
13868 + return R_REG(&cc->flashdata) & SFLASH_ST_WIP;
13870 + /* Check for Atmel Ready bit */
13871 + sflash_cmd(cc, SFLASH_AT_STATUS);
13872 + return !(R_REG(&cc->flashdata) & SFLASH_AT_READY);
13878 +/* Write len bytes starting at offset into buf. Returns number of bytes
13879 + * written. Caller should poll for completion.
13882 +sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
13884 + struct sflash *sfl;
13887 + uint32 page, byte, mask;
13892 + if ((offset + len) > sflash.size)
13896 + switch (sfl->type) {
13898 + mask = R_REG(&cc->chipid);
13899 + is4712b0 = (((mask & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
13900 + ((mask & CID_REV_MASK) == (3 << CID_REV_SHIFT)));
13901 + /* Enable writes */
13902 + sflash_cmd(cc, SFLASH_ST_WREN);
13905 + W_REG(&cc->flashaddress, offset);
13906 + W_REG(&cc->flashdata, *buf++);
13907 + /* Set chip select */
13908 + OR_REG(&cc->gpioout, mask);
13909 + /* Issue a page program with the first byte */
13910 + sflash_cmd(cc, SFLASH_ST_PP);
13914 + while (len > 0) {
13915 + if ((offset & 255) == 0) {
13916 + /* Page boundary, drop cs and return */
13917 + AND_REG(&cc->gpioout, ~mask);
13918 + if (!sflash_poll(cc, offset)) {
13919 + /* Flash rejected command */
13924 + /* Write single byte */
13925 + sflash_cmd(cc, *buf++);
13931 + /* All done, drop cs if needed */
13932 + if ((offset & 255) != 1) {
13934 + AND_REG(&cc->gpioout, ~mask);
13935 + if (!sflash_poll(cc, offset)) {
13936 + /* Flash rejected command */
13942 + W_REG(&cc->flashaddress, offset);
13943 + W_REG(&cc->flashdata, *buf);
13944 + /* Page program */
13945 + sflash_cmd(cc, SFLASH_ST_PP);
13949 + mask = sfl->blocksize - 1;
13950 + page = (offset & ~mask) << 1;
13951 + byte = offset & mask;
13952 + /* Read main memory page into buffer 1 */
13953 + if (byte || len < sfl->blocksize) {
13954 + W_REG(&cc->flashaddress, page);
13955 + sflash_cmd(cc, SFLASH_AT_BUF1_LOAD);
13956 + /* 250 us for AT45DB321B */
13957 + SPINWAIT(sflash_poll(cc, offset), 1000);
13958 + ASSERT(!sflash_poll(cc, offset));
13960 + /* Write into buffer 1 */
13961 + for (ret = 0; ret < len && byte < sfl->blocksize; ret++) {
13962 + W_REG(&cc->flashaddress, byte++);
13963 + W_REG(&cc->flashdata, *buf++);
13964 + sflash_cmd(cc, SFLASH_AT_BUF1_WRITE);
13966 + /* Write buffer 1 into main memory page */
13967 + W_REG(&cc->flashaddress, page);
13968 + sflash_cmd(cc, SFLASH_AT_BUF1_PROGRAM);
13975 +/* Erase a region. Returns number of bytes scheduled for erasure.
13976 + * Caller should poll for completion.
13979 +sflash_erase(chipcregs_t *cc, uint offset)
13981 + struct sflash *sfl;
13983 + if (offset >= sflash.size)
13987 + switch (sfl->type) {
13989 + sflash_cmd(cc, SFLASH_ST_WREN);
13990 + W_REG(&cc->flashaddress, offset);
13991 + sflash_cmd(cc, SFLASH_ST_SE);
13992 + return sfl->blocksize;
13994 + W_REG(&cc->flashaddress, offset << 1);
13995 + sflash_cmd(cc, SFLASH_AT_PAGE_ERASE);
13996 + return sfl->blocksize;
14003 + * writes the appropriate range of flash, a NULL buf simply erases
14004 + * the region of flash
14007 +sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
14009 + struct sflash *sfl;
14010 + uchar *block = NULL, *cur_ptr, *blk_ptr;
14011 + uint blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder;
14012 + uint blk_offset, blk_len, copied;
14013 + int bytes, ret = 0;
14015 + /* Check address range */
14020 + if ((offset + len) > sfl->size)
14023 + blocksize = sfl->blocksize;
14024 + mask = blocksize - 1;
14026 + /* Allocate a block of mem */
14027 + if (!(block = MALLOC(NULL, blocksize)))
14031 + /* Align offset */
14032 + cur_offset = offset & ~mask;
14033 + cur_length = blocksize;
14036 + remainder = blocksize - (offset & mask);
14037 + if (len < remainder)
14038 + cur_retlen = len;
14040 + cur_retlen = remainder;
14042 + /* buf == NULL means erase only */
14044 + /* Copy existing data into holding block if necessary */
14045 + if ((offset & mask) || (len < blocksize)) {
14046 + blk_offset = cur_offset;
14047 + blk_len = cur_length;
14048 + blk_ptr = cur_ptr;
14050 + /* Copy entire block */
14052 + copied = sflash_read(cc, blk_offset, blk_len, blk_ptr);
14053 + blk_offset += copied;
14054 + blk_len -= copied;
14055 + blk_ptr += copied;
14059 + /* Copy input data into holding block */
14060 + memcpy(cur_ptr + (offset & mask), buf, cur_retlen);
14063 + /* Erase block */
14064 + if ((ret = sflash_erase(cc, (uint) cur_offset)) < 0)
14066 + while (sflash_poll(cc, (uint) cur_offset));
14068 + /* buf == NULL means erase only */
14070 + offset += cur_retlen;
14071 + len -= cur_retlen;
14075 + /* Write holding block */
14076 + while (cur_length > 0) {
14077 + if ((bytes = sflash_write(cc,
14078 + (uint) cur_offset,
14079 + (uint) cur_length,
14080 + (uchar *) cur_ptr)) < 0) {
14084 + while (sflash_poll(cc, (uint) cur_offset));
14085 + cur_offset += bytes;
14086 + cur_length -= bytes;
14087 + cur_ptr += bytes;
14090 + offset += cur_retlen;
14091 + len -= cur_retlen;
14092 + buf += cur_retlen;
14098 + MFREE(NULL, block, blocksize);
14102 diff -Nur linux-2.4.32/arch/mips/bcm947xx/time.c linux-2.4.32-brcm/arch/mips/bcm947xx/time.c
14103 --- linux-2.4.32/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +0100
14104 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/time.c 2005-12-16 23:39:10.948837000 +0100
14107 + * Copyright 2004, Broadcom Corporation
14108 + * All Rights Reserved.
14110 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14111 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14112 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14113 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14115 + * $Id: time.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
14117 +#include <linux/config.h>
14118 +#include <linux/init.h>
14119 +#include <linux/kernel.h>
14120 +#include <linux/sched.h>
14121 +#include <linux/serial_reg.h>
14122 +#include <linux/interrupt.h>
14123 +#include <asm/addrspace.h>
14124 +#include <asm/io.h>
14125 +#include <asm/time.h>
14127 +#include <typedefs.h>
14129 +#include <sbutils.h>
14130 +#include <bcmnvram.h>
14131 +#include <sbconfig.h>
14132 +#include <sbextif.h>
14133 +#include <sbmips.h>
14135 +/* Global SB handle */
14136 +extern void *bcm947xx_sbh;
14137 +extern spinlock_t bcm947xx_sbh_lock;
14140 +#define sbh bcm947xx_sbh
14141 +#define sbh_lock bcm947xx_sbh_lock
14143 +extern int panic_timeout;
14144 +static int watchdog = 0;
14145 +static u8 *mcr = NULL;
14148 +bcm947xx_time_init(void)
14151 + extifregs_t *eir;
14154 + * Use deterministic values for initial counter interrupt
14155 + * so that calibrate delay avoids encountering a counter wrap.
14157 + write_c0_count(0);
14158 + write_c0_compare(0xffff);
14160 + if (!(hz = sb_mips_clock(sbh)))
14163 + printk("CPU: BCM%04x rev %d at %d MHz\n", sb_chip(sbh), sb_chiprev(sbh),
14164 + (hz + 500000) / 1000000);
14166 + /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
14167 + mips_hpt_frequency = hz / 2;
14169 + /* Set watchdog interval in ms */
14170 + watchdog = simple_strtoul(nvram_safe_get("watchdog"), NULL, 0);
14172 + /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */
14173 + if (watchdog > 0) {
14174 + if (watchdog < 3000)
14179 + /* Set panic timeout in seconds */
14180 + panic_timeout = watchdog / 1000;
14182 + /* Setup blink */
14183 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
14184 + sbconfig_t *sb = (sbconfig_t *)((unsigned int) eir + SBCONFIGOFF);
14185 + unsigned long base = EXTIF_CFGIF_BASE(sb_base(readl(&sb->sbadmatch1)));
14186 + mcr = (u8 *) ioremap_nocache(base + UART_MCR, 1);
14191 +bcm947xx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
14193 + /* Generic MIPS timer code */
14194 + timer_interrupt(irq, dev_id, regs);
14196 + /* Set the watchdog timer to reset after the specified number of ms */
14197 + if (watchdog > 0)
14198 + sb_watchdog(sbh, WATCHDOG_CLOCK / 1000 * watchdog);
14200 +#ifdef CONFIG_HWSIM
14201 + (*((int *)0xa0000f1c))++;
14203 + /* Blink one of the LEDs in the external UART */
14204 + if (mcr && !(jiffies % (HZ/2)))
14205 + writeb(readb(mcr) ^ UART_MCR_OUT2, mcr);
14209 +static struct irqaction bcm947xx_timer_irqaction = {
14210 + bcm947xx_timer_interrupt,
14219 +bcm947xx_timer_setup(struct irqaction *irq)
14221 + /* Enable the timer interrupt */
14222 + setup_irq(7, &bcm947xx_timer_irqaction);
14224 diff -Nur linux-2.4.32/arch/mips/config-shared.in linux-2.4.32-brcm/arch/mips/config-shared.in
14225 --- linux-2.4.32/arch/mips/config-shared.in 2005-01-19 15:09:27.000000000 +0100
14226 +++ linux-2.4.32-brcm/arch/mips/config-shared.in 2005-12-16 23:39:11.080845250 +0100
14227 @@ -205,6 +205,14 @@
14229 define_bool CONFIG_MIPS_RTC y
14231 +dep_bool 'Support for Broadcom MIPS-based boards' CONFIG_MIPS_BRCM $CONFIG_EXPERIMENTAL
14232 +dep_bool 'Support for Broadcom BCM947XX' CONFIG_BCM947XX $CONFIG_MIPS_BRCM
14233 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
14234 + bool ' Support for Broadcom BCM4710' CONFIG_BCM4710
14235 + bool ' Support for Broadcom BCM4310' CONFIG_BCM4310
14236 + bool ' Support for Broadcom BCM4704' CONFIG_BCM4704
14237 + bool ' Support for Broadcom BCM5365' CONFIG_BCM5365
14239 bool 'Support for SNI RM200 PCI' CONFIG_SNI_RM200_PCI
14240 bool 'Support for TANBAC TB0226 (Mbase)' CONFIG_TANBAC_TB0226
14241 bool 'Support for TANBAC TB0229 (VR4131DIMM)' CONFIG_TANBAC_TB0229
14242 @@ -226,6 +234,11 @@
14243 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
14246 +# Provide an option for a default kernel command line
14248 +string 'Default kernel command string' CONFIG_CMDLINE ""
14251 # Select some configuration options automatically based on user selections.
14253 if [ "$CONFIG_ACER_PICA_61" = "y" ]; then
14254 @@ -533,6 +546,13 @@
14255 define_bool CONFIG_SWAP_IO_SPACE_L y
14256 define_bool CONFIG_BOOT_ELF32 y
14258 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
14259 + define_bool CONFIG_PCI y
14260 + define_bool CONFIG_NONCOHERENT_IO y
14261 + define_bool CONFIG_NEW_TIME_C y
14262 + define_bool CONFIG_NEW_IRQ y
14263 + define_bool CONFIG_HND y
14265 if [ "$CONFIG_SNI_RM200_PCI" = "y" ]; then
14266 define_bool CONFIG_ARC32 y
14267 define_bool CONFIG_ARC_MEMORY y
14268 @@ -1011,7 +1031,11 @@
14270 bool 'Are you using a crosscompiler' CONFIG_CROSSCOMPILE
14271 bool 'Enable run-time debugging' CONFIG_RUNTIME_DEBUG
14272 -bool 'Remote GDB kernel debugging' CONFIG_KGDB
14273 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
14274 + bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG
14276 + bool 'Remote GDB kernel debugging' CONFIG_KGDB
14278 dep_bool ' Console output to GDB' CONFIG_GDB_CONSOLE $CONFIG_KGDB
14279 if [ "$CONFIG_KGDB" = "y" ]; then
14280 define_bool CONFIG_DEBUG_INFO y
14281 diff -Nur linux-2.4.32/arch/mips/kernel/cpu-probe.c linux-2.4.32-brcm/arch/mips/kernel/cpu-probe.c
14282 --- linux-2.4.32/arch/mips/kernel/cpu-probe.c 2005-01-19 15:09:29.000000000 +0100
14283 +++ linux-2.4.32-brcm/arch/mips/kernel/cpu-probe.c 2005-12-16 23:39:11.084845500 +0100
14284 @@ -174,7 +174,7 @@
14286 static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
14288 - switch (c->processor_id & 0xff00) {
14289 + switch (c->processor_id & PRID_IMP_MASK) {
14290 case PRID_IMP_R2000:
14291 c->cputype = CPU_R2000;
14292 c->isa_level = MIPS_CPU_ISA_I;
14293 @@ -184,7 +184,7 @@
14296 case PRID_IMP_R3000:
14297 - if ((c->processor_id & 0xff) == PRID_REV_R3000A)
14298 + if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A)
14299 if (cpu_has_confreg())
14300 c->cputype = CPU_R3081E;
14302 @@ -199,12 +199,12 @@
14304 case PRID_IMP_R4000:
14305 if (read_c0_config() & CONF_SC) {
14306 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
14307 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
14308 c->cputype = CPU_R4400PC;
14310 c->cputype = CPU_R4000PC;
14312 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
14313 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
14314 c->cputype = CPU_R4400SC;
14316 c->cputype = CPU_R4000SC;
14317 @@ -450,7 +450,7 @@
14318 static inline void cpu_probe_mips(struct cpuinfo_mips *c)
14321 - switch (c->processor_id & 0xff00) {
14322 + switch (c->processor_id & PRID_IMP_MASK) {
14324 c->cputype = CPU_4KC;
14325 c->isa_level = MIPS_CPU_ISA_M32;
14326 @@ -491,10 +491,10 @@
14329 c->options |= MIPS_CPU_PREFETCH;
14330 - switch (c->processor_id & 0xff00) {
14331 + switch (c->processor_id & PRID_IMP_MASK) {
14332 case PRID_IMP_AU1_REV1:
14333 case PRID_IMP_AU1_REV2:
14334 - switch ((c->processor_id >> 24) & 0xff) {
14335 + switch ((c->processor_id >> 24) & PRID_REV_MASK) {
14337 c->cputype = CPU_AU1000;
14339 @@ -522,10 +522,34 @@
14343 +static inline void cpu_probe_broadcom(struct cpuinfo_mips *c)
14345 + decode_config1(c);
14346 + c->options |= MIPS_CPU_PREFETCH;
14347 + switch (c->processor_id & PRID_IMP_MASK) {
14348 + case PRID_IMP_BCM4710:
14349 + c->cputype = CPU_BCM4710;
14350 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
14351 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
14352 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
14354 + case PRID_IMP_4KC:
14355 + case PRID_IMP_BCM3302:
14356 + c->cputype = CPU_BCM3302;
14357 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
14358 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
14359 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
14362 + c->cputype = CPU_UNKNOWN;
14367 static inline void cpu_probe_sibyte(struct cpuinfo_mips *c)
14370 - switch (c->processor_id & 0xff00) {
14371 + switch (c->processor_id & PRID_IMP_MASK) {
14373 c->cputype = CPU_SB1;
14374 c->isa_level = MIPS_CPU_ISA_M64;
14375 @@ -547,7 +571,7 @@
14376 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c)
14379 - switch (c->processor_id & 0xff00) {
14380 + switch (c->processor_id & PRID_IMP_MASK) {
14381 case PRID_IMP_SR71000:
14382 c->cputype = CPU_SR71000;
14383 c->isa_level = MIPS_CPU_ISA_M64;
14384 @@ -572,7 +596,7 @@
14385 c->cputype = CPU_UNKNOWN;
14387 c->processor_id = read_c0_prid();
14388 - switch (c->processor_id & 0xff0000) {
14389 + switch (c->processor_id & PRID_COMP_MASK) {
14391 case PRID_COMP_LEGACY:
14392 cpu_probe_legacy(c);
14393 @@ -583,6 +607,9 @@
14394 case PRID_COMP_ALCHEMY:
14395 cpu_probe_alchemy(c);
14397 + case PRID_COMP_BROADCOM:
14398 + cpu_probe_broadcom(c);
14400 case PRID_COMP_SIBYTE:
14401 cpu_probe_sibyte(c);
14403 diff -Nur linux-2.4.32/arch/mips/kernel/head.S linux-2.4.32-brcm/arch/mips/kernel/head.S
14404 --- linux-2.4.32/arch/mips/kernel/head.S 2005-01-19 15:09:29.000000000 +0100
14405 +++ linux-2.4.32-brcm/arch/mips/kernel/head.S 2005-12-16 23:39:11.084845500 +0100
14406 @@ -28,12 +28,20 @@
14407 #include <asm/mipsregs.h>
14408 #include <asm/stackframe.h>
14410 +#ifdef CONFIG_BCM4710
14412 +#define eret nop; nop; eret
14420 * Reserved space for exception handlers.
14421 * Necessary for machines which link their kernels at KSEG0.
14426 /* The following two symbols are used for kernel profiling. */
14428 diff -Nur linux-2.4.32/arch/mips/kernel/proc.c linux-2.4.32-brcm/arch/mips/kernel/proc.c
14429 --- linux-2.4.32/arch/mips/kernel/proc.c 2005-01-19 15:09:29.000000000 +0100
14430 +++ linux-2.4.32-brcm/arch/mips/kernel/proc.c 2005-12-16 23:39:11.084845500 +0100
14432 [CPU_AU1550] "Au1550",
14433 [CPU_24K] "MIPS 24K",
14434 [CPU_AU1200] "Au1200",
14435 + [CPU_BCM4710] "BCM4710",
14436 + [CPU_BCM3302] "BCM3302",
14440 static int show_cpuinfo(struct seq_file *m, void *v)
14442 unsigned int version = current_cpu_data.processor_id;
14443 diff -Nur linux-2.4.32/arch/mips/kernel/setup.c linux-2.4.32-brcm/arch/mips/kernel/setup.c
14444 --- linux-2.4.32/arch/mips/kernel/setup.c 2005-01-19 15:09:29.000000000 +0100
14445 +++ linux-2.4.32-brcm/arch/mips/kernel/setup.c 2005-12-16 23:39:11.140849000 +0100
14446 @@ -495,6 +495,7 @@
14447 void swarm_setup(void);
14448 void hp_setup(void);
14449 void au1x00_setup(void);
14450 + void brcm_setup(void);
14451 void frame_info_init(void);
14454 @@ -693,6 +694,11 @@
14455 pmc_yosemite_setup();
14458 +#if defined(CONFIG_BCM4710) || defined(CONFIG_BCM4310)
14459 + case MACH_GROUP_BRCM:
14464 panic("Unsupported architecture");
14466 diff -Nur linux-2.4.32/arch/mips/kernel/traps.c linux-2.4.32-brcm/arch/mips/kernel/traps.c
14467 --- linux-2.4.32/arch/mips/kernel/traps.c 2005-01-19 15:09:29.000000000 +0100
14468 +++ linux-2.4.32-brcm/arch/mips/kernel/traps.c 2005-12-16 23:39:11.140849000 +0100
14469 @@ -913,6 +913,7 @@
14470 void __init trap_init(void)
14472 extern char except_vec1_generic;
14473 + extern char except_vec2_generic;
14474 extern char except_vec3_generic, except_vec3_r4000;
14475 extern char except_vec_ejtag_debug;
14476 extern char except_vec4;
14477 @@ -922,6 +923,7 @@
14479 /* Copy the generic exception handler code to it's final destination. */
14480 memcpy((void *)(KSEG0 + 0x80), &except_vec1_generic, 0x80);
14481 + memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80);
14484 * Setup default vectors
14485 @@ -980,6 +982,12 @@
14486 set_except_vector(13, handle_tr);
14487 set_except_vector(22, handle_mdmx);
14489 + if (current_cpu_data.cputype == CPU_SB1) {
14490 + /* Enable timer interrupt and scd mapped interrupt */
14491 + clear_c0_status(0xf000);
14492 + set_c0_status(0xc00);
14495 if (cpu_has_fpu && !cpu_has_nofpuex)
14496 set_except_vector(15, handle_fpe);
14498 diff -Nur linux-2.4.32/arch/mips/Makefile linux-2.4.32-brcm/arch/mips/Makefile
14499 --- linux-2.4.32/arch/mips/Makefile 2005-01-19 15:09:26.000000000 +0100
14500 +++ linux-2.4.32-brcm/arch/mips/Makefile 2005-12-16 23:39:10.668819500 +0100
14501 @@ -715,6 +715,19 @@
14505 +# Broadcom BCM947XX variants
14507 +ifdef CONFIG_BCM947XX
14508 +LIBS += arch/mips/bcm947xx/generic/brcm.o arch/mips/bcm947xx/bcm947xx.o
14509 +SUBDIRS += arch/mips/bcm947xx/generic arch/mips/bcm947xx
14510 +LOADADDR := 0x80001000
14513 + $(MAKE) -C arch/$(ARCH)/bcm947xx/compressed
14518 # Choosing incompatible machines durings configuration will result in
14519 # error messages during linking. Select a default linkscript if
14520 # none has been choosen above.
14521 @@ -767,6 +780,7 @@
14522 $(MAKE) -C arch/$(ARCH)/tools clean
14523 $(MAKE) -C arch/mips/baget clean
14524 $(MAKE) -C arch/mips/lasat clean
14525 + $(MAKE) -C arch/mips/bcm947xx/compressed clean
14528 @$(MAKEBOOT) mrproper
14529 diff -Nur linux-2.4.32/arch/mips/mm/c-r4k.c linux-2.4.32-brcm/arch/mips/mm/c-r4k.c
14530 --- linux-2.4.32/arch/mips/mm/c-r4k.c 2005-01-19 15:09:29.000000000 +0100
14531 +++ linux-2.4.32-brcm/arch/mips/mm/c-r4k.c 2005-12-16 23:39:11.144849250 +0100
14532 @@ -1114,3 +1114,47 @@
14533 build_clear_page();
14537 +#ifdef CONFIG_BCM4704
14538 +static void __init mips32_icache_fill(unsigned long addr, uint nbytes)
14540 + unsigned long ic_lsize = current_cpu_data.icache.linesz;
14542 + for (i = 0; i < nbytes; i += ic_lsize)
14543 + fill_icache_line((addr + i));
14547 + * This must be run from the cache on 4704A0
14548 + * so there are no mips core BIU ops in progress
14549 + * when the PFC is enabled.
14551 +#define PFC_CR0 0xff400000 /* control reg 0 */
14552 +#define PFC_CR1 0xff400004 /* control reg 1 */
14553 +static void __init enable_pfc(u32 mode)
14555 + /* write range */
14556 + *(volatile u32 *)PFC_CR1 = 0xffff0000;
14559 + *(volatile u32 *)PFC_CR0 = mode;
14564 +void check_enable_mips_pfc(int val)
14567 +#ifdef CONFIG_BCM4704
14568 + struct cpuinfo_mips *c = ¤t_cpu_data;
14570 + /* enable prefetch cache */
14571 + if (((c->processor_id & (PRID_COMP_MASK | PRID_IMP_MASK)) == PRID_IMP_BCM3302)
14572 + && (read_c0_diag() & (1 << 29))) {
14573 + mips32_icache_fill((unsigned long) &enable_pfc, 64);
14580 diff -Nur linux-2.4.32/arch/mips/pci/Makefile linux-2.4.32-brcm/arch/mips/pci/Makefile
14581 --- linux-2.4.32/arch/mips/pci/Makefile 2005-01-19 15:09:29.000000000 +0100
14582 +++ linux-2.4.32-brcm/arch/mips/pci/Makefile 2005-12-16 23:39:11.144849250 +0100
14584 obj-$(CONFIG_MIPS_MSC) += ops-msc.o
14585 obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o
14586 obj-$(CONFIG_SNI_RM200_PCI) += ops-sni.o
14587 +ifndef CONFIG_BCM947XX
14590 obj-$(CONFIG_PCI_AUTO) += pci_auto.o
14592 include $(TOPDIR)/Rules.make
14593 diff -Nur linux-2.4.32/drivers/char/serial.c linux-2.4.32-brcm/drivers/char/serial.c
14594 --- linux-2.4.32/drivers/char/serial.c 2005-11-16 20:12:54.000000000 +0100
14595 +++ linux-2.4.32-brcm/drivers/char/serial.c 2005-12-16 23:39:11.200852750 +0100
14596 @@ -422,6 +422,10 @@
14597 return inb(info->port+1);
14599 case SERIAL_IO_MEM:
14600 +#ifdef CONFIG_BCM4310
14601 + readb((unsigned long) info->iomem_base +
14602 + (UART_SCR<<info->iomem_reg_shift));
14604 return readb((unsigned long) info->iomem_base +
14605 (offset<<info->iomem_reg_shift));
14607 @@ -442,6 +446,9 @@
14608 case SERIAL_IO_MEM:
14609 writeb(value, (unsigned long) info->iomem_base +
14610 (offset<<info->iomem_reg_shift));
14611 +#ifdef CONFIG_BCM4704
14612 + *((volatile unsigned int *) KSEG1ADDR(0x18000000));
14616 outb(value, info->port+offset);
14617 @@ -1704,7 +1711,7 @@
14618 /* Special case since 134 is really 134.5 */
14619 quot = (2*baud_base / 269);
14621 - quot = baud_base / baud;
14622 + quot = (baud_base + (baud / 2)) / baud;
14624 /* If the quotient is zero refuse the change */
14625 if (!quot && old_termios) {
14626 @@ -1721,12 +1728,12 @@
14627 /* Special case since 134 is really 134.5 */
14628 quot = (2*baud_base / 269);
14630 - quot = baud_base / baud;
14631 + quot = (baud_base + (baud / 2)) / baud;
14634 /* As a last resort, if the quotient is zero, default to 9600 bps */
14636 - quot = baud_base / 9600;
14637 + quot = (baud_base + 4800) / 9600;
14639 * Work around a bug in the Oxford Semiconductor 952 rev B
14640 * chip which causes it to seriously miscalculate baud rates
14641 @@ -5982,6 +5989,13 @@
14642 * Divisor, bytesize and parity
14644 state = rs_table + co->index;
14646 + * Safe guard: state structure must have been initialized
14648 + if (state->iomem_base == NULL) {
14649 + printk("!unable to setup serial console!\n");
14653 state->flags |= ASYNC_CONS_FLOW;
14654 info = &async_sercons;
14655 @@ -5995,7 +6009,7 @@
14656 info->io_type = state->io_type;
14657 info->iomem_base = state->iomem_base;
14658 info->iomem_reg_shift = state->iomem_reg_shift;
14659 - quot = state->baud_base / baud;
14660 + quot = (state->baud_base + (baud / 2)) / baud;
14661 cval = cflag & (CSIZE | CSTOPB);
14662 #if defined(__powerpc__) || defined(__alpha__)
14664 diff -Nur linux-2.4.32/drivers/net/Config.in linux-2.4.32-brcm/drivers/net/Config.in
14665 --- linux-2.4.32/drivers/net/Config.in 2005-01-19 15:09:56.000000000 +0100
14666 +++ linux-2.4.32-brcm/drivers/net/Config.in 2005-12-16 23:39:11.232854750 +0100
14668 # Network device configuration
14671 +tristate 'Broadcom Home Network Division' CONFIG_HND $CONFIG_PCI
14673 source drivers/net/arcnet/Config.in
14675 tristate 'Dummy net driver support' CONFIG_DUMMY
14676 @@ -173,6 +175,7 @@
14678 dep_tristate ' Apricot Xen-II on board Ethernet' CONFIG_APRICOT $CONFIG_ISA
14679 dep_tristate ' Broadcom 4400 ethernet support (EXPERIMENTAL)' CONFIG_B44 $CONFIG_PCI $CONFIG_EXPERIMENTAL
14680 + dep_tristate ' Proprietary Broadcom 10/100 Ethernet support' CONFIG_ET $CONFIG_PCI
14681 dep_tristate ' CS89x0 support' CONFIG_CS89x0 $CONFIG_ISA
14682 dep_tristate ' DECchip Tulip (dc21x4x) PCI support' CONFIG_TULIP $CONFIG_PCI
14683 if [ "$CONFIG_TULIP" = "y" -o "$CONFIG_TULIP" = "m" ]; then
14684 diff -Nur linux-2.4.32/drivers/net/et/Makefile linux-2.4.32-brcm/drivers/net/et/Makefile
14685 --- linux-2.4.32/drivers/net/et/Makefile 1970-01-01 01:00:00.000000000 +0100
14686 +++ linux-2.4.32-brcm/drivers/net/et/Makefile 2005-12-16 23:39:11.284858000 +0100
14689 +# Makefile for the Broadcom et driver
14691 +# Copyright 2004, Broadcom Corporation
14692 +# All Rights Reserved.
14694 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14695 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14696 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14697 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14699 +# $Id: Makefile,v 1.1 2005/03/16 13:50:00 wbx Exp $
14702 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCM47XX_CHOPS -DDMA -DBCMDRIVER
14705 +obj-y := et_linux.o etc.o etc47xx.o etc_robo.o etc_adm.o
14706 +obj-m := $(O_TARGET)
14708 +include $(TOPDIR)/Rules.make
14709 diff -Nur linux-2.4.32/drivers/net/hnd/bcmsrom.c linux-2.4.32-brcm/drivers/net/hnd/bcmsrom.c
14710 --- linux-2.4.32/drivers/net/hnd/bcmsrom.c 1970-01-01 01:00:00.000000000 +0100
14711 +++ linux-2.4.32-brcm/drivers/net/hnd/bcmsrom.c 2005-12-16 23:39:11.284858000 +0100
14714 + * Misc useful routines to access NIC SROM/OTP .
14716 + * Copyright 2005, Broadcom Corporation
14717 + * All Rights Reserved.
14719 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14720 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14721 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14722 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14726 +#include <typedefs.h>
14728 +#include <bcmutils.h>
14729 +#include <bcmsrom.h>
14730 +#include <bcmdevs.h>
14731 +#include <bcmendian.h>
14732 +#include <sbpcmcia.h>
14733 +#include <pcicfg.h>
14734 +#include <sbutils.h>
14735 +#include <bcmnvram.h>
14737 +#include <proto/ethernet.h> /* for sprom content groking */
14739 +#define VARS_MAX 4096 /* should be reduced */
14741 +#define WRITE_ENABLE_DELAY 500 /* 500 ms after write enable/disable toggle */
14742 +#define WRITE_WORD_DELAY 20 /* 20 ms between each word write */
14744 +static int initvars_srom_pci(void *sbh, void *curmap, char **vars, int *count);
14745 +static int initvars_cis_pcmcia(void *sbh, osl_t *osh, char **vars, int *count);
14746 +static int initvars_flash_sb(void *sbh, char **vars, int *count);
14747 +static int srom_parsecis(osl_t *osh, uint8 *cis, char **vars, int *count);
14748 +static int sprom_cmd_pcmcia(osl_t *osh, uint8 cmd);
14749 +static int sprom_read_pcmcia(osl_t *osh, uint16 addr, uint16 *data);
14750 +static int sprom_write_pcmcia(osl_t *osh, uint16 addr, uint16 data);
14751 +static int sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc);
14753 +static int initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count);
14754 +static int initvars_flash(osl_t *osh, char **vp, int len, char *devpath);
14757 + * Initialize local vars from the right source for this platform.
14758 + * Return 0 on success, nonzero on error.
14761 +srom_var_init(void *sbh, uint bustype, void *curmap, osl_t *osh, char **vars, int *count)
14763 + ASSERT(bustype == BUSTYPE(bustype));
14764 + if (vars == NULL || count == NULL)
14767 + switch (BUSTYPE(bustype)) {
14770 + return initvars_flash_sb(sbh, vars, count);
14773 + ASSERT(curmap); /* can not be NULL */
14774 + return initvars_srom_pci(sbh, curmap, vars, count);
14777 + return initvars_cis_pcmcia(sbh, osh, vars, count);
14786 +/* support only 16-bit word read from srom */
14788 +srom_read(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf)
14793 + ASSERT(bustype == BUSTYPE(bustype));
14795 + /* check input - 16-bit access only */
14796 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
14799 + off = byteoff / 2;
14802 + if (BUSTYPE(bustype) == PCI_BUS) {
14805 + srom = (uchar*)curmap + PCI_BAR0_SPROM_OFFSET;
14806 + if (sprom_read_pci(srom, off, buf, nw, FALSE))
14808 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
14809 + for (i = 0; i < nw; i++) {
14810 + if (sprom_read_pcmcia(osh, (uint16)(off + i), (uint16*)(buf + i)))
14820 +/* support only 16-bit word write into srom */
14822 +srom_write(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf)
14825 + uint i, off, nw, crc_range;
14826 + uint16 image[SPROM_SIZE], *p;
14828 + volatile uint32 val32;
14830 + ASSERT(bustype == BUSTYPE(bustype));
14832 + /* check input - 16-bit access only */
14833 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
14836 + crc_range = (((BUSTYPE(bustype) == PCMCIA_BUS) || (BUSTYPE(bustype) == SDIO_BUS)) ? SPROM_SIZE : SPROM_CRC_RANGE) * 2;
14838 + /* if changes made inside crc cover range */
14839 + if (byteoff < crc_range) {
14840 + nw = (((byteoff + nbytes) > crc_range) ? byteoff + nbytes : crc_range) / 2;
14841 + /* read data including entire first 64 words from srom */
14842 + if (srom_read(bustype, curmap, osh, 0, nw * 2, image))
14844 + /* make changes */
14845 + bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes);
14846 + /* calculate crc */
14847 + htol16_buf(image, crc_range);
14848 + crc = ~hndcrc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE);
14849 + ltoh16_buf(image, crc_range);
14850 + image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff);
14855 + off = byteoff / 2;
14859 + if (BUSTYPE(bustype) == PCI_BUS) {
14860 + srom = (uint16*)((uchar*)curmap + PCI_BAR0_SPROM_OFFSET);
14861 + /* enable writes to the SPROM */
14862 + val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32));
14863 + val32 |= SPROM_WRITEEN;
14864 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32);
14865 + bcm_mdelay(WRITE_ENABLE_DELAY);
14867 + for (i = 0; i < nw; i++) {
14868 + W_REG(&srom[off + i], p[i]);
14869 + bcm_mdelay(WRITE_WORD_DELAY);
14871 + /* disable writes to the SPROM */
14872 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 & ~SPROM_WRITEEN);
14873 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
14874 + /* enable writes to the SPROM */
14875 + if (sprom_cmd_pcmcia(osh, SROM_WEN))
14877 + bcm_mdelay(WRITE_ENABLE_DELAY);
14879 + for (i = 0; i < nw; i++) {
14880 + sprom_write_pcmcia(osh, (uint16)(off + i), p[i]);
14881 + bcm_mdelay(WRITE_WORD_DELAY);
14883 + /* disable writes to the SPROM */
14884 + if (sprom_cmd_pcmcia(osh, SROM_WDS))
14890 + bcm_mdelay(WRITE_ENABLE_DELAY);
14896 +srom_parsecis(osl_t *osh, uint8 *cis, char **vars, int *count)
14900 + uint8 tup, tlen, sromrev = 1;
14903 + bool ag_init = FALSE;
14909 + base = vp = MALLOC(osh, VARS_MAX);
14918 + if ((i + tlen) >= CIS_SIZE)
14922 + case CISTPL_MANFID:
14923 + vp += sprintf(vp, "manfid=%d", (cis[i + 1] << 8) + cis[i]);
14925 + vp += sprintf(vp, "prodid=%d", (cis[i + 3] << 8) + cis[i + 2]);
14929 + case CISTPL_FUNCE:
14930 + if (cis[i] == LAN_NID) {
14931 + ASSERT(cis[i + 1] == ETHER_ADDR_LEN);
14932 + bcm_ether_ntoa((uchar*)&cis[i + 2], eabuf);
14933 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
14938 + case CISTPL_CFTABLE:
14939 + vp += sprintf(vp, "regwindowsz=%d", (cis[i + 7] << 8) | cis[i + 6]);
14943 + case CISTPL_BRCM_HNBU:
14944 + switch (cis[i]) {
14945 + case HNBU_SROMREV:
14946 + sromrev = cis[i + 1];
14949 + case HNBU_CHIPID:
14950 + vp += sprintf(vp, "vendid=%d", (cis[i + 2] << 8) + cis[i + 1]);
14952 + vp += sprintf(vp, "devid=%d", (cis[i + 4] << 8) + cis[i + 3]);
14955 + vp += sprintf(vp, "chiprev=%d", (cis[i + 6] << 8) + cis[i + 5]);
14960 + case HNBU_BOARDREV:
14961 + vp += sprintf(vp, "boardrev=%d", cis[i + 1]);
14966 + vp += sprintf(vp, "aa0=%d", cis[i + 1]);
14971 + vp += sprintf(vp, "ag0=%d", cis[i + 1]);
14977 + ASSERT(sromrev > 1);
14978 + vp += sprintf(vp, "cc=%d", cis[i + 1]);
14982 + case HNBU_PAPARMS:
14984 + ASSERT(sromrev == 1);
14985 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + 1]);
14987 + } else if (tlen >= 9) {
14988 + if (tlen == 10) {
14989 + ASSERT(sromrev == 2);
14990 + vp += sprintf(vp, "opo=%d", cis[i + 9]);
14993 + ASSERT(tlen == 9);
14995 + for (j = 0; j < 3; j++) {
14996 + vp += sprintf(vp, "pa0b%d=%d", j,
14997 + (cis[i + (j * 2) + 2] << 8) + cis[i + (j * 2) + 1]);
15000 + vp += sprintf(vp, "pa0itssit=%d", cis[i + 7]);
15002 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + 8]);
15005 + ASSERT(tlen >= 9);
15009 + ASSERT(sromrev == 1);
15010 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
15011 + cis[i + 1], cis[i + 2], cis[i + 3], cis[i + 4],
15012 + cis[i + 5], cis[i + 6], cis[i + 7], cis[i + 8]);
15016 + case HNBU_BOARDFLAGS:
15017 + w32 = (cis[i + 2] << 8) + cis[i + 1];
15019 + w32 |= (cis[i + 4] << 24) + (cis[i + 3] << 16);
15020 + vp += sprintf(vp, "boardflags=0x%x", w32);
15025 + if (cis[i + 1] != 0xff) {
15026 + vp += sprintf(vp, "wl0gpio0=%d", cis[i + 1]);
15029 + if (cis[i + 2] != 0xff) {
15030 + vp += sprintf(vp, "wl0gpio1=%d", cis[i + 2]);
15033 + if (cis[i + 3] != 0xff) {
15034 + vp += sprintf(vp, "wl0gpio2=%d", cis[i + 3]);
15037 + if (cis[i + 4] != 0xff) {
15038 + vp += sprintf(vp, "wl0gpio3=%d", cis[i + 4]);
15044 + ASSERT(sromrev > 1);
15045 + vp += sprintf(vp, "ccode=%c%c", cis[i + 1], cis[i + 2]);
15047 + vp += sprintf(vp, "cctl=0x%x", cis[i + 3]);
15052 + ASSERT(sromrev > 2);
15053 + vp += sprintf(vp, "cckpo=0x%x", (cis[i + 2] << 8) | cis[i + 1]);
15057 + case HNBU_OFDMPO:
15058 + ASSERT(sromrev > 2);
15059 + vp += sprintf(vp, "ofdmpo=0x%x", (cis[i + 4] << 24) |
15060 + (cis[i + 3] << 16) | (cis[i + 2] << 8) | cis[i + 1]);
15068 + } while (tup != 0xff);
15070 + /* Set the srom version */
15071 + vp += sprintf(vp, "sromrev=%d", sromrev);
15074 + /* if there is no antenna gain field, set default */
15075 + if (ag_init == FALSE) {
15076 + ASSERT(sromrev == 1);
15077 + vp += sprintf(vp, "ag0=%d", 0xff);
15081 + /* final nullbyte terminator */
15083 + varsize = (uint)(vp - base);
15085 + ASSERT((vp - base) < VARS_MAX);
15087 + if (varsize == VARS_MAX) {
15090 + vp = MALLOC(osh, varsize);
15093 + bcopy(base, vp, varsize);
15094 + MFREE(osh, base, VARS_MAX);
15101 + *count = varsize;
15107 +/* set PCMCIA sprom command register */
15109 +sprom_cmd_pcmcia(osl_t *osh, uint8 cmd)
15111 + uint8 status = 0;
15112 + uint wait_cnt = 1000;
15114 + /* write sprom command register */
15115 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_CS, &cmd, 1);
15117 + /* wait status */
15118 + while (wait_cnt--) {
15119 + OSL_PCMCIA_READ_ATTR(osh, SROM_CS, &status, 1);
15120 + if (status & SROM_DONE)
15127 +/* read a word from the PCMCIA srom */
15129 +sprom_read_pcmcia(osl_t *osh, uint16 addr, uint16 *data)
15131 + uint8 addr_l, addr_h, data_l, data_h;
15133 + addr_l = (uint8)((addr * 2) & 0xff);
15134 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
15136 + /* set address */
15137 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
15138 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
15141 + if (sprom_cmd_pcmcia(osh, SROM_READ))
15145 + data_h = data_l = 0;
15146 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAH, &data_h, 1);
15147 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAL, &data_l, 1);
15149 + *data = (data_h << 8) | data_l;
15153 +/* write a word to the PCMCIA srom */
15155 +sprom_write_pcmcia(osl_t *osh, uint16 addr, uint16 data)
15157 + uint8 addr_l, addr_h, data_l, data_h;
15159 + addr_l = (uint8)((addr * 2) & 0xff);
15160 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
15161 + data_l = (uint8)(data & 0xff);
15162 + data_h = (uint8)((data >> 8) & 0xff);
15164 + /* set address */
15165 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
15166 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
15169 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAH, &data_h, 1);
15170 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAL, &data_l, 1);
15173 + return sprom_cmd_pcmcia(osh, SROM_WRITE);
15177 + * Read in and validate sprom.
15178 + * Return 0 on success, nonzero on error.
15181 +sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc)
15186 + /* read the sprom */
15187 + for (i = 0; i < nwords; i++)
15188 + buf[i] = R_REG(&sprom[wordoff + i]);
15191 + /* fixup the endianness so crc8 will pass */
15192 + htol16_buf(buf, nwords * 2);
15193 + if (hndcrc8((uint8*)buf, nwords * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE)
15195 + /* now correct the endianness of the byte array */
15196 + ltoh16_buf(buf, nwords * 2);
15203 +* Create variable table from memory.
15204 +* Return 0 on success, nonzero on error.
15207 +initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count)
15209 + int c = (int)(end - start);
15211 + /* do it only when there is more than just the null string */
15213 + char *vp = MALLOC(osh, c);
15216 + return BCME_NOMEM;
15217 + bcopy(start, vp, c);
15230 +* Find variables with <devpath> from flash. 'base' points to the beginning
15231 +* of the table upon enter and to the end of the table upon exit when success.
15232 +* Return 0 on success, nonzero on error.
15235 +initvars_flash(osl_t *osh, char **base, int size, char *devpath)
15237 + char *vp = *base;
15241 + uint l, dl, copy_len;
15243 + /* allocate memory and read in flash */
15244 + if (!(flash = MALLOC(osh, NVRAM_SPACE)))
15245 + return BCME_NOMEM;
15246 + if ((err = BCMINIT(nvram_getall)(flash, NVRAM_SPACE)))
15249 + /* grab vars with the <devpath> prefix in name */
15250 + dl = strlen(devpath);
15251 + for (s = flash; s && *s; s += l + 1) {
15254 + /* skip non-matching variable */
15255 + if (strncmp(s, devpath, dl))
15258 + /* is there enough room to copy? */
15259 + copy_len = l - dl + 1;
15260 + if (size < (int)copy_len) {
15261 + err = BCME_BUFTOOSHORT;
15265 + /* no prefix, just the name=value */
15266 + strcpy(vp, &s[dl]);
15268 + size -= copy_len;
15271 + /* add null string as terminator */
15273 + err = BCME_BUFTOOSHORT;
15280 +exit: MFREE(osh, flash, NVRAM_SPACE);
15285 + * Initialize nonvolatile variable table from flash.
15286 + * Return 0 on success, nonzero on error.
15289 +initvars_flash_sb(void *sbh, char **vars, int *count)
15291 + osl_t *osh = sb_osh(sbh);
15292 + char devpath[SB_DEVPATH_BUFSZ];
15299 + if ((err = sb_devpath(sbh, devpath, sizeof(devpath))))
15302 + base = vp = MALLOC(osh, VARS_MAX);
15305 + return BCME_NOMEM;
15307 + if ((err = initvars_flash(osh, &vp, VARS_MAX, devpath)))
15310 + err = initvars_table(osh, base, vp, vars, count);
15312 +err: MFREE(osh, base, VARS_MAX);
15317 + * Initialize nonvolatile variable table from sprom.
15318 + * Return 0 on success, nonzero on error.
15321 +initvars_srom_pci(void *sbh, void *curmap, char **vars, int *count)
15325 + struct ether_addr ea;
15330 + osl_t *osh = sb_osh(sbh);
15331 + bool flash = FALSE;
15332 + char name[SB_DEVPATH_BUFSZ+16], *value;
15333 + char devpath[SB_DEVPATH_BUFSZ];
15337 + * Apply CRC over SROM content regardless SROM is present or not,
15338 + * and use variable <devpath>sromrev's existance in flash to decide
15339 + * if we should return an error when CRC fails or read SROM variables
15342 + if (sprom_read_pci((void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, sizeof(b)/sizeof(b[0]), TRUE)) {
15343 + if ((err = sb_devpath(sbh, devpath, sizeof(devpath))))
15345 + sprintf(name, "%ssromrev", devpath);
15346 + if (!(value = getvar(NULL, name)))
15348 + sromrev = (uint8)bcm_strtoul(value, NULL, 0);
15351 + /* srom is good */
15353 + /* top word of sprom contains version and crc8 */
15354 + sromrev = b[63] & 0xff;
15355 + /* bcm4401 sroms misprogrammed */
15356 + if (sromrev == 0x10)
15360 + /* srom version check */
15367 + base = vp = MALLOC(osh, VARS_MAX);
15372 + /* read variables from flash */
15374 + if ((err = initvars_flash(osh, &vp, VARS_MAX, devpath)))
15379 + vp += sprintf(vp, "sromrev=%d", sromrev);
15382 + if (sromrev >= 3) {
15383 + /* New section takes over the 3th hardware function space */
15385 + /* Words 22+23 are 11a (mid) ofdm power offsets */
15386 + w32 = ((uint32)b[23] << 16) | b[22];
15387 + vp += sprintf(vp, "ofdmapo=%d", w32);
15390 + /* Words 24+25 are 11a (low) ofdm power offsets */
15391 + w32 = ((uint32)b[25] << 16) | b[24];
15392 + vp += sprintf(vp, "ofdmalpo=%d", w32);
15395 + /* Words 26+27 are 11a (high) ofdm power offsets */
15396 + w32 = ((uint32)b[27] << 16) | b[26];
15397 + vp += sprintf(vp, "ofdmahpo=%d", w32);
15400 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
15401 + w32 = ((uint32)b[43] << 24) | ((uint32)b[42] << 8);
15402 + vp += sprintf(vp, "gpiotimerval=%d", w32);
15404 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
15405 + w32 = ((uint32)((unsigned char)(b[21] >> 8) & 0xFF) << 24) | /* oncount*/
15406 + ((uint32)((unsigned char)(b[21] & 0xFF)) << 8); /* offcount */
15407 + vp += sprintf(vp, "gpiotimerval=%d", w32);
15412 + if (sromrev >= 2) {
15413 + /* New section takes over the 4th hardware function space */
15415 + /* Word 29 is max power 11a high/low */
15417 + vp += sprintf(vp, "pa1himaxpwr=%d", w & 0xff);
15419 + vp += sprintf(vp, "pa1lomaxpwr=%d", (w >> 8) & 0xff);
15422 + /* Words 30-32 set the 11alow pa settings,
15423 + * 33-35 are the 11ahigh ones.
15425 + for (i = 0; i < 3; i++) {
15426 + vp += sprintf(vp, "pa1lob%d=%d", i, b[30 + i]);
15428 + vp += sprintf(vp, "pa1hib%d=%d", i, b[33 + i]);
15433 + vp += sprintf(vp, "ccode=");
15435 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff));
15440 + /* parameter section of sprom starts at byte offset 72 */
15443 + /* first 6 bytes are il0macaddr */
15444 + ea.octet[0] = (b[woff] >> 8) & 0xff;
15445 + ea.octet[1] = b[woff] & 0xff;
15446 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
15447 + ea.octet[3] = b[woff+1] & 0xff;
15448 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
15449 + ea.octet[5] = b[woff+2] & 0xff;
15450 + woff += ETHER_ADDR_LEN/2 ;
15451 + bcm_ether_ntoa((uchar*)&ea, eabuf);
15452 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
15455 + /* next 6 bytes are et0macaddr */
15456 + ea.octet[0] = (b[woff] >> 8) & 0xff;
15457 + ea.octet[1] = b[woff] & 0xff;
15458 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
15459 + ea.octet[3] = b[woff+1] & 0xff;
15460 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
15461 + ea.octet[5] = b[woff+2] & 0xff;
15462 + woff += ETHER_ADDR_LEN/2 ;
15463 + bcm_ether_ntoa((uchar*)&ea, eabuf);
15464 + vp += sprintf(vp, "et0macaddr=%s", eabuf);
15467 + /* next 6 bytes are et1macaddr */
15468 + ea.octet[0] = (b[woff] >> 8) & 0xff;
15469 + ea.octet[1] = b[woff] & 0xff;
15470 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
15471 + ea.octet[3] = b[woff+1] & 0xff;
15472 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
15473 + ea.octet[5] = b[woff+2] & 0xff;
15474 + woff += ETHER_ADDR_LEN/2 ;
15475 + bcm_ether_ntoa((uchar*)&ea, eabuf);
15476 + vp += sprintf(vp, "et1macaddr=%s", eabuf);
15480 + * Enet phy settings one or two singles or a dual
15481 + * Bits 4-0 : MII address for enet0 (0x1f for not there)
15482 + * Bits 9-5 : MII address for enet1 (0x1f for not there)
15483 + * Bit 14 : Mdio for enet0
15484 + * Bit 15 : Mdio for enet1
15487 + vp += sprintf(vp, "et0phyaddr=%d", (w & 0x1f));
15489 + vp += sprintf(vp, "et1phyaddr=%d", ((w >> 5) & 0x1f));
15491 + vp += sprintf(vp, "et0mdcport=%d", ((w >> 14) & 0x1));
15493 + vp += sprintf(vp, "et1mdcport=%d", ((w >> 15) & 0x1));
15496 + /* Word 46 has board rev, antennas 0/1 & Country code/control */
15498 + vp += sprintf(vp, "boardrev=%d", w & 0xff);
15502 + vp += sprintf(vp, "cctl=%d", (w >> 8) & 0xf);
15504 + vp += sprintf(vp, "cc=%d", (w >> 8) & 0xf);
15507 + vp += sprintf(vp, "aa0=%d", (w >> 12) & 0x3);
15510 + vp += sprintf(vp, "aa1=%d", (w >> 14) & 0x3);
15513 + /* Words 47-49 set the (wl) pa settings */
15516 + for (i = 0; i < 3; i++) {
15517 + vp += sprintf(vp, "pa0b%d=%d", i, b[woff+i]);
15519 + vp += sprintf(vp, "pa1b%d=%d", i, b[woff+i+6]);
15524 + * Words 50-51 set the customer-configured wl led behavior.
15525 + * 8 bits/gpio pin. High bit: activehi=0, activelo=1;
15526 + * LED behavior values defined in wlioctl.h .
15529 + if ((w != 0) && (w != 0xffff)) {
15531 + vp += sprintf(vp, "wl0gpio0=%d", (w & 0xff));
15535 + vp += sprintf(vp, "wl0gpio1=%d", (w >> 8) & 0xff);
15539 + if ((w != 0) && (w != 0xffff)) {
15541 + vp += sprintf(vp, "wl0gpio2=%d", w & 0xff);
15545 + vp += sprintf(vp, "wl0gpio3=%d", (w >> 8) & 0xff);
15549 + /* Word 52 is max power 0/1 */
15551 + vp += sprintf(vp, "pa0maxpwr=%d", w & 0xff);
15553 + vp += sprintf(vp, "pa1maxpwr=%d", (w >> 8) & 0xff);
15556 + /* Word 56 is idle tssi target 0/1 */
15558 + vp += sprintf(vp, "pa0itssit=%d", w & 0xff);
15560 + vp += sprintf(vp, "pa1itssit=%d", (w >> 8) & 0xff);
15563 + /* Word 57 is boardflags, if not programmed make it zero */
15564 + w32 = (uint32)b[57];
15565 + if (w32 == 0xffff) w32 = 0;
15566 + if (sromrev > 1) {
15567 + /* Word 28 is the high bits of boardflags */
15568 + w32 |= (uint32)b[28] << 16;
15570 + vp += sprintf(vp, "boardflags=%d", w32);
15573 + /* Word 58 is antenna gain 0/1 */
15575 + vp += sprintf(vp, "ag0=%d", w & 0xff);
15578 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff);
15581 + if (sromrev == 1) {
15582 + /* set the oem string */
15583 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
15584 + ((b[59] >> 8) & 0xff), (b[59] & 0xff),
15585 + ((b[60] >> 8) & 0xff), (b[60] & 0xff),
15586 + ((b[61] >> 8) & 0xff), (b[61] & 0xff),
15587 + ((b[62] >> 8) & 0xff), (b[62] & 0xff));
15589 + } else if (sromrev == 2) {
15590 + /* Word 60 OFDM tx power offset from CCK level */
15591 + /* OFDM Power Offset - opo */
15592 + vp += sprintf(vp, "opo=%d", b[60] & 0xff);
15595 + /* Word 60: cck power offsets */
15596 + vp += sprintf(vp, "cckpo=%d", b[60]);
15599 + /* Words 61+62: 11g ofdm power offsets */
15600 + w32 = ((uint32)b[62] << 16) | b[61];
15601 + vp += sprintf(vp, "ofdmgpo=%d", w32);
15605 + /* final nullbyte terminator */
15608 + ASSERT((vp - base) <= VARS_MAX);
15610 +done: err = initvars_table(osh, base, vp, vars, count);
15612 +err: MFREE(osh, base, VARS_MAX);
15617 + * Read the cis and call parsecis to initialize the vars.
15618 + * Return 0 on success, nonzero on error.
15621 +initvars_cis_pcmcia(void *sbh, osl_t *osh, char **vars, int *count)
15623 + uint8 *cis = NULL;
15627 + data_sz = (sb_pcmciarev(sbh) == 1) ? (SPROM_SIZE * 2) : CIS_SIZE;
15629 + if ((cis = MALLOC(osh, data_sz)) == NULL)
15632 + if (sb_pcmciarev(sbh) == 1) {
15633 + if (srom_read(PCMCIA_BUS, (void *)NULL, osh, 0, data_sz, (uint16 *)cis)) {
15634 + MFREE(osh, cis, data_sz);
15637 + /* fix up endianess for 16-bit data vs 8-bit parsing */
15638 + ltoh16_buf((uint16 *)cis, data_sz);
15640 + OSL_PCMCIA_READ_ATTR(osh, 0, cis, data_sz);
15642 + rc = srom_parsecis(osh, cis, vars, count);
15644 + MFREE(osh, cis, data_sz);
15649 diff -Nur linux-2.4.32/drivers/net/hnd/bcmutils.c linux-2.4.32-brcm/drivers/net/hnd/bcmutils.c
15650 --- linux-2.4.32/drivers/net/hnd/bcmutils.c 1970-01-01 01:00:00.000000000 +0100
15651 +++ linux-2.4.32-brcm/drivers/net/hnd/bcmutils.c 2005-12-16 23:39:11.288858250 +0100
15654 + * Misc useful OS-independent routines.
15656 + * Copyright 2005, Broadcom Corporation
15657 + * All Rights Reserved.
15659 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
15660 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
15661 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
15662 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
15666 +#include <typedefs.h>
15669 +#include <sbutils.h>
15670 +#include <bcmnvram.h>
15672 +#include <stdio.h>
15673 +#include <string.h>
15675 +#include <bcmutils.h>
15676 +#include <bcmendian.h>
15677 +#include <bcmdevs.h>
15680 +/* copy a pkt buffer chain into a buffer */
15682 +pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf)
15687 + len = 4096; /* "infinite" */
15689 + /* skip 'offset' bytes */
15690 + for (; p && offset; p = PKTNEXT(osh, p)) {
15691 + if (offset < (uint)PKTLEN(osh, p))
15693 + offset -= PKTLEN(osh, p);
15699 + /* copy the data */
15700 + for (; p && len; p = PKTNEXT(osh, p)) {
15701 + n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len);
15702 + bcopy(PKTDATA(osh, p) + offset, buf, n);
15712 +/* return total length of buffer chain */
15714 +pkttotlen(osl_t *osh, void *p)
15719 + for (; p; p = PKTNEXT(osh, p))
15720 + total += PKTLEN(osh, p);
15725 +pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[])
15727 + q->head = q->tail = NULL;
15728 + q->maxlen = maxlen;
15731 + q->priority = TRUE;
15732 + bcopy(prio_map, q->prio_map, sizeof(q->prio_map));
15735 + q->priority = FALSE;
15738 +/* should always check pktq_full before calling pktenq */
15740 +pktenq(struct pktq *q, void *p, bool lifo)
15742 + void *next, *prev;
15744 + /* allow 10 pkts slack */
15745 + ASSERT(q->len < (q->maxlen + 10));
15747 + /* Queueing chains not allowed */
15748 + ASSERT(PKTLINK(p) == NULL);
15750 + /* Queue is empty */
15751 + if (q->tail == NULL) {
15752 + ASSERT(q->head == NULL);
15753 + q->head = q->tail = p;
15756 + /* Insert at head or tail */
15757 + else if (q->priority == FALSE) {
15758 + /* Insert at head (LIFO) */
15760 + PKTSETLINK(p, q->head);
15763 + /* Insert at tail (FIFO) */
15765 + ASSERT(PKTLINK(q->tail) == NULL);
15766 + PKTSETLINK(q->tail, p);
15767 + PKTSETLINK(p, NULL);
15772 + /* Insert by priority */
15774 + /* legal priorities 0-7 */
15775 + ASSERT(PKTPRIO(p) <= MAXPRIO);
15779 + /* Shortcut to insertion at tail */
15780 + if (_pktq_pri(q, PKTPRIO(p)) < _pktq_pri(q, PKTPRIO(q->tail)) ||
15781 + (!lifo && _pktq_pri(q, PKTPRIO(p)) <= _pktq_pri(q, PKTPRIO(q->tail)))) {
15785 + /* Insert at head or in the middle */
15790 + /* Walk the queue */
15791 + for (; next; prev = next, next = PKTLINK(next)) {
15792 + /* Priority queue invariant */
15793 + ASSERT(!prev || _pktq_pri(q, PKTPRIO(prev)) >= _pktq_pri(q, PKTPRIO(next)));
15794 + /* Insert at head of string of packets of same priority (LIFO) */
15796 + if (_pktq_pri(q, PKTPRIO(p)) >= _pktq_pri(q, PKTPRIO(next)))
15799 + /* Insert at tail of string of packets of same priority (FIFO) */
15801 + if (_pktq_pri(q, PKTPRIO(p)) > _pktq_pri(q, PKTPRIO(next)))
15805 + /* Insert at tail */
15806 + if (next == NULL) {
15807 + ASSERT(PKTLINK(q->tail) == NULL);
15808 + PKTSETLINK(q->tail, p);
15809 + PKTSETLINK(p, NULL);
15812 + /* Insert in the middle */
15814 + PKTSETLINK(prev, p);
15815 + PKTSETLINK(p, next);
15817 + /* Insert at head */
15819 + PKTSETLINK(p, q->head);
15824 + /* List invariants after insertion */
15826 + ASSERT(PKTLINK(q->tail) == NULL);
15831 +/* dequeue packet at head */
15833 +pktdeq(struct pktq *q)
15837 + if ((p = q->head)) {
15839 + q->head = PKTLINK(p);
15840 + PKTSETLINK(p, NULL);
15842 + if (q->head == NULL)
15846 + ASSERT(q->tail == NULL);
15852 +/* dequeue packet at tail */
15854 +pktdeqtail(struct pktq *q)
15857 + void *next, *prev;
15859 + if (q->head == q->tail) { /* last packet on queue or queue empty */
15861 + q->head = q->tail = NULL;
15866 + /* start walk at head */
15870 + /* Walk the queue to find prev of q->tail */
15871 + for (; next; prev = next, next = PKTLINK(next)) {
15872 + if (next == q->tail)
15878 + PKTSETLINK(prev, NULL);
15886 +unsigned char bcm_ctype[] = {
15887 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */
15888 + _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 */
15889 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */
15890 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */
15891 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */
15892 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */
15893 + _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */
15894 + _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */
15895 + _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 */
15896 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */
15897 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */
15898 + _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */
15899 + _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 */
15900 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */
15901 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */
15902 + _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */
15903 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
15904 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
15905 + _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 */
15906 + _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 */
15907 + _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 */
15908 + _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 */
15909 + _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 */
15910 + _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 */
15914 +bcm_toupper(uchar c)
15916 + if (bcm_islower(c))
15922 +bcm_strtoul(char *cp, char **endp, uint base)
15924 + ulong result, value;
15929 + while (bcm_isspace(*cp))
15932 + if (cp[0] == '+')
15934 + else if (cp[0] == '-') {
15940 + if (cp[0] == '0') {
15941 + if ((cp[1] == 'x') || (cp[1] == 'X')) {
15950 + } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) {
15956 + while (bcm_isxdigit(*cp) &&
15957 + (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) {
15958 + result = result*base + value;
15963 + result = (ulong)(result * -1);
15966 + *endp = (char *)cp;
15978 + while (bcm_isdigit(*s))
15979 + n = (n * 10) + *s++ - '0';
15983 +/* return pointer to location of substring 'needle' in 'haystack' */
15985 +bcmstrstr(char *haystack, char *needle)
15990 + if ((haystack == NULL) || (needle == NULL))
15991 + return (haystack);
15993 + nlen = strlen(needle);
15994 + len = strlen(haystack) - nlen + 1;
15996 + for (i = 0; i < len; i++)
15997 + if (bcmp(needle, &haystack[i], nlen) == 0)
15998 + return (&haystack[i]);
16003 +bcmstrcat(char *dest, const char *src)
16005 + strcpy(&dest[strlen(dest)], src);
16009 +#if defined(CONFIG_USBRNDIS_RETAIL) || defined(NDIS_MINIPORT_DRIVER)
16010 +/* registry routine buffer preparation utility functions:
16011 + * parameter order is like strncpy, but returns count
16012 + * of bytes copied. Minimum bytes copied is null char(1)/wchar(2)
16022 + ulong copyct = 1;
16025 + if (abuflen == 0)
16028 + /* wbuflen is in bytes */
16029 + wbuflen /= sizeof(ushort);
16031 + for (i = 0; i < wbuflen; ++i) {
16032 + if (--abuflen == 0)
16034 + *abuf++ = (char) *wbuf++;
16044 +bcm_ether_ntoa(char *ea, char *buf)
16046 + sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x",
16047 + (uchar)ea[0]&0xff, (uchar)ea[1]&0xff, (uchar)ea[2]&0xff,
16048 + (uchar)ea[3]&0xff, (uchar)ea[4]&0xff, (uchar)ea[5]&0xff);
16052 +/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
16054 +bcm_ether_atoe(char *p, char *ea)
16059 + ea[i++] = (char) bcm_strtoul(p, &p, 16);
16060 + if (!*p++ || i == 6)
16068 +bcm_mdelay(uint ms)
16072 + for (i = 0; i < ms; i++) {
16078 + * Search the name=value vars for a specific one and return its value.
16079 + * Returns NULL if not found.
16082 +getvar(char *vars, char *name)
16087 + len = strlen(name);
16089 + /* first look in vars[] */
16090 + for (s = vars; s && *s; ) {
16091 + if ((bcmp(s, name, len) == 0) && (s[len] == '='))
16092 + return (&s[len+1]);
16098 + /* then query nvram */
16099 + return (BCMINIT(nvram_get)(name));
16103 + * Search the vars for a specific one and return its value as
16104 + * an integer. Returns 0 if not found.
16107 +getintvar(char *vars, char *name)
16111 + if ((val = getvar(vars, name)) == NULL)
16114 + return (bcm_strtoul(val, NULL, 0));
16118 +/* Search for token in comma separated token-string */
16120 +findmatch(char *string, char *name)
16125 + len = strlen(name);
16126 + while ((c = strchr(string, ',')) != NULL) {
16127 + if (len == (uint)(c - string) && !strncmp(string, name, len))
16132 + return (!strcmp(string, name));
16135 +/* Return gpio pin number assigned to the named pin */
16137 +* Variable should be in format:
16139 +* gpio<N>=pin_name,pin_name
16141 +* This format allows multiple features to share the gpio with mutual
16144 +* 'def_pin' is returned if a specific gpio is not defined for the requested functionality
16145 +* and if def_pin is not used by others.
16148 +getgpiopin(char *vars, char *pin_name, uint def_pin)
16150 + char name[] = "gpioXXXX";
16154 + /* Go thru all possibilities till a match in pin name */
16155 + for (pin = 0; pin < GPIO_NUMPINS; pin ++) {
16156 + sprintf(name, "gpio%d", pin);
16157 + val = getvar(vars, name);
16158 + if (val && findmatch(val, pin_name))
16162 + if (def_pin != GPIO_PIN_NOTDEFINED) {
16163 + /* make sure the default pin is not used by someone else */
16164 + sprintf(name, "gpio%d", def_pin);
16165 + if (getvar(vars, name)) {
16166 + def_pin = GPIO_PIN_NOTDEFINED;
16174 +static char bcm_undeferrstr[BCME_STRLEN];
16176 +static const char *bcmerrorstrtable[] = \
16178 + "Undefined error", /* BCME_ERROR */
16179 + "Bad Argument", /* BCME_BADARG*/
16180 + "Bad Option", /* BCME_BADOPTION*/
16181 + "Not up", /* BCME_NOTUP */
16182 + "Not down", /* BCME_NOTDOWN */
16183 + "Not AP", /* BCME_NOTAP */
16184 + "Not STA", /* BCME_NOTSTA */
16185 + "Bad Key Index", /* BCME_BADKEYIDX */
16186 + "Radio Off", /* BCME_RADIOOFF */
16187 + "Not band locked", /* BCME_NOTBANDLOCKED */
16188 + "No clock", /* BCME_NOCLK */
16189 + "Bad Rate valueset", /* BCME_BADRATESET */
16190 + "Bad Band", /* BCME_BADBAND */
16191 + "Buffer too short", /* BCME_BUFTOOSHORT */
16192 + "Buffer too length", /* BCME_BUFTOOLONG */
16193 + "Busy", /* BCME_BUSY */
16194 + "Not Associated", /* BCME_NOTASSOCIATED */
16195 + "Bad SSID len", /* BCME_BADSSIDLEN */
16196 + "Out of Range Channel", /* BCME_OUTOFRANGECHAN */
16197 + "Bad Channel", /* BCME_BADCHAN */
16198 + "Bad Address", /* BCME_BADADDR */
16199 + "Not Enough Resources", /* BCME_NORESOURCE */
16200 + "Unsupported", /* BCME_UNSUPPORTED */
16201 + "Bad length", /* BCME_BADLENGTH */
16202 + "Not Ready", /* BCME_NOTREADY */
16203 + "Not Permitted", /* BCME_EPERM */
16204 + "No Memory", /* BCME_NOMEM */
16205 + "Associated", /* BCME_ASSOCIATED */
16206 + "Not In Range", /* BCME_RANGE */
16207 + "Not Found" /* BCME_NOTFOUND */
16210 +/* Convert the Error codes into related Error strings */
16212 +bcmerrorstr(int bcmerror)
16214 + int abs_bcmerror;
16216 + abs_bcmerror = ABS(bcmerror);
16218 + /* check if someone added a bcmerror code but forgot to add errorstring */
16219 + ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(bcmerrorstrtable) - 1));
16220 + if ( (bcmerror > 0) || (abs_bcmerror > ABS(BCME_LAST))) {
16221 + sprintf(bcm_undeferrstr, "undefined Error %d", bcmerror);
16222 + return bcm_undeferrstr;
16225 + ASSERT((strlen((char*)bcmerrorstrtable[abs_bcmerror])) < BCME_STRLEN);
16227 + return bcmerrorstrtable[abs_bcmerror];
16229 +#endif /* #ifdef BCMDRIVER */
16232 +/*******************************************************************************
16235 + * Computes a crc8 over the input data using the polynomial:
16237 + * x^8 + x^7 +x^6 + x^4 + x^2 + 1
16239 + * The caller provides the initial value (either CRC8_INIT_VALUE
16240 + * or the previous returned value) to allow for processing of
16241 + * discontiguous blocks of data. When generating the CRC the
16242 + * caller is responsible for complementing the final return value
16243 + * and inserting it into the byte stream. When checking, a final
16244 + * return value of CRC8_GOOD_VALUE indicates a valid CRC.
16246 + * Reference: Dallas Semiconductor Application Note 27
16247 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
16248 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
16249 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
16251 + ******************************************************************************/
16253 +static uint8 crc8_table[256] = {
16254 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
16255 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
16256 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
16257 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
16258 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
16259 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
16260 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
16261 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
16262 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
16263 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
16264 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
16265 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
16266 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
16267 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
16268 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
16269 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
16270 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
16271 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
16272 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
16273 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
16274 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
16275 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
16276 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
16277 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
16278 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
16279 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
16280 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
16281 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
16282 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
16283 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
16284 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
16285 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
16288 +#define CRC_INNER_LOOP(n, c, x) \
16289 + (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff]
16293 + uint8 *pdata, /* pointer to array of data to process */
16294 + uint nbytes, /* number of input data bytes to process */
16295 + uint8 crc /* either CRC8_INIT_VALUE or previous return value */
16298 + /* hard code the crc loop instead of using CRC_INNER_LOOP macro
16299 + * to avoid the undefined and unnecessary (uint8 >> 8) operation. */
16300 + while (nbytes-- > 0)
16301 + crc = crc8_table[(crc ^ *pdata++) & 0xff];
16306 +/*******************************************************************************
16309 + * Computes a crc16 over the input data using the polynomial:
16311 + * x^16 + x^12 +x^5 + 1
16313 + * The caller provides the initial value (either CRC16_INIT_VALUE
16314 + * or the previous returned value) to allow for processing of
16315 + * discontiguous blocks of data. When generating the CRC the
16316 + * caller is responsible for complementing the final return value
16317 + * and inserting it into the byte stream. When checking, a final
16318 + * return value of CRC16_GOOD_VALUE indicates a valid CRC.
16320 + * Reference: Dallas Semiconductor Application Note 27
16321 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
16322 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
16323 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
16325 + ******************************************************************************/
16327 +static uint16 crc16_table[256] = {
16328 + 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
16329 + 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
16330 + 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
16331 + 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
16332 + 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
16333 + 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
16334 + 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
16335 + 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
16336 + 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
16337 + 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
16338 + 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
16339 + 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
16340 + 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
16341 + 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
16342 + 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
16343 + 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
16344 + 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
16345 + 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
16346 + 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
16347 + 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
16348 + 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
16349 + 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
16350 + 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
16351 + 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
16352 + 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
16353 + 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
16354 + 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
16355 + 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
16356 + 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
16357 + 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
16358 + 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
16359 + 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
16364 + uint8 *pdata, /* pointer to array of data to process */
16365 + uint nbytes, /* number of input data bytes to process */
16366 + uint16 crc /* either CRC16_INIT_VALUE or previous return value */
16369 + while (nbytes-- > 0)
16370 + CRC_INNER_LOOP(16, crc, *pdata++);
16374 +static uint32 crc32_table[256] = {
16375 + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
16376 + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
16377 + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
16378 + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
16379 + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
16380 + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
16381 + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
16382 + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
16383 + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
16384 + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
16385 + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
16386 + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
16387 + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
16388 + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
16389 + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
16390 + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
16391 + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
16392 + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
16393 + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
16394 + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
16395 + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
16396 + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
16397 + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
16398 + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
16399 + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
16400 + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
16401 + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
16402 + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
16403 + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
16404 + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
16405 + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
16406 + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
16407 + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
16408 + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
16409 + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
16410 + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
16411 + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
16412 + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
16413 + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
16414 + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
16415 + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
16416 + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
16417 + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
16418 + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
16419 + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
16420 + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
16421 + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
16422 + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
16423 + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
16424 + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
16425 + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
16426 + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
16427 + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
16428 + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
16429 + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
16430 + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
16431 + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
16432 + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
16433 + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
16434 + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
16435 + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
16436 + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
16437 + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
16438 + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
16443 + uint8 *pdata, /* pointer to array of data to process */
16444 + uint nbytes, /* number of input data bytes to process */
16445 + uint32 crc /* either CRC32_INIT_VALUE or previous return value */
16451 + ulong *tptr = (ulong *)tmp;
16453 + /* in case the beginning of the buffer isn't aligned */
16454 + pend = (uint8 *)((uint)(pdata + 3) & 0xfffffffc);
16455 + nbytes -= (pend - pdata);
16456 + while (pdata < pend)
16457 + CRC_INNER_LOOP(32, crc, *pdata++);
16459 + /* handle bulk of data as 32-bit words */
16460 + pend = pdata + (nbytes & 0xfffffffc);
16461 + while (pdata < pend) {
16462 + tptr = *((ulong *) pdata);
16463 + *((ulong *) pdata) += 1;
16464 + CRC_INNER_LOOP(32, crc, tmp[0]);
16465 + CRC_INNER_LOOP(32, crc, tmp[1]);
16466 + CRC_INNER_LOOP(32, crc, tmp[2]);
16467 + CRC_INNER_LOOP(32, crc, tmp[3]);
16470 + /* 1-3 bytes at end of buffer */
16471 + pend = pdata + (nbytes & 0x03);
16472 + while (pdata < pend)
16473 + CRC_INNER_LOOP(32, crc, *pdata++);
16475 + pend = pdata + nbytes;
16476 + while (pdata < pend)
16477 + CRC_INNER_LOOP(32, crc, *pdata++);
16485 +#define CBUFSIZ (CLEN+4)
16488 +void testcrc32(void)
16492 + uint len[CNBUFS];
16494 + uint32 crc32tv[CNBUFS] =
16495 + {0xd2cb1faa, 0xd385c8fa, 0xf5b4f3f3, 0x55789e20, 0x00343110};
16497 + ASSERT((buf = MALLOC(CBUFSIZ*CNBUFS)) != NULL);
16499 + /* step through all possible alignments */
16500 + for (l=0;l<=4;l++) {
16501 + for (j=0; j<CNBUFS; j++) {
16503 + for (k=0; k<len[j]; k++)
16504 + *(buf + j*CBUFSIZ + (k+l)) = (j+k) & 0xff;
16507 + for (j=0; j<CNBUFS; j++) {
16508 + crcr = crc32(buf + j*CBUFSIZ + l, len[j], CRC32_INIT_VALUE);
16509 + ASSERT(crcr == crc32tv[j]);
16513 + MFREE(buf, CBUFSIZ*CNBUFS);
16520 + * Advance from the current 1-byte tag/1-byte length/variable-length value
16521 + * triple, to the next, returning a pointer to the next.
16522 + * If the current or next TLV is invalid (does not fit in given buffer length),
16523 + * NULL is returned.
16524 + * *buflen is not modified if the TLV elt parameter is invalid, or is decremented
16525 + * by the TLV paramter's length if it is valid.
16528 +bcm_next_tlv(bcm_tlv_t *elt, int *buflen)
16532 + /* validate current elt */
16533 + if (!bcm_valid_tlv(elt, *buflen))
16536 + /* advance to next elt */
16538 + elt = (bcm_tlv_t*)(elt->data + len);
16539 + *buflen -= (2 + len);
16541 + /* validate next elt */
16542 + if (!bcm_valid_tlv(elt, *buflen))
16549 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
16550 + * triples, returning a pointer to the substring whose first element
16554 +bcm_parse_tlvs(void *buf, int buflen, uint key)
16559 + elt = (bcm_tlv_t*)buf;
16562 + /* find tagged parameter */
16563 + while (totlen >= 2) {
16564 + int len = elt->len;
16566 + /* validate remaining totlen */
16567 + if ((elt->id == key) && (totlen >= (len + 2)))
16570 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
16571 + totlen -= (len + 2);
16578 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
16579 + * triples, returning a pointer to the substring whose first element
16580 + * matches tag. Stop parsing when we see an element whose ID is greater
16581 + * than the target key.
16584 +bcm_parse_ordered_tlvs(void *buf, int buflen, uint key)
16589 + elt = (bcm_tlv_t*)buf;
16592 + /* find tagged parameter */
16593 + while (totlen >= 2) {
16594 + uint id = elt->id;
16595 + int len = elt->len;
16597 + /* Punt if we start seeing IDs > than target key */
16601 + /* validate remaining totlen */
16602 + if ((id == key) && (totlen >= (len + 2)))
16605 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
16606 + totlen -= (len + 2);
16610 +/* routine to dump fields in a fileddesc structure */
16613 +bcmdumpfields(readreg_rtn read_rtn, void *arg0, void *arg1, struct fielddesc *fielddesc_array, char *buf, uint32 bufsize)
16617 + struct fielddesc *cur_ptr;
16620 + cur_ptr = fielddesc_array;
16622 + while (bufsize > (filled_len + 64)) {
16623 + if (cur_ptr->nameandfmt == NULL)
16625 + len = sprintf(buf, cur_ptr->nameandfmt, read_rtn(arg0, arg1, cur_ptr->offset));
16627 + filled_len += len;
16630 + return filled_len;
16634 +bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen)
16638 + len = strlen(name) + 1;
16640 + if ((len + datalen) > buflen)
16643 + strcpy(buf, name);
16645 + /* append data onto the end of the name string */
16646 + memcpy(&buf[len], data, datalen);
16652 +/* Quarter dBm units to mW
16653 + * Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153
16654 + * Table is offset so the last entry is largest mW value that fits in
16658 +#define QDBM_OFFSET 153
16659 +#define QDBM_TABLE_LEN 40
16661 +/* Smallest mW value that will round up to the first table entry, QDBM_OFFSET.
16662 + * Value is ( mW(QDBM_OFFSET - 1) + mW(QDBM_OFFSET) ) / 2
16664 +#define QDBM_TABLE_LOW_BOUND 6493
16666 +/* Largest mW value that will round down to the last table entry,
16667 + * QDBM_OFFSET + QDBM_TABLE_LEN-1.
16668 + * Value is ( mW(QDBM_OFFSET + QDBM_TABLE_LEN - 1) + mW(QDBM_OFFSET + QDBM_TABLE_LEN) ) / 2.
16670 +#define QDBM_TABLE_HIGH_BOUND 64938
16672 +static const uint16 nqdBm_to_mW_map[QDBM_TABLE_LEN] = {
16673 +/* qdBm: +0 +1 +2 +3 +4 +5 +6 +7 */
16674 +/* 153: */ 6683, 7079, 7499, 7943, 8414, 8913, 9441, 10000,
16675 +/* 161: */ 10593, 11220, 11885, 12589, 13335, 14125, 14962, 15849,
16676 +/* 169: */ 16788, 17783, 18836, 19953, 21135, 22387, 23714, 25119,
16677 +/* 177: */ 26607, 28184, 29854, 31623, 33497, 35481, 37584, 39811,
16678 +/* 185: */ 42170, 44668, 47315, 50119, 53088, 56234, 59566, 63096
16682 +bcm_qdbm_to_mw(uint8 qdbm)
16685 + int idx = qdbm - QDBM_OFFSET;
16687 + if (idx > QDBM_TABLE_LEN) {
16688 + /* clamp to max uint16 mW value */
16692 + /* scale the qdBm index up to the range of the table 0-40
16693 + * where an offset of 40 qdBm equals a factor of 10 mW.
16695 + while (idx < 0) {
16700 + /* return the mW value scaled down to the correct factor of 10,
16701 + * adding in factor/2 to get proper rounding. */
16702 + return ((nqdBm_to_mW_map[idx] + factor/2) / factor);
16706 +bcm_mw_to_qdbm(uint16 mw)
16710 + uint mw_uint = mw;
16713 + /* handle boundary case */
16714 + if (mw_uint <= 1)
16717 + offset = QDBM_OFFSET;
16719 + /* move mw into the range of the table */
16720 + while (mw_uint < QDBM_TABLE_LOW_BOUND) {
16725 + for (qdbm = 0; qdbm < QDBM_TABLE_LEN-1; qdbm++) {
16726 + boundary = nqdBm_to_mW_map[qdbm] + (nqdBm_to_mW_map[qdbm+1] - nqdBm_to_mW_map[qdbm])/2;
16727 + if (mw_uint < boundary) break;
16730 + qdbm += (uint8)offset;
16734 diff -Nur linux-2.4.32/drivers/net/hnd/hnddma.c linux-2.4.32-brcm/drivers/net/hnd/hnddma.c
16735 --- linux-2.4.32/drivers/net/hnd/hnddma.c 1970-01-01 01:00:00.000000000 +0100
16736 +++ linux-2.4.32-brcm/drivers/net/hnd/hnddma.c 2005-12-16 23:39:11.288858250 +0100
16739 + * Generic Broadcom Home Networking Division (HND) DMA module.
16740 + * This supports the following chips: BCM42xx, 44xx, 47xx .
16742 + * Copyright 2005, Broadcom Corporation
16743 + * All Rights Reserved.
16745 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
16746 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
16747 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
16748 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
16753 +#include <typedefs.h>
16755 +#include <bcmendian.h>
16756 +#include <sbconfig.h>
16757 +#include <bcmutils.h>
16758 +#include <bcmdevs.h>
16759 +#include <sbutils.h>
16761 +struct dma_info; /* forward declaration */
16762 +#define di_t struct dma_info
16764 +#include <sbhnddma.h>
16765 +#include <hnddma.h>
16768 +#define DMA_ERROR(args)
16769 +#define DMA_TRACE(args)
16771 +/* default dma message level (if input msg_level pointer is null in dma_attach()) */
16772 +static uint dma_msg_level =
16775 +#define MAXNAMEL 8
16777 +/* dma engine software state */
16778 +typedef struct dma_info {
16779 + hnddma_t hnddma; /* exported structure */
16780 + uint *msg_level; /* message level pointer */
16781 + char name[MAXNAMEL]; /* callers name for diag msgs */
16783 + void *osh; /* os handle */
16784 + sb_t *sbh; /* sb handle */
16786 + bool dma64; /* dma64 enabled */
16787 + bool addrext; /* this dma engine supports DmaExtendedAddrChanges */
16789 + dma32regs_t *d32txregs; /* 32 bits dma tx engine registers */
16790 + dma32regs_t *d32rxregs; /* 32 bits dma rx engine registers */
16791 + dma64regs_t *d64txregs; /* 64 bits dma tx engine registers */
16792 + dma64regs_t *d64rxregs; /* 64 bits dma rx engine registers */
16794 + uint32 dma64align; /* either 8k or 4k depends on number of dd */
16795 + dma32dd_t *txd32; /* pointer to dma32 tx descriptor ring */
16796 + dma64dd_t *txd64; /* pointer to dma64 tx descriptor ring */
16797 + uint ntxd; /* # tx descriptors tunable */
16798 + uint txin; /* index of next descriptor to reclaim */
16799 + uint txout; /* index of next descriptor to post */
16800 + uint txavail; /* # free tx descriptors */
16801 + void **txp; /* pointer to parallel array of pointers to packets */
16802 + ulong txdpa; /* physical address of descriptor ring */
16803 + uint txdalign; /* #bytes added to alloc'd mem to align txd */
16804 + uint txdalloc; /* #bytes allocated for the ring */
16806 + dma32dd_t *rxd32; /* pointer to dma32 rx descriptor ring */
16807 + dma64dd_t *rxd64; /* pointer to dma64 rx descriptor ring */
16808 + uint nrxd; /* # rx descriptors tunable */
16809 + uint rxin; /* index of next descriptor to reclaim */
16810 + uint rxout; /* index of next descriptor to post */
16811 + void **rxp; /* pointer to parallel array of pointers to packets */
16812 + ulong rxdpa; /* physical address of descriptor ring */
16813 + uint rxdalign; /* #bytes added to alloc'd mem to align rxd */
16814 + uint rxdalloc; /* #bytes allocated for the ring */
16817 + uint rxbufsize; /* rx buffer size in bytes */
16818 + uint nrxpost; /* # rx buffers to keep posted */
16819 + uint rxoffset; /* rxcontrol offset */
16820 + uint ddoffsetlow; /* add to get dma address of descriptor ring, low 32 bits */
16821 + uint ddoffsethigh; /* add to get dma address of descriptor ring, high 32 bits */
16822 + uint dataoffsetlow; /* add to get dma address of data buffer, low 32 bits */
16823 + uint dataoffsethigh; /* add to get dma address of data buffer, high 32 bits */
16827 +#define DMA64_ENAB(di) ((di)->dma64)
16829 +#define DMA64_ENAB(di) (0)
16832 +/* descriptor bumping macros */
16833 +#define XXD(x, n) ((x) & ((n) - 1))
16834 +#define TXD(x) XXD((x), di->ntxd)
16835 +#define RXD(x) XXD((x), di->nrxd)
16836 +#define NEXTTXD(i) TXD(i + 1)
16837 +#define PREVTXD(i) TXD(i - 1)
16838 +#define NEXTRXD(i) RXD(i + 1)
16839 +#define NTXDACTIVE(h, t) TXD(t - h)
16840 +#define NRXDACTIVE(h, t) RXD(t - h)
16842 +/* macros to convert between byte offsets and indexes */
16843 +#define B2I(bytes, type) ((bytes) / sizeof(type))
16844 +#define I2B(index, type) ((index) * sizeof(type))
16846 +#define PCI32ADDR_HIGH 0xc0000000 /* address[31:30] */
16847 +#define PCI32ADDR_HIGH_SHIFT 30
16851 +static bool dma_isaddrext(dma_info_t *di);
16852 +static bool dma_alloc(dma_info_t *di, uint direction);
16854 +static bool dma32_alloc(dma_info_t *di, uint direction);
16855 +static void dma32_txreset(dma_info_t *di);
16856 +static void dma32_rxreset(dma_info_t *di);
16857 +static bool dma32_txsuspendedidle(dma_info_t *di);
16858 +static int dma32_txfast(dma_info_t *di, void *p0, uint32 coreflags);
16859 +static void* dma32_getnexttxp(dma_info_t *di, bool forceall);
16860 +static void* dma32_getnextrxp(dma_info_t *di, bool forceall);
16861 +static void dma32_txrotate(di_t *di);
16863 +/* prototype or stubs */
16865 +static bool dma64_alloc(dma_info_t *di, uint direction);
16866 +static void dma64_txreset(dma_info_t *di);
16867 +static void dma64_rxreset(dma_info_t *di);
16868 +static bool dma64_txsuspendedidle(dma_info_t *di);
16869 +static int dma64_txfast(dma_info_t *di, void *p0, uint32 coreflags);
16870 +static void* dma64_getnexttxp(dma_info_t *di, bool forceall);
16871 +static void* dma64_getnextrxp(dma_info_t *di, bool forceall);
16872 +static void dma64_txrotate(di_t *di);
16874 +static bool dma64_alloc(dma_info_t *di, uint direction) { return TRUE; }
16875 +static void dma64_txreset(dma_info_t *di) {}
16876 +static void dma64_rxreset(dma_info_t *di) {}
16877 +static bool dma64_txsuspendedidle(dma_info_t *di) { return TRUE;}
16878 +static int dma64_txfast(dma_info_t *di, void *p0, uint32 coreflags) { return 0; }
16879 +static void* dma64_getnexttxp(dma_info_t *di, bool forceall) { return NULL; }
16880 +static void* dma64_getnextrxp(dma_info_t *di, bool forceall) { return NULL; }
16881 +static void dma64_txrotate(di_t *di) { return; }
16884 +/* old dmaregs struct for compatibility */
16885 +typedef volatile struct {
16886 + /* transmit channel */
16887 + uint32 xmtcontrol; /* enable, et al */
16888 + uint32 xmtaddr; /* descriptor ring base address (4K aligned) */
16889 + uint32 xmtptr; /* last descriptor posted to chip */
16890 + uint32 xmtstatus; /* current active descriptor, et al */
16892 + /* receive channel */
16893 + uint32 rcvcontrol; /* enable, et al */
16894 + uint32 rcvaddr; /* descriptor ring base address (4K aligned) */
16895 + uint32 rcvptr; /* last descriptor posted to chip */
16896 + uint32 rcvstatus; /* current active descriptor, et al */
16904 +static compat_data *ugly_hack = NULL;
16907 +dma_attold(void *drv, void *osh, char *name, dmaregs_t *regs, uint ntxd, uint nrxd,
16908 + uint rxbufsize, uint nrxpost, uint rxoffset, uint ddoffset, uint dataoffset, uint *msg_level)
16910 + dma32regs_t *dtx = regs;
16911 + dma32regs_t *drx = dtx + 1;
16913 + ugly_hack = kmalloc(sizeof(ugly_hack), GFP_KERNEL);
16914 + ugly_hack->ddoffset = ddoffset;
16915 + ugly_hack->dataoffset = dataoffset;
16916 + dma_attach((osl_t *) osh, name, NULL, dtx, drx, ntxd, nrxd, rxbufsize, nrxpost, rxoffset, msg_level);
16917 + ugly_hack = NULL;
16922 +dma_attach(osl_t *osh, char *name, sb_t *sbh, void *dmaregstx, void *dmaregsrx,
16923 + uint ntxd, uint nrxd, uint rxbufsize, uint nrxpost, uint rxoffset, uint *msg_level)
16928 + /* allocate private info structure */
16929 + if ((di = MALLOC(osh, sizeof (dma_info_t))) == NULL) {
16932 + bzero((char*)di, sizeof (dma_info_t));
16934 + di->msg_level = msg_level ? msg_level : &dma_msg_level;
16937 + di->dma64 = ((sb_coreflagshi(sbh, 0, 0) & SBTMH_DMA64) == SBTMH_DMA64);
16941 + DMA_ERROR(("dma_attach: driver doesn't have the capability to support 64 bits DMA\n"));
16946 + /* check arguments */
16947 + ASSERT(ISPOWEROF2(ntxd));
16948 + ASSERT(ISPOWEROF2(nrxd));
16950 + ASSERT(dmaregsrx == NULL);
16952 + ASSERT(dmaregstx == NULL);
16955 + /* init dma reg pointer */
16957 + ASSERT(ntxd <= D64MAXDD);
16958 + ASSERT(nrxd <= D64MAXDD);
16959 + di->d64txregs = (dma64regs_t *)dmaregstx;
16960 + di->d64rxregs = (dma64regs_t *)dmaregsrx;
16962 + di->dma64align = D64RINGALIGN;
16963 + if ((ntxd < D64MAXDD / 2) && (nrxd < D64MAXDD / 2)) {
16964 + /* for smaller dd table, HW relax the alignment requirement */
16965 + di->dma64align = D64RINGALIGN / 2;
16968 + ASSERT(ntxd <= D32MAXDD);
16969 + ASSERT(nrxd <= D32MAXDD);
16970 + di->d32txregs = (dma32regs_t *)dmaregstx;
16971 + di->d32rxregs = (dma32regs_t *)dmaregsrx;
16975 + /* make a private copy of our callers name */
16976 + strncpy(di->name, name, MAXNAMEL);
16977 + di->name[MAXNAMEL-1] = '\0';
16982 + /* save tunables */
16985 + di->rxbufsize = rxbufsize;
16986 + di->nrxpost = nrxpost;
16987 + di->rxoffset = rxoffset;
16990 + * figure out the DMA physical address offset for dd and data
16991 + * for old chips w/o sb, use zero
16992 + * for new chips w sb,
16993 + * PCI/PCIE: they map silicon backplace address to zero based memory, need offset
16994 + * Other bus: use zero
16995 + * SB_BUS BIGENDIAN kludge: use sdram swapped region for data buffer, not descriptor
16997 + di->ddoffsetlow = 0;
16998 + di->dataoffsetlow = 0;
16999 + if (ugly_hack != NULL) {
17000 + di->ddoffsetlow = ugly_hack->ddoffset;
17001 + di->dataoffsetlow = ugly_hack->dataoffset;
17002 + di->ddoffsethigh = 0;
17003 + di->dataoffsethigh = 0;
17004 + } else if (sbh != NULL) {
17005 + if (sbh->bustype == PCI_BUS) { /* for pci bus, add offset */
17006 + if ((sbh->buscoretype == SB_PCIE) && di->dma64){
17007 + di->ddoffsetlow = 0;
17008 + di->ddoffsethigh = SB_PCIE_DMA_H32;
17010 + di->ddoffsetlow = SB_PCI_DMA;
17011 + di->ddoffsethigh = 0;
17013 + di->dataoffsetlow = di->ddoffsetlow;
17014 + di->dataoffsethigh = di->ddoffsethigh;
17016 +#if defined(__mips__) && defined(IL_BIGENDIAN)
17017 + /* use sdram swapped region for data buffers but not dma descriptors */
17018 + di->dataoffsetlow = di->dataoffsetlow + SB_SDRAM_SWAPPED;
17022 + di->addrext = ((ugly_hack == NULL) ? dma_isaddrext(di) : 0);
17024 + DMA_TRACE(("%s: dma_attach: osh %p ntxd %d nrxd %d rxbufsize %d nrxpost %d rxoffset %d ddoffset 0x%x dataoffset 0x%x\n",
17025 + name, osh, ntxd, nrxd, rxbufsize, nrxpost, rxoffset, di->ddoffsetlow, di->dataoffsetlow));
17027 + /* allocate tx packet pointer vector */
17029 + size = ntxd * sizeof (void*);
17030 + if ((di->txp = MALLOC(osh, size)) == NULL) {
17031 + DMA_ERROR(("%s: dma_attach: out of tx memory, malloced %d bytes\n", di->name, MALLOCED(osh)));
17034 + bzero((char*)di->txp, size);
17037 + /* allocate rx packet pointer vector */
17039 + size = nrxd * sizeof (void*);
17040 + if ((di->rxp = MALLOC(osh, size)) == NULL) {
17041 + DMA_ERROR(("%s: dma_attach: out of rx memory, malloced %d bytes\n", di->name, MALLOCED(osh)));
17044 + bzero((char*)di->rxp, size);
17047 + /* allocate transmit descriptor ring, only need ntxd descriptors but it must be aligned */
17049 + if (!dma_alloc(di, DMA_TX))
17053 + /* allocate receive descriptor ring, only need nrxd descriptors but it must be aligned */
17055 + if (!dma_alloc(di, DMA_RX))
17059 + if ((di->ddoffsetlow == SB_PCI_DMA) && (di->txdpa > SB_PCI_DMA_SZ) && !di->addrext) {
17060 + DMA_ERROR(("%s: dma_attach: txdpa 0x%lx: addrext not supported\n", di->name, di->txdpa));
17063 + if ((di->ddoffsetlow == SB_PCI_DMA) && (di->rxdpa > SB_PCI_DMA_SZ) && !di->addrext) {
17064 + DMA_ERROR(("%s: dma_attach: rxdpa 0x%lx: addrext not supported\n", di->name, di->rxdpa));
17068 + return ((void*)di);
17071 + dma_detach((void*)di);
17076 +dma_alloc(dma_info_t *di, uint direction)
17078 + if (DMA64_ENAB(di)) {
17079 + return dma64_alloc(di, direction);
17081 + return dma32_alloc(di, direction);
17085 +/* may be called with core in reset */
17087 +dma_detach(dma_info_t *di)
17092 + DMA_TRACE(("%s: dma_detach\n", di->name));
17094 + /* shouldn't be here if descriptors are unreclaimed */
17095 + ASSERT(di->txin == di->txout);
17096 + ASSERT(di->rxin == di->rxout);
17098 + /* free dma descriptor rings */
17100 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->txd32 - di->txdalign), di->txdalloc, (di->txdpa - di->txdalign));
17102 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->rxd32 - di->rxdalign), di->rxdalloc, (di->rxdpa - di->rxdalign));
17104 + /* free packet pointer vectors */
17106 + MFREE(di->osh, (void*)di->txp, (di->ntxd * sizeof (void*)));
17108 + MFREE(di->osh, (void*)di->rxp, (di->nrxd * sizeof (void*)));
17110 + /* free our private info structure */
17111 + MFREE(di->osh, (void*)di, sizeof (dma_info_t));
17114 +/* return TRUE if this dma engine supports DmaExtendedAddrChanges, otherwise FALSE */
17116 +dma_isaddrext(dma_info_t *di)
17120 + if (DMA64_ENAB(di)) {
17121 + OR_REG(&di->d64txregs->control, D64_XC_AE);
17122 + w = R_REG(&di->d32txregs->control);
17123 + AND_REG(&di->d32txregs->control, ~D64_XC_AE);
17124 + return ((w & XC_AE) == D64_XC_AE);
17126 + OR_REG(&di->d32txregs->control, XC_AE);
17127 + w = R_REG(&di->d32txregs->control);
17128 + AND_REG(&di->d32txregs->control, ~XC_AE);
17129 + return ((w & XC_AE) == XC_AE);
17134 +dma_txreset(dma_info_t *di)
17136 + DMA_TRACE(("%s: dma_txreset\n", di->name));
17138 + if (DMA64_ENAB(di))
17139 + dma64_txreset(di);
17141 + dma32_txreset(di);
17145 +dma_rxreset(dma_info_t *di)
17147 + DMA_TRACE(("%s: dma_rxreset\n", di->name));
17149 + if (DMA64_ENAB(di))
17150 + dma64_rxreset(di);
17152 + dma32_rxreset(di);
17155 +/* initialize descriptor table base address */
17157 +dma_ddtable_init(dma_info_t *di, uint direction, ulong pa)
17159 + if (DMA64_ENAB(di)) {
17160 + if (direction == DMA_TX) {
17161 + W_REG(&di->d64txregs->addrlow, pa + di->ddoffsetlow);
17162 + W_REG(&di->d64txregs->addrhigh, di->ddoffsethigh);
17164 + W_REG(&di->d64rxregs->addrlow, pa + di->ddoffsetlow);
17165 + W_REG(&di->d64rxregs->addrhigh, di->ddoffsethigh);
17168 + uint32 offset = di->ddoffsetlow;
17169 + if ((offset != SB_PCI_DMA) || !(pa & PCI32ADDR_HIGH)) {
17170 + if (direction == DMA_TX)
17171 + W_REG(&di->d32txregs->addr, (pa + offset));
17173 + W_REG(&di->d32rxregs->addr, (pa + offset));
17175 + /* dma32 address extension */
17177 + ASSERT(di->addrext);
17178 + ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT;
17180 + if (direction == DMA_TX) {
17181 + W_REG(&di->d32txregs->addr, ((pa & ~PCI32ADDR_HIGH) + offset));
17182 + SET_REG(&di->d32txregs->control, XC_AE, (ae << XC_AE_SHIFT));
17184 + W_REG(&di->d32rxregs->addr, ((pa & ~PCI32ADDR_HIGH) + offset));
17185 + SET_REG(&di->d32rxregs->control, RC_AE, (ae << RC_AE_SHIFT));
17191 +/* init the tx or rx descriptor */
17192 +static INLINE void
17193 +dma32_dd_upd(dma_info_t *di, dma32dd_t *ddring, ulong pa, uint outidx, uint32 *ctrl)
17195 + uint offset = di->dataoffsetlow;
17197 + if ((offset != SB_PCI_DMA) || !(pa & PCI32ADDR_HIGH)) {
17198 + W_SM(&ddring[outidx].addr, BUS_SWAP32(pa + offset));
17199 + W_SM(&ddring[outidx].ctrl, BUS_SWAP32(*ctrl));
17201 + /* address extension */
17203 + ASSERT(di->addrext);
17204 + ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT;
17206 + *ctrl |= (ae << CTRL_AE_SHIFT);
17207 + W_SM(&ddring[outidx].addr, BUS_SWAP32((pa & ~PCI32ADDR_HIGH) + offset));
17208 + W_SM(&ddring[outidx].ctrl, BUS_SWAP32(*ctrl));
17212 +/* init the tx or rx descriptor */
17213 +static INLINE void
17214 +dma64_dd_upd(dma_info_t *di, dma64dd_t *ddring, ulong pa, uint outidx, uint32 *flags, uint32 bufcount)
17216 + uint32 bufaddr_low = pa + di->dataoffsetlow;
17217 + uint32 bufaddr_high = 0 + di->dataoffsethigh;
17219 + uint32 ctrl2 = bufcount & D64_CTRL2_BC_MASK;
17221 + W_SM(&ddring[outidx].addrlow, BUS_SWAP32(bufaddr_low));
17222 + W_SM(&ddring[outidx].addrhigh, BUS_SWAP32(bufaddr_high));
17223 + W_SM(&ddring[outidx].ctrl1, BUS_SWAP32(*flags));
17224 + W_SM(&ddring[outidx].ctrl2, BUS_SWAP32(ctrl2));
17228 +dma_txinit(dma_info_t *di)
17230 + DMA_TRACE(("%s: dma_txinit\n", di->name));
17232 + di->txin = di->txout = 0;
17233 + di->txavail = di->ntxd - 1;
17235 + /* clear tx descriptor ring */
17236 + if (DMA64_ENAB(di)) {
17237 + BZERO_SM((void*)di->txd64, (di->ntxd * sizeof (dma64dd_t)));
17238 + W_REG(&di->d64txregs->control, XC_XE);
17239 + dma_ddtable_init(di, DMA_TX, di->txdpa);
17241 + BZERO_SM((void*)di->txd32, (di->ntxd * sizeof (dma32dd_t)));
17242 + W_REG(&di->d32txregs->control, XC_XE);
17243 + dma_ddtable_init(di, DMA_TX, di->txdpa);
17248 +dma_txenabled(dma_info_t *di)
17252 + /* If the chip is dead, it is not enabled :-) */
17253 + if (DMA64_ENAB(di)) {
17254 + xc = R_REG(&di->d64txregs->control);
17255 + return ((xc != 0xffffffff) && (xc & D64_XC_XE));
17257 + xc = R_REG(&di->d32txregs->control);
17258 + return ((xc != 0xffffffff) && (xc & XC_XE));
17263 +dma_txsuspend(dma_info_t *di)
17265 + DMA_TRACE(("%s: dma_txsuspend\n", di->name));
17266 + if (DMA64_ENAB(di))
17267 + OR_REG(&di->d64txregs->control, D64_XC_SE);
17269 + OR_REG(&di->d32txregs->control, XC_SE);
17273 +dma_txresume(dma_info_t *di)
17275 + DMA_TRACE(("%s: dma_txresume\n", di->name));
17276 + if (DMA64_ENAB(di))
17277 + AND_REG(&di->d64txregs->control, ~D64_XC_SE);
17279 + AND_REG(&di->d32txregs->control, ~XC_SE);
17283 +dma_txsuspendedidle(dma_info_t *di)
17285 + if (DMA64_ENAB(di))
17286 + return dma64_txsuspendedidle(di);
17288 + return dma32_txsuspendedidle(di);
17292 +dma_txsuspended(dma_info_t *di)
17294 + if (DMA64_ENAB(di))
17295 + return ((R_REG(&di->d64txregs->control) & D64_XC_SE) == D64_XC_SE);
17297 + return ((R_REG(&di->d32txregs->control) & XC_SE) == XC_SE);
17301 +dma_txstopped(dma_info_t *di)
17303 + if (DMA64_ENAB(di))
17304 + return ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == D64_XS0_XS_STOPPED);
17306 + return ((R_REG(&di->d32txregs->status) & XS_XS_MASK) == XS_XS_STOPPED);
17310 +dma_rxstopped(dma_info_t *di)
17312 + if (DMA64_ENAB(di))
17313 + return ((R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK) == D64_RS0_RS_STOPPED);
17315 + return ((R_REG(&di->d32rxregs->status) & RS_RS_MASK) == RS_RS_STOPPED);
17319 +dma_fifoloopbackenable(dma_info_t *di)
17321 + DMA_TRACE(("%s: dma_fifoloopbackenable\n", di->name));
17322 + if (DMA64_ENAB(di))
17323 + OR_REG(&di->d64txregs->control, D64_XC_LE);
17325 + OR_REG(&di->d32txregs->control, XC_LE);
17329 +dma_rxinit(dma_info_t *di)
17331 + DMA_TRACE(("%s: dma_rxinit\n", di->name));
17333 + di->rxin = di->rxout = 0;
17335 + /* clear rx descriptor ring */
17336 + if (DMA64_ENAB(di)) {
17337 + BZERO_SM((void*)di->rxd64, (di->nrxd * sizeof (dma64dd_t)));
17338 + dma_rxenable(di);
17339 + dma_ddtable_init(di, DMA_RX, di->rxdpa);
17341 + BZERO_SM((void*)di->rxd32, (di->nrxd * sizeof (dma32dd_t)));
17342 + dma_rxenable(di);
17343 + dma_ddtable_init(di, DMA_RX, di->rxdpa);
17348 +dma_rxenable(dma_info_t *di)
17350 + DMA_TRACE(("%s: dma_rxenable\n", di->name));
17351 + if (DMA64_ENAB(di))
17352 + W_REG(&di->d64rxregs->control, ((di->rxoffset << D64_RC_RO_SHIFT) | D64_RC_RE));
17354 + W_REG(&di->d32rxregs->control, ((di->rxoffset << RC_RO_SHIFT) | RC_RE));
17358 +dma_rxenabled(dma_info_t *di)
17362 + if (DMA64_ENAB(di)) {
17363 + rc = R_REG(&di->d64rxregs->control);
17364 + return ((rc != 0xffffffff) && (rc & D64_RC_RE));
17366 + rc = R_REG(&di->d32rxregs->control);
17367 + return ((rc != 0xffffffff) && (rc & RC_RE));
17372 +/* !! tx entry routine */
17374 +dma_txfast(dma_info_t *di, void *p0, uint32 coreflags)
17376 + if (DMA64_ENAB(di)) {
17377 + return dma64_txfast(di, p0, coreflags);
17379 + return dma32_txfast(di, p0, coreflags);
17383 +/* !! rx entry routine, returns a pointer to the next frame received, or NULL if there are no more */
17385 +dma_rx(dma_info_t *di)
17391 + while ((p = dma_getnextrxp(di, FALSE))) {
17392 + /* skip giant packets which span multiple rx descriptors */
17393 + if (skiplen > 0) {
17394 + skiplen -= di->rxbufsize;
17397 + PKTFREE(di->osh, p, FALSE);
17401 + len = ltoh16(*(uint16*)(PKTDATA(di->osh, p)));
17402 + DMA_TRACE(("%s: dma_rx len %d\n", di->name, len));
17404 + /* bad frame length check */
17405 + if (len > (di->rxbufsize - di->rxoffset)) {
17406 + DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len));
17408 + skiplen = len - (di->rxbufsize - di->rxoffset);
17409 + PKTFREE(di->osh, p, FALSE);
17410 + di->hnddma.rxgiants++;
17414 + /* set actual length */
17415 + PKTSETLEN(di->osh, p, (di->rxoffset + len));
17423 +/* post receive buffers */
17425 +dma_rxfill(dma_info_t *di)
17428 + uint rxin, rxout;
17436 + * Determine how many receive buffers we're lacking
17437 + * from the full complement, allocate, initialize,
17438 + * and post them, then update the chip rx lastdscr.
17442 + rxout = di->rxout;
17443 + rxbufsize = di->rxbufsize;
17445 + n = di->nrxpost - NRXDACTIVE(rxin, rxout);
17447 + DMA_TRACE(("%s: dma_rxfill: post %d\n", di->name, n));
17449 + for (i = 0; i < n; i++) {
17450 + if ((p = PKTGET(di->osh, rxbufsize, FALSE)) == NULL) {
17451 + DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", di->name));
17452 + di->hnddma.rxnobuf++;
17456 + /* Do a cached write instead of uncached write since DMA_MAP
17457 + * will flush the cache. */
17458 + *(uint32*)(PKTDATA(di->osh, p)) = 0;
17460 + pa = (uint32) DMA_MAP(di->osh, PKTDATA(di->osh, p), rxbufsize, DMA_RX, p);
17461 + ASSERT(ISALIGNED(pa, 4));
17463 + /* save the free packet pointer */
17464 + ASSERT(di->rxp[rxout] == NULL);
17465 + di->rxp[rxout] = p;
17467 + if (DMA64_ENAB(di)) {
17468 + /* prep the descriptor control value */
17469 + if (rxout == (di->nrxd - 1))
17472 + dma64_dd_upd(di, di->rxd64, pa, rxout, &ctrl, rxbufsize);
17474 + /* prep the descriptor control value */
17475 + ctrl = rxbufsize;
17476 + if (rxout == (di->nrxd - 1))
17477 + ctrl |= CTRL_EOT;
17478 + dma32_dd_upd(di, di->rxd32, pa, rxout, &ctrl);
17481 + rxout = NEXTRXD(rxout);
17484 + di->rxout = rxout;
17486 + /* update the chip lastdscr pointer */
17487 + if (DMA64_ENAB(di)) {
17488 + W_REG(&di->d64rxregs->ptr, I2B(rxout, dma64dd_t));
17490 + W_REG(&di->d32rxregs->ptr, I2B(rxout, dma32dd_t));
17495 +dma_txreclaim(dma_info_t *di, bool forceall)
17499 + DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, forceall ? "all" : ""));
17501 + while ((p = dma_getnexttxp(di, forceall)))
17502 + PKTFREE(di->osh, p, TRUE);
17506 + * Reclaim next completed txd (txds if using chained buffers) and
17507 + * return associated packet.
17508 + * If 'force' is true, reclaim txd(s) and return associated packet
17509 + * regardless of the value of the hardware "curr" pointer.
17512 +dma_getnexttxp(dma_info_t *di, bool forceall)
17514 + if (DMA64_ENAB(di)) {
17515 + return dma64_getnexttxp(di, forceall);
17517 + return dma32_getnexttxp(di, forceall);
17521 +/* like getnexttxp but no reclaim */
17523 +dma_peeknexttxp(dma_info_t *di)
17527 + if (DMA64_ENAB(di)) {
17528 + end = B2I(R_REG(&di->d64txregs->status0) & D64_XS0_CD_MASK, dma64dd_t);
17530 + end = B2I(R_REG(&di->d32txregs->status) & XS_CD_MASK, dma32dd_t);
17533 + for (i = di->txin; i != end; i = NEXTTXD(i))
17535 + return (di->txp[i]);
17541 + * Rotate all active tx dma ring entries "forward" by (ActiveDescriptor - txin).
17544 +dma_txrotate(di_t *di)
17546 + if (DMA64_ENAB(di)) {
17547 + dma64_txrotate(di);
17549 + dma32_txrotate(di);
17554 +dma_rxreclaim(dma_info_t *di)
17558 + DMA_TRACE(("%s: dma_rxreclaim\n", di->name));
17560 + while ((p = dma_getnextrxp(di, TRUE)))
17561 + PKTFREE(di->osh, p, FALSE);
17565 +dma_getnextrxp(dma_info_t *di, bool forceall)
17567 + if (DMA64_ENAB(di)) {
17568 + return dma64_getnextrxp(di, forceall);
17570 + return dma32_getnextrxp(di, forceall);
17575 +dma_getvar(dma_info_t *di, char *name)
17577 + if (!strcmp(name, "&txavail"))
17578 + return ((uintptr) &di->txavail);
17586 +dma_txblock(dma_info_t *di)
17592 +dma_txunblock(dma_info_t *di)
17594 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
17598 +dma_txactive(dma_info_t *di)
17600 + return (NTXDACTIVE(di->txin, di->txout));
17604 +dma_rxpiomode(dma32regs_t *regs)
17606 + W_REG(®s->control, RC_FM);
17610 +dma_txpioloopback(dma32regs_t *regs)
17612 + OR_REG(®s->control, XC_LE);
17618 +/*** 32 bits DMA non-inline functions ***/
17620 +dma32_alloc(dma_info_t *di, uint direction)
17626 + ddlen = sizeof (dma32dd_t);
17628 + size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen);
17630 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, D32RINGALIGN))
17631 + size += D32RINGALIGN;
17634 + if (direction == DMA_TX) {
17635 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->txdpa)) == NULL) {
17636 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name));
17640 + di->txd32 = (dma32dd_t*) ROUNDUP((uintptr)va, D32RINGALIGN);
17641 + di->txdalign = (uint)((int8*)di->txd32 - (int8*)va);
17642 + di->txdpa += di->txdalign;
17643 + di->txdalloc = size;
17644 + ASSERT(ISALIGNED((uintptr)di->txd32, D32RINGALIGN));
17646 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->rxdpa)) == NULL) {
17647 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name));
17650 + di->rxd32 = (dma32dd_t*) ROUNDUP((uintptr)va, D32RINGALIGN);
17651 + di->rxdalign = (uint)((int8*)di->rxd32 - (int8*)va);
17652 + di->rxdpa += di->rxdalign;
17653 + di->rxdalloc = size;
17654 + ASSERT(ISALIGNED((uintptr)di->rxd32, D32RINGALIGN));
17661 +dma32_txreset(dma_info_t *di)
17665 + /* suspend tx DMA first */
17666 + W_REG(&di->d32txregs->control, XC_SE);
17667 + SPINWAIT((status = (R_REG(&di->d32txregs->status) & XS_XS_MASK)) != XS_XS_DISABLED &&
17668 + status != XS_XS_IDLE &&
17669 + status != XS_XS_STOPPED,
17672 + W_REG(&di->d32txregs->control, 0);
17673 + SPINWAIT((status = (R_REG(&di->d32txregs->status) & XS_XS_MASK)) != XS_XS_DISABLED,
17676 + if (status != XS_XS_DISABLED) {
17677 + DMA_ERROR(("%s: dma_txreset: dma cannot be stopped\n", di->name));
17680 + /* wait for the last transaction to complete */
17685 +dma32_rxreset(dma_info_t *di)
17689 + W_REG(&di->d32rxregs->control, 0);
17690 + SPINWAIT((status = (R_REG(&di->d32rxregs->status) & RS_RS_MASK)) != RS_RS_DISABLED,
17693 + if (status != RS_RS_DISABLED) {
17694 + DMA_ERROR(("%s: dma_rxreset: dma cannot be stopped\n", di->name));
17699 +dma32_txsuspendedidle(dma_info_t *di)
17701 + if (!(R_REG(&di->d32txregs->control) & XC_SE))
17704 + if ((R_REG(&di->d32txregs->status) & XS_XS_MASK) != XS_XS_IDLE)
17708 + return ((R_REG(&di->d32txregs->status) & XS_XS_MASK) == XS_XS_IDLE);
17712 + * supports full 32bit dma engine buffer addressing so
17713 + * dma buffers can cross 4 Kbyte page boundaries.
17716 +dma32_txfast(dma_info_t *di, void *p0, uint32 coreflags)
17725 + DMA_TRACE(("%s: dma_txfast\n", di->name));
17727 + txout = di->txout;
17731 + * Walk the chain of packet buffers
17732 + * allocating and initializing transmit descriptor entries.
17734 + for (p = p0; p; p = next) {
17735 + data = PKTDATA(di->osh, p);
17736 + len = PKTLEN(di->osh, p);
17737 + next = PKTNEXT(di->osh, p);
17739 + /* return nonzero if out of tx descriptors */
17740 + if (NEXTTXD(txout) == di->txin)
17746 + /* get physical address of buffer start */
17747 + pa = (uint32) DMA_MAP(di->osh, data, len, DMA_TX, p);
17749 + /* build the descriptor control value */
17750 + ctrl = len & CTRL_BC_MASK;
17752 + ctrl |= coreflags;
17755 + ctrl |= CTRL_SOF;
17756 + if (next == NULL)
17757 + ctrl |= (CTRL_IOC | CTRL_EOF);
17758 + if (txout == (di->ntxd - 1))
17759 + ctrl |= CTRL_EOT;
17761 + if (DMA64_ENAB(di)) {
17762 + dma64_dd_upd(di, di->txd64, pa, txout, &ctrl, len);
17764 + dma32_dd_upd(di, di->txd32, pa, txout, &ctrl);
17767 + ASSERT(di->txp[txout] == NULL);
17769 + txout = NEXTTXD(txout);
17772 + /* if last txd eof not set, fix it */
17773 + if (!(ctrl & CTRL_EOF))
17774 + W_SM(&di->txd32[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF));
17776 + /* save the packet */
17777 + di->txp[PREVTXD(txout)] = p0;
17779 + /* bump the tx descriptor index */
17780 + di->txout = txout;
17782 + /* kick the chip */
17783 + if (DMA64_ENAB(di)) {
17784 + W_REG(&di->d64txregs->ptr, I2B(txout, dma64dd_t));
17786 + W_REG(&di->d32txregs->ptr, I2B(txout, dma32dd_t));
17789 + /* tx flow control */
17790 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
17795 + DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name));
17796 + PKTFREE(di->osh, p0, TRUE);
17798 + di->hnddma.txnobuf++;
17803 +dma32_getnexttxp(dma_info_t *di, bool forceall)
17805 + uint start, end, i;
17808 + DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, forceall ? "all" : ""));
17812 + start = di->txin;
17816 + end = B2I(R_REG(&di->d32txregs->status) & XS_CD_MASK, dma32dd_t);
17818 + if ((start == 0) && (end > di->txout))
17821 + for (i = start; i != end && !txp; i = NEXTTXD(i)) {
17822 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->txd32[i].addr)) - di->dataoffsetlow),
17823 + (BUS_SWAP32(R_SM(&di->txd32[i].ctrl)) & CTRL_BC_MASK), DMA_TX, di->txp[i]);
17825 + W_SM(&di->txd32[i].addr, 0xdeadbeef);
17826 + txp = di->txp[i];
17827 + di->txp[i] = NULL;
17832 + /* tx flow control */
17833 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
17839 + DMA_ERROR(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n",
17840 + start, end, di->txout, forceall));
17846 +dma32_getnextrxp(dma_info_t *di, bool forceall)
17851 + /* if forcing, dma engine must be disabled */
17852 + ASSERT(!forceall || !dma_rxenabled(di));
17856 + /* return if no packets posted */
17857 + if (i == di->rxout)
17860 + /* ignore curr if forceall */
17861 + if (!forceall && (i == B2I(R_REG(&di->d32rxregs->status) & RS_CD_MASK, dma32dd_t)))
17864 + /* get the packet pointer that corresponds to the rx descriptor */
17865 + rxp = di->rxp[i];
17867 + di->rxp[i] = NULL;
17869 + /* clear this packet from the descriptor ring */
17870 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->rxd32[i].addr)) - di->dataoffsetlow),
17871 + di->rxbufsize, DMA_RX, rxp);
17872 + W_SM(&di->rxd32[i].addr, 0xdeadbeef);
17874 + di->rxin = NEXTRXD(i);
17880 +dma32_txrotate(di_t *di)
17887 + uint first, last;
17889 + ASSERT(dma_txsuspendedidle(di));
17891 + nactive = dma_txactive(di);
17892 + ad = B2I(((R_REG(&di->d32txregs->status) & XS_AD_MASK) >> XS_AD_SHIFT), dma32dd_t);
17893 + rot = TXD(ad - di->txin);
17895 + ASSERT(rot < di->ntxd);
17897 + /* full-ring case is a lot harder - don't worry about this */
17898 + if (rot >= (di->ntxd - nactive)) {
17899 + DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name));
17903 + first = di->txin;
17904 + last = PREVTXD(di->txout);
17906 + /* move entries starting at last and moving backwards to first */
17907 + for (old = last; old != PREVTXD(first); old = PREVTXD(old)) {
17908 + new = TXD(old + rot);
17911 + * Move the tx dma descriptor.
17912 + * EOT is set only in the last entry in the ring.
17914 + w = R_SM(&di->txd32[old].ctrl) & ~CTRL_EOT;
17915 + if (new == (di->ntxd - 1))
17917 + W_SM(&di->txd32[new].ctrl, w);
17918 + W_SM(&di->txd32[new].addr, R_SM(&di->txd32[old].addr));
17920 + /* zap the old tx dma descriptor address field */
17921 + W_SM(&di->txd32[old].addr, 0xdeadbeef);
17923 + /* move the corresponding txp[] entry */
17924 + ASSERT(di->txp[new] == NULL);
17925 + di->txp[new] = di->txp[old];
17926 + di->txp[old] = NULL;
17929 + /* update txin and txout */
17931 + di->txout = TXD(di->txout + rot);
17932 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
17934 + /* kick the chip */
17935 + W_REG(&di->d32txregs->ptr, I2B(di->txout, dma32dd_t));
17938 +/*** 64 bits DMA non-inline functions ***/
17943 +dma64_alloc(dma_info_t *di, uint direction)
17947 + uint32 alignbytes;
17950 + ddlen = sizeof (dma64dd_t);
17952 + size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen);
17954 + alignbytes = di->dma64align;
17956 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, alignbytes))
17957 + size += alignbytes;
17960 + if (direction == DMA_TX) {
17961 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->txdpa)) == NULL) {
17962 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name));
17966 + di->txd64 = (dma64dd_t*) ROUNDUP((uintptr)va, alignbytes);
17967 + di->txdalign = (uint)((int8*)di->txd64 - (int8*)va);
17968 + di->txdpa += di->txdalign;
17969 + di->txdalloc = size;
17970 + ASSERT(ISALIGNED((uintptr)di->txd64, alignbytes));
17972 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->rxdpa)) == NULL) {
17973 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name));
17976 + di->rxd64 = (dma64dd_t*) ROUNDUP((uintptr)va, alignbytes);
17977 + di->rxdalign = (uint)((int8*)di->rxd64 - (int8*)va);
17978 + di->rxdpa += di->rxdalign;
17979 + di->rxdalloc = size;
17980 + ASSERT(ISALIGNED((uintptr)di->rxd64, alignbytes));
17987 +dma64_txreset(dma_info_t *di)
17991 + /* suspend tx DMA first */
17992 + W_REG(&di->d64txregs->control, D64_XC_SE);
17993 + SPINWAIT((status = (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED &&
17994 + status != D64_XS0_XS_IDLE &&
17995 + status != D64_XS0_XS_STOPPED,
17998 + W_REG(&di->d64txregs->control, 0);
17999 + SPINWAIT((status = (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED,
18002 + if (status != D64_XS0_XS_DISABLED) {
18003 + DMA_ERROR(("%s: dma_txreset: dma cannot be stopped\n", di->name));
18006 + /* wait for the last transaction to complete */
18011 +dma64_rxreset(dma_info_t *di)
18015 + W_REG(&di->d64rxregs->control, 0);
18016 + SPINWAIT((status = (R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK)) != D64_RS0_RS_DISABLED,
18019 + if (status != D64_RS0_RS_DISABLED) {
18020 + DMA_ERROR(("%s: dma_rxreset: dma cannot be stopped\n", di->name));
18025 +dma64_txsuspendedidle(dma_info_t *di)
18028 + if (!(R_REG(&di->d64txregs->control) & D64_XC_SE))
18031 + if ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == D64_XS0_XS_IDLE)
18038 + * supports full 32bit dma engine buffer addressing so
18039 + * dma buffers can cross 4 Kbyte page boundaries.
18042 +dma64_txfast(dma_info_t *di, void *p0, uint32 coreflags)
18051 + DMA_TRACE(("%s: dma_txfast\n", di->name));
18053 + txout = di->txout;
18057 + * Walk the chain of packet buffers
18058 + * allocating and initializing transmit descriptor entries.
18060 + for (p = p0; p; p = next) {
18061 + data = PKTDATA(di->osh, p);
18062 + len = PKTLEN(di->osh, p);
18063 + next = PKTNEXT(di->osh, p);
18065 + /* return nonzero if out of tx descriptors */
18066 + if (NEXTTXD(txout) == di->txin)
18072 + /* get physical address of buffer start */
18073 + pa = (uint32) DMA_MAP(di->osh, data, len, DMA_TX, p);
18075 + flags = coreflags;
18078 + flags |= D64_CTRL1_SOF;
18079 + if (next == NULL)
18080 + flags |= (D64_CTRL1_IOC | D64_CTRL1_EOF);
18081 + if (txout == (di->ntxd - 1))
18082 + flags |= D64_CTRL1_EOT;
18084 + dma64_dd_upd(di, di->txd64, pa, txout, &flags, len);
18086 + ASSERT(di->txp[txout] == NULL);
18088 + txout = NEXTTXD(txout);
18091 + /* if last txd eof not set, fix it */
18092 + if (!(flags & D64_CTRL1_EOF))
18093 + W_SM(&di->txd64[PREVTXD(txout)].ctrl1, BUS_SWAP32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF));
18095 + /* save the packet */
18096 + di->txp[PREVTXD(txout)] = p0;
18098 + /* bump the tx descriptor index */
18099 + di->txout = txout;
18101 + /* kick the chip */
18102 + W_REG(&di->d64txregs->ptr, I2B(txout, dma64dd_t));
18104 + /* tx flow control */
18105 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18110 + DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name));
18111 + PKTFREE(di->osh, p0, TRUE);
18113 + di->hnddma.txnobuf++;
18118 +dma64_getnexttxp(dma_info_t *di, bool forceall)
18120 + uint start, end, i;
18123 + DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, forceall ? "all" : ""));
18127 + start = di->txin;
18131 + end = B2I(R_REG(&di->d64txregs->status0) & D64_XS0_CD_MASK, dma64dd_t);
18133 + if ((start == 0) && (end > di->txout))
18136 + for (i = start; i != end && !txp; i = NEXTTXD(i)) {
18137 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->txd64[i].addrlow)) - di->dataoffsetlow),
18138 + (BUS_SWAP32(R_SM(&di->txd64[i].ctrl2)) & D64_CTRL2_BC_MASK), DMA_TX, di->txp[i]);
18140 + W_SM(&di->txd64[i].addrlow, 0xdeadbeef);
18141 + W_SM(&di->txd64[i].addrhigh, 0xdeadbeef);
18143 + txp = di->txp[i];
18144 + di->txp[i] = NULL;
18149 + /* tx flow control */
18150 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18156 + DMA_ERROR(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n",
18157 + start, end, di->txout, forceall));
18163 +dma64_getnextrxp(dma_info_t *di, bool forceall)
18168 + /* if forcing, dma engine must be disabled */
18169 + ASSERT(!forceall || !dma_rxenabled(di));
18173 + /* return if no packets posted */
18174 + if (i == di->rxout)
18177 + /* ignore curr if forceall */
18178 + if (!forceall && (i == B2I(R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK, dma64dd_t)))
18181 + /* get the packet pointer that corresponds to the rx descriptor */
18182 + rxp = di->rxp[i];
18184 + di->rxp[i] = NULL;
18186 + /* clear this packet from the descriptor ring */
18187 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->rxd64[i].addrlow)) - di->dataoffsetlow),
18188 + di->rxbufsize, DMA_RX, rxp);
18190 + W_SM(&di->rxd64[i].addrlow, 0xdeadbeef);
18191 + W_SM(&di->rxd64[i].addrhigh, 0xdeadbeef);
18193 + di->rxin = NEXTRXD(i);
18199 +dma64_txrotate(di_t *di)
18206 + uint first, last;
18208 + ASSERT(dma_txsuspendedidle(di));
18210 + nactive = dma_txactive(di);
18211 + ad = B2I((R_REG(&di->d64txregs->status1) & D64_XS1_AD_MASK), dma64dd_t);
18212 + rot = TXD(ad - di->txin);
18214 + ASSERT(rot < di->ntxd);
18216 + /* full-ring case is a lot harder - don't worry about this */
18217 + if (rot >= (di->ntxd - nactive)) {
18218 + DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name));
18222 + first = di->txin;
18223 + last = PREVTXD(di->txout);
18225 + /* move entries starting at last and moving backwards to first */
18226 + for (old = last; old != PREVTXD(first); old = PREVTXD(old)) {
18227 + new = TXD(old + rot);
18230 + * Move the tx dma descriptor.
18231 + * EOT is set only in the last entry in the ring.
18233 + w = R_SM(&di->txd64[old].ctrl1) & ~D64_CTRL1_EOT;
18234 + if (new == (di->ntxd - 1))
18235 + w |= D64_CTRL1_EOT;
18236 + W_SM(&di->txd64[new].ctrl1, w);
18238 + w = R_SM(&di->txd64[old].ctrl2);
18239 + W_SM(&di->txd64[new].ctrl2, w);
18241 + W_SM(&di->txd64[new].addrlow, R_SM(&di->txd64[old].addrlow));
18242 + W_SM(&di->txd64[new].addrhigh, R_SM(&di->txd64[old].addrhigh));
18244 + /* zap the old tx dma descriptor address field */
18245 + W_SM(&di->txd64[old].addrlow, 0xdeadbeef);
18246 + W_SM(&di->txd64[old].addrhigh, 0xdeadbeef);
18248 + /* move the corresponding txp[] entry */
18249 + ASSERT(di->txp[new] == NULL);
18250 + di->txp[new] = di->txp[old];
18251 + di->txp[old] = NULL;
18254 + /* update txin and txout */
18256 + di->txout = TXD(di->txout + rot);
18257 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18259 + /* kick the chip */
18260 + W_REG(&di->d64txregs->ptr, I2B(di->txout, dma64dd_t));
18265 diff -Nur linux-2.4.32/drivers/net/hnd/linux_osl.c linux-2.4.32-brcm/drivers/net/hnd/linux_osl.c
18266 --- linux-2.4.32/drivers/net/hnd/linux_osl.c 1970-01-01 01:00:00.000000000 +0100
18267 +++ linux-2.4.32-brcm/drivers/net/hnd/linux_osl.c 2005-12-16 23:39:11.292858500 +0100
18270 + * Linux OS Independent Layer
18272 + * Copyright 2005, Broadcom Corporation
18273 + * All Rights Reserved.
18275 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
18276 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
18277 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
18278 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
18285 +#include <typedefs.h>
18286 +#include <bcmendian.h>
18287 +#include <linux/module.h>
18288 +#include <linuxver.h>
18290 +#include <bcmutils.h>
18291 +#include <linux/delay.h>
18293 +#include <asm/paccess.h>
18295 +#include <pcicfg.h>
18297 +#define PCI_CFG_RETRY 10
18299 +#define OS_HANDLE_MAGIC 0x1234abcd
18300 +#define BCM_MEM_FILENAME_LEN 24
18302 +typedef struct bcm_mem_link {
18303 + struct bcm_mem_link *prev;
18304 + struct bcm_mem_link *next;
18307 + char file[BCM_MEM_FILENAME_LEN];
18310 +struct os_handle {
18315 + bcm_mem_link_t *dbgmem_list;
18318 +static int16 linuxbcmerrormap[] = \
18320 + -EINVAL, /* BCME_ERROR */
18321 + -EINVAL, /* BCME_BADARG*/
18322 + -EINVAL, /* BCME_BADOPTION*/
18323 + -EINVAL, /* BCME_NOTUP */
18324 + -EINVAL, /* BCME_NOTDOWN */
18325 + -EINVAL, /* BCME_NOTAP */
18326 + -EINVAL, /* BCME_NOTSTA */
18327 + -EINVAL, /* BCME_BADKEYIDX */
18328 + -EINVAL, /* BCME_RADIOOFF */
18329 + -EINVAL, /* BCME_NOTBANDLOCKED */
18330 + -EINVAL, /* BCME_NOCLK */
18331 + -EINVAL, /* BCME_BADRATESET */
18332 + -EINVAL, /* BCME_BADBAND */
18333 + -E2BIG, /* BCME_BUFTOOSHORT */
18334 + -E2BIG, /* BCME_BUFTOOLONG */
18335 + -EBUSY, /* BCME_BUSY */
18336 + -EINVAL, /* BCME_NOTASSOCIATED */
18337 + -EINVAL, /* BCME_BADSSIDLEN */
18338 + -EINVAL, /* BCME_OUTOFRANGECHAN */
18339 + -EINVAL, /* BCME_BADCHAN */
18340 + -EFAULT, /* BCME_BADADDR */
18341 + -ENOMEM, /* BCME_NORESOURCE */
18342 + -EOPNOTSUPP, /* BCME_UNSUPPORTED */
18343 + -EMSGSIZE, /* BCME_BADLENGTH */
18344 + -EINVAL, /* BCME_NOTREADY */
18345 + -EPERM, /* BCME_NOTPERMITTED */
18346 + -ENOMEM, /* BCME_NOMEM */
18347 + -EINVAL, /* BCME_ASSOCIATED */
18348 + -ERANGE, /* BCME_RANGE */
18349 + -EINVAL /* BCME_NOTFOUND */
18352 +/* translate bcmerrors into linux errors*/
18354 +osl_error(int bcmerror)
18356 + int abs_bcmerror;
18357 + int array_size = ARRAYSIZE(linuxbcmerrormap);
18359 + abs_bcmerror = ABS(bcmerror);
18361 + if (bcmerror > 0)
18362 + abs_bcmerror = 0;
18364 + else if (abs_bcmerror >= array_size)
18365 + abs_bcmerror = BCME_ERROR;
18367 + return linuxbcmerrormap[abs_bcmerror];
18371 +osl_attach(void *pdev)
18375 + osh = kmalloc(sizeof(osl_t), GFP_ATOMIC);
18379 + * check the cases where
18380 + * 1.Error code Added to bcmerror table, but forgot to add it to the OS
18381 + * dependent error code
18382 + * 2. Error code is added to the bcmerror table, but forgot to add the
18383 + * corresponding errorstring(dummy call to bcmerrorstr)
18386 + ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1));
18388 + osh->magic = OS_HANDLE_MAGIC;
18389 + osh->malloced = 0;
18391 + osh->dbgmem_list = NULL;
18392 + osh->pdev = pdev;
18398 +osl_detach(osl_t *osh)
18400 + ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC));
18405 +osl_pktget(osl_t *osh, uint len, bool send)
18407 + struct sk_buff *skb;
18409 + if ((skb = dev_alloc_skb(len)) == NULL)
18412 + skb_put(skb, len);
18414 + /* ensure the cookie field is cleared */
18415 + PKTSETCOOKIE(skb, NULL);
18417 + return ((void*) skb);
18421 +osl_pktfree(void *p)
18423 + struct sk_buff *skb, *nskb;
18425 + skb = (struct sk_buff*) p;
18427 + /* perversion: we use skb->next to chain multi-skb packets */
18429 + nskb = skb->next;
18430 + skb->next = NULL;
18431 + if (skb->destructor) {
18432 + /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if destructor exists */
18433 + dev_kfree_skb_any(skb);
18435 + /* can free immediately (even in_irq()) if destructor does not exist */
18436 + dev_kfree_skb(skb);
18443 +osl_pci_read_config(osl_t *osh, uint offset, uint size)
18446 + uint retry=PCI_CFG_RETRY;
18448 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18450 + /* only 4byte access supported */
18451 + ASSERT(size == 4);
18454 + pci_read_config_dword(osh->pdev, offset, &val);
18455 + if (val != 0xffffffff)
18457 + } while (retry--);
18464 +osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val)
18466 + uint retry=PCI_CFG_RETRY;
18468 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18470 + /* only 4byte access supported */
18471 + ASSERT(size == 4);
18474 + pci_write_config_dword(osh->pdev, offset, val);
18475 + if (offset!=PCI_BAR0_WIN)
18477 + if (osl_pci_read_config(osh,offset,size) == val)
18479 + } while (retry--);
18483 +/* return bus # for the pci device pointed by osh->pdev */
18485 +osl_pci_bus(osl_t *osh)
18487 + ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev);
18489 + return ((struct pci_dev *)osh->pdev)->bus->number;
18492 +/* return slot # for the pci device pointed by osh->pdev */
18494 +osl_pci_slot(osl_t *osh)
18496 + ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev);
18498 + return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn);
18502 +osl_pcmcia_attr(osl_t *osh, uint offset, char *buf, int size, bool write)
18507 +osl_pcmcia_read_attr(osl_t *osh, uint offset, void *buf, int size)
18509 + osl_pcmcia_attr(osh, offset, (char *) buf, size, FALSE);
18513 +osl_pcmcia_write_attr(osl_t *osh, uint offset, void *buf, int size)
18515 + osl_pcmcia_attr(osh, offset, (char *) buf, size, TRUE);
18522 +osl_debug_malloc(osl_t *osh, uint size, int line, char* file)
18524 + bcm_mem_link_t *p;
18529 + if ((p = (bcm_mem_link_t*)osl_malloc(osh, sizeof(bcm_mem_link_t) + size)) == NULL)
18535 + basename = strrchr(file, '/');
18536 + /* skip the '/' */
18543 + strncpy(p->file, basename, BCM_MEM_FILENAME_LEN);
18544 + p->file[BCM_MEM_FILENAME_LEN - 1] = '\0';
18546 + /* link this block */
18548 + p->next = osh->dbgmem_list;
18550 + p->next->prev = p;
18551 + osh->dbgmem_list = p;
18557 +osl_debug_mfree(osl_t *osh, void *addr, uint size, int line, char* file)
18559 + bcm_mem_link_t *p = (bcm_mem_link_t *)((int8*)addr - sizeof(bcm_mem_link_t));
18561 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18563 + if (p->size == 0) {
18564 + printk("osl_debug_mfree: double free on addr 0x%x size %d at line %d file %s\n",
18565 + (uint)addr, size, line, file);
18570 + if (p->size != size) {
18571 + printk("osl_debug_mfree: dealloc size %d does not match alloc size %d on addr 0x%x at line %d file %s\n",
18572 + size, p->size, (uint)addr, line, file);
18573 + ASSERT(p->size == size);
18577 + /* unlink this block */
18579 + p->prev->next = p->next;
18581 + p->next->prev = p->prev;
18582 + if (osh->dbgmem_list == p)
18583 + osh->dbgmem_list = p->next;
18584 + p->next = p->prev = NULL;
18586 + osl_mfree(osh, p, size + sizeof(bcm_mem_link_t));
18590 +osl_debug_memdump(osl_t *osh, char *buf, uint sz)
18592 + bcm_mem_link_t *p;
18595 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18598 + buf += sprintf(buf, " Address\tSize\tFile:line\n");
18599 + for (p = osh->dbgmem_list; p && ((buf - obuf) < (sz - 128)); p = p->next)
18600 + buf += sprintf(buf, "0x%08x\t%5d\t%s:%d\n",
18601 + (int)p + sizeof(bcm_mem_link_t), p->size, p->file, p->line);
18606 +#endif /* BCMDBG_MEM */
18609 +osl_malloc(osl_t *osh, uint size)
18613 + /* only ASSERT if osh is defined */
18615 + ASSERT(osh->magic == OS_HANDLE_MAGIC);
18617 + if ((addr = kmalloc(size, GFP_ATOMIC)) == NULL) {
18623 + osh->malloced += size;
18629 +osl_mfree(osl_t *osh, void *addr, uint size)
18632 + ASSERT(osh->magic == OS_HANDLE_MAGIC);
18633 + osh->malloced -= size;
18639 +osl_malloced(osl_t *osh)
18641 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18642 + return (osh->malloced);
18645 +uint osl_malloc_failed(osl_t *osh)
18647 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18648 + return (osh->failed);
18652 +osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap)
18654 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18656 + return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap));
18660 +osl_dma_free_consistent(osl_t *osh, void *va, uint size, ulong pa)
18662 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18664 + pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
18668 +osl_dma_map(osl_t *osh, void *va, uint size, int direction)
18672 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18673 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
18674 + return (pci_map_single(osh->pdev, va, size, dir));
18678 +osl_dma_unmap(osl_t *osh, uint pa, uint size, int direction)
18682 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18683 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
18684 + pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
18687 +#if defined(BINOSL)
18689 +osl_assert(char *exp, char *file, int line)
18691 + char tempbuf[255];
18693 + sprintf(tempbuf, "assertion \"%s\" failed: file \"%s\", line %d\n", exp, file, line);
18696 +#endif /* BCMDBG || BINOSL */
18699 +osl_delay(uint usec)
18703 + while (usec > 0) {
18704 + d = MIN(usec, 1000);
18711 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
18716 +osl_printf(const char *format, ...)
18722 + /* sprintf into a local buffer because there *is* no "vprintk()".. */
18723 + va_start(args, format);
18724 + len = vsprintf(buf, format, args);
18727 + if (len > sizeof (buf)) {
18728 + printk("osl_printf: buffer overrun\n");
18732 + return (printk(buf));
18736 +osl_sprintf(char *buf, const char *format, ...)
18741 + va_start(args, format);
18742 + rc = vsprintf(buf, format, args);
18748 +osl_strcmp(const char *s1, const char *s2)
18750 + return (strcmp(s1, s2));
18754 +osl_strncmp(const char *s1, const char *s2, uint n)
18756 + return (strncmp(s1, s2, n));
18760 +osl_strlen(const char *s)
18762 + return (strlen(s));
18766 +osl_strcpy(char *d, const char *s)
18768 + return (strcpy(d, s));
18772 +osl_strncpy(char *d, const char *s, uint n)
18774 + return (strncpy(d, s, n));
18778 +bcopy(const void *src, void *dst, int len)
18780 + memcpy(dst, src, len);
18784 +bcmp(const void *b1, const void *b2, int len)
18786 + return (memcmp(b1, b2, len));
18790 +bzero(void *b, int len)
18792 + memset(b, '\0', len);
18796 +osl_readl(volatile uint32 *r)
18798 + return (readl(r));
18802 +osl_readw(volatile uint16 *r)
18804 + return (readw(r));
18808 +osl_readb(volatile uint8 *r)
18810 + return (readb(r));
18814 +osl_writel(uint32 v, volatile uint32 *r)
18820 +osl_writew(uint16 v, volatile uint16 *r)
18826 +osl_writeb(uint8 v, volatile uint8 *r)
18832 +osl_uncached(void *va)
18835 + return ((void*)KSEG1ADDR(va));
18837 + return ((void*)va);
18842 +osl_getcycles(void)
18847 + cycles = read_c0_count() * 2;
18848 +#elif defined(__i386__)
18857 +osl_reg_map(uint32 pa, uint size)
18859 + return (ioremap_nocache((unsigned long)pa, (unsigned long)size));
18863 +osl_reg_unmap(void *va)
18869 +osl_busprobe(uint32 *val, uint32 addr)
18872 + return get_dbe(*val, (uint32*)addr);
18874 + *val = readl(addr);
18880 +osl_pktdata(osl_t *osh, void *skb)
18882 + return (((struct sk_buff*)skb)->data);
18886 +osl_pktlen(osl_t *osh, void *skb)
18888 + return (((struct sk_buff*)skb)->len);
18892 +osl_pktheadroom(osl_t *osh, void *skb)
18894 + return (uint) skb_headroom((struct sk_buff *) skb);
18898 +osl_pkttailroom(osl_t *osh, void *skb)
18900 + return (uint) skb_tailroom((struct sk_buff *) skb);
18904 +osl_pktnext(osl_t *osh, void *skb)
18906 + return (((struct sk_buff*)skb)->next);
18910 +osl_pktsetnext(void *skb, void *x)
18912 + ((struct sk_buff*)skb)->next = (struct sk_buff*)x;
18916 +osl_pktsetlen(osl_t *osh, void *skb, uint len)
18918 + __skb_trim((struct sk_buff*)skb, len);
18922 +osl_pktpush(osl_t *osh, void *skb, int bytes)
18924 + return (skb_push((struct sk_buff*)skb, bytes));
18928 +osl_pktpull(osl_t *osh, void *skb, int bytes)
18930 + return (skb_pull((struct sk_buff*)skb, bytes));
18934 +osl_pktdup(osl_t *osh, void *skb)
18936 + return (skb_clone((struct sk_buff*)skb, GFP_ATOMIC));
18940 +osl_pktcookie(void *skb)
18942 + return ((void*)((struct sk_buff*)skb)->csum);
18946 +osl_pktsetcookie(void *skb, void *x)
18948 + ((struct sk_buff*)skb)->csum = (uint)x;
18952 +osl_pktlink(void *skb)
18954 + return (((struct sk_buff*)skb)->prev);
18958 +osl_pktsetlink(void *skb, void *x)
18960 + ((struct sk_buff*)skb)->prev = (struct sk_buff*)x;
18964 +osl_pktprio(void *skb)
18966 + return (((struct sk_buff*)skb)->priority);
18970 +osl_pktsetprio(void *skb, uint x)
18972 + ((struct sk_buff*)skb)->priority = x;
18976 +#endif /* BINOSL */
18977 diff -Nur linux-2.4.32/drivers/net/hnd/Makefile linux-2.4.32-brcm/drivers/net/hnd/Makefile
18978 --- linux-2.4.32/drivers/net/hnd/Makefile 1970-01-01 01:00:00.000000000 +0100
18979 +++ linux-2.4.32-brcm/drivers/net/hnd/Makefile 2005-12-16 23:39:11.284858000 +0100
18982 +# Makefile for the BCM47xx specific kernel interface routines
18986 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
18990 +HND_OBJS := bcmutils.o hnddma.o linux_osl.o sbutils.o bcmsrom.o
18992 +export-objs := shared_ksyms.o
18993 +obj-y := shared_ksyms.o $(HND_OBJS)
18994 +obj-m := $(O_TARGET)
18996 +include $(TOPDIR)/Rules.make
18998 +shared_ksyms.c: shared_ksyms.sh $(HND_OBJS)
18999 + sh -e $< $(HND_OBJS) > $@
19000 diff -Nur linux-2.4.32/drivers/net/hnd/sbutils.c linux-2.4.32-brcm/drivers/net/hnd/sbutils.c
19001 --- linux-2.4.32/drivers/net/hnd/sbutils.c 1970-01-01 01:00:00.000000000 +0100
19002 +++ linux-2.4.32-brcm/drivers/net/hnd/sbutils.c 2005-12-16 23:39:11.316860000 +0100
19005 + * Misc utility routines for accessing chip-specific features
19006 + * of the SiliconBackplane-based Broadcom chips.
19008 + * Copyright 2005, Broadcom Corporation
19009 + * All Rights Reserved.
19011 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
19012 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
19013 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
19014 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
19018 +#include <typedefs.h>
19020 +#include <sbutils.h>
19021 +#include <bcmutils.h>
19022 +#include <bcmdevs.h>
19023 +#include <sbconfig.h>
19024 +#include <sbchipc.h>
19025 +#include <sbpci.h>
19026 +#include <sbpcie.h>
19027 +#include <pcicfg.h>
19028 +#include <sbpcmcia.h>
19029 +#include <sbextif.h>
19030 +#include <bcmsrom.h>
19033 +#define SB_ERROR(args)
19036 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg);
19037 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg);
19038 +typedef bool (*sb_intrsenabled_t)(void *intr_arg);
19040 +/* misc sb info needed by some of the routines */
19041 +typedef struct sb_info {
19043 + struct sb_pub sb; /* back plane public state(must be first field of sb_info */
19045 + void *osh; /* osl os handle */
19046 + void *sdh; /* bcmsdh handle */
19048 + void *curmap; /* current regs va */
19049 + void *regs[SB_MAXCORES]; /* other regs va */
19051 + uint curidx; /* current core index */
19052 + uint dev_coreid; /* the core provides driver functions */
19054 + bool memseg; /* flag to toggle MEM_SEG register */
19056 + uint gpioidx; /* gpio control core index */
19057 + uint gpioid; /* gpio control coretype */
19059 + uint numcores; /* # discovered cores */
19060 + uint coreid[SB_MAXCORES]; /* id of each core */
19062 + void *intr_arg; /* interrupt callback function arg */
19063 + sb_intrsoff_t intrsoff_fn; /* function turns chip interrupts off */
19064 + sb_intrsrestore_t intrsrestore_fn; /* function restore chip interrupts */
19065 + sb_intrsenabled_t intrsenabled_fn; /* function to check if chip interrupts are enabled */
19069 +/* local prototypes */
19070 +static sb_info_t * BCMINIT(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
19071 + uint bustype, void *sdh, char **vars, int *varsz);
19072 +static void BCMINIT(sb_scan)(sb_info_t *si);
19073 +static uint sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val);
19074 +static uint _sb_coreidx(sb_info_t *si);
19075 +static uint sb_findcoreidx(sb_info_t *si, uint coreid, uint coreunit);
19076 +static uint BCMINIT(sb_pcidev2chip)(uint pcidev);
19077 +static uint BCMINIT(sb_chip2numcores)(uint chip);
19078 +static bool sb_ispcie(sb_info_t *si);
19079 +static bool sb_find_pci_capability(sb_info_t *si, uint8 req_cap_id, uchar *buf, uint32 *buflen);
19080 +static int sb_pci_fixcfg(sb_info_t *si);
19082 +/* routines to access mdio slave device registers */
19083 +static int sb_pcie_mdiowrite(sb_info_t *si, uint physmedia, uint readdr, uint val);
19084 +static void BCMINIT(sb_war30841)(sb_info_t *si);
19086 +/* delay needed between the mdio control/ mdiodata register data access */
19087 +#define PR28829_DELAY() OSL_DELAY(10)
19090 +/* global variable to indicate reservation/release of gpio's*/
19091 +static uint32 sb_gpioreservation = 0;
19093 +#define SB_INFO(sbh) (sb_info_t*)sbh
19094 +#define SET_SBREG(sbh, r, mask, val) W_SBREG((sbh), (r), ((R_SBREG((sbh), (r)) & ~(mask)) | (val)))
19095 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && ISALIGNED((x), SB_CORE_SIZE))
19096 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE))
19097 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF)
19098 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES)
19099 +#define BADIDX (SB_MAXCORES+1)
19102 +#define PCI(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCI))
19103 +#define PCIE(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCIE))
19106 +#define SONICS_2_2 (SBIDL_RV_2_2 >> SBIDL_RV_SHIFT)
19107 +#define SONICS_2_3 (SBIDL_RV_2_3 >> SBIDL_RV_SHIFT)
19109 +#define R_SBREG(sbh, sbr) sb_read_sbreg((sbh), (sbr))
19110 +#define W_SBREG(sbh, sbr, v) sb_write_sbreg((sbh), (sbr), (v))
19111 +#define AND_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) & (v)))
19112 +#define OR_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) | (v)))
19115 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/
19116 + * after core switching to avoid invalid register accesss inside ISR.
19118 +#define INTR_OFF(si, intr_val) \
19119 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
19120 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); }
19121 +#define INTR_RESTORE(si, intr_val) \
19122 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
19123 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
19125 +/* dynamic clock control defines */
19126 +#define LPOMINFREQ 25000 /* low power oscillator min */
19127 +#define LPOMAXFREQ 43000 /* low power oscillator max */
19128 +#define XTALMINFREQ 19800000 /* 20 MHz - 1% */
19129 +#define XTALMAXFREQ 20200000 /* 20 MHz + 1% */
19130 +#define PCIMINFREQ 25000000 /* 25 MHz */
19131 +#define PCIMAXFREQ 34000000 /* 33 MHz + fudge */
19133 +#define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */
19134 +#define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */
19136 +#define MIN_DUMPBUFLEN 32 /* debug */
19138 +/* different register spaces to access thr'u pcie indirect access*/
19139 +#define PCIE_CONFIGREGS 1
19140 +#define PCIE_PCIEREGS 2
19142 +/* GPIO Based LED powersave defines */
19143 +#define DEFAULT_GPIO_ONTIME 10
19144 +#define DEFAULT_GPIO_OFFTIME 90
19146 +#define DEFAULT_GPIOTIMERVAL ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME)
19149 +sb_read_sbreg(sb_info_t *si, volatile uint32 *sbr)
19152 + uint32 val, intr_val = 0;
19156 + * compact flash only has 11 bits address, while we needs 12 bits address.
19157 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
19158 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
19159 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
19162 + INTR_OFF(si, intr_val);
19164 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19165 + sbr = (uint32) ((uintptr) sbr & ~(1 << 11)); /* mask out bit 11*/
19168 + val = R_REG(sbr);
19172 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19173 + INTR_RESTORE(si, intr_val);
19180 +sb_write_sbreg(sb_info_t *si, volatile uint32 *sbr, uint32 v)
19183 + volatile uint32 dummy;
19184 + uint32 intr_val = 0;
19188 + * compact flash only has 11 bits address, while we needs 12 bits address.
19189 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
19190 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
19191 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
19194 + INTR_OFF(si, intr_val);
19196 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19197 + sbr = (uint32) ((uintptr) sbr & ~(1 << 11)); /* mask out bit 11*/
19200 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) {
19201 +#ifdef IL_BIGENDIAN
19202 + dummy = R_REG(sbr);
19203 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
19204 + dummy = R_REG(sbr);
19205 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
19207 + dummy = R_REG(sbr);
19208 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
19209 + dummy = R_REG(sbr);
19210 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
19217 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19218 + INTR_RESTORE(si, intr_val);
19223 + * Allocate a sb handle.
19224 + * devid - pci device id (used to determine chip#)
19225 + * osh - opaque OS handle
19226 + * regs - virtual address of initial core registers
19227 + * bustype - pci/pcmcia/sb/sdio/etc
19228 + * vars - pointer to a pointer area for "environment" variables
19229 + * varsz - pointer to int to return the size of the vars
19232 +BCMINITFN(sb_attach)(uint devid, osl_t *osh, void *regs,
19233 + uint bustype, void *sdh, char **vars, int *varsz)
19237 + /* alloc sb_info_t */
19238 + if ((si = MALLOC(osh, sizeof (sb_info_t))) == NULL) {
19239 + SB_ERROR(("sb_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh)));
19243 + if (BCMINIT(sb_doattach)(si, devid, osh, regs, bustype, sdh, vars, varsz) == NULL) {
19244 + MFREE(osh, si, sizeof (sb_info_t));
19247 + return (sb_t *)si;
19250 +/* Using sb_kattach depends on SB_BUS support, either implicit */
19251 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */
19252 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS)
19254 +/* global kernel resource */
19255 +static sb_info_t ksi;
19257 +/* generic kernel variant of sb_attach() */
19259 +BCMINITFN(sb_kattach)()
19263 + if (ksi.curmap == NULL) {
19266 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE);
19267 + cid = R_REG((uint32 *)regs);
19268 + if (((cid & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
19269 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) &&
19270 + ((cid & CID_REV_MASK) <= (3 << CID_REV_SHIFT))) {
19271 + uint32 *scc, val;
19273 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl));
19274 + val = R_REG(scc);
19275 + SB_ERROR((" initial scc = 0x%x\n", val));
19276 + val |= SCC_SS_XTAL;
19280 + if (BCMINIT(sb_doattach)(&ksi, BCM4710_DEVICE_ID, NULL, (void*)regs,
19281 + SB_BUS, NULL, NULL, NULL) == NULL) {
19286 + return (sb_t *)&ksi;
19290 +static sb_info_t *
19291 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
19292 + uint bustype, void *sdh, char **vars, int *varsz)
19299 + ASSERT(GOODREGS(regs));
19301 + bzero((uchar*)si, sizeof (sb_info_t));
19303 + si->sb.buscoreidx = si->gpioidx = BADIDX;
19306 + si->curmap = regs;
19309 + /* check to see if we are a sb core mimic'ing a pci core */
19310 + if (bustype == PCI_BUS) {
19311 + if (OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof (uint32)) == 0xffffffff)
19312 + bustype = SB_BUS;
19314 + bustype = PCI_BUS;
19317 + si->sb.bustype = bustype;
19318 + if (si->sb.bustype != BUSTYPE(si->sb.bustype)) {
19319 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n",
19320 + si->sb.bustype, BUSTYPE(si->sb.bustype)));
19324 + /* need to set memseg flag for CF card first before any sb registers access */
19325 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS)
19326 + si->memseg = TRUE;
19328 + /* kludge to enable the clock on the 4306 which lacks a slowclock */
19329 + if (BUSTYPE(si->sb.bustype) == PCI_BUS)
19330 + sb_clkctl_xtal(&si->sb, XTAL|PLL, ON);
19332 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
19333 + w = OSL_PCI_READ_CONFIG(osh, PCI_BAR0_WIN, sizeof (uint32));
19334 + if (!GOODCOREADDR(w))
19335 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32), SB_ENUM_BASE);
19338 + /* initialize current core index value */
19339 + si->curidx = _sb_coreidx(si);
19341 + if (si->curidx == BADIDX) {
19342 + SB_ERROR(("sb_doattach: bad core index\n"));
19346 + /* get sonics backplane revision */
19347 + sb = REGS2SB(si->curmap);
19348 + si->sb.sonicsrev = (R_SBREG(si, &(sb)->sbidlow) & SBIDL_RV_MASK) >> SBIDL_RV_SHIFT;
19350 + /* keep and reuse the initial register mapping */
19351 + origidx = si->curidx;
19352 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
19353 + si->regs[origidx] = regs;
19355 + /* is core-0 a chipcommon core? */
19356 + si->numcores = 1;
19357 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, 0);
19358 + if (sb_coreid(&si->sb) != SB_CC)
19361 + /* determine chip id and rev */
19363 + /* chip common core found! */
19364 + si->sb.chip = R_REG(&cc->chipid) & CID_ID_MASK;
19365 + si->sb.chiprev = (R_REG(&cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT;
19366 + si->sb.chippkg = (R_REG(&cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT;
19368 + /* The only pcmcia chip without a chipcommon core is a 4301 */
19369 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS)
19370 + devid = BCM4301_DEVICE_ID;
19372 + /* no chip common core -- must convert device id to chip id */
19373 + if ((si->sb.chip = BCMINIT(sb_pcidev2chip)(devid)) == 0) {
19374 + SB_ERROR(("sb_doattach: unrecognized device id 0x%04x\n", devid));
19375 + sb_setcoreidx(&si->sb, origidx);
19380 + /* get chipcommon rev */
19381 + si->sb.ccrev = cc ? (int)sb_corerev(&si->sb) : NOREV;
19383 + /* determine numcores */
19384 + if (cc && ((si->sb.ccrev == 4) || (si->sb.ccrev >= 6)))
19385 + si->numcores = (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT;
19387 + si->numcores = BCMINIT(sb_chip2numcores)(si->sb.chip);
19389 + /* return to original core */
19390 + sb_setcoreidx(&si->sb, origidx);
19392 + /* sanity checks */
19393 + ASSERT(si->sb.chip);
19395 + /* scan for cores */
19396 + BCMINIT(sb_scan)(si);
19398 + /* fixup necessary chip/core configurations */
19399 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
19400 + if (sb_pci_fixcfg(si)) {
19401 + SB_ERROR(("sb_doattach: sb_pci_fixcfg failed\n"));
19406 + /* srom_var_init() depends on sb_scan() info */
19407 + if (srom_var_init(si, si->sb.bustype, si->curmap, osh, vars, varsz)) {
19408 + SB_ERROR(("sb_doattach: srom_var_init failed: bad srom\n"));
19412 + if (cc == NULL) {
19414 + * The chip revision number is hardwired into all
19415 + * of the pci function config rev fields and is
19416 + * independent from the individual core revision numbers.
19417 + * For example, the "A0" silicon of each chip is chip rev 0.
19418 + * For PCMCIA we get it from the CIS instead.
19420 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) {
19422 + si->sb.chiprev = getintvar(*vars, "chiprev");
19423 + } else if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
19424 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_REV, sizeof (uint32));
19425 + si->sb.chiprev = w & 0xff;
19427 + si->sb.chiprev = 0;
19430 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) {
19431 + w = getintvar(*vars, "regwindowsz");
19432 + si->memseg = (w <= CFTABLE_REGWIN_2K) ? TRUE : FALSE;
19435 + /* gpio control core is required */
19436 + if (!GOODIDX(si->gpioidx)) {
19437 + SB_ERROR(("sb_doattach: gpio control core not found\n"));
19441 + /* get boardtype and boardrev */
19442 + switch (BUSTYPE(si->sb.bustype)) {
19444 + /* do a pci config read to get subsystem id and subvendor id */
19445 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_SVID, sizeof (uint32));
19446 + si->sb.boardvendor = w & 0xffff;
19447 + si->sb.boardtype = (w >> 16) & 0xffff;
19452 + si->sb.boardvendor = getintvar(*vars, "manfid");
19453 + si->sb.boardtype = getintvar(*vars, "prodid");
19458 + si->sb.boardvendor = VENDOR_BROADCOM;
19459 + if ((si->sb.boardtype = getintvar(NULL, "boardtype")) == 0)
19460 + si->sb.boardtype = 0xffff;
19464 + if (si->sb.boardtype == 0) {
19465 + SB_ERROR(("sb_doattach: unknown board type\n"));
19466 + ASSERT(si->sb.boardtype);
19469 + /* setup the GPIO based LED powersave register */
19470 + if (si->sb.ccrev >= 16) {
19471 + w = getintvar(*vars, "gpiotimerval");
19473 + w = DEFAULT_GPIOTIMERVAL;
19474 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), ~0, w);
19482 +sb_coreid(sb_t *sbh)
19487 + si = SB_INFO(sbh);
19488 + sb = REGS2SB(si->curmap);
19490 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT);
19494 +sb_coreidx(sb_t *sbh)
19498 + si = SB_INFO(sbh);
19499 + return (si->curidx);
19502 +/* return current index of core */
19504 +_sb_coreidx(sb_info_t *si)
19507 + uint32 sbaddr = 0;
19511 + switch (BUSTYPE(si->sb.bustype)) {
19513 + sb = REGS2SB(si->curmap);
19514 + sbaddr = sb_base(R_SBREG(si, &sb->sbadmatch0));
19518 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32));
19521 + case PCMCIA_BUS: {
19524 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
19525 + sbaddr = (uint)tmp << 12;
19526 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
19527 + sbaddr |= (uint)tmp << 16;
19528 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
19529 + sbaddr |= (uint)tmp << 24;
19535 + sbaddr = (uint32)si->curmap;
19537 +#endif /* BCMJTAG */
19543 + if (!GOODCOREADDR(sbaddr))
19546 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE);
19550 +sb_corevendor(sb_t *sbh)
19555 + si = SB_INFO(sbh);
19556 + sb = REGS2SB(si->curmap);
19558 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT);
19562 +sb_corerev(sb_t *sbh)
19568 + si = SB_INFO(sbh);
19569 + sb = REGS2SB(si->curmap);
19570 + sbidh = R_SBREG(si, &(sb)->sbidhigh);
19572 + return (SBCOREREV(sbidh));
19580 + si = SB_INFO(sbh);
19584 +#define SBTML_ALLOW (SBTML_PE | SBTML_FGC | SBTML_FL_MASK)
19586 +/* set/clear sbtmstatelow core-specific flags */
19588 +sb_coreflags(sb_t *sbh, uint32 mask, uint32 val)
19594 + si = SB_INFO(sbh);
19595 + sb = REGS2SB(si->curmap);
19597 + ASSERT((val & ~mask) == 0);
19598 + ASSERT((mask & ~SBTML_ALLOW) == 0);
19600 + /* mask and set */
19601 + if (mask || val) {
19602 + w = (R_SBREG(si, &sb->sbtmstatelow) & ~mask) | val;
19603 + W_SBREG(si, &sb->sbtmstatelow, w);
19606 + /* return the new value */
19607 + return (R_SBREG(si, &sb->sbtmstatelow) & SBTML_ALLOW);
19610 +/* set/clear sbtmstatehigh core-specific flags */
19612 +sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val)
19618 + si = SB_INFO(sbh);
19619 + sb = REGS2SB(si->curmap);
19621 + ASSERT((val & ~mask) == 0);
19622 + ASSERT((mask & ~SBTMH_FL_MASK) == 0);
19624 + /* mask and set */
19625 + if (mask || val) {
19626 + w = (R_SBREG(si, &sb->sbtmstatehigh) & ~mask) | val;
19627 + W_SBREG(si, &sb->sbtmstatehigh, w);
19630 + /* return the new value */
19631 + return (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_FL_MASK);
19634 +/* caller needs to take care of core-specific bist hazards */
19636 +sb_corebist(sb_t *sbh, uint coreid, uint coreunit)
19643 + si = SB_INFO(sbh);
19645 + coreidx = sb_findcoreidx(si, coreid, coreunit);
19646 + if (!GOODIDX(coreidx))
19647 + result = BCME_ERROR;
19649 + sblo = sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), 0, 0);
19650 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, (sblo | SBTML_FGC | SBTML_BE));
19652 + SPINWAIT(((sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTD) == 0), 100000);
19654 + if (sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTF)
19655 + result = BCME_ERROR;
19657 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, sblo);
19664 +sb_iscoreup(sb_t *sbh)
19669 + si = SB_INFO(sbh);
19670 + sb = REGS2SB(si->curmap);
19672 + return ((R_SBREG(si, &(sb)->sbtmstatelow) & (SBTML_RESET | SBTML_REJ_MASK | SBTML_CLK)) == SBTML_CLK);
19676 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation,
19677 + * switch back to the original core, and return the new value.
19680 +sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val)
19685 + uint intr_val = 0;
19687 + ASSERT(GOODIDX(coreidx));
19688 + ASSERT(regoff < SB_CORE_SIZE);
19689 + ASSERT((val & ~mask) == 0);
19691 + INTR_OFF(si, intr_val);
19693 + /* save current core index */
19694 + origidx = sb_coreidx(&si->sb);
19696 + /* switch core */
19697 + r = (uint32*) ((uchar*) sb_setcoreidx(&si->sb, coreidx) + regoff);
19699 + /* mask and set */
19700 + if (mask || val) {
19701 + if (regoff >= SBCONFIGOFF) {
19702 + w = (R_SBREG(si, r) & ~mask) | val;
19703 + W_SBREG(si, r, w);
19705 + w = (R_REG(r) & ~mask) | val;
19711 + if (regoff >= SBCONFIGOFF)
19712 + w = R_SBREG(si, r);
19716 + /* restore core index */
19717 + if (origidx != coreidx)
19718 + sb_setcoreidx(&si->sb, origidx);
19720 + INTR_RESTORE(si, intr_val);
19724 +#define DWORD_ALIGN(x) (x & ~(0x03))
19725 +#define BYTE_POS(x) (x & 0x3)
19726 +#define WORD_POS(x) (x & 0x1)
19728 +#define BYTE_SHIFT(x) (8 * BYTE_POS(x))
19729 +#define WORD_SHIFT(x) (16 * WORD_POS(x))
19731 +#define BYTE_VAL(a, x) ((a >> BYTE_SHIFT(x)) & 0xFF)
19732 +#define WORD_VAL(a, x) ((a >> WORD_SHIFT(x)) & 0xFFFF)
19734 +#define read_pci_cfg_byte(a) \
19735 + (BYTE_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xff)
19737 +#define read_pci_cfg_write(a) \
19738 + (WORD_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xffff)
19741 +/* return TRUE if requested capability exists in the PCI config space */
19743 +sb_find_pci_capability(sb_info_t *si, uint8 req_cap_id, uchar *buf, uint32 *buflen)
19750 + if (BUSTYPE(si->sb.bustype) != PCI_BUS)
19753 + /* check for Header type 0*/
19754 + byte_val = read_pci_cfg_byte(PCI_CFG_HDR);
19755 + if ((byte_val & 0x7f) != PCI_HEADER_NORMAL)
19758 + /* check if the capability pointer field exists */
19759 + byte_val = read_pci_cfg_byte(PCI_CFG_STAT);
19760 + if (!(byte_val & PCI_CAPPTR_PRESENT))
19763 + cap_ptr = read_pci_cfg_byte(PCI_CFG_CAPPTR);
19764 + /* check if the capability pointer is 0x00 */
19765 + if (cap_ptr == 0x00)
19769 + /* loop thr'u the capability list and see if the pcie capabilty exists */
19771 + cap_id = read_pci_cfg_byte(cap_ptr);
19773 + while (cap_id != req_cap_id) {
19774 + cap_ptr = read_pci_cfg_byte((cap_ptr+1));
19775 + if (cap_ptr == 0x00) break;
19776 + cap_id = read_pci_cfg_byte(cap_ptr);
19778 + if (cap_id != req_cap_id) {
19781 + /* found the caller requested capability */
19782 + if ((buf != NULL) && (buflen != NULL)) {
19783 + bufsize = *buflen;
19784 + if (!bufsize) goto end;
19786 + /* copy the cpability data excluding cap ID and next ptr */
19788 + if ((bufsize + cap_ptr) > SZPCR)
19789 + bufsize = SZPCR - cap_ptr;
19790 + *buflen = bufsize;
19791 + while (bufsize--) {
19792 + *buf = read_pci_cfg_byte(cap_ptr);
19801 +/* return TRUE if PCIE capability exists the pci config space */
19803 +sb_ispcie(sb_info_t *si)
19805 + return(sb_find_pci_capability(si, PCI_CAP_PCIECAP_ID, NULL, NULL));
19808 +/* scan the sb enumerated space to identify all cores */
19810 +BCMINITFN(sb_scan)(sb_info_t *si)
19823 + /* numcores should already be set */
19824 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES));
19826 + /* save current core index */
19827 + origidx = sb_coreidx(&si->sb);
19829 + si->sb.buscorerev = NOREV;
19830 + si->sb.buscoreidx = BADIDX;
19832 + si->gpioidx = BADIDX;
19834 + pci = pcie = FALSE;
19835 + pcirev = pcierev = NOREV;
19836 + pciidx = pcieidx = BADIDX;
19838 + for (i = 0; i < si->numcores; i++) {
19839 + sb_setcoreidx(&si->sb, i);
19840 + si->coreid[i] = sb_coreid(&si->sb);
19842 + if (si->coreid[i] == SB_PCI) {
19844 + pcirev = sb_corerev(&si->sb);
19846 + } else if (si->coreid[i] == SB_PCIE) {
19848 + pcierev = sb_corerev(&si->sb);
19850 + } else if (si->coreid[i] == SB_PCMCIA) {
19851 + si->sb.buscorerev = sb_corerev(&si->sb);
19852 + si->sb.buscoretype = si->coreid[i];
19853 + si->sb.buscoreidx = i;
19856 + if (pci && pcie) {
19857 + if (sb_ispcie(si))
19863 + si->sb.buscoretype = SB_PCI;
19864 + si->sb.buscorerev = pcirev;
19865 + si->sb.buscoreidx = pciidx;
19868 + si->sb.buscoretype = SB_PCIE;
19869 + si->sb.buscorerev = pcierev;
19870 + si->sb.buscoreidx = pcieidx;
19874 + * Find the gpio "controlling core" type and index.
19876 + * - if there's a chip common core - use that
19877 + * - else if there's a pci core (rev >= 2) - use that
19878 + * - else there had better be an extif core (4710 only)
19880 + if (GOODIDX(sb_findcoreidx(si, SB_CC, 0))) {
19881 + si->gpioidx = sb_findcoreidx(si, SB_CC, 0);
19882 + si->gpioid = SB_CC;
19883 + } else if (PCI(si) && (si->sb.buscorerev >= 2)) {
19884 + si->gpioidx = si->sb.buscoreidx;
19885 + si->gpioid = SB_PCI;
19886 + } else if (sb_findcoreidx(si, SB_EXTIF, 0)) {
19887 + si->gpioidx = sb_findcoreidx(si, SB_EXTIF, 0);
19888 + si->gpioid = SB_EXTIF;
19890 + ASSERT(si->gpioidx != BADIDX);
19892 + /* return to original core index */
19893 + sb_setcoreidx(&si->sb, origidx);
19896 +/* may be called with core in reset */
19898 +sb_detach(sb_t *sbh)
19903 + si = SB_INFO(sbh);
19908 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
19909 + for (idx = 0; idx < SB_MAXCORES; idx++)
19910 + if (si->regs[idx]) {
19911 + REG_UNMAP(si->regs[idx]);
19912 + si->regs[idx] = NULL;
19916 + MFREE(si->osh, si, sizeof (sb_info_t));
19919 +/* use pci dev id to determine chip id for chips not having a chipcommon core */
19921 +BCMINITFN(sb_pcidev2chip)(uint pcidev)
19923 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID))
19924 + return (BCM4710_DEVICE_ID);
19925 + if ((pcidev >= BCM4402_DEVICE_ID) && (pcidev <= BCM4402_V90_ID))
19926 + return (BCM4402_DEVICE_ID);
19927 + if (pcidev == BCM4401_ENET_ID)
19928 + return (BCM4402_DEVICE_ID);
19929 + if ((pcidev >= BCM4307_V90_ID) && (pcidev <= BCM4307_D11B_ID))
19930 + return (BCM4307_DEVICE_ID);
19931 + if (pcidev == BCM4301_DEVICE_ID)
19932 + return (BCM4301_DEVICE_ID);
19937 +/* convert chip number to number of i/o cores */
19939 +BCMINITFN(sb_chip2numcores)(uint chip)
19941 + if (chip == BCM4710_DEVICE_ID)
19943 + if (chip == BCM4402_DEVICE_ID)
19945 + if ((chip == BCM4301_DEVICE_ID) || (chip == BCM4307_DEVICE_ID))
19947 + if (chip == BCM4306_DEVICE_ID) /* < 4306c0 */
19949 + if (chip == BCM4704_DEVICE_ID)
19951 + if (chip == BCM5365_DEVICE_ID)
19954 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip));
19959 +/* return index of coreid or BADIDX if not found */
19961 +sb_findcoreidx( sb_info_t *si, uint coreid, uint coreunit)
19968 + for (i = 0; i < si->numcores; i++)
19969 + if (si->coreid[i] == coreid) {
19970 + if (found == coreunit)
19979 + * this function changes logical "focus" to the indiciated core,
19980 + * must be called with interrupt off.
19981 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
19984 +sb_setcoreidx(sb_t *sbh, uint coreidx)
19990 + si = SB_INFO(sbh);
19992 + if (coreidx >= si->numcores)
19996 + * If the user has provided an interrupt mask enabled function,
19997 + * then assert interrupts are disabled before switching the core.
19999 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg));
20001 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE);
20003 + switch (BUSTYPE(si->sb.bustype)) {
20005 + /* map new one */
20006 + if (!si->regs[coreidx]) {
20007 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE);
20008 + ASSERT(GOODREGS(si->regs[coreidx]));
20010 + si->curmap = si->regs[coreidx];
20014 + /* point bar0 window */
20015 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr);
20019 + tmp = (sbaddr >> 12) & 0x0f;
20020 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
20021 + tmp = (sbaddr >> 16) & 0xff;
20022 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
20023 + tmp = (sbaddr >> 24) & 0xff;
20024 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
20028 + /* map new one */
20029 + if (!si->regs[coreidx]) {
20030 + si->regs[coreidx] = (void *)sbaddr;
20031 + ASSERT(GOODREGS(si->regs[coreidx]));
20033 + si->curmap = si->regs[coreidx];
20035 +#endif /* BCMJTAG */
20038 + si->curidx = coreidx;
20040 + return (si->curmap);
20044 + * this function changes logical "focus" to the indiciated core,
20045 + * must be called with interrupt off.
20046 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
20049 +sb_setcore(sb_t *sbh, uint coreid, uint coreunit)
20054 + si = SB_INFO(sbh);
20055 + idx = sb_findcoreidx(si, coreid, coreunit);
20056 + if (!GOODIDX(idx))
20059 + return (sb_setcoreidx(sbh, idx));
20062 +/* return chip number */
20064 +BCMINITFN(sb_chip)(sb_t *sbh)
20068 + si = SB_INFO(sbh);
20069 + return (si->sb.chip);
20072 +/* return chip revision number */
20074 +BCMINITFN(sb_chiprev)(sb_t *sbh)
20078 + si = SB_INFO(sbh);
20079 + return (si->sb.chiprev);
20082 +/* return chip common revision number */
20084 +BCMINITFN(sb_chipcrev)(sb_t *sbh)
20088 + si = SB_INFO(sbh);
20089 + return (si->sb.ccrev);
20092 +/* return chip package option */
20094 +BCMINITFN(sb_chippkg)(sb_t *sbh)
20098 + si = SB_INFO(sbh);
20099 + return (si->sb.chippkg);
20102 +/* return PCI core rev. */
20104 +BCMINITFN(sb_pcirev)(sb_t *sbh)
20108 + si = SB_INFO(sbh);
20109 + return (si->sb.buscorerev);
20113 +BCMINITFN(sb_war16165)(sb_t *sbh)
20117 + si = SB_INFO(sbh);
20119 + return (PCI(si) && (si->sb.buscorerev <= 10));
20123 +BCMINITFN(sb_war30841)(sb_info_t *si)
20125 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_TIMER1, 0x8128);
20126 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_CDR, 0x0100);
20127 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466);
20130 +/* return PCMCIA core rev. */
20132 +BCMINITFN(sb_pcmciarev)(sb_t *sbh)
20136 + si = SB_INFO(sbh);
20137 + return (si->sb.buscorerev);
20140 +/* return board vendor id */
20142 +BCMINITFN(sb_boardvendor)(sb_t *sbh)
20146 + si = SB_INFO(sbh);
20147 + return (si->sb.boardvendor);
20150 +/* return boardtype */
20152 +BCMINITFN(sb_boardtype)(sb_t *sbh)
20157 + si = SB_INFO(sbh);
20159 + if (BUSTYPE(si->sb.bustype) == SB_BUS && si->sb.boardtype == 0xffff) {
20160 + /* boardtype format is a hex string */
20161 + si->sb.boardtype = getintvar(NULL, "boardtype");
20163 + /* backward compatibility for older boardtype string format */
20164 + if ((si->sb.boardtype == 0) && (var = getvar(NULL, "boardtype"))) {
20165 + if (!strcmp(var, "bcm94710dev"))
20166 + si->sb.boardtype = BCM94710D_BOARD;
20167 + else if (!strcmp(var, "bcm94710ap"))
20168 + si->sb.boardtype = BCM94710AP_BOARD;
20169 + else if (!strcmp(var, "bu4710"))
20170 + si->sb.boardtype = BU4710_BOARD;
20171 + else if (!strcmp(var, "bcm94702mn"))
20172 + si->sb.boardtype = BCM94702MN_BOARD;
20173 + else if (!strcmp(var, "bcm94710r1"))
20174 + si->sb.boardtype = BCM94710R1_BOARD;
20175 + else if (!strcmp(var, "bcm94710r4"))
20176 + si->sb.boardtype = BCM94710R4_BOARD;
20177 + else if (!strcmp(var, "bcm94702cpci"))
20178 + si->sb.boardtype = BCM94702CPCI_BOARD;
20179 + else if (!strcmp(var, "bcm95380_rr"))
20180 + si->sb.boardtype = BCM95380RR_BOARD;
20184 + return (si->sb.boardtype);
20187 +/* return bus type of sbh device */
20193 + si = SB_INFO(sbh);
20194 + return (si->sb.bustype);
20197 +/* return bus core type */
20199 +sb_buscoretype(sb_t *sbh)
20203 + si = SB_INFO(sbh);
20205 + return (si->sb.buscoretype);
20208 +/* return bus core revision */
20210 +sb_buscorerev(sb_t *sbh)
20213 + si = SB_INFO(sbh);
20215 + return (si->sb.buscorerev);
20218 +/* return list of found cores */
20220 +sb_corelist(sb_t *sbh, uint coreid[])
20224 + si = SB_INFO(sbh);
20226 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof (uint)));
20227 + return (si->numcores);
20230 +/* return current register mapping */
20232 +sb_coreregs(sb_t *sbh)
20236 + si = SB_INFO(sbh);
20237 + ASSERT(GOODREGS(si->curmap));
20239 + return (si->curmap);
20243 +/* do buffered registers update */
20245 +sb_commit(sb_t *sbh)
20249 + uint intr_val = 0;
20251 + si = SB_INFO(sbh);
20253 + origidx = si->curidx;
20254 + ASSERT(GOODIDX(origidx));
20256 + INTR_OFF(si, intr_val);
20258 + /* switch over to chipcommon core if there is one, else use pci */
20259 + if (si->sb.ccrev != NOREV) {
20260 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0);
20262 + /* do the buffer registers update */
20263 + W_REG(&ccregs->broadcastaddress, SB_COMMIT);
20264 + W_REG(&ccregs->broadcastdata, 0x0);
20265 + } else if (PCI(si)) {
20266 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0);
20268 + /* do the buffer registers update */
20269 + W_REG(&pciregs->bcastaddr, SB_COMMIT);
20270 + W_REG(&pciregs->bcastdata, 0x0);
20274 + /* restore core index */
20275 + sb_setcoreidx(sbh, origidx);
20276 + INTR_RESTORE(si, intr_val);
20279 +/* reset and re-enable a core */
20281 +sb_core_reset(sb_t *sbh, uint32 bits)
20285 + volatile uint32 dummy;
20287 + si = SB_INFO(sbh);
20288 + ASSERT(GOODREGS(si->curmap));
20289 + sb = REGS2SB(si->curmap);
20292 + * Must do the disable sequence first to work for arbitrary current core state.
20294 + sb_core_disable(sbh, bits);
20297 + * Now do the initialization sequence.
20300 + /* set reset while enabling the clock and forcing them on throughout the core */
20301 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits));
20302 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20305 + if (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_SERR) {
20306 + W_SBREG(si, &sb->sbtmstatehigh, 0);
20308 + if ((dummy = R_SBREG(si, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) {
20309 + AND_SBREG(si, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO));
20312 + /* clear reset and allow it to propagate throughout the core */
20313 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits));
20314 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20317 + /* leave clock enabled */
20318 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_CLK | bits));
20319 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20324 +sb_core_tofixup(sb_t *sbh)
20329 + si = SB_INFO(sbh);
20331 + if ( (BUSTYPE(si->sb.bustype) != PCI_BUS) || PCIE(si) || (PCI(si) && (si->sb.buscorerev >= 5)) )
20334 + ASSERT(GOODREGS(si->curmap));
20335 + sb = REGS2SB(si->curmap);
20337 + if (BUSTYPE(si->sb.bustype) == SB_BUS) {
20338 + SET_SBREG(si, &sb->sbimconfiglow,
20339 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
20340 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3);
20342 + if (sb_coreid(sbh) == SB_PCI) {
20343 + SET_SBREG(si, &sb->sbimconfiglow,
20344 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
20345 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
20347 + SET_SBREG(si, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0);
20355 + * Set the initiator timeout for the "master core".
20356 + * The master core is defined to be the core in control
20357 + * of the chip and so it issues accesses to non-memory
20358 + * locations (Because of dma *any* core can access memeory).
20360 + * The routine uses the bus to decide who is the master:
20362 + * JTAG_BUS => chipc
20363 + * PCI_BUS => pci or pcie
20364 + * PCMCIA_BUS => pcmcia
20365 + * SDIO_BUS => pcmcia
20367 + * This routine exists so callers can disable initiator
20368 + * timeouts so accesses to very slow devices like otp
20369 + * won't cause an abort. The routine allows arbitrary
20370 + * settings of the service and request timeouts, though.
20372 + * Returns the timeout state before changing it or -1
20376 +#define TO_MASK (SBIMCL_RTO_MASK | SBIMCL_STO_MASK)
20379 +sb_set_initiator_to(sb_t *sbh, uint32 to)
20382 + uint origidx, idx;
20383 + uint intr_val = 0;
20384 + uint32 tmp, ret = 0xffffffff;
20387 + si = SB_INFO(sbh);
20389 + if ((to & ~TO_MASK) != 0)
20392 + /* Figure out the master core */
20394 + switch (BUSTYPE(si->sb.bustype)) {
20396 + idx = si->sb.buscoreidx;
20403 + idx = sb_findcoreidx(si, SB_PCMCIA, 0);
20406 + if ((idx = sb_findcoreidx(si, SB_MIPS33, 0)) == BADIDX)
20407 + idx = sb_findcoreidx(si, SB_MIPS, 0);
20412 + if (idx == BADIDX)
20415 + INTR_OFF(si, intr_val);
20416 + origidx = sb_coreidx(sbh);
20418 + sb = REGS2SB(sb_setcoreidx(sbh, idx));
20420 + tmp = R_SBREG(si, &sb->sbimconfiglow);
20421 + ret = tmp & TO_MASK;
20422 + W_SBREG(si, &sb->sbimconfiglow, (tmp & ~TO_MASK) | to);
20425 + sb_setcoreidx(sbh, origidx);
20426 + INTR_RESTORE(si, intr_val);
20431 +sb_core_disable(sb_t *sbh, uint32 bits)
20434 + volatile uint32 dummy;
20438 + si = SB_INFO(sbh);
20440 + ASSERT(GOODREGS(si->curmap));
20441 + sb = REGS2SB(si->curmap);
20443 + /* if core is already in reset, just return */
20444 + if (R_SBREG(si, &sb->sbtmstatelow) & SBTML_RESET)
20447 + /* reject value changed between sonics 2.2 and 2.3 */
20448 + if (si->sb.sonicsrev == SONICS_2_2)
20449 + rej = (1 << SBTML_REJ_SHIFT);
20451 + rej = (2 << SBTML_REJ_SHIFT);
20453 + /* if clocks are not enabled, put into reset and return */
20454 + if ((R_SBREG(si, &sb->sbtmstatelow) & SBTML_CLK) == 0)
20457 + /* set target reject and spin until busy is clear (preserve core-specific bits) */
20458 + OR_SBREG(si, &sb->sbtmstatelow, rej);
20459 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20461 + SPINWAIT((R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
20463 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT) {
20464 + OR_SBREG(si, &sb->sbimstate, SBIM_RJ);
20465 + dummy = R_SBREG(si, &sb->sbimstate);
20467 + SPINWAIT((R_SBREG(si, &sb->sbimstate) & SBIM_BY), 100000);
20470 + /* set reset and reject while enabling the clocks */
20471 + W_SBREG(si, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | rej | SBTML_RESET));
20472 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20475 + /* don't forget to clear the initiator reject bit */
20476 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT)
20477 + AND_SBREG(si, &sb->sbimstate, ~SBIM_RJ);
20480 + /* leave reset and reject asserted */
20481 + W_SBREG(si, &sb->sbtmstatelow, (bits | rej | SBTML_RESET));
20485 +/* set chip watchdog reset timer to fire in 'ticks' backplane cycles */
20487 +sb_watchdog(sb_t *sbh, uint ticks)
20489 + sb_info_t *si = SB_INFO(sbh);
20491 + /* instant NMI */
20492 + switch (si->gpioid) {
20494 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, watchdog), ~0, ticks);
20497 + sb_corereg(si, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks);
20502 +/* initialize the pcmcia core */
20504 +sb_pcmcia_init(sb_t *sbh)
20509 + si = SB_INFO(sbh);
20511 + /* enable d11 mac interrupts */
20512 + if (si->sb.chip == BCM4301_DEVICE_ID) {
20513 + /* Have to use FCR2 in 4301 */
20514 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
20515 + cor |= COR_IRQEN | COR_FUNEN;
20516 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
20518 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
20519 + cor |= COR_IRQEN | COR_FUNEN;
20520 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
20527 + * Configure the pci core for pci client (NIC) action
20528 + * coremask is the bitvec of cores by index to be enabled.
20531 +sb_pci_setup(sb_t *sbh, uint coremask)
20535 + sbpciregs_t *pciregs;
20541 + si = SB_INFO(sbh);
20543 + /* if not pci bus, we're done */
20544 + if (BUSTYPE(si->sb.bustype) != PCI_BUS)
20547 + ASSERT(PCI(si) || PCIE(si));
20548 + ASSERT(si->sb.buscoreidx != BADIDX);
20550 + /* get current core index */
20551 + idx = si->curidx;
20553 + /* we interrupt on this backplane flag number */
20554 + ASSERT(GOODREGS(si->curmap));
20555 + sb = REGS2SB(si->curmap);
20556 + sbflag = R_SBREG(si, &sb->sbtpsflag) & SBTPS_NUM0_MASK;
20558 + /* switch over to pci core */
20559 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->sb.buscoreidx);
20560 + sb = REGS2SB(pciregs);
20563 + * Enable sb->pci interrupts. Assume
20564 + * PCI rev 2.3 support was added in pci core rev 6 and things changed..
20566 + if (PCIE(si) || (PCI(si) && ((si->sb.buscorerev) >= 6))) {
20567 + /* pci config write to set this core bit in PCIIntMask */
20568 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32));
20569 + w |= (coremask << PCI_SBIM_SHIFT);
20570 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w);
20572 + /* set sbintvec bit for our flag number */
20573 + OR_SBREG(si, &sb->sbintvec, (1 << sbflag));
20577 + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST));
20578 + if (si->sb.buscorerev >= 11)
20579 + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI);
20580 + if (si->sb.buscorerev < 5) {
20581 + SET_SBREG(si, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
20582 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
20587 + if (PCIE(si) && (si->sb.buscorerev == 0)) {
20588 + reg_val = sb_pcie_readreg((void *)sbh, (void *)PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG);
20590 + sb_pcie_writereg((void *)sbh, (void *)PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG, reg_val);
20592 + reg_val = sb_pcie_readreg((void *)sbh, (void *)PCIE_PCIEREGS, PCIE_DLLP_LCREG);
20593 + reg_val &= ~(0x40);
20594 + sb_pcie_writereg(sbh, (void *)PCIE_PCIEREGS, PCIE_DLLP_LCREG, reg_val);
20596 + BCMINIT(sb_war30841)(si);
20599 + /* switch back to previous core */
20600 + sb_setcoreidx(sbh, idx);
20604 +sb_base(uint32 admatch)
20609 + type = admatch & SBAM_TYPE_MASK;
20610 + ASSERT(type < 3);
20615 + base = admatch & SBAM_BASE0_MASK;
20616 + } else if (type == 1) {
20617 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20618 + base = admatch & SBAM_BASE1_MASK;
20619 + } else if (type == 2) {
20620 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20621 + base = admatch & SBAM_BASE2_MASK;
20628 +sb_size(uint32 admatch)
20633 + type = admatch & SBAM_TYPE_MASK;
20634 + ASSERT(type < 3);
20639 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1);
20640 + } else if (type == 1) {
20641 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20642 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1);
20643 + } else if (type == 2) {
20644 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20645 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1);
20651 +/* return the core-type instantiation # of the current core */
20653 +sb_coreunit(sb_t *sbh)
20661 + si = SB_INFO(sbh);
20664 + idx = si->curidx;
20666 + ASSERT(GOODREGS(si->curmap));
20667 + coreid = sb_coreid(sbh);
20669 + /* count the cores of our type */
20670 + for (i = 0; i < idx; i++)
20671 + if (si->coreid[i] == coreid)
20674 + return (coreunit);
20677 +static INLINE uint32
20681 + case CC_F6_2: return 2;
20682 + case CC_F6_3: return 3;
20683 + case CC_F6_4: return 4;
20684 + case CC_F6_5: return 5;
20685 + case CC_F6_6: return 6;
20686 + case CC_F6_7: return 7;
20687 + default: return 0;
20691 +/* calculate the speed the SB would run at given a set of clockcontrol values */
20693 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m)
20695 + uint32 n1, n2, clock, m1, m2, m3, mc;
20697 + n1 = n & CN_N1_MASK;
20698 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT;
20700 + if (pll_type == PLL_TYPE6) {
20701 + if (m & CC_T6_MMASK)
20705 + } else if ((pll_type == PLL_TYPE1) ||
20706 + (pll_type == PLL_TYPE3) ||
20707 + (pll_type == PLL_TYPE4) ||
20708 + (pll_type == PLL_TYPE7)) {
20709 + n1 = factor6(n1);
20710 + n2 += CC_F5_BIAS;
20711 + } else if (pll_type == PLL_TYPE2) {
20712 + n1 += CC_T2_BIAS;
20713 + n2 += CC_T2_BIAS;
20714 + ASSERT((n1 >= 2) && (n1 <= 7));
20715 + ASSERT((n2 >= 5) && (n2 <= 23));
20716 + } else if (pll_type == PLL_TYPE5) {
20717 + return (100000000);
20720 + /* PLL types 3 and 7 use BASE2 (25Mhz) */
20721 + if ((pll_type == PLL_TYPE3) ||
20722 + (pll_type == PLL_TYPE7)) {
20723 + clock = CC_CLOCK_BASE2 * n1 * n2;
20726 + clock = CC_CLOCK_BASE1 * n1 * n2;
20731 + m1 = m & CC_M1_MASK;
20732 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT;
20733 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT;
20734 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT;
20736 + if ((pll_type == PLL_TYPE1) ||
20737 + (pll_type == PLL_TYPE3) ||
20738 + (pll_type == PLL_TYPE4) ||
20739 + (pll_type == PLL_TYPE7)) {
20740 + m1 = factor6(m1);
20741 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3))
20742 + m2 += CC_F5_BIAS;
20744 + m2 = factor6(m2);
20745 + m3 = factor6(m3);
20748 + case CC_MC_BYPASS: return (clock);
20749 + case CC_MC_M1: return (clock / m1);
20750 + case CC_MC_M1M2: return (clock / (m1 * m2));
20751 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3));
20752 + case CC_MC_M1M3: return (clock / (m1 * m3));
20753 + default: return (0);
20756 + ASSERT(pll_type == PLL_TYPE2);
20758 + m1 += CC_T2_BIAS;
20759 + m2 += CC_T2M2_BIAS;
20760 + m3 += CC_T2_BIAS;
20761 + ASSERT((m1 >= 2) && (m1 <= 7));
20762 + ASSERT((m2 >= 3) && (m2 <= 10));
20763 + ASSERT((m3 >= 2) && (m3 <= 7));
20765 + if ((mc & CC_T2MC_M1BYP) == 0)
20767 + if ((mc & CC_T2MC_M2BYP) == 0)
20769 + if ((mc & CC_T2MC_M3BYP) == 0)
20776 +/* returns the current speed the SB is running at */
20778 +sb_clock(sb_t *sbh)
20781 + extifregs_t *eir;
20785 + uint32 pll_type, rate;
20786 + uint intr_val = 0;
20788 + si = SB_INFO(sbh);
20789 + idx = si->curidx;
20790 + pll_type = PLL_TYPE1;
20792 + INTR_OFF(si, intr_val);
20794 + /* switch to extif or chipc core */
20795 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
20796 + n = R_REG(&eir->clockcontrol_n);
20797 + m = R_REG(&eir->clockcontrol_sb);
20798 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
20799 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
20800 + n = R_REG(&cc->clockcontrol_n);
20801 + if (pll_type == PLL_TYPE6)
20802 + m = R_REG(&cc->clockcontrol_mips);
20803 + else if (pll_type == PLL_TYPE3)
20805 + // Added by Chen-I for 5365
20806 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
20807 + m = R_REG(&cc->clockcontrol_sb);
20809 + m = R_REG(&cc->clockcontrol_m2);
20812 + m = R_REG(&cc->clockcontrol_sb);
20814 + INTR_RESTORE(si, intr_val);
20818 + // Added by Chen-I for 5365
20819 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
20821 + rate = 100000000;
20825 + /* calculate rate */
20826 + rate = sb_clock_rate(pll_type, n, m);
20827 + if (pll_type == PLL_TYPE3)
20831 + /* switch back to previous core */
20832 + sb_setcoreidx(sbh, idx);
20834 + INTR_RESTORE(si, intr_val);
20839 +/* change logical "focus" to the gpio core for optimized access */
20841 +sb_gpiosetcore(sb_t *sbh)
20845 + si = SB_INFO(sbh);
20847 + return (sb_setcoreidx(sbh, si->gpioidx));
20850 +/* mask&set gpiocontrol bits */
20852 +sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
20857 + si = SB_INFO(sbh);
20860 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
20862 + /* gpios could be shared on router platforms */
20863 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
20864 + mask = priority ? (sb_gpioreservation & mask) :
20865 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
20869 + switch (si->gpioid) {
20871 + regoff = OFFSETOF(chipcregs_t, gpiocontrol);
20875 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol);
20882 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
20885 +/* mask&set gpio output enable bits */
20887 +sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
20892 + si = SB_INFO(sbh);
20895 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
20897 + /* gpios could be shared on router platforms */
20898 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
20899 + mask = priority ? (sb_gpioreservation & mask) :
20900 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
20904 + switch (si->gpioid) {
20906 + regoff = OFFSETOF(chipcregs_t, gpioouten);
20910 + regoff = OFFSETOF(sbpciregs_t, gpioouten);
20914 + regoff = OFFSETOF(extifregs_t, gpio[0].outen);
20918 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
20921 +/* mask&set gpio output bits */
20923 +sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
20928 + si = SB_INFO(sbh);
20931 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
20933 + /* gpios could be shared on router platforms */
20934 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
20935 + mask = priority ? (sb_gpioreservation & mask) :
20936 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
20940 + switch (si->gpioid) {
20942 + regoff = OFFSETOF(chipcregs_t, gpioout);
20946 + regoff = OFFSETOF(sbpciregs_t, gpioout);
20950 + regoff = OFFSETOF(extifregs_t, gpio[0].out);
20954 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
20957 +/* reserve one gpio */
20959 +sb_gpioreserve(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
20963 + si = SB_INFO(sbh);
20965 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
20967 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
20968 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
20969 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
20972 + /* make sure only one bit is set */
20973 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
20974 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
20978 + /* already reserved */
20979 + if (sb_gpioreservation & gpio_bitmask)
20981 + /* set reservation */
20982 + sb_gpioreservation |= gpio_bitmask;
20984 + return sb_gpioreservation;
20987 +/* release one gpio */
20989 + * releasing the gpio doesn't change the current value on the GPIO last write value
20990 + * persists till some one overwrites it
20994 +sb_gpiorelease(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
20998 + si = SB_INFO(sbh);
21000 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
21002 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
21003 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
21004 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
21007 + /* make sure only one bit is set */
21008 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
21009 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
21013 + /* already released */
21014 + if (!(sb_gpioreservation & gpio_bitmask))
21017 + /* clear reservation */
21018 + sb_gpioreservation &= ~gpio_bitmask;
21020 + return sb_gpioreservation;
21023 +/* return the current gpioin register value */
21025 +sb_gpioin(sb_t *sbh)
21030 + si = SB_INFO(sbh);
21033 + switch (si->gpioid) {
21035 + regoff = OFFSETOF(chipcregs_t, gpioin);
21039 + regoff = OFFSETOF(sbpciregs_t, gpioin);
21043 + regoff = OFFSETOF(extifregs_t, gpioin);
21047 + return (sb_corereg(si, si->gpioidx, regoff, 0, 0));
21050 +/* mask&set gpio interrupt polarity bits */
21052 +sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
21057 + si = SB_INFO(sbh);
21060 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
21062 + /* gpios could be shared on router platforms */
21063 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
21064 + mask = priority ? (sb_gpioreservation & mask) :
21065 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
21069 + switch (si->gpioid) {
21071 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity);
21075 + /* pci gpio implementation does not support interrupt polarity */
21080 + regoff = OFFSETOF(extifregs_t, gpiointpolarity);
21084 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
21087 +/* mask&set gpio interrupt mask bits */
21089 +sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
21094 + si = SB_INFO(sbh);
21097 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
21099 + /* gpios could be shared on router platforms */
21100 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
21101 + mask = priority ? (sb_gpioreservation & mask) :
21102 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
21106 + switch (si->gpioid) {
21108 + regoff = OFFSETOF(chipcregs_t, gpiointmask);
21112 + /* pci gpio implementation does not support interrupt mask */
21117 + regoff = OFFSETOF(extifregs_t, gpiointmask);
21121 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
21124 +/* assign the gpio to an led */
21126 +sb_gpioled(sb_t *sbh, uint32 mask, uint32 val)
21130 + si = SB_INFO(sbh);
21131 + if (si->sb.ccrev < 16)
21134 + /* gpio led powersave reg */
21135 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimeroutmask), mask, val));
21138 +/* mask&set gpio timer val */
21140 +sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 gpiotimerval)
21143 + si = SB_INFO(sbh);
21145 + if (si->sb.ccrev < 16)
21148 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), mask, gpiotimerval));
21152 +/* return the slow clock source - LPO, XTAL, or PCI */
21154 +sb_slowclk_src(sb_info_t *si)
21159 + ASSERT(sb_coreid(&si->sb) == SB_CC);
21161 + if (si->sb.ccrev < 6) {
21162 + if ((BUSTYPE(si->sb.bustype) == PCI_BUS)
21163 + && (OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32)) & PCI_CFG_GPIO_SCS))
21164 + return (SCC_SS_PCI);
21166 + return (SCC_SS_XTAL);
21167 + } else if (si->sb.ccrev < 10) {
21168 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
21169 + return (R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK);
21170 + } else /* Insta-clock */
21171 + return (SCC_SS_XTAL);
21174 +/* return the ILP (slowclock) min or max frequency */
21176 +sb_slowclk_freq(sb_info_t *si, bool max)
21183 + ASSERT(sb_coreid(&si->sb) == SB_CC);
21185 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
21187 + /* shouldn't be here unless we've established the chip has dynamic clk control */
21188 + ASSERT(R_REG(&cc->capabilities) & CAP_PWR_CTL);
21190 + slowclk = sb_slowclk_src(si);
21191 + if (si->sb.ccrev < 6) {
21192 + if (slowclk == SCC_SS_PCI)
21193 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64));
21195 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32));
21196 + } else if (si->sb.ccrev < 10) {
21197 + div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
21198 + if (slowclk == SCC_SS_LPO)
21199 + return (max? LPOMAXFREQ : LPOMINFREQ);
21200 + else if (slowclk == SCC_SS_XTAL)
21201 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div));
21202 + else if (slowclk == SCC_SS_PCI)
21203 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div));
21207 + /* Chipc rev 10 is InstaClock */
21208 + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT;
21209 + div = 4 * (div + 1);
21210 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div));
21216 +sb_clkctl_setdelay(sb_info_t *si, void *chipcregs)
21218 + chipcregs_t * cc;
21219 + uint slowmaxfreq, pll_delay, slowclk;
21220 + uint pll_on_delay, fref_sel_delay;
21222 + pll_delay = PLL_DELAY;
21224 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay
21225 + * since the xtal will also be powered down by dynamic clk control logic.
21227 + slowclk = sb_slowclk_src(si);
21228 + if (slowclk != SCC_SS_XTAL)
21229 + pll_delay += XTAL_ON_DELAY;
21231 + /* Starting with 4318 it is ILP that is used for the delays */
21232 + slowmaxfreq = sb_slowclk_freq(si, (si->sb.ccrev >= 10) ? FALSE : TRUE);
21234 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
21235 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
21237 + cc = (chipcregs_t *)chipcregs;
21238 + W_REG(&cc->pll_on_delay, pll_on_delay);
21239 + W_REG(&cc->fref_sel_delay, fref_sel_delay);
21243 +sb_pwrctl_slowclk(void *sbh, bool set, uint *div)
21248 + uint intr_val = 0;
21251 + si = SB_INFO(sbh);
21253 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
21254 + if (si->sb.ccrev < 6)
21257 + /* chipcommon cores rev10 are a whole new ball game */
21258 + if (si->sb.ccrev >= 10)
21261 + if (set && ((*div % 4) || (*div < 4)))
21264 + INTR_OFF(si, intr_val);
21265 + origidx = si->curidx;
21266 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
21267 + ASSERT(cc != NULL);
21269 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) {
21275 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, ((*div / 4 - 1) << SCC_CD_SHIFT));
21276 + sb_clkctl_setdelay(sbh, (void *)cc);
21278 + *div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
21281 + sb_setcoreidx(sbh, origidx);
21282 + INTR_RESTORE(si, intr_val);
21286 +/* initialize power control delay registers */
21287 +void sb_clkctl_init(sb_t *sbh)
21293 + si = SB_INFO(sbh);
21295 + origidx = si->curidx;
21297 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
21300 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
21303 + /* 4317pc does not work with SlowClock less than 5 MHz */
21304 + if ((BUSTYPE(si->sb.bustype) == PCMCIA_BUS) && (si->sb.ccrev >= 6) && (si->sb.ccrev < 10))
21305 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, (ILP_DIV_5MHZ << SCC_CD_SHIFT));
21307 + /* set all Instaclk chip ILP to 1 MHz */
21308 + else if (si->sb.ccrev >= 10)
21309 + SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
21311 + sb_clkctl_setdelay(si, (void *)cc);
21314 + sb_setcoreidx(sbh, origidx);
21316 +void sb_pwrctl_init(sb_t *sbh)
21318 +sb_clkctl_init(sbh);
21320 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */
21322 +sb_clkctl_fast_pwrup_delay(sb_t *sbh)
21327 + uint slowminfreq;
21329 + uint intr_val = 0;
21331 + si = SB_INFO(sbh);
21333 + origidx = si->curidx;
21335 + INTR_OFF(si, intr_val);
21337 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
21340 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
21343 + slowminfreq = sb_slowclk_freq(si, FALSE);
21344 + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq;
21347 + sb_setcoreidx(sbh, origidx);
21348 + INTR_RESTORE(si, intr_val);
21349 + return (fpdelay);
21351 +uint16 sb_pwrctl_fast_pwrup_delay(sb_t *sbh)
21353 +return sb_clkctl_fast_pwrup_delay(sbh);
21355 +/* turn primary xtal and/or pll off/on */
21357 +sb_clkctl_xtal(sb_t *sbh, uint what, bool on)
21360 + uint32 in, out, outen;
21362 + si = SB_INFO(sbh);
21364 + switch (BUSTYPE(si->sb.bustype)) {
21373 + /* pcie core doesn't have any mapping to control the xtal pu */
21377 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof (uint32));
21378 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
21379 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32));
21382 + * Avoid glitching the clock if GPRS is already using it.
21383 + * We can't actually read the state of the PLLPD so we infer it
21384 + * by the value of XTAL_PU which *is* readable via gpioin.
21386 + if (on && (in & PCI_CFG_GPIO_XTAL))
21390 + outen |= PCI_CFG_GPIO_XTAL;
21392 + outen |= PCI_CFG_GPIO_PLL;
21395 + /* turn primary xtal on */
21396 + if (what & XTAL) {
21397 + out |= PCI_CFG_GPIO_XTAL;
21399 + out |= PCI_CFG_GPIO_PLL;
21400 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
21401 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
21402 + OSL_DELAY(XTAL_ON_DELAY);
21405 + /* turn pll on */
21406 + if (what & PLL) {
21407 + out &= ~PCI_CFG_GPIO_PLL;
21408 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
21413 + out &= ~PCI_CFG_GPIO_XTAL;
21415 + out |= PCI_CFG_GPIO_PLL;
21416 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
21417 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
21427 +int sb_pwrctl_xtal(sb_t *sbh, uint what, bool on)
21429 +return sb_clkctl_xtal(sbh,what,on);
21432 +/* set dynamic clk control mode (forceslow, forcefast, dynamic) */
21433 +/* returns true if ignore pll off is set and false if it is not */
21435 +sb_clkctl_clk(sb_t *sbh, uint mode)
21441 + bool forcefastclk=FALSE;
21442 + uint intr_val = 0;
21444 + si = SB_INFO(sbh);
21446 + /* chipcommon cores prior to rev6 don't support dynamic clock control */
21447 + if (si->sb.ccrev < 6)
21450 + /* chipcommon cores rev10 are a whole new ball game */
21451 + if (si->sb.ccrev >= 10)
21454 + INTR_OFF(si, intr_val);
21456 + origidx = si->curidx;
21458 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
21459 + ASSERT(cc != NULL);
21461 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
21465 + case CLK_FAST: /* force fast (pll) clock */
21466 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */
21467 + sb_clkctl_xtal(&si->sb, XTAL, ON);
21469 + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
21472 + case CLK_DYNAMIC: /* enable dynamic clock control */
21473 + scc = R_REG(&cc->slow_clk_ctl);
21474 + scc &= ~(SCC_FS | SCC_IP | SCC_XC);
21475 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
21477 + W_REG(&cc->slow_clk_ctl, scc);
21479 + /* for dynamic control, we have to release our xtal_pu "force on" */
21480 + if (scc & SCC_XC)
21481 + sb_clkctl_xtal(&si->sb, XTAL, OFF);
21488 + /* Is the h/w forcing the use of the fast clk */
21489 + forcefastclk = (bool)((R_REG(&cc->slow_clk_ctl) & SCC_IP) == SCC_IP);
21492 + sb_setcoreidx(sbh, origidx);
21493 + INTR_RESTORE(si, intr_val);
21494 + return (forcefastclk);
21497 +bool sb_pwrctl_clk(sb_t *sbh, uint mode)
21499 +return sb_clkctl_clk(sbh, mode);
21501 +/* register driver interrupt disabling and restoring callback functions */
21503 +sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg)
21507 + si = SB_INFO(sbh);
21508 + si->intr_arg = intr_arg;
21509 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn;
21510 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn;
21511 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn;
21512 + /* save current core id. when this function called, the current core
21513 + * must be the core which provides driver functions(il, et, wl, etc.)
21515 + si->dev_coreid = si->coreid[si->curidx];
21520 +sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
21521 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif)
21523 + uint vendor, core, unit;
21524 + uint chip, chippkg;
21526 + uint8 class, subclass, progif;
21528 + vendor = sb_corevendor(sbh);
21529 + core = sb_coreid(sbh);
21530 + unit = sb_coreunit(sbh);
21532 + chip = BCMINIT(sb_chip)(sbh);
21533 + chippkg = BCMINIT(sb_chippkg)(sbh);
21537 + /* Known vendor translations */
21538 + switch (vendor) {
21539 + case SB_VEND_BCM:
21540 + vendor = VENDOR_BROADCOM;
21544 + /* Determine class based on known core codes */
21547 + class = PCI_CLASS_NET;
21548 + subclass = PCI_NET_ETHER;
21549 + core = BCM47XX_ILINE_ID;
21552 + class = PCI_CLASS_NET;
21553 + subclass = PCI_NET_ETHER;
21554 + core = BCM47XX_ENET_ID;
21558 + class = PCI_CLASS_MEMORY;
21559 + subclass = PCI_MEMORY_RAM;
21563 + class = PCI_CLASS_BRIDGE;
21564 + subclass = PCI_BRIDGE_PCI;
21568 + class = PCI_CLASS_CPU;
21569 + subclass = PCI_CPU_MIPS;
21572 + class = PCI_CLASS_COMM;
21573 + subclass = PCI_COMM_MODEM;
21574 + core = BCM47XX_V90_ID;
21577 + class = PCI_CLASS_SERIAL;
21578 + subclass = PCI_SERIAL_USB;
21579 + progif = 0x10; /* OHCI */
21580 + core = BCM47XX_USB_ID;
21583 + class = PCI_CLASS_SERIAL;
21584 + subclass = PCI_SERIAL_USB;
21585 + progif = 0x10; /* OHCI */
21586 + core = BCM47XX_USBH_ID;
21589 + class = PCI_CLASS_SERIAL;
21590 + subclass = PCI_SERIAL_USB;
21591 + core = BCM47XX_USBD_ID;
21594 + class = PCI_CLASS_CRYPT;
21595 + subclass = PCI_CRYPT_NETWORK;
21596 + core = BCM47XX_IPSEC_ID;
21599 + class = PCI_CLASS_NET;
21600 + subclass = PCI_NET_OTHER;
21601 + core = BCM47XX_ROBO_ID;
21605 + class = PCI_CLASS_MEMORY;
21606 + subclass = PCI_MEMORY_FLASH;
21609 + class = PCI_CLASS_NET;
21610 + subclass = PCI_NET_OTHER;
21611 + /* Let an nvram variable override this */
21612 + sprintf(varname, "wl%did", unit);
21613 + if ((core = getintvar(NULL, varname)) == 0) {
21614 + if (chip == BCM4712_DEVICE_ID) {
21615 + if (chippkg == BCM4712SMALL_PKG_ID)
21616 + core = BCM4306_D11G_ID;
21618 + core = BCM4306_D11DUAL_ID;
21624 + class = subclass = progif = 0xff;
21628 + *pcivendor = (uint16)vendor;
21629 + *pcidevice = (uint16)core;
21630 + *pciclass = class;
21631 + *pcisubclass = subclass;
21632 + *pciprogif = progif;
21638 +/* use the mdio interface to write to mdio slaves */
21640 +sb_pcie_mdiowrite(sb_info_t *si, uint physmedia, uint regaddr, uint val)
21644 + sbpcieregs_t *pcieregs;
21646 + pcieregs = (sbpcieregs_t*) sb_setcoreidx(&si->sb, si->sb.buscoreidx);
21647 + ASSERT (pcieregs);
21649 + /* enable mdio access to SERDES */
21650 + W_REG((&pcieregs->mdiocontrol), MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL);
21652 + mdiodata = MDIODATA_START | MDIODATA_WRITE |
21653 + (physmedia << MDIODATA_DEVADDR_SHF) |
21654 + (regaddr << MDIODATA_REGADDR_SHF) | MDIODATA_TA | val;
21656 + W_REG((&pcieregs->mdiodata), mdiodata);
21660 + /* retry till the transaction is complete */
21661 + while ( i < 10 ) {
21662 + if (R_REG(&(pcieregs->mdiocontrol)) & MDIOCTL_ACCESS_DONE) {
21663 + /* Disable mdio access to SERDES */
21664 + W_REG((&pcieregs->mdiocontrol), 0);
21671 + SB_ERROR(("sb_pcie_mdiowrite: timed out\n"));
21672 + /* Disable mdio access to SERDES */
21673 + W_REG((&pcieregs->mdiocontrol), 0);
21679 +/* indirect way to read pcie config regs*/
21681 +sb_pcie_readreg(void *sb, void* arg1, uint offset)
21685 + uint retval = 0xFFFFFFFF;
21686 + sbpcieregs_t *pcieregs;
21689 + sbh = (sb_t *)sb;
21690 + si = SB_INFO(sbh);
21691 + ASSERT (PCIE(si));
21693 + pcieregs = (sbpcieregs_t *)sb_setcore(sbh, SB_PCIE, 0);
21694 + ASSERT (pcieregs);
21696 + addrtype = (uint)((uintptr)arg1);
21697 + switch(addrtype) {
21698 + case PCIE_CONFIGREGS:
21699 + W_REG((&pcieregs->configaddr),offset);
21700 + retval = R_REG(&(pcieregs->configdata));
21702 + case PCIE_PCIEREGS:
21703 + W_REG(&(pcieregs->pcieaddr),offset);
21704 + retval = R_REG(&(pcieregs->pciedata));
21713 +/* indirect way to write pcie config/mdio/pciecore regs*/
21715 +sb_pcie_writereg(sb_t *sbh, void *arg1, uint offset, uint val)
21718 + sbpcieregs_t *pcieregs;
21721 + si = SB_INFO(sbh);
21722 + ASSERT (PCIE(si));
21724 + pcieregs = (sbpcieregs_t *)sb_setcore(sbh, SB_PCIE, 0);
21725 + ASSERT (pcieregs);
21727 + addrtype = (uint)((uintptr)arg1);
21729 + switch(addrtype) {
21730 + case PCIE_CONFIGREGS:
21731 + W_REG((&pcieregs->configaddr),offset);
21732 + W_REG((&pcieregs->configdata),val);
21734 + case PCIE_PCIEREGS:
21735 + W_REG((&pcieregs->pcieaddr),offset);
21736 + W_REG((&pcieregs->pciedata),val);
21746 +/* Build device path. Support SB, PCI, and JTAG for now. */
21748 +sb_devpath(sb_t *sbh, char *path, int size)
21751 + ASSERT(size >= SB_DEVPATH_BUFSZ);
21753 + switch (BUSTYPE((SB_INFO(sbh))->sb.bustype)) {
21756 + sprintf(path, "sb/%u/", sb_coreidx(sbh));
21759 + ASSERT((SB_INFO(sbh))->osh);
21760 + sprintf(path, "pci/%u/%u/", OSL_PCI_BUS((SB_INFO(sbh))->osh),
21761 + OSL_PCI_SLOT((SB_INFO(sbh))->osh));
21764 + SB_ERROR(("sb_devpath: OSL_PCMCIA_BUS() not implemented, bus 1 assumed\n"));
21765 + SB_ERROR(("sb_devpath: OSL_PCMCIA_SLOT() not implemented, slot 1 assumed\n"));
21766 + sprintf(path, "pc/%u/%u/", 1, 1);
21769 + SB_ERROR(("sb_devpath: device 0 assumed\n"));
21770 + sprintf(path, "sd/%u/", sb_coreidx(sbh));
21780 +/* Fix chip's configuration. The current core may be changed upon return */
21782 +sb_pci_fixcfg(sb_info_t *si)
21784 + uint origidx, pciidx;
21785 + sbpciregs_t *pciregs;
21786 + sbpcieregs_t *pcieregs;
21787 + uint16 val16, *reg16;
21788 + char name[SB_DEVPATH_BUFSZ+16], *value;
21789 + char devpath[SB_DEVPATH_BUFSZ];
21791 + ASSERT(BUSTYPE(si->sb.bustype) == PCI_BUS);
21793 + /* Fix PCI(e) SROM shadow area */
21794 + /* save the current index */
21795 + origidx = sb_coreidx(&si->sb);
21797 + /* check 'pi' is correct and fix it if not */
21798 + if (si->sb.buscoretype == SB_PCIE) {
21799 + pcieregs = (sbpcieregs_t *)sb_setcore(&si->sb, SB_PCIE, 0);
21800 + ASSERT(pcieregs);
21801 + reg16 = &pcieregs->sprom[SRSH_PI_OFFSET];
21803 + else if (si->sb.buscoretype == SB_PCI) {
21804 + pciregs = (sbpciregs_t *)sb_setcore(&si->sb, SB_PCI, 0);
21806 + reg16 = &pciregs->sprom[SRSH_PI_OFFSET];
21812 + pciidx = sb_coreidx(&si->sb);
21813 + val16 = R_REG(reg16);
21814 + if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (uint16)pciidx) {
21815 + val16 = (uint16)(pciidx << SRSH_PI_SHIFT) | (val16 & ~SRSH_PI_MASK);
21816 + W_REG(reg16, val16);
21819 + /* restore the original index */
21820 + sb_setcoreidx(&si->sb, origidx);
21822 + /* Fix bar0window */
21823 + /* !do it last, it changes the current core! */
21824 + if (sb_devpath(&si->sb, devpath, sizeof(devpath)))
21826 + sprintf(name, "%sb0w", devpath);
21827 + if ((value = getvar(NULL, name))) {
21828 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof(uint32),
21829 + bcm_strtoul(value, NULL, 16));
21830 + /* update curidx since the current core is changed */
21831 + si->curidx = _sb_coreidx(si);
21832 + if (si->curidx == BADIDX) {
21833 + SB_ERROR(("sb_pci_fixcfg: bad core index\n"));
21841 diff -Nur linux-2.4.32/drivers/net/hnd/shared_ksyms.sh linux-2.4.32-brcm/drivers/net/hnd/shared_ksyms.sh
21842 --- linux-2.4.32/drivers/net/hnd/shared_ksyms.sh 1970-01-01 01:00:00.000000000 +0100
21843 +++ linux-2.4.32-brcm/drivers/net/hnd/shared_ksyms.sh 2005-12-16 23:39:11.316860000 +0100
21847 +# Copyright 2004, Broadcom Corporation
21848 +# All Rights Reserved.
21850 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
21851 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
21852 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
21853 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
21855 +# $Id: shared_ksyms.sh,v 1.1 2005/03/16 13:50:00 wbx Exp $
21859 +#include <linux/config.h>
21860 +#include <linux/module.h>
21863 +for file in $* ; do
21864 + ${NM} $file | sed -ne 's/[0-9A-Fa-f]* [DT] \([^ ]*\)/extern void \1; EXPORT_SYMBOL(\1);/p'
21866 diff -Nur linux-2.4.32/drivers/net/Makefile linux-2.4.32-brcm/drivers/net/Makefile
21867 --- linux-2.4.32/drivers/net/Makefile 2005-01-19 15:09:56.000000000 +0100
21868 +++ linux-2.4.32-brcm/drivers/net/Makefile 2005-12-16 23:39:11.284858000 +0100
21870 # Makefile for the Linux network (ethercard) device drivers.
21873 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include
21879 obj-$(CONFIG_ISDN) += slhc.o
21882 +subdir-$(CONFIG_HND) += hnd
21883 +subdir-$(CONFIG_ET) += et
21884 +subdir-$(CONFIG_WL) += wl
21885 subdir-$(CONFIG_NET_PCMCIA) += pcmcia
21886 subdir-$(CONFIG_NET_WIRELESS) += wireless
21887 subdir-$(CONFIG_TULIP) += tulip
21889 obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o
21890 obj-$(CONFIG_SUNGEM) += sungem.o
21892 +ifeq ($(CONFIG_HND),y)
21893 + obj-y += hnd/hnd.o
21895 +ifeq ($(CONFIG_ET),y)
21898 +ifeq ($(CONFIG_WL),y)
21902 obj-$(CONFIG_MACE) += mace.o
21903 obj-$(CONFIG_BMAC) += bmac.o
21904 obj-$(CONFIG_GMAC) += gmac.o
21905 @@ -265,6 +280,7 @@
21910 include $(TOPDIR)/Rules.make
21913 diff -Nur linux-2.4.32/drivers/net/wireless/Config.in linux-2.4.32-brcm/drivers/net/wireless/Config.in
21914 --- linux-2.4.32/drivers/net/wireless/Config.in 2004-11-17 12:54:21.000000000 +0100
21915 +++ linux-2.4.32-brcm/drivers/net/wireless/Config.in 2005-12-16 23:39:11.364863000 +0100
21919 if [ "$CONFIG_PCI" = "y" ]; then
21920 + dep_tristate ' Proprietary Broadcom BCM43xx 802.11 Wireless support' CONFIG_WL
21921 dep_tristate ' Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.) (EXPERIMENTAL)' CONFIG_PLX_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
21922 dep_tristate ' Hermes in TMD7160/NCP130 based PCI adaptor support (Pheecom WL-PCI etc.) (EXPERIMENTAL)' CONFIG_TMD_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
21923 dep_tristate ' Prism 2.5 PCI 802.11b adaptor support (EXPERIMENTAL)' CONFIG_PCI_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
21924 diff -Nur linux-2.4.32/drivers/net/wl/Makefile linux-2.4.32-brcm/drivers/net/wl/Makefile
21925 --- linux-2.4.32/drivers/net/wl/Makefile 1970-01-01 01:00:00.000000000 +0100
21926 +++ linux-2.4.32-brcm/drivers/net/wl/Makefile 2005-12-16 23:39:11.364863000 +0100
21929 +# Makefile for the Broadcom wl driver
21931 +# Copyright 2004, Broadcom Corporation
21932 +# All Rights Reserved.
21934 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
21935 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
21936 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
21937 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
21939 +# $Id: Makefile,v 1.2 2005/03/29 03:32:18 mbm Exp $
21941 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include
21945 +obj-y := apsta_aeskeywrap.o apsta_aes.o apsta_bcmwpa.o apsta_d11ucode.o
21946 +obj-y += apsta_hmac.o apsta_md5.o apsta_passhash.o apsta_prf.o apsta_rc4.o
21947 +obj-y += apsta_rijndael-alg-fst.o apsta_sha1.o apsta_tkhash.o apsta_wlc_led.o
21948 +obj-y += apsta_wlc_phy.o apsta_wlc_rate.o apsta_wlc_security.o
21949 +obj-y += apsta_wlc_sup.o apsta_wlc_wet.o apsta_wl_linux.o apsta_wlc.o
21951 +obj-m := $(O_TARGET)
21953 +include $(TOPDIR)/Rules.make
21954 diff -Nur linux-2.4.32/drivers/parport/Config.in linux-2.4.32-brcm/drivers/parport/Config.in
21955 --- linux-2.4.32/drivers/parport/Config.in 2004-02-18 14:36:31.000000000 +0100
21956 +++ linux-2.4.32-brcm/drivers/parport/Config.in 2005-12-16 23:39:11.364863000 +0100
21958 tristate 'Parallel port support' CONFIG_PARPORT
21959 if [ "$CONFIG_PARPORT" != "n" ]; then
21960 dep_tristate ' PC-style hardware' CONFIG_PARPORT_PC $CONFIG_PARPORT
21961 + dep_tristate ' Asus WL500g parallel port' CONFIG_PARPORT_SPLINK $CONFIG_PARPORT
21962 if [ "$CONFIG_PARPORT_PC" != "n" -a "$CONFIG_SERIAL" != "n" ]; then
21963 if [ "$CONFIG_SERIAL" = "m" ]; then
21964 define_tristate CONFIG_PARPORT_PC_CML1 m
21965 diff -Nur linux-2.4.32/drivers/parport/Makefile linux-2.4.32-brcm/drivers/parport/Makefile
21966 --- linux-2.4.32/drivers/parport/Makefile 2004-08-08 01:26:05.000000000 +0200
21967 +++ linux-2.4.32-brcm/drivers/parport/Makefile 2005-12-16 23:39:11.364863000 +0100
21970 obj-$(CONFIG_PARPORT) += parport.o
21971 obj-$(CONFIG_PARPORT_PC) += parport_pc.o
21972 +obj-$(CONFIG_PARPORT_SPLINK) += parport_splink.o
21973 obj-$(CONFIG_PARPORT_PC_PCMCIA) += parport_cs.o
21974 obj-$(CONFIG_PARPORT_AMIGA) += parport_amiga.o
21975 obj-$(CONFIG_PARPORT_MFC3) += parport_mfc3.o
21976 diff -Nur linux-2.4.32/drivers/parport/parport_splink.c linux-2.4.32-brcm/drivers/parport/parport_splink.c
21977 --- linux-2.4.32/drivers/parport/parport_splink.c 1970-01-01 01:00:00.000000000 +0100
21978 +++ linux-2.4.32-brcm/drivers/parport/parport_splink.c 2005-12-16 23:39:11.364863000 +0100
21980 +/* Low-level parallel port routines for the ASUS WL-500g built-in port
21982 + * Author: Nuno Grilo <nuno.grilo@netcabo.pt>
21983 + * Based on parport_pc source
21986 +#include <linux/config.h>
21987 +#include <linux/module.h>
21988 +#include <linux/init.h>
21989 +#include <linux/ioport.h>
21990 +#include <linux/kernel.h>
21991 +#include <linux/slab.h>
21992 +#include <linux/parport.h>
21993 +#include <linux/parport_pc.h>
21995 +#define SPLINK_ADDRESS 0xBF800010
22000 +#define DPRINTK printk
22002 +#define DPRINTK(stuff...)
22006 +/* __parport_splink_frob_control differs from parport_splink_frob_control in that
22007 + * it doesn't do any extra masking. */
22008 +static __inline__ unsigned char __parport_splink_frob_control (struct parport *p,
22009 + unsigned char mask,
22010 + unsigned char val)
22012 + struct parport_pc_private *priv = p->physport->private_data;
22013 + unsigned char *io = (unsigned char *) p->base;
22014 + unsigned char ctr = priv->ctr;
22015 +#ifdef DEBUG_PARPORT
22016 + printk (KERN_DEBUG
22017 + "__parport_splink_frob_control(%02x,%02x): %02x -> %02x\n",
22018 + mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
22020 + ctr = (ctr & ~mask) ^ val;
22021 + ctr &= priv->ctr_writable; /* only write writable bits. */
22023 + priv->ctr = ctr; /* Update soft copy */
22029 +static void parport_splink_data_forward (struct parport *p)
22031 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
22032 + __parport_splink_frob_control (p, 0x20, 0);
22035 +static void parport_splink_data_reverse (struct parport *p)
22037 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
22038 + __parport_splink_frob_control (p, 0x20, 0x20);
22042 +static void parport_splink_interrupt(int irq, void *dev_id, struct pt_regs *regs)
22044 + DPRINTK(KERN_DEBUG "parport_splink: IRQ handler called\n");
22045 + parport_generic_irq(irq, (struct parport *) dev_id, regs);
22049 +static void parport_splink_enable_irq(struct parport *p)
22051 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_enable_irq called\n");
22052 + __parport_splink_frob_control (p, 0x10, 0x10);
22055 +static void parport_splink_disable_irq(struct parport *p)
22057 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_disable_irq called\n");
22058 + __parport_splink_frob_control (p, 0x10, 0);
22061 +static void parport_splink_init_state(struct pardevice *dev, struct parport_state *s)
22063 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_init_state called\n");
22064 + s->u.pc.ctr = 0xc | (dev->irq_func ? 0x10 : 0x0);
22065 + if (dev->irq_func &&
22066 + dev->port->irq != PARPORT_IRQ_NONE)
22067 + /* Set ackIntEn */
22068 + s->u.pc.ctr |= 0x10;
22071 +static void parport_splink_save_state(struct parport *p, struct parport_state *s)
22073 + const struct parport_pc_private *priv = p->physport->private_data;
22074 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_save_state called\n");
22075 + s->u.pc.ctr = priv->ctr;
22078 +static void parport_splink_restore_state(struct parport *p, struct parport_state *s)
22080 + struct parport_pc_private *priv = p->physport->private_data;
22081 + unsigned char *io = (unsigned char *) p->base;
22082 + unsigned char ctr = s->u.pc.ctr;
22084 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_restore_state called\n");
22089 +static void parport_splink_setup_interrupt(void) {
22093 +static void parport_splink_write_data(struct parport *p, unsigned char d) {
22094 + DPRINTK(KERN_DEBUG "parport_splink: write data called\n");
22095 + unsigned char *io = (unsigned char *) p->base;
22099 +static unsigned char parport_splink_read_data(struct parport *p) {
22100 + DPRINTK(KERN_DEBUG "parport_splink: read data called\n");
22101 + unsigned char *io = (unsigned char *) p->base;
22105 +static void parport_splink_write_control(struct parport *p, unsigned char d)
22107 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
22108 + PARPORT_CONTROL_AUTOFD |
22109 + PARPORT_CONTROL_INIT |
22110 + PARPORT_CONTROL_SELECT);
22112 + DPRINTK(KERN_DEBUG "parport_splink: write control called\n");
22113 + /* Take this out when drivers have adapted to the newer interface. */
22115 + printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
22116 + p->name, p->cad->name);
22117 + parport_splink_data_reverse (p);
22120 + __parport_splink_frob_control (p, wm, d & wm);
22123 +static unsigned char parport_splink_read_control(struct parport *p)
22125 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
22126 + PARPORT_CONTROL_AUTOFD |
22127 + PARPORT_CONTROL_INIT |
22128 + PARPORT_CONTROL_SELECT);
22129 + DPRINTK(KERN_DEBUG "parport_splink: read control called\n");
22130 + const struct parport_pc_private *priv = p->physport->private_data;
22131 + return priv->ctr & wm; /* Use soft copy */
22134 +static unsigned char parport_splink_frob_control (struct parport *p, unsigned char mask,
22135 + unsigned char val)
22137 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
22138 + PARPORT_CONTROL_AUTOFD |
22139 + PARPORT_CONTROL_INIT |
22140 + PARPORT_CONTROL_SELECT);
22142 + DPRINTK(KERN_DEBUG "parport_splink: frob control called\n");
22143 + /* Take this out when drivers have adapted to the newer interface. */
22144 + if (mask & 0x20) {
22145 + printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
22146 + p->name, p->cad->name,
22147 + (val & 0x20) ? "reverse" : "forward");
22149 + parport_splink_data_reverse (p);
22151 + parport_splink_data_forward (p);
22154 + /* Restrict mask and val to control lines. */
22158 + return __parport_splink_frob_control (p, mask, val);
22161 +static unsigned char parport_splink_read_status(struct parport *p)
22163 + DPRINTK(KERN_DEBUG "parport_splink: read status called\n");
22164 + unsigned char *io = (unsigned char *) p->base;
22168 +static void parport_splink_inc_use_count(void)
22171 + MOD_INC_USE_COUNT;
22175 +static void parport_splink_dec_use_count(void)
22178 + MOD_DEC_USE_COUNT;
22182 +static struct parport_operations parport_splink_ops =
22184 + parport_splink_write_data,
22185 + parport_splink_read_data,
22187 + parport_splink_write_control,
22188 + parport_splink_read_control,
22189 + parport_splink_frob_control,
22191 + parport_splink_read_status,
22193 + parport_splink_enable_irq,
22194 + parport_splink_disable_irq,
22196 + parport_splink_data_forward,
22197 + parport_splink_data_reverse,
22199 + parport_splink_init_state,
22200 + parport_splink_save_state,
22201 + parport_splink_restore_state,
22203 + parport_splink_inc_use_count,
22204 + parport_splink_dec_use_count,
22206 + parport_ieee1284_epp_write_data,
22207 + parport_ieee1284_epp_read_data,
22208 + parport_ieee1284_epp_write_addr,
22209 + parport_ieee1284_epp_read_addr,
22211 + parport_ieee1284_ecp_write_data,
22212 + parport_ieee1284_ecp_read_data,
22213 + parport_ieee1284_ecp_write_addr,
22215 + parport_ieee1284_write_compat,
22216 + parport_ieee1284_read_nibble,
22217 + parport_ieee1284_read_byte,
22220 +/* --- Initialisation code -------------------------------- */
22222 +static struct parport *parport_splink_probe_port (unsigned long int base)
22224 + struct parport_pc_private *priv;
22225 + struct parport_operations *ops;
22226 + struct parport *p;
22228 + if (check_mem_region(base, 3)) {
22229 + printk (KERN_DEBUG "parport (0x%lx): iomem region not available\n", base);
22232 + priv = kmalloc (sizeof (struct parport_pc_private), GFP_KERNEL);
22234 + printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base);
22237 + ops = kmalloc (sizeof (struct parport_operations), GFP_KERNEL);
22239 + printk (KERN_DEBUG "parport (0x%lx): no memory for ops!\n",
22244 + memcpy (ops, &parport_splink_ops, sizeof (struct parport_operations));
22246 + priv->ctr_writable = 0xff;
22248 + if (!(p = parport_register_port(base, PARPORT_IRQ_NONE,
22249 + PARPORT_DMA_NONE, ops))) {
22250 + printk (KERN_DEBUG "parport (0x%lx): registration failed!\n",
22257 + p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;
22258 + p->size = (p->modes & PARPORT_MODE_EPP)?8:3;
22259 + p->private_data = priv;
22261 + parport_proc_register(p);
22262 + request_mem_region (p->base, 3, p->name);
22264 + /* Done probing. Now put the port into a sensible start-up state. */
22265 + parport_splink_write_data(p, 0);
22266 + parport_splink_data_forward (p);
22268 + /* Now that we've told the sharing engine about the port, and
22269 + found out its characteristics, let the high-level drivers
22270 + know about it. */
22271 + parport_announce_port (p);
22273 + DPRINTK(KERN_DEBUG "parport (0x%lx): init ok!\n",
22278 +static void parport_splink_unregister_port(struct parport *p) {
22279 + struct parport_pc_private *priv = p->private_data;
22280 + struct parport_operations *ops = p->ops;
22282 + if (p->irq != PARPORT_IRQ_NONE)
22283 + free_irq(p->irq, p);
22284 + release_mem_region(p->base, 3);
22285 + parport_proc_unregister(p);
22287 + parport_unregister_port(p);
22292 +int parport_splink_init(void)
22296 + DPRINTK(KERN_DEBUG "parport_splink init called\n");
22297 + parport_splink_setup_interrupt();
22298 + ret = !parport_splink_probe_port(SPLINK_ADDRESS);
22303 +void parport_splink_cleanup(void) {
22304 + struct parport *p = parport_enumerate(), *tmp;
22305 + DPRINTK(KERN_DEBUG "parport_splink cleanup called\n");
22307 + if (p->modes & PARPORT_MODE_PCSPP) {
22310 + parport_splink_unregister_port(p);
22317 +MODULE_AUTHOR("Nuno Grilo <nuno.grilo@netcabo.pt>");
22318 +MODULE_DESCRIPTION("Parport Driver for ASUS WL-500g router builtin Port");
22319 +MODULE_SUPPORTED_DEVICE("ASUS WL-500g builtin Parallel Port");
22320 +MODULE_LICENSE("GPL");
22322 +module_init(parport_splink_init)
22323 +module_exit(parport_splink_cleanup)
22325 diff -Nur linux-2.4.32/drivers/pcmcia/bcm4710_generic.c linux-2.4.32-brcm/drivers/pcmcia/bcm4710_generic.c
22326 --- linux-2.4.32/drivers/pcmcia/bcm4710_generic.c 1970-01-01 01:00:00.000000000 +0100
22327 +++ linux-2.4.32-brcm/drivers/pcmcia/bcm4710_generic.c 2005-12-16 23:39:11.368863250 +0100
22331 + * bcm47xx pcmcia driver
22333 + * Copyright 2004, Broadcom Corporation
22334 + * All Rights Reserved.
22336 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
22337 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
22338 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
22339 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
22341 + * Based on sa1100_generic.c from www.handhelds.org,
22342 + * and au1000_generic.c from oss.sgi.com.
22344 + * $Id: bcm4710_generic.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
22346 +#include <linux/module.h>
22347 +#include <linux/init.h>
22348 +#include <linux/config.h>
22349 +#include <linux/delay.h>
22350 +#include <linux/ioport.h>
22351 +#include <linux/kernel.h>
22352 +#include <linux/tqueue.h>
22353 +#include <linux/timer.h>
22354 +#include <linux/mm.h>
22355 +#include <linux/proc_fs.h>
22356 +#include <linux/version.h>
22357 +#include <linux/types.h>
22358 +#include <linux/vmalloc.h>
22360 +#include <pcmcia/version.h>
22361 +#include <pcmcia/cs_types.h>
22362 +#include <pcmcia/cs.h>
22363 +#include <pcmcia/ss.h>
22364 +#include <pcmcia/bulkmem.h>
22365 +#include <pcmcia/cistpl.h>
22366 +#include <pcmcia/bus_ops.h>
22367 +#include "cs_internal.h"
22369 +#include <asm/io.h>
22370 +#include <asm/irq.h>
22371 +#include <asm/system.h>
22373 +#include <typedefs.h>
22374 +#include <bcm4710.h>
22375 +#include <sbextif.h>
22377 +#include "bcm4710pcmcia.h"
22379 +#ifdef PCMCIA_DEBUG
22380 +static int pc_debug = PCMCIA_DEBUG;
22383 +MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm47xx Socket Controller");
22385 +/* This structure maintains housekeeping state for each socket, such
22386 + * as the last known values of the card detect pins, or the Card Services
22387 + * callback value associated with the socket:
22389 +static struct bcm47xx_pcmcia_socket *pcmcia_socket;
22390 +static int socket_count;
22393 +/* Returned by the low-level PCMCIA interface: */
22394 +static struct pcmcia_low_level *pcmcia_low_level;
22396 +/* Event poll timer structure */
22397 +static struct timer_list poll_timer;
22400 +/* Prototypes for routines which are used internally: */
22402 +static int bcm47xx_pcmcia_driver_init(void);
22403 +static void bcm47xx_pcmcia_driver_shutdown(void);
22404 +static void bcm47xx_pcmcia_task_handler(void *data);
22405 +static void bcm47xx_pcmcia_poll_event(unsigned long data);
22406 +static void bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs);
22407 +static struct tq_struct bcm47xx_pcmcia_task;
22409 +#ifdef CONFIG_PROC_FS
22410 +static int bcm47xx_pcmcia_proc_status(char *buf, char **start,
22411 + off_t pos, int count, int *eof, void *data);
22415 +/* Prototypes for operations which are exported to the
22416 + * in-kernel PCMCIA core:
22419 +static int bcm47xx_pcmcia_init(unsigned int sock);
22420 +static int bcm47xx_pcmcia_suspend(unsigned int sock);
22421 +static int bcm47xx_pcmcia_register_callback(unsigned int sock,
22422 + void (*handler)(void *, unsigned int), void *info);
22423 +static int bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap);
22424 +static int bcm47xx_pcmcia_get_status(unsigned int sock, u_int *value);
22425 +static int bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state);
22426 +static int bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state);
22427 +static int bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *io);
22428 +static int bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *io);
22429 +static int bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *mem);
22430 +static int bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *mem);
22431 +#ifdef CONFIG_PROC_FS
22432 +static void bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base);
22435 +static struct pccard_operations bcm47xx_pcmcia_operations = {
22436 + bcm47xx_pcmcia_init,
22437 + bcm47xx_pcmcia_suspend,
22438 + bcm47xx_pcmcia_register_callback,
22439 + bcm47xx_pcmcia_inquire_socket,
22440 + bcm47xx_pcmcia_get_status,
22441 + bcm47xx_pcmcia_get_socket,
22442 + bcm47xx_pcmcia_set_socket,
22443 + bcm47xx_pcmcia_get_io_map,
22444 + bcm47xx_pcmcia_set_io_map,
22445 + bcm47xx_pcmcia_get_mem_map,
22446 + bcm47xx_pcmcia_set_mem_map,
22447 +#ifdef CONFIG_PROC_FS
22448 + bcm47xx_pcmcia_proc_setup
22454 + * bcm47xx_pcmcia_driver_init()
22456 + * This routine performs a basic sanity check to ensure that this
22457 + * kernel has been built with the appropriate board-specific low-level
22458 + * PCMCIA support, performs low-level PCMCIA initialization, registers
22459 + * this socket driver with Card Services, and then spawns the daemon
22460 + * thread which is the real workhorse of the socket driver.
22462 + * Please see linux/Documentation/arm/SA1100/PCMCIA for more information
22463 + * on the low-level kernel interface.
22465 + * Returns: 0 on success, -1 on error
22467 +static int __init bcm47xx_pcmcia_driver_init(void)
22470 + struct pcmcia_init pcmcia_init;
22471 + struct pcmcia_state state;
22473 + unsigned long tmp;
22476 + printk("\nBCM47XX PCMCIA (CS release %s)\n", CS_RELEASE);
22478 + CardServices(GetCardServicesInfo, &info);
22480 + if (info.Revision != CS_RELEASE_CODE) {
22481 + printk(KERN_ERR "Card Services release codes do not match\n");
22485 +#ifdef CONFIG_BCM4710
22486 + pcmcia_low_level=&bcm4710_pcmcia_ops;
22488 +#error Unsupported Broadcom BCM47XX board.
22491 + pcmcia_init.handler=bcm47xx_pcmcia_interrupt;
22493 + if ((socket_count = pcmcia_low_level->init(&pcmcia_init)) < 0) {
22494 + printk(KERN_ERR "Unable to initialize PCMCIA service.\n");
22497 + printk("\t%d PCMCIA sockets initialized.\n", socket_count);
22501 + kmalloc(sizeof(struct bcm47xx_pcmcia_socket) * socket_count,
22503 + memset(pcmcia_socket, 0,
22504 + sizeof(struct bcm47xx_pcmcia_socket) * socket_count);
22505 + if (!pcmcia_socket) {
22506 + printk(KERN_ERR "Card Services can't get memory \n");
22510 + for (i = 0; i < socket_count; i++) {
22511 + if (pcmcia_low_level->socket_state(i, &state) < 0) {
22512 + printk(KERN_ERR "Unable to get PCMCIA status\n");
22515 + pcmcia_socket[i].k_state = state;
22516 + pcmcia_socket[i].cs_state.csc_mask = SS_DETECT;
22519 + pcmcia_socket[i].virt_io =
22520 + (unsigned long)ioremap_nocache(EXTIF_PCMCIA_IOBASE(BCM4710_EXTIF), 0x1000);
22521 + /* Substract ioport base which gets added by in/out */
22522 + pcmcia_socket[i].virt_io -= mips_io_port_base;
22523 + pcmcia_socket[i].phys_attr =
22524 + (unsigned long)EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF);
22525 + pcmcia_socket[i].phys_mem =
22526 + (unsigned long)EXTIF_PCMCIA_MEMBASE(BCM4710_EXTIF);
22528 + printk(KERN_ERR "bcm4710: socket 1 not supported\n");
22533 + /* Only advertise as many sockets as we can detect: */
22534 + if (register_ss_entry(socket_count, &bcm47xx_pcmcia_operations) < 0) {
22535 + printk(KERN_ERR "Unable to register socket service routine\n");
22539 + /* Start the event poll timer.
22540 + * It will reschedule by itself afterwards.
22542 + bcm47xx_pcmcia_poll_event(0);
22544 + DEBUG(1, "bcm4710: initialization complete\n");
22549 +module_init(bcm47xx_pcmcia_driver_init);
22553 + * bcm47xx_pcmcia_driver_shutdown()
22555 + * Invokes the low-level kernel service to free IRQs associated with this
22556 + * socket controller and reset GPIO edge detection.
22558 +static void __exit bcm47xx_pcmcia_driver_shutdown(void)
22562 + del_timer_sync(&poll_timer);
22563 + unregister_ss_entry(&bcm47xx_pcmcia_operations);
22564 + pcmcia_low_level->shutdown();
22565 + flush_scheduled_tasks();
22566 + for (i = 0; i < socket_count; i++) {
22567 + if (pcmcia_socket[i].virt_io)
22568 + iounmap((void *)pcmcia_socket[i].virt_io);
22569 + if (pcmcia_socket[i].phys_attr)
22570 + iounmap((void *)pcmcia_socket[i].phys_attr);
22571 + if (pcmcia_socket[i].phys_mem)
22572 + iounmap((void *)pcmcia_socket[i].phys_mem);
22574 + DEBUG(1, "bcm4710: shutdown complete\n");
22577 +module_exit(bcm47xx_pcmcia_driver_shutdown);
22580 + * bcm47xx_pcmcia_init()
22581 + * We perform all of the interesting initialization tasks in
22582 + * bcm47xx_pcmcia_driver_init().
22586 +static int bcm47xx_pcmcia_init(unsigned int sock)
22588 + DEBUG(1, "%s(): initializing socket %u\n", __FUNCTION__, sock);
22594 + * bcm47xx_pcmcia_suspend()
22596 + * We don't currently perform any actions on a suspend.
22600 +static int bcm47xx_pcmcia_suspend(unsigned int sock)
22602 + DEBUG(1, "%s(): suspending socket %u\n", __FUNCTION__, sock);
22609 + * bcm47xx_pcmcia_events()
22611 + * Helper routine to generate a Card Services event mask based on
22612 + * state information obtained from the kernel low-level PCMCIA layer
22613 + * in a recent (and previous) sampling. Updates `prev_state'.
22615 + * Returns: an event mask for the given socket state.
22617 +static inline unsigned
22618 +bcm47xx_pcmcia_events(struct pcmcia_state *state,
22619 + struct pcmcia_state *prev_state,
22620 + unsigned int mask, unsigned int flags)
22622 + unsigned int events=0;
22624 + if (state->bvd1 != prev_state->bvd1) {
22626 + DEBUG(3, "%s(): card BVD1 value %u\n", __FUNCTION__, state->bvd1);
22628 + events |= mask & (flags & SS_IOCARD) ? SS_STSCHG : SS_BATDEAD;
22631 + if (state->bvd2 != prev_state->bvd2) {
22633 + DEBUG(3, "%s(): card BVD2 value %u\n", __FUNCTION__, state->bvd2);
22635 + events |= mask & (flags & SS_IOCARD) ? 0 : SS_BATWARN;
22638 + if (state->detect != prev_state->detect) {
22640 + DEBUG(3, "%s(): card detect value %u\n", __FUNCTION__, state->detect);
22642 + events |= mask & SS_DETECT;
22646 + if (state->ready != prev_state->ready) {
22648 + DEBUG(3, "%s(): card ready value %u\n", __FUNCTION__, state->ready);
22650 + events |= mask & ((flags & SS_IOCARD) ? 0 : SS_READY);
22653 + if (events != 0) {
22654 + DEBUG(2, "events: %s%s%s%s%s\n",
22655 + (events & SS_DETECT) ? "DETECT " : "",
22656 + (events & SS_READY) ? "READY " : "",
22657 + (events & SS_BATDEAD) ? "BATDEAD " : "",
22658 + (events & SS_BATWARN) ? "BATWARN " : "",
22659 + (events & SS_STSCHG) ? "STSCHG " : "");
22662 + *prev_state=*state;
22668 + * bcm47xx_pcmcia_task_handler()
22670 + * Processes serviceable socket events using the "eventd" thread context.
22672 + * Event processing (specifically, the invocation of the Card Services event
22673 + * callback) occurs in this thread rather than in the actual interrupt
22674 + * handler due to the use of scheduling operations in the PCMCIA core.
22676 +static void bcm47xx_pcmcia_task_handler(void *data)
22678 + struct pcmcia_state state;
22679 + int i, events, irq_status;
22681 + DEBUG(4, "%s(): entering PCMCIA monitoring thread\n", __FUNCTION__);
22683 + for (i = 0; i < socket_count; i++) {
22684 + if ((irq_status = pcmcia_low_level->socket_state(i, &state)) < 0)
22685 + printk(KERN_ERR "Error in kernel low-level PCMCIA service.\n");
22687 + events = bcm47xx_pcmcia_events(&state,
22688 + &pcmcia_socket[i].k_state,
22689 + pcmcia_socket[i].cs_state.csc_mask,
22690 + pcmcia_socket[i].cs_state.flags);
22692 + if (pcmcia_socket[i].handler != NULL) {
22693 + pcmcia_socket[i].handler(pcmcia_socket[i].handler_info,
22699 +static struct tq_struct bcm47xx_pcmcia_task = {
22700 + routine: bcm47xx_pcmcia_task_handler
22705 + * bcm47xx_pcmcia_poll_event()
22707 + * Let's poll for events in addition to IRQs since IRQ only is unreliable...
22709 +static void bcm47xx_pcmcia_poll_event(unsigned long dummy)
22711 + DEBUG(4, "%s(): polling for events\n", __FUNCTION__);
22713 + poll_timer.function = bcm47xx_pcmcia_poll_event;
22714 + poll_timer.expires = jiffies + BCM47XX_PCMCIA_POLL_PERIOD;
22715 + add_timer(&poll_timer);
22716 + schedule_task(&bcm47xx_pcmcia_task);
22721 + * bcm47xx_pcmcia_interrupt()
22723 + * Service routine for socket driver interrupts (requested by the
22724 + * low-level PCMCIA init() operation via bcm47xx_pcmcia_thread()).
22726 + * The actual interrupt-servicing work is performed by
22727 + * bcm47xx_pcmcia_task(), largely because the Card Services event-
22728 + * handling code performs scheduling operations which cannot be
22729 + * executed from within an interrupt context.
22732 +bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs)
22734 + DEBUG(3, "%s(): servicing IRQ %d\n", __FUNCTION__, irq);
22735 + schedule_task(&bcm47xx_pcmcia_task);
22740 + * bcm47xx_pcmcia_register_callback()
22742 + * Implements the register_callback() operation for the in-kernel
22743 + * PCMCIA service (formerly SS_RegisterCallback in Card Services). If
22744 + * the function pointer `handler' is not NULL, remember the callback
22745 + * location in the state for `sock', and increment the usage counter
22746 + * for the driver module. (The callback is invoked from the interrupt
22747 + * service routine, bcm47xx_pcmcia_interrupt(), to notify Card Services
22748 + * of interesting events.) Otherwise, clear the callback pointer in the
22749 + * socket state and decrement the module usage count.
22754 +bcm47xx_pcmcia_register_callback(unsigned int sock,
22755 + void (*handler)(void *, unsigned int), void *info)
22757 + if (handler == NULL) {
22758 + pcmcia_socket[sock].handler = NULL;
22759 + MOD_DEC_USE_COUNT;
22761 + MOD_INC_USE_COUNT;
22762 + pcmcia_socket[sock].handler = handler;
22763 + pcmcia_socket[sock].handler_info = info;
22770 + * bcm47xx_pcmcia_inquire_socket()
22772 + * Implements the inquire_socket() operation for the in-kernel PCMCIA
22773 + * service (formerly SS_InquireSocket in Card Services). Of note is
22774 + * the setting of the SS_CAP_PAGE_REGS bit in the `features' field of
22775 + * `cap' to "trick" Card Services into tolerating large "I/O memory"
22776 + * addresses. Also set is SS_CAP_STATIC_MAP, which disables the memory
22777 + * resource database check. (Mapped memory is set up within the socket
22778 + * driver itself.)
22780 + * In conjunction with the STATIC_MAP capability is a new field,
22781 + * `io_offset', recommended by David Hinds. Rather than go through
22782 + * the SetIOMap interface (which is not quite suited for communicating
22783 + * window locations up from the socket driver), we just pass up
22784 + * an offset which is applied to client-requested base I/O addresses
22785 + * in alloc_io_space().
22787 + * Returns: 0 on success, -1 if no pin has been configured for `sock'
22790 +bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap)
22792 + struct pcmcia_irq_info irq_info;
22794 + if (sock >= socket_count) {
22795 + printk(KERN_ERR "bcm47xx: socket %u not configured\n", sock);
22799 + /* SS_CAP_PAGE_REGS: used by setup_cis_mem() in cistpl.c to set the
22800 + * force_low argument to validate_mem() in rsrc_mgr.c -- since in
22801 + * general, the mapped * addresses of the PCMCIA memory regions
22802 + * will not be within 0xffff, setting force_low would be
22805 + * SS_CAP_STATIC_MAP: don't bother with the (user-configured) memory
22806 + * resource database; we instead pass up physical address ranges
22807 + * and allow other parts of Card Services to deal with remapping.
22809 + * SS_CAP_PCCARD: we can deal with 16-bit PCMCIA & CF cards, but
22810 + * not 32-bit CardBus devices.
22812 + cap->features = (SS_CAP_PAGE_REGS | SS_CAP_STATIC_MAP | SS_CAP_PCCARD);
22814 + irq_info.sock = sock;
22815 + irq_info.irq = -1;
22817 + if (pcmcia_low_level->get_irq_info(&irq_info) < 0) {
22818 + printk(KERN_ERR "Error obtaining IRQ info socket %u\n", sock);
22822 + cap->irq_mask = 0;
22823 + cap->map_size = PAGE_SIZE;
22824 + cap->pci_irq = irq_info.irq;
22825 + cap->io_offset = pcmcia_socket[sock].virt_io;
22832 + * bcm47xx_pcmcia_get_status()
22834 + * Implements the get_status() operation for the in-kernel PCMCIA
22835 + * service (formerly SS_GetStatus in Card Services). Essentially just
22836 + * fills in bits in `status' according to internal driver state or
22837 + * the value of the voltage detect chipselect register.
22839 + * As a debugging note, during card startup, the PCMCIA core issues
22840 + * three set_socket() commands in a row the first with RESET deasserted,
22841 + * the second with RESET asserted, and the last with RESET deasserted
22842 + * again. Following the third set_socket(), a get_status() command will
22843 + * be issued. The kernel is looking for the SS_READY flag (see
22844 + * setup_socket(), reset_socket(), and unreset_socket() in cs.c).
22849 +bcm47xx_pcmcia_get_status(unsigned int sock, unsigned int *status)
22851 + struct pcmcia_state state;
22854 + if ((pcmcia_low_level->socket_state(sock, &state)) < 0) {
22855 + printk(KERN_ERR "Unable to get PCMCIA status from kernel.\n");
22859 + pcmcia_socket[sock].k_state = state;
22861 + *status = state.detect ? SS_DETECT : 0;
22863 + *status |= state.ready ? SS_READY : 0;
22865 + /* The power status of individual sockets is not available
22866 + * explicitly from the hardware, so we just remember the state
22867 + * and regurgitate it upon request:
22869 + *status |= pcmcia_socket[sock].cs_state.Vcc ? SS_POWERON : 0;
22871 + if (pcmcia_socket[sock].cs_state.flags & SS_IOCARD)
22872 + *status |= state.bvd1 ? SS_STSCHG : 0;
22874 + if (state.bvd1 == 0)
22875 + *status |= SS_BATDEAD;
22876 + else if (state.bvd2 == 0)
22877 + *status |= SS_BATWARN;
22880 + *status |= state.vs_3v ? SS_3VCARD : 0;
22882 + *status |= state.vs_Xv ? SS_XVCARD : 0;
22884 + DEBUG(2, "\tstatus: %s%s%s%s%s%s%s%s\n",
22885 + (*status&SS_DETECT)?"DETECT ":"",
22886 + (*status&SS_READY)?"READY ":"",
22887 + (*status&SS_BATDEAD)?"BATDEAD ":"",
22888 + (*status&SS_BATWARN)?"BATWARN ":"",
22889 + (*status&SS_POWERON)?"POWERON ":"",
22890 + (*status&SS_STSCHG)?"STSCHG ":"",
22891 + (*status&SS_3VCARD)?"3VCARD ":"",
22892 + (*status&SS_XVCARD)?"XVCARD ":"");
22899 + * bcm47xx_pcmcia_get_socket()
22901 + * Implements the get_socket() operation for the in-kernel PCMCIA
22902 + * service (formerly SS_GetSocket in Card Services). Not a very
22903 + * exciting routine.
22908 +bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state)
22910 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
22912 + /* This information was given to us in an earlier call to set_socket(),
22913 + * so we're just regurgitating it here:
22915 + *state = pcmcia_socket[sock].cs_state;
22921 + * bcm47xx_pcmcia_set_socket()
22923 + * Implements the set_socket() operation for the in-kernel PCMCIA
22924 + * service (formerly SS_SetSocket in Card Services). We more or
22925 + * less punt all of this work and let the kernel handle the details
22926 + * of power configuration, reset, &c. We also record the value of
22927 + * `state' in order to regurgitate it to the PCMCIA core later.
22932 +bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state)
22934 + struct pcmcia_configure configure;
22936 + DEBUG(2, "\tmask: %s%s%s%s%s%s\n\tflags: %s%s%s%s%s%s\n"
22937 + "\tVcc %d Vpp %d irq %d\n",
22938 + (state->csc_mask == 0) ? "<NONE>" : "",
22939 + (state->csc_mask & SS_DETECT) ? "DETECT " : "",
22940 + (state->csc_mask & SS_READY) ? "READY " : "",
22941 + (state->csc_mask & SS_BATDEAD) ? "BATDEAD " : "",
22942 + (state->csc_mask & SS_BATWARN) ? "BATWARN " : "",
22943 + (state->csc_mask & SS_STSCHG) ? "STSCHG " : "",
22944 + (state->flags == 0) ? "<NONE>" : "",
22945 + (state->flags & SS_PWR_AUTO) ? "PWR_AUTO " : "",
22946 + (state->flags & SS_IOCARD) ? "IOCARD " : "",
22947 + (state->flags & SS_RESET) ? "RESET " : "",
22948 + (state->flags & SS_SPKR_ENA) ? "SPKR_ENA " : "",
22949 + (state->flags & SS_OUTPUT_ENA) ? "OUTPUT_ENA " : "",
22950 + state->Vcc, state->Vpp, state->io_irq);
22952 + configure.sock = sock;
22953 + configure.vcc = state->Vcc;
22954 + configure.vpp = state->Vpp;
22955 + configure.output = (state->flags & SS_OUTPUT_ENA) ? 1 : 0;
22956 + configure.speaker = (state->flags & SS_SPKR_ENA) ? 1 : 0;
22957 + configure.reset = (state->flags & SS_RESET) ? 1 : 0;
22959 + if (pcmcia_low_level->configure_socket(&configure) < 0) {
22960 + printk(KERN_ERR "Unable to configure socket %u\n", sock);
22964 + pcmcia_socket[sock].cs_state = *state;
22970 + * bcm47xx_pcmcia_get_io_map()
22972 + * Implements the get_io_map() operation for the in-kernel PCMCIA
22973 + * service (formerly SS_GetIOMap in Card Services). Just returns an
22974 + * I/O map descriptor which was assigned earlier by a set_io_map().
22976 + * Returns: 0 on success, -1 if the map index was out of range
22979 +bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *map)
22981 + DEBUG(2, "bcm47xx_pcmcia_get_io_map: sock %d\n", sock);
22983 + if (map->map >= MAX_IO_WIN) {
22984 + printk(KERN_ERR "%s(): map (%d) out of range\n",
22985 + __FUNCTION__, map->map);
22989 + *map = pcmcia_socket[sock].io_map[map->map];
22995 + * bcm47xx_pcmcia_set_io_map()
22997 + * Implements the set_io_map() operation for the in-kernel PCMCIA
22998 + * service (formerly SS_SetIOMap in Card Services). We configure
22999 + * the map speed as requested, but override the address ranges
23000 + * supplied by Card Services.
23002 + * Returns: 0 on success, -1 on error
23005 +bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *map)
23007 + unsigned int speed;
23008 + unsigned long start;
23010 + DEBUG(2, "\tmap %u speed %u\n\tstart 0x%08lx stop 0x%08lx\n"
23011 + "\tflags: %s%s%s%s%s%s%s%s\n",
23012 + map->map, map->speed, map->start, map->stop,
23013 + (map->flags == 0) ? "<NONE>" : "",
23014 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
23015 + (map->flags & MAP_16BIT) ? "16BIT " : "",
23016 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
23017 + (map->flags & MAP_0WS) ? "0WS " : "",
23018 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
23019 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "",
23020 + (map->flags & MAP_PREFETCH) ? "PREFETCH " : "");
23022 + if (map->map >= MAX_IO_WIN) {
23023 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23024 + __FUNCTION__, map->map);
23028 + if (map->flags & MAP_ACTIVE) {
23029 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_IO_SPEED;
23030 + pcmcia_socket[sock].speed_io = speed;
23033 + start = map->start;
23035 + if (map->stop == 1) {
23036 + map->stop = PAGE_SIZE - 1;
23039 + map->start = pcmcia_socket[sock].virt_io;
23040 + map->stop = map->start + (map->stop - start);
23041 + pcmcia_socket[sock].io_map[map->map] = *map;
23042 + DEBUG(2, "set_io_map %d start %x stop %x\n",
23043 + map->map, map->start, map->stop);
23049 + * bcm47xx_pcmcia_get_mem_map()
23051 + * Implements the get_mem_map() operation for the in-kernel PCMCIA
23052 + * service (formerly SS_GetMemMap in Card Services). Just returns a
23053 + * memory map descriptor which was assigned earlier by a
23054 + * set_mem_map() request.
23056 + * Returns: 0 on success, -1 if the map index was out of range
23059 +bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *map)
23061 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
23063 + if (map->map >= MAX_WIN) {
23064 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23065 + __FUNCTION__, map->map);
23069 + *map = pcmcia_socket[sock].mem_map[map->map];
23075 + * bcm47xx_pcmcia_set_mem_map()
23077 + * Implements the set_mem_map() operation for the in-kernel PCMCIA
23078 + * service (formerly SS_SetMemMap in Card Services). We configure
23079 + * the map speed as requested, but override the address ranges
23080 + * supplied by Card Services.
23082 + * Returns: 0 on success, -1 on error
23085 +bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *map)
23087 + unsigned int speed;
23088 + unsigned long start;
23091 + if (map->map >= MAX_WIN) {
23092 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23093 + __FUNCTION__, map->map);
23097 + DEBUG(2, "\tmap %u speed %u\n\tsys_start %#lx\n"
23098 + "\tsys_stop %#lx\n\tcard_start %#x\n"
23099 + "\tflags: %s%s%s%s%s%s%s%s\n",
23100 + map->map, map->speed, map->sys_start, map->sys_stop,
23101 + map->card_start, (map->flags == 0) ? "<NONE>" : "",
23102 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
23103 + (map->flags & MAP_16BIT) ? "16BIT " : "",
23104 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
23105 + (map->flags & MAP_0WS) ? "0WS " : "",
23106 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
23107 + (map->flags & MAP_ATTRIB) ? "ATTRIB " : "",
23108 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "");
23110 + if (map->flags & MAP_ACTIVE) {
23111 + /* When clients issue RequestMap, the access speed is not always
23112 + * properly configured:
23114 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_MEM_SPEED;
23117 + if (map->flags & MAP_ATTRIB) {
23118 + pcmcia_socket[sock].speed_attr = speed;
23120 + pcmcia_socket[sock].speed_mem = speed;
23124 + save_flags(flags);
23126 + start = map->sys_start;
23128 + if (map->sys_stop == 0)
23129 + map->sys_stop = PAGE_SIZE - 1;
23131 + if (map->flags & MAP_ATTRIB) {
23132 + map->sys_start = pcmcia_socket[sock].phys_attr +
23135 + map->sys_start = pcmcia_socket[sock].phys_mem +
23139 + map->sys_stop = map->sys_start + (map->sys_stop - start);
23140 + pcmcia_socket[sock].mem_map[map->map] = *map;
23141 + restore_flags(flags);
23142 + DEBUG(2, "set_mem_map %d start %x stop %x card_start %x\n",
23143 + map->map, map->sys_start, map->sys_stop,
23144 + map->card_start);
23149 +#if defined(CONFIG_PROC_FS)
23152 + * bcm47xx_pcmcia_proc_setup()
23154 + * Implements the proc_setup() operation for the in-kernel PCMCIA
23155 + * service (formerly SS_ProcSetup in Card Services).
23157 + * Returns: 0 on success, -1 on error
23160 +bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base)
23162 + struct proc_dir_entry *entry;
23164 + if ((entry = create_proc_entry("status", 0, base)) == NULL) {
23165 + printk(KERN_ERR "Unable to install \"status\" procfs entry\n");
23169 + entry->read_proc = bcm47xx_pcmcia_proc_status;
23170 + entry->data = (void *)sock;
23175 + * bcm47xx_pcmcia_proc_status()
23177 + * Implements the /proc/bus/pccard/??/status file.
23179 + * Returns: the number of characters added to the buffer
23182 +bcm47xx_pcmcia_proc_status(char *buf, char **start, off_t pos,
23183 + int count, int *eof, void *data)
23186 + unsigned int sock = (unsigned int)data;
23188 + p += sprintf(p, "k_flags : %s%s%s%s%s%s%s\n",
23189 + pcmcia_socket[sock].k_state.detect ? "detect " : "",
23190 + pcmcia_socket[sock].k_state.ready ? "ready " : "",
23191 + pcmcia_socket[sock].k_state.bvd1 ? "bvd1 " : "",
23192 + pcmcia_socket[sock].k_state.bvd2 ? "bvd2 " : "",
23193 + pcmcia_socket[sock].k_state.wrprot ? "wrprot " : "",
23194 + pcmcia_socket[sock].k_state.vs_3v ? "vs_3v " : "",
23195 + pcmcia_socket[sock].k_state.vs_Xv ? "vs_Xv " : "");
23197 + p += sprintf(p, "status : %s%s%s%s%s%s%s%s%s\n",
23198 + pcmcia_socket[sock].k_state.detect ? "SS_DETECT " : "",
23199 + pcmcia_socket[sock].k_state.ready ? "SS_READY " : "",
23200 + pcmcia_socket[sock].cs_state.Vcc ? "SS_POWERON " : "",
23201 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ? "SS_IOCARD " : "",
23202 + (pcmcia_socket[sock].cs_state.flags & SS_IOCARD &&
23203 + pcmcia_socket[sock].k_state.bvd1) ? "SS_STSCHG " : "",
23204 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
23205 + (pcmcia_socket[sock].k_state.bvd1 == 0)) ? "SS_BATDEAD " : "",
23206 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
23207 + (pcmcia_socket[sock].k_state.bvd2 == 0)) ? "SS_BATWARN " : "",
23208 + pcmcia_socket[sock].k_state.vs_3v ? "SS_3VCARD " : "",
23209 + pcmcia_socket[sock].k_state.vs_Xv ? "SS_XVCARD " : "");
23211 + p += sprintf(p, "mask : %s%s%s%s%s\n",
23212 + pcmcia_socket[sock].cs_state.csc_mask & SS_DETECT ? "SS_DETECT " : "",
23213 + pcmcia_socket[sock].cs_state.csc_mask & SS_READY ? "SS_READY " : "",
23214 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATDEAD ? "SS_BATDEAD " : "",
23215 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATWARN ? "SS_BATWARN " : "",
23216 + pcmcia_socket[sock].cs_state.csc_mask & SS_STSCHG ? "SS_STSCHG " : "");
23218 + p += sprintf(p, "cs_flags : %s%s%s%s%s\n",
23219 + pcmcia_socket[sock].cs_state.flags & SS_PWR_AUTO ?
23220 + "SS_PWR_AUTO " : "",
23221 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ?
23222 + "SS_IOCARD " : "",
23223 + pcmcia_socket[sock].cs_state.flags & SS_RESET ?
23224 + "SS_RESET " : "",
23225 + pcmcia_socket[sock].cs_state.flags & SS_SPKR_ENA ?
23226 + "SS_SPKR_ENA " : "",
23227 + pcmcia_socket[sock].cs_state.flags & SS_OUTPUT_ENA ?
23228 + "SS_OUTPUT_ENA " : "");
23230 + p += sprintf(p, "Vcc : %d\n", pcmcia_socket[sock].cs_state.Vcc);
23231 + p += sprintf(p, "Vpp : %d\n", pcmcia_socket[sock].cs_state.Vpp);
23232 + p += sprintf(p, "irq : %d\n", pcmcia_socket[sock].cs_state.io_irq);
23233 + p += sprintf(p, "I/O : %u\n", pcmcia_socket[sock].speed_io);
23234 + p += sprintf(p, "attribute: %u\n", pcmcia_socket[sock].speed_attr);
23235 + p += sprintf(p, "common : %u\n", pcmcia_socket[sock].speed_mem);
23240 +#endif /* defined(CONFIG_PROC_FS) */
23241 diff -Nur linux-2.4.32/drivers/pcmcia/bcm4710_pcmcia.c linux-2.4.32-brcm/drivers/pcmcia/bcm4710_pcmcia.c
23242 --- linux-2.4.32/drivers/pcmcia/bcm4710_pcmcia.c 1970-01-01 01:00:00.000000000 +0100
23243 +++ linux-2.4.32-brcm/drivers/pcmcia/bcm4710_pcmcia.c 2005-12-16 23:39:11.368863250 +0100
23246 + * BCM4710 specific pcmcia routines.
23248 + * Copyright 2004, Broadcom Corporation
23249 + * All Rights Reserved.
23251 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
23252 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
23253 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
23254 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
23256 + * $Id: bcm4710_pcmcia.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
23258 +#include <linux/module.h>
23259 +#include <linux/init.h>
23260 +#include <linux/config.h>
23261 +#include <linux/delay.h>
23262 +#include <linux/ioport.h>
23263 +#include <linux/kernel.h>
23264 +#include <linux/tqueue.h>
23265 +#include <linux/timer.h>
23266 +#include <linux/mm.h>
23267 +#include <linux/proc_fs.h>
23268 +#include <linux/version.h>
23269 +#include <linux/types.h>
23270 +#include <linux/pci.h>
23272 +#include <pcmcia/version.h>
23273 +#include <pcmcia/cs_types.h>
23274 +#include <pcmcia/cs.h>
23275 +#include <pcmcia/ss.h>
23276 +#include <pcmcia/bulkmem.h>
23277 +#include <pcmcia/cistpl.h>
23278 +#include <pcmcia/bus_ops.h>
23279 +#include "cs_internal.h"
23281 +#include <asm/io.h>
23282 +#include <asm/irq.h>
23283 +#include <asm/system.h>
23286 +#include <typedefs.h>
23287 +#include <bcmdevs.h>
23288 +#include <bcm4710.h>
23289 +#include <sbconfig.h>
23290 +#include <sbextif.h>
23292 +#include "bcm4710pcmcia.h"
23294 +/* Use a static var for irq dev_id */
23295 +static int bcm47xx_pcmcia_dev_id;
23297 +/* Do we think we have a card or not? */
23298 +static int bcm47xx_pcmcia_present = 0;
23301 +static void bcm4710_pcmcia_reset(void)
23303 + extifregs_t *eir;
23305 + uint32 out0, out1, outen;
23308 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
23312 + /* Use gpio7 to reset the pcmcia slot */
23313 + outen = readl(&eir->gpio[0].outen);
23314 + outen |= BCM47XX_PCMCIA_RESET;
23315 + out0 = readl(&eir->gpio[0].out);
23316 + out0 &= ~(BCM47XX_PCMCIA_RESET);
23317 + out1 = out0 | BCM47XX_PCMCIA_RESET;
23319 + writel(out0, &eir->gpio[0].out);
23320 + writel(outen, &eir->gpio[0].outen);
23322 + writel(out1, &eir->gpio[0].out);
23324 + writel(out0, &eir->gpio[0].out);
23326 + restore_flags(s);
23330 +static int bcm4710_pcmcia_init(struct pcmcia_init *init)
23332 + struct pci_dev *pdev;
23333 + extifregs_t *eir;
23334 + uint32 outen, intp, intm, tmp;
23337 + extern unsigned long bcm4710_cpu_cycle;
23340 + if (!(pdev = pci_find_device(VENDOR_BROADCOM, SB_EXTIF, NULL))) {
23341 + printk(KERN_ERR "bcm4710_pcmcia: extif not found\n");
23344 + eir = (extifregs_t *) ioremap_nocache(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
23346 + /* Initialize the pcmcia i/f: 16bit no swap */
23347 + writel(CF_EM_PCMCIA | CF_DS | CF_EN, &eir->pcmcia_config);
23351 + /* Set the timing for memory accesses */
23352 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
23353 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
23354 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
23355 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
23356 + writel(tmp, &eir->pcmcia_memwait); /* 0x01020a0c for a 100Mhz clock */
23358 + /* Set the timing for I/O accesses */
23359 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
23360 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
23361 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
23362 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
23363 + writel(tmp, &eir->pcmcia_iowait); /* 0x01020a0c for a 100Mhz clock */
23365 + /* Set the timing for attribute accesses */
23366 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
23367 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
23368 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
23369 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
23370 + writel(tmp, &eir->pcmcia_attrwait); /* 0x01020a0c for a 100Mhz clock */
23373 + /* Make sure gpio0 and gpio5 are inputs */
23374 + outen = readl(&eir->gpio[0].outen);
23375 + outen &= ~(BCM47XX_PCMCIA_WP | BCM47XX_PCMCIA_STSCHG | BCM47XX_PCMCIA_RESET);
23376 + writel(outen, &eir->gpio[0].outen);
23378 + /* Issue a reset to the pcmcia socket */
23379 + bcm4710_pcmcia_reset();
23381 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
23382 + /* Setup gpio5 to be the STSCHG interrupt */
23383 + intp = readl(&eir->gpiointpolarity);
23384 + writel(intp | BCM47XX_PCMCIA_STSCHG, &eir->gpiointpolarity); /* Active low */
23385 + intm = readl(&eir->gpiointmask);
23386 + writel(intm | BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Enable it */
23389 + DEBUG(2, "bcm4710_pcmcia after reset:\n");
23390 + DEBUG(2, "\textstatus\t= 0x%08x:\n", readl(&eir->extstatus));
23391 + DEBUG(2, "\tpcmcia_config\t= 0x%08x:\n", readl(&eir->pcmcia_config));
23392 + DEBUG(2, "\tpcmcia_memwait\t= 0x%08x:\n", readl(&eir->pcmcia_memwait));
23393 + DEBUG(2, "\tpcmcia_attrwait\t= 0x%08x:\n", readl(&eir->pcmcia_attrwait));
23394 + DEBUG(2, "\tpcmcia_iowait\t= 0x%08x:\n", readl(&eir->pcmcia_iowait));
23395 + DEBUG(2, "\tgpioin\t\t= 0x%08x:\n", readl(&eir->gpioin));
23396 + DEBUG(2, "\tgpio_outen0\t= 0x%08x:\n", readl(&eir->gpio[0].outen));
23397 + DEBUG(2, "\tgpio_out0\t= 0x%08x:\n", readl(&eir->gpio[0].out));
23398 + DEBUG(2, "\tgpiointpolarity\t= 0x%08x:\n", readl(&eir->gpiointpolarity));
23399 + DEBUG(2, "\tgpiointmask\t= 0x%08x:\n", readl(&eir->gpiointmask));
23401 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
23402 + /* Request pcmcia interrupt */
23403 + rc = request_irq(BCM47XX_PCMCIA_IRQ, init->handler, SA_INTERRUPT,
23404 + "PCMCIA Interrupt", &bcm47xx_pcmcia_dev_id);
23407 + attrsp = (uint16 *)ioremap_nocache(EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF), 0x1000);
23408 + tmp = readw(&attrsp[0]);
23409 + DEBUG(2, "\tattr[0] = 0x%04x\n", tmp);
23410 + if ((tmp == 0x7fff) || (tmp == 0x7f00)) {
23411 + bcm47xx_pcmcia_present = 0;
23413 + bcm47xx_pcmcia_present = 1;
23416 + /* There's only one socket */
23420 +static int bcm4710_pcmcia_shutdown(void)
23422 + extifregs_t *eir;
23425 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
23427 + /* Disable the pcmcia i/f */
23428 + writel(0, &eir->pcmcia_config);
23430 + /* Reset gpio's */
23431 + intm = readl(&eir->gpiointmask);
23432 + writel(intm & ~BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Disable it */
23434 + free_irq(BCM47XX_PCMCIA_IRQ, &bcm47xx_pcmcia_dev_id);
23440 +bcm4710_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
23442 + extifregs_t *eir;
23444 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
23448 + printk(KERN_ERR "bcm4710 socket_state bad sock %d\n", sock);
23452 + if (bcm47xx_pcmcia_present) {
23453 + state->detect = 1;
23454 + state->ready = 1;
23457 + state->wrprot = (readl(&eir->gpioin) & BCM47XX_PCMCIA_WP) == BCM47XX_PCMCIA_WP;
23458 + state->vs_3v = 0;
23459 + state->vs_Xv = 0;
23461 + state->detect = 0;
23462 + state->ready = 0;
23469 +static int bcm4710_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
23471 + if (info->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
23473 + info->irq = BCM47XX_PCMCIA_IRQ;
23480 +bcm4710_pcmcia_configure_socket(const struct pcmcia_configure *configure)
23482 + if (configure->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
23485 + DEBUG(2, "Vcc %dV Vpp %dV output %d speaker %d reset %d\n", configure->vcc,
23486 + configure->vpp, configure->output, configure->speaker, configure->reset);
23488 + if ((configure->vcc != 50) || (configure->vpp != 50)) {
23489 + printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc,
23493 + if (configure->reset) {
23494 + /* Issue a reset to the pcmcia socket */
23495 + DEBUG(1, "%s: Reseting socket\n", __FUNCTION__);
23496 + bcm4710_pcmcia_reset();
23503 +struct pcmcia_low_level bcm4710_pcmcia_ops = {
23504 + bcm4710_pcmcia_init,
23505 + bcm4710_pcmcia_shutdown,
23506 + bcm4710_pcmcia_socket_state,
23507 + bcm4710_pcmcia_get_irq_info,
23508 + bcm4710_pcmcia_configure_socket
23511 diff -Nur linux-2.4.32/drivers/pcmcia/bcm4710pcmcia.h linux-2.4.32-brcm/drivers/pcmcia/bcm4710pcmcia.h
23512 --- linux-2.4.32/drivers/pcmcia/bcm4710pcmcia.h 1970-01-01 01:00:00.000000000 +0100
23513 +++ linux-2.4.32-brcm/drivers/pcmcia/bcm4710pcmcia.h 2005-12-16 23:39:11.368863250 +0100
23517 + * bcm47xx pcmcia driver
23519 + * Copyright 2004, Broadcom Corporation
23520 + * All Rights Reserved.
23522 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
23523 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
23524 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
23525 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
23527 + * Based on sa1100.h and include/asm-arm/arch-sa1100/pcmica.h
23528 + * from www.handhelds.org,
23529 + * and au1000_generic.c from oss.sgi.com.
23531 + * $Id: bcm4710pcmcia.h,v 1.1 2005/03/16 13:50:00 wbx Exp $
23534 +#if !defined(_BCM4710PCMCIA_H)
23535 +#define _BCM4710PCMCIA_H
23537 +#include <pcmcia/cs_types.h>
23538 +#include <pcmcia/ss.h>
23539 +#include <pcmcia/bulkmem.h>
23540 +#include <pcmcia/cistpl.h>
23541 +#include "cs_internal.h"
23544 +/* The 47xx can only support one socket */
23545 +#define BCM47XX_PCMCIA_MAX_SOCK 1
23547 +/* In the bcm947xx gpio's are used for some pcmcia functions */
23548 +#define BCM47XX_PCMCIA_WP 0x01 /* Bit 0 is WP input */
23549 +#define BCM47XX_PCMCIA_STSCHG 0x20 /* Bit 5 is STSCHG input/interrupt */
23550 +#define BCM47XX_PCMCIA_RESET 0x80 /* Bit 7 is RESET */
23552 +#define BCM47XX_PCMCIA_IRQ 2
23554 +/* The socket driver actually works nicely in interrupt-driven form,
23555 + * so the (relatively infrequent) polling is "just to be sure."
23557 +#define BCM47XX_PCMCIA_POLL_PERIOD (2 * HZ)
23559 +#define BCM47XX_PCMCIA_IO_SPEED (255)
23560 +#define BCM47XX_PCMCIA_MEM_SPEED (300)
23563 +struct pcmcia_state {
23564 + unsigned detect: 1,
23574 +struct pcmcia_configure {
23575 + unsigned sock: 8,
23583 +struct pcmcia_irq_info {
23584 + unsigned int sock;
23585 + unsigned int irq;
23588 +/* This structure encapsulates per-socket state which we might need to
23589 + * use when responding to a Card Services query of some kind.
23591 +struct bcm47xx_pcmcia_socket {
23592 + socket_state_t cs_state;
23593 + struct pcmcia_state k_state;
23594 + unsigned int irq;
23595 + void (*handler)(void *, unsigned int);
23596 + void *handler_info;
23597 + pccard_io_map io_map[MAX_IO_WIN];
23598 + pccard_mem_map mem_map[MAX_WIN];
23599 + ioaddr_t virt_io, phys_attr, phys_mem;
23600 + unsigned short speed_io, speed_attr, speed_mem;
23603 +struct pcmcia_init {
23604 + void (*handler)(int irq, void *dev, struct pt_regs *regs);
23607 +struct pcmcia_low_level {
23608 + int (*init)(struct pcmcia_init *);
23609 + int (*shutdown)(void);
23610 + int (*socket_state)(unsigned sock, struct pcmcia_state *);
23611 + int (*get_irq_info)(struct pcmcia_irq_info *);
23612 + int (*configure_socket)(const struct pcmcia_configure *);
23615 +extern struct pcmcia_low_level bcm47xx_pcmcia_ops;
23617 +/* I/O pins replacing memory pins
23618 + * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75)
23620 + * These signals change meaning when going from memory-only to
23621 + * memory-or-I/O interface:
23623 +#define iostschg bvd1
23624 +#define iospkr bvd2
23628 + * Declaration for implementation specific low_level operations.
23630 +extern struct pcmcia_low_level bcm4710_pcmcia_ops;
23632 +#endif /* !defined(_BCM4710PCMCIA_H) */
23633 diff -Nur linux-2.4.32/drivers/pcmcia/Makefile linux-2.4.32-brcm/drivers/pcmcia/Makefile
23634 --- linux-2.4.32/drivers/pcmcia/Makefile 2004-02-18 14:36:31.000000000 +0100
23635 +++ linux-2.4.32-brcm/drivers/pcmcia/Makefile 2005-12-16 23:39:11.364863000 +0100
23637 au1000_ss-objs-$(CONFIG_PCMCIA_DB1X00) += au1000_db1x00.o
23638 au1000_ss-objs-$(CONFIG_PCMCIA_XXS1500) += au1000_xxs1500.o
23640 +obj-$(CONFIG_PCMCIA_BCM4710) += bcm4710_ss.o
23641 +bcm4710_ss-objs := bcm4710_generic.o
23642 +bcm4710_ss-objs += bcm4710_pcmcia.o
23644 obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o
23645 obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o
23646 obj-$(CONFIG_PCMCIA_SIBYTE) += sibyte_generic.o
23647 @@ -102,5 +106,8 @@
23648 au1x00_ss.o: $(au1000_ss-objs-y)
23649 $(LD) -r -o $@ $(au1000_ss-objs-y)
23651 +bcm4710_ss.o: $(bcm4710_ss-objs)
23652 + $(LD) -r -o $@ $(bcm4710_ss-objs)
23654 yenta_socket.o: $(yenta_socket-objs)
23655 $(LD) $(LD_RFLAG) -r -o $@ $(yenta_socket-objs)
23656 diff -Nur linux-2.4.32/include/asm-mips/bootinfo.h linux-2.4.32-brcm/include/asm-mips/bootinfo.h
23657 --- linux-2.4.32/include/asm-mips/bootinfo.h 2004-02-18 14:36:32.000000000 +0100
23658 +++ linux-2.4.32-brcm/include/asm-mips/bootinfo.h 2005-12-16 23:39:11.400865250 +0100
23660 #define MACH_GROUP_HP_LJ 20 /* Hewlett Packard LaserJet */
23661 #define MACH_GROUP_LASAT 21
23662 #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
23663 +#define MACH_GROUP_BRCM 23 /* Broadcom */
23666 * Valid machtype values for group unknown (low order halfword of mips_machtype)
23667 @@ -194,6 +195,15 @@
23668 #define MACH_TANBAC_TB0229 7 /* TANBAC TB0229 (VR4131DIMM) */
23671 + * Valid machtypes for group Broadcom
23673 +#define MACH_BCM93725 0
23674 +#define MACH_BCM93725_VJ 1
23675 +#define MACH_BCM93730 2
23676 +#define MACH_BCM947XX 3
23677 +#define MACH_BCM933XX 4
23680 * Valid machtype for group TITAN
23682 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
23683 diff -Nur linux-2.4.32/include/asm-mips/cpu.h linux-2.4.32-brcm/include/asm-mips/cpu.h
23684 --- linux-2.4.32/include/asm-mips/cpu.h 2005-01-19 15:10:11.000000000 +0100
23685 +++ linux-2.4.32-brcm/include/asm-mips/cpu.h 2005-12-16 23:39:11.412866000 +0100
23690 +#define PRID_COPT_MASK 0xff000000
23691 +#define PRID_COMP_MASK 0x00ff0000
23692 +#define PRID_IMP_MASK 0x0000ff00
23693 +#define PRID_REV_MASK 0x000000ff
23695 #define PRID_COMP_LEGACY 0x000000
23696 #define PRID_COMP_MIPS 0x010000
23697 #define PRID_COMP_BROADCOM 0x020000
23699 #define PRID_IMP_RM7000 0x2700
23700 #define PRID_IMP_NEVADA 0x2800 /* RM5260 ??? */
23701 #define PRID_IMP_RM9000 0x3400
23702 +#define PRID_IMP_BCM4710 0x4000
23703 #define PRID_IMP_R5432 0x5400
23704 #define PRID_IMP_R5500 0x5500
23705 #define PRID_IMP_4KC 0x8000
23706 @@ -66,10 +72,16 @@
23707 #define PRID_IMP_4KEC 0x8400
23708 #define PRID_IMP_4KSC 0x8600
23709 #define PRID_IMP_25KF 0x8800
23710 +#define PRID_IMP_BCM3302 0x9000
23711 +#define PRID_IMP_BCM3303 0x9100
23712 #define PRID_IMP_24K 0x9300
23714 #define PRID_IMP_UNKNOWN 0xff00
23716 +#define BCM330X(id) \
23717 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
23718 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
23721 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
23723 @@ -174,7 +186,9 @@
23724 #define CPU_AU1550 57
23726 #define CPU_AU1200 59
23727 -#define CPU_LAST 59
23728 +#define CPU_BCM4710 60
23729 +#define CPU_BCM3302 61
23730 +#define CPU_LAST 61
23733 * ISA Level encodings
23734 diff -Nur linux-2.4.32/include/asm-mips/r4kcache.h linux-2.4.32-brcm/include/asm-mips/r4kcache.h
23735 --- linux-2.4.32/include/asm-mips/r4kcache.h 2004-02-18 14:36:32.000000000 +0100
23736 +++ linux-2.4.32-brcm/include/asm-mips/r4kcache.h 2005-12-16 23:39:11.416866250 +0100
23737 @@ -567,4 +567,17 @@
23738 cache128_unroll32(addr|ws,Index_Writeback_Inv_SD);
23741 +extern inline void fill_icache_line(unsigned long addr)
23743 + __asm__ __volatile__(
23744 + ".set noreorder\n\t"
23746 + "cache %1, (%0)\n\t"
23754 #endif /* __ASM_R4KCACHE_H */
23755 diff -Nur linux-2.4.32/include/asm-mips/serial.h linux-2.4.32-brcm/include/asm-mips/serial.h
23756 --- linux-2.4.32/include/asm-mips/serial.h 2005-01-19 15:10:12.000000000 +0100
23757 +++ linux-2.4.32-brcm/include/asm-mips/serial.h 2005-12-16 23:39:11.428867000 +0100
23758 @@ -223,6 +223,13 @@
23759 #define TXX927_SERIAL_PORT_DEFNS
23762 +#ifdef CONFIG_BCM947XX
23763 +/* reserve 4 ports to be configured at runtime */
23764 +#define BCM947XX_SERIAL_PORT_DEFNS { 0, }, { 0, }, { 0, }, { 0, },
23766 +#define BCM947XX_SERIAL_PORT_DEFNS
23769 #ifdef CONFIG_HAVE_STD_PC_SERIAL_PORT
23770 #define STD_SERIAL_PORT_DEFNS \
23771 /* UART CLK PORT IRQ FLAGS */ \
23772 @@ -470,6 +477,7 @@
23773 #define SERIAL_PORT_DFNS \
23774 ATLAS_SERIAL_PORT_DEFNS \
23775 AU1000_SERIAL_PORT_DEFNS \
23776 + BCM947XX_SERIAL_PORT_DEFNS \
23777 COBALT_SERIAL_PORT_DEFNS \
23778 DDB5477_SERIAL_PORT_DEFNS \
23779 EV96100_SERIAL_PORT_DEFNS \
23780 diff -Nur linux-2.4.32/init/do_mounts.c linux-2.4.32-brcm/init/do_mounts.c
23781 --- linux-2.4.32/init/do_mounts.c 2003-11-28 19:26:21.000000000 +0100
23782 +++ linux-2.4.32-brcm/init/do_mounts.c 2005-12-16 23:39:11.504871750 +0100
23783 @@ -253,7 +253,13 @@
23784 { "ftlb", 0x2c08 },
23785 { "ftlc", 0x2c10 },
23786 { "ftld", 0x2c18 },
23787 +#if defined(CONFIG_MTD_BLOCK) || defined(CONFIG_MTD_BLOCK_RO)
23788 { "mtdblock", 0x1f00 },
23789 + { "mtdblock0",0x1f00 },
23790 + { "mtdblock1",0x1f01 },
23791 + { "mtdblock2",0x1f02 },
23792 + { "mtdblock3",0x1f03 },