x86-2.6 compile fixes for snapshot build
[openwrt.git] / target / linux / linux-2.4 / patches / brcm / 001-bcm47xx.patch
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
4 @@ -0,0 +1,234 @@
5 +/*
6 + * NVRAM variable manipulation (Linux kernel half)
7 + *
8 + * Copyright 2001-2003, Broadcom Corporation
9 + * All Rights Reserved.
10 + *
11 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
12 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
15 + *
16 + * $Id$
17 + */
18 +
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>
24 +#include <asm/io.h>
25 +#include <asm/uaccess.h>
26 +
27 +#include <typedefs.h>
28 +#include <osl.h>
29 +#include <bcmendian.h>
30 +#include <bcmutils.h>
31 +
32 +#define NVRAM_SIZE (0x1ff0)
33 +static char _nvdata[NVRAM_SIZE] __initdata;
34 +static char _valuestr[256] __initdata;
35 +
36 +/*
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)
39 + *
40 + * The layout of the flash/nvram is as follows:
41 + *
42 + * <type> <length> <data ...> <type> <length> <data ...> <type_end>
43 + *
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.
47 + *
48 + * Environment variables are stored as follows:
49 + *
50 + * <type_env> <length> <flags> <name> = <value>
51 + *
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
54 + *
55 + * Bit 7 set indicates "user" TLVs. In this case, bit 0 still
56 + * indicates the size of the length field.
57 + *
58 + * Flags are from the constants below:
59 + *
60 + */
61 +#define ENV_LENGTH_16BITS 0x00 /* for low bit */
62 +#define ENV_LENGTH_8BITS 0x01
63 +
64 +#define ENV_TYPE_USER 0x80
65 +
66 +#define ENV_CODE_SYS(n,l) (((n)<<1)|(l))
67 +#define ENV_CODE_USER(n,l) ((((n)<<1)|(l)) | ENV_TYPE_USER)
68 +
69 +/*
70 + * The actual TLV types we support
71 + */
72 +
73 +#define ENV_TLV_TYPE_END 0x00
74 +#define ENV_TLV_TYPE_ENV ENV_CODE_SYS(0,ENV_LENGTH_8BITS)
75 +
76 +/*
77 + * Environment variable flags
78 + */
79 +
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 */
83 +
84 +#define ENV_FLG_MASK 0xFF /* mask of attributes we keep */
85 +#define ENV_FLG_ADMIN 0x100 /* lets us internally override permissions */
86 +
87 +
88 +/* *********************************************************************
89 + * _nvram_read(buffer,offset,length)
90 + *
91 + * Read data from the NVRAM device
92 + *
93 + * Input parameters:
94 + * buffer - destination buffer
95 + * offset - offset of data to read
96 + * length - number of bytes to read
97 + *
98 + * Return value:
99 + * number of bytes read, or <0 if error occured
100 + ********************************************************************* */
101 +static int
102 +_nvram_read(unsigned char *nv_buf, unsigned char *buffer, int offset, int length)
103 +{
104 + int i;
105 + if (offset > NVRAM_SIZE)
106 + return -1;
107 +
108 + for ( i = 0; i < length; i++) {
109 + buffer[i] = ((volatile unsigned char*)nv_buf)[offset + i];
110 + }
111 + return length;
112 +}
113 +
114 +
115 +static char*
116 +_strnchr(const char *dest,int c,size_t cnt)
117 +{
118 + while (*dest && (cnt > 0)) {
119 + if (*dest == c) return (char *) dest;
120 + dest++;
121 + cnt--;
122 + }
123 + return NULL;
124 +}
125 +
126 +
127 +
128 +/*
129 + * Core support API: Externally visible.
130 + */
131 +
132 +/*
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
136 + */
137 +
138 +char*
139 +cfe_env_get(unsigned char *nv_buf, char* name)
140 +{
141 + int size;
142 + unsigned char *buffer;
143 + unsigned char *ptr;
144 + unsigned char *envval;
145 + unsigned int reclen;
146 + unsigned int rectype;
147 + int offset;
148 + int flg;
149 +
150 + size = NVRAM_SIZE;
151 + buffer = &_nvdata[0];
152 +
153 + ptr = buffer;
154 + offset = 0;
155 +
156 + /* Read the record type and length */
157 + if (_nvram_read(nv_buf, ptr,offset,1) != 1) {
158 + goto error;
159 + }
160 +
161 + while ((*ptr != ENV_TLV_TYPE_END) && (size > 1)) {
162 +
163 + /* Adjust pointer for TLV type */
164 + rectype = *(ptr);
165 + offset++;
166 + size--;
167 +
168 + /*
169 + * Read the length. It can be either 1 or 2 bytes
170 + * depending on the code
171 + */
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) {
175 + goto error;
176 + }
177 + reclen = *(ptr);
178 + size--;
179 + offset++;
180 + }
181 + else {
182 + /* Read the record type and length - 16 bits, MSB first */
183 + if (_nvram_read(nv_buf, ptr,offset,2) != 2) {
184 + goto error;
185 + }
186 + reclen = (((unsigned int) *(ptr)) << 8) + (unsigned int) *(ptr+1);
187 + size -= 2;
188 + offset += 2;
189 + }
190 +
191 + if (reclen > size)
192 + break; /* should not happen, bad NVRAM */
193 +
194 + switch (rectype) {
195 + case ENV_TLV_TYPE_ENV:
196 + /* Read the TLV data */
197 + if (_nvram_read(nv_buf, ptr,offset,reclen) != reclen)
198 + goto error;
199 + flg = *ptr++;
200 + envval = (unsigned char *) _strnchr(ptr,'=',(reclen-1));
201 + if (envval) {
202 + *envval++ = '\0';
203 + memcpy(_valuestr,envval,(reclen-1)-(envval-ptr));
204 + _valuestr[(reclen-1)-(envval-ptr)] = '\0';
205 +#if 0
206 + printk(KERN_INFO "NVRAM:%s=%s\n", ptr, _valuestr);
207 +#endif
208 + if(!strcmp(ptr, name)){
209 + return _valuestr;
210 + }
211 + if((strlen(ptr) > 1) && !strcmp(&ptr[1], name))
212 + return _valuestr;
213 + }
214 + break;
215 +
216 + default:
217 + /* Unknown TLV type, skip it. */
218 + break;
219 + }
220 +
221 + /*
222 + * Advance to next TLV
223 + */
224 +
225 + size -= (int)reclen;
226 + offset += reclen;
227 +
228 + /* Read the next record type */
229 + ptr = buffer;
230 + if (_nvram_read(nv_buf, ptr,offset,1) != 1)
231 + goto error;
232 + }
233 +
234 +error:
235 + return NULL;
236 +
237 +}
238 +
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
242 @@ -0,0 +1,33 @@
243 +#
244 +# Makefile for Broadcom BCM947XX boards
245 +#
246 +# Copyright 2001-2003, Broadcom Corporation
247 +# All Rights Reserved.
248 +#
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.
253 +#
254 +# $Id: Makefile,v 1.2 2005/04/02 12:12:57 wbx Exp $
255 +#
256 +
257 +OBJCOPY_ARGS = -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
258 +SYSTEM ?= $(TOPDIR)/vmlinux
259 +
260 +all: vmlinuz
261 +
262 +# Don't build dependencies, this may die if $(CC) isn't gcc
263 +dep:
264 +
265 +# Create a gzipped version named vmlinuz for compatibility
266 +vmlinuz: piggy
267 + gzip -c9 $< > $@
268 +
269 +piggy: $(SYSTEM)
270 + $(OBJCOPY) $(OBJCOPY_ARGS) $< $@
271 +
272 +mrproper: clean
273 +
274 +clean:
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
279 @@ -0,0 +1,51 @@
280 +/*
281 + * Generic interrupt handler for Broadcom MIPS boards
282 + *
283 + * Copyright 2004, Broadcom Corporation
284 + * All Rights Reserved.
285 + *
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.
290 + *
291 + * $Id: int-handler.S,v 1.1 2005/03/16 13:50:00 wbx Exp $
292 + */
293 +
294 +#include <linux/config.h>
295 +
296 +#include <asm/asm.h>
297 +#include <asm/mipsregs.h>
298 +#include <asm/regdef.h>
299 +#include <asm/stackframe.h>
300 +
301 +/*
302 + * MIPS IRQ Source
303 + * -------- ------
304 + * 0 Software (ignored)
305 + * 1 Software (ignored)
306 + * 2 Combined hardware interrupt (hw0)
307 + * 3 Hardware
308 + * 4 Hardware
309 + * 5 Hardware
310 + * 6 Hardware
311 + * 7 R4k timer
312 + */
313 +
314 + .text
315 + .set noreorder
316 + .set noat
317 + .align 5
318 + NESTED(brcmIRQ, PT_SIZE, sp)
319 + SAVE_ALL
320 + CLI
321 + .set at
322 + .set noreorder
323 +
324 + jal brcm_irq_dispatch
325 + move a0, sp
326 +
327 + j ret_from_irq
328 + nop
329 +
330 + END(brcmIRQ)
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
334 @@ -0,0 +1,130 @@
335 +/*
336 + * Generic interrupt control functions for Broadcom MIPS boards
337 + *
338 + * Copyright 2004, Broadcom Corporation
339 + * All Rights Reserved.
340 + *
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.
345 + *
346 + * $Id: irq.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
347 + */
348 +
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>
355 +
356 +#include <asm/irq.h>
357 +#include <asm/mipsregs.h>
358 +#include <asm/gdb-stub.h>
359 +
360 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
361 +
362 +extern asmlinkage void brcmIRQ(void);
363 +extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs);
364 +
365 +void
366 +brcm_irq_dispatch(struct pt_regs *regs)
367 +{
368 + u32 cause;
369 +
370 + cause = read_c0_cause() &
371 + read_c0_status() &
372 + CAUSEF_IP;
373 +
374 +#ifdef CONFIG_KERNPROF
375 + change_c0_status(cause | 1, 1);
376 +#else
377 + clear_c0_status(cause);
378 +#endif
379 +
380 + if (cause & CAUSEF_IP7)
381 + do_IRQ(7, regs);
382 + if (cause & CAUSEF_IP2)
383 + do_IRQ(2, regs);
384 + if (cause & CAUSEF_IP3)
385 + do_IRQ(3, regs);
386 + if (cause & CAUSEF_IP4)
387 + do_IRQ(4, regs);
388 + if (cause & CAUSEF_IP5)
389 + do_IRQ(5, regs);
390 + if (cause & CAUSEF_IP6)
391 + do_IRQ(6, regs);
392 +}
393 +
394 +static void
395 +enable_brcm_irq(unsigned int irq)
396 +{
397 + if (irq < 8)
398 + set_c0_status(1 << (irq + 8));
399 + else
400 + set_c0_status(IE_IRQ0);
401 +}
402 +
403 +static void
404 +disable_brcm_irq(unsigned int irq)
405 +{
406 + if (irq < 8)
407 + clear_c0_status(1 << (irq + 8));
408 + else
409 + clear_c0_status(IE_IRQ0);
410 +}
411 +
412 +static void
413 +ack_brcm_irq(unsigned int irq)
414 +{
415 + /* Already done in brcm_irq_dispatch */
416 +}
417 +
418 +static unsigned int
419 +startup_brcm_irq(unsigned int irq)
420 +{
421 + enable_brcm_irq(irq);
422 +
423 + return 0; /* never anything pending */
424 +}
425 +
426 +static void
427 +end_brcm_irq(unsigned int irq)
428 +{
429 + if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
430 + enable_brcm_irq(irq);
431 +}
432 +
433 +static struct hw_interrupt_type brcm_irq_type = {
434 + typename: "MIPS",
435 + startup: startup_brcm_irq,
436 + shutdown: disable_brcm_irq,
437 + enable: enable_brcm_irq,
438 + disable: disable_brcm_irq,
439 + ack: ack_brcm_irq,
440 + end: end_brcm_irq,
441 + NULL
442 +};
443 +
444 +void __init
445 +init_IRQ(void)
446 +{
447 + int i;
448 +
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;
454 + }
455 +
456 + set_except_vector(0, brcmIRQ);
457 + change_c0_status(ST0_IM, ALLINTS);
458 +
459 +#ifdef CONFIG_REMOTE_DEBUG
460 + printk("Breaking into debugger...\n");
461 + set_debug_traps();
462 + breakpoint();
463 +#endif
464 +}
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
468 @@ -0,0 +1,15 @@
469 +#
470 +# Makefile for the BCM947xx specific kernel interface routines
471 +# under Linux.
472 +#
473 +
474 +.S.s:
475 + $(CPP) $(AFLAGS) $< -o $*.s
476 +.S.o:
477 + $(CC) $(AFLAGS) -c $< -o $*.o
478 +
479 +O_TARGET := brcm.o
480 +
481 +obj-y := int-handler.o irq.o
482 +
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
487 @@ -0,0 +1,158 @@
488 +/*
489 + * GPIO char driver
490 + *
491 + * Copyright 2005, Broadcom Corporation
492 + * All Rights Reserved.
493 + *
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.
498 + *
499 + * $Id$
500 + */
501 +
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>
507 +
508 +#include <typedefs.h>
509 +#include <bcmutils.h>
510 +#include <sbutils.h>
511 +#include <bcmdevs.h>
512 +
513 +static sb_t *gpio_sbh;
514 +static int gpio_major;
515 +static devfs_handle_t gpio_dir;
516 +static struct {
517 + char *name;
518 + devfs_handle_t handle;
519 +} gpio_file[] = {
520 + { "in", NULL },
521 + { "out", NULL },
522 + { "outen", NULL },
523 + { "control", NULL }
524 +};
525 +
526 +static int
527 +gpio_open(struct inode *inode, struct file * file)
528 +{
529 + if (MINOR(inode->i_rdev) > ARRAYSIZE(gpio_file))
530 + return -ENODEV;
531 +
532 + MOD_INC_USE_COUNT;
533 + return 0;
534 +}
535 +
536 +static int
537 +gpio_release(struct inode *inode, struct file * file)
538 +{
539 + MOD_DEC_USE_COUNT;
540 + return 0;
541 +}
542 +
543 +static ssize_t
544 +gpio_read(struct file *file, char *buf, size_t count, loff_t *ppos)
545 +{
546 + u32 val;
547 +
548 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
549 + case 0:
550 + val = sb_gpioin(gpio_sbh);
551 + break;
552 + case 1:
553 + val = sb_gpioout(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY);
554 + break;
555 + case 2:
556 + val = sb_gpioouten(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY);
557 + break;
558 + case 3:
559 + val = sb_gpiocontrol(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY);
560 + break;
561 + default:
562 + return -ENODEV;
563 + }
564 +
565 + if (put_user(val, (u32 *) buf))
566 + return -EFAULT;
567 +
568 + return sizeof(val);
569 +}
570 +
571 +static ssize_t
572 +gpio_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
573 +{
574 + u32 val;
575 +
576 + if (get_user(val, (u32 *) buf))
577 + return -EFAULT;
578 +
579 + switch (MINOR(file->f_dentry->d_inode->i_rdev)) {
580 + case 0:
581 + return -EACCES;
582 + case 1:
583 + sb_gpioout(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY);
584 + break;
585 + case 2:
586 + sb_gpioouten(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY);
587 + break;
588 + case 3:
589 + sb_gpiocontrol(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY);
590 + break;
591 + default:
592 + return -ENODEV;
593 + }
594 +
595 + return sizeof(val);
596 +}
597 +
598 +static struct file_operations gpio_fops = {
599 + owner: THIS_MODULE,
600 + open: gpio_open,
601 + release: gpio_release,
602 + read: gpio_read,
603 + write: gpio_write,
604 +};
605 +
606 +static int __init
607 +gpio_init(void)
608 +{
609 + int i;
610 +
611 + if (!(gpio_sbh = sb_kattach()))
612 + return -ENODEV;
613 +
614 + sb_gpiosetcore(gpio_sbh);
615 +
616 + if ((gpio_major = devfs_register_chrdev(0, "gpio", &gpio_fops)) < 0)
617 + return gpio_major;
618 +
619 + gpio_dir = devfs_mk_dir(NULL, "gpio", NULL);
620 +
621 + for (i = 0; i < ARRAYSIZE(gpio_file); i++) {
622 + gpio_file[i].handle = devfs_register(gpio_dir,
623 + gpio_file[i].name,
624 + DEVFS_FL_DEFAULT, gpio_major, i,
625 + S_IFCHR | S_IRUGO | S_IWUGO,
626 + &gpio_fops, NULL);
627 + }
628 +
629 + return 0;
630 +}
631 +
632 +static void __exit
633 +gpio_exit(void)
634 +{
635 + int i;
636 +
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);
642 +}
643 +
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
649 @@ -0,0 +1,391 @@
650 +/*
651 + * Broadcom device-specific manifest constants.
652 + *
653 + * Copyright 2005, Broadcom Corporation
654 + * All Rights Reserved.
655 + *
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.
660 + * $Id$
661 + */
662 +
663 +#ifndef _BCMDEVS_H
664 +#define _BCMDEVS_H
665 +
666 +
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
676 +
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
682 +
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 */
687 +
688 +#define BCM3352_DEVICE_ID 0x3352 /* bcm3352 device id */
689 +#define BCM3360_DEVICE_ID 0x3360 /* bcm3360 device id */
690 +
691 +#define EPI41210_DEVICE_ID 0xa0fa /* bcm4210 */
692 +#define EPI41230_DEVICE_ID 0xa10e /* bcm4230 */
693 +
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 */
705 +
706 +#define BCM4710_DEVICE_ID 0x4710 /* 4710 primary function 0 */
707 +
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 */
714 +
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 */
719 +
720 +#define BCM4301_DEVICE_ID 0x4301 /* 4301 primary function 0 */
721 +#define BCM4301_D11B_ID 0x4301 /* 4301 802.11b */
722 +
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 */
727 +
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 */
735 +
736 +#define BCM4309_PKG_ID 1 /* 4309 package id */
737 +
738 +#define BCM4303_D11B_ID 0x4303 /* 4303 802.11b */
739 +#define BCM4303_PKG_ID 2 /* 4303 package id */
740 +
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 */
746 +
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 */
749 +
750 +
751 +#define BCM4704_DEVICE_ID 0x4704 /* 4704 chipcommon chipid */
752 +#define BCM4704_ENET_ID 0x4706 /* 4704 enet (Use 47XX_ENET_ID instead!) */
753 +
754 +#define BCM4317_DEVICE_ID 0x4317 /* 4317 chip common chipid */
755 +
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 */
760 +
761 +#define FPGA_JTAGM_ID 0x4330 /* ??? */
762 +
763 +/* Address map */
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 */
770 +
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 */
781 +
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 */
788 +
789 +#define BCM4710_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
790 +
791 +#define BCM4710_UART (BCM4710_REG_EXTIF + 0x00000300)
792 +
793 +#define BCM4710_EUART (BCM4710_EXTIF + 0x00800000)
794 +#define BCM4710_LED (BCM4710_EXTIF + 0x00900000)
795 +
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 */
801 +
802 +#define SDIOH_FPGA_ID 0x4380 /* sdio host fpga */
803 +
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 */
807 +
808 +#define BCM4320_DEVICE_ID 0x4320 /* bcm4320 chipcommon chipid */
809 +
810 +/* PCMCIA vendor Id's */
811 +
812 +#define VENDOR_BROADCOM_PCMCIA 0x02d0
813 +
814 +/* SDIO vendor Id's */
815 +#define VENDOR_BROADCOM_SDIO 0x00BF
816 +
817 +
818 +/* boardflags */
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 */
833 +
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 */
845 +
846 +/* Bus types */
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 */
852 +
853 +/* Allows optimization for single-bus support */
854 +#ifdef BCMBUSTYPE
855 +#define BUSTYPE(bus) (BCMBUSTYPE)
856 +#else
857 +#define BUSTYPE(bus) (bus)
858 +#endif
859 +
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 */
865 +
866 +/* Reference Board Types */
867 +
868 +#define BU4710_BOARD 0x0400
869 +#define VSIM4710_BOARD 0x0401
870 +#define QT4710_BOARD 0x0402
871 +
872 +#define BU4610_BOARD 0x0403
873 +#define VSIM4610_BOARD 0x0404
874 +
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
881 +
882 +#define BU4309_BOARD 0x040a
883 +#define BCM94309CB_BOARD 0x040b
884 +#define BCM94309MP_BOARD 0x040c
885 +#define BCM4309AP_BOARD 0x040d
886 +
887 +#define BCM94302MP_BOARD 0x040e
888 +
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
894 +
895 +#define BU4306_BOARD 0x0416
896 +#define BCM94306CB_BOARD 0x0417
897 +#define BCM94306MP_BOARD 0x0418
898 +
899 +#define BCM94710D_BOARD 0x041a
900 +#define BCM94710R1_BOARD 0x041b
901 +#define BCM94710R4_BOARD 0x041c
902 +#define BCM94710AP_BOARD 0x041d
903 +
904 +
905 +#define BU2050_BOARD 0x041f
906 +
907 +
908 +#define BCM94309G_BOARD 0x0421
909 +
910 +#define BCM94301PC3_BOARD 0x0422 /* Pcmcia 3.3v card */
911 +
912 +#define BU4704_BOARD 0x0423
913 +#define BU4702_BOARD 0x0424
914 +
915 +#define BCM94306PC_BOARD 0x0425 /* pcmcia 3.3v 4306 card */
916 +
917 +#define BU4317_BOARD 0x0426
918 +
919 +
920 +#define BCM94702MN_BOARD 0x0428
921 +
922 +/* BCM4702 1U CompactPCI Board */
923 +#define BCM94702CPCI_BOARD 0x0429
924 +
925 +/* BCM4702 with BCM95380 VLAN Router */
926 +#define BCM95380RR_BOARD 0x042a
927 +
928 +/* cb4306 with SiGe PA */
929 +#define BCM94306CBSG_BOARD 0x042b
930 +
931 +/* mp4301 with 2050 radio */
932 +#define BCM94301MPL_BOARD 0x042c
933 +
934 +/* cb4306 with SiGe PA */
935 +#define PCSG94306_BOARD 0x042d
936 +
937 +/* bu4704 with sdram */
938 +#define BU4704SD_BOARD 0x042e
939 +
940 +/* Dual 11a/11g Router */
941 +#define BCM94704AGR_BOARD 0x042f
942 +
943 +/* 11a-only minipci */
944 +#define BCM94308MP_BOARD 0x0430
945 +
946 +
947 +
948 +/* BCM94317 boards */
949 +#define BCM94317CB_BOARD 0x0440
950 +#define BCM94317MP_BOARD 0x0441
951 +#define BCM94317PCMCIA_BOARD 0x0442
952 +#define BCM94317SDIO_BOARD 0x0443
953 +
954 +#define BU4712_BOARD 0x0444
955 +#define BU4712SD_BOARD 0x045d
956 +#define BU4712L_BOARD 0x045f
957 +
958 +/* BCM4712 boards */
959 +#define BCM94712AP_BOARD 0x0445
960 +#define BCM94712P_BOARD 0x0446
961 +
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
968 +
969 +/* BCM63XX boards */
970 +#define BCM96338_BOARD 0x6338
971 +#define BCM96345_BOARD 0x6345
972 +#define BCM96348_BOARD 0x6348
973 +
974 +/* Another mp4306 with SiGe */
975 +#define BCM94306P_BOARD 0x044c
976 +
977 +/* CF-like 4317 modules */
978 +#define BCM94317CF_BOARD 0x044d
979 +
980 +/* mp4303 */
981 +#define BCM94303MP_BOARD 0x044e
982 +
983 +/* mpsgh4306 */
984 +#define BCM94306MPSGH_BOARD 0x044f
985 +
986 +/* BRCM 4306 w/ Front End Modules */
987 +#define BCM94306MPM 0x0450
988 +#define BCM94306MPL 0x0453
989 +
990 +/* 4712agr */
991 +#define BCM94712AGR_BOARD 0x0451
992 +
993 +/* The real CF 4317 board */
994 +#define CFI4317_BOARD 0x0452
995 +
996 +/* pcmcia 4303 */
997 +#define PC4303_BOARD 0x0454
998 +
999 +/* 5350K */
1000 +#define BCM95350K_BOARD 0x0455
1001 +
1002 +/* 5350R */
1003 +#define BCM95350R_BOARD 0x0456
1004 +
1005 +/* 4306mplna */
1006 +#define BCM94306MPLNA_BOARD 0x0457
1007 +
1008 +/* 4320 boards */
1009 +#define BU4320_BOARD 0x0458
1010 +#define BU4320S_BOARD 0x0459
1011 +#define BCM94320PH_BOARD 0x045a
1012 +
1013 +/* 4306mph */
1014 +#define BCM94306MPH_BOARD 0x045b
1015 +
1016 +/* 4306pciv */
1017 +#define BCM94306PCIV_BOARD 0x045c
1018 +
1019 +#define BU4712SD_BOARD 0x045d
1020 +
1021 +#define BCM94320PFLSH_BOARD 0x045e
1022 +
1023 +#define BU4712L_BOARD 0x045f
1024 +#define BCM94712LGR_BOARD 0x0460
1025 +#define BCM94320R_BOARD 0x0461
1026 +
1027 +#define BU5352_BOARD 0x0462
1028 +
1029 +#define BCM94318MPGH_BOARD 0x0463
1030 +
1031 +
1032 +#define BCM95352GR_BOARD 0x0467
1033 +
1034 +/* bcm95351agr */
1035 +#define BCM95351AGR_BOARD 0x0470
1036 +
1037 +/* # of GPIO pins */
1038 +#define GPIO_NUMPINS 16
1039 +
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
1044 @@ -0,0 +1,152 @@
1045 +/*
1046 + * local version of endian.h - byte order defines
1047 + *
1048 + * Copyright 2005, Broadcom Corporation
1049 + * All Rights Reserved.
1050 + *
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.
1055 + *
1056 + * $Id$
1057 +*/
1058 +
1059 +#ifndef _BCMENDIAN_H_
1060 +#define _BCMENDIAN_H_
1061 +
1062 +#include <typedefs.h>
1063 +
1064 +/* Byte swap a 16 bit value */
1065 +#define BCMSWAP16(val) \
1066 + ((uint16)( \
1067 + (((uint16)(val) & (uint16)0x00ffU) << 8) | \
1068 + (((uint16)(val) & (uint16)0xff00U) >> 8) ))
1069 +
1070 +/* Byte swap a 32 bit value */
1071 +#define BCMSWAP32(val) \
1072 + ((uint32)( \
1073 + (((uint32)(val) & (uint32)0x000000ffUL) << 24) | \
1074 + (((uint32)(val) & (uint32)0x0000ff00UL) << 8) | \
1075 + (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) | \
1076 + (((uint32)(val) & (uint32)0xff000000UL) >> 24) ))
1077 +
1078 +/* 2 Byte swap a 32 bit value */
1079 +#define BCMSWAP32BY16(val) \
1080 + ((uint32)( \
1081 + (((uint32)(val) & (uint32)0x0000ffffUL) << 16) | \
1082 + (((uint32)(val) & (uint32)0xffff0000UL) >> 16) ))
1083 +
1084 +
1085 +static INLINE uint16
1086 +bcmswap16(uint16 val)
1087 +{
1088 + return BCMSWAP16(val);
1089 +}
1090 +
1091 +static INLINE uint32
1092 +bcmswap32(uint32 val)
1093 +{
1094 + return BCMSWAP32(val);
1095 +}
1096 +
1097 +static INLINE uint32
1098 +bcmswap32by16(uint32 val)
1099 +{
1100 + return BCMSWAP32BY16(val);
1101 +}
1102 +
1103 +/* buf - start of buffer of shorts to swap */
1104 +/* len - byte length of buffer */
1105 +static INLINE void
1106 +bcmswap16_buf(uint16 *buf, uint len)
1107 +{
1108 + len = len/2;
1109 +
1110 + while(len--){
1111 + *buf = bcmswap16(*buf);
1112 + buf++;
1113 + }
1114 +}
1115 +
1116 +#ifndef hton16
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)
1127 +#else
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)
1137 +#endif
1138 +#endif
1139 +
1140 +#ifndef IL_BIGENDIAN
1141 +#define ltoh16_buf(buf, i)
1142 +#define htol16_buf(buf, i)
1143 +#else
1144 +#define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
1145 +#define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
1146 +#endif
1147 +
1148 +/*
1149 +* load 16-bit value from unaligned little endian byte array.
1150 +*/
1151 +static INLINE uint16
1152 +ltoh16_ua(uint8 *bytes)
1153 +{
1154 + return (bytes[1]<<8)+bytes[0];
1155 +}
1156 +
1157 +/*
1158 +* load 32-bit value from unaligned little endian byte array.
1159 +*/
1160 +static INLINE uint32
1161 +ltoh32_ua(uint8 *bytes)
1162 +{
1163 + return (bytes[3]<<24)+(bytes[2]<<16)+(bytes[1]<<8)+bytes[0];
1164 +}
1165 +
1166 +/*
1167 +* load 16-bit value from unaligned big(network) endian byte array.
1168 +*/
1169 +static INLINE uint16
1170 +ntoh16_ua(uint8 *bytes)
1171 +{
1172 + return (bytes[0]<<8)+bytes[1];
1173 +}
1174 +
1175 +/*
1176 +* load 32-bit value from unaligned big(network) endian byte array.
1177 +*/
1178 +static INLINE uint32
1179 +ntoh32_ua(uint8 *bytes)
1180 +{
1181 + return (bytes[0]<<24)+(bytes[1]<<16)+(bytes[2]<<8)+bytes[3];
1182 +}
1183 +
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] \
1188 +)
1189 +
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] \
1194 +)
1195 +
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
1200 @@ -0,0 +1,229 @@
1201 +/*
1202 + * Hardware-specific definitions for
1203 + * Broadcom BCM47XX 10/100 Mbps Ethernet cores.
1204 + *
1205 + * Copyright 2005, Broadcom Corporation
1206 + * All Rights Reserved.
1207 + *
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.
1212 + * $Id$
1213 + */
1214 +
1215 +#ifndef _bcmenet_47xx_h_
1216 +#define _bcmenet_47xx_h_
1217 +
1218 +#include <bcmenetmib.h>
1219 +#include <bcmenetrxh.h>
1220 +#include <bcmenetphy.h>
1221 +
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 */
1226 +
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 */
1233 +
1234 +/* cpp contortions to concatenate w/arg prescan */
1235 +#ifndef PAD
1236 +#define _PADLINE(line) pad ## line
1237 +#define _XSTR(line) _PADLINE(line)
1238 +#define PAD _XSTR(__LINE__)
1239 +#endif /* PAD */
1240 +
1241 +/*
1242 + * Host Interface Registers
1243 + */
1244 +typedef volatile struct _bcmenettregs {
1245 + /* Device and Power Control */
1246 + uint32 devcontrol;
1247 + uint32 PAD[2];
1248 + uint32 biststatus;
1249 + uint32 wakeuplength;
1250 + uint32 PAD[3];
1251 +
1252 + /* Interrupt Control */
1253 + uint32 intstatus;
1254 + uint32 intmask;
1255 + uint32 gptimer;
1256 + uint32 PAD[23];
1257 +
1258 + /* Ethernet MAC Address Filtering Control */
1259 + uint32 PAD[2];
1260 + uint32 enetftaddr;
1261 + uint32 enetftdata;
1262 + uint32 PAD[2];
1263 +
1264 + /* Ethernet MAC Control */
1265 + uint32 emactxmaxburstlen;
1266 + uint32 emacrxmaxburstlen;
1267 + uint32 emaccontrol;
1268 + uint32 emacflowcontrol;
1269 +
1270 + uint32 PAD[20];
1271 +
1272 + /* DMA Lazy Interrupt Control */
1273 + uint32 intrecvlazy;
1274 + uint32 PAD[63];
1275 +
1276 + /* DMA engine */
1277 + dma32regp_t dmaregs;
1278 + dma32diag_t dmafifo;
1279 + uint32 PAD[116];
1280 +
1281 + /* EMAC Registers */
1282 + uint32 rxconfig;
1283 + uint32 rxmaxlength;
1284 + uint32 txmaxlength;
1285 + uint32 PAD;
1286 + uint32 mdiocontrol;
1287 + uint32 mdiodata;
1288 + uint32 emacintmask;
1289 + uint32 emacintstatus;
1290 + uint32 camdatalo;
1291 + uint32 camdatahi;
1292 + uint32 camcontrol;
1293 + uint32 enetcontrol;
1294 + uint32 txcontrol;
1295 + uint32 txwatermark;
1296 + uint32 mibcontrol;
1297 + uint32 PAD[49];
1298 +
1299 + /* EMAC MIB counters */
1300 + bcmenetmib_t mib;
1301 +
1302 + uint32 PAD[585];
1303 +
1304 + /* Sonics SiliconBackplane config registers */
1305 + sbconfig_t sbconfig;
1306 +} bcmenetregs_t;
1307 +
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 */
1320 +
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)
1333 +
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 */
1348 +
1349 +/* emaccontrol */
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
1355 +
1356 +/* emacflowcontrol */
1357 +#define EMF_RFH_MASK 0xff /* rx fifo hi water mark */
1358 +#define EMF_PG ((uint32)1 << 15) /* enable pause frame generation */
1359 +
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 */
1364 +
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 */
1375 +
1376 +/* emac mdio control */
1377 +#define MC_MF_MASK 0x7f /* mdc frequency */
1378 +#define MC_PE ((uint32)1 << 7) /* mii preamble enable */
1379 +
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 */
1396 +
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 */
1401 +
1402 +/* emac cam data high */
1403 +#define CD_V ((uint32)1 << 16) /* valid bit */
1404 +
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 */
1413 +
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 */
1419 +
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 */
1425 +
1426 +/* emac mib control */
1427 +#define EMC_RZ ((uint32)1 << 0) /* autoclear on read */
1428 +
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
1433 @@ -0,0 +1,81 @@
1434 +/*
1435 + * Hardware-specific MIB definition for
1436 + * Broadcom Home Networking Division
1437 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1438 + *
1439 + * Copyright 2005, Broadcom Corporation
1440 + * All Rights Reserved.
1441 + *
1442 + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
1443 + * the contents of this file may not be disclosed to third parties, copied
1444 + * or duplicated in any form, in whole or in part, without the prior
1445 + * written permission of Broadcom Corporation.
1446 + * $Id$
1447 + */
1448 +
1449 +#ifndef _bcmenetmib_h_
1450 +#define _bcmenetmib_h_
1451 +
1452 +/* cpp contortions to concatenate w/arg prescan */
1453 +#ifndef PAD
1454 +#define _PADLINE(line) pad ## line
1455 +#define _XSTR(line) _PADLINE(line)
1456 +#define PAD _XSTR(__LINE__)
1457 +#endif /* PAD */
1458 +
1459 +/*
1460 + * EMAC MIB Registers
1461 + */
1462 +typedef volatile struct {
1463 + uint32 tx_good_octets;
1464 + uint32 tx_good_pkts;
1465 + uint32 tx_octets;
1466 + uint32 tx_pkts;
1467 + uint32 tx_broadcast_pkts;
1468 + uint32 tx_multicast_pkts;
1469 + uint32 tx_len_64;
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;
1487 + uint32 PAD[8];
1488 +
1489 + uint32 rx_good_octets;
1490 + uint32 rx_good_pkts;
1491 + uint32 rx_octets;
1492 + uint32 rx_pkts;
1493 + uint32 rx_broadcast_pkts;
1494 + uint32 rx_multicast_pkts;
1495 + uint32 rx_len_64;
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;
1512 +} bcmenetmib_t;
1513 +
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
1518 @@ -0,0 +1,58 @@
1519 +/*
1520 + * Misc Broadcom BCM47XX MDC/MDIO enet phy definitions.
1521 + *
1522 + * Copyright 2005, Broadcom Corporation
1523 + * All Rights Reserved.
1524 + *
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.
1529 + * $Id$
1530 + */
1531 +
1532 +#ifndef _bcmenetphy_h_
1533 +#define _bcmenetphy_h_
1534 +
1535 +/* phy address */
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 */
1540 +
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 */
1548 +
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 */
1553 +
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 */
1565 +
1566 +#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
1567 +#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
1568 +
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 */
1575 +
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
1580 @@ -0,0 +1,43 @@
1581 +/*
1582 + * Hardware-specific Receive Data Header for the
1583 + * Broadcom Home Networking Division
1584 + * BCM44XX and BCM47XX 10/100 Mbps Ethernet cores.
1585 + *
1586 + * Copyright 2005, Broadcom Corporation
1587 + * All Rights Reserved.
1588 + *
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.
1593 + * $Id$
1594 + */
1595 +
1596 +#ifndef _bcmenetrxh_h_
1597 +#define _bcmenetrxh_h_
1598 +
1599 +/*
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.
1604 + */
1605 +typedef volatile struct {
1606 + uint16 len;
1607 + uint16 flags;
1608 + uint16 pad[12];
1609 +} bcmenetrxh_t;
1610 +
1611 +#define RXHDR_LEN 28
1612 +
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 */
1622 +
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
1627 @@ -0,0 +1,141 @@
1628 +/*
1629 + * NVRAM variable manipulation
1630 + *
1631 + * Copyright 2005, Broadcom Corporation
1632 + * All Rights Reserved.
1633 + *
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.
1638 + *
1639 + * $Id$
1640 + */
1641 +
1642 +#ifndef _bcmnvram_h_
1643 +#define _bcmnvram_h_
1644 +
1645 +#ifndef _LANGUAGE_ASSEMBLY
1646 +
1647 +#include <typedefs.h>
1648 +
1649 +struct nvram_header {
1650 + uint32 magic;
1651 + uint32 len;
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 */
1655 +};
1656 +
1657 +struct nvram_tuple {
1658 + char *name;
1659 + char *value;
1660 + struct nvram_tuple *next;
1661 +};
1662 +
1663 +/*
1664 + * Initialize NVRAM access. May be unnecessary or undefined on certain
1665 + * platforms.
1666 + */
1667 +extern int BCMINIT(nvram_init)(void *sbh);
1668 +
1669 +/*
1670 + * Disable NVRAM access. May be unnecessary or undefined on certain
1671 + * platforms.
1672 + */
1673 +extern void BCMINIT(nvram_exit)(void *sbh);
1674 +
1675 +/*
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
1680 + */
1681 +extern char * BCMINIT(nvram_get)(const char *name);
1682 +
1683 +/*
1684 + * Read the reset GPIO value from the nvram and set the GPIO
1685 + * as input
1686 + */
1687 +extern int BCMINITFN(nvram_resetgpio_init)(void *sbh);
1688 +
1689 +/*
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
1693 + */
1694 +#define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "")
1695 +
1696 +/*
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
1702 + */
1703 +static INLINE int
1704 +nvram_match(char *name, char *match) {
1705 + const char *value = BCMINIT(nvram_get)(name);
1706 + return (value && !strcmp(value, match));
1707 +}
1708 +
1709 +/*
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
1715 + */
1716 +static INLINE int
1717 +nvram_invmatch(char *name, char *invmatch) {
1718 + const char *value = BCMINIT(nvram_get)(name);
1719 + return (value && strcmp(value, invmatch));
1720 +}
1721 +
1722 +/*
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
1730 + */
1731 +extern int BCMINIT(nvram_set)(const char *name, const char *value);
1732 +
1733 +/*
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.
1739 + */
1740 +extern int BCMINIT(nvram_unset)(const char *name);
1741 +
1742 +/*
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
1747 + */
1748 +extern int BCMINIT(nvram_commit)(void);
1749 +
1750 +/*
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
1755 + */
1756 +extern int BCMINIT(nvram_getall)(char *buf, int count);
1757 +
1758 +#endif /* _LANGUAGE_ASSEMBLY */
1759 +
1760 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
1761 +#define NVRAM_VERSION 1
1762 +#define NVRAM_HEADER_SIZE 20
1763 +#define NVRAM_SPACE 0x8000
1764 +
1765 +#define NVRAM_MAX_VALUE_LEN 255
1766 +#define NVRAM_MAX_PARAM_LEN 64
1767 +
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
1772 @@ -0,0 +1,25 @@
1773 +/*
1774 + * Misc system wide parameters.
1775 + *
1776 + * Copyright 2005, Broadcom Corporation
1777 + * All Rights Reserved.
1778 + *
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.
1783 + * $Id$
1784 + */
1785 +
1786 +#ifndef _bcmparams_h_
1787 +#define _bcmparams_h_
1788 +
1789 +#define VLAN_MAXVID 15 /* Max. VLAN ID supported/allowed */
1790 +
1791 +#define VLAN_NUMPRIS 8 /* # of prio, start from 0 */
1792 +
1793 +#define DEV_NUMIFS 16 /* Max. # of devices/interfaces supported */
1794 +
1795 +#define WL_MAXBSSCFG 16 /* maximum number of BSS Configs we can configure */
1796 +
1797 +#endif
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
1801 @@ -0,0 +1,23 @@
1802 +/*
1803 + * Misc useful routines to access NIC local SROM/OTP .
1804 + *
1805 + * Copyright 2005, Broadcom Corporation
1806 + * All Rights Reserved.
1807 + *
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.
1812 + *
1813 + * $Id$
1814 + */
1815 +
1816 +#ifndef _bcmsrom_h_
1817 +#define _bcmsrom_h_
1818 +
1819 +extern int srom_var_init(void *sbh, uint bus, void *curmap, osl_t *osh, char **vars, int *count);
1820 +
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);
1823 +
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
1828 @@ -0,0 +1,313 @@
1829 +/*
1830 + * Misc useful os-independent macros and functions.
1831 + *
1832 + * Copyright 2005, Broadcom Corporation
1833 + * All Rights Reserved.
1834 + *
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.
1839 + * $Id$
1840 + */
1841 +
1842 +#ifndef _bcmutils_h_
1843 +#define _bcmutils_h_
1844 +
1845 +/*** driver-only section ***/
1846 +#ifdef BCMDRIVER
1847 +#include <osl.h>
1848 +
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) */
1857 +
1858 +#define GPIO_PIN_NOTDEFINED 0x20
1859 +
1860 +extern unsigned char bcm_ctype[];
1861 +#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
1862 +
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)
1874 +
1875 +/*
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.
1879 + */
1880 +#define SPINWAIT(exp, us) { \
1881 + uint countdown = (us) + 9; \
1882 + while ((exp) && (countdown >= 10)) {\
1883 + OSL_DELAY(10); \
1884 + countdown -= 10; \
1885 + } \
1886 +}
1887 +
1888 +/* generic osl packet queue */
1889 +struct pktq {
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 */
1896 +};
1897 +#define DEFAULT_QLEN 128
1898 +
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))
1905 +
1906 +/* externs */
1907 +/* packet */
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);
1914 +/* string */
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);
1924 +/* delay */
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
1933 +
1934 +#endif /* #ifdef BCMDRIVER */
1935 +
1936 +/*** driver/apps-shared section ***/
1937 +
1938 +#define BCME_STRLEN 64
1939 +#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST))
1940 +
1941 +
1942 +/*
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
1948 +*/
1949 +
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
1981 +
1982 +#ifndef ABS
1983 +#define ABS(a) (((a)<0)?-(a):(a))
1984 +#endif
1985 +
1986 +#ifndef MIN
1987 +#define MIN(a, b) (((a)<(b))?(a):(b))
1988 +#endif
1989 +
1990 +#ifndef MAX
1991 +#define MAX(a, b) (((a)>(b))?(a):(b))
1992 +#endif
1993 +
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]))
2001 +
2002 +/* bit map related macros */
2003 +#ifndef setbit
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)
2009 +#endif
2010 +
2011 +#define NBITS(type) (sizeof(type) * 8)
2012 +#define NBITVAL(bits) (1 << (bits))
2013 +#define MAXBITVAL(bits) ((1 << (bits)) - 1)
2014 +
2015 +/* crc defines */
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 */
2022 +
2023 +/* bcm_format_flags() bit description structure */
2024 +typedef struct bcm_bit_desc {
2025 + uint32 bit;
2026 + char* name;
2027 +} bcm_bit_desc_t;
2028 +
2029 +/* tag_ID/length/value_buffer tuple */
2030 +typedef struct bcm_tlv {
2031 + uint8 id;
2032 + uint8 len;
2033 + uint8 data[1];
2034 +} bcm_tlv_t;
2035 +
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))
2038 +
2039 +/* buffer length for ethernet address from bcm_ether_ntoa() */
2040 +#define ETHER_ADDR_STR_LEN 18
2041 +
2042 +/* unaligned load and store macros */
2043 +#ifdef IL_BIGENDIAN
2044 +static INLINE uint32
2045 +load32_ua(uint8 *a)
2046 +{
2047 + return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
2048 +}
2049 +
2050 +static INLINE void
2051 +store32_ua(uint8 *a, uint32 v)
2052 +{
2053 + a[0] = (v >> 24) & 0xff;
2054 + a[1] = (v >> 16) & 0xff;
2055 + a[2] = (v >> 8) & 0xff;
2056 + a[3] = v & 0xff;
2057 +}
2058 +
2059 +static INLINE uint16
2060 +load16_ua(uint8 *a)
2061 +{
2062 + return ((a[0] << 8) | a[1]);
2063 +}
2064 +
2065 +static INLINE void
2066 +store16_ua(uint8 *a, uint16 v)
2067 +{
2068 + a[0] = (v >> 8) & 0xff;
2069 + a[1] = v & 0xff;
2070 +}
2071 +
2072 +#else
2073 +
2074 +static INLINE uint32
2075 +load32_ua(uint8 *a)
2076 +{
2077 + return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
2078 +}
2079 +
2080 +static INLINE void
2081 +store32_ua(uint8 *a, uint32 v)
2082 +{
2083 + a[3] = (v >> 24) & 0xff;
2084 + a[2] = (v >> 16) & 0xff;
2085 + a[1] = (v >> 8) & 0xff;
2086 + a[0] = v & 0xff;
2087 +}
2088 +
2089 +static INLINE uint16
2090 +load16_ua(uint8 *a)
2091 +{
2092 + return ((a[1] << 8) | a[0]);
2093 +}
2094 +
2095 +static INLINE void
2096 +store16_ua(uint8 *a, uint16 v)
2097 +{
2098 + a[1] = (v >> 8) & 0xff;
2099 + a[0] = v & 0xff;
2100 +}
2101 +
2102 +#endif
2103 +
2104 +/* externs */
2105 +/* crc */
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);
2109 +/* format/print */
2110 +/* IE parsing */
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);
2114 +
2115 +/* bcmerror*/
2116 +extern const char *bcmerrorstr(int bcmerror);
2117 +
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)))
2124 +
2125 +/* power conversion */
2126 +extern uint16 bcm_qdbm_to_mw(uint8 qdbm);
2127 +extern uint8 bcm_mw_to_qdbm(uint16 mw);
2128 +
2129 +/* generic datastruct to help dump routines */
2130 +struct fielddesc {
2131 + char *nameandfmt;
2132 + uint32 offset;
2133 + uint32 len;
2134 +};
2135 +
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);
2138 +
2139 +extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len);
2140 +
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
2145 @@ -0,0 +1,85 @@
2146 +/*
2147 + * bit manipulation utility functions
2148 + *
2149 + * Copyright 2005, Broadcom Corporation
2150 + * All Rights Reserved.
2151 + *
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.
2156 + * $Id$
2157 + */
2158 +
2159 +#ifndef _BITFUNCS_H
2160 +#define _BITFUNCS_H
2161 +
2162 +#include <typedefs.h>
2163 +
2164 +/* local prototypes */
2165 +static INLINE uint32 find_msbit(uint32 x);
2166 +
2167 +
2168 +/*
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.
2171 + */
2172 +
2173 +#if defined(USE_PENTIUM_BSR) && defined(__GNUC__)
2174 +
2175 +/*
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.
2180 + */
2181 +static INLINE uint32 find_msbit(uint32 x)
2182 +{
2183 + uint msbit;
2184 + __asm__("bsrl %1,%0"
2185 + :"=r" (msbit)
2186 + :"r" (x));
2187 + return msbit;
2188 +}
2189 +
2190 +#else
2191 +
2192 +/*
2193 + * Generic Implementation
2194 + */
2195 +
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
2201 +
2202 +static INLINE uint32 find_msbit(uint32 x)
2203 +{
2204 + uint32 temp_x = x;
2205 + uint msbit = 0;
2206 + if (temp_x & DB_POW_MASK16) {
2207 + temp_x >>= 16;
2208 + msbit = 16;
2209 + }
2210 + if (temp_x & DB_POW_MASK8) {
2211 + temp_x >>= 8;
2212 + msbit += 8;
2213 + }
2214 + if (temp_x & DB_POW_MASK4) {
2215 + temp_x >>= 4;
2216 + msbit += 4;
2217 + }
2218 + if (temp_x & DB_POW_MASK2) {
2219 + temp_x >>= 2;
2220 + msbit += 2;
2221 + }
2222 + if (temp_x & DB_POW_MASK1) {
2223 + msbit += 1;
2224 + }
2225 + return(msbit);
2226 +}
2227 +
2228 +#endif
2229 +
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
2234 @@ -0,0 +1,191 @@
2235 +/*
2236 + * CFE boot loader OS Abstraction Layer.
2237 + *
2238 + * Copyright 2005, Broadcom Corporation
2239 + * All Rights Reserved.
2240 + *
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.
2245 + *
2246 + * $Id$
2247 + */
2248 +
2249 +#ifndef _cfe_osl_h_
2250 +#define _cfe_osl_h_
2251 +
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>
2261 +
2262 +#include <typedefs.h>
2263 +
2264 +/* dump string */
2265 +extern int (*xprinthook)(const char *str);
2266 +#define puts(str) do { if (xprinthook) xprinthook(str); } while (0)
2267 +
2268 +/* assert and panic */
2269 +#define ASSERT(exp) do {} while (0)
2270 +
2271 +/* PCMCIA attribute space access macros */
2272 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
2273 + bzero(buf, size)
2274 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
2275 + do {} while (0)
2276 +
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) \
2281 + do {} while (0)
2282 +
2283 +/* PCI device bus # and slot # */
2284 +#define OSL_PCI_BUS(osh) (0)
2285 +#define OSL_PCI_SLOT(osh) (0)
2286 +
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))
2295 +#else
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))
2300 +#endif
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; \
2307 + } \
2308 + __osl_v; \
2309 +})
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; \
2315 + } \
2316 +} while (0)
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))
2319 +
2320 +/* bcopy, bcmp, and bzero */
2321 +#define bcmp(b1, b2, len) lib_memcmp((b1), (b2), (len))
2322 +
2323 +#define osl_attach(pdev) ((osl_t*)pdev)
2324 +#define osl_detach(osh)
2325 +
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)
2332 +
2333 +/* uncached virtual address */
2334 +#define OSL_UNCACHED(va) ((void*)UNCADDR((ulong)(va)))
2335 +
2336 +/* host/bus architecture-specific address byte swap */
2337 +#define BUS_SWAP32(v) (v)
2338 +
2339 +/* get processor cycle count */
2340 +#define OSL_GETCYCLES(x) ((x) = 0)
2341 +
2342 +/* microsecond delay */
2343 +#define OSL_DELAY(usec) cfe_usleep((cfe_cpu_speed/CPUCFG_CYCLESPERCPUTICK/1000000*(usec)))
2344 +
2345 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
2346 +
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)
2350 +
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);
2354 +
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);
2363 +
2364 +/* map/unmap direction */
2365 +#define DMA_TX 1
2366 +#define DMA_RX 2
2367 +
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)); \
2372 +})
2373 +#define DMA_UNMAP(osh, pa, size, direction, p) \
2374 + do {} while (0)
2375 +
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))
2380 +
2381 +/* generic packet structure */
2382 +#define LBUFSZ 4096
2383 +#define LBDATASZ (LBUFSZ - sizeof(struct lbuf))
2384 +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 */
2393 +};
2394 +
2395 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
2396 +#define PKTBUFSZ 2048
2397 +
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);
2424 +
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
2429 @@ -0,0 +1,69 @@
2430 +/*
2431 + * Copyright 2005, Broadcom Corporation
2432 + * All Rights Reserved.
2433 + *
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.
2438 + *
2439 + * $Id$
2440 + *
2441 +*/
2442 +
2443 +#ifndef _epivers_h_
2444 +#define _epivers_h_
2445 +
2446 +#ifdef linux
2447 +#include <linux/config.h>
2448 +#endif
2449 +
2450 +/* Vendor Name, ASCII, 32 chars max */
2451 +#ifdef COMPANYNAME
2452 +#define HPNA_VENDOR COMPANYNAME
2453 +#else
2454 +#define HPNA_VENDOR "Broadcom Corporation"
2455 +#endif
2456 +
2457 +/* Driver Date, ASCII, 32 chars max */
2458 +#define HPNA_DRV_BUILD_DATE __DATE__
2459 +
2460 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2461 +#define HPNA_HW_MFG_DATE "Not Specified"
2462 +
2463 +/* See documentation for Device Type values, 32 values max */
2464 +#ifndef HPNA_DEV_TYPE
2465 +
2466 +#if defined(CONFIG_BRCM_VJ)
2467 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2468 +
2469 +#elif defined(CONFIG_BCRM_93725)
2470 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2471 +
2472 +#else
2473 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2474 +
2475 +#endif
2476 +
2477 +#endif /* !HPNA_DEV_TYPE */
2478 +
2479 +
2480 +#define EPI_MAJOR_VERSION 3
2481 +
2482 +#define EPI_MINOR_VERSION 130
2483 +
2484 +#define EPI_RC_NUMBER 20
2485 +
2486 +#define EPI_INCREMENTAL_NUMBER 0
2487 +
2488 +#define EPI_BUILD_NUMBER 0
2489 +
2490 +#define EPI_VERSION 3,130,20,0
2491 +
2492 +#define EPI_VERSION_NUM 0x03821400
2493 +
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"
2497 +
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
2502 @@ -0,0 +1,69 @@
2503 +/*
2504 + * Copyright 2005, Broadcom Corporation
2505 + * All Rights Reserved.
2506 + *
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.
2511 + *
2512 + * $Id$
2513 + *
2514 +*/
2515 +
2516 +#ifndef _epivers_h_
2517 +#define _epivers_h_
2518 +
2519 +#ifdef linux
2520 +#include <linux/config.h>
2521 +#endif
2522 +
2523 +/* Vendor Name, ASCII, 32 chars max */
2524 +#ifdef COMPANYNAME
2525 +#define HPNA_VENDOR COMPANYNAME
2526 +#else
2527 +#define HPNA_VENDOR "Broadcom Corporation"
2528 +#endif
2529 +
2530 +/* Driver Date, ASCII, 32 chars max */
2531 +#define HPNA_DRV_BUILD_DATE __DATE__
2532 +
2533 +/* Hardware Manufacture Date, ASCII, 32 chars max */
2534 +#define HPNA_HW_MFG_DATE "Not Specified"
2535 +
2536 +/* See documentation for Device Type values, 32 values max */
2537 +#ifndef HPNA_DEV_TYPE
2538 +
2539 +#if defined(CONFIG_BRCM_VJ)
2540 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
2541 +
2542 +#elif defined(CONFIG_BCRM_93725)
2543 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
2544 +
2545 +#else
2546 +#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
2547 +
2548 +#endif
2549 +
2550 +#endif /* !HPNA_DEV_TYPE */
2551 +
2552 +
2553 +#define EPI_MAJOR_VERSION @EPI_MAJOR_VERSION@
2554 +
2555 +#define EPI_MINOR_VERSION @EPI_MINOR_VERSION@
2556 +
2557 +#define EPI_RC_NUMBER @EPI_RC_NUMBER@
2558 +
2559 +#define EPI_INCREMENTAL_NUMBER @EPI_INCREMENTAL_NUMBER@
2560 +
2561 +#define EPI_BUILD_NUMBER @EPI_BUILD_NUMBER@
2562 +
2563 +#define EPI_VERSION @EPI_VERSION@
2564 +
2565 +#define EPI_VERSION_NUM @EPI_VERSION_NUM@
2566 +
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@"
2570 +
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
2575 @@ -0,0 +1,59 @@
2576 +/*
2577 + * Driver-specific socket ioctls
2578 + * used by BSD, Linux, and PSOS
2579 + * Broadcom BCM44XX 10/100Mbps Ethernet Device Driver
2580 + *
2581 + * Copyright 2005, Broadcom Corporation
2582 + * All Rights Reserved.
2583 + *
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.
2588 + *
2589 + * $Id$
2590 + */
2591 +
2592 +#ifndef _etsockio_h_
2593 +#define _etsockio_h_
2594 +
2595 +/* THESE MUST BE CONTIGUOUS AND CONSISTENT WITH VALUES IN ETC.H */
2596 +
2597 +
2598 +#if defined(linux)
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)
2611 +
2612 +#else /* !linux */
2613 +
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)
2623 +
2624 +#endif
2625 +
2626 +/* arg to SIOCTXGEN */
2627 +struct txg {
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 */
2632 +};
2633 +
2634 +#endif
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
2638 @@ -0,0 +1,188 @@
2639 +/*
2640 + * flash.h: Common definitions for flash access.
2641 + *
2642 + * Copyright 2005, Broadcom Corporation
2643 + * All Rights Reserved.
2644 + *
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.
2649 + *
2650 + * $Id$
2651 + */
2652 +
2653 +/* Types of flashes we know about */
2654 +typedef enum _flash_type {OLD, BSC, SCS, AMD, SST, SFLASH} flash_type_t;
2655 +
2656 +/* Commands to write/erase the flases */
2657 +typedef struct _flash_cmds{
2658 + flash_type_t type;
2659 + bool need_unlock;
2660 + uint16 pre_erase;
2661 + uint16 erase_block;
2662 + uint16 erase_chip;
2663 + uint16 write_word;
2664 + uint16 write_buf;
2665 + uint16 clear_csr;
2666 + uint16 read_csr;
2667 + uint16 read_id;
2668 + uint16 confirm;
2669 + uint16 read_array;
2670 +} flash_cmds_t;
2671 +
2672 +#define UNLOCK_CMD_WORDS 2
2673 +
2674 +typedef struct _unlock_cmd {
2675 + uint addr[UNLOCK_CMD_WORDS];
2676 + uint16 cmd[UNLOCK_CMD_WORDS];
2677 +} unlock_cmd_t;
2678 +
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 */
2693 +} flash_desc_t;
2694 +
2695 +
2696 +#ifdef DECLARE_FLASHES
2697 +flash_cmds_t sflash_cmd_t =
2698 + { SFLASH, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2699 +
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 },
2706 + { 0 }
2707 +};
2708 +
2709 +unlock_cmd_t unlock_cmd_amd = {
2710 +#ifdef MIPSEB
2711 +/* addr: */ { 0x0aa8, 0x0556},
2712 +#else
2713 +/* addr: */ { 0x0aaa, 0x0554},
2714 +#endif
2715 +/* data: */ { 0xaa, 0x55}
2716 +};
2717 +
2718 +unlock_cmd_t unlock_cmd_sst = {
2719 +#ifdef MIPSEB
2720 +/* addr: */ { 0xaaa8, 0x5556},
2721 +#else
2722 +/* addr: */ { 0xaaaa, 0x5554},
2723 +#endif
2724 +/* data: */ { 0xaa, 0x55}
2725 +};
2726 +
2727 +#define AMD_CMD 0xaaa
2728 +#define SST_CMD 0xaaaa
2729 +
2730 +/* intel unlock block cmds */
2731 +#define INTEL_UNLOCK1 0x60
2732 +#define INTEL_UNLOCK2 0xD0
2733 +
2734 +/* Just eight blocks of 8KB byte each */
2735 +
2736 +uint blk8x8k[] = { 0x00000000,
2737 + 0x00002000,
2738 + 0x00004000,
2739 + 0x00006000,
2740 + 0x00008000,
2741 + 0x0000a000,
2742 + 0x0000c000,
2743 + 0x0000e000,
2744 + 0x00010000
2745 +};
2746 +
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 */
2756 + 0x00020000
2757 +};
2758 +
2759 +/* AMD arrangement for 29xx160's */
2760 +uint amd4112[] = { 0x00000000, /* 32KB */
2761 + 0x00008000, /* 8KB */
2762 + 0x0000a000, /* 8KB */
2763 + 0x0000c000, /* 16KB */
2764 + 0x00010000
2765 +};
2766 +uint amd2114[] = { 0x00000000, /* 16KB */
2767 + 0x00004000, /* 8KB */
2768 + 0x00006000, /* 8KB */
2769 + 0x00008000, /* 32KB */
2770 + 0x00010000
2771 +};
2772 +
2773 +
2774 +flash_desc_t sflash_desc =
2775 + { 0, 0, 0, 0, SFLASH, 0, 0, 0, 0, 0, NULL, "SFLASH" };
2776 +
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 },
2818 +};
2819 +
2820 +#else
2821 +
2822 +extern flash_cmds_t flash_cmds[];
2823 +extern unlock_cmd_t unlock_cmd;
2824 +extern flash_desc_t flashes[];
2825 +
2826 +#endif
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
2830 @@ -0,0 +1,27 @@
2831 +/*
2832 + * BCM47XX FLASH driver interface
2833 + *
2834 + * Copyright 2005, Broadcom Corporation
2835 + * All Rights Reserved.
2836 + *
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.
2841 + * $Id$
2842 + */
2843 +
2844 +#ifndef _flashutl_h_
2845 +#define _flashutl_h_
2846 +
2847 +
2848 +#ifndef _LANGUAGE_ASSEMBLY
2849 +
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);
2854 +
2855 +#endif /* _LANGUAGE_ASSEMBLY */
2856 +
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
2861 @@ -0,0 +1,71 @@
2862 +/*
2863 + * Generic Broadcom Home Networking Division (HND) DMA engine SW interface
2864 + * This supports the following chips: BCM42xx, 44xx, 47xx .
2865 + *
2866 + * Copyright 2005, Broadcom Corporation
2867 + * All Rights Reserved.
2868 + *
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.
2873 + * $Id$
2874 + */
2875 +
2876 +#ifndef _hnddma_h_
2877 +#define _hnddma_h_
2878 +
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 */
2886 +} hnddma_t;
2887 +
2888 +#ifndef di_t
2889 +#define di_t void
2890 +#endif
2891 +
2892 +#ifndef osl_t
2893 +#define osl_t void
2894 +#endif
2895 +
2896 +/* externs */
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);
2927 +
2928 +extern void dma_rxpiomode(dma32regs_t *);
2929 +extern void dma_txpioloopback(dma32regs_t *);
2930 +
2931 +
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
2936 @@ -0,0 +1,16 @@
2937 +/*
2938 + * Alternate include file for HND sbmips.h since CFE also ships with
2939 + * a sbmips.h.
2940 + *
2941 + * Copyright 2005, Broadcom Corporation
2942 + * All Rights Reserved.
2943 + *
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.
2948 + *
2949 + * $Id$
2950 + */
2951 +
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
2956 @@ -0,0 +1,371 @@
2957 +/*
2958 + * Linux OS Independent Layer
2959 + *
2960 + * Copyright 2005, Broadcom Corporation
2961 + * All Rights Reserved.
2962 + *
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.
2967 + *
2968 + * $Id$
2969 + */
2970 +
2971 +#ifndef _linux_osl_h_
2972 +#define _linux_osl_h_
2973 +
2974 +#include <typedefs.h>
2975 +
2976 +/* use current 2.4.x calling conventions */
2977 +#include <linuxver.h>
2978 +
2979 +/* assert and panic */
2980 +#ifdef __GNUC__
2981 +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
2982 +#if GCC_VERSION > 30100
2983 +#define ASSERT(exp) do {} while (0)
2984 +#else
2985 +/* ASSERT could causes segmentation fault on GCC3.1, use empty instead*/
2986 +#define ASSERT(exp)
2987 +#endif
2988 +#endif
2989 +
2990 +/* microsecond delay */
2991 +#define OSL_DELAY(usec) osl_delay(usec)
2992 +extern void osl_delay(uint usec);
2993 +
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 */
3002 +};
3003 +#endif
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);
3010 +
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);
3018 +
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);
3024 +
3025 +/* OSL initialization */
3026 +extern osl_t *osl_attach(void *pdev);
3027 +extern void osl_detach(osl_t *osh);
3028 +
3029 +/* host/bus architecture-specific byte swap */
3030 +#define BUS_SWAP32(v) (v)
3031 +
3032 +/* general purpose memory allocation */
3033 +
3034 +#if defined(BCMDBG_MEM)
3035 +
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);
3043 +
3044 +#else
3045 +
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))
3049 +
3050 +#endif /* BCMDBG_MEM */
3051 +
3052 +#define MALLOC_FAILED(osh) osl_malloc_failed((osh))
3053 +
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);
3058 +
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);
3067 +
3068 +/* map/unmap direction */
3069 +#define DMA_TX 1
3070 +#define DMA_RX 2
3071 +
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);
3079 +
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)))
3085 +#endif
3086 +
3087 +/*
3088 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
3089 + * Macros expand to calls to functions defined in linux_osl.c .
3090 + */
3091 +#ifndef BINOSL
3092 +
3093 +/* string library, kernel mode */
3094 +#define printf(fmt, args...) printk(fmt, ## args)
3095 +#include <linux/kernel.h>
3096 +#include <linux/string.h>
3097 +
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)) \
3105 +)
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; \
3111 + } \
3112 +} while (0)
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; \
3120 + } \
3121 + __osl_v; \
3122 +})
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; \
3128 + } \
3129 +} while (0)
3130 +#endif
3131 +#endif
3132 +
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))
3135 +
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))
3140 +
3141 +/* uncached virtual address */
3142 +#ifdef mips
3143 +#define OSL_UNCACHED(va) KSEG1ADDR((va))
3144 +#include <asm/addrspace.h>
3145 +#else
3146 +#define OSL_UNCACHED(va) (va)
3147 +#endif
3148 +
3149 +/* get processor cycle count */
3150 +#if defined(mips)
3151 +#define OSL_GETCYCLES(x) ((x) = read_c0_count() * 2)
3152 +#elif defined(__i386__)
3153 +#define OSL_GETCYCLES(x) rdtscl((x))
3154 +#else
3155 +#define OSL_GETCYCLES(x) ((x) = 0)
3156 +#endif
3157 +
3158 +/* dereference an address that may cause a bus exception */
3159 +#ifdef mips
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")
3162 +#else
3163 +#define BUSPROBE(val, addr) get_dbe((val), (addr))
3164 +#include <asm/paccess.h>
3165 +#endif
3166 +#else
3167 +#define BUSPROBE(val, addr) ({ (val) = R_REG((addr)); 0; })
3168 +#endif
3169 +
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))
3173 +
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))
3178 +
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);
3200 +
3201 +#else /* BINOSL */
3202 +
3203 +/* string library */
3204 +#ifndef LINUX_OSL
3205 +#undef printf
3206 +#define printf(fmt, args...) osl_printf((fmt), ## args)
3207 +#undef sprintf
3208 +#define sprintf(buf, fmt, args...) osl_sprintf((buf), (fmt), ## args)
3209 +#undef strcmp
3210 +#define strcmp(s1, s2) osl_strcmp((s1), (s2))
3211 +#undef strncmp
3212 +#define strncmp(s1, s2, n) osl_strncmp((s1), (s2), (n))
3213 +#undef strlen
3214 +#define strlen(s) osl_strlen((s))
3215 +#undef strcpy
3216 +#define strcpy(d, s) osl_strcpy((d), (s))
3217 +#undef strncpy
3218 +#define strncpy(d, s, n) osl_strncpy((d), (s), (n))
3219 +#endif
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);
3227 +
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)) \
3234 +)
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; \
3240 + } \
3241 +} while (0)
3242 +#endif
3243 +
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);
3252 +
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);
3257 +
3258 +/* uncached virtual address */
3259 +#define OSL_UNCACHED(va) osl_uncached((va))
3260 +extern void *osl_uncached(void *va);
3261 +
3262 +/* get processor cycle count */
3263 +#define OSL_GETCYCLES(x) ((x) = osl_getcycles())
3264 +extern uint osl_getcycles(void);
3265 +
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);
3269 +
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);
3275 +
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))
3280 +
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);
3318 +
3319 +#endif /* BINOSL */
3320 +
3321 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
3322 +extern int osl_error(int bcmerror);
3323 +
3324 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
3325 +#define PKTBUFSZ 2048
3326 +
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
3331 @@ -0,0 +1,411 @@
3332 +/*
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.
3335 + *
3336 + * Copyright 2005, Broadcom Corporation
3337 + * All Rights Reserved.
3338 + *
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.
3343 + *
3344 + * $Id$
3345 + */
3346 +
3347 +#ifndef _linuxver_h_
3348 +#define _linuxver_h_
3349 +
3350 +#include <linux/config.h>
3351 +#include <linux/version.h>
3352 +
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__
3357 +#else
3358 +#define __NO_VERSION__
3359 +#endif
3360 +#endif
3361 +
3362 +#if defined(MODULE) && defined(MODVERSIONS)
3363 +#include <linux/modversions.h>
3364 +#endif
3365 +
3366 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
3367 +#include <linux/moduleparam.h>
3368 +#endif
3369 +
3370 +
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_))
3374 +#endif
3375 +
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>
3379 +#else
3380 +#include <linux/slab.h>
3381 +#endif
3382 +
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>
3391 +
3392 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41))
3393 +#include <linux/workqueue.h>
3394 +#else
3395 +#include <linux/tqueue.h>
3396 +#ifndef work_struct
3397 +#define work_struct tq_struct
3398 +#endif
3399 +#ifndef INIT_WORK
3400 +#define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
3401 +#endif
3402 +#ifndef schedule_work
3403 +#define schedule_work(_work) schedule_task((_work))
3404 +#endif
3405 +#ifndef flush_scheduled_work
3406 +#define flush_scheduled_work() flush_scheduled_tasks()
3407 +#endif
3408 +#endif
3409 +
3410 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
3411 +/* Some distributions have their own 2.6.x compatibility layers */
3412 +#ifndef IRQ_NONE
3413 +typedef void irqreturn_t;
3414 +#define IRQ_NONE
3415 +#define IRQ_HANDLED
3416 +#define IRQ_RETVAL(x)
3417 +#endif
3418 +#else
3419 +typedef irqreturn_t (*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs);
3420 +#endif
3421 +
3422 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
3423 +
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>
3430 +
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. */
3434 +static inline void
3435 +cs_error(client_handle_t handle, int func, int ret)
3436 +{
3437 + error_info_t err = { func, ret };
3438 + CardServices(ReportError, handle, &err);
3439 +}
3440 +#endif
3441 +
3442 +#endif /* CONFIG_PCMCIA */
3443 +
3444 +#ifndef __exit
3445 +#define __exit
3446 +#endif
3447 +#ifndef __devexit
3448 +#define __devexit
3449 +#endif
3450 +#ifndef __devinit
3451 +#define __devinit __init
3452 +#endif
3453 +#ifndef __devinitdata
3454 +#define __devinitdata
3455 +#endif
3456 +#ifndef __devexit_p
3457 +#define __devexit_p(x) x
3458 +#endif
3459 +
3460 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
3461 +
3462 +#define pci_get_drvdata(dev) (dev)->sysdata
3463 +#define pci_set_drvdata(dev, value) (dev)->sysdata=(value)
3464 +
3465 +/*
3466 + * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
3467 + */
3468 +
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 */
3474 +};
3475 +
3476 +struct pci_driver {
3477 + struct list_head node;
3478 + char *name;
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 */
3484 +};
3485 +
3486 +#define MODULE_DEVICE_TABLE(type, name)
3487 +#define PCI_ANY_ID (~0)
3488 +
3489 +/* compatpci.c */
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);
3493 +
3494 +#endif /* PCI registration */
3495 +
3496 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
3497 +#ifdef MODULE
3498 +#define module_init(x) int init_module(void) { return x(); }
3499 +#define module_exit(x) void cleanup_module(void) { x(); }
3500 +#else
3501 +#define module_init(x) __initcall(x);
3502 +#define module_exit(x) __exitcall(x);
3503 +#endif
3504 +#endif
3505 +
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)
3509 +#endif
3510 +
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)
3515 +#endif
3516 +
3517 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,23))
3518 +#define pci_enable_device(dev) do { } while (0)
3519 +#endif
3520 +
3521 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,14))
3522 +#define net_device device
3523 +#endif
3524 +
3525 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,42))
3526 +
3527 +/*
3528 + * DMA mapping
3529 + *
3530 + * See linux/Documentation/DMA-mapping.txt
3531 + */
3532 +
3533 +#ifndef PCI_DMA_TODEVICE
3534 +#define PCI_DMA_TODEVICE 1
3535 +#define PCI_DMA_FROMDEVICE 2
3536 +#endif
3537 +
3538 +typedef u32 dma_addr_t;
3539 +
3540 +/* Pure 2^n version of get_order */
3541 +static inline int get_order(unsigned long size)
3542 +{
3543 + int order;
3544 +
3545 + size = (size-1) >> (PAGE_SHIFT-1);
3546 + order = -1;
3547 + do {
3548 + size >>= 1;
3549 + order++;
3550 + } while (size);
3551 + return order;
3552 +}
3553 +
3554 +static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
3555 + dma_addr_t *dma_handle)
3556 +{
3557 + void *ret;
3558 + int gfp = GFP_ATOMIC | GFP_DMA;
3559 +
3560 + ret = (void *)__get_free_pages(gfp, get_order(size));
3561 +
3562 + if (ret != NULL) {
3563 + memset(ret, 0, size);
3564 + *dma_handle = virt_to_bus(ret);
3565 + }
3566 + return ret;
3567 +}
3568 +static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
3569 + void *vaddr, dma_addr_t dma_handle)
3570 +{
3571 + free_pages((unsigned long)vaddr, get_order(size));
3572 +}
3573 +#ifdef ILSIM
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);
3576 +#else
3577 +#define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
3578 +#define pci_unmap_single(cookie, address, size, dir)
3579 +#endif
3580 +
3581 +#endif /* DMA mapping */
3582 +
3583 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43))
3584 +
3585 +#define dev_kfree_skb_any(a) dev_kfree_skb(a)
3586 +#define netif_down(dev) do { (dev)->start = 0; } while(0)
3587 +
3588 +/* pcmcia-cs provides its own netdevice compatibility layer */
3589 +#ifndef _COMPAT_NETDEVICE_H
3590 +
3591 +/*
3592 + * SoftNet
3593 + *
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.
3600 + */
3601 +
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)
3605 +
3606 +static inline void netif_start_queue(struct net_device *dev)
3607 +{
3608 + dev->tbusy = 0;
3609 + dev->interrupt = 0;
3610 + dev->start = 1;
3611 +}
3612 +
3613 +#define netif_queue_stopped(dev) (dev)->tbusy
3614 +#define netif_running(dev) (dev)->start
3615 +
3616 +#endif /* _COMPAT_NETDEVICE_H */
3617 +
3618 +#define netif_device_attach(dev) netif_start_queue(dev)
3619 +#define netif_device_detach(dev) netif_stop_queue(dev)
3620 +
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)
3624 +{
3625 + queue_task(tasklet, &tq_immediate);
3626 + mark_bh(IMMEDIATE_BH);
3627 +}
3628 +
3629 +static inline void tasklet_init(struct tasklet_struct *tasklet,
3630 + void (*func)(unsigned long),
3631 + unsigned long data)
3632 +{
3633 + tasklet->next = NULL;
3634 + tasklet->sync = 0;
3635 + tasklet->routine = (void (*)(void *))func;
3636 + tasklet->data = (void *)data;
3637 +}
3638 +#define tasklet_kill(tasklet) {do{} while(0);}
3639 +
3640 +/* 2.4.x introduced del_timer_sync() */
3641 +#define del_timer_sync(timer) del_timer(timer)
3642 +
3643 +#else
3644 +
3645 +#define netif_down(dev)
3646 +
3647 +#endif /* SoftNet */
3648 +
3649 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3))
3650 +
3651 +/*
3652 + * Emit code to initialise a tq_struct's routine and data pointers
3653 + */
3654 +#define PREPARE_TQUEUE(_tq, _routine, _data) \
3655 + do { \
3656 + (_tq)->routine = _routine; \
3657 + (_tq)->data = _data; \
3658 + } while (0)
3659 +
3660 +/*
3661 + * Emit code to initialise all of a tq_struct
3662 + */
3663 +#define INIT_TQUEUE(_tq, _routine, _data) \
3664 + do { \
3665 + INIT_LIST_HEAD(&(_tq)->list); \
3666 + (_tq)->sync = 0; \
3667 + PREPARE_TQUEUE((_tq), (_routine), (_data)); \
3668 + } while (0)
3669 +
3670 +#endif
3671 +
3672 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6))
3673 +
3674 +/* Power management related routines */
3675 +
3676 +static inline int
3677 +pci_save_state(struct pci_dev *dev, u32 *buffer)
3678 +{
3679 + int i;
3680 + if (buffer) {
3681 + for (i = 0; i < 16; i++)
3682 + pci_read_config_dword(dev, i * 4,&buffer[i]);
3683 + }
3684 + return 0;
3685 +}
3686 +
3687 +static inline int
3688 +pci_restore_state(struct pci_dev *dev, u32 *buffer)
3689 +{
3690 + int i;
3691 +
3692 + if (buffer) {
3693 + for (i = 0; i < 16; i++)
3694 + pci_write_config_dword(dev,i * 4, buffer[i]);
3695 + }
3696 + /*
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.
3701 + */
3702 + else {
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);
3708 + }
3709 + return 0;
3710 +}
3711 +
3712 +#endif /* PCI power management */
3713 +
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)
3717 +#endif
3718 +
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
3724 +#else
3725 +#define OLD_MOD_INC_USE_COUNT do {} while (0)
3726 +#define OLD_MOD_DEC_USE_COUNT do {} while (0)
3727 +#endif
3728 +
3729 +#ifndef SET_NETDEV_DEV
3730 +#define SET_NETDEV_DEV(net, pdev) do {} while (0)
3731 +#endif
3732 +
3733 +#ifndef HAVE_FREE_NETDEV
3734 +#define free_netdev(dev) kfree(dev)
3735 +#endif
3736 +
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
3740 +#endif
3741 +
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
3746 @@ -0,0 +1,126 @@
3747 +/*
3748 + * HND Minimal OS Abstraction Layer.
3749 + *
3750 + * Copyright 2005, Broadcom Corporation
3751 + * All Rights Reserved.
3752 + *
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.
3757 + *
3758 + * $Id$
3759 + */
3760 +
3761 +#ifndef _min_osl_h_
3762 +#define _min_osl_h_
3763 +
3764 +#include <typedefs.h>
3765 +#include <sbconfig.h>
3766 +#include <mipsinc.h>
3767 +
3768 +/* Cache support */
3769 +extern void caches_on(void);
3770 +extern void blast_dcache(void);
3771 +extern void blast_icache(void);
3772 +
3773 +/* uart output */
3774 +extern void putc(int c);
3775 +
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))
3793 +
3794 +/* assert & debugging */
3795 +#define ASSERT(exp) do {} while (0)
3796 +
3797 +/* PCMCIA attribute space access macros */
3798 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \
3799 + ASSERT(0)
3800 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \
3801 + ASSERT(0)
3802 +
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) \
3807 + do {} while (0)
3808 +
3809 +/* PCI device bus # and slot # */
3810 +#define OSL_PCI_BUS(osh) (0)
3811 +#define OSL_PCI_SLOT(osh) (0)
3812 +
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; \
3826 + } \
3827 + __osl_v; \
3828 +})
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; \
3834 + } \
3835 +} while (0)
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))
3838 +
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);
3847 +
3848 +/* uncached virtual address */
3849 +#define OSL_UNCACHED(va) ((void*)KSEG1ADDR((ulong)(va)))
3850 +
3851 +/* host/bus architecture-specific address byte swap */
3852 +#define BUS_SWAP32(v) (v)
3853 +
3854 +/* microsecond delay */
3855 +#define OSL_DELAY(usec) udelay(usec)
3856 +extern void udelay(uint32 usec);
3857 +
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)
3861 +
3862 +/* dereference an address that may cause a bus exception */
3863 +#define BUSPROBE(val, addr) (uint32 *)(addr) = (val)
3864 +
3865 +/* Misc stubs */
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);
3871 +
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
3876 @@ -0,0 +1,552 @@
3877 +/*
3878 + * HND Run Time Environment for standalone MIPS programs.
3879 + *
3880 + * Copyright 2005, Broadcom Corporation
3881 + * All Rights Reserved.
3882 + *
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.
3887 + *
3888 + * $Id$
3889 + */
3890 +
3891 +#ifndef _MISPINC_H
3892 +#define _MISPINC_H
3893 +
3894 +
3895 +/* MIPS defines */
3896 +
3897 +#ifdef _LANGUAGE_ASSEMBLY
3898 +
3899 +/*
3900 + * Symbolic register names for 32 bit ABI
3901 + */
3902 +#define zero $0 /* wired zero */
3903 +#define AT $1 /* assembler temp - uppercase because of ".set at" */
3904 +#define v0 $2 /* return value */
3905 +#define v1 $3
3906 +#define a0 $4 /* argument registers */
3907 +#define a1 $5
3908 +#define a2 $6
3909 +#define a3 $7
3910 +#define t0 $8 /* caller saved */
3911 +#define t1 $9
3912 +#define t2 $10
3913 +#define t3 $11
3914 +#define t4 $12
3915 +#define t5 $13
3916 +#define t6 $14
3917 +#define t7 $15
3918 +#define s0 $16 /* callee saved */
3919 +#define s1 $17
3920 +#define s2 $18
3921 +#define s3 $19
3922 +#define s4 $20
3923 +#define s5 $21
3924 +#define s6 $22
3925 +#define s7 $23
3926 +#define t8 $24 /* caller saved */
3927 +#define t9 $25
3928 +#define jp $25 /* PIC jump register */
3929 +#define k0 $26 /* kernel scratch */
3930 +#define k1 $27
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 */
3936 +
3937 +
3938 +/*
3939 + * CP0 Registers
3940 + */
3941 +
3942 +#define C0_INX $0
3943 +#define C0_RAND $1
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
3954 +#define C0_SR $12
3955 +#define C0_STATUS C0_SR
3956 +#define C0_CAUSE $13
3957 +#define C0_EPC $14
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
3967 +#define C0_ECC $26
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
3973 +
3974 +/*
3975 + * LEAF - declare leaf routine
3976 + */
3977 +#define LEAF(symbol) \
3978 + .globl symbol; \
3979 + .align 2; \
3980 + .type symbol,@function; \
3981 + .ent symbol,0; \
3982 +symbol: .frame sp,0,ra
3983 +
3984 +/*
3985 + * END - mark end of function
3986 + */
3987 +#define END(function) \
3988 + .end function; \
3989 + .size function,.-function
3990 +
3991 +#define _ULCAST_
3992 +
3993 +#else
3994 +
3995 +/*
3996 + * The following macros are especially useful for __asm__
3997 + * inline assembler.
3998 + */
3999 +#ifndef __STR
4000 +#define __STR(x) #x
4001 +#endif
4002 +#ifndef STR
4003 +#define STR(x) __STR(x)
4004 +#endif
4005 +
4006 +#define _ULCAST_ (unsigned long)
4007 +
4008 +
4009 +/*
4010 + * CP0 Registers
4011 + */
4012 +
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 */
4044 +
4045 +#endif /* _LANGUAGE_ASSEMBLY */
4046 +
4047 +/*
4048 + * Memory segments (32bit kernel mode addresses)
4049 + */
4050 +#undef KUSEG
4051 +#undef KSEG0
4052 +#undef KSEG1
4053 +#undef KSEG2
4054 +#undef KSEG3
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
4061 +
4062 +/*
4063 + * Map an address to a certain kernel segment
4064 + */
4065 +#undef PHYSADDR
4066 +#undef KSEG0ADDR
4067 +#undef KSEG1ADDR
4068 +#undef KSEG2ADDR
4069 +#undef KSEG3ADDR
4070 +
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)
4076 +
4077 +
4078 +#ifndef Index_Invalidate_I
4079 +/*
4080 + * Cache Operations
4081 + */
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
4113 +#endif
4114 +
4115 +
4116 +/*
4117 + * R4x00 interrupt enable / cause bits
4118 + */
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)
4127 +
4128 +#ifndef ST0_UM
4129 +/*
4130 + * Bitfields in the mips32 cp0 status register
4131 + */
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
4156 +#endif
4157 +
4158 +
4159 +/*
4160 + * Bitfields in the mips32 cp0 cause register
4161 + */
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
4179 +
4180 +/* Values in C_EXC */
4181 +#define EXC_INT 0
4182 +#define EXC_TLBM 1
4183 +#define EXC_TLBL 2
4184 +#define EXC_TLBS 3
4185 +#define EXC_AEL 4
4186 +#define EXC_AES 5
4187 +#define EXC_IBE 6
4188 +#define EXC_DBE 7
4189 +#define EXC_SYS 8
4190 +#define EXC_BPT 9
4191 +#define EXC_RI 10
4192 +#define EXC_CU 11
4193 +#define EXC_OV 12
4194 +#define EXC_TR 13
4195 +#define EXC_WATCH 23
4196 +#define EXC_MCHK 24
4197 +
4198 +
4199 +/*
4200 + * Bits in the cp0 config register.
4201 + */
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)
4218 +
4219 +
4220 +/*
4221 + * Bits in the cp0 config register select 1.
4222 + */
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
4248 +
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
4254 +
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
4263 +
4264 +#define PRID_IMP_UNKNOWN 0xff00
4265 +
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)))
4269 +
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) */
4275 +
4276 +/* PreFetch Cache aka Read Ahead Cache */
4277 +
4278 +#define PFC_CR0 0xff400000 /* control reg 0 */
4279 +#define PFC_CR1 0xff400004 /* control reg 1 */
4280 +
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) */
4292 +
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)
4302 +
4303 +
4304 +/*
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).
4308 + */
4309 +
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 */
4324 +
4325 +
4326 +#ifndef _LANGUAGE_ASSEMBLY
4327 +
4328 +/*
4329 + * Macros to access the system control coprocessor
4330 + */
4331 +
4332 +#define MFC0(source, sel) \
4333 +({ \
4334 + int __res; \
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" \
4340 + ".set\tat\n\t" \
4341 + ".set\treorder" \
4342 + :"=r" (__res) \
4343 + : \
4344 + :"$1"); \
4345 + __res; \
4346 +})
4347 +
4348 +#define MTC0(source, sel, value) \
4349 +do { \
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" \
4355 + ".set\tat\n\t" \
4356 + ".set\treorder" \
4357 + : \
4358 + :"jr" (value) \
4359 + :"$1"); \
4360 +} while (0)
4361 +
4362 +#define get_c0_count() \
4363 +({ \
4364 + int __res; \
4365 + __asm__ __volatile__( \
4366 + ".set\tnoreorder\n\t" \
4367 + ".set\tnoat\n\t" \
4368 + "mfc0\t%0,$9\n\t" \
4369 + ".set\tat\n\t" \
4370 + ".set\treorder" \
4371 + :"=r" (__res)); \
4372 + __res; \
4373 +})
4374 +
4375 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize)
4376 +{
4377 + uint lsz, sets, ways;
4378 +
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;
4385 + *lsize = lsz;
4386 +}
4387 +
4388 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize)
4389 +{
4390 + uint lsz, sets, ways;
4391 +
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;
4398 + *lsize = lsz;
4399 +}
4400 +
4401 +#define cache_op(base, op) \
4402 + __asm__ __volatile__(" \
4403 + .set noreorder; \
4404 + .set mips3; \
4405 + cache %1, (%0); \
4406 + .set mips0; \
4407 + .set reorder" \
4408 + : \
4409 + : "r" (base), \
4410 + "i" (op));
4411 +
4412 +#define cache_unroll4(base, delta, op) \
4413 + __asm__ __volatile__(" \
4414 + .set noreorder; \
4415 + .set mips3; \
4416 + cache %1,0(%0); \
4417 + cache %1,delta(%0); \
4418 + cache %1,(2 * delta)(%0); \
4419 + cache %1,(3 * delta)(%0); \
4420 + .set mips0; \
4421 + .set reorder" \
4422 + : \
4423 + : "r" (base), \
4424 + "i" (op));
4425 +
4426 +#endif /* !_LANGUAGE_ASSEMBLY */
4427 +
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
4432 @@ -0,0 +1,55 @@
4433 +/*
4434 + * BCM53xx RoboSwitch utility functions
4435 + *
4436 + * Copyright (C) 2002 Broadcom Corporation
4437 + * $Id$
4438 + */
4439 +
4440 +#ifndef _nvports_h_
4441 +#define _nvports_h_
4442 +
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
4448 +
4449 +enum FORCE_PORT {
4450 + FORCE_OFF,
4451 + FORCE_10H,
4452 + FORCE_10F,
4453 + FORCE_100H,
4454 + FORCE_100F,
4455 + FORCE_DOWN,
4456 + POWER_OFF
4457 +};
4458 +
4459 +typedef struct _PORT_ATTRIBS
4460 +{
4461 + uint autoneg;
4462 + uint force;
4463 + uint native;
4464 +} PORT_ATTRIBS;
4465 +
4466 +extern uint
4467 +nvExistsPortAttrib(char *attrib, uint portno);
4468 +
4469 +extern int
4470 +nvExistsAnyForcePortAttrib(uint portno);
4471 +
4472 +extern void
4473 +nvSetPortAttrib(char *attrib, uint portno);
4474 +
4475 +extern void
4476 +nvUnsetPortAttrib(char *attrib, uint portno);
4477 +
4478 +extern void
4479 +nvUnsetAllForcePortAttrib(uint portno);
4480 +
4481 +extern PORT_ATTRIBS
4482 +nvGetSwitchPortAttribs(uint portno);
4483 +
4484 +#endif /* _nvports_h_ */
4485 +
4486 +
4487 +
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
4491 @@ -0,0 +1,42 @@
4492 +/*
4493 + * OS Abstraction Layer
4494 + *
4495 + * Copyright 2005, Broadcom Corporation
4496 + * All Rights Reserved.
4497 + *
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.
4502 + * $Id$
4503 + */
4504 +
4505 +#ifndef _osl_h_
4506 +#define _osl_h_
4507 +
4508 +/* osl handle type forward declaration */
4509 +typedef struct os_handle osl_t;
4510 +
4511 +#if defined(linux)
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>
4521 +#elif PMON
4522 +#include <pmon_osl.h>
4523 +#elif defined(MACOSX)
4524 +#include <macosx_osl.h>
4525 +#else
4526 +#error "Unsupported OSL requested"
4527 +#endif
4528 +
4529 +/* handy */
4530 +#define SET_REG(r, mask, val) W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
4531 +#define MAXPRIO 7 /* 0-7 */
4532 +
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
4537 @@ -0,0 +1,451 @@
4538 +/*
4539 + * pcicfg.h: PCI configuration constants and structures.
4540 + *
4541 + * Copyright 2005, Broadcom Corporation
4542 + * All Rights Reserved.
4543 + *
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.
4548 + *
4549 + * $Id$
4550 + */
4551 +
4552 +#ifndef _h_pci_
4553 +#define _h_pci_
4554 +
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
4558 +#endif
4559 +#ifndef PCI_MAX_DEVICES
4560 +#define PCI_MAX_DEVICES 0x20
4561 +#endif
4562 +#ifndef PCI_MAX_FUNCTION
4563 +#define PCI_MAX_FUNCTION 0x8
4564 +#endif
4565 +
4566 +#ifndef PCI_INVALID_VENDORID
4567 +#define PCI_INVALID_VENDORID 0xffff
4568 +#endif
4569 +#ifndef PCI_INVALID_DEVICEID
4570 +#define PCI_INVALID_DEVICEID 0xffff
4571 +#endif
4572 +
4573 +
4574 +/* Convert between bus-slot-function-register and config addresses */
4575 +
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 */
4580 +
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 */
4585 +
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))
4591 +
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)
4596 +
4597 +/* PCIE Config space accessing MACROS*/
4598 +
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 */
4603 +
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 */
4608 +
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))
4614 +
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)
4619 +
4620 +
4621 +/* The actual config space */
4622 +
4623 +#define PCI_BAR_MAX 6
4624 +
4625 +#define PCI_ROM_BAR 8
4626 +
4627 +#define PCR_RSVDA_MAX 2
4628 +
4629 +/* pci config status reg has a bit to indicate that capability ptr is present*/
4630 +
4631 +#define PCI_CAPPTR_PRESENT 0x0010
4632 +
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];
4657 +} pci_config_regs;
4658 +
4659 +#define SZPCR (sizeof (pci_config_regs))
4660 +#define MINSZPCR 64 /* offsetof (dev_dep[0] */
4661 +
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. :-(
4665 + */
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
4693 +
4694 +/* Classes and subclasses */
4695 +
4696 +typedef enum {
4697 + PCI_CLASS_OLD = 0,
4698 + PCI_CLASS_DASDI,
4699 + PCI_CLASS_NET,
4700 + PCI_CLASS_DISPLAY,
4701 + PCI_CLASS_MMEDIA,
4702 + PCI_CLASS_MEMORY,
4703 + PCI_CLASS_BRIDGE,
4704 + PCI_CLASS_COMM,
4705 + PCI_CLASS_BASE,
4706 + PCI_CLASS_INPUT,
4707 + PCI_CLASS_DOCK,
4708 + PCI_CLASS_CPU,
4709 + PCI_CLASS_SERIAL,
4710 + PCI_CLASS_INTELLIGENT = 0xe,
4711 + PCI_CLASS_SATELLITE,
4712 + PCI_CLASS_CRYPT,
4713 + PCI_CLASS_DSP,
4714 + PCI_CLASS_MAX
4715 +} pci_classes;
4716 +
4717 +typedef enum {
4718 + PCI_DASDI_SCSI,
4719 + PCI_DASDI_IDE,
4720 + PCI_DASDI_FLOPPY,
4721 + PCI_DASDI_IPI,
4722 + PCI_DASDI_RAID,
4723 + PCI_DASDI_OTHER = 0x80
4724 +} pci_dasdi_subclasses;
4725 +
4726 +typedef enum {
4727 + PCI_NET_ETHER,
4728 + PCI_NET_TOKEN,
4729 + PCI_NET_FDDI,
4730 + PCI_NET_ATM,
4731 + PCI_NET_OTHER = 0x80
4732 +} pci_net_subclasses;
4733 +
4734 +typedef enum {
4735 + PCI_DISPLAY_VGA,
4736 + PCI_DISPLAY_XGA,
4737 + PCI_DISPLAY_3D,
4738 + PCI_DISPLAY_OTHER = 0x80
4739 +} pci_display_subclasses;
4740 +
4741 +typedef enum {
4742 + PCI_MMEDIA_VIDEO,
4743 + PCI_MMEDIA_AUDIO,
4744 + PCI_MMEDIA_PHONE,
4745 + PCI_MEDIA_OTHER = 0x80
4746 +} pci_mmedia_subclasses;
4747 +
4748 +typedef enum {
4749 + PCI_MEMORY_RAM,
4750 + PCI_MEMORY_FLASH,
4751 + PCI_MEMORY_OTHER = 0x80
4752 +} pci_memory_subclasses;
4753 +
4754 +typedef enum {
4755 + PCI_BRIDGE_HOST,
4756 + PCI_BRIDGE_ISA,
4757 + PCI_BRIDGE_EISA,
4758 + PCI_BRIDGE_MC,
4759 + PCI_BRIDGE_PCI,
4760 + PCI_BRIDGE_PCMCIA,
4761 + PCI_BRIDGE_NUBUS,
4762 + PCI_BRIDGE_CARDBUS,
4763 + PCI_BRIDGE_RACEWAY,
4764 + PCI_BRIDGE_OTHER = 0x80
4765 +} pci_bridge_subclasses;
4766 +
4767 +typedef enum {
4768 + PCI_COMM_UART,
4769 + PCI_COMM_PARALLEL,
4770 + PCI_COMM_MULTIUART,
4771 + PCI_COMM_MODEM,
4772 + PCI_COMM_OTHER = 0x80
4773 +} pci_comm_subclasses;
4774 +
4775 +typedef enum {
4776 + PCI_BASE_PIC,
4777 + PCI_BASE_DMA,
4778 + PCI_BASE_TIMER,
4779 + PCI_BASE_RTC,
4780 + PCI_BASE_PCI_HOTPLUG,
4781 + PCI_BASE_OTHER = 0x80
4782 +} pci_base_subclasses;
4783 +
4784 +typedef enum {
4785 + PCI_INPUT_KBD,
4786 + PCI_INPUT_PEN,
4787 + PCI_INPUT_MOUSE,
4788 + PCI_INPUT_SCANNER,
4789 + PCI_INPUT_GAMEPORT,
4790 + PCI_INPUT_OTHER = 0x80
4791 +} pci_input_subclasses;
4792 +
4793 +typedef enum {
4794 + PCI_DOCK_GENERIC,
4795 + PCI_DOCK_OTHER = 0x80
4796 +} pci_dock_subclasses;
4797 +
4798 +typedef enum {
4799 + PCI_CPU_386,
4800 + PCI_CPU_486,
4801 + PCI_CPU_PENTIUM,
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;
4808 +
4809 +typedef enum {
4810 + PCI_SERIAL_IEEE1394,
4811 + PCI_SERIAL_ACCESS,
4812 + PCI_SERIAL_SSA,
4813 + PCI_SERIAL_USB,
4814 + PCI_SERIAL_FIBER,
4815 + PCI_SERIAL_SMBUS,
4816 + PCI_SERIAL_OTHER = 0x80
4817 +} pci_serial_subclasses;
4818 +
4819 +typedef enum {
4820 + PCI_INTELLIGENT_I2O,
4821 +} pci_intelligent_subclasses;
4822 +
4823 +typedef enum {
4824 + PCI_SATELLITE_TV,
4825 + PCI_SATELLITE_AUDIO,
4826 + PCI_SATELLITE_VOICE,
4827 + PCI_SATELLITE_DATA,
4828 + PCI_SATELLITE_OTHER = 0x80
4829 +} pci_satellite_subclasses;
4830 +
4831 +typedef enum {
4832 + PCI_CRYPT_NETWORK,
4833 + PCI_CRYPT_ENTERTAINMENT,
4834 + PCI_CRYPT_OTHER = 0x80
4835 +} pci_crypt_subclasses;
4836 +
4837 +typedef enum {
4838 + PCI_DSP_DPIO,
4839 + PCI_DSP_OTHER = 0x80
4840 +} pci_dsp_subclasses;
4841 +
4842 +/* Header types */
4843 +typedef enum {
4844 + PCI_HEADER_NORMAL,
4845 + PCI_HEADER_BRIDGE,
4846 + PCI_HEADER_CARDBUS
4847 +} pci_header_types;
4848 +
4849 +
4850 +/* Overlay for a PCI-to-PCI bridge */
4851 +
4852 +#define PPB_RSVDA_MAX 2
4853 +#define PPB_RSVDD_MAX 8
4854 +
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];
4895 +} ppb_config_regs;
4896 +
4897 +
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
4902 +
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;
4911 +
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;
4922 +
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;
4935 +
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
4942 +
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;
4949 +
4950 +
4951 +/* Everything below is BRCM HND proprietary */
4952 +
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) */
4965 +
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 */
4968 +
4969 +/* PCI_INT_STATUS */
4970 +#define PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */
4971 +
4972 +/* PCI_INT_MASK */
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 */
4976 +
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 */
4981 +
4982 +#define SPROM_SIZE 256 /* sprom size in 16-bit */
4983 +#define SPROM_CRC_RANGE 64 /* crc cover range in 16-bit */
4984 +
4985 +/* PCI_CFG_CMD_STAT */
4986 +#define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */
4987 +
4988 +#endif
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
4992 @@ -0,0 +1,126 @@
4993 +/*
4994 + * MIPS PMON boot loader OS Abstraction Layer.
4995 + *
4996 + * Copyright 2005, Broadcom Corporation
4997 + * All Rights Reserved.
4998 + *
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.
5003 + * $Id$
5004 + */
5005 +
5006 +#ifndef _pmon_osl_h_
5007 +#define _pmon_osl_h_
5008 +
5009 +#include <typedefs.h>
5010 +#include <mips.h>
5011 +#include <string.h>
5012 +#include <utypes.h>
5013 +
5014 +extern int printf(char *fmt,...);
5015 +extern int sprintf(char *dst,char *fmt,...);
5016 +
5017 +#define OSL_UNCACHED(va) phy2k1(log2phy((va)))
5018 +#define REG_MAP(pa, size) phy2k1((pa))
5019 +#define REG_UNMAP(va) /* nop */
5020 +
5021 +/* Common macros */
5022 +
5023 +#define BUSPROBE(val, addr) ((val) = *(addr))
5024 +
5025 +#define ASSERT(exp)
5026 +
5027 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) bzero(buf, size)
5028 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size)
5029 +
5030 +/* kludge */
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)
5033 +
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))
5039 +#else
5040 +#define wreg16(r,v) (*(volatile uint16 *)(r) = (v))
5041 +#define rreg16(r) (*(volatile uint16 *)(r))
5042 +#endif
5043 +
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)
5048 +
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))
5054 +
5055 +#define R_SM(r) *(r)
5056 +#define W_SM(r, v) (*(r) = (v))
5057 +#define BZERO_SM(r, len) memset(r, '\0', len)
5058 +
5059 +/* Host/Bus architecture specific swap. Noop for little endian systems, possible swap on big endian */
5060 +#define BUS_SWAP32(v) (v)
5061 +
5062 +#define OSL_DELAY(usec) delay_us(usec)
5063 +extern void delay_us(uint usec);
5064 +
5065 +#define OSL_GETCYCLES(x) ((x) = 0)
5066 +
5067 +#define osl_attach(pdev) (pdev)
5068 +#define osl_detach(osh)
5069 +
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);
5077 +
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);
5082 +#define DMA_TX 0
5083 +#define DMA_RX 1
5084 +
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);
5088 +
5089 +struct lbuf {
5090 + struct lbuf *next; /* pointer to next lbuf on freelist */
5091 + uchar *buf; /* pointer to buffer */
5092 + uint len; /* nbytes of data */
5093 +};
5094 +
5095 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
5096 +#define PKTBUFSZ 2048
5097 +
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);
5117 +
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
5122 @@ -0,0 +1,930 @@
5123 +/*
5124 + * Copyright 2005, Broadcom Corporation
5125 + * All Rights Reserved.
5126 + *
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.
5131 + *
5132 + * Fundamental types and constants relating to 802.11
5133 + *
5134 + * $Id$
5135 + */
5136 +
5137 +#ifndef _802_11_H_
5138 +#define _802_11_H_
5139 +
5140 +#ifndef _TYPEDEFS_H_
5141 +#include <typedefs.h>
5142 +#endif
5143 +
5144 +#ifndef _NET_ETHERNET_H_
5145 +#include <proto/ethernet.h>
5146 +#endif
5147 +
5148 +#include <proto/wpa.h>
5149 +
5150 +
5151 +/* enable structure packing */
5152 +#if defined(__GNUC__)
5153 +#define PACKED __attribute__((packed))
5154 +#else
5155 +#pragma pack(1)
5156 +#define PACKED
5157 +#endif
5158 +
5159 +#define DOT11_TU_TO_US 1024 /* 802.11 Time Unit is 1024 microseconds */
5160 +
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
5169 +
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
5175 +
5176 +/* Includes MIC */
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 + \
5180 + DOT11_QOS_LEN + \
5181 + DOT11_IV_AES_CCM_LEN + \
5182 + DOT11_MAX_MPDU_BODY_LEN + \
5183 + DOT11_ICV_LEN + \
5184 + DOT11_FCS_LEN)
5185 +
5186 +#define DOT11_MAX_SSID_LEN 32
5187 +
5188 +/* dot11RTSThreshold */
5189 +#define DOT11_DEFAULT_RTS_LEN 2347
5190 +#define DOT11_MAX_RTS_LEN 2347
5191 +
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
5196 +
5197 +/* dot11BeaconPeriod */
5198 +#define DOT11_MIN_BEACON_PERIOD 1
5199 +#define DOT11_MAX_BEACON_PERIOD 0xFFFF
5200 +
5201 +/* dot11DTIMPeriod */
5202 +#define DOT11_MIN_DTIM_PERIOD 1
5203 +#define DOT11_MAX_DTIM_PERIOD 0xFF
5204 +
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 */
5215 +} PACKED;
5216 +
5217 +/* RFC1042 header used by 802.11 per 802.1H */
5218 +#define RFC1042_HDR_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN)
5219 +
5220 +/* Generic 802.11 MAC header */
5221 +/*
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.
5225 + */
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 */
5234 +} PACKED;
5235 +
5236 +/* Control frames */
5237 +
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 */
5243 +} PACKED;
5244 +#define DOT11_RTS_LEN 16
5245 +
5246 +struct dot11_cts_frame {
5247 + uint16 fc; /* frame control */
5248 + uint16 durid; /* duration/ID */
5249 + struct ether_addr ra; /* receiver address */
5250 +} PACKED;
5251 +#define DOT11_CTS_LEN 10
5252 +
5253 +struct dot11_ack_frame {
5254 + uint16 fc; /* frame control */
5255 + uint16 durid; /* duration/ID */
5256 + struct ether_addr ra; /* receiver address */
5257 +} PACKED;
5258 +#define DOT11_ACK_LEN 10
5259 +
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 */
5265 +} PACKED;
5266 +#define DOT11_PS_POLL_LEN 16
5267 +
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 */
5273 +} PACKED;
5274 +#define DOT11_CS_END_LEN 16
5275 +
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 */
5284 +} PACKED;
5285 +#define DOT11_MGMT_HDR_LEN 24
5286 +
5287 +/* Management frame payloads */
5288 +
5289 +struct dot11_bcn_prb {
5290 + uint32 timestamp[2];
5291 + uint16 beacon_interval;
5292 + uint16 capability;
5293 +} PACKED;
5294 +#define DOT11_BCN_PRB_LEN 12
5295 +
5296 +struct dot11_auth {
5297 + uint16 alg; /* algorithm */
5298 + uint16 seq; /* sequence control */
5299 + uint16 status; /* status code */
5300 +} PACKED;
5301 +#define DOT11_AUTH_FIXED_LEN 6 /* length of auth frame without challenge info elt */
5302 +
5303 +struct dot11_assoc_req {
5304 + uint16 capability; /* capability information */
5305 + uint16 listen; /* listen interval */
5306 +} PACKED;
5307 +#define DOT11_ASSOC_REQ_FIXED_LEN 4 /* length of assoc frame without info elts */
5308 +
5309 +struct dot11_reassoc_req {
5310 + uint16 capability; /* capability information */
5311 + uint16 listen; /* listen interval */
5312 + struct ether_addr ap; /* Current AP address */
5313 +} PACKED;
5314 +#define DOT11_REASSOC_REQ_FIXED_LEN 10 /* length of assoc frame without info elts */
5315 +
5316 +struct dot11_assoc_resp {
5317 + uint16 capability; /* capability information */
5318 + uint16 status; /* status code */
5319 + uint16 aid; /* association ID */
5320 +} PACKED;
5321 +
5322 +struct dot11_action_measure {
5323 + uint8 category;
5324 + uint8 action;
5325 + uint8 token;
5326 + uint8 data[1];
5327 +} PACKED;
5328 +#define DOT11_ACTION_MEASURE_LEN 3
5329 +
5330 +struct dot11_action_switch_channel {
5331 + uint8 category;
5332 + uint8 action;
5333 + uint8 data[5]; /* for switch IE */
5334 +} PACKED;
5335 +
5336 +/**************
5337 + 802.11h related definitions.
5338 +**************/
5339 +typedef struct {
5340 + uint8 id;
5341 + uint8 len;
5342 + uint8 power;
5343 +} dot11_power_cnst_t;
5344 +
5345 +typedef struct {
5346 + uint8 min;
5347 + uint8 max;
5348 +} dot11_power_cap_t;
5349 +
5350 +typedef struct {
5351 + uint8 id;
5352 + uint8 len;
5353 + uint8 tx_pwr;
5354 + uint8 margin;
5355 +} dot11_tpc_rep_t;
5356 +#define DOT11_MNG_IE_TPC_REPORT_LEN 2 /* length of IE data, not including 2 byte header */
5357 +
5358 +typedef struct {
5359 + uint8 id;
5360 + uint8 len;
5361 + uint8 first_channel;
5362 + uint8 num_channels;
5363 +} dot11_supp_channels_t;
5364 +
5365 +/* csa mode type */
5366 +#define DOT11_CSA_MODE_ADVISORY 0
5367 +#define DOT11_CSA_MODE_NO_TX 1
5368 +struct dot11_channel_switch {
5369 + uint8 id;
5370 + uint8 len;
5371 + uint8 mode;
5372 + uint8 channel;
5373 + uint8 count;
5374 +} PACKED;
5375 +typedef struct dot11_channel_switch dot11_channel_switch_t;
5376 +
5377 +/* length of IE data, not including 2 byte header */
5378 +#define DOT11_SWITCH_IE_LEN 3
5379 +
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
5385 +
5386 +/* Measurement Mode field */
5387 +
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))
5402 +
5403 +typedef struct {
5404 + uint8 id;
5405 + uint8 len;
5406 + uint8 token;
5407 + uint8 mode;
5408 + uint8 type;
5409 + uint8 channel;
5410 + uint8 start_time[8];
5411 + uint16 duration;
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
5416 +
5417 +struct dot11_meas_rep {
5418 + uint8 id;
5419 + uint8 len;
5420 + uint8 token;
5421 + uint8 mode;
5422 + uint8 type;
5423 + union
5424 + {
5425 + struct {
5426 + uint8 channel;
5427 + uint8 start_time[8];
5428 + uint16 duration;
5429 + uint8 map;
5430 + } PACKED basic;
5431 + uint8 data[1];
5432 + } PACKED rep;
5433 +} PACKED;
5434 +typedef struct dot11_meas_rep dot11_meas_rep_t;
5435 +
5436 +/* length of Measure Report IE data not including variable len */
5437 +#define DOT11_MNG_IE_MREP_FIXED_LEN 3
5438 +
5439 +struct dot11_meas_rep_basic {
5440 + uint8 channel;
5441 + uint8 start_time[8];
5442 + uint16 duration;
5443 + uint8 map;
5444 +} PACKED;
5445 +typedef struct dot11_meas_rep_basic dot11_meas_rep_basic_t;
5446 +#define DOT11_MEASURE_BASIC_REP_LEN 12
5447 +
5448 +struct dot11_quiet {
5449 + uint8 id;
5450 + uint8 len;
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 */
5455 +} PACKED;
5456 +typedef struct dot11_quiet dot11_quiet_t;
5457 +
5458 +typedef struct {
5459 + uint8 channel;
5460 + uint8 map;
5461 +} chan_map_tuple_t;
5462 +
5463 +typedef struct {
5464 + uint8 id;
5465 + uint8 len;
5466 + uint8 eaddr[ETHER_ADDR_LEN];
5467 + uint8 interval;
5468 + chan_map_tuple_t map[1];
5469 +} dot11_ibss_dfs_t;
5470 +
5471 +/* WME Elements */
5472 +#define WME_OUI "\x00\x50\xf2"
5473 +#define WME_VER 1
5474 +#define WME_TYPE 2
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 */
5478 +
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 */
5484 +#define AC_MAX 4
5485 +
5486 +/* WME Information Element (IE) */
5487 +struct wme_ie {
5488 + uint8 oui[3];
5489 + uint8 type;
5490 + uint8 subtype;
5491 + uint8 version;
5492 + uint8 acinfo;
5493 +} PACKED;
5494 +typedef struct wme_ie wme_ie_t;
5495 +#define WME_IE_LEN 7
5496 +
5497 +struct wme_acparam {
5498 + uint8 ACI;
5499 + uint8 ECW;
5500 + uint16 TXOP; /* stored in network order (ls octet first) */
5501 +} PACKED;
5502 +typedef struct wme_acparam wme_acparam_t;
5503 +
5504 +/* WME Parameter Element (PE) */
5505 +struct wme_params {
5506 + uint8 oui[3];
5507 + uint8 type;
5508 + uint8 subtype;
5509 + uint8 version;
5510 + uint8 acinfo;
5511 + uint8 rsvd;
5512 + wme_acparam_t acparam[4];
5513 +} PACKED;
5514 +typedef struct wme_params wme_params_t;
5515 +#define WME_PARAMS_IE_LEN 24
5516 +
5517 +/* acinfo */
5518 +#define WME_COUNT_MASK 0x0f
5519 +/* ACI */
5520 +#define WME_AIFS_MASK 0x0f
5521 +#define WME_ACM_MASK 0x10
5522 +#define WME_ACI_MASK 0x60
5523 +#define WME_ACI_SHIFT 5
5524 +/* ECW */
5525 +#define WME_CWMIN_MASK 0x0f
5526 +#define WME_CWMAX_MASK 0xf0
5527 +#define WME_CWMAX_SHIFT 4
5528 +
5529 +#define WME_TXOP_UNITS 32
5530 +
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
5545 +
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
5558 +
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
5563 +struct wme_tspec {
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) */
5583 +} PACKED;
5584 +typedef struct wme_tspec wme_tspec_t;
5585 +#define WME_TSPEC_LEN 56 /* not including 2-byte header */
5586 +
5587 +/* ts_info */
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)
5600 +
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 */
5604 +
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
5609 +
5610 +/* Management Notification Frame */
5611 +struct dot11_management_notification {
5612 + uint8 category; /* DOT11_ACTION_NOTIFICATION */
5613 + uint8 action;
5614 + uint8 token;
5615 + uint8 status;
5616 + uint8 data[1]; /* Elements */
5617 +} PACKED;
5618 +#define DOT11_MGMT_NOTIFICATION_LEN 4 /* Fixed length */
5619 +
5620 +/* WME Action Codes */
5621 +#define WME_SETUP_REQUEST 0
5622 +#define WME_SETUP_RESPONSE 1
5623 +#define WME_TEARDOWN 2
5624 +
5625 +/* WME Setup Response Status Codes */
5626 +#define WME_ADMISSION_ACCEPTED 0
5627 +#define WME_INVALID_PARAMETERS 1
5628 +#define WME_ADMISSION_REFUSED 3
5629 +
5630 +/* Macro to take a pointer to a beacon or probe response
5631 + * header and return the char* pointer to the SSID info element
5632 + */
5633 +#define BCN_PRB_SSID(hdr) ((char*)(hdr) + DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_LEN)
5634 +
5635 +/* Authentication frame payload constants */
5636 +#define DOT11_OPEN_SYSTEM 0
5637 +#define DOT11_SHARED_KEY 1
5638 +#define DOT11_CHALLENGE_LEN 128
5639 +
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
5663 +
5664 +/* sequence control macros */
5665 +#define SEQNUM_SHIFT 4
5666 +#define FRAGNUM_MASK 0xF
5667 +
5668 +/* Frame Control type/subtype defs */
5669 +
5670 +/* FC Types */
5671 +#define FC_TYPE_MNG 0
5672 +#define FC_TYPE_CTL 1
5673 +#define FC_TYPE_DATA 2
5674 +
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
5688 +
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
5696 +
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
5708 +
5709 +/* type-subtype combos */
5710 +#define FC_KIND_MASK (FC_TYPE_MASK | FC_SUBTYPE_MASK)
5711 +
5712 +#define FC_KIND(t, s) (((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT))
5713 +
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)
5725 +
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)
5732 +
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)
5738 +
5739 +/* QoS Control Field */
5740 +
5741 +/* 802.1D Tag */
5742 +#define QOS_PRIO_SHIFT 0
5743 +#define QOS_PRIO_MASK 0x0007
5744 +#define QOS_PRIO(qos) (((qos) & QOS_PRIO_MASK) >> QOS_PRIO_SHIFT)
5745 +
5746 +#define QOS_TID_SHIFT 0
5747 +#define QOS_TID_MASK 0x000f
5748 +#define QOS_TID(qos) (((qos) & QOS_TID_MASK) >> QOS_TID_SHIFT)
5749 +
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)
5754 +
5755 +/* Management Frames */
5756 +
5757 +/* Management Frame Constants */
5758 +
5759 +/* Fixed fields */
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
5770 +
5771 +/* DUR/ID field in assoc resp is 0xc000 | AID */
5772 +#define DOT11_AID_MASK 0x3fff
5773 +
5774 +/* Reason Codes */
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 */
5792 +
5793 +/* Status Codes */
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 */
5833 +
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
5837 +
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
5845 +
5846 +/* TLV defines */
5847 +#define TLV_TAG_OFF 0
5848 +#define TLV_LEN_OFF 1
5849 +#define TLV_HDR_LEN 2
5850 +#define TLV_BODY_OFF 2
5851 +
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
5877 +#ifdef BCMWPA2
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
5883 +
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 */
5889 +
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
5902 +
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 */
5907 +
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
5913 +
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
5920 +
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
5931 +
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
5939 +
5940 +/* 802.11 G constants */
5941 +#define DOT11_OFDM_SIGNAL_EXTENSION 6
5942 +
5943 +#define PHY_CWMAX 1023
5944 +
5945 +#define DOT11_MAXNUMFRAGS 16 /* max # fragments per MSDU */
5946 +
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 */
5963 +} d11cnt_t;
5964 +
5965 +/* BRCM OUI */
5966 +#define BRCM_OUI "\x00\x10\x18"
5967 +
5968 +/* BRCM info element */
5969 +struct brcm_ie {
5970 + uchar id; /* 221, DOT11_MNG_PROPR_ID */
5971 + uchar len;
5972 + uchar oui[3];
5973 + uchar ver;
5974 + uchar assoc; /* # of assoc STAs */
5975 + uchar flags; /* misc flags */
5976 +} PACKED;
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
5981 +
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
5988 +
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" */
5991 +
5992 +
5993 +/* OUI for BRCM proprietary IE */
5994 +#define BRCM_PROP_OUI "\x00\x90\x4C"
5995 +
5996 +/* Vendor IE structure */
5997 +struct vndr_ie {
5998 + uchar id;
5999 + uchar len;
6000 + uchar oui [3];
6001 + uchar data [1]; /* Variable size data */
6002 +}PACKED;
6003 +typedef struct vndr_ie vndr_ie_t;
6004 +
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
6008 +
6009 +/* WPA definitions */
6010 +#define WPA_VERSION 1
6011 +#define WPA_OUI "\x00\x50\xF2"
6012 +
6013 +#ifdef BCMWPA2
6014 +#define WPA2_VERSION 1
6015 +#define WPA2_VERSION_LEN 2
6016 +#define WPA2_OUI "\x00\x0F\xAC"
6017 +#endif /* BCMWPA2 */
6018 +
6019 +#define WPA_OUI_LEN 3
6020 +
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 */
6025 +
6026 +
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 */
6032 +
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 */
6046 +
6047 +#undef PACKED
6048 +#if !defined(__GNUC__)
6049 +#pragma pack()
6050 +#endif
6051 +
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
6056 @@ -0,0 +1,103 @@
6057 +/*
6058 + * Broadcom Ethernettype protocol definitions
6059 + *
6060 + * Copyright 2005, Broadcom Corporation
6061 + * All Rights Reserved.
6062 + *
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.
6067 + *
6068 + */
6069 +
6070 +/*
6071 + * Broadcom Ethernet protocol defines
6072 + *
6073 + */
6074 +
6075 +#ifndef _BCMETH_H_
6076 +#define _BCMETH_H_
6077 +
6078 +/* enable structure packing */
6079 +#if defined(__GNUC__)
6080 +#define PACKED __attribute__((packed))
6081 +#else
6082 +#pragma pack(1)
6083 +#define PACKED
6084 +#endif
6085 +
6086 +/* ETHER_TYPE_BRCM is defined in ethernet.h */
6087 +
6088 +/*
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)
6091 + *
6092 + * subtypes 0-32767:
6093 + * 8 bit subtype (0-127)
6094 + * 8 bit length in bytes (0-255)
6095 + *
6096 + * subtypes 32768-65535:
6097 + * 16 bit big-endian subtype
6098 + * 16 bit big-endian length in bytes (0-65535)
6099 + *
6100 + * length is the number of additional bytes beyond the 4 or 6 byte header
6101 + *
6102 + * Reserved values:
6103 + * 0 reserved
6104 + * 5-15 reserved for iLine protocol assignments
6105 + * 17-126 reserved, assignable
6106 + * 127 reserved
6107 + * 32768 reserved
6108 + * 32769-65534 reserved, assignable
6109 + * 65535 reserved
6110 + */
6111 +
6112 +/*
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
6115 + */
6116 +
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
6123 +
6124 +#define BCMILCP_SUBTYPE_VENDOR_LONG 32769
6125 +#define BCMILCP_SUBTYPE_CERT 32770
6126 +#define BCMILCP_SUBTYPE_SES 32771
6127 +
6128 +
6129 +#define BCMILCP_BCM_SUBTYPE_RESERVED 0
6130 +#define BCMILCP_BCM_SUBTYPE_EVENT 1
6131 +#define BCMILCP_BCM_SUBTYPE_SES 2
6132 +/*
6133 +The EAPOL type is not used anymore. Instead EAPOL messages are now embedded
6134 +within BCMILCP_BCM_SUBTYPE_EVENT type messages
6135 +*/
6136 +/*#define BCMILCP_BCM_SUBTYPE_EAPOL 3*/
6137 +
6138 +#define BCMILCP_BCM_SUBTYPEHDR_MINLENGTH 8
6139 +#define BCMILCP_BCM_SUBTYPEHDR_VERSION 0
6140 +
6141 +/* These fields are stored in network order */
6142 +typedef struct bcmeth_hdr
6143 +{
6144 + uint16 subtype; /* Vendor specific..32769*/
6145 + uint16 length;
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;
6151 +
6152 +
6153 +
6154 +#undef PACKED
6155 +#if !defined(__GNUC__)
6156 +#pragma pack()
6157 +#endif
6158 +
6159 +#endif
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
6163 @@ -0,0 +1,42 @@
6164 +/*
6165 + * Copyright 2005, Broadcom Corporation
6166 + * All Rights Reserved.
6167 + *
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.
6172 + *
6173 + * Fundamental constants relating to IP Protocol
6174 + *
6175 + * $Id$
6176 + */
6177 +
6178 +#ifndef _bcmip_h_
6179 +#define _bcmip_h_
6180 +
6181 +/* IP header */
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 */
6188 +
6189 +#define IPV4_VER_MASK 0xf0
6190 +#define IPV4_IHL_MASK 0x0f
6191 +
6192 +#define IPV4_PROT_UDP 17 /* UDP protocol type */
6193 +
6194 +#define IPV4_ADDR_LEN 4 /* IP v4 address length */
6195 +
6196 +#define IPV4_VER_NUM 0x40 /* IP v4 version number */
6197 +
6198 +/* NULL IP address check */
6199 +#define IPV4_ISNULLADDR(a) ((((uint8 *)(a))[0] + ((uint8 *)(a))[1] + \
6200 + ((uint8 *)(a))[2] + ((uint8 *)(a))[3]) == 0)
6201 +
6202 +#define IPV4_ADDR_STR_LEN 16
6203 +
6204 +#endif /* #ifndef _bcmip_h_ */
6205 +
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
6209 @@ -0,0 +1,169 @@
6210 +/*******************************************************************************
6211 + * $Id$
6212 + * Copyright 2005, Broadcom Corporation
6213 + * All Rights Reserved.
6214 + *
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 + ******************************************************************************/
6221 +
6222 +#ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
6223 +#define _NET_ETHERNET_H_
6224 +
6225 +#ifndef _TYPEDEFS_H_
6226 +#include "typedefs.h"
6227 +#endif
6228 +
6229 +/* enable structure packing */
6230 +#if defined(__GNUC__)
6231 +#define PACKED __attribute__((packed))
6232 +#else
6233 +#pragma pack(1)
6234 +#define PACKED
6235 +#endif
6236 +
6237 +/*
6238 + * The number of bytes in an ethernet (MAC) address.
6239 + */
6240 +#define ETHER_ADDR_LEN 6
6241 +
6242 +/*
6243 + * The number of bytes in the type field.
6244 + */
6245 +#define ETHER_TYPE_LEN 2
6246 +
6247 +/*
6248 + * The number of bytes in the trailing CRC field.
6249 + */
6250 +#define ETHER_CRC_LEN 4
6251 +
6252 +/*
6253 + * The length of the combined header.
6254 + */
6255 +#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
6256 +
6257 +/*
6258 + * The minimum packet length.
6259 + */
6260 +#define ETHER_MIN_LEN 64
6261 +
6262 +/*
6263 + * The minimum packet user data length.
6264 + */
6265 +#define ETHER_MIN_DATA 46
6266 +
6267 +/*
6268 + * The maximum packet length.
6269 + */
6270 +#define ETHER_MAX_LEN 1518
6271 +
6272 +/*
6273 + * The maximum packet user data length.
6274 + */
6275 +#define ETHER_MAX_DATA 1500
6276 +
6277 +/* ether types */
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*/
6284 +
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 */
6288 +
6289 +/* ether header */
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 */
6293 +
6294 +/*
6295 + * A macro to validate a length with
6296 + */
6297 +#define ETHER_IS_VALID_LEN(foo) \
6298 + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
6299 +
6300 +
6301 +#ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
6302 +/*
6303 + * Structure of a 10Mb/s Ethernet header.
6304 + */
6305 +struct ether_header {
6306 + uint8 ether_dhost[ETHER_ADDR_LEN];
6307 + uint8 ether_shost[ETHER_ADDR_LEN];
6308 + uint16 ether_type;
6309 +} PACKED;
6310 +
6311 +/*
6312 + * Structure of a 48-bit Ethernet address.
6313 + */
6314 +struct ether_addr {
6315 + uint8 octet[ETHER_ADDR_LEN];
6316 +} PACKED;
6317 +#endif
6318 +
6319 +/*
6320 + * Takes a pointer, sets locally admininistered
6321 + * address bit in the 48-bit Ethernet address.
6322 + */
6323 +#define ETHER_SET_LOCALADDR(ea) ( ((uint8 *)(ea))[0] = \
6324 + (((uint8 *)(ea))[0] | 2) )
6325 +
6326 +/*
6327 + * Takes a pointer, returns true if a 48-bit multicast address
6328 + * (including broadcast, since it is all ones)
6329 + */
6330 +#define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
6331 +
6332 +
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]))
6338 +
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]; }
6344 +
6345 +/*
6346 + * Takes a pointer, returns true if a 48-bit broadcast (all ones)
6347 + */
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)
6354 +
6355 +static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
6356 +
6357 +/*
6358 + * Takes a pointer, returns true if a 48-bit null address (all zeros)
6359 + */
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)
6366 +
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
6372 +
6373 +#undef PACKED
6374 +#if !defined(__GNUC__)
6375 +#pragma pack()
6376 +#endif
6377 +
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
6382 @@ -0,0 +1,50 @@
6383 +/*
6384 + * 802.1Q VLAN protocol definitions
6385 + *
6386 + * Copyright 2005, Broadcom Corporation
6387 + * All Rights Reserved.
6388 + *
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.
6393 + *
6394 + * $Id$
6395 + */
6396 +
6397 +#ifndef _vlan_h_
6398 +#define _vlan_h_
6399 +
6400 +/* enable structure packing */
6401 +#if defined(__GNUC__)
6402 +#define PACKED __attribute__((packed))
6403 +#else
6404 +#pragma pack(1)
6405 +#define PACKED
6406 +#endif
6407 +
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 */
6411 +
6412 +#define VLAN_PRI_MASK 7 /* 3 bits of priority */
6413 +
6414 +#define VLAN_TAG_LEN 4
6415 +#define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN)
6416 +
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;
6423 +};
6424 +
6425 +#define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN)
6426 +
6427 +#undef PACKED
6428 +#if !defined(__GNUC__)
6429 +#pragma pack()
6430 +#endif
6431 +
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
6436 @@ -0,0 +1,140 @@
6437 +/*
6438 + * Fundamental types and constants relating to WPA
6439 + *
6440 + * Copyright 2005, Broadcom Corporation
6441 + * All Rights Reserved.
6442 + *
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.
6447 + *
6448 + * $Id$
6449 + */
6450 +
6451 +#ifndef _proto_wpa_h_
6452 +#define _proto_wpa_h_
6453 +
6454 +#include <typedefs.h>
6455 +#include <proto/ethernet.h>
6456 +
6457 +/* enable structure packing */
6458 +#if defined(__GNUC__)
6459 +#define PACKED __attribute__((packed))
6460 +#else
6461 +#pragma pack(1)
6462 +#define PACKED
6463 +#endif
6464 +
6465 +/* Reason Codes */
6466 +
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 */
6470 +/* 12 is unused */
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 */
6483 +
6484 +#define WPA2_PMKID_LEN 16
6485 +
6486 +/* WPA IE fixed portion */
6487 +typedef struct
6488 +{
6489 + uint8 tag; /* TAG */
6490 + uint8 length; /* TAG length */
6491 + uint8 oui[3]; /* IE OUI */
6492 + uint8 oui_type; /* OUI type */
6493 + struct {
6494 + uint8 low;
6495 + uint8 high;
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
6501 +
6502 +typedef struct {
6503 + uint8 tag; /* TAG */
6504 + uint8 length; /* TAG length */
6505 + struct {
6506 + uint8 low;
6507 + uint8 high;
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];
6513 +
6514 +/* WPA suite/multicast suite */
6515 +typedef struct
6516 +{
6517 + uint8 oui[3];
6518 + uint8 type;
6519 +} PACKED wpa_suite_t, wpa_suite_mcast_t;
6520 +#define WPA_SUITE_LEN 4
6521 +
6522 +/* WPA unicast suite list/key management suite list */
6523 +typedef struct
6524 +{
6525 + struct {
6526 + uint8 low;
6527 + uint8 high;
6528 + } PACKED count;
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
6532 +typedef struct
6533 +{
6534 + struct {
6535 + uint8 low;
6536 + uint8 high;
6537 + } PACKED count;
6538 + wpa_pmkid_t list[1];
6539 +} PACKED wpa_pmkid_list_t;
6540 +
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) */
6548 +
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)
6555 +
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) */
6559 +
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
6565 +
6566 +/* WPA Specific defines */
6567 +#define WPA_CAP_LEN 2
6568 +
6569 +#define WPA_CAP_WPA2_PREAUTH 1
6570 +
6571 +#undef PACKED
6572 +#if !defined(__GNUC__)
6573 +#pragma pack()
6574 +#endif
6575 +
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
6580 @@ -0,0 +1,69 @@
6581 +/*******************************************************************************
6582 + * $Id$
6583 + * Copyright 2005, Broadcom Corporation
6584 + * All Rights Reserved.
6585 + *
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 + ******************************************************************************/
6592 +
6593 +#ifndef _RTS_CRC_H_
6594 +#define _RTS_CRC_H_ 1
6595 +
6596 +#include "typedefs.h"
6597 +
6598 +#ifdef __cplusplus
6599 +extern "C" {
6600 +#endif
6601 +
6602 +
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 */
6606 +
6607 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
6608 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
6609 +
6610 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
6611 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
6612 +
6613 +void hcs(uint8 *, uint);
6614 +uint8 crc8(uint8 *, uint, uint8);
6615 +uint16 crc16(uint8 *, uint, uint16);
6616 +uint32 crc32(uint8 *, uint, uint32);
6617 +
6618 +/* macros for common usage */
6619 +
6620 +#define APPEND_CRC8(pbytes, nbytes) \
6621 +do { \
6622 + uint8 tmp = crc8(pbytes, nbytes, CRC8_INIT_VALUE) ^ 0xff; \
6623 + (pbytes)[(nbytes)] = tmp; \
6624 + (nbytes) += 1; \
6625 +} while (0)
6626 +
6627 +#define APPEND_CRC16(pbytes, nbytes) \
6628 +do { \
6629 + uint16 tmp = crc16(pbytes, nbytes, CRC16_INIT_VALUE) ^ 0xffff; \
6630 + (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
6631 + (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
6632 + (nbytes) += 2; \
6633 +} while (0)
6634 +
6635 +#define APPEND_CRC32(pbytes, nbytes) \
6636 +do { \
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; \
6642 + (nbytes) += 4; \
6643 +} while (0)
6644 +
6645 +#ifdef __cplusplus
6646 +}
6647 +#endif
6648 +
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
6653 @@ -0,0 +1,440 @@
6654 +/*
6655 + * SiliconBackplane Chipcommon core hardware definitions.
6656 + *
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.
6660 + *
6661 + * $Id$
6662 + * Copyright 2005, Broadcom Corporation
6663 + * All Rights Reserved.
6664 + *
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.
6669 + *
6670 + */
6671 +
6672 +#ifndef _SBCHIPC_H
6673 +#define _SBCHIPC_H
6674 +
6675 +
6676 +#ifndef _LANGUAGE_ASSEMBLY
6677 +
6678 +/* cpp contortions to concatenate w/arg prescan */
6679 +#ifndef PAD
6680 +#define _PADLINE(line) pad ## line
6681 +#define _XSTR(line) _PADLINE(line)
6682 +#define PAD _XSTR(__LINE__)
6683 +#endif /* PAD */
6684 +
6685 +typedef volatile struct {
6686 + uint32 chipid; /* 0x0 */
6687 + uint32 capabilities;
6688 + uint32 corecontrol; /* corerev >= 1 */
6689 + uint32 bist;
6690 +
6691 + /* OTP */
6692 + uint32 otpstatus; /* 0x10, corerev >= 10 */
6693 + uint32 otpcontrol;
6694 + uint32 otpprog;
6695 + uint32 PAD;
6696 +
6697 + /* Interrupt control */
6698 + uint32 intstatus; /* 0x20 */
6699 + uint32 intmask;
6700 + uint32 chipcontrol; /* 0x28, rev >= 11 */
6701 + uint32 chipstatus; /* 0x2c, rev >= 11 */
6702 +
6703 + /* Jtag Master */
6704 + uint32 jtagcmd; /* 0x30, rev >= 10 */
6705 + uint32 jtagir;
6706 + uint32 jtagdr;
6707 + uint32 jtagctrl;
6708 +
6709 + /* serial flash interface registers */
6710 + uint32 flashcontrol; /* 0x40 */
6711 + uint32 flashaddress;
6712 + uint32 flashdata;
6713 + uint32 PAD[1];
6714 +
6715 + /* Silicon backplane configuration broadcast control */
6716 + uint32 broadcastaddress; /* 0x50 */
6717 + uint32 broadcastdata;
6718 + uint32 PAD[2];
6719 +
6720 + /* gpio - cleared only by power-on-reset */
6721 + uint32 gpioin; /* 0x60 */
6722 + uint32 gpioout;
6723 + uint32 gpioouten;
6724 + uint32 gpiocontrol;
6725 + uint32 gpiointpolarity;
6726 + uint32 gpiointmask;
6727 + uint32 PAD[2];
6728 +
6729 + /* Watchdog timer */
6730 + uint32 watchdog; /* 0x80 */
6731 + uint32 PAD[1];
6732 +
6733 + /*GPIO based LED powersave registers corerev >= 16*/
6734 + uint32 gpiotimerval; /*0x88 */
6735 + uint32 gpiotimeroutmask;
6736 +
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 */
6744 + uint32 PAD[2];
6745 +
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 */
6750 + uint32 PAD[1];
6751 +
6752 + /* Instaclock registers (corerev >= 10) */
6753 + uint32 system_clk_ctl; /* 0xc0 */
6754 + uint32 clkstatestretch;
6755 + uint32 PAD[14];
6756 +
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;
6770 + uint32 PAD[116];
6771 +
6772 + /* uarts */
6773 + uint8 uart0data; /* 0x300 */
6774 + uint8 uart0imr;
6775 + uint8 uart0fcr;
6776 + uint8 uart0lcr;
6777 + uint8 uart0mcr;
6778 + uint8 uart0lsr;
6779 + uint8 uart0msr;
6780 + uint8 uart0scratch;
6781 + uint8 PAD[248]; /* corerev >= 1 */
6782 +
6783 + uint8 uart1data; /* 0x400 */
6784 + uint8 uart1imr;
6785 + uint8 uart1fcr;
6786 + uint8 uart1lcr;
6787 + uint8 uart1mcr;
6788 + uint8 uart1lsr;
6789 + uint8 uart1msr;
6790 + uint8 uart1scratch;
6791 +} chipcregs_t;
6792 +
6793 +#endif /* _LANGUAGE_ASSEMBLY */
6794 +
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
6810 +
6811 +/* chipid */
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
6819 +
6820 +/* capabilities */
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 */
6835 +
6836 +/* PLL type */
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 */
6845 +
6846 +/* corecontrol */
6847 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */
6848 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
6849 +
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
6856 +
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
6864 +
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
6875 +
6876 +/* jtagcmd */
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
6898 +
6899 +/* jtagctrl */
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 */
6903 +
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
6912 +
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 */
6917 +
6918 +/* slow_clk_ctl */
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
6931 +
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
6940 +
6941 +/* gpiotimerval*/
6942 +#define GPIO_ONTIME_SHIFT 16
6943 +
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
6950 +
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
6959 +
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
6967 +
6968 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
6969 +
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
6975 +
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 */
6979 +
6980 +#define CC_T2MC_M1BYP 1
6981 +#define CC_T2MC_M2BYP 2
6982 +#define CC_T2MC_M3BYP 4
6983 +
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))
6989 +
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 */
6993 +
6994 +/* Clock control values for 200Mhz in 5350 */
6995 +#define CLKC_5350_N 0x0311
6996 +#define CLKC_5350_M 0x04020009
6997 +
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 */
7003 +
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 */
7015 +
7016 +/* Start/busy bit in flashcontrol */
7017 +#define SFLASH_START 0x80000000
7018 +#define SFLASH_BUSY SFLASH_START
7019 +
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 */
7031 +
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 */
7038 +
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
7061 +
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
7067 +
7068 +/* OTP regions */
7069 +#define OTP_HW_REGION OTPS_HW_PROTECT
7070 +#define OTP_SW_REGION OTPS_SW_PROTECT
7071 +#define OTP_CID_REGION OTPS_CID_PROTECT
7072 +
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
7077 +
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)
7083 +
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
7089 +
7090 +#define OTP_SIGNATURE 0x578a
7091 +#define OTP_MAGIC 0x4e56
7092 +
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
7097 @@ -0,0 +1,342 @@
7098 +/*
7099 + * Broadcom SiliconBackplane hardware register definitions.
7100 + *
7101 + * Copyright 2005, Broadcom Corporation
7102 + * All Rights Reserved.
7103 + *
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.
7108 + * $Id$
7109 + */
7110 +
7111 +#ifndef _SBCONFIG_H
7112 +#define _SBCONFIG_H
7113 +
7114 +/* cpp contortions to concatenate w/arg prescan */
7115 +#ifndef PAD
7116 +#define _PADLINE(line) pad ## line
7117 +#define _XSTR(line) _PADLINE(line)
7118 +#define PAD _XSTR(__LINE__)
7119 +#endif
7120 +
7121 +/*
7122 + * SiliconBackplane Address Map.
7123 + * All regions may not exist on all chips.
7124 + */
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 */
7131 +
7132 +#define SB_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
7133 +#define SB_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
7134 +
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 */
7138 +
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)
7145 +
7146 +
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) */
7152 +
7153 +/* mips address */
7154 +#define SB_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
7155 +
7156 +/*
7157 + * Sonics Configuration Space Registers.
7158 + */
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
7182 +
7183 +#ifndef _LANGUAGE_ASSEMBLY
7184 +
7185 +typedef volatile struct _sbconfig {
7186 + uint32 PAD[2];
7187 + uint32 sbipsflag; /* initiator port ocp slave flag */
7188 + uint32 PAD[3];
7189 + uint32 sbtpsflag; /* target port ocp slave flag */
7190 + uint32 PAD[11];
7191 + uint32 sbtmerrloga; /* (sonics >= 2.3) */
7192 + uint32 PAD;
7193 + uint32 sbtmerrlog; /* (sonics >= 2.3) */
7194 + uint32 PAD[3];
7195 + uint32 sbadmatch3; /* address match3 */
7196 + uint32 PAD;
7197 + uint32 sbadmatch2; /* address match2 */
7198 + uint32 PAD;
7199 + uint32 sbadmatch1; /* address match1 */
7200 + uint32 PAD[7];
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 */
7206 + uint32 PAD;
7207 + uint32 sbimconfiglow; /* initiator configuration */
7208 + uint32 sbimconfighigh; /* initiator configuration */
7209 + uint32 sbadmatch0; /* address match0 */
7210 + uint32 PAD;
7211 + uint32 sbtmconfiglow; /* target configuration */
7212 + uint32 sbtmconfighigh; /* target configuration */
7213 + uint32 sbbconfig; /* broadcast configuration */
7214 + uint32 PAD;
7215 + uint32 sbbstate; /* broadcast state */
7216 + uint32 PAD[3];
7217 + uint32 sbactcnfg; /* activate configuration */
7218 + uint32 PAD[3];
7219 + uint32 sbflagst; /* current sbflags */
7220 + uint32 PAD[3];
7221 + uint32 sbidlow; /* identification */
7222 + uint32 sbidhigh; /* identification */
7223 +} sbconfig_t;
7224 +
7225 +#endif /* _LANGUAGE_ASSEMBLY */
7226 +
7227 +/* sbipsflag */
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
7236 +
7237 +/* sbtpsflag */
7238 +#define SBTPS_NUM0_MASK 0x3f /* interrupt sbFlag # generated by this core */
7239 +#define SBTPS_F0EN0 0x40 /* interrupt is always sent on the backplane */
7240 +
7241 +/* sbtmerrlog */
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 */
7246 +
7247 +/* sbimstate */
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) */
7258 +
7259 +/* sbtmstatelow */
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 */
7268 +
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 */
7279 +
7280 +
7281 +/* sbbwa0 */
7282 +#define SBBWA_TAB0_MASK 0xffff /* lookup table 0 */
7283 +#define SBBWA_TAB1_MASK 0xffff /* lookup table 1 */
7284 +#define SBBWA_TAB1_SHIFT 16
7285 +
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
7292 +
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
7299 +
7300 +/* sbadmatch0 */
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
7317 +
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
7326 +
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
7337 +
7338 +/* sbbconfig */
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
7344 +
7345 +/* sbbstate */
7346 +#define SBBS_SRD 0x1 /* st reg disable */
7347 +#define SBBS_HRD 0x2 /* hold reg disable */
7348 +
7349 +/* sbidlow */
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 */
7370 +
7371 +/* sbidhigh */
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
7381 +
7382 +#define SB_COMMIT 0xfd8 /* update buffered registers value */
7383 +
7384 +/* vendor codes */
7385 +#define SB_VEND_BCM 0x4243 /* Broadcom's SB vendor code */
7386 +
7387 +/* core codes */
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 */
7417 +
7418 +#define SB_CC_IDX 0 /* chipc, when present, is always core 0 */
7419 +
7420 +/* Not really related to Silicon Backplane, but a couple of software
7421 + * conventions for the use the flash space:
7422 + */
7423 +
7424 +/* Minumum amount of flash we support */
7425 +#define FLASH_MIN 0x00020000 /* Minimum flash size */
7426 +
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 */
7438 +
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
7443 @@ -0,0 +1,242 @@
7444 +/*
7445 + * Hardware-specific External Interface I/O core definitions
7446 + * for the BCM47xx family of SiliconBackplane-based chips.
7447 + *
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.
7457 + *
7458 + * Copyright 2005, Broadcom Corporation
7459 + * All Rights Reserved.
7460 + *
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.
7465 + * $Id$
7466 + */
7467 +
7468 +#ifndef _SBEXTIF_H
7469 +#define _SBEXTIF_H
7470 +
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)
7477 +
7478 +/* cpp contortions to concatenate w/arg prescan */
7479 +#ifndef PAD
7480 +#define _PADLINE(line) pad ## line
7481 +#define _XSTR(line) _PADLINE(line)
7482 +#define PAD _XSTR(__LINE__)
7483 +#endif /* PAD */
7484 +
7485 +/*
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.
7489 + */
7490 +struct gpiouser {
7491 + uint32 out;
7492 + uint32 outen;
7493 +};
7494 +#define NGPIOUSER 5
7495 +
7496 +typedef volatile struct {
7497 + uint32 corecontrol;
7498 + uint32 extstatus;
7499 + uint32 PAD[2];
7500 +
7501 + /* pcmcia control registers */
7502 + uint32 pcmcia_config;
7503 + uint32 pcmcia_memwait;
7504 + uint32 pcmcia_attrwait;
7505 + uint32 pcmcia_iowait;
7506 +
7507 + /* programmable interface control registers */
7508 + uint32 prog_config;
7509 + uint32 prog_waitcount;
7510 +
7511 + /* flash control registers */
7512 + uint32 flash_config;
7513 + uint32 flash_waitcount;
7514 + uint32 PAD[4];
7515 +
7516 + uint32 watchdog;
7517 +
7518 + /* clock control */
7519 + uint32 clockcontrol_n;
7520 + uint32 clockcontrol_sb;
7521 + uint32 clockcontrol_pci;
7522 + uint32 clockcontrol_mii;
7523 + uint32 PAD[3];
7524 +
7525 + /* gpio */
7526 + uint32 gpioin;
7527 + struct gpiouser gpio[NGPIOUSER];
7528 + uint32 PAD;
7529 + uint32 ejtagouten;
7530 + uint32 gpiointpolarity;
7531 + uint32 gpiointmask;
7532 + uint32 PAD[153];
7533 +
7534 + uint8 uartdata;
7535 + uint8 PAD[3];
7536 + uint8 uartimer;
7537 + uint8 PAD[3];
7538 + uint8 uartfcr;
7539 + uint8 PAD[3];
7540 + uint8 uartlcr;
7541 + uint8 PAD[3];
7542 + uint8 uartmcr;
7543 + uint8 PAD[3];
7544 + uint8 uartlsr;
7545 + uint8 PAD[3];
7546 + uint8 uartmsr;
7547 + uint8 PAD[3];
7548 + uint8 uartscratch;
7549 + uint8 PAD[3];
7550 +} extifregs_t;
7551 +
7552 +/* corecontrol */
7553 +#define CC_UE (1 << 0) /* uart enable */
7554 +
7555 +/* extstatus */
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) */
7559 +
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)
7569 +
7570 +
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) */
7587 +
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
7596 +
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
7605 +
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
7614 +
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
7623 +
7624 +#define PW_W0 0x0000000c
7625 +#define PW_W1 0x00000a00
7626 +#define PW_W2 0x00020000
7627 +#define PW_W3 0x01000000
7628 +
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
7637 +
7638 +/* watchdog */
7639 +#define WATCHDOG_CLOCK 48000000 /* Hz */
7640 +
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
7645 +
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
7654 +
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
7660 +
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
7666 +
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
7674 +
7675 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
7676 +
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
7682 +
7683 +#define CC_CLOCK_BASE 24000000 /* Half the clock freq. in the 4710 */
7684 +
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
7689 @@ -0,0 +1,312 @@
7690 +/*
7691 + * Generic Broadcom Home Networking Division (HND) DMA engine HW interface
7692 + * This supports the following chips: BCM42xx, 44xx, 47xx .
7693 + *
7694 + * Copyright 2005, Broadcom Corporation
7695 + * All Rights Reserved.
7696 + *
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.
7701 + * $Id$
7702 + */
7703 +
7704 +#ifndef _sbhnddma_h_
7705 +#define _sbhnddma_h_
7706 +
7707 +
7708 +/* 2byte-wide pio register set per channel(xmt or rcv) */
7709 +typedef volatile struct {
7710 + uint16 fifocontrol;
7711 + uint16 fifodata;
7712 + uint16 fifofree; /* only valid in xmt channel, not in rcv channel */
7713 + uint16 PAD;
7714 +} pio2regs_t;
7715 +
7716 +/* a pair of pio channels(tx and rx) */
7717 +typedef volatile struct {
7718 + pio2regs_t tx;
7719 + pio2regs_t rx;
7720 +} pio2regp_t;
7721 +
7722 +/* 4byte-wide pio register set per channel(xmt or rcv) */
7723 +typedef volatile struct {
7724 + uint32 fifocontrol;
7725 + uint32 fifodata;
7726 +} pio4regs_t;
7727 +
7728 +/* a pair of pio channels(tx and rx) */
7729 +typedef volatile struct {
7730 + pio4regs_t tx;
7731 + pio4regs_t rx;
7732 +} pio4regp_t;
7733 +
7734 +
7735 +
7736 +/* DMA structure:
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
7740 + */
7741 +
7742 +
7743 +/*** 32 bits addressing ***/
7744 +
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 */
7751 +} dma32regs_t;
7752 +
7753 +typedef volatile struct {
7754 + dma32regs_t xmt; /* dma tx channel */
7755 + dma32regs_t rcv; /* dma rx channel */
7756 +} dma32regp_t;
7757 +
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 */
7763 +} dma32diag_t;
7764 +
7765 +/*
7766 + * DMA Descriptor
7767 + * Descriptors are only read by the hardware, never written back.
7768 + */
7769 +typedef volatile struct {
7770 + uint32 ctrl; /* misc control bits & bufcount */
7771 + uint32 addr; /* data buffer address */
7772 +} dma32dd_t;
7773 +
7774 +/*
7775 + * Each descriptor ring must be 4096byte aligned, and fit within a single 4096byte page.
7776 + */
7777 +#define D32MAXRINGSZ 4096
7778 +#define D32RINGALIGN 4096
7779 +#define D32MAXDD (D32MAXRINGSZ / sizeof (dma32dd_t))
7780 +
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
7788 +
7789 +/* transmit descriptor table pointer */
7790 +#define XP_LD_MASK 0xfff /* last valid descriptor */
7791 +
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
7810 +
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
7818 +
7819 +/* receive descriptor table pointer */
7820 +#define RP_LD_MASK 0xfff /* last valid descriptor */
7821 +
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
7839 +
7840 +/* fifoaddr */
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 */
7854 +
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 */
7863 +
7864 +/* control flags in the range [27:20] are core-specific and not defined here */
7865 +#define CTRL_CORE_MASK 0x0ff00000
7866 +
7867 +/*** 64 bits addressing ***/
7868 +
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 */
7877 +} dma64regs_t;
7878 +
7879 +typedef volatile struct {
7880 + dma64regs_t tx; /* dma64 tx channel */
7881 + dma64regs_t rx; /* dma64 rx channel */
7882 +} dma64regp_t;
7883 +
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 */
7889 +} dma64diag_t;
7890 +
7891 +/*
7892 + * DMA Descriptor
7893 + * Descriptors are only read by the hardware, never written back.
7894 + */
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 */
7900 +} dma64dd_t;
7901 +
7902 +/*
7903 + * Each descriptor ring must be 8kB aligned, and fit within a contiguous 8kB physical addresss.
7904 + */
7905 +#define D64MAXRINGSZ 8192
7906 +#define D64RINGALIGN 8192
7907 +#define D64MAXDD (D64MAXRINGSZ / sizeof (dma64dd_t))
7908 +
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
7916 +
7917 +/* transmit descriptor table pointer */
7918 +#define D64_XP_LD_MASK 0x00000fff /* last valid descriptor */
7919 +
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 */
7929 +
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 */
7939 +
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
7947 +
7948 +/* receive descriptor table pointer */
7949 +#define D64_RP_LD_MASK 0x00000fff /* last valid descriptor */
7950 +
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 */
7960 +
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 */
7970 +
7971 +/* fifoaddr */
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 */
7985 +
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 */
7991 +
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
7996 +
7997 +/* control flags in the range [27:20] are core-specific and not defined here */
7998 +#define D64_CTRL_CORE_MASK 0x0ff00000
7999 +
8000 +
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
8005 @@ -0,0 +1,148 @@
8006 +/*
8007 + * BCM47XX Sonics SiliconBackplane DDR/SDRAM controller core hardware definitions.
8008 + *
8009 + * Copyright 2005, Broadcom Corporation
8010 + * All Rights Reserved.
8011 + *
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.
8016 + *
8017 + * $Id$
8018 + */
8019 +
8020 +#ifndef _SBMEMC_H
8021 +#define _SBMEMC_H
8022 +
8023 +#ifdef _LANGUAGE_ASSEMBLY
8024 +
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
8046 +
8047 +
8048 +#else
8049 +
8050 +/* Sonics side: MEMC core registers */
8051 +typedef volatile struct sbmemcregs {
8052 + uint32 control;
8053 + uint32 config;
8054 + uint32 refresh;
8055 + uint32 biststat;
8056 + uint32 modebuf;
8057 + uint32 bkcls;
8058 + uint32 priorinv;
8059 + uint32 dramtim;
8060 + uint32 intstat;
8061 + uint32 intmask;
8062 + uint32 intinfo;
8063 + uint32 reserved1;
8064 + uint32 ncdlctl;
8065 + uint32 rdncdlcor;
8066 + uint32 wrncdlcor;
8067 + uint32 miscdlyctl;
8068 + uint32 dqsgatencdl;
8069 + uint32 spare;
8070 + uint32 tpaddr;
8071 + uint32 tpdata;
8072 + uint32 barrier;
8073 + uint32 core;
8074 +} sbmemcregs_t;
8075 +
8076 +#endif
8077 +
8078 +/* MEMC Core Init values (OCP ID 0x80f) */
8079 +
8080 +/* For sdr: */
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
8096 +
8097 +
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) */
8103 +
8104 +/* For ddr: */
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
8128 +
8129 +
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) */
8135 +
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
8140 +
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
8146 +
8147 +/* hw threshhold for calculating wr/rd for sdr memc */
8148 +#define MEMC_CD_THRESHOLD 128
8149 +
8150 +/* Low bit of init register says if memc is ddr or sdr */
8151 +#define MEMC_CONFIG_DDR 0x00000001
8152 +
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
8157 @@ -0,0 +1,62 @@
8158 +/*
8159 + * Broadcom SiliconBackplane MIPS definitions
8160 + *
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.
8166 + *
8167 + * Copyright 2005, Broadcom Corporation
8168 + * All Rights Reserved.
8169 + *
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.
8174 + *
8175 + * $Id$
8176 + */
8177 +
8178 +#ifndef _SBMIPS_H
8179 +#define _SBMIPS_H
8180 +
8181 +#include <mipsinc.h>
8182 +
8183 +#ifndef _LANGUAGE_ASSEMBLY
8184 +
8185 +/* cpp contortions to concatenate w/arg prescan */
8186 +#ifndef PAD
8187 +#define _PADLINE(line) pad ## line
8188 +#define _XSTR(line) _PADLINE(line)
8189 +#define PAD _XSTR(__LINE__)
8190 +#endif /* PAD */
8191 +
8192 +typedef volatile struct {
8193 + uint32 corecontrol;
8194 + uint32 PAD[2];
8195 + uint32 biststatus;
8196 + uint32 PAD[4];
8197 + uint32 intstatus;
8198 + uint32 intmask;
8199 + uint32 timer;
8200 +} mipsregs_t;
8201 +
8202 +extern uint32 sb_flag(sb_t *sbh);
8203 +extern uint sb_irq(sb_t *sbh);
8204 +
8205 +extern void BCMINIT(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift));
8206 +
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);
8215 +
8216 +
8217 +#endif /* _LANGUAGE_ASSEMBLY */
8218 +
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
8223 @@ -0,0 +1,199 @@
8224 +/*
8225 + * BCM43XX SiliconBackplane PCIE core hardware definitions.
8226 + *
8227 + * $Id:
8228 + * Copyright 2005, Broadcom Corporation
8229 + * All Rights Reserved.
8230 + *
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.
8235 + */
8236 +
8237 +#ifndef _SBPCIE_H
8238 +#define _SBPCIE_H
8239 +
8240 +/* cpp contortions to concatenate w/arg prescan */
8241 +#ifndef PAD
8242 +#define _PADLINE(line) pad ## line
8243 +#define _XSTR(line) _PADLINE(line)
8244 +#define PAD _XSTR(__LINE__)
8245 +#endif
8246 +
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
8255 +
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
8261 +
8262 +/* SB side: PCIE core and host control registers */
8263 +typedef struct sbpcieregs {
8264 +
8265 + uint32 PAD[3];
8266 + uint32 biststatus; /* bist Status: 0x00C*/
8267 + uint32 PAD[6];
8268 + uint32 sbtopcimailbox; /* sb to pcie mailbox: 0x028*/
8269 + uint32 PAD[54];
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 */
8273 + uint32 PAD[4];
8274 +
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*/
8278 +
8279 + /* mdio access to serdes */
8280 + uint32 mdiocontrol; /* controls the mdio access: 0x128 */
8281 + uint32 mdiodata; /* Data to the mdio access: 0x12c */
8282 +
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 */
8286 +
8287 + uint32 PAD[434];
8288 + uint16 sprom[36]; /* SPROM shadow Area */
8289 +} sbpcieregs_t;
8290 +
8291 +/* SB to PCIE translation masks */
8292 +#define SBTOPCIE0_MASK 0xfc000000
8293 +#define SBTOPCIE1_MASK 0xfc000000
8294 +#define SBTOPCIE2_MASK 0xc0000000
8295 +
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
8301 +
8302 +/*Prefetch enable bit 2*/
8303 +#define SBTOPCIE_PF 4
8304 +
8305 +/*Write Burst enable for memory write bit 3*/
8306 +#define SBTOPCIE_WR_BURST 8
8307 +
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
8313 +
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
8320 +
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*/
8338 +
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*/
8361 +
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*/
8394 +
8395 +/* MDIO control */
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 */
8400 +
8401 +/* MDIO Data */
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 */
8411 +
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 */
8416 +
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 */
8421 +
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
8426 @@ -0,0 +1,122 @@
8427 +/*
8428 + * BCM47XX Sonics SiliconBackplane PCI core hardware definitions.
8429 + *
8430 + * $Id$
8431 + * Copyright 2005, Broadcom Corporation
8432 + * All Rights Reserved.
8433 + *
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.
8438 + */
8439 +
8440 +#ifndef _SBPCI_H
8441 +#define _SBPCI_H
8442 +
8443 +/* cpp contortions to concatenate w/arg prescan */
8444 +#ifndef PAD
8445 +#define _PADLINE(line) pad ## line
8446 +#define _XSTR(line) _PADLINE(line)
8447 +#define PAD _XSTR(__LINE__)
8448 +#endif
8449 +
8450 +/* Sonics side: PCI core and host control registers */
8451 +typedef struct sbpciregs {
8452 + uint32 control; /* PCI control */
8453 + uint32 PAD[3];
8454 + uint32 arbcontrol; /* PCI arbiter control */
8455 + uint32 PAD[3];
8456 + uint32 intstatus; /* Interrupt status */
8457 + uint32 intmask; /* Interrupt mask */
8458 + uint32 sbtopcimailbox; /* Sonics to PCI mailbox */
8459 + uint32 PAD[9];
8460 + uint32 bcastaddr; /* Sonics broadcast address */
8461 + uint32 bcastdata; /* Sonics broadcast data */
8462 + uint32 PAD[2];
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) */
8467 + uint32 PAD[36];
8468 + uint32 sbtopci0; /* Sonics to PCI translation 0 */
8469 + uint32 sbtopci1; /* Sonics to PCI translation 1 */
8470 + uint32 sbtopci2; /* Sonics to PCI translation 2 */
8471 + uint32 PAD[445];
8472 + uint16 sprom[36]; /* SPROM shadow Area */
8473 + uint32 PAD[46];
8474 +} sbpciregs_t;
8475 +
8476 +/* PCI control */
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 */
8481 +
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 */
8491 +
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 */
8498 +
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 */
8508 +
8509 +/* Sonics broadcast address */
8510 +#define BCAST_ADDR_MASK 0xff /* Broadcast register address */
8511 +
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 */
8526 +
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 */
8531 +
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]
8537 +
8538 +#ifndef _LANGUAGE_ASSEMBLY
8539 +
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);
8545 +
8546 +#endif /* !_LANGUAGE_ASSEMBLY */
8547 +
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
8552 @@ -0,0 +1,146 @@
8553 +/*
8554 + * BCM43XX Sonics SiliconBackplane PCMCIA core hardware definitions.
8555 + *
8556 + * $Id$
8557 + * Copyright 2005, Broadcom Corporation
8558 + * All Rights Reserved.
8559 + *
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.
8564 + */
8565 +
8566 +#ifndef _SBPCMCIA_H
8567 +#define _SBPCMCIA_H
8568 +
8569 +
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.
8575 + */
8576 +
8577 +/* PCMCIA Function Configuration Registers */
8578 +#define PCMCIA_FCR (0x700 / 2)
8579 +
8580 +#define FCR0_OFF 0
8581 +#define FCR1_OFF (0x40 / 2)
8582 +#define FCR2_OFF (0x80 / 2)
8583 +#define FCR3_OFF (0xc0 / 2)
8584 +
8585 +#define PCMCIA_FCR0 (0x700 / 2)
8586 +#define PCMCIA_FCR1 (0x740 / 2)
8587 +#define PCMCIA_FCR2 (0x780 / 2)
8588 +#define PCMCIA_FCR3 (0x7c0 / 2)
8589 +
8590 +/* Standard PCMCIA FCR registers */
8591 +
8592 +#define PCMCIA_COR 0
8593 +
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
8599 +
8600 +
8601 +#define PCICIA_FCSR (2 / 2)
8602 +#define PCICIA_PRR (4 / 2)
8603 +#define PCICIA_SCR (6 / 2)
8604 +#define PCICIA_ESR (8 / 2)
8605 +
8606 +
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
8612 +
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)
8617 +
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)
8622 +
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)
8629 +
8630 +/* Values for srom_cs: */
8631 +#define SROM_IDLE 0
8632 +#define SROM_WRITE 1
8633 +#define SROM_READ 2
8634 +#define SROM_WEN 4
8635 +#define SROM_WDS 7
8636 +#define SROM_DONE 8
8637 +
8638 +/* CIS stuff */
8639 +
8640 +/* The CIS stops where the FCRs start */
8641 +#define CIS_SIZE PCMCIA_FCR
8642 +
8643 +/* Standard tuples we know about */
8644 +
8645 +#define CISTPL_MANFID 0x20 /* Manufacturer and device id */
8646 +#define CISTPL_FUNCE 0x22 /* Function extensions */
8647 +#define CISTPL_CFTABLE 0x1b /* Config table entry */
8648 +
8649 +/* Function extensions for LANs */
8650 +
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 */
8656 +
8657 +
8658 +/* CFTable */
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 */
8662 +
8663 +/* Vendor unique tuples are 0x80-0x8f. Within Broadcom we'll
8664 + * take one for HNBU, and use "extensions" (a la FUNCE) within it.
8665 + */
8666 +
8667 +#define CISTPL_BRCM_HNBU 0x80
8668 +
8669 +/* Subtypes of BRCM_HNBU: */
8670 +
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
8674 + */
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)
8685 + * in rev 2
8686 + */
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 */
8689 +
8690 +
8691 +/* sbtmstatelow */
8692 +#define SBTML_INT_ACK 0x40000 /* ack the sb interrupt */
8693 +#define SBTML_INT_EN 0x20000 /* enable sb interrupt */
8694 +
8695 +/* sbtmstatehigh */
8696 +#define SBTMH_INT_STATUS 0x40000 /* sb interrupt status */
8697 +
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
8702 @@ -0,0 +1,75 @@
8703 +/*
8704 + * BCM47XX Sonics SiliconBackplane SDRAM controller core hardware definitions.
8705 + *
8706 + * Copyright 2005, Broadcom Corporation
8707 + * All Rights Reserved.
8708 + *
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.
8713 + * $Id$
8714 + */
8715 +
8716 +#ifndef _SBSDRAM_H
8717 +#define _SBSDRAM_H
8718 +
8719 +#ifndef _LANGUAGE_ASSEMBLY
8720 +
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 */
8726 + uint32 pad1;
8727 + uint32 pad2;
8728 +} sbsdramregs_t;
8729 +
8730 +#endif
8731 +
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 */
8746 +
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 */
8754 +
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 */
8758 +
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)
8763 +
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 */
8776 +
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
8781 @@ -0,0 +1,37 @@
8782 +/*
8783 + * BCM47XX Sonics SiliconBackplane embedded ram core
8784 + *
8785 + * Copyright 2005, Broadcom Corporation
8786 + * All Rights Reserved.
8787 + *
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.
8792 + *
8793 + * $Id$
8794 + */
8795 +
8796 +#ifndef _SBSOCRAM_H
8797 +#define _SBSOCRAM_H
8798 +
8799 +#define SOCRAM_MEMSIZE 0x00
8800 +#define SOCRAM_BISTSTAT 0x0c
8801 +
8802 +
8803 +#ifndef _LANGUAGE_ASSEMBLY
8804 +
8805 +/* Memcsocram core registers */
8806 +typedef volatile struct sbsocramregs {
8807 + uint32 memsize;
8808 + uint32 biststat;
8809 +} sbsocramregs_t;
8810 +
8811 +#endif
8812 +
8813 +/* Them memory size is 2 to the power of the following
8814 + * base added to the contents of the memsize register.
8815 + */
8816 +#define SOCRAM_MEMSIZE_BASESHIFT 16
8817 +
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
8822 @@ -0,0 +1,140 @@
8823 +/*
8824 + * Misc utility routines for accessing chip-specific features
8825 + * of Broadcom HNBU SiliconBackplane-based chips.
8826 + *
8827 + * Copyright 2005, Broadcom Corporation
8828 + * All Rights Reserved.
8829 + *
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.
8834 + *
8835 + * $Id$
8836 + */
8837 +
8838 +#ifndef _sbutils_h_
8839 +#define _sbutils_h_
8840 +
8841 +/*
8842 + * Datastructure to export all chip specific common variables
8843 + * public (read-only) portion of sbutils handle returned by
8844 + * sb_attach()/sb_kattach()
8845 +*/
8846 +
8847 +struct sb_pub {
8848 +
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 */
8860 +};
8861 +
8862 +typedef const struct sb_pub sb_t;
8863 +
8864 +/*
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.
8870 + */
8871 +
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);
8923 +
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);
8936 +
8937 +
8938 +
8939 +/*
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.
8943 +*/
8944 +extern int sb_devpath(sb_t *sbh, char *path, int size);
8945 +
8946 +/* clkctl xtal what flags */
8947 +#define XTAL 0x1 /* primary crystal oscillator (2050) */
8948 +#define PLL 0x2 /* main chip pll */
8949 +
8950 +/* clkctl clk mode */
8951 +#define CLK_FAST 0 /* force fast (pll) clock */
8952 +#define CLK_DYNAMIC 2 /* enable dynamic clock control */
8953 +
8954 +
8955 +/* GPIO usage priorities */
8956 +#define GPIO_DRV_PRIORITY 0
8957 +#define GPIO_APP_PRIORITY 1
8958 +
8959 +/* device path */
8960 +#define SB_DEVPATH_BUFSZ 16 /* min buffer size in bytes */
8961 +
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
8966 @@ -0,0 +1,36 @@
8967 +/*
8968 + * Broadcom SiliconBackplane chipcommon serial flash interface
8969 + *
8970 + * Copyright 2005, Broadcom Corporation
8971 + * All Rights Reserved.
8972 + *
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.
8977 + *
8978 + * $Id$
8979 + */
8980 +
8981 +#ifndef _sflash_h_
8982 +#define _sflash_h_
8983 +
8984 +#include <typedefs.h>
8985 +#include <sbchipc.h>
8986 +
8987 +struct sflash {
8988 + uint blocksize; /* Block size */
8989 + uint numblocks; /* Number of blocks */
8990 + uint32 type; /* Type */
8991 + uint size; /* Total size in bytes */
8992 +};
8993 +
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);
9001 +
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
9006 @@ -0,0 +1,33 @@
9007 +/*
9008 + * TRX image file header format.
9009 + *
9010 + * Copyright 2005, Broadcom Corporation
9011 + * All Rights Reserved.
9012 + *
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.
9017 + *
9018 + * $Id$
9019 + */
9020 +
9021 +#include <typedefs.h>
9022 +
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
9029 +
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 */
9036 +};
9037 +
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
9043 @@ -0,0 +1,326 @@
9044 +/*
9045 + * Copyright 2005, Broadcom Corporation
9046 + * All Rights Reserved.
9047 + *
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.
9052 + * $Id$
9053 + */
9054 +
9055 +#ifndef _TYPEDEFS_H_
9056 +#define _TYPEDEFS_H_
9057 +
9058 +
9059 +/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
9060 + * typedef file "site_typedefs.h".
9061 + *
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.
9065 + *
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, ...).
9070 + */
9071 +
9072 +#ifdef SITE_TYPEDEFS
9073 +
9074 +/*******************************************************************************
9075 + * Site Specific Typedefs
9076 + *******************************************************************************/
9077 +
9078 +#include "site_typedefs.h"
9079 +
9080 +#else
9081 +
9082 +/*******************************************************************************
9083 + * Inferred Typedefs
9084 + *******************************************************************************/
9085 +
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.
9089 + */
9090 +
9091 +#ifdef __cplusplus
9092 +
9093 +#define TYPEDEF_BOOL
9094 +#ifndef FALSE
9095 +#define FALSE false
9096 +#endif
9097 +#ifndef TRUE
9098 +#define TRUE true
9099 +#endif
9100 +
9101 +#else /* ! __cplusplus */
9102 +
9103 +#if defined(_WIN32)
9104 +
9105 +#define TYPEDEF_BOOL
9106 +typedef unsigned char bool; /* consistent w/BOOL */
9107 +
9108 +#endif /* _WIN32 */
9109 +
9110 +#endif /* ! __cplusplus */
9111 +
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;
9117 +#endif
9118 +
9119 +#ifdef _HNDRTE_
9120 +typedef long unsigned int size_t;
9121 +#endif
9122 +
9123 +#ifdef _MSC_VER /* Microsoft C */
9124 +#define TYPEDEF_INT64
9125 +#define TYPEDEF_UINT64
9126 +typedef signed __int64 int64;
9127 +typedef unsigned __int64 uint64;
9128 +#endif
9129 +
9130 +#if defined(MACOSX) && defined(KERNEL)
9131 +#define TYPEDEF_BOOL
9132 +#endif
9133 +
9134 +
9135 +#if defined(linux)
9136 +#define TYPEDEF_UINT
9137 +#define TYPEDEF_USHORT
9138 +#define TYPEDEF_ULONG
9139 +#endif
9140 +
9141 +#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
9142 +#define TYPEDEF_UINT
9143 +#define TYPEDEF_USHORT
9144 +#endif
9145 +
9146 +
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
9151 +#endif
9152 +
9153 +/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
9154 + * for singned or unsigned */
9155 +#if defined(__ICL)
9156 +
9157 +#define TYPEDEF_INT64
9158 +
9159 +#if defined(__STDC__)
9160 +#define TYPEDEF_UINT64
9161 +#endif
9162 +
9163 +#endif /* __ICL */
9164 +
9165 +
9166 +#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
9167 +
9168 +/* pick up ushort & uint from standard types.h */
9169 +#if defined(linux) && defined(__KERNEL__)
9170 +
9171 +#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
9172 +
9173 +#else
9174 +
9175 +#include <sys/types.h>
9176 +
9177 +#endif
9178 +
9179 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */
9180 +
9181 +#if defined(MACOSX) && defined(KERNEL)
9182 +#include <IOKit/IOTypes.h>
9183 +#endif
9184 +
9185 +
9186 +/* use the default typedefs in the next section of this file */
9187 +#define USE_TYPEDEF_DEFAULTS
9188 +
9189 +#endif /* SITE_TYPEDEFS */
9190 +
9191 +
9192 +/*******************************************************************************
9193 + * Default Typedefs
9194 + *******************************************************************************/
9195 +
9196 +#ifdef USE_TYPEDEF_DEFAULTS
9197 +#undef USE_TYPEDEF_DEFAULTS
9198 +
9199 +#ifndef TYPEDEF_BOOL
9200 +typedef /*@abstract@*/ unsigned char bool;
9201 +#endif
9202 +
9203 +/*----------------------- define uchar, ushort, uint, ulong ------------------*/
9204 +
9205 +#ifndef TYPEDEF_UCHAR
9206 +typedef unsigned char uchar;
9207 +#endif
9208 +
9209 +#ifndef TYPEDEF_USHORT
9210 +typedef unsigned short ushort;
9211 +#endif
9212 +
9213 +#ifndef TYPEDEF_UINT
9214 +typedef unsigned int uint;
9215 +#endif
9216 +
9217 +#ifndef TYPEDEF_ULONG
9218 +typedef unsigned long ulong;
9219 +#endif
9220 +
9221 +/*----------------------- define [u]int8/16/32/64, uintptr --------------------*/
9222 +
9223 +#ifndef TYPEDEF_UINT8
9224 +typedef unsigned char uint8;
9225 +#endif
9226 +
9227 +#ifndef TYPEDEF_UINT16
9228 +typedef unsigned short uint16;
9229 +#endif
9230 +
9231 +#ifndef TYPEDEF_UINT32
9232 +typedef unsigned int uint32;
9233 +#endif
9234 +
9235 +#ifndef TYPEDEF_UINT64
9236 +typedef unsigned long long uint64;
9237 +#endif
9238 +
9239 +#ifndef TYPEDEF_UINTPTR
9240 +typedef unsigned int uintptr;
9241 +#endif
9242 +
9243 +#ifndef TYPEDEF_INT8
9244 +typedef signed char int8;
9245 +#endif
9246 +
9247 +#ifndef TYPEDEF_INT16
9248 +typedef signed short int16;
9249 +#endif
9250 +
9251 +#ifndef TYPEDEF_INT32
9252 +typedef signed int int32;
9253 +#endif
9254 +
9255 +#ifndef TYPEDEF_INT64
9256 +typedef signed long long int64;
9257 +#endif
9258 +
9259 +/*----------------------- define float32/64, float_t -----------------------*/
9260 +
9261 +#ifndef TYPEDEF_FLOAT32
9262 +typedef float float32;
9263 +#endif
9264 +
9265 +#ifndef TYPEDEF_FLOAT64
9266 +typedef double float64;
9267 +#endif
9268 +
9269 +/*
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.
9273 + */
9274 +
9275 +#ifndef TYPEDEF_FLOAT_T
9276 +
9277 +#if defined(FLOAT32)
9278 +typedef float32 float_t;
9279 +#else /* default to double precision floating point */
9280 +typedef float64 float_t;
9281 +#endif
9282 +
9283 +#endif /* TYPEDEF_FLOAT_T */
9284 +
9285 +/*----------------------- define macro values -----------------------------*/
9286 +
9287 +#ifndef FALSE
9288 +#define FALSE 0
9289 +#endif
9290 +
9291 +#ifndef TRUE
9292 +#define TRUE 1
9293 +#endif
9294 +
9295 +#ifndef NULL
9296 +#define NULL 0
9297 +#endif
9298 +
9299 +#ifndef OFF
9300 +#define OFF 0
9301 +#endif
9302 +
9303 +#ifndef ON
9304 +#define ON 1
9305 +#endif
9306 +
9307 +#define AUTO (-1)
9308 +
9309 +/* Reclaiming text and data :
9310 + The following macros specify special linker sections that can be reclaimed
9311 + after a system is considered 'up'.
9312 + */
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
9318 +#else
9319 +#define BCMINITDATA(_data) _data
9320 +#define BCMINITFN(_fn) _fn
9321 +#define BCMINIT(_id) _id
9322 +#define bcmreclaimed 0
9323 +#endif
9324 +
9325 +/*----------------------- define PTRSZ, INLINE ----------------------------*/
9326 +
9327 +#ifndef PTRSZ
9328 +#define PTRSZ sizeof (char*)
9329 +#endif
9330 +
9331 +#ifndef INLINE
9332 +
9333 +#ifdef _MSC_VER
9334 +
9335 +#define INLINE __inline
9336 +
9337 +#elif __GNUC__
9338 +
9339 +#define INLINE __inline__
9340 +
9341 +#else
9342 +
9343 +#define INLINE
9344 +
9345 +#endif /* _MSC_VER */
9346 +
9347 +#endif /* INLINE */
9348 +
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
9366 +
9367 +#endif /* USE_TYPEDEF_DEFAULTS */
9368 +
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
9373 @@ -0,0 +1,1030 @@
9374 +/*
9375 + * Custom OID/ioctl definitions for
9376 + * Broadcom 802.11abg Networking Device Driver
9377 + *
9378 + * Definitions subject to change without notice.
9379 + *
9380 + * Copyright 2005, Broadcom Corporation
9381 + * All Rights Reserved.
9382 + *
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.
9387 + *
9388 + * $Id$
9389 + */
9390 +
9391 +#ifndef _wlioctl_h_
9392 +#define _wlioctl_h_
9393 +
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>
9399 +
9400 +/* require default structure packing */
9401 +#if !defined(__GNUC__)
9402 +#pragma pack(push,8)
9403 +#endif
9404 +
9405 +#define WL_NUMRATES 255 /* max # of rates in a rateset */
9406 +
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 */
9410 +} wl_rateset_t;
9411 +
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
9417 +
9418 +/*
9419 + * Per-bss information structure.
9420 + */
9421 +
9422 +#define WL_BSS_INFO_VERSION 107 /* current version of wl_bss_info struct */
9423 +
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 */
9430 + uint8 SSID_len;
9431 + uint8 SSID[32];
9432 + struct {
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 */
9443 +} wl_bss_info_t;
9444 +
9445 +typedef struct wlc_ssid {
9446 + uint32 SSID_len;
9447 + uchar SSID[32];
9448 +} wlc_ssid_t;
9449 +
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
9464 +
9465 +typedef struct wl_scan_results {
9466 + uint32 buflen;
9467 + uint32 version;
9468 + uint32 count;
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
9473 +
9474 +/* uint32 list */
9475 +typedef struct wl_uint32_list {
9476 + /* in - # of elements, out - # of entries */
9477 + uint32 count;
9478 + /* variable length uint32 list */
9479 + uint32 element[1];
9480 +} wl_uint32_list_t;
9481 +
9482 +#define WLC_CNTRY_BUF_SZ 4 /* Country string is 3 bytes + NULL */
9483 +
9484 +typedef struct wl_channels_in_country {
9485 + uint32 buflen;
9486 + uint32 band;
9487 + char country_abbrev[WLC_CNTRY_BUF_SZ];
9488 + uint32 count;
9489 + uint32 channel[1];
9490 +} wl_channels_in_country_t;
9491 +
9492 +typedef struct wl_country_list {
9493 + uint32 buflen;
9494 + uint32 band_set;
9495 + uint32 band;
9496 + uint32 count;
9497 + char country_abbrev[1];
9498 +} wl_country_list_t;
9499 +
9500 +#define WL_RM_TYPE_BASIC 1
9501 +#define WL_RM_TYPE_CCA 2
9502 +#define WL_RM_TYPE_RPI 3
9503 +
9504 +#define WL_RM_FLAG_PARALLEL (1<<0)
9505 +
9506 +#define WL_RM_FLAG_LATE (1<<1)
9507 +#define WL_RM_FLAG_INCAPABLE (1<<2)
9508 +#define WL_RM_FLAG_REFUSED (1<<3)
9509 +
9510 +typedef struct wl_rm_req_elt {
9511 + int8 type;
9512 + int8 flags;
9513 + uint16 chanspec;
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 */
9518 +} wl_rm_req_elt_t;
9519 +
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 */
9524 +} wl_rm_req_t;
9525 +#define WL_RM_REQ_FIXED_LEN 8
9526 +
9527 +typedef struct wl_rm_rep_elt {
9528 + int8 type;
9529 + int8 flags;
9530 + uint16 chanspec;
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 */
9537 +} wl_rm_rep_elt_t;
9538 +#define WL_RM_REP_ELT_FIXED_LEN 24 /* length excluding data block */
9539 +
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];
9544 +} wl_rm_rpi_rep_t;
9545 +
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 */
9550 +} wl_rm_rep_t;
9551 +#define WL_RM_REP_FIXED_LEN 8
9552 +
9553 +
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,
9562 + WLC_SUP_KEYED,
9563 + WLC_SUP_TIMEOUT
9564 +} sup_auth_status_t;
9565 +#endif /* BCMCCX | BCMSUP_PSK */
9566 +
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
9576 +
9577 +#define WSEC_GEN_MIC_ERROR 0x0001
9578 +#define WSEC_GEN_REPLAY 0x0002
9579 +
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 */
9584 +
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 */
9589 + uint32 pad_1[18];
9590 + uint32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
9591 + uint32 flags; /* misc flags */
9592 + uint32 pad_2[2];
9593 + int pad_3;
9594 + int iv_initialized; /* has IV been initialized already? */
9595 + int pad_4;
9596 + /* Rx IV */
9597 + struct {
9598 + uint32 hi; /* upper 32 bits of IV */
9599 + uint16 lo; /* lower 16 bits of IV */
9600 + } rxiv;
9601 + uint32 pad_5[2];
9602 + struct ether_addr ea; /* per station */
9603 +} wl_wsec_key_t;
9604 +
9605 +
9606 +#define WSEC_MIN_PSK_LEN 8
9607 +#define WSEC_MAX_PSK_LEN 64
9608 +
9609 +/* Flag for key material needing passhash'ing */
9610 +#define WSEC_PASSPHRASE (1<<0)
9611 +
9612 +/* recepticle for WLC_SET_WSEC_PMK parameter */
9613 +typedef struct {
9614 + ushort key_len; /* octets in key material */
9615 + ushort flags; /* key handling qualification */
9616 + uint8 key[WSEC_MAX_PSK_LEN]; /* PMK material */
9617 +} wsec_pmk_t;
9618 +
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 */
9625 +
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 */
9632 +
9633 +#define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
9634 +#define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
9635 +
9636 +
9637 +
9638 +/* pmkid */
9639 +#define MAXPMKID 16
9640 +
9641 +typedef struct _pmkid
9642 +{
9643 + struct ether_addr BSSID;
9644 + uint8 PMKID[WPA2_PMKID_LEN];
9645 +} pmkid_t;
9646 +
9647 +typedef struct _pmkid_list
9648 +{
9649 + uint32 npmkid;
9650 + pmkid_t pmkid[1];
9651 +} pmkid_list_t;
9652 +
9653 +typedef struct _pmkid_cand {
9654 + struct ether_addr BSSID;
9655 + uint8 preauth;
9656 +} pmkid_cand_t;
9657 +
9658 +typedef struct _pmkid_cand_list {
9659 + uint32 npmkid_cand;
9660 + pmkid_cand_t pmkid_cand[1];
9661 +} pmkid_cand_list_t;
9662 +
9663 +
9664 +typedef struct wl_led_info {
9665 + uint32 index; /* led index */
9666 + uint32 behavior;
9667 + bool activehi;
9668 +} wl_led_info_t;
9669 +
9670 +typedef struct wlc_assoc_info {
9671 + uint32 req_len;
9672 + uint32 resp_len;
9673 + uint32 flags;
9674 + struct dot11_assoc_req req;
9675 + struct ether_addr reassoc_bssid; /* used in reassoc's */
9676 + struct dot11_assoc_resp resp;
9677 +} wl_assoc_info_t;
9678 +/* flags */
9679 +#define WLC_ASSOC_REQ_IS_REASSOC 0x01 /* assoc req was actually a reassoc */
9680 +/* srom read/write struct passed through ioctl */
9681 +typedef struct {
9682 + uint byteoff; /* byte offset */
9683 + uint nbytes; /* number of bytes */
9684 + uint16 buf[1];
9685 +} srom_rw_t;
9686 +
9687 +/* R_REG and W_REG struct passed through ioctl */
9688 +typedef struct {
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) */
9693 +} rw_reg_t;
9694 +
9695 +/* Structure used by GET/SET_ATTEN ioctls */
9696 +typedef struct {
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 */
9701 +} atten_t;
9702 +
9703 +/* Used to get specific STA parameters */
9704 +typedef struct {
9705 + uint32 val;
9706 + struct ether_addr ea;
9707 +} scb_val_t;
9708 +
9709 +
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 */
9717 +} wlc_event_t;
9718 +
9719 +#define BCM_MAC_STATUS_INDICATION (0x40010200L)
9720 +
9721 +typedef struct {
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*/
9731 +} sta_info_t;
9732 +
9733 +#define WL_STA_VER 2
9734 +
9735 +/* flags fields */
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
9744 +
9745 +
9746 +/*
9747 + * Country locale determines which channels are available to us.
9748 + */
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 */
9762 + WLC_LAST_LOCALE,
9763 + WLC_UNDEFINED_LOCALE = 0xf
9764 +} wlc_locale_t;
9765 +
9766 +/* channel encoding */
9767 +typedef struct channel_info {
9768 + int hw_channel;
9769 + int target_channel;
9770 + int scan_channel;
9771 +} channel_info_t;
9772 +
9773 +/* For ioctls that take a list of MAC addresses */
9774 +struct maclist {
9775 + uint count; /* number of MAC addresses */
9776 + struct ether_addr ea[1]; /* variable length array of MAC addresses */
9777 +};
9778 +
9779 +/* get pkt count struct passed through ioctl */
9780 +typedef struct get_pktcnt {
9781 + uint rx_good_pkt;
9782 + uint rx_bad_pkt;
9783 + uint tx_good_pkt;
9784 + uint tx_bad_pkt;
9785 +} get_pktcnt_t;
9786 +
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) */
9795 +} wl_ioctl_t;
9796 +
9797 +/*
9798 + * Structure for passing hardware and software
9799 + * revision info up from the driver.
9800 + */
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 */
9814 +} wlc_rev_info_t;
9815 +
9816 +#define WL_BRAND_MAX 10
9817 +typedef struct wl_instance_info {
9818 + uint instance;
9819 + char brand[WL_BRAND_MAX];
9820 +} wl_instance_info_t;
9821 +
9822 +/* check this magic number */
9823 +#define WLC_IOCTL_MAGIC 0x14e46c77
9824 +
9825 +/* bump this number if you change the ioctl interface */
9826 +#define WLC_IOCTL_VERSION 1
9827 +
9828 +#define WLC_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */
9829 +#define WLC_IOCTL_SMLEN 256 /* "small" length ioctl buffer required */
9830 +
9831 +/* common ioctl definitions */
9832 +#define WLC_GET_MAGIC 0
9833 +#define WLC_GET_VERSION 1
9834 +#define WLC_UP 2
9835 +#define WLC_DOWN 3
9836 +#define WLC_DUMP 6
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 */
9987 +
9988 +/*
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.
9994 + */
9995 +#ifndef EPICTRL_COOKIE
9996 +#define EPICTRL_COOKIE 0xABADCEDE
9997 +#endif
9998 +
9999 +/* vx wlc ioctl's offset */
10000 +#define CMN_IOCTL_OFF 0x180
10001 +
10002 +/*
10003 + * custom OID support
10004 + *
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
10009 + */
10010 +
10011 +/* begin 0x1f values beyond the start of the ET driver range. */
10012 +#define WL_OID_BASE 0xFFE41420
10013 +
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)
10017 +
10018 +#define WL_DECRYPT_STATUS_SUCCESS 1
10019 +#define WL_DECRYPT_STATUS_FAILURE 2
10020 +#define WL_DECRYPT_STATUS_UNKNOWN 3
10021 +
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
10025 +
10026 +#ifdef CONFIG_USBRNDIS_RETAIL
10027 +/* struct passed in for WLC_NDCONFIG_ITEM */
10028 +typedef struct {
10029 + char *name;
10030 + void *param;
10031 +} ndconfig_item_t;
10032 +#endif
10033 +
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 */
10039 +
10040 +/* Override bit for WLC_SET_TXPWR. if set, ignore other level limits */
10041 +#define WL_TXPWR_OVERRIDE (1<<31)
10042 +
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 */
10050 +
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 */
10062 +
10063 +/* Bus types */
10064 +#define WL_SB_BUS 0 /* Silicon Backplane */
10065 +#define WL_PCI_BUS 1 /* PCI target */
10066 +#define WL_PCMCIA_BUS 2 /* PCMCIA target */
10067 +
10068 +/* band types */
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 */
10073 +
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
10079 +
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) */
10084 +
10085 +/*
10086 + *
10087 + */
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
10095 +
10096 +/* values for PLCPHdr_override */
10097 +#define WLC_PLCP_AUTO -1
10098 +#define WLC_PLCP_SHORT 0
10099 +#define WLC_PLCP_LONG 1
10100 +
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
10105 +
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
10110 +
10111 +/* Values for PM */
10112 +#define PM_OFF 0
10113 +#define PM_MAX 1
10114 +#define PM_FAST 2
10115 +
10116 +
10117 +
10118 +typedef struct {
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;
10126 +
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 */
10131 +
10132 +/* dfs_status iovar-related defines */
10133 +
10134 +/* cac - channel availability check,
10135 + * ism - in-service monitoring
10136 + * csa - channel switching anouncement
10137 + */
10138 +
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 */
10148 +
10149 +/* data structure used in 'dfs_status' wl interface, which is used to query dfs status */
10150 +typedef struct {
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
10155 + */
10156 + uint channel_cleared;
10157 +} wl_dfs_status_t;
10158 +
10159 +#define NUM_PWRCTRL_RATES 12
10160 +
10161 +
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 */
10167 +
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 */
10174 +
10175 +#define WL_MPC_VAL 0x00400000
10176 +#define WL_APSTA_VAL 0x00800000
10177 +#define WL_DFS_VAL 0x01000000
10178 +
10179 +/* max # of leds supported by GPIO (gpio pin# == led index#) */
10180 +#define WL_LED_NUMGPIO 16 /* gpio 0-15 */
10181 +
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
10196 +
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 */
10200 +
10201 +
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 */
10206 +
10207 +/* number of bytes needed to define a 128-bit mask for MAC event reporting */
10208 +#define WL_EVENTING_MASK_LEN 16
10209 +
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) */
10212 +
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
10218 +
10219 +typedef struct {
10220 + uint32 pktflag; /* bitmask indicating which packet(s) contain this IE */
10221 + vndr_ie_t vndr_ie_data; /* vendor IE data */
10222 +} vndr_ie_info_t;
10223 +
10224 +typedef struct {
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 */
10227 +} vndr_ie_buf_t;
10228 +
10229 +typedef struct {
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;
10233 +
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 */
10238 +
10239 +/* band preference */
10240 +#define WLJP_BAND_ASSOC_PREF 255 /* use assoc preference settings */
10241 + /* others use WLC_BAND_XXXX as values */
10242 +
10243 +/* any multicast cipher suite */
10244 +#define WL_WPA_ACP_MCS_ANY "\x00\x00\x00\x00"
10245 +
10246 +#if !defined(__GNUC__)
10247 +#pragma pack(pop)
10248 +#endif
10249 +
10250 +#define NFIFO 6 /* # tx/rx fifopairs */
10251 +
10252 +#define WL_CNT_T_VERSION 1 /* current version of wl_cnt_t struct */
10253 +
10254 +typedef struct {
10255 + uint16 version; /* see definition of WL_CNT_T_VERSION */
10256 + uint16 length; /* length of entire structure */
10257 +
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) */
10271 +
10272 + /* transmit chip error counters */
10273 + uint32 txuflo; /* tx fifo underflows */
10274 + uint32 txphyerr; /* tx phy errors (indicated in tx status) */
10275 + uint32 txphycrs;
10276 +
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 */
10294 +
10295 + /* receive chip error counters */
10296 + uint32 rxoflo; /* rx fifo overflow errors */
10297 + uint32 rxuflo[NFIFO]; /* rx dma descriptor underflow errors */
10298 +
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 */
10302 +
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 */
10309 + uint32 txdmawar;
10310 +
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
10345 + to see these) */
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
10350 + response */
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 */
10371 +
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 */
10387 +
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 */
10401 +} wl_cnt_t;
10402 +
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
10407 @@ -0,0 +1,15 @@
10408 +#
10409 +# Makefile for the BCM947xx specific kernel interface routines
10410 +# under Linux.
10411 +#
10412 +
10413 +EXTRA_CFLAGS+=-I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
10414 +
10415 +O_TARGET := bcm947xx.o
10416 +
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
10421 +
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
10426 @@ -0,0 +1,320 @@
10427 +/*
10428 + * NVRAM variable manipulation (common)
10429 + *
10430 + * Copyright 2004, Broadcom Corporation
10431 + * All Rights Reserved.
10432 + *
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.
10437 + *
10438 + */
10439 +
10440 +#include <typedefs.h>
10441 +#include <osl.h>
10442 +#include <bcmendian.h>
10443 +#include <bcmnvram.h>
10444 +#include <bcmutils.h>
10445 +#include <sbsdram.h>
10446 +
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);
10450 +
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);
10458 +
10459 +static struct nvram_tuple * BCMINITDATA(nvram_hash)[257];
10460 +static struct nvram_tuple * nvram_dead;
10461 +
10462 +/* Free all tuples. Should be locked. */
10463 +static void
10464 +BCMINITFN(nvram_free)(void)
10465 +{
10466 + uint i;
10467 + struct nvram_tuple *t, *next;
10468 +
10469 + /* Free hash table */
10470 + for (i = 0; i < ARRAYSIZE(BCMINIT(nvram_hash)); i++) {
10471 + for (t = BCMINIT(nvram_hash)[i]; t; t = next) {
10472 + next = t->next;
10473 + BCMINIT(_nvram_free)(t);
10474 + }
10475 + BCMINIT(nvram_hash)[i] = NULL;
10476 + }
10477 +
10478 + /* Free dead table */
10479 + for (t = nvram_dead; t; t = next) {
10480 + next = t->next;
10481 + BCMINIT(_nvram_free)(t);
10482 + }
10483 + nvram_dead = NULL;
10484 +
10485 + /* Indicate to per-port code that all tuples have been freed */
10486 + BCMINIT(_nvram_free)(NULL);
10487 +}
10488 +
10489 +/* String hash */
10490 +static INLINE uint
10491 +hash(const char *s)
10492 +{
10493 + uint hash = 0;
10494 +
10495 + while (*s)
10496 + hash = 31 * hash + *s++;
10497 +
10498 + return hash;
10499 +}
10500 +
10501 +/* (Re)initialize the hash table. Should be locked. */
10502 +static int
10503 +BCMINITFN(nvram_rehash)(struct nvram_header *header)
10504 +{
10505 + char buf[] = "0xXXXXXXXX", *name, *value, *end, *eq;
10506 +
10507 + /* (Re)initialize hash table */
10508 + BCMINIT(nvram_free)();
10509 +
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, '=')))
10516 + break;
10517 + *eq = '\0';
10518 + value = eq + 1;
10519 + BCMINIT(_nvram_set)(name, value);
10520 + *eq = '=';
10521 + }
10522 +
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);
10527 + }
10528 + if (!BCMINIT(_nvram_get)("sdram_config")) {
10529 + sprintf(buf, "0x%04X", (uint16)(header->config_refresh & 0xffff));
10530 + BCMINIT(_nvram_set)("sdram_config", buf);
10531 + }
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);
10535 + }
10536 + if (!BCMINIT(_nvram_get)("sdram_ncdl")) {
10537 + sprintf(buf, "0x%08X", header->config_ncdl);
10538 + BCMINIT(_nvram_set)("sdram_ncdl", buf);
10539 + }
10540 +
10541 + return 0;
10542 +}
10543 +
10544 +/* Get the value of an NVRAM variable. Should be locked. */
10545 +char *
10546 +BCMINITFN(_nvram_get)(const char *name)
10547 +{
10548 + uint i;
10549 + struct nvram_tuple *t;
10550 + char *value;
10551 +
10552 + if (!name)
10553 + return NULL;
10554 +
10555 + /* Hash the name */
10556 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
10557 +
10558 + /* Find the associated tuple in the hash table */
10559 + for (t = BCMINIT(nvram_hash)[i]; t && strcmp(t->name, name); t = t->next);
10560 +
10561 + value = t ? t->value : NULL;
10562 +
10563 + return value;
10564 +}
10565 +
10566 +/* Get the value of an NVRAM variable. Should be locked. */
10567 +int
10568 +BCMINITFN(_nvram_set)(const char *name, const char *value)
10569 +{
10570 + uint i;
10571 + struct nvram_tuple *t, *u, **prev;
10572 +
10573 + /* Hash the name */
10574 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
10575 +
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);
10578 +
10579 + /* (Re)allocate tuple */
10580 + if (!(u = BCMINIT(_nvram_realloc)(t, name, value)))
10581 + return -12; /* -ENOMEM */
10582 +
10583 + /* Value reallocated */
10584 + if (t && t == u)
10585 + return 0;
10586 +
10587 + /* Move old tuple to the dead table */
10588 + if (t) {
10589 + *prev = t->next;
10590 + t->next = nvram_dead;
10591 + nvram_dead = t;
10592 + }
10593 +
10594 + /* Add new tuple to the hash table */
10595 + u->next = BCMINIT(nvram_hash)[i];
10596 + BCMINIT(nvram_hash)[i] = u;
10597 +
10598 + return 0;
10599 +}
10600 +
10601 +/* Unset the value of an NVRAM variable. Should be locked. */
10602 +int
10603 +BCMINITFN(_nvram_unset)(const char *name)
10604 +{
10605 + uint i;
10606 + struct nvram_tuple *t, **prev;
10607 +
10608 + if (!name)
10609 + return 0;
10610 +
10611 + /* Hash the name */
10612 + i = hash(name) % ARRAYSIZE(BCMINIT(nvram_hash));
10613 +
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);
10616 +
10617 + /* Move it to the dead table */
10618 + if (t) {
10619 + *prev = t->next;
10620 + t->next = nvram_dead;
10621 + nvram_dead = t;
10622 + }
10623 +
10624 + return 0;
10625 +}
10626 +
10627 +/* Get all NVRAM variables. Should be locked. */
10628 +int
10629 +BCMINITFN(_nvram_getall)(char *buf, int count)
10630 +{
10631 + uint i;
10632 + struct nvram_tuple *t;
10633 + int len = 0;
10634 +
10635 + bzero(buf, count);
10636 +
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;
10642 + else
10643 + break;
10644 + }
10645 + }
10646 +
10647 + return 0;
10648 +}
10649 +
10650 +/* Regenerate NVRAM. Should be locked. */
10651 +int
10652 +BCMINITFN(_nvram_commit)(struct nvram_header *header)
10653 +{
10654 + char *init, *config, *refresh, *ncdl;
10655 + char *ptr, *end;
10656 + int i;
10657 + struct nvram_tuple *t;
10658 + struct nvram_header tmp;
10659 + uint8 crc;
10660 +
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;
10672 + } else {
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);
10677 + }
10678 +
10679 + /* Clear data area */
10680 + ptr = (char *) header + sizeof(struct nvram_header);
10681 + bzero(ptr, NVRAM_SPACE - sizeof(struct nvram_header));
10682 +
10683 + /* Leave space for a double NUL at the end */
10684 + end = (char *) header + NVRAM_SPACE - 2;
10685 +
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)
10690 + break;
10691 + ptr += sprintf(ptr, "%s=%s", t->name, t->value) + 1;
10692 + }
10693 + }
10694 +
10695 + /* End with a double NUL */
10696 + ptr += 2;
10697 +
10698 + /* Set new length */
10699 + header->len = ROUNDUP(ptr - (char *) header, 4);
10700 +
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);
10706 +
10707 + /* Continue CRC8 over data bytes */
10708 + crc = hndcrc8((char *) &header[1], header->len - sizeof(struct nvram_header), crc);
10709 +
10710 + /* Set new CRC8 */
10711 + header->crc_ver_init |= crc;
10712 +
10713 + /* Reinitialize hash table */
10714 + return BCMINIT(nvram_rehash)(header);
10715 +}
10716 +
10717 +/* Initialize hash table. Should be locked. */
10718 +int
10719 +BCMINITFN(_nvram_init)(void)
10720 +{
10721 + struct nvram_header *header;
10722 + int ret;
10723 + void *osh;
10724 +
10725 + /* get kernel osl handler */
10726 + osh = osl_attach(NULL);
10727 +
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 */
10731 + }
10732 +
10733 + if ((ret = BCMINIT(_nvram_read)(header)) == 0 &&
10734 + header->magic == NVRAM_MAGIC)
10735 + BCMINIT(nvram_rehash)(header);
10736 +
10737 + MFREE(osh, header, NVRAM_SPACE);
10738 + return ret;
10739 +}
10740 +
10741 +/* Free hash table. Should be locked. */
10742 +void
10743 +BCMINITFN(_nvram_exit)(void)
10744 +{
10745 + BCMINIT(nvram_free)();
10746 +}
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
10750 @@ -0,0 +1,653 @@
10751 +/*
10752 + * NVRAM variable manipulation (Linux kernel half)
10753 + *
10754 + * Copyright 2005, Broadcom Corporation
10755 + * All Rights Reserved.
10756 + *
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.
10761 + *
10762 + */
10763 +
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>
10780 +
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>
10790 +
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)));
10793 +
10794 +#ifdef MODULE
10795 +
10796 +#define early_nvram_get(name) nvram_get(name)
10797 +
10798 +#else /* !MODULE */
10799 +
10800 +/* Global SB handle */
10801 +extern void *bcm947xx_sbh;
10802 +extern spinlock_t bcm947xx_sbh_lock;
10803 +
10804 +static int cfe_env;
10805 +extern char *cfe_env_get(char *nv_buf, const char *name);
10806 +
10807 +/* Convenience */
10808 +#define sbh bcm947xx_sbh
10809 +#define sbh_lock bcm947xx_sbh_lock
10810 +#define KB * 1024
10811 +#define MB * 1024 * 1024
10812 +
10813 +/* Probe for NVRAM header */
10814 +static void __init
10815 +early_nvram_init(void)
10816 +{
10817 + struct nvram_header *header;
10818 + chipcregs_t *cc;
10819 + struct sflash *info = NULL;
10820 + int i;
10821 + uint32 base, off, lim;
10822 + u32 *src, *dst;
10823 +
10824 + if ((cc = sb_setcore(sbh, SB_CC, 0)) != NULL) {
10825 + base = KSEG1ADDR(SB_FLASH2);
10826 + switch (readl(&cc->capabilities) & CAP_FLASH_MASK) {
10827 + case PFLASH:
10828 + lim = SB_FLASH2_SZ;
10829 + break;
10830 +
10831 + case SFLASH_ST:
10832 + case SFLASH_AT:
10833 + if ((info = sflash_init(cc)) == NULL)
10834 + return;
10835 + lim = info->size;
10836 + break;
10837 +
10838 + case FLASH_NONE:
10839 + default:
10840 + return;
10841 + }
10842 + } else {
10843 + /* extif assumed, Stop at 4 MB */
10844 + base = KSEG1ADDR(SB_FLASH1);
10845 + lim = SB_FLASH1_SZ;
10846 + }
10847 +
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");
10853 +
10854 + for (i = 0; i < 0x1ff0; i++) {
10855 + if (*src == 0xFFFFFFFF)
10856 + break;
10857 + *dst++ = *src++;
10858 + }
10859 + cfe_env = 1;
10860 + return;
10861 + }
10862 +
10863 + off = FLASH_MIN;
10864 + while (off <= lim) {
10865 + /* Windowed flash access */
10866 + header = (struct nvram_header *) KSEG1ADDR(base + off - NVRAM_SPACE);
10867 + if (header->magic == NVRAM_MAGIC)
10868 + goto found;
10869 + off <<= 1;
10870 + }
10871 +
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)
10875 + goto found;
10876 +
10877 + header = (struct nvram_header *) KSEG1ADDR(base + 1 KB);
10878 + if (header->magic == NVRAM_MAGIC)
10879 + goto found;
10880 +
10881 + printk("early_nvram_init: NVRAM not found\n");
10882 + return;
10883 +
10884 +found:
10885 + src = (u32 *) header;
10886 + dst = (u32 *) nvram_buf;
10887 + for (i = 0; i < sizeof(struct nvram_header); i += 4)
10888 + *dst++ = *src++;
10889 + for (; i < header->len && i < NVRAM_SPACE; i += 4)
10890 + *dst++ = ltoh32(*src++);
10891 +}
10892 +
10893 +/* Early (before mm or mtd) read-only access to NVRAM */
10894 +static char * __init
10895 +early_nvram_get(const char *name)
10896 +{
10897 + char *var, *value, *end, *eq;
10898 +
10899 + if (!name)
10900 + return NULL;
10901 +
10902 + /* Too early? */
10903 + if (sbh == NULL)
10904 + return NULL;
10905 +
10906 + if (!nvram_buf[0])
10907 + early_nvram_init();
10908 +
10909 + if (cfe_env)
10910 + return cfe_env_get(nvram_buf, name);
10911 +
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, '=')))
10918 + break;
10919 + value = eq + 1;
10920 + if ((eq - var) == strlen(name) && strncmp(var, name, (eq - var)) == 0)
10921 + return value;
10922 + }
10923 +
10924 + return NULL;
10925 +}
10926 +
10927 +#endif /* !MODULE */
10928 +
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);
10936 +
10937 +/* Globals */
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;
10944 +
10945 +int
10946 +_nvram_read(char *buf)
10947 +{
10948 + struct nvram_header *header = (struct nvram_header *) buf;
10949 + size_t len;
10950 +
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);
10957 + }
10958 +
10959 + return 0;
10960 +}
10961 +
10962 +struct nvram_tuple *
10963 +_nvram_realloc(struct nvram_tuple *t, const char *name, const char *value)
10964 +{
10965 + if ((nvram_offset + strlen(value) + 1) > NVRAM_SPACE)
10966 + return NULL;
10967 +
10968 + if (!t) {
10969 + if (!(t = kmalloc(sizeof(struct nvram_tuple) + strlen(name) + 1, GFP_ATOMIC)))
10970 + return NULL;
10971 +
10972 + /* Copy name */
10973 + t->name = (char *) &t[1];
10974 + strcpy(t->name, name);
10975 +
10976 + t->value = NULL;
10977 + }
10978 +
10979 + /* Copy value */
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;
10984 + }
10985 +
10986 + return t;
10987 +}
10988 +
10989 +void
10990 +_nvram_free(struct nvram_tuple *t)
10991 +{
10992 + if (!t)
10993 + nvram_offset = 0;
10994 + else
10995 + kfree(t);
10996 +}
10997 +
10998 +int
10999 +nvram_set(const char *name, const char *value)
11000 +{
11001 + unsigned long flags;
11002 + int ret;
11003 + struct nvram_header *header;
11004 +
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);
11011 + kfree(header);
11012 + }
11013 + }
11014 + spin_unlock_irqrestore(&nvram_lock, flags);
11015 +
11016 + return ret;
11017 +}
11018 +
11019 +char *
11020 +real_nvram_get(const char *name)
11021 +{
11022 + unsigned long flags;
11023 + char *value;
11024 +
11025 + spin_lock_irqsave(&nvram_lock, flags);
11026 + value = _nvram_get(name);
11027 + spin_unlock_irqrestore(&nvram_lock, flags);
11028 +
11029 + return value;
11030 +}
11031 +
11032 +char *
11033 +nvram_get(const char *name)
11034 +{
11035 + if (nvram_major >= 0)
11036 + return real_nvram_get(name);
11037 + else
11038 + return early_nvram_get(name);
11039 +}
11040 +
11041 +int
11042 +nvram_unset(const char *name)
11043 +{
11044 + unsigned long flags;
11045 + int ret;
11046 +
11047 + spin_lock_irqsave(&nvram_lock, flags);
11048 + ret = _nvram_unset(name);
11049 + spin_unlock_irqrestore(&nvram_lock, flags);
11050 +
11051 + return ret;
11052 +}
11053 +
11054 +static void
11055 +erase_callback(struct erase_info *done)
11056 +{
11057 + wait_queue_head_t *wait_q = (wait_queue_head_t *) done->priv;
11058 + wake_up(wait_q);
11059 +}
11060 +
11061 +int
11062 +nvram_commit(void)
11063 +{
11064 + char *buf;
11065 + size_t erasesize, len;
11066 + unsigned int i;
11067 + int ret;
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;
11074 +
11075 + if (!nvram_mtd) {
11076 + printk("nvram_commit: NVRAM not found\n");
11077 + return -ENODEV;
11078 + }
11079 +
11080 + if (in_interrupt()) {
11081 + printk("nvram_commit: not committing in interrupt\n");
11082 + return -EINVAL;
11083 + }
11084 +
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");
11089 + return -ENOMEM;
11090 + }
11091 +
11092 + down(&nvram_sem);
11093 +
11094 + if ((i = erasesize - NVRAM_SPACE) > 0) {
11095 + offset = nvram_mtd->size - erasesize;
11096 + len = 0;
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);
11100 + ret = -EIO;
11101 + goto done;
11102 + }
11103 + header = (struct nvram_header *)(buf + i);
11104 + } else {
11105 + offset = nvram_mtd->size - NVRAM_SPACE;
11106 + header = (struct nvram_header *)buf;
11107 + }
11108 +
11109 + /* Regenerate NVRAM */
11110 + spin_lock_irqsave(&nvram_lock, flags);
11111 + ret = _nvram_commit(header);
11112 + spin_unlock_irqrestore(&nvram_lock, flags);
11113 + if (ret)
11114 + goto done;
11115 +
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;
11124 +
11125 + set_current_state(TASK_INTERRUPTIBLE);
11126 + add_wait_queue(&wait_q, &wait);
11127 +
11128 + /* Unlock sector blocks */
11129 + if (nvram_mtd->unlock)
11130 + nvram_mtd->unlock(nvram_mtd, offset, nvram_mtd->erasesize);
11131 +
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");
11136 + goto done;
11137 + }
11138 +
11139 + /* Wait for erase to finish */
11140 + schedule();
11141 + remove_wait_queue(&wait_q, &wait);
11142 + }
11143 +
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");
11150 + ret = -EIO;
11151 + goto done;
11152 + }
11153 +
11154 + offset = nvram_mtd->size - erasesize;
11155 + ret = MTD_READ(nvram_mtd, offset, 4, &len, buf);
11156 +
11157 + done:
11158 + up(&nvram_sem);
11159 + kfree(buf);
11160 + return ret;
11161 +}
11162 +
11163 +int
11164 +nvram_getall(char *buf, int count)
11165 +{
11166 + unsigned long flags;
11167 + int ret;
11168 +
11169 + spin_lock_irqsave(&nvram_lock, flags);
11170 + ret = _nvram_getall(buf, count);
11171 + spin_unlock_irqrestore(&nvram_lock, flags);
11172 +
11173 + return ret;
11174 +}
11175 +
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);
11181 +
11182 +/* User mode interface below */
11183 +
11184 +static ssize_t
11185 +dev_nvram_read(struct file *file, char *buf, size_t count, loff_t *ppos)
11186 +{
11187 + char tmp[100], *name = tmp, *value;
11188 + ssize_t ret;
11189 + unsigned long off;
11190 +
11191 + if (count > sizeof(tmp)) {
11192 + if (!(name = kmalloc(count, GFP_KERNEL)))
11193 + return -ENOMEM;
11194 + }
11195 +
11196 + if (copy_from_user(name, buf, count)) {
11197 + ret = -EFAULT;
11198 + goto done;
11199 + }
11200 +
11201 + if (*name == '\0') {
11202 + /* Get all variables */
11203 + ret = nvram_getall(name, count);
11204 + if (ret == 0) {
11205 + if (copy_to_user(buf, name, count)) {
11206 + ret = -EFAULT;
11207 + goto done;
11208 + }
11209 + ret = count;
11210 + }
11211 + } else {
11212 + if (!(value = nvram_get(name))) {
11213 + ret = 0;
11214 + goto done;
11215 + }
11216 +
11217 + /* Provide the offset into mmap() space */
11218 + off = (unsigned long) value - (unsigned long) nvram_buf;
11219 +
11220 + if (put_user(off, (unsigned long *) buf)) {
11221 + ret = -EFAULT;
11222 + goto done;
11223 + }
11224 +
11225 + ret = sizeof(unsigned long);
11226 + }
11227 +
11228 + flush_cache_all();
11229 +
11230 +done:
11231 + if (name != tmp)
11232 + kfree(name);
11233 +
11234 + return ret;
11235 +}
11236 +
11237 +static ssize_t
11238 +dev_nvram_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
11239 +{
11240 + char tmp[100], *name = tmp, *value;
11241 + ssize_t ret;
11242 +
11243 + if (count > sizeof(tmp)) {
11244 + if (!(name = kmalloc(count, GFP_KERNEL)))
11245 + return -ENOMEM;
11246 + }
11247 +
11248 + if (copy_from_user(name, buf, count)) {
11249 + ret = -EFAULT;
11250 + goto done;
11251 + }
11252 +
11253 + value = name;
11254 + name = strsep(&value, "=");
11255 + if (value)
11256 + ret = nvram_set(name, value) ? : count;
11257 + else
11258 + ret = nvram_unset(name) ? : count;
11259 +
11260 + done:
11261 + if (name != tmp)
11262 + kfree(name);
11263 +
11264 + return ret;
11265 +}
11266 +
11267 +static int
11268 +dev_nvram_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
11269 +{
11270 + if (cmd != NVRAM_MAGIC)
11271 + return -EINVAL;
11272 + return nvram_commit();
11273 +}
11274 +
11275 +static int
11276 +dev_nvram_mmap(struct file *file, struct vm_area_struct *vma)
11277 +{
11278 + unsigned long offset = virt_to_phys(nvram_buf);
11279 +
11280 + if (remap_page_range(vma->vm_start, offset, vma->vm_end-vma->vm_start,
11281 + vma->vm_page_prot))
11282 + return -EAGAIN;
11283 +
11284 + return 0;
11285 +}
11286 +
11287 +static int
11288 +dev_nvram_open(struct inode *inode, struct file * file)
11289 +{
11290 + MOD_INC_USE_COUNT;
11291 + return 0;
11292 +}
11293 +
11294 +static int
11295 +dev_nvram_release(struct inode *inode, struct file * file)
11296 +{
11297 + MOD_DEC_USE_COUNT;
11298 + return 0;
11299 +}
11300 +
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,
11309 +};
11310 +
11311 +static void
11312 +dev_nvram_exit(void)
11313 +{
11314 + int order = 0;
11315 + struct page *page, *end;
11316 +
11317 + if (nvram_handle)
11318 + devfs_unregister(nvram_handle);
11319 +
11320 + if (nvram_major >= 0)
11321 + devfs_unregister_chrdev(nvram_major, "nvram");
11322 +
11323 + if (nvram_mtd)
11324 + put_mtd_device(nvram_mtd);
11325 +
11326 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
11327 + order++;
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);
11331 +
11332 + _nvram_exit();
11333 +}
11334 +
11335 +static int __init
11336 +dev_nvram_init(void)
11337 +{
11338 + int order = 0, ret = 0;
11339 + struct page *page, *end;
11340 + unsigned int i;
11341 +
11342 + /* Allocate and reserve memory to mmap() */
11343 + while ((PAGE_SIZE << order) < NVRAM_SPACE)
11344 + order++;
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);
11348 +
11349 +#ifdef CONFIG_MTD
11350 + /* Find associated MTD device */
11351 + for (i = 0; i < MAX_MTD_DEVICES; i++) {
11352 + nvram_mtd = get_mtd_device(NULL, i);
11353 + if (nvram_mtd) {
11354 + if (!strcmp(nvram_mtd->name, "nvram") &&
11355 + nvram_mtd->size >= NVRAM_SPACE)
11356 + break;
11357 + put_mtd_device(nvram_mtd);
11358 + }
11359 + }
11360 + if (i >= MAX_MTD_DEVICES)
11361 + nvram_mtd = NULL;
11362 +#endif
11363 +
11364 + /* Initialize hash table lock */
11365 + spin_lock_init(&nvram_lock);
11366 +
11367 + /* Initialize commit semaphore */
11368 + init_MUTEX(&nvram_sem);
11369 +
11370 + /* Register char device */
11371 + if ((nvram_major = devfs_register_chrdev(0, "nvram", &dev_nvram_fops)) < 0) {
11372 + ret = nvram_major;
11373 + goto err;
11374 + }
11375 +
11376 + /* Initialize hash table */
11377 + _nvram_init();
11378 +
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);
11382 +
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";
11387 +
11388 + if ((ncdl = sb_memc_get_ncdl(sbh))) {
11389 + sprintf(buf, "0x%08x", ncdl);
11390 + nvram_set("sdram_ncdl", buf);
11391 + nvram_commit();
11392 + }
11393 + }
11394 +
11395 + return 0;
11396 +
11397 + err:
11398 + dev_nvram_exit();
11399 + return ret;
11400 +}
11401 +
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
11407 @@ -0,0 +1,355 @@
11408 +/*
11409 + * Low-Level PCI and SB support for BCM47xx (Linux support code)
11410 + *
11411 + * Copyright 2005, Broadcom Corporation
11412 + * All Rights Reserved.
11413 + *
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.
11418 + *
11419 + * $Id$
11420 + */
11421 +
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>
11432 +
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>
11441 +
11442 +/* Global SB handle */
11443 +extern sb_t *bcm947xx_sbh;
11444 +extern spinlock_t bcm947xx_sbh_lock;
11445 +
11446 +/* Convenience */
11447 +#define sbh bcm947xx_sbh
11448 +#define sbh_lock bcm947xx_sbh_lock
11449 +
11450 +static int
11451 +sbpci_read_config_byte(struct pci_dev *dev, int where, u8 *value)
11452 +{
11453 + unsigned long flags;
11454 + int ret;
11455 +
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;
11460 +}
11461 +
11462 +static int
11463 +sbpci_read_config_word(struct pci_dev *dev, int where, u16 *value)
11464 +{
11465 + unsigned long flags;
11466 + int ret;
11467 +
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;
11472 +}
11473 +
11474 +static int
11475 +sbpci_read_config_dword(struct pci_dev *dev, int where, u32 *value)
11476 +{
11477 + unsigned long flags;
11478 + int ret;
11479 +
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;
11484 +}
11485 +
11486 +static int
11487 +sbpci_write_config_byte(struct pci_dev *dev, int where, u8 value)
11488 +{
11489 + unsigned long flags;
11490 + int ret;
11491 +
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;
11496 +}
11497 +
11498 +static int
11499 +sbpci_write_config_word(struct pci_dev *dev, int where, u16 value)
11500 +{
11501 + unsigned long flags;
11502 + int ret;
11503 +
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;
11508 +}
11509 +
11510 +static int
11511 +sbpci_write_config_dword(struct pci_dev *dev, int where, u32 value)
11512 +{
11513 + unsigned long flags;
11514 + int ret;
11515 +
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;
11520 +}
11521 +
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
11529 +};
11530 +
11531 +
11532 +void __init
11533 +pcibios_init(void)
11534 +{
11535 + ulong flags;
11536 +
11537 + if (!(sbh = sb_kattach()))
11538 + panic("sb_kattach failed");
11539 + spin_lock_init(&sbh_lock);
11540 +
11541 + spin_lock_irqsave(&sbh_lock, flags);
11542 + sbpci_init(sbh);
11543 + spin_unlock_irqrestore(&sbh_lock, flags);
11544 +
11545 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
11546 +
11547 + mdelay(300); //By Joey for Atheros Card
11548 +
11549 + /* Scan the SB bus */
11550 + pci_scan_bus(0, &pcibios_ops, NULL);
11551 +
11552 +}
11553 +
11554 +char * __init
11555 +pcibios_setup(char *str)
11556 +{
11557 + if (!strncmp(str, "ban=", 4)) {
11558 + sbpci_ban(simple_strtoul(str + 4, NULL, 0));
11559 + return NULL;
11560 + }
11561 +
11562 + return (str);
11563 +}
11564 +
11565 +static u32 pci_iobase = 0x100;
11566 +static u32 pci_membase = SB_PCI_DMA;
11567 +
11568 +void __init
11569 +pcibios_fixup_bus(struct pci_bus *b)
11570 +{
11571 + struct list_head *ln;
11572 + struct pci_dev *d;
11573 + struct resource *res;
11574 + int pos, size;
11575 + u32 *base;
11576 + u8 irq;
11577 +
11578 + printk("PCI: Fixing up bus %d\n", b->number);
11579 +
11580 + /* Fix up SB */
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);
11588 + }
11589 + }
11590 +
11591 + /* Fix up external PCI */
11592 + else {
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;
11599 + if (res->end) {
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;
11605 + *base += size;
11606 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
11607 + }
11608 + /* Fix up PCI bridge BAR0 only */
11609 + if (b->number == 1 && PCI_SLOT(d->devfn) == 0)
11610 + break;
11611 + }
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);
11616 + }
11617 + }
11618 +}
11619 +
11620 +unsigned int
11621 +pcibios_assign_all_busses(void)
11622 +{
11623 + return 1;
11624 +}
11625 +
11626 +void
11627 +pcibios_align_resource(void *data, struct resource *res,
11628 + unsigned long size, unsigned long align)
11629 +{
11630 +}
11631 +
11632 +int
11633 +pcibios_enable_resources(struct pci_dev *dev)
11634 +{
11635 + u16 cmd, old_cmd;
11636 + int idx;
11637 + struct resource *r;
11638 +
11639 + /* External PCI only */
11640 + if (dev->bus->number == 0)
11641 + return 0;
11642 +
11643 + pci_read_config_word(dev, PCI_COMMAND, &cmd);
11644 + old_cmd = 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;
11651 + }
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);
11657 + }
11658 + return 0;
11659 +}
11660 +
11661 +int
11662 +pcibios_enable_device(struct pci_dev *dev, int mask)
11663 +{
11664 + ulong flags;
11665 + uint coreidx;
11666 +
11667 + /* External PCI device enable */
11668 + if (dev->bus->number != 0)
11669 + return pcibios_enable_resources(dev);
11670 +
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)
11676 + return 0;
11677 +
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;
11682 +
11683 + /*
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().
11691 + */
11692 + if (sb_coreid(sbh) == SB_USB) {
11693 + sb_core_disable(sbh, sb_coreflags(sbh, 0, 0));
11694 + sb_core_reset(sbh, 1 << 29);
11695 + } else
11696 + sb_core_reset(sbh, 0);
11697 +
11698 + sb_setcoreidx(sbh, coreidx);
11699 + spin_unlock_irqrestore(&sbh_lock, flags);
11700 +
11701 + return 0;
11702 +}
11703 +
11704 +void
11705 +pcibios_update_resource(struct pci_dev *dev, struct resource *root,
11706 + struct resource *res, int resource)
11707 +{
11708 + unsigned long where, size;
11709 + u32 reg;
11710 +
11711 + /* External PCI only */
11712 + if (dev->bus->number == 0)
11713 + return;
11714 +
11715 + where = PCI_BASE_ADDRESS_0 + (resource * 4);
11716 + size = res->end - res->start;
11717 + pci_read_config_dword(dev, where, &reg);
11718 + reg = (reg & size) | (((u32)(res->start - root->start)) & ~size);
11719 + pci_write_config_dword(dev, where, reg);
11720 +}
11721 +
11722 +static void __init
11723 +quirk_sbpci_bridge(struct pci_dev *dev)
11724 +{
11725 + if (dev->bus->number != 1 || PCI_SLOT(dev->devfn) != 0)
11726 + return;
11727 +
11728 + printk("PCI: Fixing up bridge\n");
11729 +
11730 + /* Enable PCI bridge bus mastering and memory space */
11731 + pci_set_master(dev);
11732 + pcibios_enable_resources(dev);
11733 +
11734 + /* Enable PCI bridge BAR1 prefetch and burst */
11735 + pci_write_config_dword(dev, PCI_BAR1_CONTROL, 3);
11736 +}
11737 +
11738 +struct pci_fixup pcibios_fixups[] = {
11739 + { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, quirk_sbpci_bridge },
11740 + { 0 }
11741 +};
11742 +
11743 +/*
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.
11746 + */
11747 +unsigned int pcibios_max_latency = 255;
11748 +
11749 +void pcibios_set_master(struct pci_dev *dev)
11750 +{
11751 + u8 lat;
11752 + pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
11753 + if (lat < 16)
11754 + lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
11755 + else if (lat > pcibios_max_latency)
11756 + lat = pcibios_max_latency;
11757 + else
11758 + return;
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);
11761 +}
11762 +
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
11766 @@ -0,0 +1,41 @@
11767 +/*
11768 + * Early initialization code for BCM94710 boards
11769 + *
11770 + * Copyright 2004, Broadcom Corporation
11771 + * All Rights Reserved.
11772 + *
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.
11777 + *
11778 + * $Id: prom.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
11779 + */
11780 +
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>
11786 +
11787 +void __init
11788 +prom_init(int argc, const char **argv)
11789 +{
11790 + unsigned long mem;
11791 +
11792 + mips_machgroup = MACH_GROUP_BRCM;
11793 + mips_machtype = MACH_BCM947XX;
11794 +
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))
11799 + break;
11800 + }
11801 + add_memory_region(0, mem, BOOT_MEM_RAM);
11802 +}
11803 +
11804 +void __init
11805 +prom_free_prom_memory(void)
11806 +{
11807 +}
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
11811 @@ -0,0 +1,1038 @@
11812 +/*
11813 + * BCM47XX Sonics SiliconBackplane MIPS core routines
11814 + *
11815 + * Copyright 2005, Broadcom Corporation
11816 + * All Rights Reserved.
11817 + *
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.
11822 + *
11823 + * $Id$
11824 + */
11825 +
11826 +#include <typedefs.h>
11827 +#include <osl.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>
11839 +
11840 +/*
11841 + * Returns TRUE if an external UART exists at the given base
11842 + * register.
11843 + */
11844 +static bool
11845 +BCMINITFN(serial_exists)(uint8 *regs)
11846 +{
11847 + uint8 save_mcr, status1;
11848 +
11849 + save_mcr = R_REG(&regs[UART_MCR]);
11850 + W_REG(&regs[UART_MCR], UART_MCR_LOOP | 0x0a);
11851 + status1 = R_REG(&regs[UART_MSR]) & 0xf0;
11852 + W_REG(&regs[UART_MCR], save_mcr);
11853 +
11854 + return (status1 == 0x90);
11855 +}
11856 +
11857 +/*
11858 + * Initializes UART access. The callback function will be called once
11859 + * per found UART.
11860 + */
11861 +void
11862 +BCMINITFN(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift))
11863 +{
11864 + void *regs;
11865 + ulong base;
11866 + uint irq;
11867 + int i, n;
11868 +
11869 + if ((regs = sb_setcore(sbh, SB_EXTIF, 0))) {
11870 + extifregs_t *eir = (extifregs_t *) regs;
11871 + sbconfig_t *sb;
11872 +
11873 + /* Determine external UART register base */
11874 + sb = (sbconfig_t *)((ulong) eir + SBCONFIGOFF);
11875 + base = EXTIF_CFGIF_BASE(sb_base(R_REG(&sb->sbadmatch1)));
11876 +
11877 + /* Determine IRQ */
11878 + irq = sb_irq(sbh);
11879 +
11880 + /* Disable GPIO interrupt initially */
11881 + W_REG(&eir->gpiointpolarity, 0);
11882 + W_REG(&eir->gpiointmask, 0);
11883 +
11884 + /* Search for external UARTs */
11885 + n = 2;
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);
11891 + if (add)
11892 + add(regs, irq, 13500000, 0);
11893 + }
11894 + }
11895 +
11896 + /* Add internal UART if enabled */
11897 + if (R_REG(&eir->corecontrol) & CC_UE)
11898 + if (add)
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;
11903 +
11904 + /* Determine core revision and capabilities */
11905 + rev = sb_corerev(sbh);
11906 + cap = R_REG(&cc->capabilities);
11907 + pll = cap & CAP_PLL_MASK;
11908 +
11909 + /* Determine IRQ */
11910 + irq = sb_irq(sbh);
11911 +
11912 + if (pll == PLL_TYPE1) {
11913 + /* PLL clock */
11914 + baud_base = sb_clock_rate(pll,
11915 + R_REG(&cc->clockcontrol_n),
11916 + R_REG(&cc->clockcontrol_m2));
11917 + div = 1;
11918 + } else {
11919 + if (rev >= 11) {
11920 + /* Fixed ALP clock */
11921 + baud_base = 20000000;
11922 + div = 1;
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));
11931 + } else {
11932 + /* Fixed internal backplane clock */
11933 + baud_base = 88000000;
11934 + div = 48;
11935 + }
11936 +
11937 + /* Clock source depends on strapping if UartClkOverride is unset */
11938 + if ((rev > 0) &&
11939 + ((R_REG(&cc->corecontrol) & CC_UARTCLKO) == 0)) {
11940 + if ((cap & CAP_UCLKSEL) == CAP_UINTCLK) {
11941 + /* Internal divided backplane clock */
11942 + baud_base /= div;
11943 + } else {
11944 + /* Assume external clock of 1.8432 MHz */
11945 + baud_base = 1843200;
11946 + }
11947 + }
11948 + }
11949 +
11950 + /* Add internal UARTs */
11951 + n = cap & CAP_UARTS_MASK;
11952 + for (i = 0; i < n; i++) {
11953 + /* Register offset changed after revision 0 */
11954 + if (rev)
11955 + regs = (void *)((ulong) &cc->uart0data + (i * 256));
11956 + else
11957 + regs = (void *)((ulong) &cc->uart0data + (i * 8));
11958 +
11959 + if (add)
11960 + add(regs, irq, baud_base, 0);
11961 + }
11962 + }
11963 +}
11964 +
11965 +/*
11966 + * Initialize jtag master and return handle for
11967 + * jtag_rwreg. Returns NULL on failure.
11968 + */
11969 +void *
11970 +sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap)
11971 +{
11972 + void *regs;
11973 +
11974 + if ((regs = sb_setcore(sbh, SB_CC, 0)) != NULL) {
11975 + chipcregs_t *cc = (chipcregs_t *) regs;
11976 + uint32 tmp;
11977 +
11978 + /*
11979 + * Determine jtagm availability from
11980 + * core revision and capabilities.
11981 + */
11982 + tmp = sb_corerev(sbh);
11983 + /*
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.
11988 + */
11989 + if (tmp < 11)
11990 + return (NULL);
11991 +
11992 + tmp = R_REG(&cc->capabilities);
11993 + if ((tmp & CAP_JTAGP) == 0)
11994 + return (NULL);
11995 +
11996 + /* Set clock divider if requested */
11997 + if (clkd != 0) {
11998 + tmp = R_REG(&cc->clkdiv);
11999 + tmp = (tmp & ~CLKD_JTAG) |
12000 + ((clkd << CLKD_JTAG_SHIFT) & CLKD_JTAG);
12001 + W_REG(&cc->clkdiv, tmp);
12002 + }
12003 +
12004 + /* Enable jtagm */
12005 + tmp = JCTRL_EN | (exttap ? JCTRL_EXT_EN : 0);
12006 + W_REG(&cc->jtagctrl, tmp);
12007 + }
12008 +
12009 + return (regs);
12010 +}
12011 +
12012 +void
12013 +sb_jtagm_disable(void *h)
12014 +{
12015 + chipcregs_t *cc = (chipcregs_t *)h;
12016 +
12017 + W_REG(&cc->jtagctrl, R_REG(&cc->jtagctrl) & ~JCTRL_EN);
12018 +}
12019 +
12020 +/*
12021 + * Read/write a jtag register. Assumes a target with
12022 + * 8 bit IR and 32 bit DR.
12023 + */
12024 +#define IRWIDTH 8
12025 +#define DRWIDTH 32
12026 +uint32
12027 +jtag_rwreg(void *h, uint32 ir, uint32 dr)
12028 +{
12029 + chipcregs_t *cc = (chipcregs_t *) h;
12030 + uint32 tmp;
12031 +
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) |
12036 + (DRWIDTH - 1);
12037 + W_REG(&cc->jtagcmd, tmp);
12038 + while (((tmp = R_REG(&cc->jtagcmd)) & JCMD_BUSY) == JCMD_BUSY) {
12039 + /* OSL_DELAY(1); */
12040 + }
12041 +
12042 + tmp = R_REG(&cc->jtagdr);
12043 + return (tmp);
12044 +}
12045 +
12046 +/* Returns the SB interrupt flag of the current core. */
12047 +uint32
12048 +sb_flag(sb_t *sbh)
12049 +{
12050 + void *regs;
12051 + sbconfig_t *sb;
12052 +
12053 + regs = sb_coreregs(sbh);
12054 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12055 +
12056 + return (R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK);
12057 +}
12058 +
12059 +static const uint32 sbips_int_mask[] = {
12060 + 0,
12061 + SBIPS_INT1_MASK,
12062 + SBIPS_INT2_MASK,
12063 + SBIPS_INT3_MASK,
12064 + SBIPS_INT4_MASK
12065 +};
12066 +
12067 +static const uint32 sbips_int_shift[] = {
12068 + 0,
12069 + 0,
12070 + SBIPS_INT2_SHIFT,
12071 + SBIPS_INT3_SHIFT,
12072 + SBIPS_INT4_SHIFT
12073 +};
12074 +
12075 +/*
12076 + * Returns the MIPS IRQ assignment of the current core. If unassigned,
12077 + * 0 is returned.
12078 + */
12079 +uint
12080 +sb_irq(sb_t *sbh)
12081 +{
12082 + uint idx;
12083 + void *regs;
12084 + sbconfig_t *sb;
12085 + uint32 flag, sbipsflag;
12086 + uint irq = 0;
12087 +
12088 + flag = sb_flag(sbh);
12089 +
12090 + idx = sb_coreidx(sbh);
12091 +
12092 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
12093 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
12094 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12095 +
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)
12100 + break;
12101 + }
12102 + if (irq == 5)
12103 + irq = 0;
12104 + }
12105 +
12106 + sb_setcoreidx(sbh, idx);
12107 +
12108 + return irq;
12109 +}
12110 +
12111 +/* Clears the specified MIPS IRQ. */
12112 +static void
12113 +BCMINITFN(sb_clearirq)(sb_t *sbh, uint irq)
12114 +{
12115 + void *regs;
12116 + sbconfig_t *sb;
12117 +
12118 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
12119 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
12120 + ASSERT(regs);
12121 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12122 +
12123 + if (irq == 0)
12124 + W_REG(&sb->sbintvec, 0);
12125 + else
12126 + OR_REG(&sb->sbipsflag, sbips_int_mask[irq]);
12127 +}
12128 +
12129 +/*
12130 + * Assigns the specified MIPS IRQ to the specified core. Shared MIPS
12131 + * IRQ 0 may be assigned more than once.
12132 + */
12133 +static void
12134 +BCMINITFN(sb_setirq)(sb_t *sbh, uint irq, uint coreid, uint coreunit)
12135 +{
12136 + void *regs;
12137 + sbconfig_t *sb;
12138 + uint32 flag;
12139 +
12140 + regs = sb_setcore(sbh, coreid, coreunit);
12141 + ASSERT(regs);
12142 + flag = sb_flag(sbh);
12143 +
12144 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
12145 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
12146 + ASSERT(regs);
12147 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
12148 +
12149 + if (irq == 0)
12150 + OR_REG(&sb->sbintvec, 1 << flag);
12151 + else {
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);
12156 + }
12157 +}
12158 +
12159 +/*
12160 + * Initializes clocks and interrupts. SB and NVRAM access must be
12161 + * initialized prior to calling.
12162 + */
12163 +void
12164 +BCMINITFN(sb_mips_init)(sb_t *sbh)
12165 +{
12166 + ulong hz, ns, tmp;
12167 + extifregs_t *eir;
12168 + chipcregs_t *cc;
12169 + char *value;
12170 + uint irq;
12171 +
12172 + /* Figure out current SB clock speed */
12173 + if ((hz = sb_clock(sbh)) == 0)
12174 + hz = 100000000;
12175 + ns = 1000000000 / hz;
12176 +
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);
12181 +
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 */
12187 +
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 */
12199 +
12200 + // Added by Chen-I for 5365
12201 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
12202 + {
12203 + W_REG(&cc->flash_waitcount, tmp);
12204 + W_REG(&cc->pcmcia_memwait, tmp);
12205 + }
12206 + else
12207 + {
12208 + if (sb_corerev(sbh) < 9)
12209 + W_REG(&cc->flash_waitcount, tmp);
12210 +
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);
12214 + }
12215 + }
12216 + }
12217 +
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);
12229 + ASSERT(eir);
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);
12236 + } else {
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);
12242 + }
12243 + break;
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);
12253 + break;
12254 + }
12255 +}
12256 +
12257 +uint32
12258 +BCMINITFN(sb_mips_clock)(sb_t *sbh)
12259 +{
12260 + extifregs_t *eir;
12261 + chipcregs_t *cc;
12262 + uint32 n, m;
12263 + uint idx;
12264 + uint32 pll_type, rate = 0;
12265 +
12266 + /* get index of the current core */
12267 + idx = sb_coreidx(sbh);
12268 + pll_type = PLL_TYPE1;
12269 +
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;
12284 + goto out;
12285 + }
12286 + else if (pll_type == PLL_TYPE3) {
12287 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) { /* 5365 is also type3 */
12288 + rate = 200000000;
12289 + goto out;
12290 + } else
12291 + m = R_REG(&cc->clockcontrol_m2); /* 5350 uses m2 to control mips */
12292 + } else
12293 + m = R_REG(&cc->clockcontrol_sb);
12294 + } else
12295 + goto out;
12296 +
12297 + // Added by Chen-I for 5365
12298 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
12299 + rate = 100000000;
12300 + else
12301 + /* calculate rate */
12302 + rate = sb_clock_rate(pll_type, n, m);
12303 +
12304 + if (pll_type == PLL_TYPE6)
12305 + rate = SB2MIPS_T6(rate);
12306 +
12307 +out:
12308 + /* switch back to previous core */
12309 + sb_setcoreidx(sbh, idx);
12310 +
12311 + return rate;
12312 +}
12313 +
12314 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
12315 +
12316 +static void
12317 +BCMINITFN(handler)(void)
12318 +{
12319 + /* Step 11 */
12320 + __asm__ (
12321 + ".set\tmips32\n\t"
12322 + "ssnop\n\t"
12323 + "ssnop\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"
12331 + "eret\n\t"
12332 + "nop\n\t"
12333 + "nop\n\t"
12334 + ".set\tmips0"
12335 + );
12336 +}
12337 +
12338 +/* The following MUST come right after handler() */
12339 +static void
12340 +BCMINITFN(afterhandler)(void)
12341 +{
12342 +}
12343 +
12344 +/*
12345 + * Set the MIPS, backplane and PCI clocks as closely as possible.
12346 + */
12347 +bool
12348 +BCMINITFN(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock)
12349 +{
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;
12357 + uint idx, i;
12358 + typedef struct {
12359 + uint32 mipsclock;
12360 + uint16 n;
12361 + uint32 sb;
12362 + uint32 pci33;
12363 + uint32 pci25;
12364 + } n3m_table_t;
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 */
12386 + };
12387 + typedef struct {
12388 + uint32 mipsclock;
12389 + uint16 n;
12390 + uint32 m2; /* that is the clockcontrol_m2 */
12391 + } type3_table_t;
12392 + static type3_table_t type3_table[] = { /* for 5350, mips clock is always double sb clock */
12393 + { 150000000, 0x311, 0x4020005 },
12394 + { 200000000, 0x311, 0x4020003 },
12395 + };
12396 + typedef struct {
12397 + uint32 mipsclock;
12398 + uint32 sbclock;
12399 + uint16 n;
12400 + uint32 sb;
12401 + uint32 pci33;
12402 + uint32 m2;
12403 + uint32 m3;
12404 + uint32 ratio_cfg;
12405 + uint32 ratio_parm;
12406 + } n4m_table_t;
12407 +
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 }
12426 + };
12427 +
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 }
12449 + };
12450 +
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 }
12466 + };
12467 +
12468 + ulong start, end, dst;
12469 + bool ret = FALSE;
12470 +
12471 + /* get index of the current core */
12472 + idx = sb_coreidx(sbh);
12473 + clockcontrol_m2 = NULL;
12474 +
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;
12488 + } else {
12489 + clockcontrol_n = &cc->clockcontrol_n;
12490 + clockcontrol_sb = &cc->clockcontrol_sb;
12491 + clockcontrol_pci = &cc->clockcontrol_pci;
12492 + clockcontrol_m2 = &cc->clockcontrol_m2;
12493 + }
12494 + } else
12495 + goto done;
12496 +
12497 + if (pll_type == PLL_TYPE6) {
12498 + /* Silence compilers */
12499 + orig_n = orig_sb = orig_pci = 0;
12500 + } else {
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);
12505 + }
12506 +
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;
12512 + }
12513 +
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)
12519 + break;
12520 + }
12521 + if (i == 0) {
12522 + ret = FALSE;
12523 + goto done;
12524 + } else {
12525 + ret = TRUE;
12526 + i--;
12527 + }
12528 + ASSERT(BCMINIT(type1_table)[i].mipsclock <= mipsclock);
12529 +
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))
12534 + goto done;
12535 +
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);
12541 + else
12542 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci33);
12543 +
12544 + /* Reset */
12545 + sb_watchdog(sbh, 1);
12546 +
12547 + while (1);
12548 + } else if ((pll_type == PLL_TYPE3) &&
12549 + (BCMINIT(sb_chip)(sbh) != BCM5365_DEVICE_ID)) {
12550 + /* 5350 */
12551 + /* Search for the closest MIPS clock less than or equal to a preferred value */
12552 +
12553 + for (i = 0; i < ARRAYSIZE(type3_table); i++) {
12554 + if (type3_table[i].mipsclock > mipsclock)
12555 + break;
12556 + }
12557 + if (i == 0) {
12558 + ret = FALSE;
12559 + goto done;
12560 + } else {
12561 + ret = TRUE;
12562 + i--;
12563 + }
12564 + ASSERT(type3_table[i].mipsclock <= mipsclock);
12565 +
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)) {
12570 + goto done;
12571 + }
12572 +
12573 + /* Set the PLL controls */
12574 + W_REG(clockcontrol_n, type3_table[i].n);
12575 + W_REG(clockcontrol_m2, type3_table[i].m2);
12576 +
12577 + /* Reset */
12578 + sb_watchdog(sbh, 1);
12579 + while (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;
12585 + uint tabsz = 0;
12586 +
12587 + ASSERT(cc);
12588 +
12589 + orig_mips = R_REG(&cc->clockcontrol_mips);
12590 +
12591 + if (pll_type == PLL_TYPE6) {
12592 + uint32 new_mips = 0;
12593 +
12594 + ret = TRUE;
12595 + if (mipsclock <= SB2MIPS_T6(CC_T6_M1))
12596 + new_mips = CC_T6_MMASK;
12597 +
12598 + if (orig_mips == new_mips)
12599 + goto done;
12600 +
12601 + W_REG(&cc->clockcontrol_mips, new_mips);
12602 + goto end_fill;
12603 + }
12604 +
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));
12614 + } else
12615 + ASSERT("No table for plltype" == NULL);
12616 +
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;
12621 +
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;
12631 + break;
12632 + }
12633 + }
12634 +
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)))
12641 + break;
12642 + }
12643 + if (i == tabsz) {
12644 + ret = FALSE;
12645 + goto done;
12646 + } else {
12647 + te = &table[i];
12648 + ret = TRUE;
12649 + }
12650 +
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))
12657 + goto done;
12658 +
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);
12665 +
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);
12671 +
12672 + /* No ratio change */
12673 + if (orig_ratio_parm == te->ratio_parm)
12674 + goto end_fill;
12675 +
12676 + icache_probe(MFC0(C0_CONFIG, 1), &ic_size, &ic_lsize);
12677 +
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;
12684 + }
12685 +
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));
12692 +
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);
12696 +
12697 + /* Clear BEV bit */
12698 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~ST0_BEV);
12699 +
12700 + /* Enable interrupts */
12701 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) | (ALLINTS | ST0_IE));
12702 +
12703 + /* Enable MIPS timer interrupt */
12704 + if (!(mipsr = sb_setcore(sbh, SB_MIPS, 0)) &&
12705 + !(mipsr = sb_setcore(sbh, SB_MIPS33, 0)))
12706 + ASSERT(mipsr);
12707 + W_REG(&mipsr->intmask, 1);
12708 +
12709 + start_fill:
12710 + /* step 1, set clock ratios */
12711 + MTC0(C0_BROADCOM, 3, te->ratio_parm);
12712 + MTC0(C0_BROADCOM, 1, te->ratio_cfg);
12713 +
12714 + /* step 2: program timer intr */
12715 + W_REG(&mipsr->timer, 100);
12716 + (void) R_REG(&mipsr->timer);
12717 +
12718 + /* step 3, switch to async */
12719 + sync_mode = MFC0(C0_BROADCOM, 4);
12720 + MTC0(C0_BROADCOM, 4, 1 << 22);
12721 +
12722 + /* step 4, set cfg active */
12723 + MTC0(C0_BROADCOM, 2, 0x9);
12724 +
12725 +
12726 + /* steps 5 & 6 */
12727 + __asm__ __volatile__ (
12728 + ".set\tmips3\n\t"
12729 + "wait\n\t"
12730 + ".set\tmips0"
12731 + );
12732 +
12733 + /* step 7, clear cfg_active */
12734 + MTC0(C0_BROADCOM, 2, 0);
12735 +
12736 + /* Additional Step: set back to orig sync mode */
12737 + MTC0(C0_BROADCOM, 4, sync_mode);
12738 +
12739 + /* step 8, fake soft reset */
12740 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | 4);
12741 +
12742 + end_fill:
12743 + /* step 9 set watchdog timer */
12744 + sb_watchdog(sbh, 20);
12745 + (void) R_REG(&cc->chipid);
12746 +
12747 + /* step 11 */
12748 + __asm__ __volatile__ (
12749 + ".set\tmips3\n\t"
12750 + "sync\n\t"
12751 + "wait\n\t"
12752 + ".set\tmips0"
12753 + );
12754 + while (1);
12755 + }
12756 +
12757 +done:
12758 + /* switch back to previous core */
12759 + sb_setcoreidx(sbh, idx);
12760 +
12761 + return ret;
12762 +}
12763 +
12764 +/*
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.
12768 + */
12769 +
12770 +static void
12771 +BCMINITFN(_enable_pfc)(uint32 mode)
12772 +{
12773 + /* write range */
12774 + *(volatile uint32 *)PFC_CR1 = 0xffff0000;
12775 +
12776 + /* enable */
12777 + *(volatile uint32 *)PFC_CR0 = mode;
12778 +}
12779 +
12780 +void
12781 +BCMINITFN(enable_pfc)(uint32 mode)
12782 +{
12783 + ulong start, end;
12784 + int i;
12785 +
12786 + /* If auto then choose the correct mode for this
12787 + platform, currently we only ever select one mode */
12788 + if (mode == PFC_AUTO)
12789 + mode = PFC_INST;
12790 +
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);
12795 +
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);
12799 +
12800 + BCMINIT(_enable_pfc)(mode);
12801 + }
12802 +}
12803 +
12804 +/* returns the ncdl value to be programmed into sdram_ncdl for calibration */
12805 +uint32
12806 +BCMINITFN(sb_memc_get_ncdl)(sb_t *sbh)
12807 +{
12808 + sbmemcregs_t *memc;
12809 + uint32 ret = 0;
12810 + uint32 config, rd, wr, misc, dqsg, cd, sm, sd;
12811 + uint idx, rev;
12812 +
12813 + idx = sb_coreidx(sbh);
12814 +
12815 + memc = (sbmemcregs_t *)sb_setcore(sbh, SB_MEMC, 0);
12816 + if (memc == 0)
12817 + goto out;
12818 +
12819 + rev = sb_corerev(sbh);
12820 +
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);
12826 +
12827 + rd &= MEMC_RDNCDLCOR_RD_MASK;
12828 + wr &= MEMC_WRNCDLCOR_WR_MASK;
12829 + dqsg &= MEMC_DQSGATENCDL_G_MASK;
12830 +
12831 + if (config & MEMC_CONFIG_DDR) {
12832 + ret = (wr << 16) | (rd << 8) | dqsg;
12833 + } else {
12834 + if (rev > 0)
12835 + cd = rd;
12836 + else
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;
12841 + }
12842 +
12843 +out:
12844 + /* switch back to previous core */
12845 + sb_setcoreidx(sbh, idx);
12846 +
12847 + return ret;
12848 +}
12849 +
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
12853 @@ -0,0 +1,588 @@
12854 +/*
12855 + * Low-Level PCI and SB support for BCM47xx
12856 + *
12857 + * Copyright 2005, Broadcom Corporation
12858 + * All Rights Reserved.
12859 + *
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.
12864 + *
12865 + * $Id$
12866 + */
12867 +
12868 +#include <typedefs.h>
12869 +#include <pcicfg.h>
12870 +#include <bcmdevs.h>
12871 +#include <sbconfig.h>
12872 +#include <osl.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>
12879 +
12880 +/* Can free sbpci_init() memory after boot */
12881 +#ifndef linux
12882 +#define __init
12883 +#endif
12884 +
12885 +/* Emulated configuration space */
12886 +static pci_config_regs sb_config_regs[SB_MAXCORES];
12887 +
12888 +/* Banned cores */
12889 +static uint16 pci_ban[32] = { 0 };
12890 +static uint pci_banned = 0;
12891 +
12892 +/* CardBus mode */
12893 +static bool cardbus = FALSE;
12894 +
12895 +/* Disable PCI host core */
12896 +static bool pci_disabled = FALSE;
12897 +
12898 +/*
12899 + * Functions for accessing external PCI configuration space
12900 + */
12901 +
12902 +/* Assume one-hot slot wiring */
12903 +#define PCI_SLOT_MAX 16
12904 +
12905 +static uint32
12906 +config_cmd(sb_t *sbh, uint bus, uint dev, uint func, uint off)
12907 +{
12908 + uint coreidx;
12909 + sbpciregs_t *regs;
12910 + uint32 addr = 0;
12911 +
12912 + /* CardBusMode supports only one device */
12913 + if (cardbus && dev > 1)
12914 + return 0;
12915 +
12916 + coreidx = sb_coreidx(sbh);
12917 + regs = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
12918 +
12919 + /* Type 0 transaction */
12920 + if (bus == 1) {
12921 + /* Skip unwired slots */
12922 + if (dev < PCI_SLOT_MAX) {
12923 + /* Slide the PCI window to the appropriate slot */
12924 + W_REG(&regs->sbtopci1, SBTOPCI_CFG0 | ((1 << (dev + 16)) & SBTOPCI1_MASK));
12925 + addr = SB_PCI_CFG | ((1 << (dev + 16)) & ~SBTOPCI1_MASK) |
12926 + (func << 8) | (off & ~3);
12927 + }
12928 + }
12929 +
12930 + /* Type 1 transaction */
12931 + else {
12932 + W_REG(&regs->sbtopci1, SBTOPCI_CFG1);
12933 + addr = SB_PCI_CFG | (bus << 16) | (dev << 11) | (func << 8) | (off & ~3);
12934 + }
12935 +
12936 + sb_setcoreidx(sbh, coreidx);
12937 +
12938 + return addr;
12939 +}
12940 +
12941 +static int
12942 +extpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12943 +{
12944 + uint32 addr, *reg = NULL, val;
12945 + int ret = 0;
12946 +
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;
12952 +
12953 + val >>= 8 * (off & 3);
12954 + if (len == 4)
12955 + *((uint32 *) buf) = val;
12956 + else if (len == 2)
12957 + *((uint16 *) buf) = (uint16) val;
12958 + else if (len == 1)
12959 + *((uint8 *) buf) = (uint8) val;
12960 + else
12961 + ret = -1;
12962 +
12963 + if (reg)
12964 + REG_UNMAP(reg);
12965 +
12966 + return ret;
12967 +}
12968 +
12969 +static int
12970 +extpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
12971 +{
12972 + uint32 addr, *reg = NULL, val;
12973 + int ret = 0;
12974 +
12975 + if (pci_disabled ||
12976 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
12977 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
12978 + BUSPROBE(val, reg))
12979 + goto done;
12980 +
12981 + if (len == 4)
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));
12989 + } else
12990 + ret = -1;
12991 +
12992 + W_REG(reg, val);
12993 +
12994 + done:
12995 + if (reg)
12996 + REG_UNMAP(reg);
12997 +
12998 + return ret;
12999 +}
13000 +
13001 +/*
13002 + * Functions for accessing translated SB configuration space
13003 + */
13004 +
13005 +static int
13006 +sb_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
13007 +{
13008 + pci_config_regs *cfg;
13009 +
13010 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
13011 + return -1;
13012 + cfg = &sb_config_regs[dev];
13013 +
13014 + ASSERT(ISALIGNED(off, len));
13015 + ASSERT(ISALIGNED((uintptr)buf, len));
13016 +
13017 + if (len == 4)
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));
13023 + else
13024 + return -1;
13025 +
13026 + return 0;
13027 +}
13028 +
13029 +static int
13030 +sb_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
13031 +{
13032 + uint coreidx, n;
13033 + void *regs;
13034 + sbconfig_t *sb;
13035 + pci_config_regs *cfg;
13036 +
13037 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
13038 + return -1;
13039 + cfg = &sb_config_regs[dev];
13040 +
13041 + ASSERT(ISALIGNED(off, len));
13042 + ASSERT(ISALIGNED((uintptr)buf, len));
13043 +
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);
13060 + }
13061 + sb_setcoreidx(sbh, coreidx);
13062 + return 0;
13063 + }
13064 +
13065 + if (len == 4)
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);
13071 + else
13072 + return -1;
13073 +
13074 + return 0;
13075 +}
13076 +
13077 +int
13078 +sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
13079 +{
13080 + if (bus == 0)
13081 + return sb_read_config(sbh, bus, dev, func, off, buf, len);
13082 + else
13083 + return extpci_read_config(sbh, bus, dev, func, off, buf, len);
13084 +}
13085 +
13086 +int
13087 +sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
13088 +{
13089 + if (bus == 0)
13090 + return sb_write_config(sbh, bus, dev, func, off, buf, len);
13091 + else
13092 + return extpci_write_config(sbh, bus, dev, func, off, buf, len);
13093 +}
13094 +
13095 +void
13096 +sbpci_ban(uint16 core)
13097 +{
13098 + if (pci_banned < ARRAYSIZE(pci_ban))
13099 + pci_ban[pci_banned++] = core;
13100 +}
13101 +
13102 +static int
13103 +sbpci_init_pci(sb_t *sbh)
13104 +{
13105 + uint chip, chiprev, chippkg, host;
13106 + uint32 boardflags;
13107 + sbpciregs_t *pci;
13108 + sbconfig_t *sb;
13109 + uint32 val;
13110 +
13111 + chip = sb_chip(sbh);
13112 + chiprev = sb_chiprev(sbh);
13113 + chippkg = sb_chippkg(sbh);
13114 +
13115 + if (!(pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0))) {
13116 + printf("PCI: no core\n");
13117 + pci_disabled = TRUE;
13118 + return -1;
13119 + }
13120 + sb_core_reset(sbh, 0);
13121 +
13122 + boardflags = (uint32) getintvar(NULL, "boardflags");
13123 +
13124 + if ((chip == BCM4310_DEVICE_ID) && (chiprev == 0))
13125 + pci_disabled = TRUE;
13126 +
13127 + /*
13128 + * The 200-pin BCM4712 package does not bond out PCI. Even when
13129 + * PCI is bonded out, some boards may leave the pins
13130 + * floating.
13131 + */
13132 + if (((chip == BCM4712_DEVICE_ID) &&
13133 + ((chippkg == BCM4712SMALL_PKG_ID) ||
13134 + (chippkg == BCM4712MID_PKG_ID))) ||
13135 + (boardflags & BFL_NOPCI))
13136 + pci_disabled = TRUE;
13137 +
13138 + /*
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
13142 + * mode.
13143 + */
13144 + if (pci_disabled)
13145 + host = 0;
13146 + else
13147 + host = !BUSPROBE(val, &pci->control);
13148 +
13149 + if (!host) {
13150 + /* Disable PCI interrupts in client mode */
13151 + sb = (sbconfig_t *)((ulong) pci + SBCONFIGOFF);
13152 + W_REG(&sb->sbintvec, 0);
13153 +
13154 + /* Disable the PCI bridge in client mode */
13155 + sbpci_ban(SB_PCI);
13156 + printf("PCI: Disabled\n");
13157 + } else {
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 */
13165 +
13166 + /* Enable CardBusMode */
13167 + cardbus = nvram_match("cardbus", "1");
13168 + if (cardbus) {
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);
13174 + }
13175 +
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);
13182 +
13183 + /* Enable PCI bridge BAR0 prefetch and burst */
13184 + val = 6;
13185 + sbpci_write_config(sbh, 1, 0, 0, PCI_CFG_CMD, &val, sizeof(val));
13186 +
13187 + /* Enable PCI interrupts */
13188 + W_REG(&pci->intmask, PCI_INTA);
13189 + }
13190 +
13191 + return 0;
13192 +}
13193 +
13194 +static int
13195 +sbpci_init_cores(sb_t *sbh)
13196 +{
13197 + uint chip, chiprev, chippkg, coreidx, i;
13198 + sbconfig_t *sb;
13199 + pci_config_regs *cfg;
13200 + void *regs;
13201 + char varname[8];
13202 + uint wlidx = 0;
13203 + uint16 vendor, core;
13204 + uint8 class, subclass, progif;
13205 + uint32 val;
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 };
13208 +
13209 + chip = sb_chip(sbh);
13210 + chiprev = sb_chiprev(sbh);
13211 + chippkg = sb_chippkg(sbh);
13212 + coreidx = sb_coreidx(sbh);
13213 +
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)))
13219 + continue;
13220 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
13221 +
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;
13226 + progif = 0;
13227 +
13228 + /* Check if this core is banned */
13229 + for (i = 0; i < pci_banned; i++)
13230 + if (core == pci_ban[i])
13231 + break;
13232 + if (i < pci_banned)
13233 + continue;
13234 +
13235 + /* Known vendor translations */
13236 + switch (vendor) {
13237 + case SB_VEND_BCM:
13238 + vendor = VENDOR_BROADCOM;
13239 + break;
13240 + }
13241 +
13242 + /* Determine class based on known core codes */
13243 + switch (core) {
13244 + case SB_ILINE20:
13245 + class = PCI_CLASS_NET;
13246 + subclass = PCI_NET_ETHER;
13247 + core = BCM47XX_ILINE_ID;
13248 + break;
13249 + case SB_ILINE100:
13250 + class = PCI_CLASS_NET;
13251 + subclass = PCI_NET_ETHER;
13252 + core = BCM4610_ILINE_ID;
13253 + break;
13254 + case SB_ENET:
13255 + class = PCI_CLASS_NET;
13256 + subclass = PCI_NET_ETHER;
13257 + core = BCM47XX_ENET_ID;
13258 + break;
13259 + case SB_SDRAM:
13260 + case SB_MEMC:
13261 + class = PCI_CLASS_MEMORY;
13262 + subclass = PCI_MEMORY_RAM;
13263 + break;
13264 + case SB_PCI:
13265 + class = PCI_CLASS_BRIDGE;
13266 + subclass = PCI_BRIDGE_PCI;
13267 + break;
13268 + case SB_MIPS:
13269 + case SB_MIPS33:
13270 + class = PCI_CLASS_CPU;
13271 + subclass = PCI_CPU_MIPS;
13272 + break;
13273 + case SB_CODEC:
13274 + class = PCI_CLASS_COMM;
13275 + subclass = PCI_COMM_MODEM;
13276 + core = BCM47XX_V90_ID;
13277 + break;
13278 + case SB_USB:
13279 + class = PCI_CLASS_SERIAL;
13280 + subclass = PCI_SERIAL_USB;
13281 + progif = 0x10; /* OHCI */
13282 + core = BCM47XX_USB_ID;
13283 + break;
13284 + case SB_USB11H:
13285 + class = PCI_CLASS_SERIAL;
13286 + subclass = PCI_SERIAL_USB;
13287 + progif = 0x10; /* OHCI */
13288 + core = BCM47XX_USBH_ID;
13289 + break;
13290 + case SB_USB11D:
13291 + class = PCI_CLASS_SERIAL;
13292 + subclass = PCI_SERIAL_USB;
13293 + core = BCM47XX_USBD_ID;
13294 + break;
13295 + case SB_IPSEC:
13296 + class = PCI_CLASS_CRYPT;
13297 + subclass = PCI_CRYPT_NETWORK;
13298 + core = BCM47XX_IPSEC_ID;
13299 + break;
13300 + case SB_ROBO:
13301 + class = PCI_CLASS_NET;
13302 + subclass = PCI_NET_OTHER;
13303 + core = BCM47XX_ROBO_ID;
13304 + break;
13305 + case SB_EXTIF:
13306 + case SB_CC:
13307 + class = PCI_CLASS_MEMORY;
13308 + subclass = PCI_MEMORY_FLASH;
13309 + break;
13310 + case SB_D11:
13311 + class = PCI_CLASS_NET;
13312 + subclass = PCI_NET_OTHER;
13313 + /* Let an nvram variable override this */
13314 + sprintf(varname, "wl%did", wlidx);
13315 + 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;
13320 + else
13321 + core = BCM4306_D11DUAL_ID;
13322 + } else {
13323 + /* 4310 */
13324 + core = BCM4310_D11B_ID;
13325 + }
13326 + }
13327 + break;
13328 +
13329 + default:
13330 + class = subclass = progif = 0xff;
13331 + break;
13332 + }
13333 +
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;
13349 + else
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)
13362 + break;
13363 + }
13364 + if (cfg->int_line > 4)
13365 + cfg->int_line = 0;
13366 + }
13367 + /* Emulated core */
13368 + *((uint32 *) &cfg->sprom_control) = 0xffffffff;
13369 + }
13370 +
13371 + sb_setcoreidx(sbh, coreidx);
13372 + return 0;
13373 +}
13374 +
13375 +int __init
13376 +sbpci_init(sb_t *sbh)
13377 +{
13378 + sbpci_init_pci(sbh);
13379 + sbpci_init_cores(sbh);
13380 + return 0;
13381 +}
13382 +
13383 +void
13384 +sbpci_check(sb_t *sbh)
13385 +{
13386 + uint coreidx;
13387 + sbpciregs_t *pci;
13388 + uint32 sbtopci1;
13389 + uint32 buf[64], *ptr, i;
13390 + ulong pa;
13391 + volatile uint j;
13392 +
13393 + coreidx = sb_coreidx(sbh);
13394 + pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
13395 +
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));
13400 +
13401 + /* Point PCI window 1 to memory */
13402 + sbtopci1 = R_REG(&pci->sbtopci1);
13403 + W_REG(&pci->sbtopci1, SBTOPCI_MEM | (pa & SBTOPCI1_MASK));
13404 +
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);
13410 + }
13411 + REG_UNMAP(ptr);
13412 +
13413 + /* Restore PCI window 1 */
13414 + W_REG(&pci->sbtopci1, sbtopci1);
13415 +
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++) {
13420 + if (ptr[i] != i)
13421 + break;
13422 + }
13423 +
13424 + /* Change the clock if the test fails */
13425 + if (i < ARRAYSIZE(buf)) {
13426 + uint32 req, cur;
13427 +
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);
13434 + }
13435 + /* Should not reach here */
13436 + ASSERT(0);
13437 + }
13438 +
13439 + sb_setcoreidx(sbh, coreidx);
13440 +}
13441 +
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
13445 @@ -0,0 +1,232 @@
13446 +/*
13447 + * Generic setup routines for Broadcom MIPS boards
13448 + *
13449 + * Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
13450 + *
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.
13455 + *
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.
13466 + *
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.
13470 + *
13471 + *
13472 + * Copyright 2005, Broadcom Corporation
13473 + * All Rights Reserved.
13474 + *
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.
13479 + *
13480 + */
13481 +
13482 +#include <linux/config.h>
13483 +#include <linux/init.h>
13484 +#include <linux/kernel.h>
13485 +#include <linux/serialP.h>
13486 +#include <linux/ide.h>
13487 +#include <asm/bootinfo.h>
13488 +#include <asm/cpu.h>
13489 +#include <asm/time.h>
13490 +#include <asm/reboot.h>
13491 +
13492 +#include <typedefs.h>
13493 +#include <osl.h>
13494 +#include <sbutils.h>
13495 +#include <bcmutils.h>
13496 +#include <bcmnvram.h>
13497 +#include <sbmips.h>
13498 +#include <trxhdr.h>
13499 +
13500 +/* Global SB handle */
13501 +sb_t *bcm947xx_sbh = NULL;
13502 +spinlock_t bcm947xx_sbh_lock = SPIN_LOCK_UNLOCKED;
13503 +
13504 +/* Convenience */
13505 +#define sbh bcm947xx_sbh
13506 +#define sbh_lock bcm947xx_sbh_lock
13507 +
13508 +extern void bcm947xx_time_init(void);
13509 +extern void bcm947xx_timer_setup(struct irqaction *irq);
13510 +
13511 +#ifdef CONFIG_REMOTE_DEBUG
13512 +extern void set_debug_traps(void);
13513 +extern void rs_kgdb_hook(struct serial_state *);
13514 +extern void breakpoint(void);
13515 +#endif
13516 +
13517 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
13518 +extern struct ide_ops std_ide_ops;
13519 +#endif
13520 +
13521 +/* Kernel command line */
13522 +char arcs_cmdline[CL_SIZE] __initdata = CONFIG_CMDLINE;
13523 +
13524 +void
13525 +bcm947xx_machine_restart(char *command)
13526 +{
13527 + printk("Please stand by while rebooting the system...\n");
13528 +
13529 + /* Set the watchdog timer to reset immediately */
13530 + __cli();
13531 + sb_watchdog(sbh, 1);
13532 + while (1);
13533 +}
13534 +
13535 +void
13536 +bcm947xx_machine_halt(void)
13537 +{
13538 + printk("System halted\n");
13539 +
13540 + /* Disable interrupts and watchdog and spin forever */
13541 + __cli();
13542 + sb_watchdog(sbh, 0);
13543 + while (1);
13544 +}
13545 +
13546 +#ifdef CONFIG_SERIAL
13547 +
13548 +static int ser_line = 0;
13549 +
13550 +typedef struct {
13551 + void *regs;
13552 + uint irq;
13553 + uint baud_base;
13554 + uint reg_shift;
13555 +} serial_port;
13556 +
13557 +static serial_port ports[4];
13558 +static int num_ports = 0;
13559 +
13560 +static void
13561 +serial_add(void *regs, uint irq, uint baud_base, uint reg_shift)
13562 +{
13563 + ports[num_ports].regs = regs;
13564 + ports[num_ports].irq = irq;
13565 + ports[num_ports].baud_base = baud_base;
13566 + ports[num_ports].reg_shift = reg_shift;
13567 + num_ports++;
13568 +}
13569 +
13570 +static void
13571 +do_serial_add(serial_port *port)
13572 +{
13573 + void *regs;
13574 + uint irq;
13575 + uint baud_base;
13576 + uint reg_shift;
13577 + struct serial_struct s;
13578 +
13579 + regs = port->regs;
13580 + irq = port->irq;
13581 + baud_base = port->baud_base;
13582 + reg_shift = port->reg_shift;
13583 +
13584 + memset(&s, 0, sizeof(s));
13585 +
13586 + s.line = ser_line++;
13587 + s.iomem_base = regs;
13588 + s.irq = irq + 2;
13589 + s.baud_base = baud_base / 16;
13590 + s.flags = ASYNC_BOOT_AUTOCONF;
13591 + s.io_type = SERIAL_IO_MEM;
13592 + s.iomem_reg_shift = reg_shift;
13593 +
13594 + if (early_serial_setup(&s) != 0) {
13595 + printk(KERN_ERR "Serial setup failed!\n");
13596 + }
13597 +}
13598 +
13599 +#endif /* CONFIG_SERIAL */
13600 +
13601 +void __init
13602 +brcm_setup(void)
13603 +{
13604 + char *s;
13605 + int i;
13606 + char *value;
13607 +
13608 + /* Get global SB handle */
13609 + sbh = sb_kattach();
13610 +
13611 + /* Initialize clocks and interrupts */
13612 + sb_mips_init(sbh);
13613 +
13614 + if (BCM330X(current_cpu_data.processor_id) &&
13615 + (read_c0_diag() & BRCM_PFC_AVAIL)) {
13616 + /*
13617 + * Now that the sbh is inited set the proper PFC value
13618 + */
13619 + printk("Setting the PFC to its default value\n");
13620 + enable_pfc(PFC_AUTO);
13621 + }
13622 +
13623 +
13624 +#ifdef CONFIG_SERIAL
13625 + sb_serial_init(sbh, serial_add);
13626 +
13627 + /* reverse serial ports if nvram variable starts with console=ttyS1 */
13628 + /* Initialize UARTs */
13629 + s = nvram_get("kernel_args");
13630 + if (!s) s = "";
13631 + if (!strncmp(s, "console=ttyS1", 13)) {
13632 + for (i = num_ports; i; i--)
13633 + do_serial_add(&ports[i - 1]);
13634 + } else {
13635 + for (i = 0; i < num_ports; i++)
13636 + do_serial_add(&ports[i]);
13637 + }
13638 +#endif
13639 +
13640 +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
13641 + ide_ops = &std_ide_ops;
13642 +#endif
13643 +
13644 + /* Override default command line arguments */
13645 + value = nvram_get("kernel_cmdline");
13646 + if (value && strlen(value) && strncmp(value, "empty", 5))
13647 + strncpy(arcs_cmdline, value, sizeof(arcs_cmdline));
13648 +
13649 +
13650 + /* Generic setup */
13651 + _machine_restart = bcm947xx_machine_restart;
13652 + _machine_halt = bcm947xx_machine_halt;
13653 + _machine_power_off = bcm947xx_machine_halt;
13654 +
13655 + board_time_init = bcm947xx_time_init;
13656 + board_timer_setup = bcm947xx_timer_setup;
13657 +}
13658 +
13659 +const char *
13660 +get_system_type(void)
13661 +{
13662 + static char s[32];
13663 +
13664 + if (bcm947xx_sbh) {
13665 + sprintf(s, "Broadcom BCM%X chip rev %d", sb_chip(bcm947xx_sbh),
13666 + sb_chiprev(bcm947xx_sbh));
13667 + return s;
13668 + }
13669 + else
13670 + return "Broadcom BCM947XX";
13671 +}
13672 +
13673 +void __init
13674 +bus_error_init(void)
13675 +{
13676 +}
13677 +
13678 diff -Nur linux-2.4.32/arch/mips/bcm947xx/sflash.c linux-2.4.32-brcm/arch/mips/bcm947xx/sflash.c
13679 --- linux-2.4.32/arch/mips/bcm947xx/sflash.c 1970-01-01 01:00:00.000000000 +0100
13680 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/sflash.c 2005-12-16 23:39:10.948837000 +0100
13681 @@ -0,0 +1,418 @@
13682 +/*
13683 + * Broadcom SiliconBackplane chipcommon serial flash interface
13684 + *
13685 + * Copyright 2005, Broadcom Corporation
13686 + * All Rights Reserved.
13687 + *
13688 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
13689 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
13690 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
13691 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
13692 + *
13693 + * $Id$
13694 + */
13695 +
13696 +#include <osl.h>
13697 +#include <typedefs.h>
13698 +#include <sbconfig.h>
13699 +#include <sbchipc.h>
13700 +#include <mipsinc.h>
13701 +#include <bcmutils.h>
13702 +#include <bcmdevs.h>
13703 +#include <sflash.h>
13704 +
13705 +/* Private global state */
13706 +static struct sflash sflash;
13707 +
13708 +/* Issue a serial flash command */
13709 +static INLINE void
13710 +sflash_cmd(chipcregs_t *cc, uint opcode)
13711 +{
13712 + W_REG(&cc->flashcontrol, SFLASH_START | opcode);
13713 + while (R_REG(&cc->flashcontrol) & SFLASH_BUSY);
13714 +}
13715 +
13716 +/* Initialize serial flash access */
13717 +struct sflash *
13718 +sflash_init(chipcregs_t *cc)
13719 +{
13720 + uint32 id, id2;
13721 +
13722 + bzero(&sflash, sizeof(sflash));
13723 +
13724 + sflash.type = R_REG(&cc->capabilities) & CAP_FLASH_MASK;
13725 +
13726 + switch (sflash.type) {
13727 + case SFLASH_ST:
13728 + /* Probe for ST chips */
13729 + sflash_cmd(cc, SFLASH_ST_DP);
13730 + sflash_cmd(cc, SFLASH_ST_RES);
13731 + id = R_REG(&cc->flashdata);
13732 + switch (id) {
13733 + case 0x11:
13734 + /* ST M25P20 2 Mbit Serial Flash */
13735 + sflash.blocksize = 64 * 1024;
13736 + sflash.numblocks = 4;
13737 + break;
13738 + case 0x12:
13739 + /* ST M25P40 4 Mbit Serial Flash */
13740 + sflash.blocksize = 64 * 1024;
13741 + sflash.numblocks = 8;
13742 + break;
13743 + case 0x13:
13744 + /* ST M25P80 8 Mbit Serial Flash */
13745 + sflash.blocksize = 64 * 1024;
13746 + sflash.numblocks = 16;
13747 + break;
13748 + case 0x14:
13749 + /* ST M25P16 16 Mbit Serial Flash */
13750 + sflash.blocksize = 64 * 1024;
13751 + sflash.numblocks = 32;
13752 + break;
13753 + case 0x15:
13754 + /* ST M25P32 32 Mbit Serial Flash */
13755 + sflash.blocksize = 64 * 1024;
13756 + sflash.numblocks = 64;
13757 + break;
13758 + case 0xbf:
13759 + W_REG(&cc->flashaddress, 1);
13760 + sflash_cmd(cc, SFLASH_ST_RES);
13761 + id2 = R_REG(&cc->flashdata);
13762 + if (id2 == 0x44) {
13763 + /* SST M25VF80 4 Mbit Serial Flash */
13764 + sflash.blocksize = 64 * 1024;
13765 + sflash.numblocks = 8;
13766 + }
13767 + break;
13768 + }
13769 + break;
13770 +
13771 + case SFLASH_AT:
13772 + /* Probe for Atmel chips */
13773 + sflash_cmd(cc, SFLASH_AT_STATUS);
13774 + id = R_REG(&cc->flashdata) & 0x3c;
13775 + switch (id) {
13776 + case 0xc:
13777 + /* Atmel AT45DB011 1Mbit Serial Flash */
13778 + sflash.blocksize = 256;
13779 + sflash.numblocks = 512;
13780 + break;
13781 + case 0x14:
13782 + /* Atmel AT45DB021 2Mbit Serial Flash */
13783 + sflash.blocksize = 256;
13784 + sflash.numblocks = 1024;
13785 + break;
13786 + case 0x1c:
13787 + /* Atmel AT45DB041 4Mbit Serial Flash */
13788 + sflash.blocksize = 256;
13789 + sflash.numblocks = 2048;
13790 + break;
13791 + case 0x24:
13792 + /* Atmel AT45DB081 8Mbit Serial Flash */
13793 + sflash.blocksize = 256;
13794 + sflash.numblocks = 4096;
13795 + break;
13796 + case 0x2c:
13797 + /* Atmel AT45DB161 16Mbit Serial Flash */
13798 + sflash.blocksize = 512;
13799 + sflash.numblocks = 4096;
13800 + break;
13801 + case 0x34:
13802 + /* Atmel AT45DB321 32Mbit Serial Flash */
13803 + sflash.blocksize = 512;
13804 + sflash.numblocks = 8192;
13805 + break;
13806 + case 0x3c:
13807 + /* Atmel AT45DB642 64Mbit Serial Flash */
13808 + sflash.blocksize = 1024;
13809 + sflash.numblocks = 8192;
13810 + break;
13811 + }
13812 + break;
13813 + }
13814 +
13815 + sflash.size = sflash.blocksize * sflash.numblocks;
13816 + return sflash.size ? &sflash : NULL;
13817 +}
13818 +
13819 +/* Read len bytes starting at offset into buf. Returns number of bytes read. */
13820 +int
13821 +sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf)
13822 +{
13823 + int cnt;
13824 + uint32 *from, *to;
13825 +
13826 + if (!len)
13827 + return 0;
13828 +
13829 + if ((offset + len) > sflash.size)
13830 + return -22;
13831 +
13832 + if ((len >= 4) && (offset & 3))
13833 + cnt = 4 - (offset & 3);
13834 + else if ((len >= 4) && ((uint32)buf & 3))
13835 + cnt = 4 - ((uint32)buf & 3);
13836 + else
13837 + cnt = len;
13838 +
13839 + from = (uint32 *)KSEG1ADDR(SB_FLASH2 + offset);
13840 + to = (uint32 *)buf;
13841 +
13842 + if (cnt < 4) {
13843 + bcopy(from, to, cnt);
13844 + return cnt;
13845 + }
13846 +
13847 + while (cnt >= 4) {
13848 + *to++ = *from++;
13849 + cnt -= 4;
13850 + }
13851 +
13852 + return (len - cnt);
13853 +}
13854 +
13855 +/* Poll for command completion. Returns zero when complete. */
13856 +int
13857 +sflash_poll(chipcregs_t *cc, uint offset)
13858 +{
13859 + if (offset >= sflash.size)
13860 + return -22;
13861 +
13862 + switch (sflash.type) {
13863 + case SFLASH_ST:
13864 + /* Check for ST Write In Progress bit */
13865 + sflash_cmd(cc, SFLASH_ST_RDSR);
13866 + return R_REG(&cc->flashdata) & SFLASH_ST_WIP;
13867 + case SFLASH_AT:
13868 + /* Check for Atmel Ready bit */
13869 + sflash_cmd(cc, SFLASH_AT_STATUS);
13870 + return !(R_REG(&cc->flashdata) & SFLASH_AT_READY);
13871 + }
13872 +
13873 + return 0;
13874 +}
13875 +
13876 +/* Write len bytes starting at offset into buf. Returns number of bytes
13877 + * written. Caller should poll for completion.
13878 + */
13879 +int
13880 +sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
13881 +{
13882 + struct sflash *sfl;
13883 + int ret = 0;
13884 + bool is4712b0;
13885 + uint32 page, byte, mask;
13886 +
13887 + if (!len)
13888 + return 0;
13889 +
13890 + if ((offset + len) > sflash.size)
13891 + return -22;
13892 +
13893 + sfl = &sflash;
13894 + switch (sfl->type) {
13895 + case SFLASH_ST:
13896 + mask = R_REG(&cc->chipid);
13897 + is4712b0 = (((mask & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
13898 + ((mask & CID_REV_MASK) == (3 << CID_REV_SHIFT)));
13899 + /* Enable writes */
13900 + sflash_cmd(cc, SFLASH_ST_WREN);
13901 + if (is4712b0) {
13902 + mask = 1 << 14;
13903 + W_REG(&cc->flashaddress, offset);
13904 + W_REG(&cc->flashdata, *buf++);
13905 + /* Set chip select */
13906 + OR_REG(&cc->gpioout, mask);
13907 + /* Issue a page program with the first byte */
13908 + sflash_cmd(cc, SFLASH_ST_PP);
13909 + ret = 1;
13910 + offset++;
13911 + len--;
13912 + while (len > 0) {
13913 + if ((offset & 255) == 0) {
13914 + /* Page boundary, drop cs and return */
13915 + AND_REG(&cc->gpioout, ~mask);
13916 + if (!sflash_poll(cc, offset)) {
13917 + /* Flash rejected command */
13918 + return -11;
13919 + }
13920 + return ret;
13921 + } else {
13922 + /* Write single byte */
13923 + sflash_cmd(cc, *buf++);
13924 + }
13925 + ret++;
13926 + offset++;
13927 + len--;
13928 + }
13929 + /* All done, drop cs if needed */
13930 + if ((offset & 255) != 1) {
13931 + /* Drop cs */
13932 + AND_REG(&cc->gpioout, ~mask);
13933 + if (!sflash_poll(cc, offset)) {
13934 + /* Flash rejected command */
13935 + return -12;
13936 + }
13937 + }
13938 + } else {
13939 + ret = 1;
13940 + W_REG(&cc->flashaddress, offset);
13941 + W_REG(&cc->flashdata, *buf);
13942 + /* Page program */
13943 + sflash_cmd(cc, SFLASH_ST_PP);
13944 + }
13945 + break;
13946 + case SFLASH_AT:
13947 + mask = sfl->blocksize - 1;
13948 + page = (offset & ~mask) << 1;
13949 + byte = offset & mask;
13950 + /* Read main memory page into buffer 1 */
13951 + if (byte || len < sfl->blocksize) {
13952 + W_REG(&cc->flashaddress, page);
13953 + sflash_cmd(cc, SFLASH_AT_BUF1_LOAD);
13954 + /* 250 us for AT45DB321B */
13955 + SPINWAIT(sflash_poll(cc, offset), 1000);
13956 + ASSERT(!sflash_poll(cc, offset));
13957 + }
13958 + /* Write into buffer 1 */
13959 + for (ret = 0; ret < len && byte < sfl->blocksize; ret++) {
13960 + W_REG(&cc->flashaddress, byte++);
13961 + W_REG(&cc->flashdata, *buf++);
13962 + sflash_cmd(cc, SFLASH_AT_BUF1_WRITE);
13963 + }
13964 + /* Write buffer 1 into main memory page */
13965 + W_REG(&cc->flashaddress, page);
13966 + sflash_cmd(cc, SFLASH_AT_BUF1_PROGRAM);
13967 + break;
13968 + }
13969 +
13970 + return ret;
13971 +}
13972 +
13973 +/* Erase a region. Returns number of bytes scheduled for erasure.
13974 + * Caller should poll for completion.
13975 + */
13976 +int
13977 +sflash_erase(chipcregs_t *cc, uint offset)
13978 +{
13979 + struct sflash *sfl;
13980 +
13981 + if (offset >= sflash.size)
13982 + return -22;
13983 +
13984 + sfl = &sflash;
13985 + switch (sfl->type) {
13986 + case SFLASH_ST:
13987 + sflash_cmd(cc, SFLASH_ST_WREN);
13988 + W_REG(&cc->flashaddress, offset);
13989 + sflash_cmd(cc, SFLASH_ST_SE);
13990 + return sfl->blocksize;
13991 + case SFLASH_AT:
13992 + W_REG(&cc->flashaddress, offset << 1);
13993 + sflash_cmd(cc, SFLASH_AT_PAGE_ERASE);
13994 + return sfl->blocksize;
13995 + }
13996 +
13997 + return 0;
13998 +}
13999 +
14000 +/*
14001 + * writes the appropriate range of flash, a NULL buf simply erases
14002 + * the region of flash
14003 + */
14004 +int
14005 +sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
14006 +{
14007 + struct sflash *sfl;
14008 + uchar *block = NULL, *cur_ptr, *blk_ptr;
14009 + uint blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder;
14010 + uint blk_offset, blk_len, copied;
14011 + int bytes, ret = 0;
14012 +
14013 + /* Check address range */
14014 + if (len <= 0)
14015 + return 0;
14016 +
14017 + sfl = &sflash;
14018 + if ((offset + len) > sfl->size)
14019 + return -1;
14020 +
14021 + blocksize = sfl->blocksize;
14022 + mask = blocksize - 1;
14023 +
14024 + /* Allocate a block of mem */
14025 + if (!(block = MALLOC(NULL, blocksize)))
14026 + return -1;
14027 +
14028 + while (len) {
14029 + /* Align offset */
14030 + cur_offset = offset & ~mask;
14031 + cur_length = blocksize;
14032 + cur_ptr = block;
14033 +
14034 + remainder = blocksize - (offset & mask);
14035 + if (len < remainder)
14036 + cur_retlen = len;
14037 + else
14038 + cur_retlen = remainder;
14039 +
14040 + /* buf == NULL means erase only */
14041 + if (buf) {
14042 + /* Copy existing data into holding block if necessary */
14043 + if ((offset & mask) || (len < blocksize)) {
14044 + blk_offset = cur_offset;
14045 + blk_len = cur_length;
14046 + blk_ptr = cur_ptr;
14047 +
14048 + /* Copy entire block */
14049 + while(blk_len) {
14050 + copied = sflash_read(cc, blk_offset, blk_len, blk_ptr);
14051 + blk_offset += copied;
14052 + blk_len -= copied;
14053 + blk_ptr += copied;
14054 + }
14055 + }
14056 +
14057 + /* Copy input data into holding block */
14058 + memcpy(cur_ptr + (offset & mask), buf, cur_retlen);
14059 + }
14060 +
14061 + /* Erase block */
14062 + if ((ret = sflash_erase(cc, (uint) cur_offset)) < 0)
14063 + goto done;
14064 + while (sflash_poll(cc, (uint) cur_offset));
14065 +
14066 + /* buf == NULL means erase only */
14067 + if (!buf) {
14068 + offset += cur_retlen;
14069 + len -= cur_retlen;
14070 + continue;
14071 + }
14072 +
14073 + /* Write holding block */
14074 + while (cur_length > 0) {
14075 + if ((bytes = sflash_write(cc,
14076 + (uint) cur_offset,
14077 + (uint) cur_length,
14078 + (uchar *) cur_ptr)) < 0) {
14079 + ret = bytes;
14080 + goto done;
14081 + }
14082 + while (sflash_poll(cc, (uint) cur_offset));
14083 + cur_offset += bytes;
14084 + cur_length -= bytes;
14085 + cur_ptr += bytes;
14086 + }
14087 +
14088 + offset += cur_retlen;
14089 + len -= cur_retlen;
14090 + buf += cur_retlen;
14091 + }
14092 +
14093 + ret = len;
14094 +done:
14095 + if (block)
14096 + MFREE(NULL, block, blocksize);
14097 + return ret;
14098 +}
14099 +
14100 diff -Nur linux-2.4.32/arch/mips/bcm947xx/time.c linux-2.4.32-brcm/arch/mips/bcm947xx/time.c
14101 --- linux-2.4.32/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +0100
14102 +++ linux-2.4.32-brcm/arch/mips/bcm947xx/time.c 2005-12-16 23:39:10.948837000 +0100
14103 @@ -0,0 +1,118 @@
14104 +/*
14105 + * Copyright 2004, Broadcom Corporation
14106 + * All Rights Reserved.
14107 + *
14108 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14109 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14110 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14111 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14112 + *
14113 + * $Id: time.c,v 1.1 2005/03/16 13:49:59 wbx Exp $
14114 + */
14115 +#include <linux/config.h>
14116 +#include <linux/init.h>
14117 +#include <linux/kernel.h>
14118 +#include <linux/sched.h>
14119 +#include <linux/serial_reg.h>
14120 +#include <linux/interrupt.h>
14121 +#include <asm/addrspace.h>
14122 +#include <asm/io.h>
14123 +#include <asm/time.h>
14124 +
14125 +#include <typedefs.h>
14126 +#include <osl.h>
14127 +#include <sbutils.h>
14128 +#include <bcmnvram.h>
14129 +#include <sbconfig.h>
14130 +#include <sbextif.h>
14131 +#include <sbmips.h>
14132 +
14133 +/* Global SB handle */
14134 +extern void *bcm947xx_sbh;
14135 +extern spinlock_t bcm947xx_sbh_lock;
14136 +
14137 +/* Convenience */
14138 +#define sbh bcm947xx_sbh
14139 +#define sbh_lock bcm947xx_sbh_lock
14140 +
14141 +extern int panic_timeout;
14142 +static int watchdog = 0;
14143 +static u8 *mcr = NULL;
14144 +
14145 +void __init
14146 +bcm947xx_time_init(void)
14147 +{
14148 + unsigned int hz;
14149 + extifregs_t *eir;
14150 +
14151 + /*
14152 + * Use deterministic values for initial counter interrupt
14153 + * so that calibrate delay avoids encountering a counter wrap.
14154 + */
14155 + write_c0_count(0);
14156 + write_c0_compare(0xffff);
14157 +
14158 + if (!(hz = sb_mips_clock(sbh)))
14159 + hz = 100000000;
14160 +
14161 + printk("CPU: BCM%04x rev %d at %d MHz\n", sb_chip(sbh), sb_chiprev(sbh),
14162 + (hz + 500000) / 1000000);
14163 +
14164 + /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
14165 + mips_hpt_frequency = hz / 2;
14166 +
14167 + /* Set watchdog interval in ms */
14168 + watchdog = simple_strtoul(nvram_safe_get("watchdog"), NULL, 0);
14169 +
14170 + /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */
14171 + if (watchdog > 0) {
14172 + if (watchdog < 3000)
14173 + watchdog = 3000;
14174 + }
14175 +
14176 +
14177 + /* Set panic timeout in seconds */
14178 + panic_timeout = watchdog / 1000;
14179 +
14180 + /* Setup blink */
14181 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
14182 + sbconfig_t *sb = (sbconfig_t *)((unsigned int) eir + SBCONFIGOFF);
14183 + unsigned long base = EXTIF_CFGIF_BASE(sb_base(readl(&sb->sbadmatch1)));
14184 + mcr = (u8 *) ioremap_nocache(base + UART_MCR, 1);
14185 + }
14186 +}
14187 +
14188 +static void
14189 +bcm947xx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
14190 +{
14191 + /* Generic MIPS timer code */
14192 + timer_interrupt(irq, dev_id, regs);
14193 +
14194 + /* Set the watchdog timer to reset after the specified number of ms */
14195 + if (watchdog > 0)
14196 + sb_watchdog(sbh, WATCHDOG_CLOCK / 1000 * watchdog);
14197 +
14198 +#ifdef CONFIG_HWSIM
14199 + (*((int *)0xa0000f1c))++;
14200 +#else
14201 + /* Blink one of the LEDs in the external UART */
14202 + if (mcr && !(jiffies % (HZ/2)))
14203 + writeb(readb(mcr) ^ UART_MCR_OUT2, mcr);
14204 +#endif
14205 +}
14206 +
14207 +static struct irqaction bcm947xx_timer_irqaction = {
14208 + bcm947xx_timer_interrupt,
14209 + SA_INTERRUPT,
14210 + 0,
14211 + "timer",
14212 + NULL,
14213 + NULL
14214 +};
14215 +
14216 +void __init
14217 +bcm947xx_timer_setup(struct irqaction *irq)
14218 +{
14219 + /* Enable the timer interrupt */
14220 + setup_irq(7, &bcm947xx_timer_irqaction);
14221 +}
14222 diff -Nur linux-2.4.32/arch/mips/config-shared.in linux-2.4.32-brcm/arch/mips/config-shared.in
14223 --- linux-2.4.32/arch/mips/config-shared.in 2005-01-19 15:09:27.000000000 +0100
14224 +++ linux-2.4.32-brcm/arch/mips/config-shared.in 2005-12-16 23:39:11.080845250 +0100
14225 @@ -205,6 +205,14 @@
14226 fi
14227 define_bool CONFIG_MIPS_RTC y
14228 fi
14229 +dep_bool 'Support for Broadcom MIPS-based boards' CONFIG_MIPS_BRCM $CONFIG_EXPERIMENTAL
14230 +dep_bool 'Support for Broadcom BCM947XX' CONFIG_BCM947XX $CONFIG_MIPS_BRCM
14231 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
14232 + bool ' Support for Broadcom BCM4710' CONFIG_BCM4710
14233 + bool ' Support for Broadcom BCM4310' CONFIG_BCM4310
14234 + bool ' Support for Broadcom BCM4704' CONFIG_BCM4704
14235 + bool ' Support for Broadcom BCM5365' CONFIG_BCM5365
14236 +fi
14237 bool 'Support for SNI RM200 PCI' CONFIG_SNI_RM200_PCI
14238 bool 'Support for TANBAC TB0226 (Mbase)' CONFIG_TANBAC_TB0226
14239 bool 'Support for TANBAC TB0229 (VR4131DIMM)' CONFIG_TANBAC_TB0229
14240 @@ -226,6 +234,11 @@
14241 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
14242
14243 #
14244 +# Provide an option for a default kernel command line
14245 +#
14246 +string 'Default kernel command string' CONFIG_CMDLINE ""
14247 +
14248 +#
14249 # Select some configuration options automatically based on user selections.
14250 #
14251 if [ "$CONFIG_ACER_PICA_61" = "y" ]; then
14252 @@ -533,6 +546,13 @@
14253 define_bool CONFIG_SWAP_IO_SPACE_L y
14254 define_bool CONFIG_BOOT_ELF32 y
14255 fi
14256 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
14257 + define_bool CONFIG_PCI y
14258 + define_bool CONFIG_NONCOHERENT_IO y
14259 + define_bool CONFIG_NEW_TIME_C y
14260 + define_bool CONFIG_NEW_IRQ y
14261 + define_bool CONFIG_HND y
14262 +fi
14263 if [ "$CONFIG_SNI_RM200_PCI" = "y" ]; then
14264 define_bool CONFIG_ARC32 y
14265 define_bool CONFIG_ARC_MEMORY y
14266 @@ -1011,7 +1031,11 @@
14267
14268 bool 'Are you using a crosscompiler' CONFIG_CROSSCOMPILE
14269 bool 'Enable run-time debugging' CONFIG_RUNTIME_DEBUG
14270 -bool 'Remote GDB kernel debugging' CONFIG_KGDB
14271 +if [ "$CONFIG_BCM947XX" = "y" ] ; then
14272 + bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG
14273 +else
14274 + bool 'Remote GDB kernel debugging' CONFIG_KGDB
14275 +fi
14276 dep_bool ' Console output to GDB' CONFIG_GDB_CONSOLE $CONFIG_KGDB
14277 if [ "$CONFIG_KGDB" = "y" ]; then
14278 define_bool CONFIG_DEBUG_INFO y
14279 diff -Nur linux-2.4.32/arch/mips/kernel/cpu-probe.c linux-2.4.32-brcm/arch/mips/kernel/cpu-probe.c
14280 --- linux-2.4.32/arch/mips/kernel/cpu-probe.c 2005-01-19 15:09:29.000000000 +0100
14281 +++ linux-2.4.32-brcm/arch/mips/kernel/cpu-probe.c 2005-12-16 23:39:11.084845500 +0100
14282 @@ -174,7 +174,7 @@
14283
14284 static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
14285 {
14286 - switch (c->processor_id & 0xff00) {
14287 + switch (c->processor_id & PRID_IMP_MASK) {
14288 case PRID_IMP_R2000:
14289 c->cputype = CPU_R2000;
14290 c->isa_level = MIPS_CPU_ISA_I;
14291 @@ -184,7 +184,7 @@
14292 c->tlbsize = 64;
14293 break;
14294 case PRID_IMP_R3000:
14295 - if ((c->processor_id & 0xff) == PRID_REV_R3000A)
14296 + if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A)
14297 if (cpu_has_confreg())
14298 c->cputype = CPU_R3081E;
14299 else
14300 @@ -199,12 +199,12 @@
14301 break;
14302 case PRID_IMP_R4000:
14303 if (read_c0_config() & CONF_SC) {
14304 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
14305 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
14306 c->cputype = CPU_R4400PC;
14307 else
14308 c->cputype = CPU_R4000PC;
14309 } else {
14310 - if ((c->processor_id & 0xff) >= PRID_REV_R4400)
14311 + if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_R4400)
14312 c->cputype = CPU_R4400SC;
14313 else
14314 c->cputype = CPU_R4000SC;
14315 @@ -450,7 +450,7 @@
14316 static inline void cpu_probe_mips(struct cpuinfo_mips *c)
14317 {
14318 decode_config1(c);
14319 - switch (c->processor_id & 0xff00) {
14320 + switch (c->processor_id & PRID_IMP_MASK) {
14321 case PRID_IMP_4KC:
14322 c->cputype = CPU_4KC;
14323 c->isa_level = MIPS_CPU_ISA_M32;
14324 @@ -491,10 +491,10 @@
14325 {
14326 decode_config1(c);
14327 c->options |= MIPS_CPU_PREFETCH;
14328 - switch (c->processor_id & 0xff00) {
14329 + switch (c->processor_id & PRID_IMP_MASK) {
14330 case PRID_IMP_AU1_REV1:
14331 case PRID_IMP_AU1_REV2:
14332 - switch ((c->processor_id >> 24) & 0xff) {
14333 + switch ((c->processor_id >> 24) & PRID_REV_MASK) {
14334 case 0:
14335 c->cputype = CPU_AU1000;
14336 break;
14337 @@ -522,10 +522,34 @@
14338 }
14339 }
14340
14341 +static inline void cpu_probe_broadcom(struct cpuinfo_mips *c)
14342 +{
14343 + decode_config1(c);
14344 + c->options |= MIPS_CPU_PREFETCH;
14345 + switch (c->processor_id & PRID_IMP_MASK) {
14346 + case PRID_IMP_BCM4710:
14347 + c->cputype = CPU_BCM4710;
14348 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
14349 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
14350 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
14351 + break;
14352 + case PRID_IMP_4KC:
14353 + case PRID_IMP_BCM3302:
14354 + c->cputype = CPU_BCM3302;
14355 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
14356 + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER;
14357 + c->scache.flags = MIPS_CACHE_NOT_PRESENT;
14358 + break;
14359 + default:
14360 + c->cputype = CPU_UNKNOWN;
14361 + break;
14362 + }
14363 +}
14364 +
14365 static inline void cpu_probe_sibyte(struct cpuinfo_mips *c)
14366 {
14367 decode_config1(c);
14368 - switch (c->processor_id & 0xff00) {
14369 + switch (c->processor_id & PRID_IMP_MASK) {
14370 case PRID_IMP_SB1:
14371 c->cputype = CPU_SB1;
14372 c->isa_level = MIPS_CPU_ISA_M64;
14373 @@ -547,7 +571,7 @@
14374 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c)
14375 {
14376 decode_config1(c);
14377 - switch (c->processor_id & 0xff00) {
14378 + switch (c->processor_id & PRID_IMP_MASK) {
14379 case PRID_IMP_SR71000:
14380 c->cputype = CPU_SR71000;
14381 c->isa_level = MIPS_CPU_ISA_M64;
14382 @@ -572,7 +596,7 @@
14383 c->cputype = CPU_UNKNOWN;
14384
14385 c->processor_id = read_c0_prid();
14386 - switch (c->processor_id & 0xff0000) {
14387 + switch (c->processor_id & PRID_COMP_MASK) {
14388
14389 case PRID_COMP_LEGACY:
14390 cpu_probe_legacy(c);
14391 @@ -583,6 +607,9 @@
14392 case PRID_COMP_ALCHEMY:
14393 cpu_probe_alchemy(c);
14394 break;
14395 + case PRID_COMP_BROADCOM:
14396 + cpu_probe_broadcom(c);
14397 + break;
14398 case PRID_COMP_SIBYTE:
14399 cpu_probe_sibyte(c);
14400 break;
14401 diff -Nur linux-2.4.32/arch/mips/kernel/head.S linux-2.4.32-brcm/arch/mips/kernel/head.S
14402 --- linux-2.4.32/arch/mips/kernel/head.S 2005-01-19 15:09:29.000000000 +0100
14403 +++ linux-2.4.32-brcm/arch/mips/kernel/head.S 2005-12-16 23:39:11.084845500 +0100
14404 @@ -28,12 +28,20 @@
14405 #include <asm/mipsregs.h>
14406 #include <asm/stackframe.h>
14407
14408 +#ifdef CONFIG_BCM4710
14409 +#undef eret
14410 +#define eret nop; nop; eret
14411 +#endif
14412 +
14413 .text
14414 + j kernel_entry
14415 + nop
14416 +
14417 /*
14418 * Reserved space for exception handlers.
14419 * Necessary for machines which link their kernels at KSEG0.
14420 */
14421 - .fill 0x400
14422 + .fill 0x3f4
14423
14424 /* The following two symbols are used for kernel profiling. */
14425 EXPORT(stext)
14426 diff -Nur linux-2.4.32/arch/mips/kernel/proc.c linux-2.4.32-brcm/arch/mips/kernel/proc.c
14427 --- linux-2.4.32/arch/mips/kernel/proc.c 2005-01-19 15:09:29.000000000 +0100
14428 +++ linux-2.4.32-brcm/arch/mips/kernel/proc.c 2005-12-16 23:39:11.084845500 +0100
14429 @@ -78,9 +78,10 @@
14430 [CPU_AU1550] "Au1550",
14431 [CPU_24K] "MIPS 24K",
14432 [CPU_AU1200] "Au1200",
14433 + [CPU_BCM4710] "BCM4710",
14434 + [CPU_BCM3302] "BCM3302",
14435 };
14436
14437 -
14438 static int show_cpuinfo(struct seq_file *m, void *v)
14439 {
14440 unsigned int version = current_cpu_data.processor_id;
14441 diff -Nur linux-2.4.32/arch/mips/kernel/setup.c linux-2.4.32-brcm/arch/mips/kernel/setup.c
14442 --- linux-2.4.32/arch/mips/kernel/setup.c 2005-01-19 15:09:29.000000000 +0100
14443 +++ linux-2.4.32-brcm/arch/mips/kernel/setup.c 2005-12-16 23:39:11.140849000 +0100
14444 @@ -495,6 +495,7 @@
14445 void swarm_setup(void);
14446 void hp_setup(void);
14447 void au1x00_setup(void);
14448 + void brcm_setup(void);
14449 void frame_info_init(void);
14450
14451 frame_info_init();
14452 @@ -693,6 +694,11 @@
14453 pmc_yosemite_setup();
14454 break;
14455 #endif
14456 +#if defined(CONFIG_BCM4710) || defined(CONFIG_BCM4310)
14457 + case MACH_GROUP_BRCM:
14458 + brcm_setup();
14459 + break;
14460 +#endif
14461 default:
14462 panic("Unsupported architecture");
14463 }
14464 diff -Nur linux-2.4.32/arch/mips/kernel/traps.c linux-2.4.32-brcm/arch/mips/kernel/traps.c
14465 --- linux-2.4.32/arch/mips/kernel/traps.c 2005-01-19 15:09:29.000000000 +0100
14466 +++ linux-2.4.32-brcm/arch/mips/kernel/traps.c 2005-12-16 23:39:11.140849000 +0100
14467 @@ -913,6 +913,7 @@
14468 void __init trap_init(void)
14469 {
14470 extern char except_vec1_generic;
14471 + extern char except_vec2_generic;
14472 extern char except_vec3_generic, except_vec3_r4000;
14473 extern char except_vec_ejtag_debug;
14474 extern char except_vec4;
14475 @@ -922,6 +923,7 @@
14476
14477 /* Copy the generic exception handler code to it's final destination. */
14478 memcpy((void *)(KSEG0 + 0x80), &except_vec1_generic, 0x80);
14479 + memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80);
14480
14481 /*
14482 * Setup default vectors
14483 @@ -980,6 +982,12 @@
14484 set_except_vector(13, handle_tr);
14485 set_except_vector(22, handle_mdmx);
14486
14487 + if (current_cpu_data.cputype == CPU_SB1) {
14488 + /* Enable timer interrupt and scd mapped interrupt */
14489 + clear_c0_status(0xf000);
14490 + set_c0_status(0xc00);
14491 + }
14492 +
14493 if (cpu_has_fpu && !cpu_has_nofpuex)
14494 set_except_vector(15, handle_fpe);
14495
14496 diff -Nur linux-2.4.32/arch/mips/Makefile linux-2.4.32-brcm/arch/mips/Makefile
14497 --- linux-2.4.32/arch/mips/Makefile 2005-01-19 15:09:26.000000000 +0100
14498 +++ linux-2.4.32-brcm/arch/mips/Makefile 2005-12-16 23:39:10.668819500 +0100
14499 @@ -715,6 +715,19 @@
14500 endif
14501
14502 #
14503 +# Broadcom BCM947XX variants
14504 +#
14505 +ifdef CONFIG_BCM947XX
14506 +LIBS += arch/mips/bcm947xx/generic/brcm.o arch/mips/bcm947xx/bcm947xx.o
14507 +SUBDIRS += arch/mips/bcm947xx/generic arch/mips/bcm947xx
14508 +LOADADDR := 0x80001000
14509 +
14510 +zImage: vmlinux
14511 + $(MAKE) -C arch/$(ARCH)/bcm947xx/compressed
14512 +export LOADADDR
14513 +endif
14514 +
14515 +#
14516 # Choosing incompatible machines durings configuration will result in
14517 # error messages during linking. Select a default linkscript if
14518 # none has been choosen above.
14519 @@ -767,6 +780,7 @@
14520 $(MAKE) -C arch/$(ARCH)/tools clean
14521 $(MAKE) -C arch/mips/baget clean
14522 $(MAKE) -C arch/mips/lasat clean
14523 + $(MAKE) -C arch/mips/bcm947xx/compressed clean
14524
14525 archmrproper:
14526 @$(MAKEBOOT) mrproper
14527 diff -Nur linux-2.4.32/arch/mips/mm/c-r4k.c linux-2.4.32-brcm/arch/mips/mm/c-r4k.c
14528 --- linux-2.4.32/arch/mips/mm/c-r4k.c 2005-01-19 15:09:29.000000000 +0100
14529 +++ linux-2.4.32-brcm/arch/mips/mm/c-r4k.c 2005-12-16 23:39:11.144849250 +0100
14530 @@ -1114,3 +1114,47 @@
14531 build_clear_page();
14532 build_copy_page();
14533 }
14534 +
14535 +#ifdef CONFIG_BCM4704
14536 +static void __init mips32_icache_fill(unsigned long addr, uint nbytes)
14537 +{
14538 + unsigned long ic_lsize = current_cpu_data.icache.linesz;
14539 + int i;
14540 + for (i = 0; i < nbytes; i += ic_lsize)
14541 + fill_icache_line((addr + i));
14542 +}
14543 +
14544 +/*
14545 + * This must be run from the cache on 4704A0
14546 + * so there are no mips core BIU ops in progress
14547 + * when the PFC is enabled.
14548 + */
14549 +#define PFC_CR0 0xff400000 /* control reg 0 */
14550 +#define PFC_CR1 0xff400004 /* control reg 1 */
14551 +static void __init enable_pfc(u32 mode)
14552 +{
14553 + /* write range */
14554 + *(volatile u32 *)PFC_CR1 = 0xffff0000;
14555 +
14556 + /* enable */
14557 + *(volatile u32 *)PFC_CR0 = mode;
14558 +}
14559 +#endif
14560 +
14561 +
14562 +void check_enable_mips_pfc(int val)
14563 +{
14564 +
14565 +#ifdef CONFIG_BCM4704
14566 + struct cpuinfo_mips *c = &current_cpu_data;
14567 +
14568 + /* enable prefetch cache */
14569 + if (((c->processor_id & (PRID_COMP_MASK | PRID_IMP_MASK)) == PRID_IMP_BCM3302)
14570 + && (read_c0_diag() & (1 << 29))) {
14571 + mips32_icache_fill((unsigned long) &enable_pfc, 64);
14572 + enable_pfc(val);
14573 + }
14574 +#endif
14575 +}
14576 +
14577 +
14578 diff -Nur linux-2.4.32/arch/mips/pci/Makefile linux-2.4.32-brcm/arch/mips/pci/Makefile
14579 --- linux-2.4.32/arch/mips/pci/Makefile 2005-01-19 15:09:29.000000000 +0100
14580 +++ linux-2.4.32-brcm/arch/mips/pci/Makefile 2005-12-16 23:39:11.144849250 +0100
14581 @@ -13,7 +13,9 @@
14582 obj-$(CONFIG_MIPS_MSC) += ops-msc.o
14583 obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o
14584 obj-$(CONFIG_SNI_RM200_PCI) += ops-sni.o
14585 +ifndef CONFIG_BCM947XX
14586 obj-y += pci.o
14587 +endif
14588 obj-$(CONFIG_PCI_AUTO) += pci_auto.o
14589
14590 include $(TOPDIR)/Rules.make
14591 diff -Nur linux-2.4.32/drivers/char/serial.c linux-2.4.32-brcm/drivers/char/serial.c
14592 --- linux-2.4.32/drivers/char/serial.c 2005-11-16 20:12:54.000000000 +0100
14593 +++ linux-2.4.32-brcm/drivers/char/serial.c 2005-12-16 23:39:11.200852750 +0100
14594 @@ -422,6 +422,10 @@
14595 return inb(info->port+1);
14596 #endif
14597 case SERIAL_IO_MEM:
14598 +#ifdef CONFIG_BCM4310
14599 + readb((unsigned long) info->iomem_base +
14600 + (UART_SCR<<info->iomem_reg_shift));
14601 +#endif
14602 return readb((unsigned long) info->iomem_base +
14603 (offset<<info->iomem_reg_shift));
14604 default:
14605 @@ -442,6 +446,9 @@
14606 case SERIAL_IO_MEM:
14607 writeb(value, (unsigned long) info->iomem_base +
14608 (offset<<info->iomem_reg_shift));
14609 +#ifdef CONFIG_BCM4704
14610 + *((volatile unsigned int *) KSEG1ADDR(0x18000000));
14611 +#endif
14612 break;
14613 default:
14614 outb(value, info->port+offset);
14615 @@ -1704,7 +1711,7 @@
14616 /* Special case since 134 is really 134.5 */
14617 quot = (2*baud_base / 269);
14618 else if (baud)
14619 - quot = baud_base / baud;
14620 + quot = (baud_base + (baud / 2)) / baud;
14621 }
14622 /* If the quotient is zero refuse the change */
14623 if (!quot && old_termios) {
14624 @@ -1721,12 +1728,12 @@
14625 /* Special case since 134 is really 134.5 */
14626 quot = (2*baud_base / 269);
14627 else if (baud)
14628 - quot = baud_base / baud;
14629 + quot = (baud_base + (baud / 2)) / baud;
14630 }
14631 }
14632 /* As a last resort, if the quotient is zero, default to 9600 bps */
14633 if (!quot)
14634 - quot = baud_base / 9600;
14635 + quot = (baud_base + 4800) / 9600;
14636 /*
14637 * Work around a bug in the Oxford Semiconductor 952 rev B
14638 * chip which causes it to seriously miscalculate baud rates
14639 @@ -5982,6 +5989,13 @@
14640 * Divisor, bytesize and parity
14641 */
14642 state = rs_table + co->index;
14643 + /*
14644 + * Safe guard: state structure must have been initialized
14645 + */
14646 + if (state->iomem_base == NULL) {
14647 + printk("!unable to setup serial console!\n");
14648 + return -1;
14649 + }
14650 if (doflow)
14651 state->flags |= ASYNC_CONS_FLOW;
14652 info = &async_sercons;
14653 @@ -5995,7 +6009,7 @@
14654 info->io_type = state->io_type;
14655 info->iomem_base = state->iomem_base;
14656 info->iomem_reg_shift = state->iomem_reg_shift;
14657 - quot = state->baud_base / baud;
14658 + quot = (state->baud_base + (baud / 2)) / baud;
14659 cval = cflag & (CSIZE | CSTOPB);
14660 #if defined(__powerpc__) || defined(__alpha__)
14661 cval >>= 8;
14662 diff -Nur linux-2.4.32/drivers/net/Config.in linux-2.4.32-brcm/drivers/net/Config.in
14663 --- linux-2.4.32/drivers/net/Config.in 2005-01-19 15:09:56.000000000 +0100
14664 +++ linux-2.4.32-brcm/drivers/net/Config.in 2005-12-16 23:39:11.232854750 +0100
14665 @@ -2,6 +2,8 @@
14666 # Network device configuration
14667 #
14668
14669 +tristate 'Broadcom Home Network Division' CONFIG_HND $CONFIG_PCI
14670 +
14671 source drivers/net/arcnet/Config.in
14672
14673 tristate 'Dummy net driver support' CONFIG_DUMMY
14674 @@ -173,6 +175,7 @@
14675
14676 dep_tristate ' Apricot Xen-II on board Ethernet' CONFIG_APRICOT $CONFIG_ISA
14677 dep_tristate ' Broadcom 4400 ethernet support (EXPERIMENTAL)' CONFIG_B44 $CONFIG_PCI $CONFIG_EXPERIMENTAL
14678 + dep_tristate ' Proprietary Broadcom 10/100 Ethernet support' CONFIG_ET $CONFIG_PCI
14679 dep_tristate ' CS89x0 support' CONFIG_CS89x0 $CONFIG_ISA
14680 dep_tristate ' DECchip Tulip (dc21x4x) PCI support' CONFIG_TULIP $CONFIG_PCI
14681 if [ "$CONFIG_TULIP" = "y" -o "$CONFIG_TULIP" = "m" ]; then
14682 diff -Nur linux-2.4.32/drivers/net/et/Makefile linux-2.4.32-brcm/drivers/net/et/Makefile
14683 --- linux-2.4.32/drivers/net/et/Makefile 1970-01-01 01:00:00.000000000 +0100
14684 +++ linux-2.4.32-brcm/drivers/net/et/Makefile 2005-12-16 23:39:11.284858000 +0100
14685 @@ -0,0 +1,21 @@
14686 +#
14687 +# Makefile for the Broadcom et driver
14688 +#
14689 +# Copyright 2004, Broadcom Corporation
14690 +# All Rights Reserved.
14691 +#
14692 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14693 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14694 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14695 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14696 +#
14697 +# $Id: Makefile,v 1.1 2005/03/16 13:50:00 wbx Exp $
14698 +#
14699 +
14700 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCM47XX_CHOPS -DDMA -DBCMDRIVER
14701 +
14702 +O_TARGET := et.o
14703 +obj-y := et_linux.o etc.o etc47xx.o etc_robo.o etc_adm.o
14704 +obj-m := $(O_TARGET)
14705 +
14706 +include $(TOPDIR)/Rules.make
14707 diff -Nur linux-2.4.32/drivers/net/hnd/bcmsrom.c linux-2.4.32-brcm/drivers/net/hnd/bcmsrom.c
14708 --- linux-2.4.32/drivers/net/hnd/bcmsrom.c 1970-01-01 01:00:00.000000000 +0100
14709 +++ linux-2.4.32-brcm/drivers/net/hnd/bcmsrom.c 2005-12-16 23:39:11.284858000 +0100
14710 @@ -0,0 +1,936 @@
14711 +/*
14712 + * Misc useful routines to access NIC SROM/OTP .
14713 + *
14714 + * Copyright 2005, Broadcom Corporation
14715 + * All Rights Reserved.
14716 + *
14717 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
14718 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
14719 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
14720 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
14721 + * $Id$
14722 + */
14723 +
14724 +#include <typedefs.h>
14725 +#include <osl.h>
14726 +#include <bcmutils.h>
14727 +#include <bcmsrom.h>
14728 +#include <bcmdevs.h>
14729 +#include <bcmendian.h>
14730 +#include <sbpcmcia.h>
14731 +#include <pcicfg.h>
14732 +#include <sbutils.h>
14733 +#include <bcmnvram.h>
14734 +
14735 +#include <proto/ethernet.h> /* for sprom content groking */
14736 +
14737 +#define VARS_MAX 4096 /* should be reduced */
14738 +
14739 +#define WRITE_ENABLE_DELAY 500 /* 500 ms after write enable/disable toggle */
14740 +#define WRITE_WORD_DELAY 20 /* 20 ms between each word write */
14741 +
14742 +static int initvars_srom_pci(void *sbh, void *curmap, char **vars, int *count);
14743 +static int initvars_cis_pcmcia(void *sbh, osl_t *osh, char **vars, int *count);
14744 +static int initvars_flash_sb(void *sbh, char **vars, int *count);
14745 +static int srom_parsecis(osl_t *osh, uint8 *cis, char **vars, int *count);
14746 +static int sprom_cmd_pcmcia(osl_t *osh, uint8 cmd);
14747 +static int sprom_read_pcmcia(osl_t *osh, uint16 addr, uint16 *data);
14748 +static int sprom_write_pcmcia(osl_t *osh, uint16 addr, uint16 data);
14749 +static int sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc);
14750 +
14751 +static int initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count);
14752 +static int initvars_flash(osl_t *osh, char **vp, int len, char *devpath);
14753 +
14754 +/*
14755 + * Initialize local vars from the right source for this platform.
14756 + * Return 0 on success, nonzero on error.
14757 + */
14758 +int
14759 +srom_var_init(void *sbh, uint bustype, void *curmap, osl_t *osh, char **vars, int *count)
14760 +{
14761 + ASSERT(bustype == BUSTYPE(bustype));
14762 + if (vars == NULL || count == NULL)
14763 + return (0);
14764 +
14765 + switch (BUSTYPE(bustype)) {
14766 + case SB_BUS:
14767 + case JTAG_BUS:
14768 + return initvars_flash_sb(sbh, vars, count);
14769 +
14770 + case PCI_BUS:
14771 + ASSERT(curmap); /* can not be NULL */
14772 + return initvars_srom_pci(sbh, curmap, vars, count);
14773 +
14774 + case PCMCIA_BUS:
14775 + return initvars_cis_pcmcia(sbh, osh, vars, count);
14776 +
14777 +
14778 + default:
14779 + ASSERT(0);
14780 + }
14781 + return (-1);
14782 +}
14783 +
14784 +/* support only 16-bit word read from srom */
14785 +int
14786 +srom_read(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf)
14787 +{
14788 + void *srom;
14789 + uint i, off, nw;
14790 +
14791 + ASSERT(bustype == BUSTYPE(bustype));
14792 +
14793 + /* check input - 16-bit access only */
14794 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
14795 + return 1;
14796 +
14797 + off = byteoff / 2;
14798 + nw = nbytes / 2;
14799 +
14800 + if (BUSTYPE(bustype) == PCI_BUS) {
14801 + if (!curmap)
14802 + return 1;
14803 + srom = (uchar*)curmap + PCI_BAR0_SPROM_OFFSET;
14804 + if (sprom_read_pci(srom, off, buf, nw, FALSE))
14805 + return 1;
14806 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
14807 + for (i = 0; i < nw; i++) {
14808 + if (sprom_read_pcmcia(osh, (uint16)(off + i), (uint16*)(buf + i)))
14809 + return 1;
14810 + }
14811 + } else {
14812 + return 1;
14813 + }
14814 +
14815 + return 0;
14816 +}
14817 +
14818 +/* support only 16-bit word write into srom */
14819 +int
14820 +srom_write(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf)
14821 +{
14822 + uint16 *srom;
14823 + uint i, off, nw, crc_range;
14824 + uint16 image[SPROM_SIZE], *p;
14825 + uint8 crc;
14826 + volatile uint32 val32;
14827 +
14828 + ASSERT(bustype == BUSTYPE(bustype));
14829 +
14830 + /* check input - 16-bit access only */
14831 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
14832 + return 1;
14833 +
14834 + crc_range = (((BUSTYPE(bustype) == PCMCIA_BUS) || (BUSTYPE(bustype) == SDIO_BUS)) ? SPROM_SIZE : SPROM_CRC_RANGE) * 2;
14835 +
14836 + /* if changes made inside crc cover range */
14837 + if (byteoff < crc_range) {
14838 + nw = (((byteoff + nbytes) > crc_range) ? byteoff + nbytes : crc_range) / 2;
14839 + /* read data including entire first 64 words from srom */
14840 + if (srom_read(bustype, curmap, osh, 0, nw * 2, image))
14841 + return 1;
14842 + /* make changes */
14843 + bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes);
14844 + /* calculate crc */
14845 + htol16_buf(image, crc_range);
14846 + crc = ~hndcrc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE);
14847 + ltoh16_buf(image, crc_range);
14848 + image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff);
14849 + p = image;
14850 + off = 0;
14851 + } else {
14852 + p = buf;
14853 + off = byteoff / 2;
14854 + nw = nbytes / 2;
14855 + }
14856 +
14857 + if (BUSTYPE(bustype) == PCI_BUS) {
14858 + srom = (uint16*)((uchar*)curmap + PCI_BAR0_SPROM_OFFSET);
14859 + /* enable writes to the SPROM */
14860 + val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32));
14861 + val32 |= SPROM_WRITEEN;
14862 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32);
14863 + bcm_mdelay(WRITE_ENABLE_DELAY);
14864 + /* write srom */
14865 + for (i = 0; i < nw; i++) {
14866 + W_REG(&srom[off + i], p[i]);
14867 + bcm_mdelay(WRITE_WORD_DELAY);
14868 + }
14869 + /* disable writes to the SPROM */
14870 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 & ~SPROM_WRITEEN);
14871 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
14872 + /* enable writes to the SPROM */
14873 + if (sprom_cmd_pcmcia(osh, SROM_WEN))
14874 + return 1;
14875 + bcm_mdelay(WRITE_ENABLE_DELAY);
14876 + /* write srom */
14877 + for (i = 0; i < nw; i++) {
14878 + sprom_write_pcmcia(osh, (uint16)(off + i), p[i]);
14879 + bcm_mdelay(WRITE_WORD_DELAY);
14880 + }
14881 + /* disable writes to the SPROM */
14882 + if (sprom_cmd_pcmcia(osh, SROM_WDS))
14883 + return 1;
14884 + } else {
14885 + return 1;
14886 + }
14887 +
14888 + bcm_mdelay(WRITE_ENABLE_DELAY);
14889 + return 0;
14890 +}
14891 +
14892 +
14893 +static int
14894 +srom_parsecis(osl_t *osh, uint8 *cis, char **vars, int *count)
14895 +{
14896 + char eabuf[32];
14897 + char *vp, *base;
14898 + uint8 tup, tlen, sromrev = 1;
14899 + int i, j;
14900 + uint varsize;
14901 + bool ag_init = FALSE;
14902 + uint32 w32;
14903 +
14904 + ASSERT(vars);
14905 + ASSERT(count);
14906 +
14907 + base = vp = MALLOC(osh, VARS_MAX);
14908 + ASSERT(vp);
14909 + if (!vp)
14910 + return -2;
14911 +
14912 + i = 0;
14913 + do {
14914 + tup = cis[i++];
14915 + tlen = cis[i++];
14916 + if ((i + tlen) >= CIS_SIZE)
14917 + break;
14918 +
14919 + switch (tup) {
14920 + case CISTPL_MANFID:
14921 + vp += sprintf(vp, "manfid=%d", (cis[i + 1] << 8) + cis[i]);
14922 + vp++;
14923 + vp += sprintf(vp, "prodid=%d", (cis[i + 3] << 8) + cis[i + 2]);
14924 + vp++;
14925 + break;
14926 +
14927 + case CISTPL_FUNCE:
14928 + if (cis[i] == LAN_NID) {
14929 + ASSERT(cis[i + 1] == ETHER_ADDR_LEN);
14930 + bcm_ether_ntoa((uchar*)&cis[i + 2], eabuf);
14931 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
14932 + vp++;
14933 + }
14934 + break;
14935 +
14936 + case CISTPL_CFTABLE:
14937 + vp += sprintf(vp, "regwindowsz=%d", (cis[i + 7] << 8) | cis[i + 6]);
14938 + vp++;
14939 + break;
14940 +
14941 + case CISTPL_BRCM_HNBU:
14942 + switch (cis[i]) {
14943 + case HNBU_SROMREV:
14944 + sromrev = cis[i + 1];
14945 + break;
14946 +
14947 + case HNBU_CHIPID:
14948 + vp += sprintf(vp, "vendid=%d", (cis[i + 2] << 8) + cis[i + 1]);
14949 + vp++;
14950 + vp += sprintf(vp, "devid=%d", (cis[i + 4] << 8) + cis[i + 3]);
14951 + vp++;
14952 + if (tlen == 7) {
14953 + vp += sprintf(vp, "chiprev=%d", (cis[i + 6] << 8) + cis[i + 5]);
14954 + vp++;
14955 + }
14956 + break;
14957 +
14958 + case HNBU_BOARDREV:
14959 + vp += sprintf(vp, "boardrev=%d", cis[i + 1]);
14960 + vp++;
14961 + break;
14962 +
14963 + case HNBU_AA:
14964 + vp += sprintf(vp, "aa0=%d", cis[i + 1]);
14965 + vp++;
14966 + break;
14967 +
14968 + case HNBU_AG:
14969 + vp += sprintf(vp, "ag0=%d", cis[i + 1]);
14970 + vp++;
14971 + ag_init = TRUE;
14972 + break;
14973 +
14974 + case HNBU_CC:
14975 + ASSERT(sromrev > 1);
14976 + vp += sprintf(vp, "cc=%d", cis[i + 1]);
14977 + vp++;
14978 + break;
14979 +
14980 + case HNBU_PAPARMS:
14981 + if (tlen == 2) {
14982 + ASSERT(sromrev == 1);
14983 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + 1]);
14984 + vp++;
14985 + } else if (tlen >= 9) {
14986 + if (tlen == 10) {
14987 + ASSERT(sromrev == 2);
14988 + vp += sprintf(vp, "opo=%d", cis[i + 9]);
14989 + vp++;
14990 + } else
14991 + ASSERT(tlen == 9);
14992 +
14993 + for (j = 0; j < 3; j++) {
14994 + vp += sprintf(vp, "pa0b%d=%d", j,
14995 + (cis[i + (j * 2) + 2] << 8) + cis[i + (j * 2) + 1]);
14996 + vp++;
14997 + }
14998 + vp += sprintf(vp, "pa0itssit=%d", cis[i + 7]);
14999 + vp++;
15000 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + 8]);
15001 + vp++;
15002 + } else
15003 + ASSERT(tlen >= 9);
15004 + break;
15005 +
15006 + case HNBU_OEM:
15007 + ASSERT(sromrev == 1);
15008 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
15009 + cis[i + 1], cis[i + 2], cis[i + 3], cis[i + 4],
15010 + cis[i + 5], cis[i + 6], cis[i + 7], cis[i + 8]);
15011 + vp++;
15012 + break;
15013 +
15014 + case HNBU_BOARDFLAGS:
15015 + w32 = (cis[i + 2] << 8) + cis[i + 1];
15016 + if (tlen == 5)
15017 + w32 |= (cis[i + 4] << 24) + (cis[i + 3] << 16);
15018 + vp += sprintf(vp, "boardflags=0x%x", w32);
15019 + vp++;
15020 + break;
15021 +
15022 + case HNBU_LEDS:
15023 + if (cis[i + 1] != 0xff) {
15024 + vp += sprintf(vp, "wl0gpio0=%d", cis[i + 1]);
15025 + vp++;
15026 + }
15027 + if (cis[i + 2] != 0xff) {
15028 + vp += sprintf(vp, "wl0gpio1=%d", cis[i + 2]);
15029 + vp++;
15030 + }
15031 + if (cis[i + 3] != 0xff) {
15032 + vp += sprintf(vp, "wl0gpio2=%d", cis[i + 3]);
15033 + vp++;
15034 + }
15035 + if (cis[i + 4] != 0xff) {
15036 + vp += sprintf(vp, "wl0gpio3=%d", cis[i + 4]);
15037 + vp++;
15038 + }
15039 + break;
15040 +
15041 + case HNBU_CCODE:
15042 + ASSERT(sromrev > 1);
15043 + vp += sprintf(vp, "ccode=%c%c", cis[i + 1], cis[i + 2]);
15044 + vp++;
15045 + vp += sprintf(vp, "cctl=0x%x", cis[i + 3]);
15046 + vp++;
15047 + break;
15048 +
15049 + case HNBU_CCKPO:
15050 + ASSERT(sromrev > 2);
15051 + vp += sprintf(vp, "cckpo=0x%x", (cis[i + 2] << 8) | cis[i + 1]);
15052 + vp++;
15053 + break;
15054 +
15055 + case HNBU_OFDMPO:
15056 + ASSERT(sromrev > 2);
15057 + vp += sprintf(vp, "ofdmpo=0x%x", (cis[i + 4] << 24) |
15058 + (cis[i + 3] << 16) | (cis[i + 2] << 8) | cis[i + 1]);
15059 + vp++;
15060 + break;
15061 + }
15062 + break;
15063 +
15064 + }
15065 + i += tlen;
15066 + } while (tup != 0xff);
15067 +
15068 + /* Set the srom version */
15069 + vp += sprintf(vp, "sromrev=%d", sromrev);
15070 + vp++;
15071 +
15072 + /* if there is no antenna gain field, set default */
15073 + if (ag_init == FALSE) {
15074 + ASSERT(sromrev == 1);
15075 + vp += sprintf(vp, "ag0=%d", 0xff);
15076 + vp++;
15077 + }
15078 +
15079 + /* final nullbyte terminator */
15080 + *vp++ = '\0';
15081 + varsize = (uint)(vp - base);
15082 +
15083 + ASSERT((vp - base) < VARS_MAX);
15084 +
15085 + if (varsize == VARS_MAX) {
15086 + *vars = base;
15087 + } else {
15088 + vp = MALLOC(osh, varsize);
15089 + ASSERT(vp);
15090 + if (vp)
15091 + bcopy(base, vp, varsize);
15092 + MFREE(osh, base, VARS_MAX);
15093 + *vars = vp;
15094 + if (!vp) {
15095 + *count = 0;
15096 + return -2;
15097 + }
15098 + }
15099 + *count = varsize;
15100 +
15101 + return (0);
15102 +}
15103 +
15104 +
15105 +/* set PCMCIA sprom command register */
15106 +static int
15107 +sprom_cmd_pcmcia(osl_t *osh, uint8 cmd)
15108 +{
15109 + uint8 status = 0;
15110 + uint wait_cnt = 1000;
15111 +
15112 + /* write sprom command register */
15113 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_CS, &cmd, 1);
15114 +
15115 + /* wait status */
15116 + while (wait_cnt--) {
15117 + OSL_PCMCIA_READ_ATTR(osh, SROM_CS, &status, 1);
15118 + if (status & SROM_DONE)
15119 + return 0;
15120 + }
15121 +
15122 + return 1;
15123 +}
15124 +
15125 +/* read a word from the PCMCIA srom */
15126 +static int
15127 +sprom_read_pcmcia(osl_t *osh, uint16 addr, uint16 *data)
15128 +{
15129 + uint8 addr_l, addr_h, data_l, data_h;
15130 +
15131 + addr_l = (uint8)((addr * 2) & 0xff);
15132 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
15133 +
15134 + /* set address */
15135 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
15136 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
15137 +
15138 + /* do read */
15139 + if (sprom_cmd_pcmcia(osh, SROM_READ))
15140 + return 1;
15141 +
15142 + /* read data */
15143 + data_h = data_l = 0;
15144 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAH, &data_h, 1);
15145 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAL, &data_l, 1);
15146 +
15147 + *data = (data_h << 8) | data_l;
15148 + return 0;
15149 +}
15150 +
15151 +/* write a word to the PCMCIA srom */
15152 +static int
15153 +sprom_write_pcmcia(osl_t *osh, uint16 addr, uint16 data)
15154 +{
15155 + uint8 addr_l, addr_h, data_l, data_h;
15156 +
15157 + addr_l = (uint8)((addr * 2) & 0xff);
15158 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff);
15159 + data_l = (uint8)(data & 0xff);
15160 + data_h = (uint8)((data >> 8) & 0xff);
15161 +
15162 + /* set address */
15163 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1);
15164 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1);
15165 +
15166 + /* write data */
15167 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAH, &data_h, 1);
15168 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAL, &data_l, 1);
15169 +
15170 + /* do write */
15171 + return sprom_cmd_pcmcia(osh, SROM_WRITE);
15172 +}
15173 +
15174 +/*
15175 + * Read in and validate sprom.
15176 + * Return 0 on success, nonzero on error.
15177 + */
15178 +static int
15179 +sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc)
15180 +{
15181 + int err = 0;
15182 + uint i;
15183 +
15184 + /* read the sprom */
15185 + for (i = 0; i < nwords; i++)
15186 + buf[i] = R_REG(&sprom[wordoff + i]);
15187 +
15188 + if (check_crc) {
15189 + /* fixup the endianness so crc8 will pass */
15190 + htol16_buf(buf, nwords * 2);
15191 + if (hndcrc8((uint8*)buf, nwords * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE)
15192 + err = 1;
15193 + /* now correct the endianness of the byte array */
15194 + ltoh16_buf(buf, nwords * 2);
15195 + }
15196 +
15197 + return err;
15198 +}
15199 +
15200 +/*
15201 +* Create variable table from memory.
15202 +* Return 0 on success, nonzero on error.
15203 +*/
15204 +static int
15205 +initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count)
15206 +{
15207 + int c = (int)(end - start);
15208 +
15209 + /* do it only when there is more than just the null string */
15210 + if (c > 1) {
15211 + char *vp = MALLOC(osh, c);
15212 + ASSERT(vp);
15213 + if (!vp)
15214 + return BCME_NOMEM;
15215 + bcopy(start, vp, c);
15216 + *vars = vp;
15217 + *count = c;
15218 + }
15219 + else {
15220 + *vars = NULL;
15221 + *count = 0;
15222 + }
15223 +
15224 + return 0;
15225 +}
15226 +
15227 +/*
15228 +* Find variables with <devpath> from flash. 'base' points to the beginning
15229 +* of the table upon enter and to the end of the table upon exit when success.
15230 +* Return 0 on success, nonzero on error.
15231 +*/
15232 +static int
15233 +initvars_flash(osl_t *osh, char **base, int size, char *devpath)
15234 +{
15235 + char *vp = *base;
15236 + char *flash;
15237 + int err;
15238 + char *s;
15239 + uint l, dl, copy_len;
15240 +
15241 + /* allocate memory and read in flash */
15242 + if (!(flash = MALLOC(osh, NVRAM_SPACE)))
15243 + return BCME_NOMEM;
15244 + if ((err = BCMINIT(nvram_getall)(flash, NVRAM_SPACE)))
15245 + goto exit;
15246 +
15247 + /* grab vars with the <devpath> prefix in name */
15248 + dl = strlen(devpath);
15249 + for (s = flash; s && *s; s += l + 1) {
15250 + l = strlen(s);
15251 +
15252 + /* skip non-matching variable */
15253 + if (strncmp(s, devpath, dl))
15254 + continue;
15255 +
15256 + /* is there enough room to copy? */
15257 + copy_len = l - dl + 1;
15258 + if (size < (int)copy_len) {
15259 + err = BCME_BUFTOOSHORT;
15260 + goto exit;
15261 + }
15262 +
15263 + /* no prefix, just the name=value */
15264 + strcpy(vp, &s[dl]);
15265 + vp += copy_len;
15266 + size -= copy_len;
15267 + }
15268 +
15269 + /* add null string as terminator */
15270 + if (size < 1) {
15271 + err = BCME_BUFTOOSHORT;
15272 + goto exit;
15273 + }
15274 + *vp++ = '\0';
15275 +
15276 + *base = vp;
15277 +
15278 +exit: MFREE(osh, flash, NVRAM_SPACE);
15279 + return err;
15280 +}
15281 +
15282 +/*
15283 + * Initialize nonvolatile variable table from flash.
15284 + * Return 0 on success, nonzero on error.
15285 + */
15286 +static int
15287 +initvars_flash_sb(void *sbh, char **vars, int *count)
15288 +{
15289 + osl_t *osh = sb_osh(sbh);
15290 + char devpath[SB_DEVPATH_BUFSZ];
15291 + char *vp, *base;
15292 + int err;
15293 +
15294 + ASSERT(vars);
15295 + ASSERT(count);
15296 +
15297 + if ((err = sb_devpath(sbh, devpath, sizeof(devpath))))
15298 + return err;
15299 +
15300 + base = vp = MALLOC(osh, VARS_MAX);
15301 + ASSERT(vp);
15302 + if (!vp)
15303 + return BCME_NOMEM;
15304 +
15305 + if ((err = initvars_flash(osh, &vp, VARS_MAX, devpath)))
15306 + goto err;
15307 +
15308 + err = initvars_table(osh, base, vp, vars, count);
15309 +
15310 +err: MFREE(osh, base, VARS_MAX);
15311 + return err;
15312 +}
15313 +
15314 +/*
15315 + * Initialize nonvolatile variable table from sprom.
15316 + * Return 0 on success, nonzero on error.
15317 + */
15318 +static int
15319 +initvars_srom_pci(void *sbh, void *curmap, char **vars, int *count)
15320 +{
15321 + uint16 w, b[64];
15322 + uint8 sromrev;
15323 + struct ether_addr ea;
15324 + char eabuf[32];
15325 + uint32 w32;
15326 + int woff, i;
15327 + char *vp, *base;
15328 + osl_t *osh = sb_osh(sbh);
15329 + bool flash = FALSE;
15330 + char name[SB_DEVPATH_BUFSZ+16], *value;
15331 + char devpath[SB_DEVPATH_BUFSZ];
15332 + int err;
15333 +
15334 + /*
15335 + * Apply CRC over SROM content regardless SROM is present or not,
15336 + * and use variable <devpath>sromrev's existance in flash to decide
15337 + * if we should return an error when CRC fails or read SROM variables
15338 + * from flash.
15339 + */
15340 + if (sprom_read_pci((void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, sizeof(b)/sizeof(b[0]), TRUE)) {
15341 + if ((err = sb_devpath(sbh, devpath, sizeof(devpath))))
15342 + return err;
15343 + sprintf(name, "%ssromrev", devpath);
15344 + if (!(value = getvar(NULL, name)))
15345 + return (-1);
15346 + sromrev = (uint8)bcm_strtoul(value, NULL, 0);
15347 + flash = TRUE;
15348 + }
15349 + /* srom is good */
15350 + else {
15351 + /* top word of sprom contains version and crc8 */
15352 + sromrev = b[63] & 0xff;
15353 + /* bcm4401 sroms misprogrammed */
15354 + if (sromrev == 0x10)
15355 + sromrev = 1;
15356 + }
15357 +
15358 + /* srom version check */
15359 + if (sromrev > 3)
15360 + return (-2);
15361 +
15362 + ASSERT(vars);
15363 + ASSERT(count);
15364 +
15365 + base = vp = MALLOC(osh, VARS_MAX);
15366 + ASSERT(vp);
15367 + if (!vp)
15368 + return -2;
15369 +
15370 + /* read variables from flash */
15371 + if (flash) {
15372 + if ((err = initvars_flash(osh, &vp, VARS_MAX, devpath)))
15373 + goto err;
15374 + goto done;
15375 + }
15376 +
15377 + vp += sprintf(vp, "sromrev=%d", sromrev);
15378 + vp++;
15379 +
15380 + if (sromrev >= 3) {
15381 + /* New section takes over the 3th hardware function space */
15382 +
15383 + /* Words 22+23 are 11a (mid) ofdm power offsets */
15384 + w32 = ((uint32)b[23] << 16) | b[22];
15385 + vp += sprintf(vp, "ofdmapo=%d", w32);
15386 + vp++;
15387 +
15388 + /* Words 24+25 are 11a (low) ofdm power offsets */
15389 + w32 = ((uint32)b[25] << 16) | b[24];
15390 + vp += sprintf(vp, "ofdmalpo=%d", w32);
15391 + vp++;
15392 +
15393 + /* Words 26+27 are 11a (high) ofdm power offsets */
15394 + w32 = ((uint32)b[27] << 16) | b[26];
15395 + vp += sprintf(vp, "ofdmahpo=%d", w32);
15396 + vp++;
15397 +
15398 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
15399 + w32 = ((uint32)b[43] << 24) | ((uint32)b[42] << 8);
15400 + vp += sprintf(vp, "gpiotimerval=%d", w32);
15401 +
15402 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
15403 + w32 = ((uint32)((unsigned char)(b[21] >> 8) & 0xFF) << 24) | /* oncount*/
15404 + ((uint32)((unsigned char)(b[21] & 0xFF)) << 8); /* offcount */
15405 + vp += sprintf(vp, "gpiotimerval=%d", w32);
15406 +
15407 + vp++;
15408 + }
15409 +
15410 + if (sromrev >= 2) {
15411 + /* New section takes over the 4th hardware function space */
15412 +
15413 + /* Word 29 is max power 11a high/low */
15414 + w = b[29];
15415 + vp += sprintf(vp, "pa1himaxpwr=%d", w & 0xff);
15416 + vp++;
15417 + vp += sprintf(vp, "pa1lomaxpwr=%d", (w >> 8) & 0xff);
15418 + vp++;
15419 +
15420 + /* Words 30-32 set the 11alow pa settings,
15421 + * 33-35 are the 11ahigh ones.
15422 + */
15423 + for (i = 0; i < 3; i++) {
15424 + vp += sprintf(vp, "pa1lob%d=%d", i, b[30 + i]);
15425 + vp++;
15426 + vp += sprintf(vp, "pa1hib%d=%d", i, b[33 + i]);
15427 + vp++;
15428 + }
15429 + w = b[59];
15430 + if (w == 0)
15431 + vp += sprintf(vp, "ccode=");
15432 + else
15433 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff));
15434 + vp++;
15435 +
15436 + }
15437 +
15438 + /* parameter section of sprom starts at byte offset 72 */
15439 + woff = 72/2;
15440 +
15441 + /* first 6 bytes are il0macaddr */
15442 + ea.octet[0] = (b[woff] >> 8) & 0xff;
15443 + ea.octet[1] = b[woff] & 0xff;
15444 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
15445 + ea.octet[3] = b[woff+1] & 0xff;
15446 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
15447 + ea.octet[5] = b[woff+2] & 0xff;
15448 + woff += ETHER_ADDR_LEN/2 ;
15449 + bcm_ether_ntoa((uchar*)&ea, eabuf);
15450 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
15451 + vp++;
15452 +
15453 + /* next 6 bytes are et0macaddr */
15454 + ea.octet[0] = (b[woff] >> 8) & 0xff;
15455 + ea.octet[1] = b[woff] & 0xff;
15456 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
15457 + ea.octet[3] = b[woff+1] & 0xff;
15458 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
15459 + ea.octet[5] = b[woff+2] & 0xff;
15460 + woff += ETHER_ADDR_LEN/2 ;
15461 + bcm_ether_ntoa((uchar*)&ea, eabuf);
15462 + vp += sprintf(vp, "et0macaddr=%s", eabuf);
15463 + vp++;
15464 +
15465 + /* next 6 bytes are et1macaddr */
15466 + ea.octet[0] = (b[woff] >> 8) & 0xff;
15467 + ea.octet[1] = b[woff] & 0xff;
15468 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
15469 + ea.octet[3] = b[woff+1] & 0xff;
15470 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
15471 + ea.octet[5] = b[woff+2] & 0xff;
15472 + woff += ETHER_ADDR_LEN/2 ;
15473 + bcm_ether_ntoa((uchar*)&ea, eabuf);
15474 + vp += sprintf(vp, "et1macaddr=%s", eabuf);
15475 + vp++;
15476 +
15477 + /*
15478 + * Enet phy settings one or two singles or a dual
15479 + * Bits 4-0 : MII address for enet0 (0x1f for not there)
15480 + * Bits 9-5 : MII address for enet1 (0x1f for not there)
15481 + * Bit 14 : Mdio for enet0
15482 + * Bit 15 : Mdio for enet1
15483 + */
15484 + w = b[woff];
15485 + vp += sprintf(vp, "et0phyaddr=%d", (w & 0x1f));
15486 + vp++;
15487 + vp += sprintf(vp, "et1phyaddr=%d", ((w >> 5) & 0x1f));
15488 + vp++;
15489 + vp += sprintf(vp, "et0mdcport=%d", ((w >> 14) & 0x1));
15490 + vp++;
15491 + vp += sprintf(vp, "et1mdcport=%d", ((w >> 15) & 0x1));
15492 + vp++;
15493 +
15494 + /* Word 46 has board rev, antennas 0/1 & Country code/control */
15495 + w = b[46];
15496 + vp += sprintf(vp, "boardrev=%d", w & 0xff);
15497 + vp++;
15498 +
15499 + if (sromrev > 1)
15500 + vp += sprintf(vp, "cctl=%d", (w >> 8) & 0xf);
15501 + else
15502 + vp += sprintf(vp, "cc=%d", (w >> 8) & 0xf);
15503 + vp++;
15504 +
15505 + vp += sprintf(vp, "aa0=%d", (w >> 12) & 0x3);
15506 + vp++;
15507 +
15508 + vp += sprintf(vp, "aa1=%d", (w >> 14) & 0x3);
15509 + vp++;
15510 +
15511 + /* Words 47-49 set the (wl) pa settings */
15512 + woff = 47;
15513 +
15514 + for (i = 0; i < 3; i++) {
15515 + vp += sprintf(vp, "pa0b%d=%d", i, b[woff+i]);
15516 + vp++;
15517 + vp += sprintf(vp, "pa1b%d=%d", i, b[woff+i+6]);
15518 + vp++;
15519 + }
15520 +
15521 + /*
15522 + * Words 50-51 set the customer-configured wl led behavior.
15523 + * 8 bits/gpio pin. High bit: activehi=0, activelo=1;
15524 + * LED behavior values defined in wlioctl.h .
15525 + */
15526 + w = b[50];
15527 + if ((w != 0) && (w != 0xffff)) {
15528 + /* gpio0 */
15529 + vp += sprintf(vp, "wl0gpio0=%d", (w & 0xff));
15530 + vp++;
15531 +
15532 + /* gpio1 */
15533 + vp += sprintf(vp, "wl0gpio1=%d", (w >> 8) & 0xff);
15534 + vp++;
15535 + }
15536 + w = b[51];
15537 + if ((w != 0) && (w != 0xffff)) {
15538 + /* gpio2 */
15539 + vp += sprintf(vp, "wl0gpio2=%d", w & 0xff);
15540 + vp++;
15541 +
15542 + /* gpio3 */
15543 + vp += sprintf(vp, "wl0gpio3=%d", (w >> 8) & 0xff);
15544 + vp++;
15545 + }
15546 +
15547 + /* Word 52 is max power 0/1 */
15548 + w = b[52];
15549 + vp += sprintf(vp, "pa0maxpwr=%d", w & 0xff);
15550 + vp++;
15551 + vp += sprintf(vp, "pa1maxpwr=%d", (w >> 8) & 0xff);
15552 + vp++;
15553 +
15554 + /* Word 56 is idle tssi target 0/1 */
15555 + w = b[56];
15556 + vp += sprintf(vp, "pa0itssit=%d", w & 0xff);
15557 + vp++;
15558 + vp += sprintf(vp, "pa1itssit=%d", (w >> 8) & 0xff);
15559 + vp++;
15560 +
15561 + /* Word 57 is boardflags, if not programmed make it zero */
15562 + w32 = (uint32)b[57];
15563 + if (w32 == 0xffff) w32 = 0;
15564 + if (sromrev > 1) {
15565 + /* Word 28 is the high bits of boardflags */
15566 + w32 |= (uint32)b[28] << 16;
15567 + }
15568 + vp += sprintf(vp, "boardflags=%d", w32);
15569 + vp++;
15570 +
15571 + /* Word 58 is antenna gain 0/1 */
15572 + w = b[58];
15573 + vp += sprintf(vp, "ag0=%d", w & 0xff);
15574 + vp++;
15575 +
15576 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff);
15577 + vp++;
15578 +
15579 + if (sromrev == 1) {
15580 + /* set the oem string */
15581 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
15582 + ((b[59] >> 8) & 0xff), (b[59] & 0xff),
15583 + ((b[60] >> 8) & 0xff), (b[60] & 0xff),
15584 + ((b[61] >> 8) & 0xff), (b[61] & 0xff),
15585 + ((b[62] >> 8) & 0xff), (b[62] & 0xff));
15586 + vp++;
15587 + } else if (sromrev == 2) {
15588 + /* Word 60 OFDM tx power offset from CCK level */
15589 + /* OFDM Power Offset - opo */
15590 + vp += sprintf(vp, "opo=%d", b[60] & 0xff);
15591 + vp++;
15592 + } else {
15593 + /* Word 60: cck power offsets */
15594 + vp += sprintf(vp, "cckpo=%d", b[60]);
15595 + vp++;
15596 +
15597 + /* Words 61+62: 11g ofdm power offsets */
15598 + w32 = ((uint32)b[62] << 16) | b[61];
15599 + vp += sprintf(vp, "ofdmgpo=%d", w32);
15600 + vp++;
15601 + }
15602 +
15603 + /* final nullbyte terminator */
15604 + *vp++ = '\0';
15605 +
15606 + ASSERT((vp - base) <= VARS_MAX);
15607 +
15608 +done: err = initvars_table(osh, base, vp, vars, count);
15609 +
15610 +err: MFREE(osh, base, VARS_MAX);
15611 + return err;
15612 +}
15613 +
15614 +/*
15615 + * Read the cis and call parsecis to initialize the vars.
15616 + * Return 0 on success, nonzero on error.
15617 + */
15618 +static int
15619 +initvars_cis_pcmcia(void *sbh, osl_t *osh, char **vars, int *count)
15620 +{
15621 + uint8 *cis = NULL;
15622 + int rc;
15623 + uint data_sz;
15624 +
15625 + data_sz = (sb_pcmciarev(sbh) == 1) ? (SPROM_SIZE * 2) : CIS_SIZE;
15626 +
15627 + if ((cis = MALLOC(osh, data_sz)) == NULL)
15628 + return (-2);
15629 +
15630 + if (sb_pcmciarev(sbh) == 1) {
15631 + if (srom_read(PCMCIA_BUS, (void *)NULL, osh, 0, data_sz, (uint16 *)cis)) {
15632 + MFREE(osh, cis, data_sz);
15633 + return (-1);
15634 + }
15635 + /* fix up endianess for 16-bit data vs 8-bit parsing */
15636 + ltoh16_buf((uint16 *)cis, data_sz);
15637 + } else
15638 + OSL_PCMCIA_READ_ATTR(osh, 0, cis, data_sz);
15639 +
15640 + rc = srom_parsecis(osh, cis, vars, count);
15641 +
15642 + MFREE(osh, cis, data_sz);
15643 +
15644 + return (rc);
15645 +}
15646 +
15647 diff -Nur linux-2.4.32/drivers/net/hnd/bcmutils.c linux-2.4.32-brcm/drivers/net/hnd/bcmutils.c
15648 --- linux-2.4.32/drivers/net/hnd/bcmutils.c 1970-01-01 01:00:00.000000000 +0100
15649 +++ linux-2.4.32-brcm/drivers/net/hnd/bcmutils.c 2005-12-16 23:39:11.288858250 +0100
15650 @@ -0,0 +1,1081 @@
15651 +/*
15652 + * Misc useful OS-independent routines.
15653 + *
15654 + * Copyright 2005, Broadcom Corporation
15655 + * All Rights Reserved.
15656 + *
15657 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
15658 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
15659 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
15660 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
15661 + * $Id$
15662 + */
15663 +
15664 +#include <typedefs.h>
15665 +#ifdef BCMDRIVER
15666 +#include <osl.h>
15667 +#include <sbutils.h>
15668 +#include <bcmnvram.h>
15669 +#else
15670 +#include <stdio.h>
15671 +#include <string.h>
15672 +#endif
15673 +#include <bcmutils.h>
15674 +#include <bcmendian.h>
15675 +#include <bcmdevs.h>
15676 +
15677 +#ifdef BCMDRIVER
15678 +/* copy a pkt buffer chain into a buffer */
15679 +uint
15680 +pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf)
15681 +{
15682 + uint n, ret = 0;
15683 +
15684 + if (len < 0)
15685 + len = 4096; /* "infinite" */
15686 +
15687 + /* skip 'offset' bytes */
15688 + for (; p && offset; p = PKTNEXT(osh, p)) {
15689 + if (offset < (uint)PKTLEN(osh, p))
15690 + break;
15691 + offset -= PKTLEN(osh, p);
15692 + }
15693 +
15694 + if (!p)
15695 + return 0;
15696 +
15697 + /* copy the data */
15698 + for (; p && len; p = PKTNEXT(osh, p)) {
15699 + n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len);
15700 + bcopy(PKTDATA(osh, p) + offset, buf, n);
15701 + buf += n;
15702 + len -= n;
15703 + ret += n;
15704 + offset = 0;
15705 + }
15706 +
15707 + return ret;
15708 +}
15709 +
15710 +/* return total length of buffer chain */
15711 +uint
15712 +pkttotlen(osl_t *osh, void *p)
15713 +{
15714 + uint total;
15715 +
15716 + total = 0;
15717 + for (; p; p = PKTNEXT(osh, p))
15718 + total += PKTLEN(osh, p);
15719 + return (total);
15720 +}
15721 +
15722 +void
15723 +pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[])
15724 +{
15725 + q->head = q->tail = NULL;
15726 + q->maxlen = maxlen;
15727 + q->len = 0;
15728 + if (prio_map) {
15729 + q->priority = TRUE;
15730 + bcopy(prio_map, q->prio_map, sizeof(q->prio_map));
15731 + }
15732 + else
15733 + q->priority = FALSE;
15734 +}
15735 +
15736 +/* should always check pktq_full before calling pktenq */
15737 +void
15738 +pktenq(struct pktq *q, void *p, bool lifo)
15739 +{
15740 + void *next, *prev;
15741 +
15742 + /* allow 10 pkts slack */
15743 + ASSERT(q->len < (q->maxlen + 10));
15744 +
15745 + /* Queueing chains not allowed */
15746 + ASSERT(PKTLINK(p) == NULL);
15747 +
15748 + /* Queue is empty */
15749 + if (q->tail == NULL) {
15750 + ASSERT(q->head == NULL);
15751 + q->head = q->tail = p;
15752 + }
15753 +
15754 + /* Insert at head or tail */
15755 + else if (q->priority == FALSE) {
15756 + /* Insert at head (LIFO) */
15757 + if (lifo) {
15758 + PKTSETLINK(p, q->head);
15759 + q->head = p;
15760 + }
15761 + /* Insert at tail (FIFO) */
15762 + else {
15763 + ASSERT(PKTLINK(q->tail) == NULL);
15764 + PKTSETLINK(q->tail, p);
15765 + PKTSETLINK(p, NULL);
15766 + q->tail = p;
15767 + }
15768 + }
15769 +
15770 + /* Insert by priority */
15771 + else {
15772 + /* legal priorities 0-7 */
15773 + ASSERT(PKTPRIO(p) <= MAXPRIO);
15774 +
15775 + ASSERT(q->head);
15776 + ASSERT(q->tail);
15777 + /* Shortcut to insertion at tail */
15778 + if (_pktq_pri(q, PKTPRIO(p)) < _pktq_pri(q, PKTPRIO(q->tail)) ||
15779 + (!lifo && _pktq_pri(q, PKTPRIO(p)) <= _pktq_pri(q, PKTPRIO(q->tail)))) {
15780 + prev = q->tail;
15781 + next = NULL;
15782 + }
15783 + /* Insert at head or in the middle */
15784 + else {
15785 + prev = NULL;
15786 + next = q->head;
15787 + }
15788 + /* Walk the queue */
15789 + for (; next; prev = next, next = PKTLINK(next)) {
15790 + /* Priority queue invariant */
15791 + ASSERT(!prev || _pktq_pri(q, PKTPRIO(prev)) >= _pktq_pri(q, PKTPRIO(next)));
15792 + /* Insert at head of string of packets of same priority (LIFO) */
15793 + if (lifo) {
15794 + if (_pktq_pri(q, PKTPRIO(p)) >= _pktq_pri(q, PKTPRIO(next)))
15795 + break;
15796 + }
15797 + /* Insert at tail of string of packets of same priority (FIFO) */
15798 + else {
15799 + if (_pktq_pri(q, PKTPRIO(p)) > _pktq_pri(q, PKTPRIO(next)))
15800 + break;
15801 + }
15802 + }
15803 + /* Insert at tail */
15804 + if (next == NULL) {
15805 + ASSERT(PKTLINK(q->tail) == NULL);
15806 + PKTSETLINK(q->tail, p);
15807 + PKTSETLINK(p, NULL);
15808 + q->tail = p;
15809 + }
15810 + /* Insert in the middle */
15811 + else if (prev) {
15812 + PKTSETLINK(prev, p);
15813 + PKTSETLINK(p, next);
15814 + }
15815 + /* Insert at head */
15816 + else {
15817 + PKTSETLINK(p, q->head);
15818 + q->head = p;
15819 + }
15820 + }
15821 +
15822 + /* List invariants after insertion */
15823 + ASSERT(q->head);
15824 + ASSERT(PKTLINK(q->tail) == NULL);
15825 +
15826 + q->len++;
15827 +}
15828 +
15829 +/* dequeue packet at head */
15830 +void*
15831 +pktdeq(struct pktq *q)
15832 +{
15833 + void *p;
15834 +
15835 + if ((p = q->head)) {
15836 + ASSERT(q->tail);
15837 + q->head = PKTLINK(p);
15838 + PKTSETLINK(p, NULL);
15839 + q->len--;
15840 + if (q->head == NULL)
15841 + q->tail = NULL;
15842 + }
15843 + else {
15844 + ASSERT(q->tail == NULL);
15845 + }
15846 +
15847 + return (p);
15848 +}
15849 +
15850 +/* dequeue packet at tail */
15851 +void*
15852 +pktdeqtail(struct pktq *q)
15853 +{
15854 + void *p;
15855 + void *next, *prev;
15856 +
15857 + if (q->head == q->tail) { /* last packet on queue or queue empty */
15858 + p = q->head;
15859 + q->head = q->tail = NULL;
15860 + q->len = 0;
15861 + return(p);
15862 + }
15863 +
15864 + /* start walk at head */
15865 + prev = NULL;
15866 + next = q->head;
15867 +
15868 + /* Walk the queue to find prev of q->tail */
15869 + for (; next; prev = next, next = PKTLINK(next)) {
15870 + if (next == q->tail)
15871 + break;
15872 + }
15873 +
15874 + ASSERT(prev);
15875 +
15876 + PKTSETLINK(prev, NULL);
15877 + q->tail = prev;
15878 + q->len--;
15879 + p = next;
15880 +
15881 + return (p);
15882 +}
15883 +
15884 +unsigned char bcm_ctype[] = {
15885 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */
15886 + _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 */
15887 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */
15888 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */
15889 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */
15890 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */
15891 + _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */
15892 + _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */
15893 + _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 */
15894 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */
15895 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */
15896 + _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */
15897 + _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 */
15898 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */
15899 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */
15900 + _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */
15901 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
15902 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
15903 + _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 */
15904 + _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 */
15905 + _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 */
15906 + _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 */
15907 + _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 */
15908 + _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 */
15909 +};
15910 +
15911 +uchar
15912 +bcm_toupper(uchar c)
15913 +{
15914 + if (bcm_islower(c))
15915 + c -= 'a'-'A';
15916 + return (c);
15917 +}
15918 +
15919 +ulong
15920 +bcm_strtoul(char *cp, char **endp, uint base)
15921 +{
15922 + ulong result, value;
15923 + bool minus;
15924 +
15925 + minus = FALSE;
15926 +
15927 + while (bcm_isspace(*cp))
15928 + cp++;
15929 +
15930 + if (cp[0] == '+')
15931 + cp++;
15932 + else if (cp[0] == '-') {
15933 + minus = TRUE;
15934 + cp++;
15935 + }
15936 +
15937 + if (base == 0) {
15938 + if (cp[0] == '0') {
15939 + if ((cp[1] == 'x') || (cp[1] == 'X')) {
15940 + base = 16;
15941 + cp = &cp[2];
15942 + } else {
15943 + base = 8;
15944 + cp = &cp[1];
15945 + }
15946 + } else
15947 + base = 10;
15948 + } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) {
15949 + cp = &cp[2];
15950 + }
15951 +
15952 + result = 0;
15953 +
15954 + while (bcm_isxdigit(*cp) &&
15955 + (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) {
15956 + result = result*base + value;
15957 + cp++;
15958 + }
15959 +
15960 + if (minus)
15961 + result = (ulong)(result * -1);
15962 +
15963 + if (endp)
15964 + *endp = (char *)cp;
15965 +
15966 + return (result);
15967 +}
15968 +
15969 +uint
15970 +bcm_atoi(char *s)
15971 +{
15972 + uint n;
15973 +
15974 + n = 0;
15975 +
15976 + while (bcm_isdigit(*s))
15977 + n = (n * 10) + *s++ - '0';
15978 + return (n);
15979 +}
15980 +
15981 +/* return pointer to location of substring 'needle' in 'haystack' */
15982 +char*
15983 +bcmstrstr(char *haystack, char *needle)
15984 +{
15985 + int len, nlen;
15986 + int i;
15987 +
15988 + if ((haystack == NULL) || (needle == NULL))
15989 + return (haystack);
15990 +
15991 + nlen = strlen(needle);
15992 + len = strlen(haystack) - nlen + 1;
15993 +
15994 + for (i = 0; i < len; i++)
15995 + if (bcmp(needle, &haystack[i], nlen) == 0)
15996 + return (&haystack[i]);
15997 + return (NULL);
15998 +}
15999 +
16000 +char*
16001 +bcmstrcat(char *dest, const char *src)
16002 +{
16003 + strcpy(&dest[strlen(dest)], src);
16004 + return (dest);
16005 +}
16006 +
16007 +#if defined(CONFIG_USBRNDIS_RETAIL) || defined(NDIS_MINIPORT_DRIVER)
16008 +/* registry routine buffer preparation utility functions:
16009 + * parameter order is like strncpy, but returns count
16010 + * of bytes copied. Minimum bytes copied is null char(1)/wchar(2)
16011 + */
16012 +ulong
16013 +wchar2ascii(
16014 + char *abuf,
16015 + ushort *wbuf,
16016 + ushort wbuflen,
16017 + ulong abuflen
16018 +)
16019 +{
16020 + ulong copyct = 1;
16021 + ushort i;
16022 +
16023 + if (abuflen == 0)
16024 + return 0;
16025 +
16026 + /* wbuflen is in bytes */
16027 + wbuflen /= sizeof(ushort);
16028 +
16029 + for (i = 0; i < wbuflen; ++i) {
16030 + if (--abuflen == 0)
16031 + break;
16032 + *abuf++ = (char) *wbuf++;
16033 + ++copyct;
16034 + }
16035 + *abuf = '\0';
16036 +
16037 + return copyct;
16038 +}
16039 +#endif
16040 +
16041 +char*
16042 +bcm_ether_ntoa(char *ea, char *buf)
16043 +{
16044 + sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x",
16045 + (uchar)ea[0]&0xff, (uchar)ea[1]&0xff, (uchar)ea[2]&0xff,
16046 + (uchar)ea[3]&0xff, (uchar)ea[4]&0xff, (uchar)ea[5]&0xff);
16047 + return (buf);
16048 +}
16049 +
16050 +/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
16051 +int
16052 +bcm_ether_atoe(char *p, char *ea)
16053 +{
16054 + int i = 0;
16055 +
16056 + for (;;) {
16057 + ea[i++] = (char) bcm_strtoul(p, &p, 16);
16058 + if (!*p++ || i == 6)
16059 + break;
16060 + }
16061 +
16062 + return (i == 6);
16063 +}
16064 +
16065 +void
16066 +bcm_mdelay(uint ms)
16067 +{
16068 + uint i;
16069 +
16070 + for (i = 0; i < ms; i++) {
16071 + OSL_DELAY(1000);
16072 + }
16073 +}
16074 +
16075 +/*
16076 + * Search the name=value vars for a specific one and return its value.
16077 + * Returns NULL if not found.
16078 + */
16079 +char*
16080 +getvar(char *vars, char *name)
16081 +{
16082 + char *s;
16083 + int len;
16084 +
16085 + len = strlen(name);
16086 +
16087 + /* first look in vars[] */
16088 + for (s = vars; s && *s; ) {
16089 + if ((bcmp(s, name, len) == 0) && (s[len] == '='))
16090 + return (&s[len+1]);
16091 +
16092 + while (*s++)
16093 + ;
16094 + }
16095 +
16096 + /* then query nvram */
16097 + return (BCMINIT(nvram_get)(name));
16098 +}
16099 +
16100 +/*
16101 + * Search the vars for a specific one and return its value as
16102 + * an integer. Returns 0 if not found.
16103 + */
16104 +int
16105 +getintvar(char *vars, char *name)
16106 +{
16107 + char *val;
16108 +
16109 + if ((val = getvar(vars, name)) == NULL)
16110 + return (0);
16111 +
16112 + return (bcm_strtoul(val, NULL, 0));
16113 +}
16114 +
16115 +
16116 +/* Search for token in comma separated token-string */
16117 +static int
16118 +findmatch(char *string, char *name)
16119 +{
16120 + uint len;
16121 + char *c;
16122 +
16123 + len = strlen(name);
16124 + while ((c = strchr(string, ',')) != NULL) {
16125 + if (len == (uint)(c - string) && !strncmp(string, name, len))
16126 + return 1;
16127 + string = c + 1;
16128 + }
16129 +
16130 + return (!strcmp(string, name));
16131 +}
16132 +
16133 +/* Return gpio pin number assigned to the named pin */
16134 +/*
16135 +* Variable should be in format:
16136 +*
16137 +* gpio<N>=pin_name,pin_name
16138 +*
16139 +* This format allows multiple features to share the gpio with mutual
16140 +* understanding.
16141 +*
16142 +* 'def_pin' is returned if a specific gpio is not defined for the requested functionality
16143 +* and if def_pin is not used by others.
16144 +*/
16145 +uint
16146 +getgpiopin(char *vars, char *pin_name, uint def_pin)
16147 +{
16148 + char name[] = "gpioXXXX";
16149 + char *val;
16150 + uint pin;
16151 +
16152 + /* Go thru all possibilities till a match in pin name */
16153 + for (pin = 0; pin < GPIO_NUMPINS; pin ++) {
16154 + sprintf(name, "gpio%d", pin);
16155 + val = getvar(vars, name);
16156 + if (val && findmatch(val, pin_name))
16157 + return pin;
16158 + }
16159 +
16160 + if (def_pin != GPIO_PIN_NOTDEFINED) {
16161 + /* make sure the default pin is not used by someone else */
16162 + sprintf(name, "gpio%d", def_pin);
16163 + if (getvar(vars, name)) {
16164 + def_pin = GPIO_PIN_NOTDEFINED;
16165 + }
16166 + }
16167 +
16168 + return def_pin;
16169 +}
16170 +
16171 +
16172 +static char bcm_undeferrstr[BCME_STRLEN];
16173 +
16174 +static const char *bcmerrorstrtable[] = \
16175 +{ "OK", /* 0 */
16176 + "Undefined error", /* BCME_ERROR */
16177 + "Bad Argument", /* BCME_BADARG*/
16178 + "Bad Option", /* BCME_BADOPTION*/
16179 + "Not up", /* BCME_NOTUP */
16180 + "Not down", /* BCME_NOTDOWN */
16181 + "Not AP", /* BCME_NOTAP */
16182 + "Not STA", /* BCME_NOTSTA */
16183 + "Bad Key Index", /* BCME_BADKEYIDX */
16184 + "Radio Off", /* BCME_RADIOOFF */
16185 + "Not band locked", /* BCME_NOTBANDLOCKED */
16186 + "No clock", /* BCME_NOCLK */
16187 + "Bad Rate valueset", /* BCME_BADRATESET */
16188 + "Bad Band", /* BCME_BADBAND */
16189 + "Buffer too short", /* BCME_BUFTOOSHORT */
16190 + "Buffer too length", /* BCME_BUFTOOLONG */
16191 + "Busy", /* BCME_BUSY */
16192 + "Not Associated", /* BCME_NOTASSOCIATED */
16193 + "Bad SSID len", /* BCME_BADSSIDLEN */
16194 + "Out of Range Channel", /* BCME_OUTOFRANGECHAN */
16195 + "Bad Channel", /* BCME_BADCHAN */
16196 + "Bad Address", /* BCME_BADADDR */
16197 + "Not Enough Resources", /* BCME_NORESOURCE */
16198 + "Unsupported", /* BCME_UNSUPPORTED */
16199 + "Bad length", /* BCME_BADLENGTH */
16200 + "Not Ready", /* BCME_NOTREADY */
16201 + "Not Permitted", /* BCME_EPERM */
16202 + "No Memory", /* BCME_NOMEM */
16203 + "Associated", /* BCME_ASSOCIATED */
16204 + "Not In Range", /* BCME_RANGE */
16205 + "Not Found" /* BCME_NOTFOUND */
16206 + };
16207 +
16208 +/* Convert the Error codes into related Error strings */
16209 +const char *
16210 +bcmerrorstr(int bcmerror)
16211 +{
16212 + int abs_bcmerror;
16213 +
16214 + abs_bcmerror = ABS(bcmerror);
16215 +
16216 + /* check if someone added a bcmerror code but forgot to add errorstring */
16217 + ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(bcmerrorstrtable) - 1));
16218 + if ( (bcmerror > 0) || (abs_bcmerror > ABS(BCME_LAST))) {
16219 + sprintf(bcm_undeferrstr, "undefined Error %d", bcmerror);
16220 + return bcm_undeferrstr;
16221 + }
16222 +
16223 + ASSERT((strlen((char*)bcmerrorstrtable[abs_bcmerror])) < BCME_STRLEN);
16224 +
16225 + return bcmerrorstrtable[abs_bcmerror];
16226 +}
16227 +#endif /* #ifdef BCMDRIVER */
16228 +
16229 +
16230 +/*******************************************************************************
16231 + * crc8
16232 + *
16233 + * Computes a crc8 over the input data using the polynomial:
16234 + *
16235 + * x^8 + x^7 +x^6 + x^4 + x^2 + 1
16236 + *
16237 + * The caller provides the initial value (either CRC8_INIT_VALUE
16238 + * or the previous returned value) to allow for processing of
16239 + * discontiguous blocks of data. When generating the CRC the
16240 + * caller is responsible for complementing the final return value
16241 + * and inserting it into the byte stream. When checking, a final
16242 + * return value of CRC8_GOOD_VALUE indicates a valid CRC.
16243 + *
16244 + * Reference: Dallas Semiconductor Application Note 27
16245 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
16246 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
16247 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
16248 + *
16249 + ******************************************************************************/
16250 +
16251 +static uint8 crc8_table[256] = {
16252 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
16253 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
16254 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
16255 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
16256 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
16257 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
16258 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
16259 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
16260 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
16261 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
16262 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
16263 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
16264 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
16265 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
16266 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
16267 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
16268 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
16269 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
16270 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
16271 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
16272 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
16273 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
16274 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
16275 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
16276 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
16277 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
16278 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
16279 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
16280 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
16281 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
16282 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
16283 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
16284 +};
16285 +
16286 +#define CRC_INNER_LOOP(n, c, x) \
16287 + (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff]
16288 +
16289 +uint8
16290 +hndcrc8(
16291 + uint8 *pdata, /* pointer to array of data to process */
16292 + uint nbytes, /* number of input data bytes to process */
16293 + uint8 crc /* either CRC8_INIT_VALUE or previous return value */
16294 +)
16295 +{
16296 + /* hard code the crc loop instead of using CRC_INNER_LOOP macro
16297 + * to avoid the undefined and unnecessary (uint8 >> 8) operation. */
16298 + while (nbytes-- > 0)
16299 + crc = crc8_table[(crc ^ *pdata++) & 0xff];
16300 +
16301 + return crc;
16302 +}
16303 +
16304 +/*******************************************************************************
16305 + * crc16
16306 + *
16307 + * Computes a crc16 over the input data using the polynomial:
16308 + *
16309 + * x^16 + x^12 +x^5 + 1
16310 + *
16311 + * The caller provides the initial value (either CRC16_INIT_VALUE
16312 + * or the previous returned value) to allow for processing of
16313 + * discontiguous blocks of data. When generating the CRC the
16314 + * caller is responsible for complementing the final return value
16315 + * and inserting it into the byte stream. When checking, a final
16316 + * return value of CRC16_GOOD_VALUE indicates a valid CRC.
16317 + *
16318 + * Reference: Dallas Semiconductor Application Note 27
16319 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
16320 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
16321 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
16322 + *
16323 + ******************************************************************************/
16324 +
16325 +static uint16 crc16_table[256] = {
16326 + 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
16327 + 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
16328 + 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
16329 + 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
16330 + 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
16331 + 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
16332 + 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
16333 + 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
16334 + 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
16335 + 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
16336 + 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
16337 + 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
16338 + 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
16339 + 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
16340 + 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
16341 + 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
16342 + 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
16343 + 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
16344 + 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
16345 + 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
16346 + 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
16347 + 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
16348 + 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
16349 + 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
16350 + 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
16351 + 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
16352 + 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
16353 + 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
16354 + 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
16355 + 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
16356 + 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
16357 + 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
16358 +};
16359 +
16360 +uint16
16361 +hndcrc16(
16362 + uint8 *pdata, /* pointer to array of data to process */
16363 + uint nbytes, /* number of input data bytes to process */
16364 + uint16 crc /* either CRC16_INIT_VALUE or previous return value */
16365 +)
16366 +{
16367 + while (nbytes-- > 0)
16368 + CRC_INNER_LOOP(16, crc, *pdata++);
16369 + return crc;
16370 +}
16371 +
16372 +static uint32 crc32_table[256] = {
16373 + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
16374 + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
16375 + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
16376 + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
16377 + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
16378 + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
16379 + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
16380 + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
16381 + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
16382 + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
16383 + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
16384 + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
16385 + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
16386 + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
16387 + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
16388 + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
16389 + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
16390 + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
16391 + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
16392 + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
16393 + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
16394 + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
16395 + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
16396 + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
16397 + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
16398 + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
16399 + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
16400 + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
16401 + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
16402 + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
16403 + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
16404 + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
16405 + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
16406 + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
16407 + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
16408 + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
16409 + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
16410 + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
16411 + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
16412 + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
16413 + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
16414 + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
16415 + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
16416 + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
16417 + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
16418 + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
16419 + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
16420 + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
16421 + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
16422 + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
16423 + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
16424 + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
16425 + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
16426 + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
16427 + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
16428 + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
16429 + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
16430 + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
16431 + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
16432 + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
16433 + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
16434 + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
16435 + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
16436 + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
16437 +};
16438 +
16439 +uint32
16440 +hndcrc32(
16441 + uint8 *pdata, /* pointer to array of data to process */
16442 + uint nbytes, /* number of input data bytes to process */
16443 + uint32 crc /* either CRC32_INIT_VALUE or previous return value */
16444 +)
16445 +{
16446 + uint8 *pend;
16447 +#ifdef __mips__
16448 + uint8 tmp[4];
16449 + ulong *tptr = (ulong *)tmp;
16450 +
16451 + /* in case the beginning of the buffer isn't aligned */
16452 + pend = (uint8 *)((uint)(pdata + 3) & 0xfffffffc);
16453 + nbytes -= (pend - pdata);
16454 + while (pdata < pend)
16455 + CRC_INNER_LOOP(32, crc, *pdata++);
16456 +
16457 + /* handle bulk of data as 32-bit words */
16458 + pend = pdata + (nbytes & 0xfffffffc);
16459 + while (pdata < pend) {
16460 + tptr = *((ulong *) pdata);
16461 + *((ulong *) pdata) += 1;
16462 + CRC_INNER_LOOP(32, crc, tmp[0]);
16463 + CRC_INNER_LOOP(32, crc, tmp[1]);
16464 + CRC_INNER_LOOP(32, crc, tmp[2]);
16465 + CRC_INNER_LOOP(32, crc, tmp[3]);
16466 + }
16467 +
16468 + /* 1-3 bytes at end of buffer */
16469 + pend = pdata + (nbytes & 0x03);
16470 + while (pdata < pend)
16471 + CRC_INNER_LOOP(32, crc, *pdata++);
16472 +#else
16473 + pend = pdata + nbytes;
16474 + while (pdata < pend)
16475 + CRC_INNER_LOOP(32, crc, *pdata++);
16476 +#endif
16477 +
16478 + return crc;
16479 +}
16480 +
16481 +#ifdef notdef
16482 +#define CLEN 1499
16483 +#define CBUFSIZ (CLEN+4)
16484 +#define CNBUFS 5
16485 +
16486 +void testcrc32(void)
16487 +{
16488 + uint j,k,l;
16489 + uint8 *buf;
16490 + uint len[CNBUFS];
16491 + uint32 crcr;
16492 + uint32 crc32tv[CNBUFS] =
16493 + {0xd2cb1faa, 0xd385c8fa, 0xf5b4f3f3, 0x55789e20, 0x00343110};
16494 +
16495 + ASSERT((buf = MALLOC(CBUFSIZ*CNBUFS)) != NULL);
16496 +
16497 + /* step through all possible alignments */
16498 + for (l=0;l<=4;l++) {
16499 + for (j=0; j<CNBUFS; j++) {
16500 + len[j] = CLEN;
16501 + for (k=0; k<len[j]; k++)
16502 + *(buf + j*CBUFSIZ + (k+l)) = (j+k) & 0xff;
16503 + }
16504 +
16505 + for (j=0; j<CNBUFS; j++) {
16506 + crcr = crc32(buf + j*CBUFSIZ + l, len[j], CRC32_INIT_VALUE);
16507 + ASSERT(crcr == crc32tv[j]);
16508 + }
16509 + }
16510 +
16511 + MFREE(buf, CBUFSIZ*CNBUFS);
16512 + return;
16513 +}
16514 +#endif
16515 +
16516 +
16517 +/*
16518 + * Advance from the current 1-byte tag/1-byte length/variable-length value
16519 + * triple, to the next, returning a pointer to the next.
16520 + * If the current or next TLV is invalid (does not fit in given buffer length),
16521 + * NULL is returned.
16522 + * *buflen is not modified if the TLV elt parameter is invalid, or is decremented
16523 + * by the TLV paramter's length if it is valid.
16524 + */
16525 +bcm_tlv_t *
16526 +bcm_next_tlv(bcm_tlv_t *elt, int *buflen)
16527 +{
16528 + int len;
16529 +
16530 + /* validate current elt */
16531 + if (!bcm_valid_tlv(elt, *buflen))
16532 + return NULL;
16533 +
16534 + /* advance to next elt */
16535 + len = elt->len;
16536 + elt = (bcm_tlv_t*)(elt->data + len);
16537 + *buflen -= (2 + len);
16538 +
16539 + /* validate next elt */
16540 + if (!bcm_valid_tlv(elt, *buflen))
16541 + return NULL;
16542 +
16543 + return elt;
16544 +}
16545 +
16546 +/*
16547 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
16548 + * triples, returning a pointer to the substring whose first element
16549 + * matches tag
16550 + */
16551 +bcm_tlv_t *
16552 +bcm_parse_tlvs(void *buf, int buflen, uint key)
16553 +{
16554 + bcm_tlv_t *elt;
16555 + int totlen;
16556 +
16557 + elt = (bcm_tlv_t*)buf;
16558 + totlen = buflen;
16559 +
16560 + /* find tagged parameter */
16561 + while (totlen >= 2) {
16562 + int len = elt->len;
16563 +
16564 + /* validate remaining totlen */
16565 + if ((elt->id == key) && (totlen >= (len + 2)))
16566 + return (elt);
16567 +
16568 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
16569 + totlen -= (len + 2);
16570 + }
16571 +
16572 + return NULL;
16573 +}
16574 +
16575 +/*
16576 + * Traverse a string of 1-byte tag/1-byte length/variable-length value
16577 + * triples, returning a pointer to the substring whose first element
16578 + * matches tag. Stop parsing when we see an element whose ID is greater
16579 + * than the target key.
16580 + */
16581 +bcm_tlv_t *
16582 +bcm_parse_ordered_tlvs(void *buf, int buflen, uint key)
16583 +{
16584 + bcm_tlv_t *elt;
16585 + int totlen;
16586 +
16587 + elt = (bcm_tlv_t*)buf;
16588 + totlen = buflen;
16589 +
16590 + /* find tagged parameter */
16591 + while (totlen >= 2) {
16592 + uint id = elt->id;
16593 + int len = elt->len;
16594 +
16595 + /* Punt if we start seeing IDs > than target key */
16596 + if (id > key)
16597 + return(NULL);
16598 +
16599 + /* validate remaining totlen */
16600 + if ((id == key) && (totlen >= (len + 2)))
16601 + return (elt);
16602 +
16603 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
16604 + totlen -= (len + 2);
16605 + }
16606 + return NULL;
16607 +}
16608 +/* routine to dump fields in a fileddesc structure */
16609 +
16610 +uint
16611 +bcmdumpfields(readreg_rtn read_rtn, void *arg0, void *arg1, struct fielddesc *fielddesc_array, char *buf, uint32 bufsize)
16612 +{
16613 + uint filled_len;
16614 + uint len;
16615 + struct fielddesc *cur_ptr;
16616 +
16617 + filled_len = 0;
16618 + cur_ptr = fielddesc_array;
16619 +
16620 + while (bufsize > (filled_len + 64)) {
16621 + if (cur_ptr->nameandfmt == NULL)
16622 + break;
16623 + len = sprintf(buf, cur_ptr->nameandfmt, read_rtn(arg0, arg1, cur_ptr->offset));
16624 + buf += len;
16625 + filled_len += len;
16626 + cur_ptr++;
16627 + }
16628 + return filled_len;
16629 +}
16630 +
16631 +uint
16632 +bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen)
16633 +{
16634 + uint len;
16635 +
16636 + len = strlen(name) + 1;
16637 +
16638 + if ((len + datalen) > buflen)
16639 + return 0;
16640 +
16641 + strcpy(buf, name);
16642 +
16643 + /* append data onto the end of the name string */
16644 + memcpy(&buf[len], data, datalen);
16645 + len += datalen;
16646 +
16647 + return len;
16648 +}
16649 +
16650 +/* Quarter dBm units to mW
16651 + * Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153
16652 + * Table is offset so the last entry is largest mW value that fits in
16653 + * a uint16.
16654 + */
16655 +
16656 +#define QDBM_OFFSET 153
16657 +#define QDBM_TABLE_LEN 40
16658 +
16659 +/* Smallest mW value that will round up to the first table entry, QDBM_OFFSET.
16660 + * Value is ( mW(QDBM_OFFSET - 1) + mW(QDBM_OFFSET) ) / 2
16661 + */
16662 +#define QDBM_TABLE_LOW_BOUND 6493
16663 +
16664 +/* Largest mW value that will round down to the last table entry,
16665 + * QDBM_OFFSET + QDBM_TABLE_LEN-1.
16666 + * Value is ( mW(QDBM_OFFSET + QDBM_TABLE_LEN - 1) + mW(QDBM_OFFSET + QDBM_TABLE_LEN) ) / 2.
16667 + */
16668 +#define QDBM_TABLE_HIGH_BOUND 64938
16669 +
16670 +static const uint16 nqdBm_to_mW_map[QDBM_TABLE_LEN] = {
16671 +/* qdBm: +0 +1 +2 +3 +4 +5 +6 +7 */
16672 +/* 153: */ 6683, 7079, 7499, 7943, 8414, 8913, 9441, 10000,
16673 +/* 161: */ 10593, 11220, 11885, 12589, 13335, 14125, 14962, 15849,
16674 +/* 169: */ 16788, 17783, 18836, 19953, 21135, 22387, 23714, 25119,
16675 +/* 177: */ 26607, 28184, 29854, 31623, 33497, 35481, 37584, 39811,
16676 +/* 185: */ 42170, 44668, 47315, 50119, 53088, 56234, 59566, 63096
16677 +};
16678 +
16679 +uint16
16680 +bcm_qdbm_to_mw(uint8 qdbm)
16681 +{
16682 + uint factor = 1;
16683 + int idx = qdbm - QDBM_OFFSET;
16684 +
16685 + if (idx > QDBM_TABLE_LEN) {
16686 + /* clamp to max uint16 mW value */
16687 + return 0xFFFF;
16688 + }
16689 +
16690 + /* scale the qdBm index up to the range of the table 0-40
16691 + * where an offset of 40 qdBm equals a factor of 10 mW.
16692 + */
16693 + while (idx < 0) {
16694 + idx += 40;
16695 + factor *= 10;
16696 + }
16697 +
16698 + /* return the mW value scaled down to the correct factor of 10,
16699 + * adding in factor/2 to get proper rounding. */
16700 + return ((nqdBm_to_mW_map[idx] + factor/2) / factor);
16701 +}
16702 +
16703 +uint8
16704 +bcm_mw_to_qdbm(uint16 mw)
16705 +{
16706 + uint8 qdbm;
16707 + int offset;
16708 + uint mw_uint = mw;
16709 + uint boundary;
16710 +
16711 + /* handle boundary case */
16712 + if (mw_uint <= 1)
16713 + return 0;
16714 +
16715 + offset = QDBM_OFFSET;
16716 +
16717 + /* move mw into the range of the table */
16718 + while (mw_uint < QDBM_TABLE_LOW_BOUND) {
16719 + mw_uint *= 10;
16720 + offset -= 40;
16721 + }
16722 +
16723 + for (qdbm = 0; qdbm < QDBM_TABLE_LEN-1; qdbm++) {
16724 + boundary = nqdBm_to_mW_map[qdbm] + (nqdBm_to_mW_map[qdbm+1] - nqdBm_to_mW_map[qdbm])/2;
16725 + if (mw_uint < boundary) break;
16726 + }
16727 +
16728 + qdbm += (uint8)offset;
16729 +
16730 + return(qdbm);
16731 +}
16732 diff -Nur linux-2.4.32/drivers/net/hnd/hnddma.c linux-2.4.32-brcm/drivers/net/hnd/hnddma.c
16733 --- linux-2.4.32/drivers/net/hnd/hnddma.c 1970-01-01 01:00:00.000000000 +0100
16734 +++ linux-2.4.32-brcm/drivers/net/hnd/hnddma.c 2005-12-16 23:39:11.288858250 +0100
16735 @@ -0,0 +1,1527 @@
16736 +/*
16737 + * Generic Broadcom Home Networking Division (HND) DMA module.
16738 + * This supports the following chips: BCM42xx, 44xx, 47xx .
16739 + *
16740 + * Copyright 2005, Broadcom Corporation
16741 + * All Rights Reserved.
16742 + *
16743 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
16744 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
16745 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
16746 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
16747 + *
16748 + * $Id$
16749 + */
16750 +
16751 +#include <typedefs.h>
16752 +#include <osl.h>
16753 +#include <bcmendian.h>
16754 +#include <sbconfig.h>
16755 +#include <bcmutils.h>
16756 +#include <bcmdevs.h>
16757 +#include <sbutils.h>
16758 +
16759 +struct dma_info; /* forward declaration */
16760 +#define di_t struct dma_info
16761 +
16762 +#include <sbhnddma.h>
16763 +#include <hnddma.h>
16764 +
16765 +/* debug/trace */
16766 +#define DMA_ERROR(args)
16767 +#define DMA_TRACE(args)
16768 +
16769 +/* default dma message level (if input msg_level pointer is null in dma_attach()) */
16770 +static uint dma_msg_level =
16771 + 0;
16772 +
16773 +#define MAXNAMEL 8
16774 +
16775 +/* dma engine software state */
16776 +typedef struct dma_info {
16777 + hnddma_t hnddma; /* exported structure */
16778 + uint *msg_level; /* message level pointer */
16779 + char name[MAXNAMEL]; /* callers name for diag msgs */
16780 +
16781 + void *osh; /* os handle */
16782 + sb_t *sbh; /* sb handle */
16783 +
16784 + bool dma64; /* dma64 enabled */
16785 + bool addrext; /* this dma engine supports DmaExtendedAddrChanges */
16786 +
16787 + dma32regs_t *d32txregs; /* 32 bits dma tx engine registers */
16788 + dma32regs_t *d32rxregs; /* 32 bits dma rx engine registers */
16789 + dma64regs_t *d64txregs; /* 64 bits dma tx engine registers */
16790 + dma64regs_t *d64rxregs; /* 64 bits dma rx engine registers */
16791 +
16792 + uint32 dma64align; /* either 8k or 4k depends on number of dd */
16793 + dma32dd_t *txd32; /* pointer to dma32 tx descriptor ring */
16794 + dma64dd_t *txd64; /* pointer to dma64 tx descriptor ring */
16795 + uint ntxd; /* # tx descriptors tunable */
16796 + uint txin; /* index of next descriptor to reclaim */
16797 + uint txout; /* index of next descriptor to post */
16798 + uint txavail; /* # free tx descriptors */
16799 + void **txp; /* pointer to parallel array of pointers to packets */
16800 + ulong txdpa; /* physical address of descriptor ring */
16801 + uint txdalign; /* #bytes added to alloc'd mem to align txd */
16802 + uint txdalloc; /* #bytes allocated for the ring */
16803 +
16804 + dma32dd_t *rxd32; /* pointer to dma32 rx descriptor ring */
16805 + dma64dd_t *rxd64; /* pointer to dma64 rx descriptor ring */
16806 + uint nrxd; /* # rx descriptors tunable */
16807 + uint rxin; /* index of next descriptor to reclaim */
16808 + uint rxout; /* index of next descriptor to post */
16809 + void **rxp; /* pointer to parallel array of pointers to packets */
16810 + ulong rxdpa; /* physical address of descriptor ring */
16811 + uint rxdalign; /* #bytes added to alloc'd mem to align rxd */
16812 + uint rxdalloc; /* #bytes allocated for the ring */
16813 +
16814 + /* tunables */
16815 + uint rxbufsize; /* rx buffer size in bytes */
16816 + uint nrxpost; /* # rx buffers to keep posted */
16817 + uint rxoffset; /* rxcontrol offset */
16818 + uint ddoffsetlow; /* add to get dma address of descriptor ring, low 32 bits */
16819 + uint ddoffsethigh; /* add to get dma address of descriptor ring, high 32 bits */
16820 + uint dataoffsetlow; /* add to get dma address of data buffer, low 32 bits */
16821 + uint dataoffsethigh; /* add to get dma address of data buffer, high 32 bits */
16822 +} dma_info_t;
16823 +
16824 +#ifdef BCMDMA64
16825 +#define DMA64_ENAB(di) ((di)->dma64)
16826 +#else
16827 +#define DMA64_ENAB(di) (0)
16828 +#endif
16829 +
16830 +/* descriptor bumping macros */
16831 +#define XXD(x, n) ((x) & ((n) - 1))
16832 +#define TXD(x) XXD((x), di->ntxd)
16833 +#define RXD(x) XXD((x), di->nrxd)
16834 +#define NEXTTXD(i) TXD(i + 1)
16835 +#define PREVTXD(i) TXD(i - 1)
16836 +#define NEXTRXD(i) RXD(i + 1)
16837 +#define NTXDACTIVE(h, t) TXD(t - h)
16838 +#define NRXDACTIVE(h, t) RXD(t - h)
16839 +
16840 +/* macros to convert between byte offsets and indexes */
16841 +#define B2I(bytes, type) ((bytes) / sizeof(type))
16842 +#define I2B(index, type) ((index) * sizeof(type))
16843 +
16844 +#define PCI32ADDR_HIGH 0xc0000000 /* address[31:30] */
16845 +#define PCI32ADDR_HIGH_SHIFT 30
16846 +
16847 +
16848 +/* prototypes */
16849 +static bool dma_isaddrext(dma_info_t *di);
16850 +static bool dma_alloc(dma_info_t *di, uint direction);
16851 +
16852 +static bool dma32_alloc(dma_info_t *di, uint direction);
16853 +static void dma32_txreset(dma_info_t *di);
16854 +static void dma32_rxreset(dma_info_t *di);
16855 +static bool dma32_txsuspendedidle(dma_info_t *di);
16856 +static int dma32_txfast(dma_info_t *di, void *p0, uint32 coreflags);
16857 +static void* dma32_getnexttxp(dma_info_t *di, bool forceall);
16858 +static void* dma32_getnextrxp(dma_info_t *di, bool forceall);
16859 +static void dma32_txrotate(di_t *di);
16860 +
16861 +/* prototype or stubs */
16862 +#ifdef BCMDMA64
16863 +static bool dma64_alloc(dma_info_t *di, uint direction);
16864 +static void dma64_txreset(dma_info_t *di);
16865 +static void dma64_rxreset(dma_info_t *di);
16866 +static bool dma64_txsuspendedidle(dma_info_t *di);
16867 +static int dma64_txfast(dma_info_t *di, void *p0, uint32 coreflags);
16868 +static void* dma64_getnexttxp(dma_info_t *di, bool forceall);
16869 +static void* dma64_getnextrxp(dma_info_t *di, bool forceall);
16870 +static void dma64_txrotate(di_t *di);
16871 +#else
16872 +static bool dma64_alloc(dma_info_t *di, uint direction) { return TRUE; }
16873 +static void dma64_txreset(dma_info_t *di) {}
16874 +static void dma64_rxreset(dma_info_t *di) {}
16875 +static bool dma64_txsuspendedidle(dma_info_t *di) { return TRUE;}
16876 +static int dma64_txfast(dma_info_t *di, void *p0, uint32 coreflags) { return 0; }
16877 +static void* dma64_getnexttxp(dma_info_t *di, bool forceall) { return NULL; }
16878 +static void* dma64_getnextrxp(dma_info_t *di, bool forceall) { return NULL; }
16879 +static void dma64_txrotate(di_t *di) { return; }
16880 +#endif
16881 +
16882 +/* old dmaregs struct for compatibility */
16883 +typedef volatile struct {
16884 + /* transmit channel */
16885 + uint32 xmtcontrol; /* enable, et al */
16886 + uint32 xmtaddr; /* descriptor ring base address (4K aligned) */
16887 + uint32 xmtptr; /* last descriptor posted to chip */
16888 + uint32 xmtstatus; /* current active descriptor, et al */
16889 +
16890 + /* receive channel */
16891 + uint32 rcvcontrol; /* enable, et al */
16892 + uint32 rcvaddr; /* descriptor ring base address (4K aligned) */
16893 + uint32 rcvptr; /* last descriptor posted to chip */
16894 + uint32 rcvstatus; /* current active descriptor, et al */
16895 +} dmaregs_t;
16896 +
16897 +typedef struct {
16898 + uint ddoffset;
16899 + uint dataoffset;
16900 +} compat_data;
16901 +
16902 +static compat_data *ugly_hack = NULL;
16903 +
16904 +void*
16905 +dma_attold(void *drv, void *osh, char *name, dmaregs_t *regs, uint ntxd, uint nrxd,
16906 + uint rxbufsize, uint nrxpost, uint rxoffset, uint ddoffset, uint dataoffset, uint *msg_level)
16907 +{
16908 + dma32regs_t *dtx = regs;
16909 + dma32regs_t *drx = dtx + 1;
16910 +
16911 + ugly_hack = kmalloc(sizeof(ugly_hack), GFP_KERNEL);
16912 + ugly_hack->ddoffset = ddoffset;
16913 + ugly_hack->dataoffset = dataoffset;
16914 + dma_attach((osl_t *) osh, name, NULL, dtx, drx, ntxd, nrxd, rxbufsize, nrxpost, rxoffset, msg_level);
16915 + ugly_hack = NULL;
16916 +}
16917 +
16918 +
16919 +void*
16920 +dma_attach(osl_t *osh, char *name, sb_t *sbh, void *dmaregstx, void *dmaregsrx,
16921 + uint ntxd, uint nrxd, uint rxbufsize, uint nrxpost, uint rxoffset, uint *msg_level)
16922 +{
16923 + dma_info_t *di;
16924 + uint size;
16925 +
16926 + /* allocate private info structure */
16927 + if ((di = MALLOC(osh, sizeof (dma_info_t))) == NULL) {
16928 + return (NULL);
16929 + }
16930 + bzero((char*)di, sizeof (dma_info_t));
16931 +
16932 + di->msg_level = msg_level ? msg_level : &dma_msg_level;
16933 +
16934 + if (sbh != NULL)
16935 + di->dma64 = ((sb_coreflagshi(sbh, 0, 0) & SBTMH_DMA64) == SBTMH_DMA64);
16936 +
16937 +#ifndef BCMDMA64
16938 + if (di->dma64) {
16939 + DMA_ERROR(("dma_attach: driver doesn't have the capability to support 64 bits DMA\n"));
16940 + goto fail;
16941 + }
16942 +#endif
16943 +
16944 + /* check arguments */
16945 + ASSERT(ISPOWEROF2(ntxd));
16946 + ASSERT(ISPOWEROF2(nrxd));
16947 + if (nrxd == 0)
16948 + ASSERT(dmaregsrx == NULL);
16949 + if (ntxd == 0)
16950 + ASSERT(dmaregstx == NULL);
16951 +
16952 +
16953 + /* init dma reg pointer */
16954 + if (di->dma64) {
16955 + ASSERT(ntxd <= D64MAXDD);
16956 + ASSERT(nrxd <= D64MAXDD);
16957 + di->d64txregs = (dma64regs_t *)dmaregstx;
16958 + di->d64rxregs = (dma64regs_t *)dmaregsrx;
16959 +
16960 + di->dma64align = D64RINGALIGN;
16961 + if ((ntxd < D64MAXDD / 2) && (nrxd < D64MAXDD / 2)) {
16962 + /* for smaller dd table, HW relax the alignment requirement */
16963 + di->dma64align = D64RINGALIGN / 2;
16964 + }
16965 + } else {
16966 + ASSERT(ntxd <= D32MAXDD);
16967 + ASSERT(nrxd <= D32MAXDD);
16968 + di->d32txregs = (dma32regs_t *)dmaregstx;
16969 + di->d32rxregs = (dma32regs_t *)dmaregsrx;
16970 + }
16971 +
16972 +
16973 + /* make a private copy of our callers name */
16974 + strncpy(di->name, name, MAXNAMEL);
16975 + di->name[MAXNAMEL-1] = '\0';
16976 +
16977 + di->osh = osh;
16978 + di->sbh = sbh;
16979 +
16980 + /* save tunables */
16981 + di->ntxd = ntxd;
16982 + di->nrxd = nrxd;
16983 + di->rxbufsize = rxbufsize;
16984 + di->nrxpost = nrxpost;
16985 + di->rxoffset = rxoffset;
16986 +
16987 + /*
16988 + * figure out the DMA physical address offset for dd and data
16989 + * for old chips w/o sb, use zero
16990 + * for new chips w sb,
16991 + * PCI/PCIE: they map silicon backplace address to zero based memory, need offset
16992 + * Other bus: use zero
16993 + * SB_BUS BIGENDIAN kludge: use sdram swapped region for data buffer, not descriptor
16994 + */
16995 + di->ddoffsetlow = 0;
16996 + di->dataoffsetlow = 0;
16997 + if (ugly_hack != NULL) {
16998 + di->ddoffsetlow = ugly_hack->ddoffset;
16999 + di->dataoffsetlow = ugly_hack->dataoffset;
17000 + di->ddoffsethigh = 0;
17001 + di->dataoffsethigh = 0;
17002 + } else if (sbh != NULL) {
17003 + if (sbh->bustype == PCI_BUS) { /* for pci bus, add offset */
17004 + if ((sbh->buscoretype == SB_PCIE) && di->dma64){
17005 + di->ddoffsetlow = 0;
17006 + di->ddoffsethigh = SB_PCIE_DMA_H32;
17007 + } else {
17008 + di->ddoffsetlow = SB_PCI_DMA;
17009 + di->ddoffsethigh = 0;
17010 + }
17011 + di->dataoffsetlow = di->ddoffsetlow;
17012 + di->dataoffsethigh = di->ddoffsethigh;
17013 + }
17014 +#if defined(__mips__) && defined(IL_BIGENDIAN)
17015 + /* use sdram swapped region for data buffers but not dma descriptors */
17016 + di->dataoffsetlow = di->dataoffsetlow + SB_SDRAM_SWAPPED;
17017 +#endif
17018 + }
17019 +
17020 + di->addrext = ((ugly_hack == NULL) ? dma_isaddrext(di) : 0);
17021 +
17022 + DMA_TRACE(("%s: dma_attach: osh %p ntxd %d nrxd %d rxbufsize %d nrxpost %d rxoffset %d ddoffset 0x%x dataoffset 0x%x\n",
17023 + name, osh, ntxd, nrxd, rxbufsize, nrxpost, rxoffset, di->ddoffsetlow, di->dataoffsetlow));
17024 +
17025 + /* allocate tx packet pointer vector */
17026 + if (ntxd) {
17027 + size = ntxd * sizeof (void*);
17028 + if ((di->txp = MALLOC(osh, size)) == NULL) {
17029 + DMA_ERROR(("%s: dma_attach: out of tx memory, malloced %d bytes\n", di->name, MALLOCED(osh)));
17030 + goto fail;
17031 + }
17032 + bzero((char*)di->txp, size);
17033 + }
17034 +
17035 + /* allocate rx packet pointer vector */
17036 + if (nrxd) {
17037 + size = nrxd * sizeof (void*);
17038 + if ((di->rxp = MALLOC(osh, size)) == NULL) {
17039 + DMA_ERROR(("%s: dma_attach: out of rx memory, malloced %d bytes\n", di->name, MALLOCED(osh)));
17040 + goto fail;
17041 + }
17042 + bzero((char*)di->rxp, size);
17043 + }
17044 +
17045 + /* allocate transmit descriptor ring, only need ntxd descriptors but it must be aligned */
17046 + if (ntxd) {
17047 + if (!dma_alloc(di, DMA_TX))
17048 + goto fail;
17049 + }
17050 +
17051 + /* allocate receive descriptor ring, only need nrxd descriptors but it must be aligned */
17052 + if (nrxd) {
17053 + if (!dma_alloc(di, DMA_RX))
17054 + goto fail;
17055 + }
17056 +
17057 + if ((di->ddoffsetlow == SB_PCI_DMA) && (di->txdpa > SB_PCI_DMA_SZ) && !di->addrext) {
17058 + DMA_ERROR(("%s: dma_attach: txdpa 0x%lx: addrext not supported\n", di->name, di->txdpa));
17059 + goto fail;
17060 + }
17061 + if ((di->ddoffsetlow == SB_PCI_DMA) && (di->rxdpa > SB_PCI_DMA_SZ) && !di->addrext) {
17062 + DMA_ERROR(("%s: dma_attach: rxdpa 0x%lx: addrext not supported\n", di->name, di->rxdpa));
17063 + goto fail;
17064 + }
17065 +
17066 + return ((void*)di);
17067 +
17068 +fail:
17069 + dma_detach((void*)di);
17070 + return (NULL);
17071 +}
17072 +
17073 +static bool
17074 +dma_alloc(dma_info_t *di, uint direction)
17075 +{
17076 + if (DMA64_ENAB(di)) {
17077 + return dma64_alloc(di, direction);
17078 + } else {
17079 + return dma32_alloc(di, direction);
17080 + }
17081 +}
17082 +
17083 +/* may be called with core in reset */
17084 +void
17085 +dma_detach(dma_info_t *di)
17086 +{
17087 + if (di == NULL)
17088 + return;
17089 +
17090 + DMA_TRACE(("%s: dma_detach\n", di->name));
17091 +
17092 + /* shouldn't be here if descriptors are unreclaimed */
17093 + ASSERT(di->txin == di->txout);
17094 + ASSERT(di->rxin == di->rxout);
17095 +
17096 + /* free dma descriptor rings */
17097 + if (di->txd32)
17098 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->txd32 - di->txdalign), di->txdalloc, (di->txdpa - di->txdalign));
17099 + if (di->rxd32)
17100 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->rxd32 - di->rxdalign), di->rxdalloc, (di->rxdpa - di->rxdalign));
17101 +
17102 + /* free packet pointer vectors */
17103 + if (di->txp)
17104 + MFREE(di->osh, (void*)di->txp, (di->ntxd * sizeof (void*)));
17105 + if (di->rxp)
17106 + MFREE(di->osh, (void*)di->rxp, (di->nrxd * sizeof (void*)));
17107 +
17108 + /* free our private info structure */
17109 + MFREE(di->osh, (void*)di, sizeof (dma_info_t));
17110 +}
17111 +
17112 +/* return TRUE if this dma engine supports DmaExtendedAddrChanges, otherwise FALSE */
17113 +static bool
17114 +dma_isaddrext(dma_info_t *di)
17115 +{
17116 + uint32 w;
17117 +
17118 + if (DMA64_ENAB(di)) {
17119 + OR_REG(&di->d64txregs->control, D64_XC_AE);
17120 + w = R_REG(&di->d32txregs->control);
17121 + AND_REG(&di->d32txregs->control, ~D64_XC_AE);
17122 + return ((w & XC_AE) == D64_XC_AE);
17123 + } else {
17124 + OR_REG(&di->d32txregs->control, XC_AE);
17125 + w = R_REG(&di->d32txregs->control);
17126 + AND_REG(&di->d32txregs->control, ~XC_AE);
17127 + return ((w & XC_AE) == XC_AE);
17128 + }
17129 +}
17130 +
17131 +void
17132 +dma_txreset(dma_info_t *di)
17133 +{
17134 + DMA_TRACE(("%s: dma_txreset\n", di->name));
17135 +
17136 + if (DMA64_ENAB(di))
17137 + dma64_txreset(di);
17138 + else
17139 + dma32_txreset(di);
17140 +}
17141 +
17142 +void
17143 +dma_rxreset(dma_info_t *di)
17144 +{
17145 + DMA_TRACE(("%s: dma_rxreset\n", di->name));
17146 +
17147 + if (DMA64_ENAB(di))
17148 + dma64_rxreset(di);
17149 + else
17150 + dma32_rxreset(di);
17151 +}
17152 +
17153 +/* initialize descriptor table base address */
17154 +static void
17155 +dma_ddtable_init(dma_info_t *di, uint direction, ulong pa)
17156 +{
17157 + if (DMA64_ENAB(di)) {
17158 + if (direction == DMA_TX) {
17159 + W_REG(&di->d64txregs->addrlow, pa + di->ddoffsetlow);
17160 + W_REG(&di->d64txregs->addrhigh, di->ddoffsethigh);
17161 + } else {
17162 + W_REG(&di->d64rxregs->addrlow, pa + di->ddoffsetlow);
17163 + W_REG(&di->d64rxregs->addrhigh, di->ddoffsethigh);
17164 + }
17165 + } else {
17166 + uint32 offset = di->ddoffsetlow;
17167 + if ((offset != SB_PCI_DMA) || !(pa & PCI32ADDR_HIGH)) {
17168 + if (direction == DMA_TX)
17169 + W_REG(&di->d32txregs->addr, (pa + offset));
17170 + else
17171 + W_REG(&di->d32rxregs->addr, (pa + offset));
17172 + } else {
17173 + /* dma32 address extension */
17174 + uint32 ae;
17175 + ASSERT(di->addrext);
17176 + ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT;
17177 +
17178 + if (direction == DMA_TX) {
17179 + W_REG(&di->d32txregs->addr, ((pa & ~PCI32ADDR_HIGH) + offset));
17180 + SET_REG(&di->d32txregs->control, XC_AE, (ae << XC_AE_SHIFT));
17181 + } else {
17182 + W_REG(&di->d32rxregs->addr, ((pa & ~PCI32ADDR_HIGH) + offset));
17183 + SET_REG(&di->d32rxregs->control, RC_AE, (ae << RC_AE_SHIFT));
17184 + }
17185 + }
17186 + }
17187 +}
17188 +
17189 +/* init the tx or rx descriptor */
17190 +static INLINE void
17191 +dma32_dd_upd(dma_info_t *di, dma32dd_t *ddring, ulong pa, uint outidx, uint32 *ctrl)
17192 +{
17193 + uint offset = di->dataoffsetlow;
17194 +
17195 + if ((offset != SB_PCI_DMA) || !(pa & PCI32ADDR_HIGH)) {
17196 + W_SM(&ddring[outidx].addr, BUS_SWAP32(pa + offset));
17197 + W_SM(&ddring[outidx].ctrl, BUS_SWAP32(*ctrl));
17198 + } else {
17199 + /* address extension */
17200 + uint32 ae;
17201 + ASSERT(di->addrext);
17202 + ae = (pa & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT;
17203 +
17204 + *ctrl |= (ae << CTRL_AE_SHIFT);
17205 + W_SM(&ddring[outidx].addr, BUS_SWAP32((pa & ~PCI32ADDR_HIGH) + offset));
17206 + W_SM(&ddring[outidx].ctrl, BUS_SWAP32(*ctrl));
17207 + }
17208 +}
17209 +
17210 +/* init the tx or rx descriptor */
17211 +static INLINE void
17212 +dma64_dd_upd(dma_info_t *di, dma64dd_t *ddring, ulong pa, uint outidx, uint32 *flags, uint32 bufcount)
17213 +{
17214 + uint32 bufaddr_low = pa + di->dataoffsetlow;
17215 + uint32 bufaddr_high = 0 + di->dataoffsethigh;
17216 +
17217 + uint32 ctrl2 = bufcount & D64_CTRL2_BC_MASK;
17218 +
17219 + W_SM(&ddring[outidx].addrlow, BUS_SWAP32(bufaddr_low));
17220 + W_SM(&ddring[outidx].addrhigh, BUS_SWAP32(bufaddr_high));
17221 + W_SM(&ddring[outidx].ctrl1, BUS_SWAP32(*flags));
17222 + W_SM(&ddring[outidx].ctrl2, BUS_SWAP32(ctrl2));
17223 +}
17224 +
17225 +void
17226 +dma_txinit(dma_info_t *di)
17227 +{
17228 + DMA_TRACE(("%s: dma_txinit\n", di->name));
17229 +
17230 + di->txin = di->txout = 0;
17231 + di->txavail = di->ntxd - 1;
17232 +
17233 + /* clear tx descriptor ring */
17234 + if (DMA64_ENAB(di)) {
17235 + BZERO_SM((void*)di->txd64, (di->ntxd * sizeof (dma64dd_t)));
17236 + W_REG(&di->d64txregs->control, XC_XE);
17237 + dma_ddtable_init(di, DMA_TX, di->txdpa);
17238 + } else {
17239 + BZERO_SM((void*)di->txd32, (di->ntxd * sizeof (dma32dd_t)));
17240 + W_REG(&di->d32txregs->control, XC_XE);
17241 + dma_ddtable_init(di, DMA_TX, di->txdpa);
17242 + }
17243 +}
17244 +
17245 +bool
17246 +dma_txenabled(dma_info_t *di)
17247 +{
17248 + uint32 xc;
17249 +
17250 + /* If the chip is dead, it is not enabled :-) */
17251 + if (DMA64_ENAB(di)) {
17252 + xc = R_REG(&di->d64txregs->control);
17253 + return ((xc != 0xffffffff) && (xc & D64_XC_XE));
17254 + } else {
17255 + xc = R_REG(&di->d32txregs->control);
17256 + return ((xc != 0xffffffff) && (xc & XC_XE));
17257 + }
17258 +}
17259 +
17260 +void
17261 +dma_txsuspend(dma_info_t *di)
17262 +{
17263 + DMA_TRACE(("%s: dma_txsuspend\n", di->name));
17264 + if (DMA64_ENAB(di))
17265 + OR_REG(&di->d64txregs->control, D64_XC_SE);
17266 + else
17267 + OR_REG(&di->d32txregs->control, XC_SE);
17268 +}
17269 +
17270 +void
17271 +dma_txresume(dma_info_t *di)
17272 +{
17273 + DMA_TRACE(("%s: dma_txresume\n", di->name));
17274 + if (DMA64_ENAB(di))
17275 + AND_REG(&di->d64txregs->control, ~D64_XC_SE);
17276 + else
17277 + AND_REG(&di->d32txregs->control, ~XC_SE);
17278 +}
17279 +
17280 +bool
17281 +dma_txsuspendedidle(dma_info_t *di)
17282 +{
17283 + if (DMA64_ENAB(di))
17284 + return dma64_txsuspendedidle(di);
17285 + else
17286 + return dma32_txsuspendedidle(di);
17287 +}
17288 +
17289 +bool
17290 +dma_txsuspended(dma_info_t *di)
17291 +{
17292 + if (DMA64_ENAB(di))
17293 + return ((R_REG(&di->d64txregs->control) & D64_XC_SE) == D64_XC_SE);
17294 + else
17295 + return ((R_REG(&di->d32txregs->control) & XC_SE) == XC_SE);
17296 +}
17297 +
17298 +bool
17299 +dma_txstopped(dma_info_t *di)
17300 +{
17301 + if (DMA64_ENAB(di))
17302 + return ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == D64_XS0_XS_STOPPED);
17303 + else
17304 + return ((R_REG(&di->d32txregs->status) & XS_XS_MASK) == XS_XS_STOPPED);
17305 +}
17306 +
17307 +bool
17308 +dma_rxstopped(dma_info_t *di)
17309 +{
17310 + if (DMA64_ENAB(di))
17311 + return ((R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK) == D64_RS0_RS_STOPPED);
17312 + else
17313 + return ((R_REG(&di->d32rxregs->status) & RS_RS_MASK) == RS_RS_STOPPED);
17314 +}
17315 +
17316 +void
17317 +dma_fifoloopbackenable(dma_info_t *di)
17318 +{
17319 + DMA_TRACE(("%s: dma_fifoloopbackenable\n", di->name));
17320 + if (DMA64_ENAB(di))
17321 + OR_REG(&di->d64txregs->control, D64_XC_LE);
17322 + else
17323 + OR_REG(&di->d32txregs->control, XC_LE);
17324 +}
17325 +
17326 +void
17327 +dma_rxinit(dma_info_t *di)
17328 +{
17329 + DMA_TRACE(("%s: dma_rxinit\n", di->name));
17330 +
17331 + di->rxin = di->rxout = 0;
17332 +
17333 + /* clear rx descriptor ring */
17334 + if (DMA64_ENAB(di)) {
17335 + BZERO_SM((void*)di->rxd64, (di->nrxd * sizeof (dma64dd_t)));
17336 + dma_rxenable(di);
17337 + dma_ddtable_init(di, DMA_RX, di->rxdpa);
17338 + } else {
17339 + BZERO_SM((void*)di->rxd32, (di->nrxd * sizeof (dma32dd_t)));
17340 + dma_rxenable(di);
17341 + dma_ddtable_init(di, DMA_RX, di->rxdpa);
17342 + }
17343 +}
17344 +
17345 +void
17346 +dma_rxenable(dma_info_t *di)
17347 +{
17348 + DMA_TRACE(("%s: dma_rxenable\n", di->name));
17349 + if (DMA64_ENAB(di))
17350 + W_REG(&di->d64rxregs->control, ((di->rxoffset << D64_RC_RO_SHIFT) | D64_RC_RE));
17351 + else
17352 + W_REG(&di->d32rxregs->control, ((di->rxoffset << RC_RO_SHIFT) | RC_RE));
17353 +}
17354 +
17355 +bool
17356 +dma_rxenabled(dma_info_t *di)
17357 +{
17358 + uint32 rc;
17359 +
17360 + if (DMA64_ENAB(di)) {
17361 + rc = R_REG(&di->d64rxregs->control);
17362 + return ((rc != 0xffffffff) && (rc & D64_RC_RE));
17363 + } else {
17364 + rc = R_REG(&di->d32rxregs->control);
17365 + return ((rc != 0xffffffff) && (rc & RC_RE));
17366 + }
17367 +}
17368 +
17369 +
17370 +/* !! tx entry routine */
17371 +int
17372 +dma_txfast(dma_info_t *di, void *p0, uint32 coreflags)
17373 +{
17374 + if (DMA64_ENAB(di)) {
17375 + return dma64_txfast(di, p0, coreflags);
17376 + } else {
17377 + return dma32_txfast(di, p0, coreflags);
17378 + }
17379 +}
17380 +
17381 +/* !! rx entry routine, returns a pointer to the next frame received, or NULL if there are no more */
17382 +void*
17383 +dma_rx(dma_info_t *di)
17384 +{
17385 + void *p;
17386 + uint len;
17387 + int skiplen = 0;
17388 +
17389 + while ((p = dma_getnextrxp(di, FALSE))) {
17390 + /* skip giant packets which span multiple rx descriptors */
17391 + if (skiplen > 0) {
17392 + skiplen -= di->rxbufsize;
17393 + if (skiplen < 0)
17394 + skiplen = 0;
17395 + PKTFREE(di->osh, p, FALSE);
17396 + continue;
17397 + }
17398 +
17399 + len = ltoh16(*(uint16*)(PKTDATA(di->osh, p)));
17400 + DMA_TRACE(("%s: dma_rx len %d\n", di->name, len));
17401 +
17402 + /* bad frame length check */
17403 + if (len > (di->rxbufsize - di->rxoffset)) {
17404 + DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len));
17405 + if (len > 0)
17406 + skiplen = len - (di->rxbufsize - di->rxoffset);
17407 + PKTFREE(di->osh, p, FALSE);
17408 + di->hnddma.rxgiants++;
17409 + continue;
17410 + }
17411 +
17412 + /* set actual length */
17413 + PKTSETLEN(di->osh, p, (di->rxoffset + len));
17414 +
17415 + break;
17416 + }
17417 +
17418 + return (p);
17419 +}
17420 +
17421 +/* post receive buffers */
17422 +void
17423 +dma_rxfill(dma_info_t *di)
17424 +{
17425 + void *p;
17426 + uint rxin, rxout;
17427 + uint32 ctrl;
17428 + uint n;
17429 + uint i;
17430 + uint32 pa;
17431 + uint rxbufsize;
17432 +
17433 + /*
17434 + * Determine how many receive buffers we're lacking
17435 + * from the full complement, allocate, initialize,
17436 + * and post them, then update the chip rx lastdscr.
17437 + */
17438 +
17439 + rxin = di->rxin;
17440 + rxout = di->rxout;
17441 + rxbufsize = di->rxbufsize;
17442 +
17443 + n = di->nrxpost - NRXDACTIVE(rxin, rxout);
17444 +
17445 + DMA_TRACE(("%s: dma_rxfill: post %d\n", di->name, n));
17446 +
17447 + for (i = 0; i < n; i++) {
17448 + if ((p = PKTGET(di->osh, rxbufsize, FALSE)) == NULL) {
17449 + DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", di->name));
17450 + di->hnddma.rxnobuf++;
17451 + break;
17452 + }
17453 +
17454 + /* Do a cached write instead of uncached write since DMA_MAP
17455 + * will flush the cache. */
17456 + *(uint32*)(PKTDATA(di->osh, p)) = 0;
17457 +
17458 + pa = (uint32) DMA_MAP(di->osh, PKTDATA(di->osh, p), rxbufsize, DMA_RX, p);
17459 + ASSERT(ISALIGNED(pa, 4));
17460 +
17461 + /* save the free packet pointer */
17462 + ASSERT(di->rxp[rxout] == NULL);
17463 + di->rxp[rxout] = p;
17464 +
17465 + if (DMA64_ENAB(di)) {
17466 + /* prep the descriptor control value */
17467 + if (rxout == (di->nrxd - 1))
17468 + ctrl = CTRL_EOT;
17469 +
17470 + dma64_dd_upd(di, di->rxd64, pa, rxout, &ctrl, rxbufsize);
17471 + } else {
17472 + /* prep the descriptor control value */
17473 + ctrl = rxbufsize;
17474 + if (rxout == (di->nrxd - 1))
17475 + ctrl |= CTRL_EOT;
17476 + dma32_dd_upd(di, di->rxd32, pa, rxout, &ctrl);
17477 + }
17478 +
17479 + rxout = NEXTRXD(rxout);
17480 + }
17481 +
17482 + di->rxout = rxout;
17483 +
17484 + /* update the chip lastdscr pointer */
17485 + if (DMA64_ENAB(di)) {
17486 + W_REG(&di->d64rxregs->ptr, I2B(rxout, dma64dd_t));
17487 + } else {
17488 + W_REG(&di->d32rxregs->ptr, I2B(rxout, dma32dd_t));
17489 + }
17490 +}
17491 +
17492 +void
17493 +dma_txreclaim(dma_info_t *di, bool forceall)
17494 +{
17495 + void *p;
17496 +
17497 + DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, forceall ? "all" : ""));
17498 +
17499 + while ((p = dma_getnexttxp(di, forceall)))
17500 + PKTFREE(di->osh, p, TRUE);
17501 +}
17502 +
17503 +/*
17504 + * Reclaim next completed txd (txds if using chained buffers) and
17505 + * return associated packet.
17506 + * If 'force' is true, reclaim txd(s) and return associated packet
17507 + * regardless of the value of the hardware "curr" pointer.
17508 + */
17509 +void*
17510 +dma_getnexttxp(dma_info_t *di, bool forceall)
17511 +{
17512 + if (DMA64_ENAB(di)) {
17513 + return dma64_getnexttxp(di, forceall);
17514 + } else {
17515 + return dma32_getnexttxp(di, forceall);
17516 + }
17517 +}
17518 +
17519 +/* like getnexttxp but no reclaim */
17520 +void*
17521 +dma_peeknexttxp(dma_info_t *di)
17522 +{
17523 + uint end, i;
17524 +
17525 + if (DMA64_ENAB(di)) {
17526 + end = B2I(R_REG(&di->d64txregs->status0) & D64_XS0_CD_MASK, dma64dd_t);
17527 + } else {
17528 + end = B2I(R_REG(&di->d32txregs->status) & XS_CD_MASK, dma32dd_t);
17529 + }
17530 +
17531 + for (i = di->txin; i != end; i = NEXTTXD(i))
17532 + if (di->txp[i])
17533 + return (di->txp[i]);
17534 +
17535 + return (NULL);
17536 +}
17537 +
17538 +/*
17539 + * Rotate all active tx dma ring entries "forward" by (ActiveDescriptor - txin).
17540 + */
17541 +void
17542 +dma_txrotate(di_t *di)
17543 +{
17544 + if (DMA64_ENAB(di)) {
17545 + dma64_txrotate(di);
17546 + } else {
17547 + dma32_txrotate(di);
17548 + }
17549 +}
17550 +
17551 +void
17552 +dma_rxreclaim(dma_info_t *di)
17553 +{
17554 + void *p;
17555 +
17556 + DMA_TRACE(("%s: dma_rxreclaim\n", di->name));
17557 +
17558 + while ((p = dma_getnextrxp(di, TRUE)))
17559 + PKTFREE(di->osh, p, FALSE);
17560 +}
17561 +
17562 +void *
17563 +dma_getnextrxp(dma_info_t *di, bool forceall)
17564 +{
17565 + if (DMA64_ENAB(di)) {
17566 + return dma64_getnextrxp(di, forceall);
17567 + } else {
17568 + return dma32_getnextrxp(di, forceall);
17569 + }
17570 +}
17571 +
17572 +uintptr
17573 +dma_getvar(dma_info_t *di, char *name)
17574 +{
17575 + if (!strcmp(name, "&txavail"))
17576 + return ((uintptr) &di->txavail);
17577 + else {
17578 + ASSERT(0);
17579 + }
17580 + return (0);
17581 +}
17582 +
17583 +void
17584 +dma_txblock(dma_info_t *di)
17585 +{
17586 + di->txavail = 0;
17587 +}
17588 +
17589 +void
17590 +dma_txunblock(dma_info_t *di)
17591 +{
17592 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
17593 +}
17594 +
17595 +uint
17596 +dma_txactive(dma_info_t *di)
17597 +{
17598 + return (NTXDACTIVE(di->txin, di->txout));
17599 +}
17600 +
17601 +void
17602 +dma_rxpiomode(dma32regs_t *regs)
17603 +{
17604 + W_REG(&regs->control, RC_FM);
17605 +}
17606 +
17607 +void
17608 +dma_txpioloopback(dma32regs_t *regs)
17609 +{
17610 + OR_REG(&regs->control, XC_LE);
17611 +}
17612 +
17613 +
17614 +
17615 +
17616 +/*** 32 bits DMA non-inline functions ***/
17617 +static bool
17618 +dma32_alloc(dma_info_t *di, uint direction)
17619 +{
17620 + uint size;
17621 + uint ddlen;
17622 + void *va;
17623 +
17624 + ddlen = sizeof (dma32dd_t);
17625 +
17626 + size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen);
17627 +
17628 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, D32RINGALIGN))
17629 + size += D32RINGALIGN;
17630 +
17631 +
17632 + if (direction == DMA_TX) {
17633 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->txdpa)) == NULL) {
17634 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name));
17635 + return FALSE;
17636 + }
17637 +
17638 + di->txd32 = (dma32dd_t*) ROUNDUP((uintptr)va, D32RINGALIGN);
17639 + di->txdalign = (uint)((int8*)di->txd32 - (int8*)va);
17640 + di->txdpa += di->txdalign;
17641 + di->txdalloc = size;
17642 + ASSERT(ISALIGNED((uintptr)di->txd32, D32RINGALIGN));
17643 + } else {
17644 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->rxdpa)) == NULL) {
17645 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name));
17646 + return FALSE;
17647 + }
17648 + di->rxd32 = (dma32dd_t*) ROUNDUP((uintptr)va, D32RINGALIGN);
17649 + di->rxdalign = (uint)((int8*)di->rxd32 - (int8*)va);
17650 + di->rxdpa += di->rxdalign;
17651 + di->rxdalloc = size;
17652 + ASSERT(ISALIGNED((uintptr)di->rxd32, D32RINGALIGN));
17653 + }
17654 +
17655 + return TRUE;
17656 +}
17657 +
17658 +static void
17659 +dma32_txreset(dma_info_t *di)
17660 +{
17661 + uint32 status;
17662 +
17663 + /* suspend tx DMA first */
17664 + W_REG(&di->d32txregs->control, XC_SE);
17665 + SPINWAIT((status = (R_REG(&di->d32txregs->status) & XS_XS_MASK)) != XS_XS_DISABLED &&
17666 + status != XS_XS_IDLE &&
17667 + status != XS_XS_STOPPED,
17668 + 10000);
17669 +
17670 + W_REG(&di->d32txregs->control, 0);
17671 + SPINWAIT((status = (R_REG(&di->d32txregs->status) & XS_XS_MASK)) != XS_XS_DISABLED,
17672 + 10000);
17673 +
17674 + if (status != XS_XS_DISABLED) {
17675 + DMA_ERROR(("%s: dma_txreset: dma cannot be stopped\n", di->name));
17676 + }
17677 +
17678 + /* wait for the last transaction to complete */
17679 + OSL_DELAY(300);
17680 +}
17681 +
17682 +static void
17683 +dma32_rxreset(dma_info_t *di)
17684 +{
17685 + uint32 status;
17686 +
17687 + W_REG(&di->d32rxregs->control, 0);
17688 + SPINWAIT((status = (R_REG(&di->d32rxregs->status) & RS_RS_MASK)) != RS_RS_DISABLED,
17689 + 10000);
17690 +
17691 + if (status != RS_RS_DISABLED) {
17692 + DMA_ERROR(("%s: dma_rxreset: dma cannot be stopped\n", di->name));
17693 + }
17694 +}
17695 +
17696 +static bool
17697 +dma32_txsuspendedidle(dma_info_t *di)
17698 +{
17699 + if (!(R_REG(&di->d32txregs->control) & XC_SE))
17700 + return 0;
17701 +
17702 + if ((R_REG(&di->d32txregs->status) & XS_XS_MASK) != XS_XS_IDLE)
17703 + return 0;
17704 +
17705 + OSL_DELAY(2);
17706 + return ((R_REG(&di->d32txregs->status) & XS_XS_MASK) == XS_XS_IDLE);
17707 +}
17708 +
17709 +/*
17710 + * supports full 32bit dma engine buffer addressing so
17711 + * dma buffers can cross 4 Kbyte page boundaries.
17712 + */
17713 +static int
17714 +dma32_txfast(dma_info_t *di, void *p0, uint32 coreflags)
17715 +{
17716 + void *p, *next;
17717 + uchar *data;
17718 + uint len;
17719 + uint txout;
17720 + uint32 ctrl;
17721 + uint32 pa;
17722 +
17723 + DMA_TRACE(("%s: dma_txfast\n", di->name));
17724 +
17725 + txout = di->txout;
17726 + ctrl = 0;
17727 +
17728 + /*
17729 + * Walk the chain of packet buffers
17730 + * allocating and initializing transmit descriptor entries.
17731 + */
17732 + for (p = p0; p; p = next) {
17733 + data = PKTDATA(di->osh, p);
17734 + len = PKTLEN(di->osh, p);
17735 + next = PKTNEXT(di->osh, p);
17736 +
17737 + /* return nonzero if out of tx descriptors */
17738 + if (NEXTTXD(txout) == di->txin)
17739 + goto outoftxd;
17740 +
17741 + if (len == 0)
17742 + continue;
17743 +
17744 + /* get physical address of buffer start */
17745 + pa = (uint32) DMA_MAP(di->osh, data, len, DMA_TX, p);
17746 +
17747 + /* build the descriptor control value */
17748 + ctrl = len & CTRL_BC_MASK;
17749 +
17750 + ctrl |= coreflags;
17751 +
17752 + if (p == p0)
17753 + ctrl |= CTRL_SOF;
17754 + if (next == NULL)
17755 + ctrl |= (CTRL_IOC | CTRL_EOF);
17756 + if (txout == (di->ntxd - 1))
17757 + ctrl |= CTRL_EOT;
17758 +
17759 + if (DMA64_ENAB(di)) {
17760 + dma64_dd_upd(di, di->txd64, pa, txout, &ctrl, len);
17761 + } else {
17762 + dma32_dd_upd(di, di->txd32, pa, txout, &ctrl);
17763 + }
17764 +
17765 + ASSERT(di->txp[txout] == NULL);
17766 +
17767 + txout = NEXTTXD(txout);
17768 + }
17769 +
17770 + /* if last txd eof not set, fix it */
17771 + if (!(ctrl & CTRL_EOF))
17772 + W_SM(&di->txd32[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF));
17773 +
17774 + /* save the packet */
17775 + di->txp[PREVTXD(txout)] = p0;
17776 +
17777 + /* bump the tx descriptor index */
17778 + di->txout = txout;
17779 +
17780 + /* kick the chip */
17781 + if (DMA64_ENAB(di)) {
17782 + W_REG(&di->d64txregs->ptr, I2B(txout, dma64dd_t));
17783 + } else {
17784 + W_REG(&di->d32txregs->ptr, I2B(txout, dma32dd_t));
17785 + }
17786 +
17787 + /* tx flow control */
17788 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
17789 +
17790 + return (0);
17791 +
17792 + outoftxd:
17793 + DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name));
17794 + PKTFREE(di->osh, p0, TRUE);
17795 + di->txavail = 0;
17796 + di->hnddma.txnobuf++;
17797 + return (-1);
17798 +}
17799 +
17800 +static void*
17801 +dma32_getnexttxp(dma_info_t *di, bool forceall)
17802 +{
17803 + uint start, end, i;
17804 + void *txp;
17805 +
17806 + DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, forceall ? "all" : ""));
17807 +
17808 + txp = NULL;
17809 +
17810 + start = di->txin;
17811 + if (forceall)
17812 + end = di->txout;
17813 + else
17814 + end = B2I(R_REG(&di->d32txregs->status) & XS_CD_MASK, dma32dd_t);
17815 +
17816 + if ((start == 0) && (end > di->txout))
17817 + goto bogus;
17818 +
17819 + for (i = start; i != end && !txp; i = NEXTTXD(i)) {
17820 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->txd32[i].addr)) - di->dataoffsetlow),
17821 + (BUS_SWAP32(R_SM(&di->txd32[i].ctrl)) & CTRL_BC_MASK), DMA_TX, di->txp[i]);
17822 +
17823 + W_SM(&di->txd32[i].addr, 0xdeadbeef);
17824 + txp = di->txp[i];
17825 + di->txp[i] = NULL;
17826 + }
17827 +
17828 + di->txin = i;
17829 +
17830 + /* tx flow control */
17831 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
17832 +
17833 + return (txp);
17834 +
17835 +bogus:
17836 +/*
17837 + DMA_ERROR(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n",
17838 + start, end, di->txout, forceall));
17839 +*/
17840 + return (NULL);
17841 +}
17842 +
17843 +static void *
17844 +dma32_getnextrxp(dma_info_t *di, bool forceall)
17845 +{
17846 + uint i;
17847 + void *rxp;
17848 +
17849 + /* if forcing, dma engine must be disabled */
17850 + ASSERT(!forceall || !dma_rxenabled(di));
17851 +
17852 + i = di->rxin;
17853 +
17854 + /* return if no packets posted */
17855 + if (i == di->rxout)
17856 + return (NULL);
17857 +
17858 + /* ignore curr if forceall */
17859 + if (!forceall && (i == B2I(R_REG(&di->d32rxregs->status) & RS_CD_MASK, dma32dd_t)))
17860 + return (NULL);
17861 +
17862 + /* get the packet pointer that corresponds to the rx descriptor */
17863 + rxp = di->rxp[i];
17864 + ASSERT(rxp);
17865 + di->rxp[i] = NULL;
17866 +
17867 + /* clear this packet from the descriptor ring */
17868 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->rxd32[i].addr)) - di->dataoffsetlow),
17869 + di->rxbufsize, DMA_RX, rxp);
17870 + W_SM(&di->rxd32[i].addr, 0xdeadbeef);
17871 +
17872 + di->rxin = NEXTRXD(i);
17873 +
17874 + return (rxp);
17875 +}
17876 +
17877 +static void
17878 +dma32_txrotate(di_t *di)
17879 +{
17880 + uint ad;
17881 + uint nactive;
17882 + uint rot;
17883 + uint old, new;
17884 + uint32 w;
17885 + uint first, last;
17886 +
17887 + ASSERT(dma_txsuspendedidle(di));
17888 +
17889 + nactive = dma_txactive(di);
17890 + ad = B2I(((R_REG(&di->d32txregs->status) & XS_AD_MASK) >> XS_AD_SHIFT), dma32dd_t);
17891 + rot = TXD(ad - di->txin);
17892 +
17893 + ASSERT(rot < di->ntxd);
17894 +
17895 + /* full-ring case is a lot harder - don't worry about this */
17896 + if (rot >= (di->ntxd - nactive)) {
17897 + DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name));
17898 + return;
17899 + }
17900 +
17901 + first = di->txin;
17902 + last = PREVTXD(di->txout);
17903 +
17904 + /* move entries starting at last and moving backwards to first */
17905 + for (old = last; old != PREVTXD(first); old = PREVTXD(old)) {
17906 + new = TXD(old + rot);
17907 +
17908 + /*
17909 + * Move the tx dma descriptor.
17910 + * EOT is set only in the last entry in the ring.
17911 + */
17912 + w = R_SM(&di->txd32[old].ctrl) & ~CTRL_EOT;
17913 + if (new == (di->ntxd - 1))
17914 + w |= CTRL_EOT;
17915 + W_SM(&di->txd32[new].ctrl, w);
17916 + W_SM(&di->txd32[new].addr, R_SM(&di->txd32[old].addr));
17917 +
17918 + /* zap the old tx dma descriptor address field */
17919 + W_SM(&di->txd32[old].addr, 0xdeadbeef);
17920 +
17921 + /* move the corresponding txp[] entry */
17922 + ASSERT(di->txp[new] == NULL);
17923 + di->txp[new] = di->txp[old];
17924 + di->txp[old] = NULL;
17925 + }
17926 +
17927 + /* update txin and txout */
17928 + di->txin = ad;
17929 + di->txout = TXD(di->txout + rot);
17930 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
17931 +
17932 + /* kick the chip */
17933 + W_REG(&di->d32txregs->ptr, I2B(di->txout, dma32dd_t));
17934 +}
17935 +
17936 +/*** 64 bits DMA non-inline functions ***/
17937 +
17938 +#ifdef BCMDMA64
17939 +
17940 +static bool
17941 +dma64_alloc(dma_info_t *di, uint direction)
17942 +{
17943 + uint size;
17944 + uint ddlen;
17945 + uint32 alignbytes;
17946 + void *va;
17947 +
17948 + ddlen = sizeof (dma64dd_t);
17949 +
17950 + size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen);
17951 +
17952 + alignbytes = di->dma64align;
17953 +
17954 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, alignbytes))
17955 + size += alignbytes;
17956 +
17957 +
17958 + if (direction == DMA_TX) {
17959 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->txdpa)) == NULL) {
17960 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name));
17961 + return FALSE;
17962 + }
17963 +
17964 + di->txd64 = (dma64dd_t*) ROUNDUP((uintptr)va, alignbytes);
17965 + di->txdalign = (uint)((int8*)di->txd64 - (int8*)va);
17966 + di->txdpa += di->txdalign;
17967 + di->txdalloc = size;
17968 + ASSERT(ISALIGNED((uintptr)di->txd64, alignbytes));
17969 + } else {
17970 + if ((va = DMA_ALLOC_CONSISTENT(di->osh, size, &di->rxdpa)) == NULL) {
17971 + DMA_ERROR(("%s: dma_attach: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name));
17972 + return FALSE;
17973 + }
17974 + di->rxd64 = (dma64dd_t*) ROUNDUP((uintptr)va, alignbytes);
17975 + di->rxdalign = (uint)((int8*)di->rxd64 - (int8*)va);
17976 + di->rxdpa += di->rxdalign;
17977 + di->rxdalloc = size;
17978 + ASSERT(ISALIGNED((uintptr)di->rxd64, alignbytes));
17979 + }
17980 +
17981 + return TRUE;
17982 +}
17983 +
17984 +static void
17985 +dma64_txreset(dma_info_t *di)
17986 +{
17987 + uint32 status;
17988 +
17989 + /* suspend tx DMA first */
17990 + W_REG(&di->d64txregs->control, D64_XC_SE);
17991 + SPINWAIT((status = (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED &&
17992 + status != D64_XS0_XS_IDLE &&
17993 + status != D64_XS0_XS_STOPPED,
17994 + 10000);
17995 +
17996 + W_REG(&di->d64txregs->control, 0);
17997 + SPINWAIT((status = (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED,
17998 + 10000);
17999 +
18000 + if (status != D64_XS0_XS_DISABLED) {
18001 + DMA_ERROR(("%s: dma_txreset: dma cannot be stopped\n", di->name));
18002 + }
18003 +
18004 + /* wait for the last transaction to complete */
18005 + OSL_DELAY(300);
18006 +}
18007 +
18008 +static void
18009 +dma64_rxreset(dma_info_t *di)
18010 +{
18011 + uint32 status;
18012 +
18013 + W_REG(&di->d64rxregs->control, 0);
18014 + SPINWAIT((status = (R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK)) != D64_RS0_RS_DISABLED,
18015 + 10000);
18016 +
18017 + if (status != D64_RS0_RS_DISABLED) {
18018 + DMA_ERROR(("%s: dma_rxreset: dma cannot be stopped\n", di->name));
18019 + }
18020 +}
18021 +
18022 +static bool
18023 +dma64_txsuspendedidle(dma_info_t *di)
18024 +{
18025 +
18026 + if (!(R_REG(&di->d64txregs->control) & D64_XC_SE))
18027 + return 0;
18028 +
18029 + if ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == D64_XS0_XS_IDLE)
18030 + return 1;
18031 +
18032 + return 0;
18033 +}
18034 +
18035 +/*
18036 + * supports full 32bit dma engine buffer addressing so
18037 + * dma buffers can cross 4 Kbyte page boundaries.
18038 + */
18039 +static int
18040 +dma64_txfast(dma_info_t *di, void *p0, uint32 coreflags)
18041 +{
18042 + void *p, *next;
18043 + uchar *data;
18044 + uint len;
18045 + uint txout;
18046 + uint32 flags;
18047 + uint32 pa;
18048 +
18049 + DMA_TRACE(("%s: dma_txfast\n", di->name));
18050 +
18051 + txout = di->txout;
18052 + flags = 0;
18053 +
18054 + /*
18055 + * Walk the chain of packet buffers
18056 + * allocating and initializing transmit descriptor entries.
18057 + */
18058 + for (p = p0; p; p = next) {
18059 + data = PKTDATA(di->osh, p);
18060 + len = PKTLEN(di->osh, p);
18061 + next = PKTNEXT(di->osh, p);
18062 +
18063 + /* return nonzero if out of tx descriptors */
18064 + if (NEXTTXD(txout) == di->txin)
18065 + goto outoftxd;
18066 +
18067 + if (len == 0)
18068 + continue;
18069 +
18070 + /* get physical address of buffer start */
18071 + pa = (uint32) DMA_MAP(di->osh, data, len, DMA_TX, p);
18072 +
18073 + flags = coreflags;
18074 +
18075 + if (p == p0)
18076 + flags |= D64_CTRL1_SOF;
18077 + if (next == NULL)
18078 + flags |= (D64_CTRL1_IOC | D64_CTRL1_EOF);
18079 + if (txout == (di->ntxd - 1))
18080 + flags |= D64_CTRL1_EOT;
18081 +
18082 + dma64_dd_upd(di, di->txd64, pa, txout, &flags, len);
18083 +
18084 + ASSERT(di->txp[txout] == NULL);
18085 +
18086 + txout = NEXTTXD(txout);
18087 + }
18088 +
18089 + /* if last txd eof not set, fix it */
18090 + if (!(flags & D64_CTRL1_EOF))
18091 + W_SM(&di->txd64[PREVTXD(txout)].ctrl1, BUS_SWAP32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF));
18092 +
18093 + /* save the packet */
18094 + di->txp[PREVTXD(txout)] = p0;
18095 +
18096 + /* bump the tx descriptor index */
18097 + di->txout = txout;
18098 +
18099 + /* kick the chip */
18100 + W_REG(&di->d64txregs->ptr, I2B(txout, dma64dd_t));
18101 +
18102 + /* tx flow control */
18103 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18104 +
18105 + return (0);
18106 +
18107 +outoftxd:
18108 + DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name));
18109 + PKTFREE(di->osh, p0, TRUE);
18110 + di->txavail = 0;
18111 + di->hnddma.txnobuf++;
18112 + return (-1);
18113 +}
18114 +
18115 +static void*
18116 +dma64_getnexttxp(dma_info_t *di, bool forceall)
18117 +{
18118 + uint start, end, i;
18119 + void *txp;
18120 +
18121 + DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, forceall ? "all" : ""));
18122 +
18123 + txp = NULL;
18124 +
18125 + start = di->txin;
18126 + if (forceall)
18127 + end = di->txout;
18128 + else
18129 + end = B2I(R_REG(&di->d64txregs->status0) & D64_XS0_CD_MASK, dma64dd_t);
18130 +
18131 + if ((start == 0) && (end > di->txout))
18132 + goto bogus;
18133 +
18134 + for (i = start; i != end && !txp; i = NEXTTXD(i)) {
18135 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->txd64[i].addrlow)) - di->dataoffsetlow),
18136 + (BUS_SWAP32(R_SM(&di->txd64[i].ctrl2)) & D64_CTRL2_BC_MASK), DMA_TX, di->txp[i]);
18137 +
18138 + W_SM(&di->txd64[i].addrlow, 0xdeadbeef);
18139 + W_SM(&di->txd64[i].addrhigh, 0xdeadbeef);
18140 +
18141 + txp = di->txp[i];
18142 + di->txp[i] = NULL;
18143 + }
18144 +
18145 + di->txin = i;
18146 +
18147 + /* tx flow control */
18148 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18149 +
18150 + return (txp);
18151 +
18152 +bogus:
18153 +/*
18154 + DMA_ERROR(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n",
18155 + start, end, di->txout, forceall));
18156 +*/
18157 + return (NULL);
18158 +}
18159 +
18160 +static void *
18161 +dma64_getnextrxp(dma_info_t *di, bool forceall)
18162 +{
18163 + uint i;
18164 + void *rxp;
18165 +
18166 + /* if forcing, dma engine must be disabled */
18167 + ASSERT(!forceall || !dma_rxenabled(di));
18168 +
18169 + i = di->rxin;
18170 +
18171 + /* return if no packets posted */
18172 + if (i == di->rxout)
18173 + return (NULL);
18174 +
18175 + /* ignore curr if forceall */
18176 + if (!forceall && (i == B2I(R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK, dma64dd_t)))
18177 + return (NULL);
18178 +
18179 + /* get the packet pointer that corresponds to the rx descriptor */
18180 + rxp = di->rxp[i];
18181 + ASSERT(rxp);
18182 + di->rxp[i] = NULL;
18183 +
18184 + /* clear this packet from the descriptor ring */
18185 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->rxd64[i].addrlow)) - di->dataoffsetlow),
18186 + di->rxbufsize, DMA_RX, rxp);
18187 +
18188 + W_SM(&di->rxd64[i].addrlow, 0xdeadbeef);
18189 + W_SM(&di->rxd64[i].addrhigh, 0xdeadbeef);
18190 +
18191 + di->rxin = NEXTRXD(i);
18192 +
18193 + return (rxp);
18194 +}
18195 +
18196 +static void
18197 +dma64_txrotate(di_t *di)
18198 +{
18199 + uint ad;
18200 + uint nactive;
18201 + uint rot;
18202 + uint old, new;
18203 + uint32 w;
18204 + uint first, last;
18205 +
18206 + ASSERT(dma_txsuspendedidle(di));
18207 +
18208 + nactive = dma_txactive(di);
18209 + ad = B2I((R_REG(&di->d64txregs->status1) & D64_XS1_AD_MASK), dma64dd_t);
18210 + rot = TXD(ad - di->txin);
18211 +
18212 + ASSERT(rot < di->ntxd);
18213 +
18214 + /* full-ring case is a lot harder - don't worry about this */
18215 + if (rot >= (di->ntxd - nactive)) {
18216 + DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name));
18217 + return;
18218 + }
18219 +
18220 + first = di->txin;
18221 + last = PREVTXD(di->txout);
18222 +
18223 + /* move entries starting at last and moving backwards to first */
18224 + for (old = last; old != PREVTXD(first); old = PREVTXD(old)) {
18225 + new = TXD(old + rot);
18226 +
18227 + /*
18228 + * Move the tx dma descriptor.
18229 + * EOT is set only in the last entry in the ring.
18230 + */
18231 + w = R_SM(&di->txd64[old].ctrl1) & ~D64_CTRL1_EOT;
18232 + if (new == (di->ntxd - 1))
18233 + w |= D64_CTRL1_EOT;
18234 + W_SM(&di->txd64[new].ctrl1, w);
18235 +
18236 + w = R_SM(&di->txd64[old].ctrl2);
18237 + W_SM(&di->txd64[new].ctrl2, w);
18238 +
18239 + W_SM(&di->txd64[new].addrlow, R_SM(&di->txd64[old].addrlow));
18240 + W_SM(&di->txd64[new].addrhigh, R_SM(&di->txd64[old].addrhigh));
18241 +
18242 + /* zap the old tx dma descriptor address field */
18243 + W_SM(&di->txd64[old].addrlow, 0xdeadbeef);
18244 + W_SM(&di->txd64[old].addrhigh, 0xdeadbeef);
18245 +
18246 + /* move the corresponding txp[] entry */
18247 + ASSERT(di->txp[new] == NULL);
18248 + di->txp[new] = di->txp[old];
18249 + di->txp[old] = NULL;
18250 + }
18251 +
18252 + /* update txin and txout */
18253 + di->txin = ad;
18254 + di->txout = TXD(di->txout + rot);
18255 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1;
18256 +
18257 + /* kick the chip */
18258 + W_REG(&di->d64txregs->ptr, I2B(di->txout, dma64dd_t));
18259 +}
18260 +
18261 +#endif
18262 +
18263 diff -Nur linux-2.4.32/drivers/net/hnd/linux_osl.c linux-2.4.32-brcm/drivers/net/hnd/linux_osl.c
18264 --- linux-2.4.32/drivers/net/hnd/linux_osl.c 1970-01-01 01:00:00.000000000 +0100
18265 +++ linux-2.4.32-brcm/drivers/net/hnd/linux_osl.c 2005-12-16 23:39:11.292858500 +0100
18266 @@ -0,0 +1,708 @@
18267 +/*
18268 + * Linux OS Independent Layer
18269 + *
18270 + * Copyright 2005, Broadcom Corporation
18271 + * All Rights Reserved.
18272 + *
18273 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
18274 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
18275 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
18276 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
18277 + *
18278 + * $Id$
18279 + */
18280 +
18281 +#define LINUX_OSL
18282 +
18283 +#include <typedefs.h>
18284 +#include <bcmendian.h>
18285 +#include <linux/module.h>
18286 +#include <linuxver.h>
18287 +#include <osl.h>
18288 +#include <bcmutils.h>
18289 +#include <linux/delay.h>
18290 +#ifdef mips
18291 +#include <asm/paccess.h>
18292 +#endif
18293 +#include <pcicfg.h>
18294 +
18295 +#define PCI_CFG_RETRY 10
18296 +
18297 +#define OS_HANDLE_MAGIC 0x1234abcd
18298 +#define BCM_MEM_FILENAME_LEN 24
18299 +
18300 +typedef struct bcm_mem_link {
18301 + struct bcm_mem_link *prev;
18302 + struct bcm_mem_link *next;
18303 + uint size;
18304 + int line;
18305 + char file[BCM_MEM_FILENAME_LEN];
18306 +} bcm_mem_link_t;
18307 +
18308 +struct os_handle {
18309 + uint magic;
18310 + void *pdev;
18311 + uint malloced;
18312 + uint failed;
18313 + bcm_mem_link_t *dbgmem_list;
18314 +};
18315 +
18316 +static int16 linuxbcmerrormap[] = \
18317 +{ 0, /* 0 */
18318 + -EINVAL, /* BCME_ERROR */
18319 + -EINVAL, /* BCME_BADARG*/
18320 + -EINVAL, /* BCME_BADOPTION*/
18321 + -EINVAL, /* BCME_NOTUP */
18322 + -EINVAL, /* BCME_NOTDOWN */
18323 + -EINVAL, /* BCME_NOTAP */
18324 + -EINVAL, /* BCME_NOTSTA */
18325 + -EINVAL, /* BCME_BADKEYIDX */
18326 + -EINVAL, /* BCME_RADIOOFF */
18327 + -EINVAL, /* BCME_NOTBANDLOCKED */
18328 + -EINVAL, /* BCME_NOCLK */
18329 + -EINVAL, /* BCME_BADRATESET */
18330 + -EINVAL, /* BCME_BADBAND */
18331 + -E2BIG, /* BCME_BUFTOOSHORT */
18332 + -E2BIG, /* BCME_BUFTOOLONG */
18333 + -EBUSY, /* BCME_BUSY */
18334 + -EINVAL, /* BCME_NOTASSOCIATED */
18335 + -EINVAL, /* BCME_BADSSIDLEN */
18336 + -EINVAL, /* BCME_OUTOFRANGECHAN */
18337 + -EINVAL, /* BCME_BADCHAN */
18338 + -EFAULT, /* BCME_BADADDR */
18339 + -ENOMEM, /* BCME_NORESOURCE */
18340 + -EOPNOTSUPP, /* BCME_UNSUPPORTED */
18341 + -EMSGSIZE, /* BCME_BADLENGTH */
18342 + -EINVAL, /* BCME_NOTREADY */
18343 + -EPERM, /* BCME_NOTPERMITTED */
18344 + -ENOMEM, /* BCME_NOMEM */
18345 + -EINVAL, /* BCME_ASSOCIATED */
18346 + -ERANGE, /* BCME_RANGE */
18347 + -EINVAL /* BCME_NOTFOUND */
18348 +};
18349 +
18350 +/* translate bcmerrors into linux errors*/
18351 +int
18352 +osl_error(int bcmerror)
18353 +{
18354 + int abs_bcmerror;
18355 + int array_size = ARRAYSIZE(linuxbcmerrormap);
18356 +
18357 + abs_bcmerror = ABS(bcmerror);
18358 +
18359 + if (bcmerror > 0)
18360 + abs_bcmerror = 0;
18361 +
18362 + else if (abs_bcmerror >= array_size)
18363 + abs_bcmerror = BCME_ERROR;
18364 +
18365 + return linuxbcmerrormap[abs_bcmerror];
18366 +}
18367 +
18368 +osl_t *
18369 +osl_attach(void *pdev)
18370 +{
18371 + osl_t *osh;
18372 +
18373 + osh = kmalloc(sizeof(osl_t), GFP_ATOMIC);
18374 + ASSERT(osh);
18375 +
18376 + /*
18377 + * check the cases where
18378 + * 1.Error code Added to bcmerror table, but forgot to add it to the OS
18379 + * dependent error code
18380 + * 2. Error code is added to the bcmerror table, but forgot to add the
18381 + * corresponding errorstring(dummy call to bcmerrorstr)
18382 + */
18383 + bcmerrorstr(0);
18384 + ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1));
18385 +
18386 + osh->magic = OS_HANDLE_MAGIC;
18387 + osh->malloced = 0;
18388 + osh->failed = 0;
18389 + osh->dbgmem_list = NULL;
18390 + osh->pdev = pdev;
18391 +
18392 + return osh;
18393 +}
18394 +
18395 +void
18396 +osl_detach(osl_t *osh)
18397 +{
18398 + ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC));
18399 + kfree(osh);
18400 +}
18401 +
18402 +void*
18403 +osl_pktget(osl_t *osh, uint len, bool send)
18404 +{
18405 + struct sk_buff *skb;
18406 +
18407 + if ((skb = dev_alloc_skb(len)) == NULL)
18408 + return (NULL);
18409 +
18410 + skb_put(skb, len);
18411 +
18412 + /* ensure the cookie field is cleared */
18413 + PKTSETCOOKIE(skb, NULL);
18414 +
18415 + return ((void*) skb);
18416 +}
18417 +
18418 +void
18419 +osl_pktfree(void *p)
18420 +{
18421 + struct sk_buff *skb, *nskb;
18422 +
18423 + skb = (struct sk_buff*) p;
18424 +
18425 + /* perversion: we use skb->next to chain multi-skb packets */
18426 + while (skb) {
18427 + nskb = skb->next;
18428 + skb->next = NULL;
18429 + if (skb->destructor) {
18430 + /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if destructor exists */
18431 + dev_kfree_skb_any(skb);
18432 + } else {
18433 + /* can free immediately (even in_irq()) if destructor does not exist */
18434 + dev_kfree_skb(skb);
18435 + }
18436 + skb = nskb;
18437 + }
18438 +}
18439 +
18440 +uint32
18441 +osl_pci_read_config(osl_t *osh, uint offset, uint size)
18442 +{
18443 + uint val;
18444 + uint retry=PCI_CFG_RETRY;
18445 +
18446 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18447 +
18448 + /* only 4byte access supported */
18449 + ASSERT(size == 4);
18450 +
18451 + do {
18452 + pci_read_config_dword(osh->pdev, offset, &val);
18453 + if (val != 0xffffffff)
18454 + break;
18455 + } while (retry--);
18456 +
18457 +
18458 + return (val);
18459 +}
18460 +
18461 +void
18462 +osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val)
18463 +{
18464 + uint retry=PCI_CFG_RETRY;
18465 +
18466 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18467 +
18468 + /* only 4byte access supported */
18469 + ASSERT(size == 4);
18470 +
18471 + do {
18472 + pci_write_config_dword(osh->pdev, offset, val);
18473 + if (offset!=PCI_BAR0_WIN)
18474 + break;
18475 + if (osl_pci_read_config(osh,offset,size) == val)
18476 + break;
18477 + } while (retry--);
18478 +
18479 +}
18480 +
18481 +/* return bus # for the pci device pointed by osh->pdev */
18482 +uint
18483 +osl_pci_bus(osl_t *osh)
18484 +{
18485 + ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev);
18486 +
18487 + return ((struct pci_dev *)osh->pdev)->bus->number;
18488 +}
18489 +
18490 +/* return slot # for the pci device pointed by osh->pdev */
18491 +uint
18492 +osl_pci_slot(osl_t *osh)
18493 +{
18494 + ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev);
18495 +
18496 + return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn);
18497 +}
18498 +
18499 +static void
18500 +osl_pcmcia_attr(osl_t *osh, uint offset, char *buf, int size, bool write)
18501 +{
18502 +}
18503 +
18504 +void
18505 +osl_pcmcia_read_attr(osl_t *osh, uint offset, void *buf, int size)
18506 +{
18507 + osl_pcmcia_attr(osh, offset, (char *) buf, size, FALSE);
18508 +}
18509 +
18510 +void
18511 +osl_pcmcia_write_attr(osl_t *osh, uint offset, void *buf, int size)
18512 +{
18513 + osl_pcmcia_attr(osh, offset, (char *) buf, size, TRUE);
18514 +}
18515 +
18516 +
18517 +#ifdef BCMDBG_MEM
18518 +
18519 +void*
18520 +osl_debug_malloc(osl_t *osh, uint size, int line, char* file)
18521 +{
18522 + bcm_mem_link_t *p;
18523 + char* basename;
18524 +
18525 + ASSERT(size);
18526 +
18527 + if ((p = (bcm_mem_link_t*)osl_malloc(osh, sizeof(bcm_mem_link_t) + size)) == NULL)
18528 + return (NULL);
18529 +
18530 + p->size = size;
18531 + p->line = line;
18532 +
18533 + basename = strrchr(file, '/');
18534 + /* skip the '/' */
18535 + if (basename)
18536 + basename++;
18537 +
18538 + if (!basename)
18539 + basename = file;
18540 +
18541 + strncpy(p->file, basename, BCM_MEM_FILENAME_LEN);
18542 + p->file[BCM_MEM_FILENAME_LEN - 1] = '\0';
18543 +
18544 + /* link this block */
18545 + p->prev = NULL;
18546 + p->next = osh->dbgmem_list;
18547 + if (p->next)
18548 + p->next->prev = p;
18549 + osh->dbgmem_list = p;
18550 +
18551 + return p + 1;
18552 +}
18553 +
18554 +void
18555 +osl_debug_mfree(osl_t *osh, void *addr, uint size, int line, char* file)
18556 +{
18557 + bcm_mem_link_t *p = (bcm_mem_link_t *)((int8*)addr - sizeof(bcm_mem_link_t));
18558 +
18559 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18560 +
18561 + if (p->size == 0) {
18562 + printk("osl_debug_mfree: double free on addr 0x%x size %d at line %d file %s\n",
18563 + (uint)addr, size, line, file);
18564 + ASSERT(p->size);
18565 + return;
18566 + }
18567 +
18568 + if (p->size != size) {
18569 + printk("osl_debug_mfree: dealloc size %d does not match alloc size %d on addr 0x%x at line %d file %s\n",
18570 + size, p->size, (uint)addr, line, file);
18571 + ASSERT(p->size == size);
18572 + return;
18573 + }
18574 +
18575 + /* unlink this block */
18576 + if (p->prev)
18577 + p->prev->next = p->next;
18578 + if (p->next)
18579 + p->next->prev = p->prev;
18580 + if (osh->dbgmem_list == p)
18581 + osh->dbgmem_list = p->next;
18582 + p->next = p->prev = NULL;
18583 +
18584 + osl_mfree(osh, p, size + sizeof(bcm_mem_link_t));
18585 +}
18586 +
18587 +char*
18588 +osl_debug_memdump(osl_t *osh, char *buf, uint sz)
18589 +{
18590 + bcm_mem_link_t *p;
18591 + char *obuf;
18592 +
18593 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18594 + obuf = buf;
18595 +
18596 + buf += sprintf(buf, " Address\tSize\tFile:line\n");
18597 + for (p = osh->dbgmem_list; p && ((buf - obuf) < (sz - 128)); p = p->next)
18598 + buf += sprintf(buf, "0x%08x\t%5d\t%s:%d\n",
18599 + (int)p + sizeof(bcm_mem_link_t), p->size, p->file, p->line);
18600 +
18601 + return (obuf);
18602 +}
18603 +
18604 +#endif /* BCMDBG_MEM */
18605 +
18606 +void*
18607 +osl_malloc(osl_t *osh, uint size)
18608 +{
18609 + void *addr;
18610 +
18611 + /* only ASSERT if osh is defined */
18612 + if (osh)
18613 + ASSERT(osh->magic == OS_HANDLE_MAGIC);
18614 +
18615 + if ((addr = kmalloc(size, GFP_ATOMIC)) == NULL) {
18616 + if(osh)
18617 + osh->failed++;
18618 + return (NULL);
18619 + }
18620 + if (osh)
18621 + osh->malloced += size;
18622 +
18623 + return (addr);
18624 +}
18625 +
18626 +void
18627 +osl_mfree(osl_t *osh, void *addr, uint size)
18628 +{
18629 + if (osh) {
18630 + ASSERT(osh->magic == OS_HANDLE_MAGIC);
18631 + osh->malloced -= size;
18632 + }
18633 + kfree(addr);
18634 +}
18635 +
18636 +uint
18637 +osl_malloced(osl_t *osh)
18638 +{
18639 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18640 + return (osh->malloced);
18641 +}
18642 +
18643 +uint osl_malloc_failed(osl_t *osh)
18644 +{
18645 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18646 + return (osh->failed);
18647 +}
18648 +
18649 +void*
18650 +osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap)
18651 +{
18652 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18653 +
18654 + return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap));
18655 +}
18656 +
18657 +void
18658 +osl_dma_free_consistent(osl_t *osh, void *va, uint size, ulong pa)
18659 +{
18660 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18661 +
18662 + pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
18663 +}
18664 +
18665 +uint
18666 +osl_dma_map(osl_t *osh, void *va, uint size, int direction)
18667 +{
18668 + int dir;
18669 +
18670 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18671 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
18672 + return (pci_map_single(osh->pdev, va, size, dir));
18673 +}
18674 +
18675 +void
18676 +osl_dma_unmap(osl_t *osh, uint pa, uint size, int direction)
18677 +{
18678 + int dir;
18679 +
18680 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
18681 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
18682 + pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
18683 +}
18684 +
18685 +#if defined(BINOSL)
18686 +void
18687 +osl_assert(char *exp, char *file, int line)
18688 +{
18689 + char tempbuf[255];
18690 +
18691 + sprintf(tempbuf, "assertion \"%s\" failed: file \"%s\", line %d\n", exp, file, line);
18692 + panic(tempbuf);
18693 +}
18694 +#endif /* BCMDBG || BINOSL */
18695 +
18696 +void
18697 +osl_delay(uint usec)
18698 +{
18699 + uint d;
18700 +
18701 + while (usec > 0) {
18702 + d = MIN(usec, 1000);
18703 + udelay(d);
18704 + usec -= d;
18705 + }
18706 +}
18707 +
18708 +/*
18709 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
18710 + */
18711 +#ifdef BINOSL
18712 +
18713 +int
18714 +osl_printf(const char *format, ...)
18715 +{
18716 + va_list args;
18717 + char buf[1024];
18718 + int len;
18719 +
18720 + /* sprintf into a local buffer because there *is* no "vprintk()".. */
18721 + va_start(args, format);
18722 + len = vsprintf(buf, format, args);
18723 + va_end(args);
18724 +
18725 + if (len > sizeof (buf)) {
18726 + printk("osl_printf: buffer overrun\n");
18727 + return (0);
18728 + }
18729 +
18730 + return (printk(buf));
18731 +}
18732 +
18733 +int
18734 +osl_sprintf(char *buf, const char *format, ...)
18735 +{
18736 + va_list args;
18737 + int rc;
18738 +
18739 + va_start(args, format);
18740 + rc = vsprintf(buf, format, args);
18741 + va_end(args);
18742 + return (rc);
18743 +}
18744 +
18745 +int
18746 +osl_strcmp(const char *s1, const char *s2)
18747 +{
18748 + return (strcmp(s1, s2));
18749 +}
18750 +
18751 +int
18752 +osl_strncmp(const char *s1, const char *s2, uint n)
18753 +{
18754 + return (strncmp(s1, s2, n));
18755 +}
18756 +
18757 +int
18758 +osl_strlen(const char *s)
18759 +{
18760 + return (strlen(s));
18761 +}
18762 +
18763 +char*
18764 +osl_strcpy(char *d, const char *s)
18765 +{
18766 + return (strcpy(d, s));
18767 +}
18768 +
18769 +char*
18770 +osl_strncpy(char *d, const char *s, uint n)
18771 +{
18772 + return (strncpy(d, s, n));
18773 +}
18774 +
18775 +void
18776 +bcopy(const void *src, void *dst, int len)
18777 +{
18778 + memcpy(dst, src, len);
18779 +}
18780 +
18781 +int
18782 +bcmp(const void *b1, const void *b2, int len)
18783 +{
18784 + return (memcmp(b1, b2, len));
18785 +}
18786 +
18787 +void
18788 +bzero(void *b, int len)
18789 +{
18790 + memset(b, '\0', len);
18791 +}
18792 +
18793 +uint32
18794 +osl_readl(volatile uint32 *r)
18795 +{
18796 + return (readl(r));
18797 +}
18798 +
18799 +uint16
18800 +osl_readw(volatile uint16 *r)
18801 +{
18802 + return (readw(r));
18803 +}
18804 +
18805 +uint8
18806 +osl_readb(volatile uint8 *r)
18807 +{
18808 + return (readb(r));
18809 +}
18810 +
18811 +void
18812 +osl_writel(uint32 v, volatile uint32 *r)
18813 +{
18814 + writel(v, r);
18815 +}
18816 +
18817 +void
18818 +osl_writew(uint16 v, volatile uint16 *r)
18819 +{
18820 + writew(v, r);
18821 +}
18822 +
18823 +void
18824 +osl_writeb(uint8 v, volatile uint8 *r)
18825 +{
18826 + writeb(v, r);
18827 +}
18828 +
18829 +void *
18830 +osl_uncached(void *va)
18831 +{
18832 +#ifdef mips
18833 + return ((void*)KSEG1ADDR(va));
18834 +#else
18835 + return ((void*)va);
18836 +#endif
18837 +}
18838 +
18839 +uint
18840 +osl_getcycles(void)
18841 +{
18842 + uint cycles;
18843 +
18844 +#if defined(mips)
18845 + cycles = read_c0_count() * 2;
18846 +#elif defined(__i386__)
18847 + rdtscl(cycles);
18848 +#else
18849 + cycles = 0;
18850 +#endif
18851 + return cycles;
18852 +}
18853 +
18854 +void *
18855 +osl_reg_map(uint32 pa, uint size)
18856 +{
18857 + return (ioremap_nocache((unsigned long)pa, (unsigned long)size));
18858 +}
18859 +
18860 +void
18861 +osl_reg_unmap(void *va)
18862 +{
18863 + iounmap(va);
18864 +}
18865 +
18866 +int
18867 +osl_busprobe(uint32 *val, uint32 addr)
18868 +{
18869 +#ifdef mips
18870 + return get_dbe(*val, (uint32*)addr);
18871 +#else
18872 + *val = readl(addr);
18873 + return 0;
18874 +#endif
18875 +}
18876 +
18877 +uchar*
18878 +osl_pktdata(osl_t *osh, void *skb)
18879 +{
18880 + return (((struct sk_buff*)skb)->data);
18881 +}
18882 +
18883 +uint
18884 +osl_pktlen(osl_t *osh, void *skb)
18885 +{
18886 + return (((struct sk_buff*)skb)->len);
18887 +}
18888 +
18889 +uint
18890 +osl_pktheadroom(osl_t *osh, void *skb)
18891 +{
18892 + return (uint) skb_headroom((struct sk_buff *) skb);
18893 +}
18894 +
18895 +uint
18896 +osl_pkttailroom(osl_t *osh, void *skb)
18897 +{
18898 + return (uint) skb_tailroom((struct sk_buff *) skb);
18899 +}
18900 +
18901 +void*
18902 +osl_pktnext(osl_t *osh, void *skb)
18903 +{
18904 + return (((struct sk_buff*)skb)->next);
18905 +}
18906 +
18907 +void
18908 +osl_pktsetnext(void *skb, void *x)
18909 +{
18910 + ((struct sk_buff*)skb)->next = (struct sk_buff*)x;
18911 +}
18912 +
18913 +void
18914 +osl_pktsetlen(osl_t *osh, void *skb, uint len)
18915 +{
18916 + __skb_trim((struct sk_buff*)skb, len);
18917 +}
18918 +
18919 +uchar*
18920 +osl_pktpush(osl_t *osh, void *skb, int bytes)
18921 +{
18922 + return (skb_push((struct sk_buff*)skb, bytes));
18923 +}
18924 +
18925 +uchar*
18926 +osl_pktpull(osl_t *osh, void *skb, int bytes)
18927 +{
18928 + return (skb_pull((struct sk_buff*)skb, bytes));
18929 +}
18930 +
18931 +void*
18932 +osl_pktdup(osl_t *osh, void *skb)
18933 +{
18934 + return (skb_clone((struct sk_buff*)skb, GFP_ATOMIC));
18935 +}
18936 +
18937 +void*
18938 +osl_pktcookie(void *skb)
18939 +{
18940 + return ((void*)((struct sk_buff*)skb)->csum);
18941 +}
18942 +
18943 +void
18944 +osl_pktsetcookie(void *skb, void *x)
18945 +{
18946 + ((struct sk_buff*)skb)->csum = (uint)x;
18947 +}
18948 +
18949 +void*
18950 +osl_pktlink(void *skb)
18951 +{
18952 + return (((struct sk_buff*)skb)->prev);
18953 +}
18954 +
18955 +void
18956 +osl_pktsetlink(void *skb, void *x)
18957 +{
18958 + ((struct sk_buff*)skb)->prev = (struct sk_buff*)x;
18959 +}
18960 +
18961 +uint
18962 +osl_pktprio(void *skb)
18963 +{
18964 + return (((struct sk_buff*)skb)->priority);
18965 +}
18966 +
18967 +void
18968 +osl_pktsetprio(void *skb, uint x)
18969 +{
18970 + ((struct sk_buff*)skb)->priority = x;
18971 +}
18972 +
18973 +
18974 +#endif /* BINOSL */
18975 diff -Nur linux-2.4.32/drivers/net/hnd/Makefile linux-2.4.32-brcm/drivers/net/hnd/Makefile
18976 --- linux-2.4.32/drivers/net/hnd/Makefile 1970-01-01 01:00:00.000000000 +0100
18977 +++ linux-2.4.32-brcm/drivers/net/hnd/Makefile 2005-12-16 23:39:11.284858000 +0100
18978 @@ -0,0 +1,19 @@
18979 +#
18980 +# Makefile for the BCM47xx specific kernel interface routines
18981 +# under Linux.
18982 +#
18983 +
18984 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
18985 +
18986 +O_TARGET := hnd.o
18987 +
18988 +HND_OBJS := bcmutils.o hnddma.o linux_osl.o sbutils.o bcmsrom.o
18989 +
18990 +export-objs := shared_ksyms.o
18991 +obj-y := shared_ksyms.o $(HND_OBJS)
18992 +obj-m := $(O_TARGET)
18993 +
18994 +include $(TOPDIR)/Rules.make
18995 +
18996 +shared_ksyms.c: shared_ksyms.sh $(HND_OBJS)
18997 + sh -e $< $(HND_OBJS) > $@
18998 diff -Nur linux-2.4.32/drivers/net/hnd/sbutils.c linux-2.4.32-brcm/drivers/net/hnd/sbutils.c
18999 --- linux-2.4.32/drivers/net/hnd/sbutils.c 1970-01-01 01:00:00.000000000 +0100
19000 +++ linux-2.4.32-brcm/drivers/net/hnd/sbutils.c 2005-12-16 23:39:11.316860000 +0100
19001 @@ -0,0 +1,2837 @@
19002 +/*
19003 + * Misc utility routines for accessing chip-specific features
19004 + * of the SiliconBackplane-based Broadcom chips.
19005 + *
19006 + * Copyright 2005, Broadcom Corporation
19007 + * All Rights Reserved.
19008 + *
19009 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
19010 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
19011 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
19012 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
19013 + * $Id$
19014 + */
19015 +
19016 +#include <typedefs.h>
19017 +#include <osl.h>
19018 +#include <sbutils.h>
19019 +#include <bcmutils.h>
19020 +#include <bcmdevs.h>
19021 +#include <sbconfig.h>
19022 +#include <sbchipc.h>
19023 +#include <sbpci.h>
19024 +#include <sbpcie.h>
19025 +#include <pcicfg.h>
19026 +#include <sbpcmcia.h>
19027 +#include <sbextif.h>
19028 +#include <bcmsrom.h>
19029 +
19030 +/* debug/trace */
19031 +#define SB_ERROR(args)
19032 +
19033 +
19034 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg);
19035 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg);
19036 +typedef bool (*sb_intrsenabled_t)(void *intr_arg);
19037 +
19038 +/* misc sb info needed by some of the routines */
19039 +typedef struct sb_info {
19040 +
19041 + struct sb_pub sb; /* back plane public state(must be first field of sb_info */
19042 +
19043 + void *osh; /* osl os handle */
19044 + void *sdh; /* bcmsdh handle */
19045 +
19046 + void *curmap; /* current regs va */
19047 + void *regs[SB_MAXCORES]; /* other regs va */
19048 +
19049 + uint curidx; /* current core index */
19050 + uint dev_coreid; /* the core provides driver functions */
19051 +
19052 + bool memseg; /* flag to toggle MEM_SEG register */
19053 +
19054 + uint gpioidx; /* gpio control core index */
19055 + uint gpioid; /* gpio control coretype */
19056 +
19057 + uint numcores; /* # discovered cores */
19058 + uint coreid[SB_MAXCORES]; /* id of each core */
19059 +
19060 + void *intr_arg; /* interrupt callback function arg */
19061 + sb_intrsoff_t intrsoff_fn; /* function turns chip interrupts off */
19062 + sb_intrsrestore_t intrsrestore_fn; /* function restore chip interrupts */
19063 + sb_intrsenabled_t intrsenabled_fn; /* function to check if chip interrupts are enabled */
19064 +
19065 +} sb_info_t;
19066 +
19067 +/* local prototypes */
19068 +static sb_info_t * BCMINIT(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
19069 + uint bustype, void *sdh, char **vars, int *varsz);
19070 +static void BCMINIT(sb_scan)(sb_info_t *si);
19071 +static uint sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val);
19072 +static uint _sb_coreidx(sb_info_t *si);
19073 +static uint sb_findcoreidx(sb_info_t *si, uint coreid, uint coreunit);
19074 +static uint BCMINIT(sb_pcidev2chip)(uint pcidev);
19075 +static uint BCMINIT(sb_chip2numcores)(uint chip);
19076 +static bool sb_ispcie(sb_info_t *si);
19077 +static bool sb_find_pci_capability(sb_info_t *si, uint8 req_cap_id, uchar *buf, uint32 *buflen);
19078 +static int sb_pci_fixcfg(sb_info_t *si);
19079 +
19080 +/* routines to access mdio slave device registers */
19081 +static int sb_pcie_mdiowrite(sb_info_t *si, uint physmedia, uint readdr, uint val);
19082 +static void BCMINIT(sb_war30841)(sb_info_t *si);
19083 +
19084 +/* delay needed between the mdio control/ mdiodata register data access */
19085 +#define PR28829_DELAY() OSL_DELAY(10)
19086 +
19087 +
19088 +/* global variable to indicate reservation/release of gpio's*/
19089 +static uint32 sb_gpioreservation = 0;
19090 +
19091 +#define SB_INFO(sbh) (sb_info_t*)sbh
19092 +#define SET_SBREG(sbh, r, mask, val) W_SBREG((sbh), (r), ((R_SBREG((sbh), (r)) & ~(mask)) | (val)))
19093 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && ISALIGNED((x), SB_CORE_SIZE))
19094 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE))
19095 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF)
19096 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES)
19097 +#define BADIDX (SB_MAXCORES+1)
19098 +#define NOREV -1
19099 +
19100 +#define PCI(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCI))
19101 +#define PCIE(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCIE))
19102 +
19103 +/* sonicsrev */
19104 +#define SONICS_2_2 (SBIDL_RV_2_2 >> SBIDL_RV_SHIFT)
19105 +#define SONICS_2_3 (SBIDL_RV_2_3 >> SBIDL_RV_SHIFT)
19106 +
19107 +#define R_SBREG(sbh, sbr) sb_read_sbreg((sbh), (sbr))
19108 +#define W_SBREG(sbh, sbr, v) sb_write_sbreg((sbh), (sbr), (v))
19109 +#define AND_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) & (v)))
19110 +#define OR_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) | (v)))
19111 +
19112 +/*
19113 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/
19114 + * after core switching to avoid invalid register accesss inside ISR.
19115 + */
19116 +#define INTR_OFF(si, intr_val) \
19117 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
19118 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); }
19119 +#define INTR_RESTORE(si, intr_val) \
19120 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
19121 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
19122 +
19123 +/* dynamic clock control defines */
19124 +#define LPOMINFREQ 25000 /* low power oscillator min */
19125 +#define LPOMAXFREQ 43000 /* low power oscillator max */
19126 +#define XTALMINFREQ 19800000 /* 20 MHz - 1% */
19127 +#define XTALMAXFREQ 20200000 /* 20 MHz + 1% */
19128 +#define PCIMINFREQ 25000000 /* 25 MHz */
19129 +#define PCIMAXFREQ 34000000 /* 33 MHz + fudge */
19130 +
19131 +#define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */
19132 +#define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */
19133 +
19134 +#define MIN_DUMPBUFLEN 32 /* debug */
19135 +
19136 +/* different register spaces to access thr'u pcie indirect access*/
19137 +#define PCIE_CONFIGREGS 1
19138 +#define PCIE_PCIEREGS 2
19139 +
19140 +/* GPIO Based LED powersave defines */
19141 +#define DEFAULT_GPIO_ONTIME 10
19142 +#define DEFAULT_GPIO_OFFTIME 90
19143 +
19144 +#define DEFAULT_GPIOTIMERVAL ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME)
19145 +
19146 +static uint32
19147 +sb_read_sbreg(sb_info_t *si, volatile uint32 *sbr)
19148 +{
19149 + uint8 tmp;
19150 + uint32 val, intr_val = 0;
19151 +
19152 +
19153 + /*
19154 + * compact flash only has 11 bits address, while we needs 12 bits address.
19155 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
19156 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
19157 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
19158 + */
19159 + if(si->memseg) {
19160 + INTR_OFF(si, intr_val);
19161 + tmp = 1;
19162 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19163 + sbr = (uint32) ((uintptr) sbr & ~(1 << 11)); /* mask out bit 11*/
19164 + }
19165 +
19166 + val = R_REG(sbr);
19167 +
19168 + if(si->memseg) {
19169 + tmp = 0;
19170 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19171 + INTR_RESTORE(si, intr_val);
19172 + }
19173 +
19174 + return (val);
19175 +}
19176 +
19177 +static void
19178 +sb_write_sbreg(sb_info_t *si, volatile uint32 *sbr, uint32 v)
19179 +{
19180 + uint8 tmp;
19181 + volatile uint32 dummy;
19182 + uint32 intr_val = 0;
19183 +
19184 +
19185 + /*
19186 + * compact flash only has 11 bits address, while we needs 12 bits address.
19187 + * MEM_SEG will be OR'd with other 11 bits address in hardware,
19188 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters).
19189 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special
19190 + */
19191 + if(si->memseg) {
19192 + INTR_OFF(si, intr_val);
19193 + tmp = 1;
19194 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19195 + sbr = (uint32) ((uintptr) sbr & ~(1 << 11)); /* mask out bit 11*/
19196 + }
19197 +
19198 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) {
19199 +#ifdef IL_BIGENDIAN
19200 + dummy = R_REG(sbr);
19201 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
19202 + dummy = R_REG(sbr);
19203 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
19204 +#else
19205 + dummy = R_REG(sbr);
19206 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff));
19207 + dummy = R_REG(sbr);
19208 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff));
19209 +#endif
19210 + } else
19211 + W_REG(sbr, v);
19212 +
19213 + if(si->memseg) {
19214 + tmp = 0;
19215 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1);
19216 + INTR_RESTORE(si, intr_val);
19217 + }
19218 +}
19219 +
19220 +/*
19221 + * Allocate a sb handle.
19222 + * devid - pci device id (used to determine chip#)
19223 + * osh - opaque OS handle
19224 + * regs - virtual address of initial core registers
19225 + * bustype - pci/pcmcia/sb/sdio/etc
19226 + * vars - pointer to a pointer area for "environment" variables
19227 + * varsz - pointer to int to return the size of the vars
19228 + */
19229 +sb_t *
19230 +BCMINITFN(sb_attach)(uint devid, osl_t *osh, void *regs,
19231 + uint bustype, void *sdh, char **vars, int *varsz)
19232 +{
19233 + sb_info_t *si;
19234 +
19235 + /* alloc sb_info_t */
19236 + if ((si = MALLOC(osh, sizeof (sb_info_t))) == NULL) {
19237 + SB_ERROR(("sb_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh)));
19238 + return (NULL);
19239 + }
19240 +
19241 + if (BCMINIT(sb_doattach)(si, devid, osh, regs, bustype, sdh, vars, varsz) == NULL) {
19242 + MFREE(osh, si, sizeof (sb_info_t));
19243 + return (NULL);
19244 + }
19245 + return (sb_t *)si;
19246 +}
19247 +
19248 +/* Using sb_kattach depends on SB_BUS support, either implicit */
19249 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */
19250 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS)
19251 +
19252 +/* global kernel resource */
19253 +static sb_info_t ksi;
19254 +
19255 +/* generic kernel variant of sb_attach() */
19256 +sb_t *
19257 +BCMINITFN(sb_kattach)()
19258 +{
19259 + uint32 *regs;
19260 +
19261 + if (ksi.curmap == NULL) {
19262 + uint32 cid;
19263 +
19264 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE);
19265 + cid = R_REG((uint32 *)regs);
19266 + if (((cid & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
19267 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) &&
19268 + ((cid & CID_REV_MASK) <= (3 << CID_REV_SHIFT))) {
19269 + uint32 *scc, val;
19270 +
19271 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl));
19272 + val = R_REG(scc);
19273 + SB_ERROR((" initial scc = 0x%x\n", val));
19274 + val |= SCC_SS_XTAL;
19275 + W_REG(scc, val);
19276 + }
19277 +
19278 + if (BCMINIT(sb_doattach)(&ksi, BCM4710_DEVICE_ID, NULL, (void*)regs,
19279 + SB_BUS, NULL, NULL, NULL) == NULL) {
19280 + return NULL;
19281 + }
19282 + }
19283 +
19284 + return (sb_t *)&ksi;
19285 +}
19286 +#endif
19287 +
19288 +static sb_info_t *
19289 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
19290 + uint bustype, void *sdh, char **vars, int *varsz)
19291 +{
19292 + uint origidx;
19293 + chipcregs_t *cc;
19294 + sbconfig_t *sb;
19295 + uint32 w;
19296 +
19297 + ASSERT(GOODREGS(regs));
19298 +
19299 + bzero((uchar*)si, sizeof (sb_info_t));
19300 +
19301 + si->sb.buscoreidx = si->gpioidx = BADIDX;
19302 +
19303 + si->osh = osh;
19304 + si->curmap = regs;
19305 + si->sdh = sdh;
19306 +
19307 + /* check to see if we are a sb core mimic'ing a pci core */
19308 + if (bustype == PCI_BUS) {
19309 + if (OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof (uint32)) == 0xffffffff)
19310 + bustype = SB_BUS;
19311 + else
19312 + bustype = PCI_BUS;
19313 + }
19314 +
19315 + si->sb.bustype = bustype;
19316 + if (si->sb.bustype != BUSTYPE(si->sb.bustype)) {
19317 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n",
19318 + si->sb.bustype, BUSTYPE(si->sb.bustype)));
19319 + return NULL;
19320 + }
19321 +
19322 + /* need to set memseg flag for CF card first before any sb registers access */
19323 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS)
19324 + si->memseg = TRUE;
19325 +
19326 + /* kludge to enable the clock on the 4306 which lacks a slowclock */
19327 + if (BUSTYPE(si->sb.bustype) == PCI_BUS)
19328 + sb_clkctl_xtal(&si->sb, XTAL|PLL, ON);
19329 +
19330 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
19331 + w = OSL_PCI_READ_CONFIG(osh, PCI_BAR0_WIN, sizeof (uint32));
19332 + if (!GOODCOREADDR(w))
19333 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32), SB_ENUM_BASE);
19334 + }
19335 +
19336 + /* initialize current core index value */
19337 + si->curidx = _sb_coreidx(si);
19338 +
19339 + if (si->curidx == BADIDX) {
19340 + SB_ERROR(("sb_doattach: bad core index\n"));
19341 + return NULL;
19342 + }
19343 +
19344 + /* get sonics backplane revision */
19345 + sb = REGS2SB(si->curmap);
19346 + si->sb.sonicsrev = (R_SBREG(si, &(sb)->sbidlow) & SBIDL_RV_MASK) >> SBIDL_RV_SHIFT;
19347 +
19348 + /* keep and reuse the initial register mapping */
19349 + origidx = si->curidx;
19350 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
19351 + si->regs[origidx] = regs;
19352 +
19353 + /* is core-0 a chipcommon core? */
19354 + si->numcores = 1;
19355 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, 0);
19356 + if (sb_coreid(&si->sb) != SB_CC)
19357 + cc = NULL;
19358 +
19359 + /* determine chip id and rev */
19360 + if (cc) {
19361 + /* chip common core found! */
19362 + si->sb.chip = R_REG(&cc->chipid) & CID_ID_MASK;
19363 + si->sb.chiprev = (R_REG(&cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT;
19364 + si->sb.chippkg = (R_REG(&cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT;
19365 + } else {
19366 + /* The only pcmcia chip without a chipcommon core is a 4301 */
19367 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS)
19368 + devid = BCM4301_DEVICE_ID;
19369 +
19370 + /* no chip common core -- must convert device id to chip id */
19371 + if ((si->sb.chip = BCMINIT(sb_pcidev2chip)(devid)) == 0) {
19372 + SB_ERROR(("sb_doattach: unrecognized device id 0x%04x\n", devid));
19373 + sb_setcoreidx(&si->sb, origidx);
19374 + return NULL;
19375 + }
19376 + }
19377 +
19378 + /* get chipcommon rev */
19379 + si->sb.ccrev = cc ? (int)sb_corerev(&si->sb) : NOREV;
19380 +
19381 + /* determine numcores */
19382 + if (cc && ((si->sb.ccrev == 4) || (si->sb.ccrev >= 6)))
19383 + si->numcores = (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT;
19384 + else
19385 + si->numcores = BCMINIT(sb_chip2numcores)(si->sb.chip);
19386 +
19387 + /* return to original core */
19388 + sb_setcoreidx(&si->sb, origidx);
19389 +
19390 + /* sanity checks */
19391 + ASSERT(si->sb.chip);
19392 +
19393 + /* scan for cores */
19394 + BCMINIT(sb_scan)(si);
19395 +
19396 + /* fixup necessary chip/core configurations */
19397 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
19398 + if (sb_pci_fixcfg(si)) {
19399 + SB_ERROR(("sb_doattach: sb_pci_fixcfg failed\n"));
19400 + return NULL;
19401 + }
19402 + }
19403 +
19404 + /* srom_var_init() depends on sb_scan() info */
19405 + if (srom_var_init(si, si->sb.bustype, si->curmap, osh, vars, varsz)) {
19406 + SB_ERROR(("sb_doattach: srom_var_init failed: bad srom\n"));
19407 + return (NULL);
19408 + }
19409 +
19410 + if (cc == NULL) {
19411 + /*
19412 + * The chip revision number is hardwired into all
19413 + * of the pci function config rev fields and is
19414 + * independent from the individual core revision numbers.
19415 + * For example, the "A0" silicon of each chip is chip rev 0.
19416 + * For PCMCIA we get it from the CIS instead.
19417 + */
19418 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) {
19419 + ASSERT(vars);
19420 + si->sb.chiprev = getintvar(*vars, "chiprev");
19421 + } else if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
19422 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_REV, sizeof (uint32));
19423 + si->sb.chiprev = w & 0xff;
19424 + } else
19425 + si->sb.chiprev = 0;
19426 + }
19427 +
19428 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) {
19429 + w = getintvar(*vars, "regwindowsz");
19430 + si->memseg = (w <= CFTABLE_REGWIN_2K) ? TRUE : FALSE;
19431 + }
19432 +
19433 + /* gpio control core is required */
19434 + if (!GOODIDX(si->gpioidx)) {
19435 + SB_ERROR(("sb_doattach: gpio control core not found\n"));
19436 + return NULL;
19437 + }
19438 +
19439 + /* get boardtype and boardrev */
19440 + switch (BUSTYPE(si->sb.bustype)) {
19441 + case PCI_BUS:
19442 + /* do a pci config read to get subsystem id and subvendor id */
19443 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_SVID, sizeof (uint32));
19444 + si->sb.boardvendor = w & 0xffff;
19445 + si->sb.boardtype = (w >> 16) & 0xffff;
19446 + break;
19447 +
19448 + case PCMCIA_BUS:
19449 + case SDIO_BUS:
19450 + si->sb.boardvendor = getintvar(*vars, "manfid");
19451 + si->sb.boardtype = getintvar(*vars, "prodid");
19452 + break;
19453 +
19454 + case SB_BUS:
19455 + case JTAG_BUS:
19456 + si->sb.boardvendor = VENDOR_BROADCOM;
19457 + if ((si->sb.boardtype = getintvar(NULL, "boardtype")) == 0)
19458 + si->sb.boardtype = 0xffff;
19459 + break;
19460 + }
19461 +
19462 + if (si->sb.boardtype == 0) {
19463 + SB_ERROR(("sb_doattach: unknown board type\n"));
19464 + ASSERT(si->sb.boardtype);
19465 + }
19466 +
19467 + /* setup the GPIO based LED powersave register */
19468 + if (si->sb.ccrev >= 16) {
19469 + w = getintvar(*vars, "gpiotimerval");
19470 + if (!w)
19471 + w = DEFAULT_GPIOTIMERVAL;
19472 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), ~0, w);
19473 + }
19474 +
19475 +
19476 + return (si);
19477 +}
19478 +
19479 +uint
19480 +sb_coreid(sb_t *sbh)
19481 +{
19482 + sb_info_t *si;
19483 + sbconfig_t *sb;
19484 +
19485 + si = SB_INFO(sbh);
19486 + sb = REGS2SB(si->curmap);
19487 +
19488 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT);
19489 +}
19490 +
19491 +uint
19492 +sb_coreidx(sb_t *sbh)
19493 +{
19494 + sb_info_t *si;
19495 +
19496 + si = SB_INFO(sbh);
19497 + return (si->curidx);
19498 +}
19499 +
19500 +/* return current index of core */
19501 +static uint
19502 +_sb_coreidx(sb_info_t *si)
19503 +{
19504 + sbconfig_t *sb;
19505 + uint32 sbaddr = 0;
19506 +
19507 + ASSERT(si);
19508 +
19509 + switch (BUSTYPE(si->sb.bustype)) {
19510 + case SB_BUS:
19511 + sb = REGS2SB(si->curmap);
19512 + sbaddr = sb_base(R_SBREG(si, &sb->sbadmatch0));
19513 + break;
19514 +
19515 + case PCI_BUS:
19516 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32));
19517 + break;
19518 +
19519 + case PCMCIA_BUS: {
19520 + uint8 tmp = 0;
19521 +
19522 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
19523 + sbaddr = (uint)tmp << 12;
19524 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
19525 + sbaddr |= (uint)tmp << 16;
19526 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
19527 + sbaddr |= (uint)tmp << 24;
19528 + break;
19529 + }
19530 +
19531 +#ifdef BCMJTAG
19532 + case JTAG_BUS:
19533 + sbaddr = (uint32)si->curmap;
19534 + break;
19535 +#endif /* BCMJTAG */
19536 +
19537 + default:
19538 + ASSERT(0);
19539 + }
19540 +
19541 + if (!GOODCOREADDR(sbaddr))
19542 + return BADIDX;
19543 +
19544 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE);
19545 +}
19546 +
19547 +uint
19548 +sb_corevendor(sb_t *sbh)
19549 +{
19550 + sb_info_t *si;
19551 + sbconfig_t *sb;
19552 +
19553 + si = SB_INFO(sbh);
19554 + sb = REGS2SB(si->curmap);
19555 +
19556 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT);
19557 +}
19558 +
19559 +uint
19560 +sb_corerev(sb_t *sbh)
19561 +{
19562 + sb_info_t *si;
19563 + sbconfig_t *sb;
19564 + uint sbidh;
19565 +
19566 + si = SB_INFO(sbh);
19567 + sb = REGS2SB(si->curmap);
19568 + sbidh = R_SBREG(si, &(sb)->sbidhigh);
19569 +
19570 + return (SBCOREREV(sbidh));
19571 +}
19572 +
19573 +void *
19574 +sb_osh(sb_t *sbh)
19575 +{
19576 + sb_info_t *si;
19577 +
19578 + si = SB_INFO(sbh);
19579 + return si->osh;
19580 +}
19581 +
19582 +#define SBTML_ALLOW (SBTML_PE | SBTML_FGC | SBTML_FL_MASK)
19583 +
19584 +/* set/clear sbtmstatelow core-specific flags */
19585 +uint32
19586 +sb_coreflags(sb_t *sbh, uint32 mask, uint32 val)
19587 +{
19588 + sb_info_t *si;
19589 + sbconfig_t *sb;
19590 + uint32 w;
19591 +
19592 + si = SB_INFO(sbh);
19593 + sb = REGS2SB(si->curmap);
19594 +
19595 + ASSERT((val & ~mask) == 0);
19596 + ASSERT((mask & ~SBTML_ALLOW) == 0);
19597 +
19598 + /* mask and set */
19599 + if (mask || val) {
19600 + w = (R_SBREG(si, &sb->sbtmstatelow) & ~mask) | val;
19601 + W_SBREG(si, &sb->sbtmstatelow, w);
19602 + }
19603 +
19604 + /* return the new value */
19605 + return (R_SBREG(si, &sb->sbtmstatelow) & SBTML_ALLOW);
19606 +}
19607 +
19608 +/* set/clear sbtmstatehigh core-specific flags */
19609 +uint32
19610 +sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val)
19611 +{
19612 + sb_info_t *si;
19613 + sbconfig_t *sb;
19614 + uint32 w;
19615 +
19616 + si = SB_INFO(sbh);
19617 + sb = REGS2SB(si->curmap);
19618 +
19619 + ASSERT((val & ~mask) == 0);
19620 + ASSERT((mask & ~SBTMH_FL_MASK) == 0);
19621 +
19622 + /* mask and set */
19623 + if (mask || val) {
19624 + w = (R_SBREG(si, &sb->sbtmstatehigh) & ~mask) | val;
19625 + W_SBREG(si, &sb->sbtmstatehigh, w);
19626 + }
19627 +
19628 + /* return the new value */
19629 + return (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_FL_MASK);
19630 +}
19631 +
19632 +/* caller needs to take care of core-specific bist hazards */
19633 +int
19634 +sb_corebist(sb_t *sbh, uint coreid, uint coreunit)
19635 +{
19636 + uint32 sblo;
19637 + uint coreidx;
19638 + sb_info_t *si;
19639 + int result = 0;
19640 +
19641 + si = SB_INFO(sbh);
19642 +
19643 + coreidx = sb_findcoreidx(si, coreid, coreunit);
19644 + if (!GOODIDX(coreidx))
19645 + result = BCME_ERROR;
19646 + else {
19647 + sblo = sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), 0, 0);
19648 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, (sblo | SBTML_FGC | SBTML_BE));
19649 +
19650 + SPINWAIT(((sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTD) == 0), 100000);
19651 +
19652 + if (sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTF)
19653 + result = BCME_ERROR;
19654 +
19655 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, sblo);
19656 + }
19657 +
19658 + return result;
19659 +}
19660 +
19661 +bool
19662 +sb_iscoreup(sb_t *sbh)
19663 +{
19664 + sb_info_t *si;
19665 + sbconfig_t *sb;
19666 +
19667 + si = SB_INFO(sbh);
19668 + sb = REGS2SB(si->curmap);
19669 +
19670 + return ((R_SBREG(si, &(sb)->sbtmstatelow) & (SBTML_RESET | SBTML_REJ_MASK | SBTML_CLK)) == SBTML_CLK);
19671 +}
19672 +
19673 +/*
19674 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation,
19675 + * switch back to the original core, and return the new value.
19676 + */
19677 +static uint
19678 +sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val)
19679 +{
19680 + uint origidx;
19681 + uint32 *r;
19682 + uint w;
19683 + uint intr_val = 0;
19684 +
19685 + ASSERT(GOODIDX(coreidx));
19686 + ASSERT(regoff < SB_CORE_SIZE);
19687 + ASSERT((val & ~mask) == 0);
19688 +
19689 + INTR_OFF(si, intr_val);
19690 +
19691 + /* save current core index */
19692 + origidx = sb_coreidx(&si->sb);
19693 +
19694 + /* switch core */
19695 + r = (uint32*) ((uchar*) sb_setcoreidx(&si->sb, coreidx) + regoff);
19696 +
19697 + /* mask and set */
19698 + if (mask || val) {
19699 + if (regoff >= SBCONFIGOFF) {
19700 + w = (R_SBREG(si, r) & ~mask) | val;
19701 + W_SBREG(si, r, w);
19702 + } else {
19703 + w = (R_REG(r) & ~mask) | val;
19704 + W_REG(r, w);
19705 + }
19706 + }
19707 +
19708 + /* readback */
19709 + if (regoff >= SBCONFIGOFF)
19710 + w = R_SBREG(si, r);
19711 + else
19712 + w = R_REG(r);
19713 +
19714 + /* restore core index */
19715 + if (origidx != coreidx)
19716 + sb_setcoreidx(&si->sb, origidx);
19717 +
19718 + INTR_RESTORE(si, intr_val);
19719 + return (w);
19720 +}
19721 +
19722 +#define DWORD_ALIGN(x) (x & ~(0x03))
19723 +#define BYTE_POS(x) (x & 0x3)
19724 +#define WORD_POS(x) (x & 0x1)
19725 +
19726 +#define BYTE_SHIFT(x) (8 * BYTE_POS(x))
19727 +#define WORD_SHIFT(x) (16 * WORD_POS(x))
19728 +
19729 +#define BYTE_VAL(a, x) ((a >> BYTE_SHIFT(x)) & 0xFF)
19730 +#define WORD_VAL(a, x) ((a >> WORD_SHIFT(x)) & 0xFFFF)
19731 +
19732 +#define read_pci_cfg_byte(a) \
19733 + (BYTE_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xff)
19734 +
19735 +#define read_pci_cfg_write(a) \
19736 + (WORD_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xffff)
19737 +
19738 +
19739 +/* return TRUE if requested capability exists in the PCI config space */
19740 +static bool
19741 +sb_find_pci_capability(sb_info_t *si, uint8 req_cap_id, uchar *buf, uint32 *buflen)
19742 +{
19743 + uint8 cap_id;
19744 + uint8 cap_ptr;
19745 + uint32 bufsize;
19746 + uint8 byte_val;
19747 +
19748 + if (BUSTYPE(si->sb.bustype) != PCI_BUS)
19749 + return FALSE;
19750 +
19751 + /* check for Header type 0*/
19752 + byte_val = read_pci_cfg_byte(PCI_CFG_HDR);
19753 + if ((byte_val & 0x7f) != PCI_HEADER_NORMAL)
19754 + return FALSE;
19755 +
19756 + /* check if the capability pointer field exists */
19757 + byte_val = read_pci_cfg_byte(PCI_CFG_STAT);
19758 + if (!(byte_val & PCI_CAPPTR_PRESENT))
19759 + return FALSE;
19760 +
19761 + cap_ptr = read_pci_cfg_byte(PCI_CFG_CAPPTR);
19762 + /* check if the capability pointer is 0x00 */
19763 + if (cap_ptr == 0x00)
19764 + return FALSE;
19765 +
19766 +
19767 + /* loop thr'u the capability list and see if the pcie capabilty exists */
19768 +
19769 + cap_id = read_pci_cfg_byte(cap_ptr);
19770 +
19771 + while (cap_id != req_cap_id) {
19772 + cap_ptr = read_pci_cfg_byte((cap_ptr+1));
19773 + if (cap_ptr == 0x00) break;
19774 + cap_id = read_pci_cfg_byte(cap_ptr);
19775 + }
19776 + if (cap_id != req_cap_id) {
19777 + return FALSE;
19778 + }
19779 + /* found the caller requested capability */
19780 + if ((buf != NULL) && (buflen != NULL)) {
19781 + bufsize = *buflen;
19782 + if (!bufsize) goto end;
19783 + *buflen = 0;
19784 + /* copy the cpability data excluding cap ID and next ptr */
19785 + cap_ptr += 2;
19786 + if ((bufsize + cap_ptr) > SZPCR)
19787 + bufsize = SZPCR - cap_ptr;
19788 + *buflen = bufsize;
19789 + while (bufsize--) {
19790 + *buf = read_pci_cfg_byte(cap_ptr);
19791 + cap_ptr++;
19792 + buf++;
19793 + }
19794 + }
19795 +end:
19796 + return TRUE;
19797 +}
19798 +
19799 +/* return TRUE if PCIE capability exists the pci config space */
19800 +static bool
19801 +sb_ispcie(sb_info_t *si)
19802 +{
19803 + return(sb_find_pci_capability(si, PCI_CAP_PCIECAP_ID, NULL, NULL));
19804 +}
19805 +
19806 +/* scan the sb enumerated space to identify all cores */
19807 +static void
19808 +BCMINITFN(sb_scan)(sb_info_t *si)
19809 +{
19810 + uint origidx;
19811 + uint i;
19812 + bool pci;
19813 + bool pcie;
19814 + uint pciidx;
19815 + uint pcieidx;
19816 + uint pcirev;
19817 + uint pcierev;
19818 +
19819 +
19820 +
19821 + /* numcores should already be set */
19822 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES));
19823 +
19824 + /* save current core index */
19825 + origidx = sb_coreidx(&si->sb);
19826 +
19827 + si->sb.buscorerev = NOREV;
19828 + si->sb.buscoreidx = BADIDX;
19829 +
19830 + si->gpioidx = BADIDX;
19831 +
19832 + pci = pcie = FALSE;
19833 + pcirev = pcierev = NOREV;
19834 + pciidx = pcieidx = BADIDX;
19835 +
19836 + for (i = 0; i < si->numcores; i++) {
19837 + sb_setcoreidx(&si->sb, i);
19838 + si->coreid[i] = sb_coreid(&si->sb);
19839 +
19840 + if (si->coreid[i] == SB_PCI) {
19841 + pciidx = i;
19842 + pcirev = sb_corerev(&si->sb);
19843 + pci = TRUE;
19844 + } else if (si->coreid[i] == SB_PCIE) {
19845 + pcieidx = i;
19846 + pcierev = sb_corerev(&si->sb);
19847 + pcie = TRUE;
19848 + } else if (si->coreid[i] == SB_PCMCIA) {
19849 + si->sb.buscorerev = sb_corerev(&si->sb);
19850 + si->sb.buscoretype = si->coreid[i];
19851 + si->sb.buscoreidx = i;
19852 + }
19853 + }
19854 + if (pci && pcie) {
19855 + if (sb_ispcie(si))
19856 + pci = FALSE;
19857 + else
19858 + pcie = FALSE;
19859 + }
19860 + if (pci) {
19861 + si->sb.buscoretype = SB_PCI;
19862 + si->sb.buscorerev = pcirev;
19863 + si->sb.buscoreidx = pciidx;
19864 + }
19865 + else if (pcie) {
19866 + si->sb.buscoretype = SB_PCIE;
19867 + si->sb.buscorerev = pcierev;
19868 + si->sb.buscoreidx = pcieidx;
19869 + }
19870 +
19871 + /*
19872 + * Find the gpio "controlling core" type and index.
19873 + * Precedence:
19874 + * - if there's a chip common core - use that
19875 + * - else if there's a pci core (rev >= 2) - use that
19876 + * - else there had better be an extif core (4710 only)
19877 + */
19878 + if (GOODIDX(sb_findcoreidx(si, SB_CC, 0))) {
19879 + si->gpioidx = sb_findcoreidx(si, SB_CC, 0);
19880 + si->gpioid = SB_CC;
19881 + } else if (PCI(si) && (si->sb.buscorerev >= 2)) {
19882 + si->gpioidx = si->sb.buscoreidx;
19883 + si->gpioid = SB_PCI;
19884 + } else if (sb_findcoreidx(si, SB_EXTIF, 0)) {
19885 + si->gpioidx = sb_findcoreidx(si, SB_EXTIF, 0);
19886 + si->gpioid = SB_EXTIF;
19887 + } else
19888 + ASSERT(si->gpioidx != BADIDX);
19889 +
19890 + /* return to original core index */
19891 + sb_setcoreidx(&si->sb, origidx);
19892 +}
19893 +
19894 +/* may be called with core in reset */
19895 +void
19896 +sb_detach(sb_t *sbh)
19897 +{
19898 + sb_info_t *si;
19899 + uint idx;
19900 +
19901 + si = SB_INFO(sbh);
19902 +
19903 + if (si == NULL)
19904 + return;
19905 +
19906 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
19907 + for (idx = 0; idx < SB_MAXCORES; idx++)
19908 + if (si->regs[idx]) {
19909 + REG_UNMAP(si->regs[idx]);
19910 + si->regs[idx] = NULL;
19911 + }
19912 +
19913 + if (si != &ksi)
19914 + MFREE(si->osh, si, sizeof (sb_info_t));
19915 +}
19916 +
19917 +/* use pci dev id to determine chip id for chips not having a chipcommon core */
19918 +static uint
19919 +BCMINITFN(sb_pcidev2chip)(uint pcidev)
19920 +{
19921 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID))
19922 + return (BCM4710_DEVICE_ID);
19923 + if ((pcidev >= BCM4402_DEVICE_ID) && (pcidev <= BCM4402_V90_ID))
19924 + return (BCM4402_DEVICE_ID);
19925 + if (pcidev == BCM4401_ENET_ID)
19926 + return (BCM4402_DEVICE_ID);
19927 + if ((pcidev >= BCM4307_V90_ID) && (pcidev <= BCM4307_D11B_ID))
19928 + return (BCM4307_DEVICE_ID);
19929 + if (pcidev == BCM4301_DEVICE_ID)
19930 + return (BCM4301_DEVICE_ID);
19931 +
19932 + return (0);
19933 +}
19934 +
19935 +/* convert chip number to number of i/o cores */
19936 +static uint
19937 +BCMINITFN(sb_chip2numcores)(uint chip)
19938 +{
19939 + if (chip == BCM4710_DEVICE_ID)
19940 + return (9);
19941 + if (chip == BCM4402_DEVICE_ID)
19942 + return (3);
19943 + if ((chip == BCM4301_DEVICE_ID) || (chip == BCM4307_DEVICE_ID))
19944 + return (5);
19945 + if (chip == BCM4306_DEVICE_ID) /* < 4306c0 */
19946 + return (6);
19947 + if (chip == BCM4704_DEVICE_ID)
19948 + return (9);
19949 + if (chip == BCM5365_DEVICE_ID)
19950 + return (7);
19951 +
19952 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip));
19953 + ASSERT(0);
19954 + return (1);
19955 +}
19956 +
19957 +/* return index of coreid or BADIDX if not found */
19958 +static uint
19959 +sb_findcoreidx( sb_info_t *si, uint coreid, uint coreunit)
19960 +{
19961 + uint found;
19962 + uint i;
19963 +
19964 + found = 0;
19965 +
19966 + for (i = 0; i < si->numcores; i++)
19967 + if (si->coreid[i] == coreid) {
19968 + if (found == coreunit)
19969 + return (i);
19970 + found++;
19971 + }
19972 +
19973 + return (BADIDX);
19974 +}
19975 +
19976 +/*
19977 + * this function changes logical "focus" to the indiciated core,
19978 + * must be called with interrupt off.
19979 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
19980 + */
19981 +void*
19982 +sb_setcoreidx(sb_t *sbh, uint coreidx)
19983 +{
19984 + sb_info_t *si;
19985 + uint32 sbaddr;
19986 + uint8 tmp;
19987 +
19988 + si = SB_INFO(sbh);
19989 +
19990 + if (coreidx >= si->numcores)
19991 + return (NULL);
19992 +
19993 + /*
19994 + * If the user has provided an interrupt mask enabled function,
19995 + * then assert interrupts are disabled before switching the core.
19996 + */
19997 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg));
19998 +
19999 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE);
20000 +
20001 + switch (BUSTYPE(si->sb.bustype)) {
20002 + case SB_BUS:
20003 + /* map new one */
20004 + if (!si->regs[coreidx]) {
20005 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE);
20006 + ASSERT(GOODREGS(si->regs[coreidx]));
20007 + }
20008 + si->curmap = si->regs[coreidx];
20009 + break;
20010 +
20011 + case PCI_BUS:
20012 + /* point bar0 window */
20013 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr);
20014 + break;
20015 +
20016 + case PCMCIA_BUS:
20017 + tmp = (sbaddr >> 12) & 0x0f;
20018 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1);
20019 + tmp = (sbaddr >> 16) & 0xff;
20020 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1);
20021 + tmp = (sbaddr >> 24) & 0xff;
20022 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1);
20023 + break;
20024 +#ifdef BCMJTAG
20025 + case JTAG_BUS:
20026 + /* map new one */
20027 + if (!si->regs[coreidx]) {
20028 + si->regs[coreidx] = (void *)sbaddr;
20029 + ASSERT(GOODREGS(si->regs[coreidx]));
20030 + }
20031 + si->curmap = si->regs[coreidx];
20032 + break;
20033 +#endif /* BCMJTAG */
20034 + }
20035 +
20036 + si->curidx = coreidx;
20037 +
20038 + return (si->curmap);
20039 +}
20040 +
20041 +/*
20042 + * this function changes logical "focus" to the indiciated core,
20043 + * must be called with interrupt off.
20044 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
20045 + */
20046 +void*
20047 +sb_setcore(sb_t *sbh, uint coreid, uint coreunit)
20048 +{
20049 + sb_info_t *si;
20050 + uint idx;
20051 +
20052 + si = SB_INFO(sbh);
20053 + idx = sb_findcoreidx(si, coreid, coreunit);
20054 + if (!GOODIDX(idx))
20055 + return (NULL);
20056 +
20057 + return (sb_setcoreidx(sbh, idx));
20058 +}
20059 +
20060 +/* return chip number */
20061 +uint
20062 +BCMINITFN(sb_chip)(sb_t *sbh)
20063 +{
20064 + sb_info_t *si;
20065 +
20066 + si = SB_INFO(sbh);
20067 + return (si->sb.chip);
20068 +}
20069 +
20070 +/* return chip revision number */
20071 +uint
20072 +BCMINITFN(sb_chiprev)(sb_t *sbh)
20073 +{
20074 + sb_info_t *si;
20075 +
20076 + si = SB_INFO(sbh);
20077 + return (si->sb.chiprev);
20078 +}
20079 +
20080 +/* return chip common revision number */
20081 +uint
20082 +BCMINITFN(sb_chipcrev)(sb_t *sbh)
20083 +{
20084 + sb_info_t *si;
20085 +
20086 + si = SB_INFO(sbh);
20087 + return (si->sb.ccrev);
20088 +}
20089 +
20090 +/* return chip package option */
20091 +uint
20092 +BCMINITFN(sb_chippkg)(sb_t *sbh)
20093 +{
20094 + sb_info_t *si;
20095 +
20096 + si = SB_INFO(sbh);
20097 + return (si->sb.chippkg);
20098 +}
20099 +
20100 +/* return PCI core rev. */
20101 +uint
20102 +BCMINITFN(sb_pcirev)(sb_t *sbh)
20103 +{
20104 + sb_info_t *si;
20105 +
20106 + si = SB_INFO(sbh);
20107 + return (si->sb.buscorerev);
20108 +}
20109 +
20110 +bool
20111 +BCMINITFN(sb_war16165)(sb_t *sbh)
20112 +{
20113 + sb_info_t *si;
20114 +
20115 + si = SB_INFO(sbh);
20116 +
20117 + return (PCI(si) && (si->sb.buscorerev <= 10));
20118 +}
20119 +
20120 +static void
20121 +BCMINITFN(sb_war30841)(sb_info_t *si)
20122 +{
20123 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_TIMER1, 0x8128);
20124 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_CDR, 0x0100);
20125 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466);
20126 +}
20127 +
20128 +/* return PCMCIA core rev. */
20129 +uint
20130 +BCMINITFN(sb_pcmciarev)(sb_t *sbh)
20131 +{
20132 + sb_info_t *si;
20133 +
20134 + si = SB_INFO(sbh);
20135 + return (si->sb.buscorerev);
20136 +}
20137 +
20138 +/* return board vendor id */
20139 +uint
20140 +BCMINITFN(sb_boardvendor)(sb_t *sbh)
20141 +{
20142 + sb_info_t *si;
20143 +
20144 + si = SB_INFO(sbh);
20145 + return (si->sb.boardvendor);
20146 +}
20147 +
20148 +/* return boardtype */
20149 +uint
20150 +BCMINITFN(sb_boardtype)(sb_t *sbh)
20151 +{
20152 + sb_info_t *si;
20153 + char *var;
20154 +
20155 + si = SB_INFO(sbh);
20156 +
20157 + if (BUSTYPE(si->sb.bustype) == SB_BUS && si->sb.boardtype == 0xffff) {
20158 + /* boardtype format is a hex string */
20159 + si->sb.boardtype = getintvar(NULL, "boardtype");
20160 +
20161 + /* backward compatibility for older boardtype string format */
20162 + if ((si->sb.boardtype == 0) && (var = getvar(NULL, "boardtype"))) {
20163 + if (!strcmp(var, "bcm94710dev"))
20164 + si->sb.boardtype = BCM94710D_BOARD;
20165 + else if (!strcmp(var, "bcm94710ap"))
20166 + si->sb.boardtype = BCM94710AP_BOARD;
20167 + else if (!strcmp(var, "bu4710"))
20168 + si->sb.boardtype = BU4710_BOARD;
20169 + else if (!strcmp(var, "bcm94702mn"))
20170 + si->sb.boardtype = BCM94702MN_BOARD;
20171 + else if (!strcmp(var, "bcm94710r1"))
20172 + si->sb.boardtype = BCM94710R1_BOARD;
20173 + else if (!strcmp(var, "bcm94710r4"))
20174 + si->sb.boardtype = BCM94710R4_BOARD;
20175 + else if (!strcmp(var, "bcm94702cpci"))
20176 + si->sb.boardtype = BCM94702CPCI_BOARD;
20177 + else if (!strcmp(var, "bcm95380_rr"))
20178 + si->sb.boardtype = BCM95380RR_BOARD;
20179 + }
20180 + }
20181 +
20182 + return (si->sb.boardtype);
20183 +}
20184 +
20185 +/* return bus type of sbh device */
20186 +uint
20187 +sb_bus(sb_t *sbh)
20188 +{
20189 + sb_info_t *si;
20190 +
20191 + si = SB_INFO(sbh);
20192 + return (si->sb.bustype);
20193 +}
20194 +
20195 +/* return bus core type */
20196 +uint
20197 +sb_buscoretype(sb_t *sbh)
20198 +{
20199 + sb_info_t *si;
20200 +
20201 + si = SB_INFO(sbh);
20202 +
20203 + return (si->sb.buscoretype);
20204 +}
20205 +
20206 +/* return bus core revision */
20207 +uint
20208 +sb_buscorerev(sb_t *sbh)
20209 +{
20210 + sb_info_t *si;
20211 + si = SB_INFO(sbh);
20212 +
20213 + return (si->sb.buscorerev);
20214 +}
20215 +
20216 +/* return list of found cores */
20217 +uint
20218 +sb_corelist(sb_t *sbh, uint coreid[])
20219 +{
20220 + sb_info_t *si;
20221 +
20222 + si = SB_INFO(sbh);
20223 +
20224 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof (uint)));
20225 + return (si->numcores);
20226 +}
20227 +
20228 +/* return current register mapping */
20229 +void *
20230 +sb_coreregs(sb_t *sbh)
20231 +{
20232 + sb_info_t *si;
20233 +
20234 + si = SB_INFO(sbh);
20235 + ASSERT(GOODREGS(si->curmap));
20236 +
20237 + return (si->curmap);
20238 +}
20239 +
20240 +
20241 +/* do buffered registers update */
20242 +void
20243 +sb_commit(sb_t *sbh)
20244 +{
20245 + sb_info_t *si;
20246 + uint origidx;
20247 + uint intr_val = 0;
20248 +
20249 + si = SB_INFO(sbh);
20250 +
20251 + origidx = si->curidx;
20252 + ASSERT(GOODIDX(origidx));
20253 +
20254 + INTR_OFF(si, intr_val);
20255 +
20256 + /* switch over to chipcommon core if there is one, else use pci */
20257 + if (si->sb.ccrev != NOREV) {
20258 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0);
20259 +
20260 + /* do the buffer registers update */
20261 + W_REG(&ccregs->broadcastaddress, SB_COMMIT);
20262 + W_REG(&ccregs->broadcastdata, 0x0);
20263 + } else if (PCI(si)) {
20264 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0);
20265 +
20266 + /* do the buffer registers update */
20267 + W_REG(&pciregs->bcastaddr, SB_COMMIT);
20268 + W_REG(&pciregs->bcastdata, 0x0);
20269 + } else
20270 + ASSERT(0);
20271 +
20272 + /* restore core index */
20273 + sb_setcoreidx(sbh, origidx);
20274 + INTR_RESTORE(si, intr_val);
20275 +}
20276 +
20277 +/* reset and re-enable a core */
20278 +void
20279 +sb_core_reset(sb_t *sbh, uint32 bits)
20280 +{
20281 + sb_info_t *si;
20282 + sbconfig_t *sb;
20283 + volatile uint32 dummy;
20284 +
20285 + si = SB_INFO(sbh);
20286 + ASSERT(GOODREGS(si->curmap));
20287 + sb = REGS2SB(si->curmap);
20288 +
20289 + /*
20290 + * Must do the disable sequence first to work for arbitrary current core state.
20291 + */
20292 + sb_core_disable(sbh, bits);
20293 +
20294 + /*
20295 + * Now do the initialization sequence.
20296 + */
20297 +
20298 + /* set reset while enabling the clock and forcing them on throughout the core */
20299 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits));
20300 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20301 + OSL_DELAY(1);
20302 +
20303 + if (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_SERR) {
20304 + W_SBREG(si, &sb->sbtmstatehigh, 0);
20305 + }
20306 + if ((dummy = R_SBREG(si, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) {
20307 + AND_SBREG(si, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO));
20308 + }
20309 +
20310 + /* clear reset and allow it to propagate throughout the core */
20311 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits));
20312 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20313 + OSL_DELAY(1);
20314 +
20315 + /* leave clock enabled */
20316 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_CLK | bits));
20317 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20318 + OSL_DELAY(1);
20319 +}
20320 +
20321 +void
20322 +sb_core_tofixup(sb_t *sbh)
20323 +{
20324 + sb_info_t *si;
20325 + sbconfig_t *sb;
20326 +
20327 + si = SB_INFO(sbh);
20328 +
20329 + if ( (BUSTYPE(si->sb.bustype) != PCI_BUS) || PCIE(si) || (PCI(si) && (si->sb.buscorerev >= 5)) )
20330 + return;
20331 +
20332 + ASSERT(GOODREGS(si->curmap));
20333 + sb = REGS2SB(si->curmap);
20334 +
20335 + if (BUSTYPE(si->sb.bustype) == SB_BUS) {
20336 + SET_SBREG(si, &sb->sbimconfiglow,
20337 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
20338 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3);
20339 + } else {
20340 + if (sb_coreid(sbh) == SB_PCI) {
20341 + SET_SBREG(si, &sb->sbimconfiglow,
20342 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
20343 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
20344 + } else {
20345 + SET_SBREG(si, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0);
20346 + }
20347 + }
20348 +
20349 + sb_commit(sbh);
20350 +}
20351 +
20352 +/*
20353 + * Set the initiator timeout for the "master core".
20354 + * The master core is defined to be the core in control
20355 + * of the chip and so it issues accesses to non-memory
20356 + * locations (Because of dma *any* core can access memeory).
20357 + *
20358 + * The routine uses the bus to decide who is the master:
20359 + * SB_BUS => mips
20360 + * JTAG_BUS => chipc
20361 + * PCI_BUS => pci or pcie
20362 + * PCMCIA_BUS => pcmcia
20363 + * SDIO_BUS => pcmcia
20364 + *
20365 + * This routine exists so callers can disable initiator
20366 + * timeouts so accesses to very slow devices like otp
20367 + * won't cause an abort. The routine allows arbitrary
20368 + * settings of the service and request timeouts, though.
20369 + *
20370 + * Returns the timeout state before changing it or -1
20371 + * on error.
20372 + */
20373 +
20374 +#define TO_MASK (SBIMCL_RTO_MASK | SBIMCL_STO_MASK)
20375 +
20376 +uint32
20377 +sb_set_initiator_to(sb_t *sbh, uint32 to)
20378 +{
20379 + sb_info_t *si;
20380 + uint origidx, idx;
20381 + uint intr_val = 0;
20382 + uint32 tmp, ret = 0xffffffff;
20383 + sbconfig_t *sb;
20384 +
20385 + si = SB_INFO(sbh);
20386 +
20387 + if ((to & ~TO_MASK) != 0)
20388 + return ret;
20389 +
20390 + /* Figure out the master core */
20391 + idx = BADIDX;
20392 + switch (BUSTYPE(si->sb.bustype)) {
20393 + case PCI_BUS:
20394 + idx = si->sb.buscoreidx;
20395 + break;
20396 + case JTAG_BUS:
20397 + idx = SB_CC_IDX;
20398 + break;
20399 + case PCMCIA_BUS:
20400 + case SDIO_BUS:
20401 + idx = sb_findcoreidx(si, SB_PCMCIA, 0);
20402 + break;
20403 + case SB_BUS:
20404 + if ((idx = sb_findcoreidx(si, SB_MIPS33, 0)) == BADIDX)
20405 + idx = sb_findcoreidx(si, SB_MIPS, 0);
20406 + break;
20407 + default:
20408 + ASSERT(0);
20409 + }
20410 + if (idx == BADIDX)
20411 + return ret;
20412 +
20413 + INTR_OFF(si, intr_val);
20414 + origidx = sb_coreidx(sbh);
20415 +
20416 + sb = REGS2SB(sb_setcoreidx(sbh, idx));
20417 +
20418 + tmp = R_SBREG(si, &sb->sbimconfiglow);
20419 + ret = tmp & TO_MASK;
20420 + W_SBREG(si, &sb->sbimconfiglow, (tmp & ~TO_MASK) | to);
20421 +
20422 + sb_commit(sbh);
20423 + sb_setcoreidx(sbh, origidx);
20424 + INTR_RESTORE(si, intr_val);
20425 + return ret;
20426 +}
20427 +
20428 +void
20429 +sb_core_disable(sb_t *sbh, uint32 bits)
20430 +{
20431 + sb_info_t *si;
20432 + volatile uint32 dummy;
20433 + uint32 rej;
20434 + sbconfig_t *sb;
20435 +
20436 + si = SB_INFO(sbh);
20437 +
20438 + ASSERT(GOODREGS(si->curmap));
20439 + sb = REGS2SB(si->curmap);
20440 +
20441 + /* if core is already in reset, just return */
20442 + if (R_SBREG(si, &sb->sbtmstatelow) & SBTML_RESET)
20443 + return;
20444 +
20445 + /* reject value changed between sonics 2.2 and 2.3 */
20446 + if (si->sb.sonicsrev == SONICS_2_2)
20447 + rej = (1 << SBTML_REJ_SHIFT);
20448 + else
20449 + rej = (2 << SBTML_REJ_SHIFT);
20450 +
20451 + /* if clocks are not enabled, put into reset and return */
20452 + if ((R_SBREG(si, &sb->sbtmstatelow) & SBTML_CLK) == 0)
20453 + goto disable;
20454 +
20455 + /* set target reject and spin until busy is clear (preserve core-specific bits) */
20456 + OR_SBREG(si, &sb->sbtmstatelow, rej);
20457 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20458 + OSL_DELAY(1);
20459 + SPINWAIT((R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
20460 +
20461 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT) {
20462 + OR_SBREG(si, &sb->sbimstate, SBIM_RJ);
20463 + dummy = R_SBREG(si, &sb->sbimstate);
20464 + OSL_DELAY(1);
20465 + SPINWAIT((R_SBREG(si, &sb->sbimstate) & SBIM_BY), 100000);
20466 + }
20467 +
20468 + /* set reset and reject while enabling the clocks */
20469 + W_SBREG(si, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | rej | SBTML_RESET));
20470 + dummy = R_SBREG(si, &sb->sbtmstatelow);
20471 + OSL_DELAY(10);
20472 +
20473 + /* don't forget to clear the initiator reject bit */
20474 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT)
20475 + AND_SBREG(si, &sb->sbimstate, ~SBIM_RJ);
20476 +
20477 +disable:
20478 + /* leave reset and reject asserted */
20479 + W_SBREG(si, &sb->sbtmstatelow, (bits | rej | SBTML_RESET));
20480 + OSL_DELAY(1);
20481 +}
20482 +
20483 +/* set chip watchdog reset timer to fire in 'ticks' backplane cycles */
20484 +void
20485 +sb_watchdog(sb_t *sbh, uint ticks)
20486 +{
20487 + sb_info_t *si = SB_INFO(sbh);
20488 +
20489 + /* instant NMI */
20490 + switch (si->gpioid) {
20491 + case SB_CC:
20492 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, watchdog), ~0, ticks);
20493 + break;
20494 + case SB_EXTIF:
20495 + sb_corereg(si, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks);
20496 + break;
20497 + }
20498 +}
20499 +
20500 +/* initialize the pcmcia core */
20501 +void
20502 +sb_pcmcia_init(sb_t *sbh)
20503 +{
20504 + sb_info_t *si;
20505 + uint8 cor;
20506 +
20507 + si = SB_INFO(sbh);
20508 +
20509 + /* enable d11 mac interrupts */
20510 + if (si->sb.chip == BCM4301_DEVICE_ID) {
20511 + /* Have to use FCR2 in 4301 */
20512 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
20513 + cor |= COR_IRQEN | COR_FUNEN;
20514 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1);
20515 + } else {
20516 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
20517 + cor |= COR_IRQEN | COR_FUNEN;
20518 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1);
20519 + }
20520 +
20521 +}
20522 +
20523 +
20524 +/*
20525 + * Configure the pci core for pci client (NIC) action
20526 + * coremask is the bitvec of cores by index to be enabled.
20527 + */
20528 +void
20529 +sb_pci_setup(sb_t *sbh, uint coremask)
20530 +{
20531 + sb_info_t *si;
20532 + sbconfig_t *sb;
20533 + sbpciregs_t *pciregs;
20534 + uint32 sbflag;
20535 + uint32 w;
20536 + uint idx;
20537 + int reg_val;
20538 +
20539 + si = SB_INFO(sbh);
20540 +
20541 + /* if not pci bus, we're done */
20542 + if (BUSTYPE(si->sb.bustype) != PCI_BUS)
20543 + return;
20544 +
20545 + ASSERT(PCI(si) || PCIE(si));
20546 + ASSERT(si->sb.buscoreidx != BADIDX);
20547 +
20548 + /* get current core index */
20549 + idx = si->curidx;
20550 +
20551 + /* we interrupt on this backplane flag number */
20552 + ASSERT(GOODREGS(si->curmap));
20553 + sb = REGS2SB(si->curmap);
20554 + sbflag = R_SBREG(si, &sb->sbtpsflag) & SBTPS_NUM0_MASK;
20555 +
20556 + /* switch over to pci core */
20557 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->sb.buscoreidx);
20558 + sb = REGS2SB(pciregs);
20559 +
20560 + /*
20561 + * Enable sb->pci interrupts. Assume
20562 + * PCI rev 2.3 support was added in pci core rev 6 and things changed..
20563 + */
20564 + if (PCIE(si) || (PCI(si) && ((si->sb.buscorerev) >= 6))) {
20565 + /* pci config write to set this core bit in PCIIntMask */
20566 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32));
20567 + w |= (coremask << PCI_SBIM_SHIFT);
20568 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w);
20569 + } else {
20570 + /* set sbintvec bit for our flag number */
20571 + OR_SBREG(si, &sb->sbintvec, (1 << sbflag));
20572 + }
20573 +
20574 + if (PCI(si)) {
20575 + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST));
20576 + if (si->sb.buscorerev >= 11)
20577 + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI);
20578 + if (si->sb.buscorerev < 5) {
20579 + SET_SBREG(si, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
20580 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
20581 + sb_commit(sbh);
20582 + }
20583 + }
20584 +
20585 + if (PCIE(si) && (si->sb.buscorerev == 0)) {
20586 + reg_val = sb_pcie_readreg((void *)sbh, (void *)PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG);
20587 + reg_val |= 0x8;
20588 + sb_pcie_writereg((void *)sbh, (void *)PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG, reg_val);
20589 +
20590 + reg_val = sb_pcie_readreg((void *)sbh, (void *)PCIE_PCIEREGS, PCIE_DLLP_LCREG);
20591 + reg_val &= ~(0x40);
20592 + sb_pcie_writereg(sbh, (void *)PCIE_PCIEREGS, PCIE_DLLP_LCREG, reg_val);
20593 +
20594 + BCMINIT(sb_war30841)(si);
20595 + }
20596 +
20597 + /* switch back to previous core */
20598 + sb_setcoreidx(sbh, idx);
20599 +}
20600 +
20601 +uint32
20602 +sb_base(uint32 admatch)
20603 +{
20604 + uint32 base;
20605 + uint type;
20606 +
20607 + type = admatch & SBAM_TYPE_MASK;
20608 + ASSERT(type < 3);
20609 +
20610 + base = 0;
20611 +
20612 + if (type == 0) {
20613 + base = admatch & SBAM_BASE0_MASK;
20614 + } else if (type == 1) {
20615 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20616 + base = admatch & SBAM_BASE1_MASK;
20617 + } else if (type == 2) {
20618 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20619 + base = admatch & SBAM_BASE2_MASK;
20620 + }
20621 +
20622 + return (base);
20623 +}
20624 +
20625 +uint32
20626 +sb_size(uint32 admatch)
20627 +{
20628 + uint32 size;
20629 + uint type;
20630 +
20631 + type = admatch & SBAM_TYPE_MASK;
20632 + ASSERT(type < 3);
20633 +
20634 + size = 0;
20635 +
20636 + if (type == 0) {
20637 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1);
20638 + } else if (type == 1) {
20639 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20640 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1);
20641 + } else if (type == 2) {
20642 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
20643 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1);
20644 + }
20645 +
20646 + return (size);
20647 +}
20648 +
20649 +/* return the core-type instantiation # of the current core */
20650 +uint
20651 +sb_coreunit(sb_t *sbh)
20652 +{
20653 + sb_info_t *si;
20654 + uint idx;
20655 + uint coreid;
20656 + uint coreunit;
20657 + uint i;
20658 +
20659 + si = SB_INFO(sbh);
20660 + coreunit = 0;
20661 +
20662 + idx = si->curidx;
20663 +
20664 + ASSERT(GOODREGS(si->curmap));
20665 + coreid = sb_coreid(sbh);
20666 +
20667 + /* count the cores of our type */
20668 + for (i = 0; i < idx; i++)
20669 + if (si->coreid[i] == coreid)
20670 + coreunit++;
20671 +
20672 + return (coreunit);
20673 +}
20674 +
20675 +static INLINE uint32
20676 +factor6(uint32 x)
20677 +{
20678 + switch (x) {
20679 + case CC_F6_2: return 2;
20680 + case CC_F6_3: return 3;
20681 + case CC_F6_4: return 4;
20682 + case CC_F6_5: return 5;
20683 + case CC_F6_6: return 6;
20684 + case CC_F6_7: return 7;
20685 + default: return 0;
20686 + }
20687 +}
20688 +
20689 +/* calculate the speed the SB would run at given a set of clockcontrol values */
20690 +uint32
20691 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m)
20692 +{
20693 + uint32 n1, n2, clock, m1, m2, m3, mc;
20694 +
20695 + n1 = n & CN_N1_MASK;
20696 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT;
20697 +
20698 + if (pll_type == PLL_TYPE6) {
20699 + if (m & CC_T6_MMASK)
20700 + return CC_T6_M1;
20701 + else
20702 + return CC_T6_M0;
20703 + } else if ((pll_type == PLL_TYPE1) ||
20704 + (pll_type == PLL_TYPE3) ||
20705 + (pll_type == PLL_TYPE4) ||
20706 + (pll_type == PLL_TYPE7)) {
20707 + n1 = factor6(n1);
20708 + n2 += CC_F5_BIAS;
20709 + } else if (pll_type == PLL_TYPE2) {
20710 + n1 += CC_T2_BIAS;
20711 + n2 += CC_T2_BIAS;
20712 + ASSERT((n1 >= 2) && (n1 <= 7));
20713 + ASSERT((n2 >= 5) && (n2 <= 23));
20714 + } else if (pll_type == PLL_TYPE5) {
20715 + return (100000000);
20716 + } else
20717 + ASSERT(0);
20718 + /* PLL types 3 and 7 use BASE2 (25Mhz) */
20719 + if ((pll_type == PLL_TYPE3) ||
20720 + (pll_type == PLL_TYPE7)) {
20721 + clock = CC_CLOCK_BASE2 * n1 * n2;
20722 + }
20723 + else
20724 + clock = CC_CLOCK_BASE1 * n1 * n2;
20725 +
20726 + if (clock == 0)
20727 + return 0;
20728 +
20729 + m1 = m & CC_M1_MASK;
20730 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT;
20731 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT;
20732 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT;
20733 +
20734 + if ((pll_type == PLL_TYPE1) ||
20735 + (pll_type == PLL_TYPE3) ||
20736 + (pll_type == PLL_TYPE4) ||
20737 + (pll_type == PLL_TYPE7)) {
20738 + m1 = factor6(m1);
20739 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3))
20740 + m2 += CC_F5_BIAS;
20741 + else
20742 + m2 = factor6(m2);
20743 + m3 = factor6(m3);
20744 +
20745 + switch (mc) {
20746 + case CC_MC_BYPASS: return (clock);
20747 + case CC_MC_M1: return (clock / m1);
20748 + case CC_MC_M1M2: return (clock / (m1 * m2));
20749 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3));
20750 + case CC_MC_M1M3: return (clock / (m1 * m3));
20751 + default: return (0);
20752 + }
20753 + } else {
20754 + ASSERT(pll_type == PLL_TYPE2);
20755 +
20756 + m1 += CC_T2_BIAS;
20757 + m2 += CC_T2M2_BIAS;
20758 + m3 += CC_T2_BIAS;
20759 + ASSERT((m1 >= 2) && (m1 <= 7));
20760 + ASSERT((m2 >= 3) && (m2 <= 10));
20761 + ASSERT((m3 >= 2) && (m3 <= 7));
20762 +
20763 + if ((mc & CC_T2MC_M1BYP) == 0)
20764 + clock /= m1;
20765 + if ((mc & CC_T2MC_M2BYP) == 0)
20766 + clock /= m2;
20767 + if ((mc & CC_T2MC_M3BYP) == 0)
20768 + clock /= m3;
20769 +
20770 + return(clock);
20771 + }
20772 +}
20773 +
20774 +/* returns the current speed the SB is running at */
20775 +uint32
20776 +sb_clock(sb_t *sbh)
20777 +{
20778 + sb_info_t *si;
20779 + extifregs_t *eir;
20780 + chipcregs_t *cc;
20781 + uint32 n, m;
20782 + uint idx;
20783 + uint32 pll_type, rate;
20784 + uint intr_val = 0;
20785 +
20786 + si = SB_INFO(sbh);
20787 + idx = si->curidx;
20788 + pll_type = PLL_TYPE1;
20789 +
20790 + INTR_OFF(si, intr_val);
20791 +
20792 + /* switch to extif or chipc core */
20793 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
20794 + n = R_REG(&eir->clockcontrol_n);
20795 + m = R_REG(&eir->clockcontrol_sb);
20796 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
20797 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
20798 + n = R_REG(&cc->clockcontrol_n);
20799 + if (pll_type == PLL_TYPE6)
20800 + m = R_REG(&cc->clockcontrol_mips);
20801 + else if (pll_type == PLL_TYPE3)
20802 + {
20803 + // Added by Chen-I for 5365
20804 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
20805 + m = R_REG(&cc->clockcontrol_sb);
20806 + else
20807 + m = R_REG(&cc->clockcontrol_m2);
20808 + }
20809 + else
20810 + m = R_REG(&cc->clockcontrol_sb);
20811 + } else {
20812 + INTR_RESTORE(si, intr_val);
20813 + return 0;
20814 + }
20815 +
20816 + // Added by Chen-I for 5365
20817 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
20818 + {
20819 + rate = 100000000;
20820 + }
20821 + else
20822 + {
20823 + /* calculate rate */
20824 + rate = sb_clock_rate(pll_type, n, m);
20825 + if (pll_type == PLL_TYPE3)
20826 + rate = rate / 2;
20827 + }
20828 +
20829 + /* switch back to previous core */
20830 + sb_setcoreidx(sbh, idx);
20831 +
20832 + INTR_RESTORE(si, intr_val);
20833 +
20834 + return rate;
20835 +}
20836 +
20837 +/* change logical "focus" to the gpio core for optimized access */
20838 +void*
20839 +sb_gpiosetcore(sb_t *sbh)
20840 +{
20841 + sb_info_t *si;
20842 +
20843 + si = SB_INFO(sbh);
20844 +
20845 + return (sb_setcoreidx(sbh, si->gpioidx));
20846 +}
20847 +
20848 +/* mask&set gpiocontrol bits */
20849 +uint32
20850 +sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
20851 +{
20852 + sb_info_t *si;
20853 + uint regoff;
20854 +
20855 + si = SB_INFO(sbh);
20856 + regoff = 0;
20857 +
20858 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
20859 +
20860 + /* gpios could be shared on router platforms */
20861 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
20862 + mask = priority ? (sb_gpioreservation & mask) :
20863 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
20864 + val &= mask;
20865 + }
20866 +
20867 + switch (si->gpioid) {
20868 + case SB_CC:
20869 + regoff = OFFSETOF(chipcregs_t, gpiocontrol);
20870 + break;
20871 +
20872 + case SB_PCI:
20873 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol);
20874 + break;
20875 +
20876 + case SB_EXTIF:
20877 + return (0);
20878 + }
20879 +
20880 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
20881 +}
20882 +
20883 +/* mask&set gpio output enable bits */
20884 +uint32
20885 +sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
20886 +{
20887 + sb_info_t *si;
20888 + uint regoff;
20889 +
20890 + si = SB_INFO(sbh);
20891 + regoff = 0;
20892 +
20893 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
20894 +
20895 + /* gpios could be shared on router platforms */
20896 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
20897 + mask = priority ? (sb_gpioreservation & mask) :
20898 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
20899 + val &= mask;
20900 + }
20901 +
20902 + switch (si->gpioid) {
20903 + case SB_CC:
20904 + regoff = OFFSETOF(chipcregs_t, gpioouten);
20905 + break;
20906 +
20907 + case SB_PCI:
20908 + regoff = OFFSETOF(sbpciregs_t, gpioouten);
20909 + break;
20910 +
20911 + case SB_EXTIF:
20912 + regoff = OFFSETOF(extifregs_t, gpio[0].outen);
20913 + break;
20914 + }
20915 +
20916 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
20917 +}
20918 +
20919 +/* mask&set gpio output bits */
20920 +uint32
20921 +sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
20922 +{
20923 + sb_info_t *si;
20924 + uint regoff;
20925 +
20926 + si = SB_INFO(sbh);
20927 + regoff = 0;
20928 +
20929 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
20930 +
20931 + /* gpios could be shared on router platforms */
20932 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
20933 + mask = priority ? (sb_gpioreservation & mask) :
20934 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
20935 + val &= mask;
20936 + }
20937 +
20938 + switch (si->gpioid) {
20939 + case SB_CC:
20940 + regoff = OFFSETOF(chipcregs_t, gpioout);
20941 + break;
20942 +
20943 + case SB_PCI:
20944 + regoff = OFFSETOF(sbpciregs_t, gpioout);
20945 + break;
20946 +
20947 + case SB_EXTIF:
20948 + regoff = OFFSETOF(extifregs_t, gpio[0].out);
20949 + break;
20950 + }
20951 +
20952 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
20953 +}
20954 +
20955 +/* reserve one gpio */
20956 +uint32
20957 +sb_gpioreserve(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
20958 +{
20959 + sb_info_t *si;
20960 +
20961 + si = SB_INFO(sbh);
20962 +
20963 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
20964 +
20965 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
20966 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
20967 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
20968 + return -1;
20969 + }
20970 + /* make sure only one bit is set */
20971 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
20972 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
20973 + return -1;
20974 + }
20975 +
20976 + /* already reserved */
20977 + if (sb_gpioreservation & gpio_bitmask)
20978 + return -1;
20979 + /* set reservation */
20980 + sb_gpioreservation |= gpio_bitmask;
20981 +
20982 + return sb_gpioreservation;
20983 +}
20984 +
20985 +/* release one gpio */
20986 +/*
20987 + * releasing the gpio doesn't change the current value on the GPIO last write value
20988 + * persists till some one overwrites it
20989 +*/
20990 +
20991 +uint32
20992 +sb_gpiorelease(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
20993 +{
20994 + sb_info_t *si;
20995 +
20996 + si = SB_INFO(sbh);
20997 +
20998 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
20999 +
21000 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
21001 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
21002 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
21003 + return -1;
21004 + }
21005 + /* make sure only one bit is set */
21006 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
21007 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
21008 + return -1;
21009 + }
21010 +
21011 + /* already released */
21012 + if (!(sb_gpioreservation & gpio_bitmask))
21013 + return -1;
21014 +
21015 + /* clear reservation */
21016 + sb_gpioreservation &= ~gpio_bitmask;
21017 +
21018 + return sb_gpioreservation;
21019 +}
21020 +
21021 +/* return the current gpioin register value */
21022 +uint32
21023 +sb_gpioin(sb_t *sbh)
21024 +{
21025 + sb_info_t *si;
21026 + uint regoff;
21027 +
21028 + si = SB_INFO(sbh);
21029 + regoff = 0;
21030 +
21031 + switch (si->gpioid) {
21032 + case SB_CC:
21033 + regoff = OFFSETOF(chipcregs_t, gpioin);
21034 + break;
21035 +
21036 + case SB_PCI:
21037 + regoff = OFFSETOF(sbpciregs_t, gpioin);
21038 + break;
21039 +
21040 + case SB_EXTIF:
21041 + regoff = OFFSETOF(extifregs_t, gpioin);
21042 + break;
21043 + }
21044 +
21045 + return (sb_corereg(si, si->gpioidx, regoff, 0, 0));
21046 +}
21047 +
21048 +/* mask&set gpio interrupt polarity bits */
21049 +uint32
21050 +sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
21051 +{
21052 + sb_info_t *si;
21053 + uint regoff;
21054 +
21055 + si = SB_INFO(sbh);
21056 + regoff = 0;
21057 +
21058 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
21059 +
21060 + /* gpios could be shared on router platforms */
21061 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
21062 + mask = priority ? (sb_gpioreservation & mask) :
21063 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
21064 + val &= mask;
21065 + }
21066 +
21067 + switch (si->gpioid) {
21068 + case SB_CC:
21069 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity);
21070 + break;
21071 +
21072 + case SB_PCI:
21073 + /* pci gpio implementation does not support interrupt polarity */
21074 + ASSERT(0);
21075 + break;
21076 +
21077 + case SB_EXTIF:
21078 + regoff = OFFSETOF(extifregs_t, gpiointpolarity);
21079 + break;
21080 + }
21081 +
21082 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
21083 +}
21084 +
21085 +/* mask&set gpio interrupt mask bits */
21086 +uint32
21087 +sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
21088 +{
21089 + sb_info_t *si;
21090 + uint regoff;
21091 +
21092 + si = SB_INFO(sbh);
21093 + regoff = 0;
21094 +
21095 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
21096 +
21097 + /* gpios could be shared on router platforms */
21098 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
21099 + mask = priority ? (sb_gpioreservation & mask) :
21100 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
21101 + val &= mask;
21102 + }
21103 +
21104 + switch (si->gpioid) {
21105 + case SB_CC:
21106 + regoff = OFFSETOF(chipcregs_t, gpiointmask);
21107 + break;
21108 +
21109 + case SB_PCI:
21110 + /* pci gpio implementation does not support interrupt mask */
21111 + ASSERT(0);
21112 + break;
21113 +
21114 + case SB_EXTIF:
21115 + regoff = OFFSETOF(extifregs_t, gpiointmask);
21116 + break;
21117 + }
21118 +
21119 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
21120 +}
21121 +
21122 +/* assign the gpio to an led */
21123 +uint32
21124 +sb_gpioled(sb_t *sbh, uint32 mask, uint32 val)
21125 +{
21126 + sb_info_t *si;
21127 +
21128 + si = SB_INFO(sbh);
21129 + if (si->sb.ccrev < 16)
21130 + return -1;
21131 +
21132 + /* gpio led powersave reg */
21133 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimeroutmask), mask, val));
21134 +}
21135 +
21136 +/* mask&set gpio timer val */
21137 +uint32
21138 +sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 gpiotimerval)
21139 +{
21140 + sb_info_t *si;
21141 + si = SB_INFO(sbh);
21142 +
21143 + if (si->sb.ccrev < 16)
21144 + return -1;
21145 +
21146 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), mask, gpiotimerval));
21147 +}
21148 +
21149 +
21150 +/* return the slow clock source - LPO, XTAL, or PCI */
21151 +static uint
21152 +sb_slowclk_src(sb_info_t *si)
21153 +{
21154 + chipcregs_t *cc;
21155 +
21156 +
21157 + ASSERT(sb_coreid(&si->sb) == SB_CC);
21158 +
21159 + if (si->sb.ccrev < 6) {
21160 + if ((BUSTYPE(si->sb.bustype) == PCI_BUS)
21161 + && (OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32)) & PCI_CFG_GPIO_SCS))
21162 + return (SCC_SS_PCI);
21163 + else
21164 + return (SCC_SS_XTAL);
21165 + } else if (si->sb.ccrev < 10) {
21166 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
21167 + return (R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK);
21168 + } else /* Insta-clock */
21169 + return (SCC_SS_XTAL);
21170 +}
21171 +
21172 +/* return the ILP (slowclock) min or max frequency */
21173 +static uint
21174 +sb_slowclk_freq(sb_info_t *si, bool max)
21175 +{
21176 + chipcregs_t *cc;
21177 + uint32 slowclk;
21178 + uint div;
21179 +
21180 +
21181 + ASSERT(sb_coreid(&si->sb) == SB_CC);
21182 +
21183 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
21184 +
21185 + /* shouldn't be here unless we've established the chip has dynamic clk control */
21186 + ASSERT(R_REG(&cc->capabilities) & CAP_PWR_CTL);
21187 +
21188 + slowclk = sb_slowclk_src(si);
21189 + if (si->sb.ccrev < 6) {
21190 + if (slowclk == SCC_SS_PCI)
21191 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64));
21192 + else
21193 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32));
21194 + } else if (si->sb.ccrev < 10) {
21195 + div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
21196 + if (slowclk == SCC_SS_LPO)
21197 + return (max? LPOMAXFREQ : LPOMINFREQ);
21198 + else if (slowclk == SCC_SS_XTAL)
21199 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div));
21200 + else if (slowclk == SCC_SS_PCI)
21201 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div));
21202 + else
21203 + ASSERT(0);
21204 + } else {
21205 + /* Chipc rev 10 is InstaClock */
21206 + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT;
21207 + div = 4 * (div + 1);
21208 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div));
21209 + }
21210 + return (0);
21211 +}
21212 +
21213 +static void
21214 +sb_clkctl_setdelay(sb_info_t *si, void *chipcregs)
21215 +{
21216 + chipcregs_t * cc;
21217 + uint slowmaxfreq, pll_delay, slowclk;
21218 + uint pll_on_delay, fref_sel_delay;
21219 +
21220 + pll_delay = PLL_DELAY;
21221 +
21222 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay
21223 + * since the xtal will also be powered down by dynamic clk control logic.
21224 + */
21225 + slowclk = sb_slowclk_src(si);
21226 + if (slowclk != SCC_SS_XTAL)
21227 + pll_delay += XTAL_ON_DELAY;
21228 +
21229 + /* Starting with 4318 it is ILP that is used for the delays */
21230 + slowmaxfreq = sb_slowclk_freq(si, (si->sb.ccrev >= 10) ? FALSE : TRUE);
21231 +
21232 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
21233 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
21234 +
21235 + cc = (chipcregs_t *)chipcregs;
21236 + W_REG(&cc->pll_on_delay, pll_on_delay);
21237 + W_REG(&cc->fref_sel_delay, fref_sel_delay);
21238 +}
21239 +
21240 +int
21241 +sb_pwrctl_slowclk(void *sbh, bool set, uint *div)
21242 +{
21243 + sb_info_t *si;
21244 + uint origidx;
21245 + chipcregs_t *cc;
21246 + uint intr_val = 0;
21247 + uint err = 0;
21248 +
21249 + si = SB_INFO(sbh);
21250 +
21251 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
21252 + if (si->sb.ccrev < 6)
21253 + return 1;
21254 +
21255 + /* chipcommon cores rev10 are a whole new ball game */
21256 + if (si->sb.ccrev >= 10)
21257 + return 1;
21258 +
21259 + if (set && ((*div % 4) || (*div < 4)))
21260 + return 2;
21261 +
21262 + INTR_OFF(si, intr_val);
21263 + origidx = si->curidx;
21264 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
21265 + ASSERT(cc != NULL);
21266 +
21267 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) {
21268 + err = 3;
21269 + goto done;
21270 + }
21271 +
21272 + if (set) {
21273 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, ((*div / 4 - 1) << SCC_CD_SHIFT));
21274 + sb_clkctl_setdelay(sbh, (void *)cc);
21275 + } else
21276 + *div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
21277 +
21278 +done:
21279 + sb_setcoreidx(sbh, origidx);
21280 + INTR_RESTORE(si, intr_val);
21281 + return err;
21282 +}
21283 +
21284 +/* initialize power control delay registers */
21285 +void sb_clkctl_init(sb_t *sbh)
21286 +{
21287 + sb_info_t *si;
21288 + uint origidx;
21289 + chipcregs_t *cc;
21290 +
21291 + si = SB_INFO(sbh);
21292 +
21293 + origidx = si->curidx;
21294 +
21295 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
21296 + return;
21297 +
21298 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
21299 + goto done;
21300 +
21301 + /* 4317pc does not work with SlowClock less than 5 MHz */
21302 + if ((BUSTYPE(si->sb.bustype) == PCMCIA_BUS) && (si->sb.ccrev >= 6) && (si->sb.ccrev < 10))
21303 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, (ILP_DIV_5MHZ << SCC_CD_SHIFT));
21304 +
21305 + /* set all Instaclk chip ILP to 1 MHz */
21306 + else if (si->sb.ccrev >= 10)
21307 + SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
21308 +
21309 + sb_clkctl_setdelay(si, (void *)cc);
21310 +
21311 +done:
21312 + sb_setcoreidx(sbh, origidx);
21313 +}
21314 +void sb_pwrctl_init(sb_t *sbh)
21315 +{
21316 +sb_clkctl_init(sbh);
21317 +}
21318 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */
21319 +uint16
21320 +sb_clkctl_fast_pwrup_delay(sb_t *sbh)
21321 +{
21322 + sb_info_t *si;
21323 + uint origidx;
21324 + chipcregs_t *cc;
21325 + uint slowminfreq;
21326 + uint16 fpdelay;
21327 + uint intr_val = 0;
21328 +
21329 + si = SB_INFO(sbh);
21330 + fpdelay = 0;
21331 + origidx = si->curidx;
21332 +
21333 + INTR_OFF(si, intr_val);
21334 +
21335 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
21336 + goto done;
21337 +
21338 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
21339 + goto done;
21340 +
21341 + slowminfreq = sb_slowclk_freq(si, FALSE);
21342 + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq;
21343 +
21344 +done:
21345 + sb_setcoreidx(sbh, origidx);
21346 + INTR_RESTORE(si, intr_val);
21347 + return (fpdelay);
21348 +}
21349 +uint16 sb_pwrctl_fast_pwrup_delay(sb_t *sbh)
21350 +{
21351 +return sb_clkctl_fast_pwrup_delay(sbh);
21352 +}
21353 +/* turn primary xtal and/or pll off/on */
21354 +int
21355 +sb_clkctl_xtal(sb_t *sbh, uint what, bool on)
21356 +{
21357 + sb_info_t *si;
21358 + uint32 in, out, outen;
21359 +
21360 + si = SB_INFO(sbh);
21361 +
21362 + switch (BUSTYPE(si->sb.bustype)) {
21363 +
21364 +
21365 + case PCMCIA_BUS:
21366 + return (0);
21367 +
21368 +
21369 + case PCI_BUS:
21370 +
21371 + /* pcie core doesn't have any mapping to control the xtal pu */
21372 + if (PCIE(si))
21373 + return -1;
21374 +
21375 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof (uint32));
21376 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
21377 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32));
21378 +
21379 + /*
21380 + * Avoid glitching the clock if GPRS is already using it.
21381 + * We can't actually read the state of the PLLPD so we infer it
21382 + * by the value of XTAL_PU which *is* readable via gpioin.
21383 + */
21384 + if (on && (in & PCI_CFG_GPIO_XTAL))
21385 + return (0);
21386 +
21387 + if (what & XTAL)
21388 + outen |= PCI_CFG_GPIO_XTAL;
21389 + if (what & PLL)
21390 + outen |= PCI_CFG_GPIO_PLL;
21391 +
21392 + if (on) {
21393 + /* turn primary xtal on */
21394 + if (what & XTAL) {
21395 + out |= PCI_CFG_GPIO_XTAL;
21396 + if (what & PLL)
21397 + out |= PCI_CFG_GPIO_PLL;
21398 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
21399 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
21400 + OSL_DELAY(XTAL_ON_DELAY);
21401 + }
21402 +
21403 + /* turn pll on */
21404 + if (what & PLL) {
21405 + out &= ~PCI_CFG_GPIO_PLL;
21406 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
21407 + OSL_DELAY(2000);
21408 + }
21409 + } else {
21410 + if (what & XTAL)
21411 + out &= ~PCI_CFG_GPIO_XTAL;
21412 + if (what & PLL)
21413 + out |= PCI_CFG_GPIO_PLL;
21414 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
21415 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
21416 + }
21417 +
21418 + default:
21419 + return (-1);
21420 + }
21421 +
21422 + return (0);
21423 +}
21424 +
21425 +int sb_pwrctl_xtal(sb_t *sbh, uint what, bool on)
21426 +{
21427 +return sb_clkctl_xtal(sbh,what,on);
21428 +}
21429 +
21430 +/* set dynamic clk control mode (forceslow, forcefast, dynamic) */
21431 +/* returns true if ignore pll off is set and false if it is not */
21432 +bool
21433 +sb_clkctl_clk(sb_t *sbh, uint mode)
21434 +{
21435 + sb_info_t *si;
21436 + uint origidx;
21437 + chipcregs_t *cc;
21438 + uint32 scc;
21439 + bool forcefastclk=FALSE;
21440 + uint intr_val = 0;
21441 +
21442 + si = SB_INFO(sbh);
21443 +
21444 + /* chipcommon cores prior to rev6 don't support dynamic clock control */
21445 + if (si->sb.ccrev < 6)
21446 + return (FALSE);
21447 +
21448 + /* chipcommon cores rev10 are a whole new ball game */
21449 + if (si->sb.ccrev >= 10)
21450 + return (FALSE);
21451 +
21452 + INTR_OFF(si, intr_val);
21453 +
21454 + origidx = si->curidx;
21455 +
21456 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
21457 + ASSERT(cc != NULL);
21458 +
21459 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
21460 + goto done;
21461 +
21462 + switch (mode) {
21463 + case CLK_FAST: /* force fast (pll) clock */
21464 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */
21465 + sb_clkctl_xtal(&si->sb, XTAL, ON);
21466 +
21467 + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
21468 + break;
21469 +
21470 + case CLK_DYNAMIC: /* enable dynamic clock control */
21471 + scc = R_REG(&cc->slow_clk_ctl);
21472 + scc &= ~(SCC_FS | SCC_IP | SCC_XC);
21473 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
21474 + scc |= SCC_XC;
21475 + W_REG(&cc->slow_clk_ctl, scc);
21476 +
21477 + /* for dynamic control, we have to release our xtal_pu "force on" */
21478 + if (scc & SCC_XC)
21479 + sb_clkctl_xtal(&si->sb, XTAL, OFF);
21480 + break;
21481 +
21482 + default:
21483 + ASSERT(0);
21484 + }
21485 +
21486 + /* Is the h/w forcing the use of the fast clk */
21487 + forcefastclk = (bool)((R_REG(&cc->slow_clk_ctl) & SCC_IP) == SCC_IP);
21488 +
21489 +done:
21490 + sb_setcoreidx(sbh, origidx);
21491 + INTR_RESTORE(si, intr_val);
21492 + return (forcefastclk);
21493 +}
21494 +
21495 +bool sb_pwrctl_clk(sb_t *sbh, uint mode)
21496 +{
21497 +return sb_clkctl_clk(sbh, mode);
21498 +}
21499 +/* register driver interrupt disabling and restoring callback functions */
21500 +void
21501 +sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg)
21502 +{
21503 + sb_info_t *si;
21504 +
21505 + si = SB_INFO(sbh);
21506 + si->intr_arg = intr_arg;
21507 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn;
21508 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn;
21509 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn;
21510 + /* save current core id. when this function called, the current core
21511 + * must be the core which provides driver functions(il, et, wl, etc.)
21512 + */
21513 + si->dev_coreid = si->coreid[si->curidx];
21514 +}
21515 +
21516 +
21517 +void
21518 +sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
21519 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif)
21520 +{
21521 + uint vendor, core, unit;
21522 + uint chip, chippkg;
21523 + char varname[8];
21524 + uint8 class, subclass, progif;
21525 +
21526 + vendor = sb_corevendor(sbh);
21527 + core = sb_coreid(sbh);
21528 + unit = sb_coreunit(sbh);
21529 +
21530 + chip = BCMINIT(sb_chip)(sbh);
21531 + chippkg = BCMINIT(sb_chippkg)(sbh);
21532 +
21533 + progif = 0;
21534 +
21535 + /* Known vendor translations */
21536 + switch (vendor) {
21537 + case SB_VEND_BCM:
21538 + vendor = VENDOR_BROADCOM;
21539 + break;
21540 + }
21541 +
21542 + /* Determine class based on known core codes */
21543 + switch (core) {
21544 + case SB_ILINE20:
21545 + class = PCI_CLASS_NET;
21546 + subclass = PCI_NET_ETHER;
21547 + core = BCM47XX_ILINE_ID;
21548 + break;
21549 + case SB_ENET:
21550 + class = PCI_CLASS_NET;
21551 + subclass = PCI_NET_ETHER;
21552 + core = BCM47XX_ENET_ID;
21553 + break;
21554 + case SB_SDRAM:
21555 + case SB_MEMC:
21556 + class = PCI_CLASS_MEMORY;
21557 + subclass = PCI_MEMORY_RAM;
21558 + break;
21559 + case SB_PCI:
21560 + case SB_PCIE:
21561 + class = PCI_CLASS_BRIDGE;
21562 + subclass = PCI_BRIDGE_PCI;
21563 + break;
21564 + case SB_MIPS:
21565 + case SB_MIPS33:
21566 + class = PCI_CLASS_CPU;
21567 + subclass = PCI_CPU_MIPS;
21568 + break;
21569 + case SB_CODEC:
21570 + class = PCI_CLASS_COMM;
21571 + subclass = PCI_COMM_MODEM;
21572 + core = BCM47XX_V90_ID;
21573 + break;
21574 + case SB_USB:
21575 + class = PCI_CLASS_SERIAL;
21576 + subclass = PCI_SERIAL_USB;
21577 + progif = 0x10; /* OHCI */
21578 + core = BCM47XX_USB_ID;
21579 + break;
21580 + case SB_USB11H:
21581 + class = PCI_CLASS_SERIAL;
21582 + subclass = PCI_SERIAL_USB;
21583 + progif = 0x10; /* OHCI */
21584 + core = BCM47XX_USBH_ID;
21585 + break;
21586 + case SB_USB11D:
21587 + class = PCI_CLASS_SERIAL;
21588 + subclass = PCI_SERIAL_USB;
21589 + core = BCM47XX_USBD_ID;
21590 + break;
21591 + case SB_IPSEC:
21592 + class = PCI_CLASS_CRYPT;
21593 + subclass = PCI_CRYPT_NETWORK;
21594 + core = BCM47XX_IPSEC_ID;
21595 + break;
21596 + case SB_ROBO:
21597 + class = PCI_CLASS_NET;
21598 + subclass = PCI_NET_OTHER;
21599 + core = BCM47XX_ROBO_ID;
21600 + break;
21601 + case SB_EXTIF:
21602 + case SB_CC:
21603 + class = PCI_CLASS_MEMORY;
21604 + subclass = PCI_MEMORY_FLASH;
21605 + break;
21606 + case SB_D11:
21607 + class = PCI_CLASS_NET;
21608 + subclass = PCI_NET_OTHER;
21609 + /* Let an nvram variable override this */
21610 + sprintf(varname, "wl%did", unit);
21611 + if ((core = getintvar(NULL, varname)) == 0) {
21612 + if (chip == BCM4712_DEVICE_ID) {
21613 + if (chippkg == BCM4712SMALL_PKG_ID)
21614 + core = BCM4306_D11G_ID;
21615 + else
21616 + core = BCM4306_D11DUAL_ID;
21617 + }
21618 + }
21619 + break;
21620 +
21621 + default:
21622 + class = subclass = progif = 0xff;
21623 + break;
21624 + }
21625 +
21626 + *pcivendor = (uint16)vendor;
21627 + *pcidevice = (uint16)core;
21628 + *pciclass = class;
21629 + *pcisubclass = subclass;
21630 + *pciprogif = progif;
21631 +}
21632 +
21633 +
21634 +
21635 +
21636 +/* use the mdio interface to write to mdio slaves */
21637 +static int
21638 +sb_pcie_mdiowrite(sb_info_t *si, uint physmedia, uint regaddr, uint val)
21639 +{
21640 + uint mdiodata;
21641 + uint i = 0;
21642 + sbpcieregs_t *pcieregs;
21643 +
21644 + pcieregs = (sbpcieregs_t*) sb_setcoreidx(&si->sb, si->sb.buscoreidx);
21645 + ASSERT (pcieregs);
21646 +
21647 + /* enable mdio access to SERDES */
21648 + W_REG((&pcieregs->mdiocontrol), MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL);
21649 +
21650 + mdiodata = MDIODATA_START | MDIODATA_WRITE |
21651 + (physmedia << MDIODATA_DEVADDR_SHF) |
21652 + (regaddr << MDIODATA_REGADDR_SHF) | MDIODATA_TA | val;
21653 +
21654 + W_REG((&pcieregs->mdiodata), mdiodata);
21655 +
21656 + PR28829_DELAY();
21657 +
21658 + /* retry till the transaction is complete */
21659 + while ( i < 10 ) {
21660 + if (R_REG(&(pcieregs->mdiocontrol)) & MDIOCTL_ACCESS_DONE) {
21661 + /* Disable mdio access to SERDES */
21662 + W_REG((&pcieregs->mdiocontrol), 0);
21663 + return 0;
21664 + }
21665 + OSL_DELAY(1000);
21666 + i++;
21667 + }
21668 +
21669 + SB_ERROR(("sb_pcie_mdiowrite: timed out\n"));
21670 + /* Disable mdio access to SERDES */
21671 + W_REG((&pcieregs->mdiocontrol), 0);
21672 + ASSERT(0);
21673 + return 1;
21674 +
21675 +}
21676 +
21677 +/* indirect way to read pcie config regs*/
21678 +uint
21679 +sb_pcie_readreg(void *sb, void* arg1, uint offset)
21680 +{
21681 + sb_info_t *si;
21682 + sb_t *sbh;
21683 + uint retval = 0xFFFFFFFF;
21684 + sbpcieregs_t *pcieregs;
21685 + uint addrtype;
21686 +
21687 + sbh = (sb_t *)sb;
21688 + si = SB_INFO(sbh);
21689 + ASSERT (PCIE(si));
21690 +
21691 + pcieregs = (sbpcieregs_t *)sb_setcore(sbh, SB_PCIE, 0);
21692 + ASSERT (pcieregs);
21693 +
21694 + addrtype = (uint)((uintptr)arg1);
21695 + switch(addrtype) {
21696 + case PCIE_CONFIGREGS:
21697 + W_REG((&pcieregs->configaddr),offset);
21698 + retval = R_REG(&(pcieregs->configdata));
21699 + break;
21700 + case PCIE_PCIEREGS:
21701 + W_REG(&(pcieregs->pcieaddr),offset);
21702 + retval = R_REG(&(pcieregs->pciedata));
21703 + break;
21704 + default:
21705 + ASSERT(0);
21706 + break;
21707 + }
21708 + return retval;
21709 +}
21710 +
21711 +/* indirect way to write pcie config/mdio/pciecore regs*/
21712 +uint
21713 +sb_pcie_writereg(sb_t *sbh, void *arg1, uint offset, uint val)
21714 +{
21715 + sb_info_t *si;
21716 + sbpcieregs_t *pcieregs;
21717 + uint addrtype;
21718 +
21719 + si = SB_INFO(sbh);
21720 + ASSERT (PCIE(si));
21721 +
21722 + pcieregs = (sbpcieregs_t *)sb_setcore(sbh, SB_PCIE, 0);
21723 + ASSERT (pcieregs);
21724 +
21725 + addrtype = (uint)((uintptr)arg1);
21726 +
21727 + switch(addrtype) {
21728 + case PCIE_CONFIGREGS:
21729 + W_REG((&pcieregs->configaddr),offset);
21730 + W_REG((&pcieregs->configdata),val);
21731 + break;
21732 + case PCIE_PCIEREGS:
21733 + W_REG((&pcieregs->pcieaddr),offset);
21734 + W_REG((&pcieregs->pciedata),val);
21735 + break;
21736 + default:
21737 + ASSERT(0);
21738 + break;
21739 + }
21740 + return 0;
21741 +}
21742 +
21743 +
21744 +/* Build device path. Support SB, PCI, and JTAG for now. */
21745 +int
21746 +sb_devpath(sb_t *sbh, char *path, int size)
21747 +{
21748 + ASSERT(path);
21749 + ASSERT(size >= SB_DEVPATH_BUFSZ);
21750 +
21751 + switch (BUSTYPE((SB_INFO(sbh))->sb.bustype)) {
21752 + case SB_BUS:
21753 + case JTAG_BUS:
21754 + sprintf(path, "sb/%u/", sb_coreidx(sbh));
21755 + break;
21756 + case PCI_BUS:
21757 + ASSERT((SB_INFO(sbh))->osh);
21758 + sprintf(path, "pci/%u/%u/", OSL_PCI_BUS((SB_INFO(sbh))->osh),
21759 + OSL_PCI_SLOT((SB_INFO(sbh))->osh));
21760 + break;
21761 + case PCMCIA_BUS:
21762 + SB_ERROR(("sb_devpath: OSL_PCMCIA_BUS() not implemented, bus 1 assumed\n"));
21763 + SB_ERROR(("sb_devpath: OSL_PCMCIA_SLOT() not implemented, slot 1 assumed\n"));
21764 + sprintf(path, "pc/%u/%u/", 1, 1);
21765 + break;
21766 + case SDIO_BUS:
21767 + SB_ERROR(("sb_devpath: device 0 assumed\n"));
21768 + sprintf(path, "sd/%u/", sb_coreidx(sbh));
21769 + break;
21770 + default:
21771 + ASSERT(0);
21772 + break;
21773 + }
21774 +
21775 + return 0;
21776 +}
21777 +
21778 +/* Fix chip's configuration. The current core may be changed upon return */
21779 +static int
21780 +sb_pci_fixcfg(sb_info_t *si)
21781 +{
21782 + uint origidx, pciidx;
21783 + sbpciregs_t *pciregs;
21784 + sbpcieregs_t *pcieregs;
21785 + uint16 val16, *reg16;
21786 + char name[SB_DEVPATH_BUFSZ+16], *value;
21787 + char devpath[SB_DEVPATH_BUFSZ];
21788 +
21789 + ASSERT(BUSTYPE(si->sb.bustype) == PCI_BUS);
21790 +
21791 + /* Fix PCI(e) SROM shadow area */
21792 + /* save the current index */
21793 + origidx = sb_coreidx(&si->sb);
21794 +
21795 + /* check 'pi' is correct and fix it if not */
21796 + if (si->sb.buscoretype == SB_PCIE) {
21797 + pcieregs = (sbpcieregs_t *)sb_setcore(&si->sb, SB_PCIE, 0);
21798 + ASSERT(pcieregs);
21799 + reg16 = &pcieregs->sprom[SRSH_PI_OFFSET];
21800 + }
21801 + else if (si->sb.buscoretype == SB_PCI) {
21802 + pciregs = (sbpciregs_t *)sb_setcore(&si->sb, SB_PCI, 0);
21803 + ASSERT(pciregs);
21804 + reg16 = &pciregs->sprom[SRSH_PI_OFFSET];
21805 + }
21806 + else {
21807 + ASSERT(0);
21808 + return -1;
21809 + }
21810 + pciidx = sb_coreidx(&si->sb);
21811 + val16 = R_REG(reg16);
21812 + if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (uint16)pciidx) {
21813 + val16 = (uint16)(pciidx << SRSH_PI_SHIFT) | (val16 & ~SRSH_PI_MASK);
21814 + W_REG(reg16, val16);
21815 + }
21816 +
21817 + /* restore the original index */
21818 + sb_setcoreidx(&si->sb, origidx);
21819 +
21820 + /* Fix bar0window */
21821 + /* !do it last, it changes the current core! */
21822 + if (sb_devpath(&si->sb, devpath, sizeof(devpath)))
21823 + return -1;
21824 + sprintf(name, "%sb0w", devpath);
21825 + if ((value = getvar(NULL, name))) {
21826 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof(uint32),
21827 + bcm_strtoul(value, NULL, 16));
21828 + /* update curidx since the current core is changed */
21829 + si->curidx = _sb_coreidx(si);
21830 + if (si->curidx == BADIDX) {
21831 + SB_ERROR(("sb_pci_fixcfg: bad core index\n"));
21832 + return -1;
21833 + }
21834 + }
21835 +
21836 + return 0;
21837 +}
21838 +
21839 diff -Nur linux-2.4.32/drivers/net/hnd/shared_ksyms.sh linux-2.4.32-brcm/drivers/net/hnd/shared_ksyms.sh
21840 --- linux-2.4.32/drivers/net/hnd/shared_ksyms.sh 1970-01-01 01:00:00.000000000 +0100
21841 +++ linux-2.4.32-brcm/drivers/net/hnd/shared_ksyms.sh 2005-12-16 23:39:11.316860000 +0100
21842 @@ -0,0 +1,21 @@
21843 +#!/bin/sh
21844 +#
21845 +# Copyright 2004, Broadcom Corporation
21846 +# All Rights Reserved.
21847 +#
21848 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
21849 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
21850 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
21851 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
21852 +#
21853 +# $Id: shared_ksyms.sh,v 1.1 2005/03/16 13:50:00 wbx Exp $
21854 +#
21855 +
21856 +cat <<EOF
21857 +#include <linux/config.h>
21858 +#include <linux/module.h>
21859 +EOF
21860 +
21861 +for file in $* ; do
21862 + ${NM} $file | sed -ne 's/[0-9A-Fa-f]* [DT] \([^ ]*\)/extern void \1; EXPORT_SYMBOL(\1);/p'
21863 +done
21864 diff -Nur linux-2.4.32/drivers/net/Makefile linux-2.4.32-brcm/drivers/net/Makefile
21865 --- linux-2.4.32/drivers/net/Makefile 2005-01-19 15:09:56.000000000 +0100
21866 +++ linux-2.4.32-brcm/drivers/net/Makefile 2005-12-16 23:39:11.284858000 +0100
21867 @@ -3,6 +3,8 @@
21868 # Makefile for the Linux network (ethercard) device drivers.
21869 #
21870
21871 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include
21872 +
21873 obj-y :=
21874 obj-m :=
21875 obj-n :=
21876 @@ -39,6 +41,9 @@
21877 obj-$(CONFIG_ISDN) += slhc.o
21878 endif
21879
21880 +subdir-$(CONFIG_HND) += hnd
21881 +subdir-$(CONFIG_ET) += et
21882 +subdir-$(CONFIG_WL) += wl
21883 subdir-$(CONFIG_NET_PCMCIA) += pcmcia
21884 subdir-$(CONFIG_NET_WIRELESS) += wireless
21885 subdir-$(CONFIG_TULIP) += tulip
21886 @@ -69,6 +74,16 @@
21887 obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o
21888 obj-$(CONFIG_SUNGEM) += sungem.o
21889
21890 +ifeq ($(CONFIG_HND),y)
21891 + obj-y += hnd/hnd.o
21892 +endif
21893 +ifeq ($(CONFIG_ET),y)
21894 + obj-y += et/et.o
21895 +endif
21896 +ifeq ($(CONFIG_WL),y)
21897 + obj-y += wl/wl.o
21898 +endif
21899 +
21900 obj-$(CONFIG_MACE) += mace.o
21901 obj-$(CONFIG_BMAC) += bmac.o
21902 obj-$(CONFIG_GMAC) += gmac.o
21903 @@ -265,6 +280,7 @@
21904 endif
21905 endif
21906
21907 +
21908 include $(TOPDIR)/Rules.make
21909
21910 clean:
21911 diff -Nur linux-2.4.32/drivers/net/wireless/Config.in linux-2.4.32-brcm/drivers/net/wireless/Config.in
21912 --- linux-2.4.32/drivers/net/wireless/Config.in 2004-11-17 12:54:21.000000000 +0100
21913 +++ linux-2.4.32-brcm/drivers/net/wireless/Config.in 2005-12-16 23:39:11.364863000 +0100
21914 @@ -13,6 +13,7 @@
21915 fi
21916
21917 if [ "$CONFIG_PCI" = "y" ]; then
21918 + dep_tristate ' Proprietary Broadcom BCM43xx 802.11 Wireless support' CONFIG_WL
21919 dep_tristate ' Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.) (EXPERIMENTAL)' CONFIG_PLX_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
21920 dep_tristate ' Hermes in TMD7160/NCP130 based PCI adaptor support (Pheecom WL-PCI etc.) (EXPERIMENTAL)' CONFIG_TMD_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
21921 dep_tristate ' Prism 2.5 PCI 802.11b adaptor support (EXPERIMENTAL)' CONFIG_PCI_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
21922 diff -Nur linux-2.4.32/drivers/net/wl/Makefile linux-2.4.32-brcm/drivers/net/wl/Makefile
21923 --- linux-2.4.32/drivers/net/wl/Makefile 1970-01-01 01:00:00.000000000 +0100
21924 +++ linux-2.4.32-brcm/drivers/net/wl/Makefile 2005-12-16 23:39:11.364863000 +0100
21925 @@ -0,0 +1,26 @@
21926 +#
21927 +# Makefile for the Broadcom wl driver
21928 +#
21929 +# Copyright 2004, Broadcom Corporation
21930 +# All Rights Reserved.
21931 +#
21932 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
21933 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
21934 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
21935 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
21936 +#
21937 +# $Id: Makefile,v 1.2 2005/03/29 03:32:18 mbm Exp $
21938 +
21939 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include
21940 +
21941 +O_TARGET := wl.o
21942 +
21943 +obj-y := apsta_aeskeywrap.o apsta_aes.o apsta_bcmwpa.o apsta_d11ucode.o
21944 +obj-y += apsta_hmac.o apsta_md5.o apsta_passhash.o apsta_prf.o apsta_rc4.o
21945 +obj-y += apsta_rijndael-alg-fst.o apsta_sha1.o apsta_tkhash.o apsta_wlc_led.o
21946 +obj-y += apsta_wlc_phy.o apsta_wlc_rate.o apsta_wlc_security.o
21947 +obj-y += apsta_wlc_sup.o apsta_wlc_wet.o apsta_wl_linux.o apsta_wlc.o
21948 +
21949 +obj-m := $(O_TARGET)
21950 +
21951 +include $(TOPDIR)/Rules.make
21952 diff -Nur linux-2.4.32/drivers/parport/Config.in linux-2.4.32-brcm/drivers/parport/Config.in
21953 --- linux-2.4.32/drivers/parport/Config.in 2004-02-18 14:36:31.000000000 +0100
21954 +++ linux-2.4.32-brcm/drivers/parport/Config.in 2005-12-16 23:39:11.364863000 +0100
21955 @@ -11,6 +11,7 @@
21956 tristate 'Parallel port support' CONFIG_PARPORT
21957 if [ "$CONFIG_PARPORT" != "n" ]; then
21958 dep_tristate ' PC-style hardware' CONFIG_PARPORT_PC $CONFIG_PARPORT
21959 + dep_tristate ' Asus WL500g parallel port' CONFIG_PARPORT_SPLINK $CONFIG_PARPORT
21960 if [ "$CONFIG_PARPORT_PC" != "n" -a "$CONFIG_SERIAL" != "n" ]; then
21961 if [ "$CONFIG_SERIAL" = "m" ]; then
21962 define_tristate CONFIG_PARPORT_PC_CML1 m
21963 diff -Nur linux-2.4.32/drivers/parport/Makefile linux-2.4.32-brcm/drivers/parport/Makefile
21964 --- linux-2.4.32/drivers/parport/Makefile 2004-08-08 01:26:05.000000000 +0200
21965 +++ linux-2.4.32-brcm/drivers/parport/Makefile 2005-12-16 23:39:11.364863000 +0100
21966 @@ -22,6 +22,7 @@
21967
21968 obj-$(CONFIG_PARPORT) += parport.o
21969 obj-$(CONFIG_PARPORT_PC) += parport_pc.o
21970 +obj-$(CONFIG_PARPORT_SPLINK) += parport_splink.o
21971 obj-$(CONFIG_PARPORT_PC_PCMCIA) += parport_cs.o
21972 obj-$(CONFIG_PARPORT_AMIGA) += parport_amiga.o
21973 obj-$(CONFIG_PARPORT_MFC3) += parport_mfc3.o
21974 diff -Nur linux-2.4.32/drivers/parport/parport_splink.c linux-2.4.32-brcm/drivers/parport/parport_splink.c
21975 --- linux-2.4.32/drivers/parport/parport_splink.c 1970-01-01 01:00:00.000000000 +0100
21976 +++ linux-2.4.32-brcm/drivers/parport/parport_splink.c 2005-12-16 23:39:11.364863000 +0100
21977 @@ -0,0 +1,345 @@
21978 +/* Low-level parallel port routines for the ASUS WL-500g built-in port
21979 + *
21980 + * Author: Nuno Grilo <nuno.grilo@netcabo.pt>
21981 + * Based on parport_pc source
21982 + */
21983 +
21984 +#include <linux/config.h>
21985 +#include <linux/module.h>
21986 +#include <linux/init.h>
21987 +#include <linux/ioport.h>
21988 +#include <linux/kernel.h>
21989 +#include <linux/slab.h>
21990 +#include <linux/parport.h>
21991 +#include <linux/parport_pc.h>
21992 +
21993 +#define SPLINK_ADDRESS 0xBF800010
21994 +
21995 +#undef DEBUG
21996 +
21997 +#ifdef DEBUG
21998 +#define DPRINTK printk
21999 +#else
22000 +#define DPRINTK(stuff...)
22001 +#endif
22002 +
22003 +
22004 +/* __parport_splink_frob_control differs from parport_splink_frob_control in that
22005 + * it doesn't do any extra masking. */
22006 +static __inline__ unsigned char __parport_splink_frob_control (struct parport *p,
22007 + unsigned char mask,
22008 + unsigned char val)
22009 +{
22010 + struct parport_pc_private *priv = p->physport->private_data;
22011 + unsigned char *io = (unsigned char *) p->base;
22012 + unsigned char ctr = priv->ctr;
22013 +#ifdef DEBUG_PARPORT
22014 + printk (KERN_DEBUG
22015 + "__parport_splink_frob_control(%02x,%02x): %02x -> %02x\n",
22016 + mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
22017 +#endif
22018 + ctr = (ctr & ~mask) ^ val;
22019 + ctr &= priv->ctr_writable; /* only write writable bits. */
22020 + *(io+2) = ctr;
22021 + priv->ctr = ctr; /* Update soft copy */
22022 + return ctr;
22023 +}
22024 +
22025 +
22026 +
22027 +static void parport_splink_data_forward (struct parport *p)
22028 +{
22029 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
22030 + __parport_splink_frob_control (p, 0x20, 0);
22031 +}
22032 +
22033 +static void parport_splink_data_reverse (struct parport *p)
22034 +{
22035 + DPRINTK(KERN_DEBUG "parport_splink: parport_data_forward called\n");
22036 + __parport_splink_frob_control (p, 0x20, 0x20);
22037 +}
22038 +
22039 +/*
22040 +static void parport_splink_interrupt(int irq, void *dev_id, struct pt_regs *regs)
22041 +{
22042 + DPRINTK(KERN_DEBUG "parport_splink: IRQ handler called\n");
22043 + parport_generic_irq(irq, (struct parport *) dev_id, regs);
22044 +}
22045 +*/
22046 +
22047 +static void parport_splink_enable_irq(struct parport *p)
22048 +{
22049 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_enable_irq called\n");
22050 + __parport_splink_frob_control (p, 0x10, 0x10);
22051 +}
22052 +
22053 +static void parport_splink_disable_irq(struct parport *p)
22054 +{
22055 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_disable_irq called\n");
22056 + __parport_splink_frob_control (p, 0x10, 0);
22057 +}
22058 +
22059 +static void parport_splink_init_state(struct pardevice *dev, struct parport_state *s)
22060 +{
22061 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_init_state called\n");
22062 + s->u.pc.ctr = 0xc | (dev->irq_func ? 0x10 : 0x0);
22063 + if (dev->irq_func &&
22064 + dev->port->irq != PARPORT_IRQ_NONE)
22065 + /* Set ackIntEn */
22066 + s->u.pc.ctr |= 0x10;
22067 +}
22068 +
22069 +static void parport_splink_save_state(struct parport *p, struct parport_state *s)
22070 +{
22071 + const struct parport_pc_private *priv = p->physport->private_data;
22072 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_save_state called\n");
22073 + s->u.pc.ctr = priv->ctr;
22074 +}
22075 +
22076 +static void parport_splink_restore_state(struct parport *p, struct parport_state *s)
22077 +{
22078 + struct parport_pc_private *priv = p->physport->private_data;
22079 + unsigned char *io = (unsigned char *) p->base;
22080 + unsigned char ctr = s->u.pc.ctr;
22081 +
22082 + DPRINTK(KERN_DEBUG "parport_splink: parport_splink_restore_state called\n");
22083 + *(io+2) = ctr;
22084 + priv->ctr = ctr;
22085 +}
22086 +
22087 +static void parport_splink_setup_interrupt(void) {
22088 + return;
22089 +}
22090 +
22091 +static void parport_splink_write_data(struct parport *p, unsigned char d) {
22092 + DPRINTK(KERN_DEBUG "parport_splink: write data called\n");
22093 + unsigned char *io = (unsigned char *) p->base;
22094 + *io = d;
22095 +}
22096 +
22097 +static unsigned char parport_splink_read_data(struct parport *p) {
22098 + DPRINTK(KERN_DEBUG "parport_splink: read data called\n");
22099 + unsigned char *io = (unsigned char *) p->base;
22100 + return *io;
22101 +}
22102 +
22103 +static void parport_splink_write_control(struct parport *p, unsigned char d)
22104 +{
22105 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
22106 + PARPORT_CONTROL_AUTOFD |
22107 + PARPORT_CONTROL_INIT |
22108 + PARPORT_CONTROL_SELECT);
22109 +
22110 + DPRINTK(KERN_DEBUG "parport_splink: write control called\n");
22111 + /* Take this out when drivers have adapted to the newer interface. */
22112 + if (d & 0x20) {
22113 + printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
22114 + p->name, p->cad->name);
22115 + parport_splink_data_reverse (p);
22116 + }
22117 +
22118 + __parport_splink_frob_control (p, wm, d & wm);
22119 +}
22120 +
22121 +static unsigned char parport_splink_read_control(struct parport *p)
22122 +{
22123 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
22124 + PARPORT_CONTROL_AUTOFD |
22125 + PARPORT_CONTROL_INIT |
22126 + PARPORT_CONTROL_SELECT);
22127 + DPRINTK(KERN_DEBUG "parport_splink: read control called\n");
22128 + const struct parport_pc_private *priv = p->physport->private_data;
22129 + return priv->ctr & wm; /* Use soft copy */
22130 +}
22131 +
22132 +static unsigned char parport_splink_frob_control (struct parport *p, unsigned char mask,
22133 + unsigned char val)
22134 +{
22135 + const unsigned char wm = (PARPORT_CONTROL_STROBE |
22136 + PARPORT_CONTROL_AUTOFD |
22137 + PARPORT_CONTROL_INIT |
22138 + PARPORT_CONTROL_SELECT);
22139 +
22140 + DPRINTK(KERN_DEBUG "parport_splink: frob control called\n");
22141 + /* Take this out when drivers have adapted to the newer interface. */
22142 + if (mask & 0x20) {
22143 + printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
22144 + p->name, p->cad->name,
22145 + (val & 0x20) ? "reverse" : "forward");
22146 + if (val & 0x20)
22147 + parport_splink_data_reverse (p);
22148 + else
22149 + parport_splink_data_forward (p);
22150 + }
22151 +
22152 + /* Restrict mask and val to control lines. */
22153 + mask &= wm;
22154 + val &= wm;
22155 +
22156 + return __parport_splink_frob_control (p, mask, val);
22157 +}
22158 +
22159 +static unsigned char parport_splink_read_status(struct parport *p)
22160 +{
22161 + DPRINTK(KERN_DEBUG "parport_splink: read status called\n");
22162 + unsigned char *io = (unsigned char *) p->base;
22163 + return *(io+1);
22164 +}
22165 +
22166 +static void parport_splink_inc_use_count(void)
22167 +{
22168 +#ifdef MODULE
22169 + MOD_INC_USE_COUNT;
22170 +#endif
22171 +}
22172 +
22173 +static void parport_splink_dec_use_count(void)
22174 +{
22175 +#ifdef MODULE
22176 + MOD_DEC_USE_COUNT;
22177 +#endif
22178 +}
22179 +
22180 +static struct parport_operations parport_splink_ops =
22181 +{
22182 + parport_splink_write_data,
22183 + parport_splink_read_data,
22184 +
22185 + parport_splink_write_control,
22186 + parport_splink_read_control,
22187 + parport_splink_frob_control,
22188 +
22189 + parport_splink_read_status,
22190 +
22191 + parport_splink_enable_irq,
22192 + parport_splink_disable_irq,
22193 +
22194 + parport_splink_data_forward,
22195 + parport_splink_data_reverse,
22196 +
22197 + parport_splink_init_state,
22198 + parport_splink_save_state,
22199 + parport_splink_restore_state,
22200 +
22201 + parport_splink_inc_use_count,
22202 + parport_splink_dec_use_count,
22203 +
22204 + parport_ieee1284_epp_write_data,
22205 + parport_ieee1284_epp_read_data,
22206 + parport_ieee1284_epp_write_addr,
22207 + parport_ieee1284_epp_read_addr,
22208 +
22209 + parport_ieee1284_ecp_write_data,
22210 + parport_ieee1284_ecp_read_data,
22211 + parport_ieee1284_ecp_write_addr,
22212 +
22213 + parport_ieee1284_write_compat,
22214 + parport_ieee1284_read_nibble,
22215 + parport_ieee1284_read_byte,
22216 +};
22217 +
22218 +/* --- Initialisation code -------------------------------- */
22219 +
22220 +static struct parport *parport_splink_probe_port (unsigned long int base)
22221 +{
22222 + struct parport_pc_private *priv;
22223 + struct parport_operations *ops;
22224 + struct parport *p;
22225 +
22226 + if (check_mem_region(base, 3)) {
22227 + printk (KERN_DEBUG "parport (0x%lx): iomem region not available\n", base);
22228 + return NULL;
22229 + }
22230 + priv = kmalloc (sizeof (struct parport_pc_private), GFP_KERNEL);
22231 + if (!priv) {
22232 + printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base);
22233 + return NULL;
22234 + }
22235 + ops = kmalloc (sizeof (struct parport_operations), GFP_KERNEL);
22236 + if (!ops) {
22237 + printk (KERN_DEBUG "parport (0x%lx): no memory for ops!\n",
22238 + base);
22239 + kfree (priv);
22240 + return NULL;
22241 + }
22242 + memcpy (ops, &parport_splink_ops, sizeof (struct parport_operations));
22243 + priv->ctr = 0xc;
22244 + priv->ctr_writable = 0xff;
22245 +
22246 + if (!(p = parport_register_port(base, PARPORT_IRQ_NONE,
22247 + PARPORT_DMA_NONE, ops))) {
22248 + printk (KERN_DEBUG "parport (0x%lx): registration failed!\n",
22249 + base);
22250 + kfree (priv);
22251 + kfree (ops);
22252 + return NULL;
22253 + }
22254 +
22255 + p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;
22256 + p->size = (p->modes & PARPORT_MODE_EPP)?8:3;
22257 + p->private_data = priv;
22258 +
22259 + parport_proc_register(p);
22260 + request_mem_region (p->base, 3, p->name);
22261 +
22262 + /* Done probing. Now put the port into a sensible start-up state. */
22263 + parport_splink_write_data(p, 0);
22264 + parport_splink_data_forward (p);
22265 +
22266 + /* Now that we've told the sharing engine about the port, and
22267 + found out its characteristics, let the high-level drivers
22268 + know about it. */
22269 + parport_announce_port (p);
22270 +
22271 + DPRINTK(KERN_DEBUG "parport (0x%lx): init ok!\n",
22272 + base);
22273 + return p;
22274 +}
22275 +
22276 +static void parport_splink_unregister_port(struct parport *p) {
22277 + struct parport_pc_private *priv = p->private_data;
22278 + struct parport_operations *ops = p->ops;
22279 +
22280 + if (p->irq != PARPORT_IRQ_NONE)
22281 + free_irq(p->irq, p);
22282 + release_mem_region(p->base, 3);
22283 + parport_proc_unregister(p);
22284 + kfree (priv);
22285 + parport_unregister_port(p);
22286 + kfree (ops);
22287 +}
22288 +
22289 +
22290 +int parport_splink_init(void)
22291 +{
22292 + int ret;
22293 +
22294 + DPRINTK(KERN_DEBUG "parport_splink init called\n");
22295 + parport_splink_setup_interrupt();
22296 + ret = !parport_splink_probe_port(SPLINK_ADDRESS);
22297 +
22298 + return ret;
22299 +}
22300 +
22301 +void parport_splink_cleanup(void) {
22302 + struct parport *p = parport_enumerate(), *tmp;
22303 + DPRINTK(KERN_DEBUG "parport_splink cleanup called\n");
22304 + if (p->size) {
22305 + if (p->modes & PARPORT_MODE_PCSPP) {
22306 + while(p) {
22307 + tmp = p->next;
22308 + parport_splink_unregister_port(p);
22309 + p = tmp;
22310 + }
22311 + }
22312 + }
22313 +}
22314 +
22315 +MODULE_AUTHOR("Nuno Grilo <nuno.grilo@netcabo.pt>");
22316 +MODULE_DESCRIPTION("Parport Driver for ASUS WL-500g router builtin Port");
22317 +MODULE_SUPPORTED_DEVICE("ASUS WL-500g builtin Parallel Port");
22318 +MODULE_LICENSE("GPL");
22319 +
22320 +module_init(parport_splink_init)
22321 +module_exit(parport_splink_cleanup)
22322 +
22323 diff -Nur linux-2.4.32/drivers/pcmcia/bcm4710_generic.c linux-2.4.32-brcm/drivers/pcmcia/bcm4710_generic.c
22324 --- linux-2.4.32/drivers/pcmcia/bcm4710_generic.c 1970-01-01 01:00:00.000000000 +0100
22325 +++ linux-2.4.32-brcm/drivers/pcmcia/bcm4710_generic.c 2005-12-16 23:39:11.368863250 +0100
22326 @@ -0,0 +1,912 @@
22327 +/*
22328 + *
22329 + * bcm47xx pcmcia driver
22330 + *
22331 + * Copyright 2004, Broadcom Corporation
22332 + * All Rights Reserved.
22333 + *
22334 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
22335 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
22336 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
22337 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
22338 + *
22339 + * Based on sa1100_generic.c from www.handhelds.org,
22340 + * and au1000_generic.c from oss.sgi.com.
22341 + *
22342 + * $Id: bcm4710_generic.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
22343 + */
22344 +#include <linux/module.h>
22345 +#include <linux/init.h>
22346 +#include <linux/config.h>
22347 +#include <linux/delay.h>
22348 +#include <linux/ioport.h>
22349 +#include <linux/kernel.h>
22350 +#include <linux/tqueue.h>
22351 +#include <linux/timer.h>
22352 +#include <linux/mm.h>
22353 +#include <linux/proc_fs.h>
22354 +#include <linux/version.h>
22355 +#include <linux/types.h>
22356 +#include <linux/vmalloc.h>
22357 +
22358 +#include <pcmcia/version.h>
22359 +#include <pcmcia/cs_types.h>
22360 +#include <pcmcia/cs.h>
22361 +#include <pcmcia/ss.h>
22362 +#include <pcmcia/bulkmem.h>
22363 +#include <pcmcia/cistpl.h>
22364 +#include <pcmcia/bus_ops.h>
22365 +#include "cs_internal.h"
22366 +
22367 +#include <asm/io.h>
22368 +#include <asm/irq.h>
22369 +#include <asm/system.h>
22370 +
22371 +#include <typedefs.h>
22372 +#include <bcm4710.h>
22373 +#include <sbextif.h>
22374 +
22375 +#include "bcm4710pcmcia.h"
22376 +
22377 +#ifdef PCMCIA_DEBUG
22378 +static int pc_debug = PCMCIA_DEBUG;
22379 +#endif
22380 +
22381 +MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm47xx Socket Controller");
22382 +
22383 +/* This structure maintains housekeeping state for each socket, such
22384 + * as the last known values of the card detect pins, or the Card Services
22385 + * callback value associated with the socket:
22386 + */
22387 +static struct bcm47xx_pcmcia_socket *pcmcia_socket;
22388 +static int socket_count;
22389 +
22390 +
22391 +/* Returned by the low-level PCMCIA interface: */
22392 +static struct pcmcia_low_level *pcmcia_low_level;
22393 +
22394 +/* Event poll timer structure */
22395 +static struct timer_list poll_timer;
22396 +
22397 +
22398 +/* Prototypes for routines which are used internally: */
22399 +
22400 +static int bcm47xx_pcmcia_driver_init(void);
22401 +static void bcm47xx_pcmcia_driver_shutdown(void);
22402 +static void bcm47xx_pcmcia_task_handler(void *data);
22403 +static void bcm47xx_pcmcia_poll_event(unsigned long data);
22404 +static void bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs);
22405 +static struct tq_struct bcm47xx_pcmcia_task;
22406 +
22407 +#ifdef CONFIG_PROC_FS
22408 +static int bcm47xx_pcmcia_proc_status(char *buf, char **start,
22409 + off_t pos, int count, int *eof, void *data);
22410 +#endif
22411 +
22412 +
22413 +/* Prototypes for operations which are exported to the
22414 + * in-kernel PCMCIA core:
22415 + */
22416 +
22417 +static int bcm47xx_pcmcia_init(unsigned int sock);
22418 +static int bcm47xx_pcmcia_suspend(unsigned int sock);
22419 +static int bcm47xx_pcmcia_register_callback(unsigned int sock,
22420 + void (*handler)(void *, unsigned int), void *info);
22421 +static int bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap);
22422 +static int bcm47xx_pcmcia_get_status(unsigned int sock, u_int *value);
22423 +static int bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state);
22424 +static int bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state);
22425 +static int bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *io);
22426 +static int bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *io);
22427 +static int bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *mem);
22428 +static int bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *mem);
22429 +#ifdef CONFIG_PROC_FS
22430 +static void bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base);
22431 +#endif
22432 +
22433 +static struct pccard_operations bcm47xx_pcmcia_operations = {
22434 + bcm47xx_pcmcia_init,
22435 + bcm47xx_pcmcia_suspend,
22436 + bcm47xx_pcmcia_register_callback,
22437 + bcm47xx_pcmcia_inquire_socket,
22438 + bcm47xx_pcmcia_get_status,
22439 + bcm47xx_pcmcia_get_socket,
22440 + bcm47xx_pcmcia_set_socket,
22441 + bcm47xx_pcmcia_get_io_map,
22442 + bcm47xx_pcmcia_set_io_map,
22443 + bcm47xx_pcmcia_get_mem_map,
22444 + bcm47xx_pcmcia_set_mem_map,
22445 +#ifdef CONFIG_PROC_FS
22446 + bcm47xx_pcmcia_proc_setup
22447 +#endif
22448 +};
22449 +
22450 +
22451 +/*
22452 + * bcm47xx_pcmcia_driver_init()
22453 + *
22454 + * This routine performs a basic sanity check to ensure that this
22455 + * kernel has been built with the appropriate board-specific low-level
22456 + * PCMCIA support, performs low-level PCMCIA initialization, registers
22457 + * this socket driver with Card Services, and then spawns the daemon
22458 + * thread which is the real workhorse of the socket driver.
22459 + *
22460 + * Please see linux/Documentation/arm/SA1100/PCMCIA for more information
22461 + * on the low-level kernel interface.
22462 + *
22463 + * Returns: 0 on success, -1 on error
22464 + */
22465 +static int __init bcm47xx_pcmcia_driver_init(void)
22466 +{
22467 + servinfo_t info;
22468 + struct pcmcia_init pcmcia_init;
22469 + struct pcmcia_state state;
22470 + unsigned int i;
22471 + unsigned long tmp;
22472 +
22473 +
22474 + printk("\nBCM47XX PCMCIA (CS release %s)\n", CS_RELEASE);
22475 +
22476 + CardServices(GetCardServicesInfo, &info);
22477 +
22478 + if (info.Revision != CS_RELEASE_CODE) {
22479 + printk(KERN_ERR "Card Services release codes do not match\n");
22480 + return -1;
22481 + }
22482 +
22483 +#ifdef CONFIG_BCM4710
22484 + pcmcia_low_level=&bcm4710_pcmcia_ops;
22485 +#else
22486 +#error Unsupported Broadcom BCM47XX board.
22487 +#endif
22488 +
22489 + pcmcia_init.handler=bcm47xx_pcmcia_interrupt;
22490 +
22491 + if ((socket_count = pcmcia_low_level->init(&pcmcia_init)) < 0) {
22492 + printk(KERN_ERR "Unable to initialize PCMCIA service.\n");
22493 + return -EIO;
22494 + } else {
22495 + printk("\t%d PCMCIA sockets initialized.\n", socket_count);
22496 + }
22497 +
22498 + pcmcia_socket =
22499 + kmalloc(sizeof(struct bcm47xx_pcmcia_socket) * socket_count,
22500 + GFP_KERNEL);
22501 + memset(pcmcia_socket, 0,
22502 + sizeof(struct bcm47xx_pcmcia_socket) * socket_count);
22503 + if (!pcmcia_socket) {
22504 + printk(KERN_ERR "Card Services can't get memory \n");
22505 + return -1;
22506 + }
22507 +
22508 + for (i = 0; i < socket_count; i++) {
22509 + if (pcmcia_low_level->socket_state(i, &state) < 0) {
22510 + printk(KERN_ERR "Unable to get PCMCIA status\n");
22511 + return -EIO;
22512 + }
22513 + pcmcia_socket[i].k_state = state;
22514 + pcmcia_socket[i].cs_state.csc_mask = SS_DETECT;
22515 +
22516 + if (i == 0) {
22517 + pcmcia_socket[i].virt_io =
22518 + (unsigned long)ioremap_nocache(EXTIF_PCMCIA_IOBASE(BCM4710_EXTIF), 0x1000);
22519 + /* Substract ioport base which gets added by in/out */
22520 + pcmcia_socket[i].virt_io -= mips_io_port_base;
22521 + pcmcia_socket[i].phys_attr =
22522 + (unsigned long)EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF);
22523 + pcmcia_socket[i].phys_mem =
22524 + (unsigned long)EXTIF_PCMCIA_MEMBASE(BCM4710_EXTIF);
22525 + } else {
22526 + printk(KERN_ERR "bcm4710: socket 1 not supported\n");
22527 + return 1;
22528 + }
22529 + }
22530 +
22531 + /* Only advertise as many sockets as we can detect: */
22532 + if (register_ss_entry(socket_count, &bcm47xx_pcmcia_operations) < 0) {
22533 + printk(KERN_ERR "Unable to register socket service routine\n");
22534 + return -ENXIO;
22535 + }
22536 +
22537 + /* Start the event poll timer.
22538 + * It will reschedule by itself afterwards.
22539 + */
22540 + bcm47xx_pcmcia_poll_event(0);
22541 +
22542 + DEBUG(1, "bcm4710: initialization complete\n");
22543 + return 0;
22544 +
22545 +}
22546 +
22547 +module_init(bcm47xx_pcmcia_driver_init);
22548 +
22549 +
22550 +/*
22551 + * bcm47xx_pcmcia_driver_shutdown()
22552 + *
22553 + * Invokes the low-level kernel service to free IRQs associated with this
22554 + * socket controller and reset GPIO edge detection.
22555 + */
22556 +static void __exit bcm47xx_pcmcia_driver_shutdown(void)
22557 +{
22558 + int i;
22559 +
22560 + del_timer_sync(&poll_timer);
22561 + unregister_ss_entry(&bcm47xx_pcmcia_operations);
22562 + pcmcia_low_level->shutdown();
22563 + flush_scheduled_tasks();
22564 + for (i = 0; i < socket_count; i++) {
22565 + if (pcmcia_socket[i].virt_io)
22566 + iounmap((void *)pcmcia_socket[i].virt_io);
22567 + if (pcmcia_socket[i].phys_attr)
22568 + iounmap((void *)pcmcia_socket[i].phys_attr);
22569 + if (pcmcia_socket[i].phys_mem)
22570 + iounmap((void *)pcmcia_socket[i].phys_mem);
22571 + }
22572 + DEBUG(1, "bcm4710: shutdown complete\n");
22573 +}
22574 +
22575 +module_exit(bcm47xx_pcmcia_driver_shutdown);
22576 +
22577 +/*
22578 + * bcm47xx_pcmcia_init()
22579 + * We perform all of the interesting initialization tasks in
22580 + * bcm47xx_pcmcia_driver_init().
22581 + *
22582 + * Returns: 0
22583 + */
22584 +static int bcm47xx_pcmcia_init(unsigned int sock)
22585 +{
22586 + DEBUG(1, "%s(): initializing socket %u\n", __FUNCTION__, sock);
22587 +
22588 + return 0;
22589 +}
22590 +
22591 +/*
22592 + * bcm47xx_pcmcia_suspend()
22593 + *
22594 + * We don't currently perform any actions on a suspend.
22595 + *
22596 + * Returns: 0
22597 + */
22598 +static int bcm47xx_pcmcia_suspend(unsigned int sock)
22599 +{
22600 + DEBUG(1, "%s(): suspending socket %u\n", __FUNCTION__, sock);
22601 +
22602 + return 0;
22603 +}
22604 +
22605 +
22606 +/*
22607 + * bcm47xx_pcmcia_events()
22608 + *
22609 + * Helper routine to generate a Card Services event mask based on
22610 + * state information obtained from the kernel low-level PCMCIA layer
22611 + * in a recent (and previous) sampling. Updates `prev_state'.
22612 + *
22613 + * Returns: an event mask for the given socket state.
22614 + */
22615 +static inline unsigned
22616 +bcm47xx_pcmcia_events(struct pcmcia_state *state,
22617 + struct pcmcia_state *prev_state,
22618 + unsigned int mask, unsigned int flags)
22619 +{
22620 + unsigned int events=0;
22621 +
22622 + if (state->bvd1 != prev_state->bvd1) {
22623 +
22624 + DEBUG(3, "%s(): card BVD1 value %u\n", __FUNCTION__, state->bvd1);
22625 +
22626 + events |= mask & (flags & SS_IOCARD) ? SS_STSCHG : SS_BATDEAD;
22627 + }
22628 +
22629 + if (state->bvd2 != prev_state->bvd2) {
22630 +
22631 + DEBUG(3, "%s(): card BVD2 value %u\n", __FUNCTION__, state->bvd2);
22632 +
22633 + events |= mask & (flags & SS_IOCARD) ? 0 : SS_BATWARN;
22634 + }
22635 +
22636 + if (state->detect != prev_state->detect) {
22637 +
22638 + DEBUG(3, "%s(): card detect value %u\n", __FUNCTION__, state->detect);
22639 +
22640 + events |= mask & SS_DETECT;
22641 + }
22642 +
22643 +
22644 + if (state->ready != prev_state->ready) {
22645 +
22646 + DEBUG(3, "%s(): card ready value %u\n", __FUNCTION__, state->ready);
22647 +
22648 + events |= mask & ((flags & SS_IOCARD) ? 0 : SS_READY);
22649 + }
22650 +
22651 + if (events != 0) {
22652 + DEBUG(2, "events: %s%s%s%s%s\n",
22653 + (events & SS_DETECT) ? "DETECT " : "",
22654 + (events & SS_READY) ? "READY " : "",
22655 + (events & SS_BATDEAD) ? "BATDEAD " : "",
22656 + (events & SS_BATWARN) ? "BATWARN " : "",
22657 + (events & SS_STSCHG) ? "STSCHG " : "");
22658 + }
22659 +
22660 + *prev_state=*state;
22661 + return events;
22662 +}
22663 +
22664 +
22665 +/*
22666 + * bcm47xx_pcmcia_task_handler()
22667 + *
22668 + * Processes serviceable socket events using the "eventd" thread context.
22669 + *
22670 + * Event processing (specifically, the invocation of the Card Services event
22671 + * callback) occurs in this thread rather than in the actual interrupt
22672 + * handler due to the use of scheduling operations in the PCMCIA core.
22673 + */
22674 +static void bcm47xx_pcmcia_task_handler(void *data)
22675 +{
22676 + struct pcmcia_state state;
22677 + int i, events, irq_status;
22678 +
22679 + DEBUG(4, "%s(): entering PCMCIA monitoring thread\n", __FUNCTION__);
22680 +
22681 + for (i = 0; i < socket_count; i++) {
22682 + if ((irq_status = pcmcia_low_level->socket_state(i, &state)) < 0)
22683 + printk(KERN_ERR "Error in kernel low-level PCMCIA service.\n");
22684 +
22685 + events = bcm47xx_pcmcia_events(&state,
22686 + &pcmcia_socket[i].k_state,
22687 + pcmcia_socket[i].cs_state.csc_mask,
22688 + pcmcia_socket[i].cs_state.flags);
22689 +
22690 + if (pcmcia_socket[i].handler != NULL) {
22691 + pcmcia_socket[i].handler(pcmcia_socket[i].handler_info,
22692 + events);
22693 + }
22694 + }
22695 +}
22696 +
22697 +static struct tq_struct bcm47xx_pcmcia_task = {
22698 + routine: bcm47xx_pcmcia_task_handler
22699 +};
22700 +
22701 +
22702 +/*
22703 + * bcm47xx_pcmcia_poll_event()
22704 + *
22705 + * Let's poll for events in addition to IRQs since IRQ only is unreliable...
22706 + */
22707 +static void bcm47xx_pcmcia_poll_event(unsigned long dummy)
22708 +{
22709 + DEBUG(4, "%s(): polling for events\n", __FUNCTION__);
22710 +
22711 + poll_timer.function = bcm47xx_pcmcia_poll_event;
22712 + poll_timer.expires = jiffies + BCM47XX_PCMCIA_POLL_PERIOD;
22713 + add_timer(&poll_timer);
22714 + schedule_task(&bcm47xx_pcmcia_task);
22715 +}
22716 +
22717 +
22718 +/*
22719 + * bcm47xx_pcmcia_interrupt()
22720 + *
22721 + * Service routine for socket driver interrupts (requested by the
22722 + * low-level PCMCIA init() operation via bcm47xx_pcmcia_thread()).
22723 + *
22724 + * The actual interrupt-servicing work is performed by
22725 + * bcm47xx_pcmcia_task(), largely because the Card Services event-
22726 + * handling code performs scheduling operations which cannot be
22727 + * executed from within an interrupt context.
22728 + */
22729 +static void
22730 +bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs)
22731 +{
22732 + DEBUG(3, "%s(): servicing IRQ %d\n", __FUNCTION__, irq);
22733 + schedule_task(&bcm47xx_pcmcia_task);
22734 +}
22735 +
22736 +
22737 +/*
22738 + * bcm47xx_pcmcia_register_callback()
22739 + *
22740 + * Implements the register_callback() operation for the in-kernel
22741 + * PCMCIA service (formerly SS_RegisterCallback in Card Services). If
22742 + * the function pointer `handler' is not NULL, remember the callback
22743 + * location in the state for `sock', and increment the usage counter
22744 + * for the driver module. (The callback is invoked from the interrupt
22745 + * service routine, bcm47xx_pcmcia_interrupt(), to notify Card Services
22746 + * of interesting events.) Otherwise, clear the callback pointer in the
22747 + * socket state and decrement the module usage count.
22748 + *
22749 + * Returns: 0
22750 + */
22751 +static int
22752 +bcm47xx_pcmcia_register_callback(unsigned int sock,
22753 + void (*handler)(void *, unsigned int), void *info)
22754 +{
22755 + if (handler == NULL) {
22756 + pcmcia_socket[sock].handler = NULL;
22757 + MOD_DEC_USE_COUNT;
22758 + } else {
22759 + MOD_INC_USE_COUNT;
22760 + pcmcia_socket[sock].handler = handler;
22761 + pcmcia_socket[sock].handler_info = info;
22762 + }
22763 + return 0;
22764 +}
22765 +
22766 +
22767 +/*
22768 + * bcm47xx_pcmcia_inquire_socket()
22769 + *
22770 + * Implements the inquire_socket() operation for the in-kernel PCMCIA
22771 + * service (formerly SS_InquireSocket in Card Services). Of note is
22772 + * the setting of the SS_CAP_PAGE_REGS bit in the `features' field of
22773 + * `cap' to "trick" Card Services into tolerating large "I/O memory"
22774 + * addresses. Also set is SS_CAP_STATIC_MAP, which disables the memory
22775 + * resource database check. (Mapped memory is set up within the socket
22776 + * driver itself.)
22777 + *
22778 + * In conjunction with the STATIC_MAP capability is a new field,
22779 + * `io_offset', recommended by David Hinds. Rather than go through
22780 + * the SetIOMap interface (which is not quite suited for communicating
22781 + * window locations up from the socket driver), we just pass up
22782 + * an offset which is applied to client-requested base I/O addresses
22783 + * in alloc_io_space().
22784 + *
22785 + * Returns: 0 on success, -1 if no pin has been configured for `sock'
22786 + */
22787 +static int
22788 +bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap)
22789 +{
22790 + struct pcmcia_irq_info irq_info;
22791 +
22792 + if (sock >= socket_count) {
22793 + printk(KERN_ERR "bcm47xx: socket %u not configured\n", sock);
22794 + return -1;
22795 + }
22796 +
22797 + /* SS_CAP_PAGE_REGS: used by setup_cis_mem() in cistpl.c to set the
22798 + * force_low argument to validate_mem() in rsrc_mgr.c -- since in
22799 + * general, the mapped * addresses of the PCMCIA memory regions
22800 + * will not be within 0xffff, setting force_low would be
22801 + * undesirable.
22802 + *
22803 + * SS_CAP_STATIC_MAP: don't bother with the (user-configured) memory
22804 + * resource database; we instead pass up physical address ranges
22805 + * and allow other parts of Card Services to deal with remapping.
22806 + *
22807 + * SS_CAP_PCCARD: we can deal with 16-bit PCMCIA & CF cards, but
22808 + * not 32-bit CardBus devices.
22809 + */
22810 + cap->features = (SS_CAP_PAGE_REGS | SS_CAP_STATIC_MAP | SS_CAP_PCCARD);
22811 +
22812 + irq_info.sock = sock;
22813 + irq_info.irq = -1;
22814 +
22815 + if (pcmcia_low_level->get_irq_info(&irq_info) < 0) {
22816 + printk(KERN_ERR "Error obtaining IRQ info socket %u\n", sock);
22817 + return -1;
22818 + }
22819 +
22820 + cap->irq_mask = 0;
22821 + cap->map_size = PAGE_SIZE;
22822 + cap->pci_irq = irq_info.irq;
22823 + cap->io_offset = pcmcia_socket[sock].virt_io;
22824 +
22825 + return 0;
22826 +}
22827 +
22828 +
22829 +/*
22830 + * bcm47xx_pcmcia_get_status()
22831 + *
22832 + * Implements the get_status() operation for the in-kernel PCMCIA
22833 + * service (formerly SS_GetStatus in Card Services). Essentially just
22834 + * fills in bits in `status' according to internal driver state or
22835 + * the value of the voltage detect chipselect register.
22836 + *
22837 + * As a debugging note, during card startup, the PCMCIA core issues
22838 + * three set_socket() commands in a row the first with RESET deasserted,
22839 + * the second with RESET asserted, and the last with RESET deasserted
22840 + * again. Following the third set_socket(), a get_status() command will
22841 + * be issued. The kernel is looking for the SS_READY flag (see
22842 + * setup_socket(), reset_socket(), and unreset_socket() in cs.c).
22843 + *
22844 + * Returns: 0
22845 + */
22846 +static int
22847 +bcm47xx_pcmcia_get_status(unsigned int sock, unsigned int *status)
22848 +{
22849 + struct pcmcia_state state;
22850 +
22851 +
22852 + if ((pcmcia_low_level->socket_state(sock, &state)) < 0) {
22853 + printk(KERN_ERR "Unable to get PCMCIA status from kernel.\n");
22854 + return -1;
22855 + }
22856 +
22857 + pcmcia_socket[sock].k_state = state;
22858 +
22859 + *status = state.detect ? SS_DETECT : 0;
22860 +
22861 + *status |= state.ready ? SS_READY : 0;
22862 +
22863 + /* The power status of individual sockets is not available
22864 + * explicitly from the hardware, so we just remember the state
22865 + * and regurgitate it upon request:
22866 + */
22867 + *status |= pcmcia_socket[sock].cs_state.Vcc ? SS_POWERON : 0;
22868 +
22869 + if (pcmcia_socket[sock].cs_state.flags & SS_IOCARD)
22870 + *status |= state.bvd1 ? SS_STSCHG : 0;
22871 + else {
22872 + if (state.bvd1 == 0)
22873 + *status |= SS_BATDEAD;
22874 + else if (state.bvd2 == 0)
22875 + *status |= SS_BATWARN;
22876 + }
22877 +
22878 + *status |= state.vs_3v ? SS_3VCARD : 0;
22879 +
22880 + *status |= state.vs_Xv ? SS_XVCARD : 0;
22881 +
22882 + DEBUG(2, "\tstatus: %s%s%s%s%s%s%s%s\n",
22883 + (*status&SS_DETECT)?"DETECT ":"",
22884 + (*status&SS_READY)?"READY ":"",
22885 + (*status&SS_BATDEAD)?"BATDEAD ":"",
22886 + (*status&SS_BATWARN)?"BATWARN ":"",
22887 + (*status&SS_POWERON)?"POWERON ":"",
22888 + (*status&SS_STSCHG)?"STSCHG ":"",
22889 + (*status&SS_3VCARD)?"3VCARD ":"",
22890 + (*status&SS_XVCARD)?"XVCARD ":"");
22891 +
22892 + return 0;
22893 +}
22894 +
22895 +
22896 +/*
22897 + * bcm47xx_pcmcia_get_socket()
22898 + *
22899 + * Implements the get_socket() operation for the in-kernel PCMCIA
22900 + * service (formerly SS_GetSocket in Card Services). Not a very
22901 + * exciting routine.
22902 + *
22903 + * Returns: 0
22904 + */
22905 +static int
22906 +bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state)
22907 +{
22908 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
22909 +
22910 + /* This information was given to us in an earlier call to set_socket(),
22911 + * so we're just regurgitating it here:
22912 + */
22913 + *state = pcmcia_socket[sock].cs_state;
22914 + return 0;
22915 +}
22916 +
22917 +
22918 +/*
22919 + * bcm47xx_pcmcia_set_socket()
22920 + *
22921 + * Implements the set_socket() operation for the in-kernel PCMCIA
22922 + * service (formerly SS_SetSocket in Card Services). We more or
22923 + * less punt all of this work and let the kernel handle the details
22924 + * of power configuration, reset, &c. We also record the value of
22925 + * `state' in order to regurgitate it to the PCMCIA core later.
22926 + *
22927 + * Returns: 0
22928 + */
22929 +static int
22930 +bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state)
22931 +{
22932 + struct pcmcia_configure configure;
22933 +
22934 + DEBUG(2, "\tmask: %s%s%s%s%s%s\n\tflags: %s%s%s%s%s%s\n"
22935 + "\tVcc %d Vpp %d irq %d\n",
22936 + (state->csc_mask == 0) ? "<NONE>" : "",
22937 + (state->csc_mask & SS_DETECT) ? "DETECT " : "",
22938 + (state->csc_mask & SS_READY) ? "READY " : "",
22939 + (state->csc_mask & SS_BATDEAD) ? "BATDEAD " : "",
22940 + (state->csc_mask & SS_BATWARN) ? "BATWARN " : "",
22941 + (state->csc_mask & SS_STSCHG) ? "STSCHG " : "",
22942 + (state->flags == 0) ? "<NONE>" : "",
22943 + (state->flags & SS_PWR_AUTO) ? "PWR_AUTO " : "",
22944 + (state->flags & SS_IOCARD) ? "IOCARD " : "",
22945 + (state->flags & SS_RESET) ? "RESET " : "",
22946 + (state->flags & SS_SPKR_ENA) ? "SPKR_ENA " : "",
22947 + (state->flags & SS_OUTPUT_ENA) ? "OUTPUT_ENA " : "",
22948 + state->Vcc, state->Vpp, state->io_irq);
22949 +
22950 + configure.sock = sock;
22951 + configure.vcc = state->Vcc;
22952 + configure.vpp = state->Vpp;
22953 + configure.output = (state->flags & SS_OUTPUT_ENA) ? 1 : 0;
22954 + configure.speaker = (state->flags & SS_SPKR_ENA) ? 1 : 0;
22955 + configure.reset = (state->flags & SS_RESET) ? 1 : 0;
22956 +
22957 + if (pcmcia_low_level->configure_socket(&configure) < 0) {
22958 + printk(KERN_ERR "Unable to configure socket %u\n", sock);
22959 + return -1;
22960 + }
22961 +
22962 + pcmcia_socket[sock].cs_state = *state;
22963 + return 0;
22964 +}
22965 +
22966 +
22967 +/*
22968 + * bcm47xx_pcmcia_get_io_map()
22969 + *
22970 + * Implements the get_io_map() operation for the in-kernel PCMCIA
22971 + * service (formerly SS_GetIOMap in Card Services). Just returns an
22972 + * I/O map descriptor which was assigned earlier by a set_io_map().
22973 + *
22974 + * Returns: 0 on success, -1 if the map index was out of range
22975 + */
22976 +static int
22977 +bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *map)
22978 +{
22979 + DEBUG(2, "bcm47xx_pcmcia_get_io_map: sock %d\n", sock);
22980 +
22981 + if (map->map >= MAX_IO_WIN) {
22982 + printk(KERN_ERR "%s(): map (%d) out of range\n",
22983 + __FUNCTION__, map->map);
22984 + return -1;
22985 + }
22986 +
22987 + *map = pcmcia_socket[sock].io_map[map->map];
22988 + return 0;
22989 +}
22990 +
22991 +
22992 +/*
22993 + * bcm47xx_pcmcia_set_io_map()
22994 + *
22995 + * Implements the set_io_map() operation for the in-kernel PCMCIA
22996 + * service (formerly SS_SetIOMap in Card Services). We configure
22997 + * the map speed as requested, but override the address ranges
22998 + * supplied by Card Services.
22999 + *
23000 + * Returns: 0 on success, -1 on error
23001 + */
23002 +int
23003 +bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *map)
23004 +{
23005 + unsigned int speed;
23006 + unsigned long start;
23007 +
23008 + DEBUG(2, "\tmap %u speed %u\n\tstart 0x%08lx stop 0x%08lx\n"
23009 + "\tflags: %s%s%s%s%s%s%s%s\n",
23010 + map->map, map->speed, map->start, map->stop,
23011 + (map->flags == 0) ? "<NONE>" : "",
23012 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
23013 + (map->flags & MAP_16BIT) ? "16BIT " : "",
23014 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
23015 + (map->flags & MAP_0WS) ? "0WS " : "",
23016 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
23017 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "",
23018 + (map->flags & MAP_PREFETCH) ? "PREFETCH " : "");
23019 +
23020 + if (map->map >= MAX_IO_WIN) {
23021 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23022 + __FUNCTION__, map->map);
23023 + return -1;
23024 + }
23025 +
23026 + if (map->flags & MAP_ACTIVE) {
23027 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_IO_SPEED;
23028 + pcmcia_socket[sock].speed_io = speed;
23029 + }
23030 +
23031 + start = map->start;
23032 +
23033 + if (map->stop == 1) {
23034 + map->stop = PAGE_SIZE - 1;
23035 + }
23036 +
23037 + map->start = pcmcia_socket[sock].virt_io;
23038 + map->stop = map->start + (map->stop - start);
23039 + pcmcia_socket[sock].io_map[map->map] = *map;
23040 + DEBUG(2, "set_io_map %d start %x stop %x\n",
23041 + map->map, map->start, map->stop);
23042 + return 0;
23043 +}
23044 +
23045 +
23046 +/*
23047 + * bcm47xx_pcmcia_get_mem_map()
23048 + *
23049 + * Implements the get_mem_map() operation for the in-kernel PCMCIA
23050 + * service (formerly SS_GetMemMap in Card Services). Just returns a
23051 + * memory map descriptor which was assigned earlier by a
23052 + * set_mem_map() request.
23053 + *
23054 + * Returns: 0 on success, -1 if the map index was out of range
23055 + */
23056 +static int
23057 +bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *map)
23058 +{
23059 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock);
23060 +
23061 + if (map->map >= MAX_WIN) {
23062 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23063 + __FUNCTION__, map->map);
23064 + return -1;
23065 + }
23066 +
23067 + *map = pcmcia_socket[sock].mem_map[map->map];
23068 + return 0;
23069 +}
23070 +
23071 +
23072 +/*
23073 + * bcm47xx_pcmcia_set_mem_map()
23074 + *
23075 + * Implements the set_mem_map() operation for the in-kernel PCMCIA
23076 + * service (formerly SS_SetMemMap in Card Services). We configure
23077 + * the map speed as requested, but override the address ranges
23078 + * supplied by Card Services.
23079 + *
23080 + * Returns: 0 on success, -1 on error
23081 + */
23082 +static int
23083 +bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *map)
23084 +{
23085 + unsigned int speed;
23086 + unsigned long start;
23087 + u_long flags;
23088 +
23089 + if (map->map >= MAX_WIN) {
23090 + printk(KERN_ERR "%s(): map (%d) out of range\n",
23091 + __FUNCTION__, map->map);
23092 + return -1;
23093 + }
23094 +
23095 + DEBUG(2, "\tmap %u speed %u\n\tsys_start %#lx\n"
23096 + "\tsys_stop %#lx\n\tcard_start %#x\n"
23097 + "\tflags: %s%s%s%s%s%s%s%s\n",
23098 + map->map, map->speed, map->sys_start, map->sys_stop,
23099 + map->card_start, (map->flags == 0) ? "<NONE>" : "",
23100 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
23101 + (map->flags & MAP_16BIT) ? "16BIT " : "",
23102 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
23103 + (map->flags & MAP_0WS) ? "0WS " : "",
23104 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
23105 + (map->flags & MAP_ATTRIB) ? "ATTRIB " : "",
23106 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "");
23107 +
23108 + if (map->flags & MAP_ACTIVE) {
23109 + /* When clients issue RequestMap, the access speed is not always
23110 + * properly configured:
23111 + */
23112 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_MEM_SPEED;
23113 +
23114 + /* TBD */
23115 + if (map->flags & MAP_ATTRIB) {
23116 + pcmcia_socket[sock].speed_attr = speed;
23117 + } else {
23118 + pcmcia_socket[sock].speed_mem = speed;
23119 + }
23120 + }
23121 +
23122 + save_flags(flags);
23123 + cli();
23124 + start = map->sys_start;
23125 +
23126 + if (map->sys_stop == 0)
23127 + map->sys_stop = PAGE_SIZE - 1;
23128 +
23129 + if (map->flags & MAP_ATTRIB) {
23130 + map->sys_start = pcmcia_socket[sock].phys_attr +
23131 + map->card_start;
23132 + } else {
23133 + map->sys_start = pcmcia_socket[sock].phys_mem +
23134 + map->card_start;
23135 + }
23136 +
23137 + map->sys_stop = map->sys_start + (map->sys_stop - start);
23138 + pcmcia_socket[sock].mem_map[map->map] = *map;
23139 + restore_flags(flags);
23140 + DEBUG(2, "set_mem_map %d start %x stop %x card_start %x\n",
23141 + map->map, map->sys_start, map->sys_stop,
23142 + map->card_start);
23143 + return 0;
23144 +}
23145 +
23146 +
23147 +#if defined(CONFIG_PROC_FS)
23148 +
23149 +/*
23150 + * bcm47xx_pcmcia_proc_setup()
23151 + *
23152 + * Implements the proc_setup() operation for the in-kernel PCMCIA
23153 + * service (formerly SS_ProcSetup in Card Services).
23154 + *
23155 + * Returns: 0 on success, -1 on error
23156 + */
23157 +static void
23158 +bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base)
23159 +{
23160 + struct proc_dir_entry *entry;
23161 +
23162 + if ((entry = create_proc_entry("status", 0, base)) == NULL) {
23163 + printk(KERN_ERR "Unable to install \"status\" procfs entry\n");
23164 + return;
23165 + }
23166 +
23167 + entry->read_proc = bcm47xx_pcmcia_proc_status;
23168 + entry->data = (void *)sock;
23169 +}
23170 +
23171 +
23172 +/*
23173 + * bcm47xx_pcmcia_proc_status()
23174 + *
23175 + * Implements the /proc/bus/pccard/??/status file.
23176 + *
23177 + * Returns: the number of characters added to the buffer
23178 + */
23179 +static int
23180 +bcm47xx_pcmcia_proc_status(char *buf, char **start, off_t pos,
23181 + int count, int *eof, void *data)
23182 +{
23183 + char *p = buf;
23184 + unsigned int sock = (unsigned int)data;
23185 +
23186 + p += sprintf(p, "k_flags : %s%s%s%s%s%s%s\n",
23187 + pcmcia_socket[sock].k_state.detect ? "detect " : "",
23188 + pcmcia_socket[sock].k_state.ready ? "ready " : "",
23189 + pcmcia_socket[sock].k_state.bvd1 ? "bvd1 " : "",
23190 + pcmcia_socket[sock].k_state.bvd2 ? "bvd2 " : "",
23191 + pcmcia_socket[sock].k_state.wrprot ? "wrprot " : "",
23192 + pcmcia_socket[sock].k_state.vs_3v ? "vs_3v " : "",
23193 + pcmcia_socket[sock].k_state.vs_Xv ? "vs_Xv " : "");
23194 +
23195 + p += sprintf(p, "status : %s%s%s%s%s%s%s%s%s\n",
23196 + pcmcia_socket[sock].k_state.detect ? "SS_DETECT " : "",
23197 + pcmcia_socket[sock].k_state.ready ? "SS_READY " : "",
23198 + pcmcia_socket[sock].cs_state.Vcc ? "SS_POWERON " : "",
23199 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ? "SS_IOCARD " : "",
23200 + (pcmcia_socket[sock].cs_state.flags & SS_IOCARD &&
23201 + pcmcia_socket[sock].k_state.bvd1) ? "SS_STSCHG " : "",
23202 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
23203 + (pcmcia_socket[sock].k_state.bvd1 == 0)) ? "SS_BATDEAD " : "",
23204 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 &&
23205 + (pcmcia_socket[sock].k_state.bvd2 == 0)) ? "SS_BATWARN " : "",
23206 + pcmcia_socket[sock].k_state.vs_3v ? "SS_3VCARD " : "",
23207 + pcmcia_socket[sock].k_state.vs_Xv ? "SS_XVCARD " : "");
23208 +
23209 + p += sprintf(p, "mask : %s%s%s%s%s\n",
23210 + pcmcia_socket[sock].cs_state.csc_mask & SS_DETECT ? "SS_DETECT " : "",
23211 + pcmcia_socket[sock].cs_state.csc_mask & SS_READY ? "SS_READY " : "",
23212 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATDEAD ? "SS_BATDEAD " : "",
23213 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATWARN ? "SS_BATWARN " : "",
23214 + pcmcia_socket[sock].cs_state.csc_mask & SS_STSCHG ? "SS_STSCHG " : "");
23215 +
23216 + p += sprintf(p, "cs_flags : %s%s%s%s%s\n",
23217 + pcmcia_socket[sock].cs_state.flags & SS_PWR_AUTO ?
23218 + "SS_PWR_AUTO " : "",
23219 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ?
23220 + "SS_IOCARD " : "",
23221 + pcmcia_socket[sock].cs_state.flags & SS_RESET ?
23222 + "SS_RESET " : "",
23223 + pcmcia_socket[sock].cs_state.flags & SS_SPKR_ENA ?
23224 + "SS_SPKR_ENA " : "",
23225 + pcmcia_socket[sock].cs_state.flags & SS_OUTPUT_ENA ?
23226 + "SS_OUTPUT_ENA " : "");
23227 +
23228 + p += sprintf(p, "Vcc : %d\n", pcmcia_socket[sock].cs_state.Vcc);
23229 + p += sprintf(p, "Vpp : %d\n", pcmcia_socket[sock].cs_state.Vpp);
23230 + p += sprintf(p, "irq : %d\n", pcmcia_socket[sock].cs_state.io_irq);
23231 + p += sprintf(p, "I/O : %u\n", pcmcia_socket[sock].speed_io);
23232 + p += sprintf(p, "attribute: %u\n", pcmcia_socket[sock].speed_attr);
23233 + p += sprintf(p, "common : %u\n", pcmcia_socket[sock].speed_mem);
23234 + return p-buf;
23235 +}
23236 +
23237 +
23238 +#endif /* defined(CONFIG_PROC_FS) */
23239 diff -Nur linux-2.4.32/drivers/pcmcia/bcm4710_pcmcia.c linux-2.4.32-brcm/drivers/pcmcia/bcm4710_pcmcia.c
23240 --- linux-2.4.32/drivers/pcmcia/bcm4710_pcmcia.c 1970-01-01 01:00:00.000000000 +0100
23241 +++ linux-2.4.32-brcm/drivers/pcmcia/bcm4710_pcmcia.c 2005-12-16 23:39:11.368863250 +0100
23242 @@ -0,0 +1,266 @@
23243 +/*
23244 + * BCM4710 specific pcmcia routines.
23245 + *
23246 + * Copyright 2004, Broadcom Corporation
23247 + * All Rights Reserved.
23248 + *
23249 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
23250 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
23251 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
23252 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
23253 + *
23254 + * $Id: bcm4710_pcmcia.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
23255 + */
23256 +#include <linux/module.h>
23257 +#include <linux/init.h>
23258 +#include <linux/config.h>
23259 +#include <linux/delay.h>
23260 +#include <linux/ioport.h>
23261 +#include <linux/kernel.h>
23262 +#include <linux/tqueue.h>
23263 +#include <linux/timer.h>
23264 +#include <linux/mm.h>
23265 +#include <linux/proc_fs.h>
23266 +#include <linux/version.h>
23267 +#include <linux/types.h>
23268 +#include <linux/pci.h>
23269 +
23270 +#include <pcmcia/version.h>
23271 +#include <pcmcia/cs_types.h>
23272 +#include <pcmcia/cs.h>
23273 +#include <pcmcia/ss.h>
23274 +#include <pcmcia/bulkmem.h>
23275 +#include <pcmcia/cistpl.h>
23276 +#include <pcmcia/bus_ops.h>
23277 +#include "cs_internal.h"
23278 +
23279 +#include <asm/io.h>
23280 +#include <asm/irq.h>
23281 +#include <asm/system.h>
23282 +
23283 +
23284 +#include <typedefs.h>
23285 +#include <bcmdevs.h>
23286 +#include <bcm4710.h>
23287 +#include <sbconfig.h>
23288 +#include <sbextif.h>
23289 +
23290 +#include "bcm4710pcmcia.h"
23291 +
23292 +/* Use a static var for irq dev_id */
23293 +static int bcm47xx_pcmcia_dev_id;
23294 +
23295 +/* Do we think we have a card or not? */
23296 +static int bcm47xx_pcmcia_present = 0;
23297 +
23298 +
23299 +static void bcm4710_pcmcia_reset(void)
23300 +{
23301 + extifregs_t *eir;
23302 + unsigned long s;
23303 + uint32 out0, out1, outen;
23304 +
23305 +
23306 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
23307 +
23308 + save_and_cli(s);
23309 +
23310 + /* Use gpio7 to reset the pcmcia slot */
23311 + outen = readl(&eir->gpio[0].outen);
23312 + outen |= BCM47XX_PCMCIA_RESET;
23313 + out0 = readl(&eir->gpio[0].out);
23314 + out0 &= ~(BCM47XX_PCMCIA_RESET);
23315 + out1 = out0 | BCM47XX_PCMCIA_RESET;
23316 +
23317 + writel(out0, &eir->gpio[0].out);
23318 + writel(outen, &eir->gpio[0].outen);
23319 + mdelay(1);
23320 + writel(out1, &eir->gpio[0].out);
23321 + mdelay(1);
23322 + writel(out0, &eir->gpio[0].out);
23323 +
23324 + restore_flags(s);
23325 +}
23326 +
23327 +
23328 +static int bcm4710_pcmcia_init(struct pcmcia_init *init)
23329 +{
23330 + struct pci_dev *pdev;
23331 + extifregs_t *eir;
23332 + uint32 outen, intp, intm, tmp;
23333 + uint16 *attrsp;
23334 + int rc = 0, i;
23335 + extern unsigned long bcm4710_cpu_cycle;
23336 +
23337 +
23338 + if (!(pdev = pci_find_device(VENDOR_BROADCOM, SB_EXTIF, NULL))) {
23339 + printk(KERN_ERR "bcm4710_pcmcia: extif not found\n");
23340 + return -ENODEV;
23341 + }
23342 + eir = (extifregs_t *) ioremap_nocache(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
23343 +
23344 + /* Initialize the pcmcia i/f: 16bit no swap */
23345 + writel(CF_EM_PCMCIA | CF_DS | CF_EN, &eir->pcmcia_config);
23346 +
23347 +#ifdef notYet
23348 +
23349 + /* Set the timing for memory accesses */
23350 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
23351 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
23352 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
23353 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
23354 + writel(tmp, &eir->pcmcia_memwait); /* 0x01020a0c for a 100Mhz clock */
23355 +
23356 + /* Set the timing for I/O accesses */
23357 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
23358 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
23359 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
23360 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
23361 + writel(tmp, &eir->pcmcia_iowait); /* 0x01020a0c for a 100Mhz clock */
23362 +
23363 + /* Set the timing for attribute accesses */
23364 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */
23365 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */
23366 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */
23367 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */
23368 + writel(tmp, &eir->pcmcia_attrwait); /* 0x01020a0c for a 100Mhz clock */
23369 +
23370 +#endif
23371 + /* Make sure gpio0 and gpio5 are inputs */
23372 + outen = readl(&eir->gpio[0].outen);
23373 + outen &= ~(BCM47XX_PCMCIA_WP | BCM47XX_PCMCIA_STSCHG | BCM47XX_PCMCIA_RESET);
23374 + writel(outen, &eir->gpio[0].outen);
23375 +
23376 + /* Issue a reset to the pcmcia socket */
23377 + bcm4710_pcmcia_reset();
23378 +
23379 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
23380 + /* Setup gpio5 to be the STSCHG interrupt */
23381 + intp = readl(&eir->gpiointpolarity);
23382 + writel(intp | BCM47XX_PCMCIA_STSCHG, &eir->gpiointpolarity); /* Active low */
23383 + intm = readl(&eir->gpiointmask);
23384 + writel(intm | BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Enable it */
23385 +#endif
23386 +
23387 + DEBUG(2, "bcm4710_pcmcia after reset:\n");
23388 + DEBUG(2, "\textstatus\t= 0x%08x:\n", readl(&eir->extstatus));
23389 + DEBUG(2, "\tpcmcia_config\t= 0x%08x:\n", readl(&eir->pcmcia_config));
23390 + DEBUG(2, "\tpcmcia_memwait\t= 0x%08x:\n", readl(&eir->pcmcia_memwait));
23391 + DEBUG(2, "\tpcmcia_attrwait\t= 0x%08x:\n", readl(&eir->pcmcia_attrwait));
23392 + DEBUG(2, "\tpcmcia_iowait\t= 0x%08x:\n", readl(&eir->pcmcia_iowait));
23393 + DEBUG(2, "\tgpioin\t\t= 0x%08x:\n", readl(&eir->gpioin));
23394 + DEBUG(2, "\tgpio_outen0\t= 0x%08x:\n", readl(&eir->gpio[0].outen));
23395 + DEBUG(2, "\tgpio_out0\t= 0x%08x:\n", readl(&eir->gpio[0].out));
23396 + DEBUG(2, "\tgpiointpolarity\t= 0x%08x:\n", readl(&eir->gpiointpolarity));
23397 + DEBUG(2, "\tgpiointmask\t= 0x%08x:\n", readl(&eir->gpiointmask));
23398 +
23399 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS
23400 + /* Request pcmcia interrupt */
23401 + rc = request_irq(BCM47XX_PCMCIA_IRQ, init->handler, SA_INTERRUPT,
23402 + "PCMCIA Interrupt", &bcm47xx_pcmcia_dev_id);
23403 +#endif
23404 +
23405 + attrsp = (uint16 *)ioremap_nocache(EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF), 0x1000);
23406 + tmp = readw(&attrsp[0]);
23407 + DEBUG(2, "\tattr[0] = 0x%04x\n", tmp);
23408 + if ((tmp == 0x7fff) || (tmp == 0x7f00)) {
23409 + bcm47xx_pcmcia_present = 0;
23410 + } else {
23411 + bcm47xx_pcmcia_present = 1;
23412 + }
23413 +
23414 + /* There's only one socket */
23415 + return 1;
23416 +}
23417 +
23418 +static int bcm4710_pcmcia_shutdown(void)
23419 +{
23420 + extifregs_t *eir;
23421 + uint32 intm;
23422 +
23423 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
23424 +
23425 + /* Disable the pcmcia i/f */
23426 + writel(0, &eir->pcmcia_config);
23427 +
23428 + /* Reset gpio's */
23429 + intm = readl(&eir->gpiointmask);
23430 + writel(intm & ~BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Disable it */
23431 +
23432 + free_irq(BCM47XX_PCMCIA_IRQ, &bcm47xx_pcmcia_dev_id);
23433 +
23434 + return 0;
23435 +}
23436 +
23437 +static int
23438 +bcm4710_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
23439 +{
23440 + extifregs_t *eir;
23441 +
23442 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t));
23443 +
23444 +
23445 + if (sock != 0) {
23446 + printk(KERN_ERR "bcm4710 socket_state bad sock %d\n", sock);
23447 + return -1;
23448 + }
23449 +
23450 + if (bcm47xx_pcmcia_present) {
23451 + state->detect = 1;
23452 + state->ready = 1;
23453 + state->bvd1 = 1;
23454 + state->bvd2 = 1;
23455 + state->wrprot = (readl(&eir->gpioin) & BCM47XX_PCMCIA_WP) == BCM47XX_PCMCIA_WP;
23456 + state->vs_3v = 0;
23457 + state->vs_Xv = 0;
23458 + } else {
23459 + state->detect = 0;
23460 + state->ready = 0;
23461 + }
23462 +
23463 + return 1;
23464 +}
23465 +
23466 +
23467 +static int bcm4710_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
23468 +{
23469 + if (info->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
23470 +
23471 + info->irq = BCM47XX_PCMCIA_IRQ;
23472 +
23473 + return 0;
23474 +}
23475 +
23476 +
23477 +static int
23478 +bcm4710_pcmcia_configure_socket(const struct pcmcia_configure *configure)
23479 +{
23480 + if (configure->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1;
23481 +
23482 +
23483 + DEBUG(2, "Vcc %dV Vpp %dV output %d speaker %d reset %d\n", configure->vcc,
23484 + configure->vpp, configure->output, configure->speaker, configure->reset);
23485 +
23486 + if ((configure->vcc != 50) || (configure->vpp != 50)) {
23487 + printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc,
23488 + configure->vpp);
23489 + }
23490 +
23491 + if (configure->reset) {
23492 + /* Issue a reset to the pcmcia socket */
23493 + DEBUG(1, "%s: Reseting socket\n", __FUNCTION__);
23494 + bcm4710_pcmcia_reset();
23495 + }
23496 +
23497 +
23498 + return 0;
23499 +}
23500 +
23501 +struct pcmcia_low_level bcm4710_pcmcia_ops = {
23502 + bcm4710_pcmcia_init,
23503 + bcm4710_pcmcia_shutdown,
23504 + bcm4710_pcmcia_socket_state,
23505 + bcm4710_pcmcia_get_irq_info,
23506 + bcm4710_pcmcia_configure_socket
23507 +};
23508 +
23509 diff -Nur linux-2.4.32/drivers/pcmcia/bcm4710pcmcia.h linux-2.4.32-brcm/drivers/pcmcia/bcm4710pcmcia.h
23510 --- linux-2.4.32/drivers/pcmcia/bcm4710pcmcia.h 1970-01-01 01:00:00.000000000 +0100
23511 +++ linux-2.4.32-brcm/drivers/pcmcia/bcm4710pcmcia.h 2005-12-16 23:39:11.368863250 +0100
23512 @@ -0,0 +1,118 @@
23513 +/*
23514 + *
23515 + * bcm47xx pcmcia driver
23516 + *
23517 + * Copyright 2004, Broadcom Corporation
23518 + * All Rights Reserved.
23519 + *
23520 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
23521 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
23522 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
23523 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
23524 + *
23525 + * Based on sa1100.h and include/asm-arm/arch-sa1100/pcmica.h
23526 + * from www.handhelds.org,
23527 + * and au1000_generic.c from oss.sgi.com.
23528 + *
23529 + * $Id: bcm4710pcmcia.h,v 1.1 2005/03/16 13:50:00 wbx Exp $
23530 + */
23531 +
23532 +#if !defined(_BCM4710PCMCIA_H)
23533 +#define _BCM4710PCMCIA_H
23534 +
23535 +#include <pcmcia/cs_types.h>
23536 +#include <pcmcia/ss.h>
23537 +#include <pcmcia/bulkmem.h>
23538 +#include <pcmcia/cistpl.h>
23539 +#include "cs_internal.h"
23540 +
23541 +
23542 +/* The 47xx can only support one socket */
23543 +#define BCM47XX_PCMCIA_MAX_SOCK 1
23544 +
23545 +/* In the bcm947xx gpio's are used for some pcmcia functions */
23546 +#define BCM47XX_PCMCIA_WP 0x01 /* Bit 0 is WP input */
23547 +#define BCM47XX_PCMCIA_STSCHG 0x20 /* Bit 5 is STSCHG input/interrupt */
23548 +#define BCM47XX_PCMCIA_RESET 0x80 /* Bit 7 is RESET */
23549 +
23550 +#define BCM47XX_PCMCIA_IRQ 2
23551 +
23552 +/* The socket driver actually works nicely in interrupt-driven form,
23553 + * so the (relatively infrequent) polling is "just to be sure."
23554 + */
23555 +#define BCM47XX_PCMCIA_POLL_PERIOD (2 * HZ)
23556 +
23557 +#define BCM47XX_PCMCIA_IO_SPEED (255)
23558 +#define BCM47XX_PCMCIA_MEM_SPEED (300)
23559 +
23560 +
23561 +struct pcmcia_state {
23562 + unsigned detect: 1,
23563 + ready: 1,
23564 + bvd1: 1,
23565 + bvd2: 1,
23566 + wrprot: 1,
23567 + vs_3v: 1,
23568 + vs_Xv: 1;
23569 +};
23570 +
23571 +
23572 +struct pcmcia_configure {
23573 + unsigned sock: 8,
23574 + vcc: 8,
23575 + vpp: 8,
23576 + output: 1,
23577 + speaker: 1,
23578 + reset: 1;
23579 +};
23580 +
23581 +struct pcmcia_irq_info {
23582 + unsigned int sock;
23583 + unsigned int irq;
23584 +};
23585 +
23586 +/* This structure encapsulates per-socket state which we might need to
23587 + * use when responding to a Card Services query of some kind.
23588 + */
23589 +struct bcm47xx_pcmcia_socket {
23590 + socket_state_t cs_state;
23591 + struct pcmcia_state k_state;
23592 + unsigned int irq;
23593 + void (*handler)(void *, unsigned int);
23594 + void *handler_info;
23595 + pccard_io_map io_map[MAX_IO_WIN];
23596 + pccard_mem_map mem_map[MAX_WIN];
23597 + ioaddr_t virt_io, phys_attr, phys_mem;
23598 + unsigned short speed_io, speed_attr, speed_mem;
23599 +};
23600 +
23601 +struct pcmcia_init {
23602 + void (*handler)(int irq, void *dev, struct pt_regs *regs);
23603 +};
23604 +
23605 +struct pcmcia_low_level {
23606 + int (*init)(struct pcmcia_init *);
23607 + int (*shutdown)(void);
23608 + int (*socket_state)(unsigned sock, struct pcmcia_state *);
23609 + int (*get_irq_info)(struct pcmcia_irq_info *);
23610 + int (*configure_socket)(const struct pcmcia_configure *);
23611 +};
23612 +
23613 +extern struct pcmcia_low_level bcm47xx_pcmcia_ops;
23614 +
23615 +/* I/O pins replacing memory pins
23616 + * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75)
23617 + *
23618 + * These signals change meaning when going from memory-only to
23619 + * memory-or-I/O interface:
23620 + */
23621 +#define iostschg bvd1
23622 +#define iospkr bvd2
23623 +
23624 +
23625 +/*
23626 + * Declaration for implementation specific low_level operations.
23627 + */
23628 +extern struct pcmcia_low_level bcm4710_pcmcia_ops;
23629 +
23630 +#endif /* !defined(_BCM4710PCMCIA_H) */
23631 diff -Nur linux-2.4.32/drivers/pcmcia/Makefile linux-2.4.32-brcm/drivers/pcmcia/Makefile
23632 --- linux-2.4.32/drivers/pcmcia/Makefile 2004-02-18 14:36:31.000000000 +0100
23633 +++ linux-2.4.32-brcm/drivers/pcmcia/Makefile 2005-12-16 23:39:11.364863000 +0100
23634 @@ -65,6 +65,10 @@
23635 au1000_ss-objs-$(CONFIG_PCMCIA_DB1X00) += au1000_db1x00.o
23636 au1000_ss-objs-$(CONFIG_PCMCIA_XXS1500) += au1000_xxs1500.o
23637
23638 +obj-$(CONFIG_PCMCIA_BCM4710) += bcm4710_ss.o
23639 +bcm4710_ss-objs := bcm4710_generic.o
23640 +bcm4710_ss-objs += bcm4710_pcmcia.o
23641 +
23642 obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o
23643 obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o
23644 obj-$(CONFIG_PCMCIA_SIBYTE) += sibyte_generic.o
23645 @@ -102,5 +106,8 @@
23646 au1x00_ss.o: $(au1000_ss-objs-y)
23647 $(LD) -r -o $@ $(au1000_ss-objs-y)
23648
23649 +bcm4710_ss.o: $(bcm4710_ss-objs)
23650 + $(LD) -r -o $@ $(bcm4710_ss-objs)
23651 +
23652 yenta_socket.o: $(yenta_socket-objs)
23653 $(LD) $(LD_RFLAG) -r -o $@ $(yenta_socket-objs)
23654 diff -Nur linux-2.4.32/include/asm-mips/bootinfo.h linux-2.4.32-brcm/include/asm-mips/bootinfo.h
23655 --- linux-2.4.32/include/asm-mips/bootinfo.h 2004-02-18 14:36:32.000000000 +0100
23656 +++ linux-2.4.32-brcm/include/asm-mips/bootinfo.h 2005-12-16 23:39:11.400865250 +0100
23657 @@ -37,6 +37,7 @@
23658 #define MACH_GROUP_HP_LJ 20 /* Hewlett Packard LaserJet */
23659 #define MACH_GROUP_LASAT 21
23660 #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
23661 +#define MACH_GROUP_BRCM 23 /* Broadcom */
23662
23663 /*
23664 * Valid machtype values for group unknown (low order halfword of mips_machtype)
23665 @@ -194,6 +195,15 @@
23666 #define MACH_TANBAC_TB0229 7 /* TANBAC TB0229 (VR4131DIMM) */
23667
23668 /*
23669 + * Valid machtypes for group Broadcom
23670 + */
23671 +#define MACH_BCM93725 0
23672 +#define MACH_BCM93725_VJ 1
23673 +#define MACH_BCM93730 2
23674 +#define MACH_BCM947XX 3
23675 +#define MACH_BCM933XX 4
23676 +
23677 +/*
23678 * Valid machtype for group TITAN
23679 */
23680 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
23681 diff -Nur linux-2.4.32/include/asm-mips/cpu.h linux-2.4.32-brcm/include/asm-mips/cpu.h
23682 --- linux-2.4.32/include/asm-mips/cpu.h 2005-01-19 15:10:11.000000000 +0100
23683 +++ linux-2.4.32-brcm/include/asm-mips/cpu.h 2005-12-16 23:39:11.412866000 +0100
23684 @@ -22,6 +22,11 @@
23685 spec.
23686 */
23687
23688 +#define PRID_COPT_MASK 0xff000000
23689 +#define PRID_COMP_MASK 0x00ff0000
23690 +#define PRID_IMP_MASK 0x0000ff00
23691 +#define PRID_REV_MASK 0x000000ff
23692 +
23693 #define PRID_COMP_LEGACY 0x000000
23694 #define PRID_COMP_MIPS 0x010000
23695 #define PRID_COMP_BROADCOM 0x020000
23696 @@ -58,6 +63,7 @@
23697 #define PRID_IMP_RM7000 0x2700
23698 #define PRID_IMP_NEVADA 0x2800 /* RM5260 ??? */
23699 #define PRID_IMP_RM9000 0x3400
23700 +#define PRID_IMP_BCM4710 0x4000
23701 #define PRID_IMP_R5432 0x5400
23702 #define PRID_IMP_R5500 0x5500
23703 #define PRID_IMP_4KC 0x8000
23704 @@ -66,10 +72,16 @@
23705 #define PRID_IMP_4KEC 0x8400
23706 #define PRID_IMP_4KSC 0x8600
23707 #define PRID_IMP_25KF 0x8800
23708 +#define PRID_IMP_BCM3302 0x9000
23709 +#define PRID_IMP_BCM3303 0x9100
23710 #define PRID_IMP_24K 0x9300
23711
23712 #define PRID_IMP_UNKNOWN 0xff00
23713
23714 +#define BCM330X(id) \
23715 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
23716 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
23717 +
23718 /*
23719 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
23720 */
23721 @@ -174,7 +186,9 @@
23722 #define CPU_AU1550 57
23723 #define CPU_24K 58
23724 #define CPU_AU1200 59
23725 -#define CPU_LAST 59
23726 +#define CPU_BCM4710 60
23727 +#define CPU_BCM3302 61
23728 +#define CPU_LAST 61
23729
23730 /*
23731 * ISA Level encodings
23732 diff -Nur linux-2.4.32/include/asm-mips/r4kcache.h linux-2.4.32-brcm/include/asm-mips/r4kcache.h
23733 --- linux-2.4.32/include/asm-mips/r4kcache.h 2004-02-18 14:36:32.000000000 +0100
23734 +++ linux-2.4.32-brcm/include/asm-mips/r4kcache.h 2005-12-16 23:39:11.416866250 +0100
23735 @@ -567,4 +567,17 @@
23736 cache128_unroll32(addr|ws,Index_Writeback_Inv_SD);
23737 }
23738
23739 +extern inline void fill_icache_line(unsigned long addr)
23740 +{
23741 + __asm__ __volatile__(
23742 + ".set noreorder\n\t"
23743 + ".set mips3\n\t"
23744 + "cache %1, (%0)\n\t"
23745 + ".set mips0\n\t"
23746 + ".set reorder"
23747 + :
23748 + : "r" (addr),
23749 + "i" (Fill));
23750 +}
23751 +
23752 #endif /* __ASM_R4KCACHE_H */
23753 diff -Nur linux-2.4.32/include/asm-mips/serial.h linux-2.4.32-brcm/include/asm-mips/serial.h
23754 --- linux-2.4.32/include/asm-mips/serial.h 2005-01-19 15:10:12.000000000 +0100
23755 +++ linux-2.4.32-brcm/include/asm-mips/serial.h 2005-12-16 23:39:11.428867000 +0100
23756 @@ -223,6 +223,13 @@
23757 #define TXX927_SERIAL_PORT_DEFNS
23758 #endif
23759
23760 +#ifdef CONFIG_BCM947XX
23761 +/* reserve 4 ports to be configured at runtime */
23762 +#define BCM947XX_SERIAL_PORT_DEFNS { 0, }, { 0, }, { 0, }, { 0, },
23763 +#else
23764 +#define BCM947XX_SERIAL_PORT_DEFNS
23765 +#endif
23766 +
23767 #ifdef CONFIG_HAVE_STD_PC_SERIAL_PORT
23768 #define STD_SERIAL_PORT_DEFNS \
23769 /* UART CLK PORT IRQ FLAGS */ \
23770 @@ -470,6 +477,7 @@
23771 #define SERIAL_PORT_DFNS \
23772 ATLAS_SERIAL_PORT_DEFNS \
23773 AU1000_SERIAL_PORT_DEFNS \
23774 + BCM947XX_SERIAL_PORT_DEFNS \
23775 COBALT_SERIAL_PORT_DEFNS \
23776 DDB5477_SERIAL_PORT_DEFNS \
23777 EV96100_SERIAL_PORT_DEFNS \
23778 diff -Nur linux-2.4.32/init/do_mounts.c linux-2.4.32-brcm/init/do_mounts.c
23779 --- linux-2.4.32/init/do_mounts.c 2003-11-28 19:26:21.000000000 +0100
23780 +++ linux-2.4.32-brcm/init/do_mounts.c 2005-12-16 23:39:11.504871750 +0100
23781 @@ -253,7 +253,13 @@
23782 { "ftlb", 0x2c08 },
23783 { "ftlc", 0x2c10 },
23784 { "ftld", 0x2c18 },
23785 +#if defined(CONFIG_MTD_BLOCK) || defined(CONFIG_MTD_BLOCK_RO)
23786 { "mtdblock", 0x1f00 },
23787 + { "mtdblock0",0x1f00 },
23788 + { "mtdblock1",0x1f01 },
23789 + { "mtdblock2",0x1f02 },
23790 + { "mtdblock3",0x1f03 },
23791 +#endif
23792 { "nb", 0x2b00 },
23793 { NULL, 0 }
23794 };
This page took 1.010804 seconds and 5 git commands to generate.