1 diff -urN linux-mips/arch/mips/ar531x/ar531xdbg_io.c mips-linux-2.4.25/arch/mips/ar531x/ar531xdbg_io.c
2 --- linux-mips/arch/mips/ar531x/ar531xdbg_io.c 1970-01-01 01:00:00.000000000 +0100
3 +++ mips-linux-2.4.25/arch/mips/ar531x/ar531xdbg_io.c 2005-12-30 17:26:30.606883840 +0000
6 + * This file is subject to the terms and conditions of the GNU General Public
7 + * License. See the file "COPYING" in the main directory of this archive
10 + * Copyright MontaVista Software Inc
11 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
15 + * Basic support for polled character input/output
16 + * using the AR531X's serial port.
19 +#include <linux/config.h>
20 +#include <linux/init.h>
21 +#include <linux/delay.h>
22 +#include <linux/irq.h>
23 +#include <linux/interrupt.h>
24 +#include <linux/serial.h>
25 +#include <linux/types.h>
26 +#include <linux/string.h>
28 +#include <asm/reboot.h>
30 +#include <asm/time.h>
31 +#include <asm/pgtable.h>
32 +#include <asm/processor.h>
33 +#include <asm/reboot.h>
34 +#include <asm/system.h>
35 +#include <asm/serial.h>
36 +#include <asm/gdb-stub.h>
38 +#include "ar531xlnx.h"
40 +#if CONFIG_EARLY_PRINTK_HACK || CONFIG_KGDB
41 +/* base addr of uart and clock timing */
43 +#define BASE AR5315_UART0
45 +#define BASE AR531X_UART0
48 +/* distance in bytes between two serial registers */
52 + * 0 - we need to do serial init
53 + * 1 - skip serial init
55 +static int serialPortInitialized = 0;
58 + * * the default baud rate *if* we do serial init
60 +#define BAUD_DEFAULT UART16550_BAUD_9600
62 +/* === END OF CONFIG === */
64 +#define UART16550_BAUD_2400 2400
65 +#define UART16550_BAUD_4800 4800
66 +#define UART16550_BAUD_9600 9600
67 +#define UART16550_BAUD_19200 19200
68 +#define UART16550_BAUD_38400 38400
69 +#define UART16550_BAUD_57600 57600
70 +#define UART16550_BAUD_115200 115200
72 +#define UART16550_PARITY_NONE 0
73 +#define UART16550_PARITY_ODD 0x08
74 +#define UART16550_PARITY_EVEN 0x18
75 +#define UART16550_PARITY_MARK 0x28
76 +#define UART16550_PARITY_SPACE 0x38
78 +#define UART16550_DATA_5BIT 0x0
79 +#define UART16550_DATA_6BIT 0x1
80 +#define UART16550_DATA_7BIT 0x2
81 +#define UART16550_DATA_8BIT 0x3
83 +#define UART16550_STOP_1BIT 0x0
84 +#define UART16550_STOP_2BIT 0x4
86 +/* register offset */
87 +#define OFS_RCV_BUFFER (0*REG_OFFSET)
88 +#define OFS_TRANS_HOLD (0*REG_OFFSET)
89 +#define OFS_SEND_BUFFER (0*REG_OFFSET)
90 +#define OFS_INTR_ENABLE (1*REG_OFFSET)
91 +#define OFS_INTR_ID (2*REG_OFFSET)
92 +#define OFS_DATA_FORMAT (3*REG_OFFSET)
93 +#define OFS_LINE_CONTROL (3*REG_OFFSET)
94 +#define OFS_MODEM_CONTROL (4*REG_OFFSET)
95 +#define OFS_RS232_OUTPUT (4*REG_OFFSET)
96 +#define OFS_LINE_STATUS (5*REG_OFFSET)
97 +#define OFS_MODEM_STATUS (6*REG_OFFSET)
98 +#define OFS_RS232_INPUT (6*REG_OFFSET)
99 +#define OFS_SCRATCH_PAD (7*REG_OFFSET)
101 +#define OFS_DIVISOR_LSB (0*REG_OFFSET)
102 +#define OFS_DIVISOR_MSB (1*REG_OFFSET)
105 +/* memory-mapped read/write of the port */
106 +#define UART16550_READ(y) (*((volatile u8*)(BASE + y)))
107 +#define UART16550_WRITE(y, z) ((*((volatile u8*)(BASE + y))) = z)
110 +debugPortInit(u32 baud, u8 data, u8 parity, u8 stop)
112 + /* Pull UART out of reset */
114 + sysRegWrite(AR5315_RESET,
115 + sysRegRead(AR5315_RESET) & ~(RESET_UART0));
117 + sysRegWrite(AR531X_RESET,
118 + sysRegRead(AR531X_RESET) & ~(AR531X_RESET_UART0));
121 + /* disable interrupts */
122 + UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
123 + UART16550_WRITE(OFS_INTR_ENABLE, 0);
125 + /* set up buad rate */
129 + u32 uart_clock_rate = ar531x_apb_frequency();
131 + u32 uart_clock_rate = ar531x_cpu_frequency() / 4;
133 + u32 base_baud = uart_clock_rate / 16;
136 + UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
139 + divisor = base_baud / baud;
140 + UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
141 + UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00)>>8);
143 + /* clear DIAB bit */
144 + UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
147 + /* set data format */
148 + UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
154 + if (!serialPortInitialized) {
155 + serialPortInitialized = 1;
156 + debugPortInit(BAUD_DEFAULT,
157 + UART16550_DATA_8BIT,
158 + UART16550_PARITY_NONE, UART16550_STOP_1BIT);
161 + while((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
162 + return UART16550_READ(OFS_RCV_BUFFER);
167 + * Peek at the most recently received character.
168 + * Don't wait for a new character to be received.
173 + return UART16550_READ(OFS_RCV_BUFFER);
176 +static int kgdbInitialized = 0;
182 + sysRegWrite(AR5315_WDC, WDC_IGNORE_EXPIRATION);
184 + sysRegWrite(AR531X_WD_CTRL, AR531X_WD_CTRL_IGNORE_EXPIRATION);
187 + if (!kgdbInitialized) {
188 + printk("Setting debug traps - please connect the remote debugger.\n");
190 + kgdbInitialized = 1;
198 + return kgdbInitialized;
201 +#define DEBUG_CHAR '\001';
206 + if (!kgdbInitialized) {
211 + * Try to avoid swallowing too much input: Only consume
212 + * a character if nothing new has arrived. Yes, there's
213 + * still a small hole here, and we may lose an input
214 + * character now and then.
216 + if (UART16550_READ(OFS_LINE_STATUS) & 1) {
219 + return UART16550_READ(OFS_RCV_BUFFER) == DEBUG_CHAR;
226 +putDebugChar(char byte)
228 + if (!serialPortInitialized) {
229 + serialPortInitialized = 1;
230 + debugPortInit(BAUD_DEFAULT,
231 + UART16550_DATA_8BIT,
232 + UART16550_PARITY_NONE, UART16550_STOP_1BIT);
235 + while ((UART16550_READ(OFS_LINE_STATUS) &0x20) == 0);
236 + UART16550_WRITE(OFS_SEND_BUFFER, byte);
238 +#endif /* CONFIG_EARLY_PRINTK_HACK || CONFIG_KGDB */
239 diff -urN linux-mips/arch/mips/ar531x/ar531xgpio.c mips-linux-2.4.25/arch/mips/ar531x/ar531xgpio.c
240 --- linux-mips/arch/mips/ar531x/ar531xgpio.c 1970-01-01 01:00:00.000000000 +0100
241 +++ mips-linux-2.4.25/arch/mips/ar531x/ar531xgpio.c 2005-12-30 17:26:30.606883840 +0000
244 + * This file is subject to the terms and conditions of the GNU General Public
245 + * License. See the file "COPYING" in the main directory of this archive
246 + * for more details.
248 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
252 + * Support for GPIO -- General Purpose Input/Output Pins
255 +#include <linux/config.h>
256 +#include <linux/kernel.h>
257 +#include <linux/signal.h>
258 +#include <linux/interrupt.h>
259 +#include <linux/irq.h>
261 +#include "ar531xlnx.h"
263 +/* GPIO Interrupt Support */
265 +/* Turn on the specified AR531X_GPIO_IRQ interrupt */
267 +ar531x_gpio_intr_startup(unsigned int irq)
269 + ar531x_gpio_intr_enable(irq);
273 +/* Turn off the specified AR531X_GPIO_IRQ interrupt */
275 +ar531x_gpio_intr_shutdown(unsigned int irq)
277 + ar531x_gpio_intr_disable(irq);
280 +u32 gpioIntMask = 0;
282 +/* Enable the specified AR531X_GPIO_IRQ interrupt */
284 +ar531x_gpio_intr_enable(unsigned int irq)
289 +#ifndef CONFIG_AR5315
290 + gpio = irq - AR531X_GPIO_IRQ_BASE;
291 + gpioIntMask |= gpio;
293 + reg = sysRegRead(AR531X_GPIO_CR);
294 + reg &= ~(GPIO_CR_M(gpio) | GPIO_CR_UART(gpio) | GPIO_CR_INT(gpio));
295 + reg |= GPIO_CR_I(gpio);
296 + reg |= GPIO_CR_INT(gpio);
298 + sysRegWrite(AR531X_GPIO_CR, reg);
299 + (void)sysRegRead(AR531X_GPIO_CR); /* flush to hardware */
303 +/* Disable the specified AR531X_GPIO_IRQ interrupt */
305 +ar531x_gpio_intr_disable(unsigned int irq)
310 +#ifndef CONFIG_AR5315
311 + gpio = irq - AR531X_GPIO_IRQ_BASE;
312 + reg = sysRegRead(AR531X_GPIO_CR);
313 + reg &= ~(GPIO_CR_M(gpio) | GPIO_CR_UART(gpio) | GPIO_CR_INT(gpio));
314 + reg |= GPIO_CR_I(gpio);
315 + /* No GPIO_CR_INT bit */
317 + sysRegWrite(AR531X_GPIO_CR, reg);
318 + (void)sysRegRead(AR531X_GPIO_CR); /* flush to hardware */
320 + gpioIntMask &= ~gpio;
325 +ar531x_gpio_intr_ack(unsigned int irq)
327 + ar531x_gpio_intr_disable(irq);
331 +ar531x_gpio_intr_end(unsigned int irq)
333 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
334 + ar531x_gpio_intr_enable(irq);
338 +ar531x_gpio_intr_set_affinity(unsigned int irq, unsigned long mask)
340 + /* Only 1 CPU; ignore affinity request */
343 +int ar531x_gpio_irq_base;
345 +struct hw_interrupt_type ar531x_gpio_intr_controller = {
347 + ar531x_gpio_intr_startup,
348 + ar531x_gpio_intr_shutdown,
349 + ar531x_gpio_intr_enable,
350 + ar531x_gpio_intr_disable,
351 + ar531x_gpio_intr_ack,
352 + ar531x_gpio_intr_end,
353 + ar531x_gpio_intr_set_affinity,
357 +ar531x_gpio_intr_init(int irq_base)
361 + for (i = irq_base; i < irq_base + AR531X_GPIO_IRQ_COUNT; i++) {
362 + irq_desc[i].status = IRQ_DISABLED;
363 + irq_desc[i].action = NULL;
364 + irq_desc[i].depth = 1;
365 + irq_desc[i].handler = &ar531x_gpio_intr_controller;
368 + ar531x_gpio_irq_base = irq_base;
373 +spurious_gpio_handler(int cpl, void *dev_id, struct pt_regs *regs)
377 + gpioDataIn = sysRegRead(AR5315_GPIO_DI) & gpioIntMask;
379 + gpioDataIn = sysRegRead(AR531X_GPIO_DI) & gpioIntMask;
382 + printk("spurious_gpio_handler: 0x%x di=0x%8.8x gpioIntMask=0x%8.8x\n",
383 + cpl, gpioDataIn, gpioIntMask);
386 +struct irqaction spurious_gpio =
387 + {spurious_gpio_handler, SA_INTERRUPT, 0, "spurious_gpio",
390 diff -urN linux-mips/arch/mips/ar531x/ar531x.h mips-linux-2.4.25/arch/mips/ar531x/ar531x.h
391 --- linux-mips/arch/mips/ar531x/ar531x.h 1970-01-01 01:00:00.000000000 +0100
392 +++ mips-linux-2.4.25/arch/mips/ar531x/ar531x.h 2005-12-30 17:26:30.605883992 +0000
395 + * This file is subject to the terms and conditions of the GNU General Public
396 + * License. See the file "COPYING" in the main directory of this archive
397 + * for more details.
399 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
405 +#ifndef CONFIG_AR5315
407 +#include <asm/addrspace.h>
410 +#define AR531X_WLAN0 0x18000000
411 +#define AR531X_WLAN1 0x18500000
412 +#define AR531X_ENET0 0x18100000
413 +#define AR531X_ENET1 0x18200000
414 +#define AR531X_SDRAMCTL 0x18300000
415 +#define AR531X_FLASHCTL 0x18400000
416 +#define AR531X_APBBASE 0x1c000000
417 +#define AR531X_FLASH 0x1e000000
418 +#define AR531X_UART0 0xbc000003 /* UART MMR */
421 + * AR531X_NUM_ENET_MAC defines the number of ethernet MACs that
422 + * should be considered available. The AR5312 supports 2 enet MACS,
423 + * even though many reference boards only actually use 1 of them
424 + * (i.e. Only MAC 0 is actually connected to an enet PHY or PHY switch.
425 + * The AR2312 supports 1 enet MAC.
427 +#define AR531X_NUM_ENET_MAC 2
430 + * Need these defines to determine true number of ethernet MACs
432 +#define AR5212_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
433 +#define AR5212_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
434 +#define AR5212_AR2313_REV8 0x0058 /* AR2313 WMAC (AP43-030) */
435 +#define AR531X_RADIO_MASK_OFF 0xc8
436 +#define AR531X_RADIO0_MASK 0x0003
437 +#define AR531X_RADIO1_MASK 0x000c
438 +#define AR531X_RADIO1_S 2
441 + * AR531X_NUM_WMAC defines the number of Wireless MACs that\
442 + * should be considered available.
444 +#define AR531X_NUM_WMAC 2
446 +/* Reset/Timer Block Address Map */
447 +#define AR531X_RESETTMR (AR531X_APBBASE + 0x3000)
448 +#define AR531X_TIMER (AR531X_RESETTMR + 0x0000) /* countdown timer */
449 +#define AR531X_WD_CTRL (AR531X_RESETTMR + 0x0008) /* watchdog cntrl */
450 +#define AR531X_WD_TIMER (AR531X_RESETTMR + 0x000c) /* watchdog timer */
451 +#define AR531X_ISR (AR531X_RESETTMR + 0x0010) /* Intr Status Reg */
452 +#define AR531X_IMR (AR531X_RESETTMR + 0x0014) /* Intr Mask Reg */
453 +#define AR531X_RESET (AR531X_RESETTMR + 0x0020)
454 +#define AR5312_CLOCKCTL1 (AR531X_RESETTMR + 0x0064)
455 +#define AR5312_SCRATCH (AR531X_RESETTMR + 0x006c)
456 +#define AR531X_PROCADDR (AR531X_RESETTMR + 0x0070)
457 +#define AR531X_PROC1 (AR531X_RESETTMR + 0x0074)
458 +#define AR531X_DMAADDR (AR531X_RESETTMR + 0x0078)
459 +#define AR531X_DMA1 (AR531X_RESETTMR + 0x007c)
460 +#define AR531X_ENABLE (AR531X_RESETTMR + 0x0080) /* interface enb */
461 +#define AR531X_REV (AR531X_RESETTMR + 0x0090) /* revision */
463 +/* AR531X_WD_CTRL register bit field definitions */
464 +#define AR531X_WD_CTRL_IGNORE_EXPIRATION 0x0000
465 +#define AR531X_WD_CTRL_NMI 0x0001
466 +#define AR531X_WD_CTRL_RESET 0x0002
468 +/* AR531X_ISR register bit field definitions */
469 +#define AR531X_ISR_NONE 0x0000
470 +#define AR531X_ISR_TIMER 0x0001
471 +#define AR531X_ISR_AHBPROC 0x0002
472 +#define AR531X_ISR_AHBDMA 0x0004
473 +#define AR531X_ISR_GPIO 0x0008
474 +#define AR531X_ISR_UART0 0x0010
475 +#define AR531X_ISR_UART0DMA 0x0020
476 +#define AR531X_ISR_WD 0x0040
477 +#define AR531X_ISR_LOCAL 0x0080
479 +/* AR531X_RESET register bit field definitions */
480 +#define AR531X_RESET_SYSTEM 0x00000001 /* cold reset full system */
481 +#define AR531X_RESET_PROC 0x00000002 /* cold reset MIPS core */
482 +#define AR531X_RESET_WLAN0 0x00000004 /* cold reset WLAN MAC and BB */
483 +#define AR531X_RESET_EPHY0 0x00000008 /* cold reset ENET0 phy */
484 +#define AR531X_RESET_EPHY1 0x00000010 /* cold reset ENET1 phy */
485 +#define AR531X_RESET_ENET0 0x00000020 /* cold reset ENET0 mac */
486 +#define AR531X_RESET_ENET1 0x00000040 /* cold reset ENET1 mac */
487 +#define AR531X_RESET_UART0 0x00000100 /* cold reset UART0 (high speed) */
488 +#define AR531X_RESET_WLAN1 0x00000200 /* cold reset WLAN MAC/BB */
489 +#define AR531X_RESET_APB 0x00000400 /* cold reset APB (ar5312) */
490 +#define AR531X_RESET_WARM_PROC 0x00001000 /* warm reset MIPS core */
491 +#define AR531X_RESET_WARM_WLAN0_MAC 0x00002000 /* warm reset WLAN0 MAC */
492 +#define AR531X_RESET_WARM_WLAN0_BB 0x00004000 /* warm reset WLAN0 BaseBand */
493 +#define AR531X_RESET_NMI 0x00010000 /* send an NMI to the processor */
494 +#define AR531X_RESET_WARM_WLAN1_MAC 0x00020000 /* warm reset WLAN1 mac */
495 +#define AR531X_RESET_WARM_WLAN1_BB 0x00040000 /* warm reset WLAN1 baseband */
496 +#define AR531X_RESET_LOCAL_BUS 0x00080000 /* reset local bus */
497 +#define AR531X_RESET_WDOG 0x00100000 /* last reset was a watchdog */
499 +#define AR531X_RESET_WMAC0_BITS \
500 + AR531X_RESET_WLAN0 |\
501 + AR531X_RESET_WARM_WLAN0_MAC |\
502 + AR531X_RESET_WARM_WLAN0_BB
504 +#define AR531X_RESERT_WMAC1_BITS \
505 + AR531X_RESET_WLAN1 |\
506 + AR531X_RESET_WARM_WLAN1_MAC |\
507 + AR531X_RESET_WARM_WLAN1_BB
509 +/* AR5312_CLOCKCTL1 register bit field definitions */
510 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
511 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
512 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
513 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
514 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
516 +/* Valid for AR5312 and AR2312 */
517 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
518 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
519 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
520 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
521 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
523 +/* Valid for AR2313 */
524 +#define AR2313_CLOCKCTL1_PREDIVIDE_MASK 0x00003000
525 +#define AR2313_CLOCKCTL1_PREDIVIDE_SHIFT 12
526 +#define AR2313_CLOCKCTL1_MULTIPLIER_MASK 0x001f0000
527 +#define AR2313_CLOCKCTL1_MULTIPLIER_SHIFT 16
528 +#define AR2313_CLOCKCTL1_DOUBLER_MASK 0x00000000
531 +/* AR531X_ENABLE register bit field definitions */
532 +#define AR531X_ENABLE_WLAN0 0x0001
533 +#define AR531X_ENABLE_ENET0 0x0002
534 +#define AR531X_ENABLE_ENET1 0x0004
535 +#define AR531X_ENABLE_UART_AND_WLAN1_PIO 0x0008 /* UART, and WLAN1 PIOs */
536 +#define AR531X_ENABLE_WLAN1_DMA 0x0010 /* WLAN1 DMAs */
537 +#define AR531X_ENABLE_WLAN1 \
538 + (AR531X_ENABLE_UART_AND_WLAN1_PIO | AR531X_ENABLE_WLAN1_DMA)
540 +/* AR531X_REV register bit field definitions */
541 +#define AR531X_REV_WMAC_MAJ 0xf000
542 +#define AR531X_REV_WMAC_MAJ_S 12
543 +#define AR531X_REV_WMAC_MIN 0x0f00
544 +#define AR531X_REV_WMAC_MIN_S 8
545 +#define AR531X_REV_MAJ 0x00f0
546 +#define AR531X_REV_MAJ_S 4
547 +#define AR531X_REV_MIN 0x000f
548 +#define AR531X_REV_MIN_S 0
549 +#define AR531X_REV_CHIP (REV_MAJ|REV_MIN)
551 +/* Major revision numbers, bits 7..4 of Revision ID register */
552 +#define AR531X_REV_MAJ_AR5312 0x4
553 +#define AR531X_REV_MAJ_AR2313 0x5
555 +/* Minor revision numbers, bits 3..0 of Revision ID register */
556 +#define AR5312_REV_MIN_DUAL 0x0 /* Dual WLAN version */
557 +#define AR5312_REV_MIN_SINGLE 0x1 /* Single WLAN version */
559 +/* AR531X_FLASHCTL register bit field definitions */
560 +#define FLASHCTL_IDCY 0x0000000f /* Idle cycle turn around time */
561 +#define FLASHCTL_IDCY_S 0
562 +#define FLASHCTL_WST1 0x000003e0 /* Wait state 1 */
563 +#define FLASHCTL_WST1_S 5
564 +#define FLASHCTL_RBLE 0x00000400 /* Read byte lane enable */
565 +#define FLASHCTL_WST2 0x0000f800 /* Wait state 2 */
566 +#define FLASHCTL_WST2_S 11
567 +#define FLASHCTL_AC 0x00070000 /* Flash address check (added) */
568 +#define FLASHCTL_AC_S 16
569 +#define FLASHCTL_AC_128K 0x00000000
570 +#define FLASHCTL_AC_256K 0x00010000
571 +#define FLASHCTL_AC_512K 0x00020000
572 +#define FLASHCTL_AC_1M 0x00030000
573 +#define FLASHCTL_AC_2M 0x00040000
574 +#define FLASHCTL_AC_4M 0x00050000
575 +#define FLASHCTL_AC_8M 0x00060000
576 +#define FLASHCTL_AC_RES 0x00070000 /* 16MB is not supported */
577 +#define FLASHCTL_E 0x00080000 /* Flash bank enable (added) */
578 +#define FLASHCTL_BUSERR 0x01000000 /* Bus transfer error status flag */
579 +#define FLASHCTL_WPERR 0x02000000 /* Write protect error status flag */
580 +#define FLASHCTL_WP 0x04000000 /* Write protect */
581 +#define FLASHCTL_BM 0x08000000 /* Burst mode */
582 +#define FLASHCTL_MW 0x30000000 /* Memory width */
583 +#define FLASHCTL_MWx8 0x00000000 /* Memory width x8 */
584 +#define FLASHCTL_MWx16 0x10000000 /* Memory width x16 */
585 +#define FLASHCTL_MWx32 0x20000000 /* Memory width x32 (not supported) */
586 +#define FLASHCTL_ATNR 0x00000000 /* Access type == no retry */
587 +#define FLASHCTL_ATR 0x80000000 /* Access type == retry every */
588 +#define FLASHCTL_ATR4 0xc0000000 /* Access type == retry every 4 */
590 +/* ARM Flash Controller -- 3 flash banks with either x8 or x16 devices. */
591 +#define AR531X_FLASHCTL0 (AR531X_FLASHCTL + 0x00)
592 +#define AR531X_FLASHCTL1 (AR531X_FLASHCTL + 0x04)
593 +#define AR531X_FLASHCTL2 (AR531X_FLASHCTL + 0x08)
595 +/* ARM SDRAM Controller -- just enough to determine memory size */
596 +#define AR531X_MEM_CFG1 (AR531X_SDRAMCTL + 0x04)
597 +#define MEM_CFG1_AC0 0x00000700 /* bank 0: SDRAM addr check (added) */
598 +#define MEM_CFG1_AC0_S 8
599 +#define MEM_CFG1_AC1 0x00007000 /* bank 1: SDRAM addr check (added) */
600 +#define MEM_CFG1_AC1_S 12
602 +/* GPIO Address Map */
603 +#define AR531X_GPIO (AR531X_APBBASE + 0x2000)
604 +#define AR531X_GPIO_DO (AR531X_GPIO + 0x00) /* output register */
605 +#define AR531X_GPIO_DI (AR531X_GPIO + 0x04) /* intput register */
606 +#define AR531X_GPIO_CR (AR531X_GPIO + 0x08) /* control register */
608 +/* GPIO Control Register bit field definitions */
609 +#define GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
610 +#define GPIO_CR_O(x) (0 << (x)) /* mask for output */
611 +#define GPIO_CR_I(x) (1 << (x)) /* mask for input */
612 +#define GPIO_CR_INT(x) (1 << ((x)+8)) /* mask for interrupt */
613 +#define GPIO_CR_UART(x) (1 << ((x)+16)) /* uart multiplex */
616 +typedef unsigned int AR531X_REG;
618 +#define sysRegRead(phys) \
619 + (*(volatile AR531X_REG *)PHYS_TO_K1(phys))
621 +#define sysRegWrite(phys, val) \
622 + ((*(volatile AR531X_REG *)PHYS_TO_K1(phys)) = (val))
626 + * This is board-specific data that is stored in a "fixed" location in flash.
627 + * It is shared across operating systems, so it should not be changed lightly.
628 + * The main reason we need it is in order to extract the ethernet MAC
631 +struct ar531x_boarddata {
632 + u32 magic; /* board data is valid */
633 +#define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
634 + u16 cksum; /* checksum (starting with BD_REV 2) */
635 + u16 rev; /* revision of this struct */
637 + char boardName[64]; /* Name of board */
638 + u16 major; /* Board major number */
639 + u16 minor; /* Board minor number */
640 + u32 config; /* Board configuration */
641 +#define BD_ENET0 0x00000001 /* ENET0 is stuffed */
642 +#define BD_ENET1 0x00000002 /* ENET1 is stuffed */
643 +#define BD_UART1 0x00000004 /* UART1 is stuffed */
644 +#define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
645 +#define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
646 +#define BD_SYSLED 0x00000020 /* System LED stuffed */
647 +#define BD_EXTUARTCLK 0x00000040 /* External UART clock */
648 +#define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
649 +#define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
650 +#define BD_WLAN0 0x00000200 /* Enable WLAN0 */
651 +#define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
652 +#define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
653 +#define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
654 +#define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
655 +#define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
656 +#define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
657 +#define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
658 +#define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
659 + u16 resetConfigGpio; /* Reset factory GPIO pin */
660 + u16 sysLedGpio; /* System LED GPIO pin */
662 + u32 cpuFreq; /* CPU core frequency in Hz */
663 + u32 sysFreq; /* System frequency in Hz */
664 + u32 cntFreq; /* Calculated C0_COUNT frequency */
670 + u16 pciId; /* Pseudo PCIID for common code */
671 + u16 memCap; /* cap bank1 in MB */
674 + u8 wlan1Mac[6]; /* (ar5212) */
682 +#define AR5315_SDRAM0 0x00000000 /* DRAM */
683 +#define AR5315_SPI_READ 0x08000000 /* SPI FLASH */
684 +#define AR5315_WLAN0 0xB0000000 /* Wireless MMR */
685 +#define AR5315_PCI 0xB0100000 /* PCI MMR */
686 +#define AR5315_SDRAMCTL 0xB0300000 /* SDRAM MMR */
687 +#define AR5315_LOCAL 0xB0400000 /* LOCAL BUS MMR */
688 +#define AR5315_ENET0 0xB0500000 /* ETHERNET MMR */
689 +#define AR5315_DSLBASE 0xB1000000 /* RESET CONTROL MMR */
690 +#define AR5315_UART0 0xB1100003 /* UART MMR */
691 +#define AR5315_SPI 0xB1300000 /* SPI FLASH MMR */
692 +#define AR5315_FLASHBT 0xBfc00000 /* ro boot alias to FLASH */
693 +#define AR5315_RAM1 0x40000000 /* ram alias */
694 +#define AR5315_PCIEXT 0x80000000 /* pci external */
695 +#define AR5315_RAM2 0xc0000000 /* ram alias */
696 +#define AR5315_RAM3 0xe0000000 /* ram alias */
701 +#define AR5315_COLD_RESET (AR5315_DSLBASE + 0x0000)
704 +#define RESET_COLD_AHB 0x00000001
705 +#define RESET_COLD_APB 0x00000002
706 +#define RESET_COLD_CPU 0x00000004
707 +#define RESET_COLD_CPUWARM 0x00000008
708 +#define RESET_SYSTEM (RESET_COLD_CPU | RESET_COLD_APB | RESET_COLD_AHB) /* full system */
712 +#define AR5315_RESET (AR5315_DSLBASE + 0x0004)
714 +#define RESET_WARM_WLAN0_MAC 0x00000001 /* warm reset WLAN0 MAC */
715 +#define RESET_WARM_WLAN0_BB 0x00000002 /* warm reset WLAN0 BaseBand */
716 +#define RESET_MPEGTS_RSVD 0x00000004 /* warm reset MPEG-TS */
717 +#define RESET_PCIDMA 0x00000008 /* warm reset PCI ahb/dma */
718 +#define RESET_MEMCTL 0x00000010 /* warm reset memory controller */
719 +#define RESET_LOCAL 0x00000020 /* warm reset local bus */
720 +#define RESET_I2C_RSVD 0x00000040 /* warm reset I2C bus */
721 +#define RESET_SPI 0x00000080 /* warm reset SPI interface */
722 +#define RESET_UART0 0x00000100 /* warm reset UART0 */
723 +#define RESET_IR_RSVD 0x00000200 /* warm reset IR interface */
724 +#define RESET_EPHY0 0x00000400 /* cold reset ENET0 phy */
725 +#define RESET_ENET0 0x00000800 /* cold reset ENET0 mac */
728 + * AHB master arbitration control
730 +#define AR5315_AHB_ARB_CTL (AR5315_DSLBASE + 0x0008)
732 +#define ARB_CPU 0x00000001 /* CPU, default */
733 +#define ARB_WLAN 0x00000002 /* WLAN */
734 +#define ARB_MPEGTS_RSVD 0x00000004 /* MPEG-TS */
735 +#define ARB_LOCAL 0x00000008 /* LOCAL */
736 +#define ARB_PCI 0x00000010 /* PCI */
737 +#define ARB_ETHERNET 0x00000020 /* Ethernet */
738 +#define ARB_RETRY 0x00000100 /* retry policy, debug only */
743 +#define AR5315_ENDIAN_CTL (AR5315_DSLBASE + 0x000c)
745 +#define CONFIG_AHB 0x00000001 /* EC - AHB bridge endianess */
746 +#define CONFIG_WLAN 0x00000002 /* WLAN byteswap */
747 +#define CONFIG_MPEGTS_RSVD 0x00000004 /* MPEG-TS byteswap */
748 +#define CONFIG_PCI 0x00000008 /* PCI byteswap */
749 +#define CONFIG_MEMCTL 0x00000010 /* Memory controller endianess */
750 +#define CONFIG_LOCAL 0x00000020 /* Local bus byteswap */
751 +#define CONFIG_ETHERNET 0x00000040 /* Ethernet byteswap */
753 +#define CONFIG_MERGE 0x00000200 /* CPU write buffer merge */
754 +#define CONFIG_CPU 0x00000400 /* CPU big endian */
755 +#define CONFIG_PCIAHB 0x00000800
756 +#define CONFIG_PCIAHB_BRIDGE 0x00001000
757 +#define CONFIG_SPI 0x00008000 /* SPI byteswap */
758 +#define CONFIG_CPU_DRAM 0x00010000
759 +#define CONFIG_CPU_PCI 0x00020000
760 +#define CONFIG_CPU_MMR 0x00040000
761 +#define CONFIG_BIG 0x00000400
767 +#define AR5315_NMI_CTL (AR5315_DSLBASE + 0x0010)
772 + * Revision Register - Initial value is 0x3010 (WMAC 3.0, AR531X 1.0).
774 +#define AR5315_SREV (AR5315_DSLBASE + 0x0014)
776 +#define REV_MAJ 0x00f0
778 +#define REV_MIN 0x000f
780 +#define REV_CHIP (REV_MAJ|REV_MIN)
785 +#define AR5315_IF_CTL (AR5315_DSLBASE + 0x0018)
787 +#define IF_MASK 0x00000007
788 +#define IF_DISABLED 0
790 +#define IF_TS_LOCAL 2
791 +#define IF_ALL 3 /* only for emulation with separate pins */
792 +#define IF_LOCAL_HOST 0x00000008
793 +#define IF_PCI_HOST 0x00000010
794 +#define IF_PCI_INTR 0x00000020
795 +#define IF_PCI_CLK_MASK 0x00030000
796 +#define IF_PCI_CLK_INPUT 0
797 +#define IF_PCI_CLK_OUTPUT_LOW 1
798 +#define IF_PCI_CLK_OUTPUT_CLK 2
799 +#define IF_PCI_CLK_OUTPUT_HIGH 3
800 +#define IF_PCI_CLK_SHIFT 16
803 +/* Major revision numbers, bits 7..4 of Revision ID register */
804 +#define REV_MAJ_AR5311 0x01
805 +#define REV_MAJ_AR5312 0x04
806 +#define REV_MAJ_AR5315 0x0B
809 + * APB Interrupt control
812 +#define AR5315_ISR (AR5315_DSLBASE + 0x0020)
813 +#define AR5315_IMR (AR5315_DSLBASE + 0x0024)
814 +#define AR5315_GISR (AR5315_DSLBASE + 0x0028)
816 +#define ISR_UART0 0x0001 /* high speed UART */
817 +#define ISR_I2C_RSVD 0x0002 /* I2C bus */
818 +#define ISR_SPI 0x0004 /* SPI bus */
819 +#define ISR_AHB 0x0008 /* AHB error */
820 +#define ISR_APB 0x0010 /* APB error */
821 +#define ISR_TIMER 0x0020 /* timer */
822 +#define ISR_GPIO 0x0040 /* GPIO */
823 +#define ISR_WD 0x0080 /* watchdog */
824 +#define ISR_IR_RSVD 0x0100 /* IR */
826 +#define IMR_UART0 ISR_UART0
827 +#define IMR_I2C_RSVD ISR_I2C_RSVD
828 +#define IMR_SPI ISR_SPI
829 +#define IMR_AHB ISR_AHB
830 +#define IMR_APB ISR_APB
831 +#define IMR_TIMER ISR_TIMER
832 +#define IMR_GPIO ISR_GPIO
833 +#define IMR_WD ISR_WD
834 +#define IMR_IR_RSVD ISR_IR_RSVD
836 +#define GISR_MISC 0x0001
837 +#define GISR_WLAN0 0x0002
838 +#define GISR_MPEGTS_RSVD 0x0004
839 +#define GISR_LOCALPCI 0x0008
840 +#define GISR_WMACPOLL 0x0010
841 +#define GISR_TIMER 0x0020
842 +#define GISR_ETHERNET 0x0040
845 + * Interrupt routing from IO to the processor IP bits
846 + * Define our inter mask and level
848 +#define AR5315_INTR_MISCIO SR_IBIT3
849 +#define AR5315_INTR_WLAN0 SR_IBIT4
850 +#define AR5315_INTR_ENET0 SR_IBIT5
851 +#define AR5315_INTR_LOCALPCI SR_IBIT6
852 +#define AR5315_INTR_WMACPOLL SR_IBIT7
853 +#define AR5315_INTR_COMPARE SR_IBIT8
858 +#define AR5315_TIMER (AR5315_DSLBASE + 0x0030)
859 +#define AR5315_RELOAD (AR5315_DSLBASE + 0x0034)
860 +#define AR5315_WD (AR5315_DSLBASE + 0x0038)
861 +#define AR5315_WDC (AR5315_DSLBASE + 0x003c)
863 +#define WDC_RESET 0x00000002 /* reset on watchdog */
864 +#define WDC_NMI 0x00000001 /* NMI on watchdog */
865 +#define WDC_IGNORE_EXPIRATION 0x00000000
870 +#define AR531X_FLASHDBG (AR531X_RESETTMR + 0x0040)
871 +#define AR531X_MIIDBG (AR531X_RESETTMR + 0x0044)
875 + * CPU Performance Counters
877 +#define AR5315_PERFCNT0 (AR5315_DSLBASE + 0x0048)
878 +#define AR5315_PERFCNT1 (AR5315_DSLBASE + 0x004c)
880 +#define PERF_DATAHIT 0x0001 /* Count Data Cache Hits */
881 +#define PERF_DATAMISS 0x0002 /* Count Data Cache Misses */
882 +#define PERF_INSTHIT 0x0004 /* Count Instruction Cache Hits */
883 +#define PERF_INSTMISS 0x0008 /* Count Instruction Cache Misses */
884 +#define PERF_ACTIVE 0x0010 /* Count Active Processor Cycles */
885 +#define PERF_WBHIT 0x0020 /* Count CPU Write Buffer Hits */
886 +#define PERF_WBMISS 0x0040 /* Count CPU Write Buffer Misses */
888 +#define PERF_EB_ARDY 0x0001 /* Count EB_ARdy signal */
889 +#define PERF_EB_AVALID 0x0002 /* Count EB_AValid signal */
890 +#define PERF_EB_WDRDY 0x0004 /* Count EB_WDRdy signal */
891 +#define PERF_EB_RDVAL 0x0008 /* Count EB_RdVal signal */
892 +#define PERF_VRADDR 0x0010 /* Count valid read address cycles */
893 +#define PERF_VWADDR 0x0020 /* Count valid write address cycles */
894 +#define PERF_VWDATA 0x0040 /* Count valid write data cycles */
897 + * AHB Error Reporting.
899 +#define AR5315_AHB_ERR0 (AR5315_DSLBASE + 0x0050) /* error */
900 +#define AR5315_AHB_ERR1 (AR5315_DSLBASE + 0x0054) /* haddr */
901 +#define AR5315_AHB_ERR2 (AR5315_DSLBASE + 0x0058) /* hwdata */
902 +#define AR5315_AHB_ERR3 (AR5315_DSLBASE + 0x005c) /* hrdata */
903 +#define AR5315_AHB_ERR4 (AR5315_DSLBASE + 0x0060) /* status */
905 +#define AHB_ERROR_DET 1 /* AHB Error has been detected, */
906 + /* write 1 to clear all bits in ERR0 */
907 +#define AHB_ERROR_OVR 2 /* AHB Error overflow has been detected */
908 +#define AHB_ERROR_WDT 4 /* AHB Error due to wdt instead of hresp */
910 +#define PROCERR_HMAST 0x0000000f
911 +#define PROCERR_HMAST_DFLT 0
912 +#define PROCERR_HMAST_WMAC 1
913 +#define PROCERR_HMAST_ENET 2
914 +#define PROCERR_HMAST_PCIENDPT 3
915 +#define PROCERR_HMAST_LOCAL 4
916 +#define PROCERR_HMAST_CPU 5
917 +#define PROCERR_HMAST_PCITGT 6
919 +#define PROCERR_HMAST_S 0
920 +#define PROCERR_HWRITE 0x00000010
921 +#define PROCERR_HSIZE 0x00000060
922 +#define PROCERR_HSIZE_S 5
923 +#define PROCERR_HTRANS 0x00000180
924 +#define PROCERR_HTRANS_S 7
925 +#define PROCERR_HBURST 0x00000e00
926 +#define PROCERR_HBURST_S 9
933 +#define AR5315_PLLC_CTL (AR5315_DSLBASE + 0x0064)
934 +#define AR5315_PLLV_CTL (AR5315_DSLBASE + 0x0068)
935 +#define AR5315_CPUCLK (AR5315_DSLBASE + 0x006c)
936 +#define AR5315_AMBACLK (AR5315_DSLBASE + 0x0070)
937 +#define AR5315_SYNCCLK (AR5315_DSLBASE + 0x0074)
938 +#define AR5315_DSL_SLEEP_CTL (AR5315_DSLBASE + 0x0080)
939 +#define AR5315_DSL_SLEEP_DUR (AR5315_DSLBASE + 0x0084)
941 +/* PLLc Control fields */
942 +#define PLLC_REF_DIV_M 0x00000003
943 +#define PLLC_REF_DIV_S 0
944 +#define PLLC_FDBACK_DIV_M 0x0000007C
945 +#define PLLC_FDBACK_DIV_S 2
946 +#define PLLC_ADD_FDBACK_DIV_M 0x00000080
947 +#define PLLC_ADD_FDBACK_DIV_S 7
948 +#define PLLC_CLKC_DIV_M 0x0001c000
949 +#define PLLC_CLKC_DIV_S 14
950 +#define PLLC_CLKM_DIV_M 0x00700000
951 +#define PLLC_CLKM_DIV_S 20
953 +/* CPU CLK Control fields */
954 +#define CPUCLK_CLK_SEL_M 0x00000003
955 +#define CPUCLK_CLK_SEL_S 0
956 +#define CPUCLK_CLK_DIV_M 0x0000000c
957 +#define CPUCLK_CLK_DIV_S 2
959 +/* AMBA CLK Control fields */
960 +#define AMBACLK_CLK_SEL_M 0x00000003
961 +#define AMBACLK_CLK_SEL_S 0
962 +#define AMBACLK_CLK_DIV_M 0x0000000c
963 +#define AMBACLK_CLK_DIV_S 2
965 +#if defined(COBRA_EMUL)
966 +#define AR5315_AMBA_CLOCK_RATE 20000000
967 +#define AR5315_CPU_CLOCK_RATE 40000000
969 +#if defined(DEFAULT_PLL)
970 +#define AR5315_AMBA_CLOCK_RATE 40000000
971 +#define AR5315_CPU_CLOCK_RATE 40000000
973 +#define AR5315_AMBA_CLOCK_RATE 92000000
974 +#define AR5315_CPU_CLOCK_RATE 184000000
975 +#endif /* ! DEFAULT_PLL */
976 +#endif /* ! COBRA_EMUL */
978 +#define AR5315_UART_CLOCK_RATE AR5315_AMBA_CLOCK_RATE
979 +#define AR5315_SDRAM_CLOCK_RATE AR5315_AMBA_CLOCK_RATE
982 + * The UART computes baud rate as:
983 + * baud = clock / (16 * divisor)
984 + * where divisor is specified as a High Byte (DLM) and a Low Byte (DLL).
986 +#define DESIRED_BAUD_RATE 38400
989 + * The WATCHDOG value is computed as
990 + * 10 seconds * AR531X_WATCHDOG_CLOCK_RATE
992 +#define DESIRED_WATCHDOG_SECONDS 10
993 +#define AR531X_WATCHDOG_TIME \
994 + (DESIRED_WATCHDOG_SECONDS * AR531X_WATCHDOG_CLOCK_RATE)
997 +#define CLOCKCTL_UART0 0x0010 /* enable UART0 external clock */
1001 + * Applicable "PCICFG" bits for WLAN(s). Assoc status and LED mode.
1003 +#define AR531X_PCICFG (AR531X_RESETTMR + 0x00b0)
1004 +#define ASSOC_STATUS_M 0x00000003
1005 +#define ASSOC_STATUS_NONE 0
1006 +#define ASSOC_STATUS_PENDING 1
1007 +#define ASSOC_STATUS_ASSOCIATED 2
1008 +#define LED_MODE_M 0x0000001c
1009 +#define LED_BLINK_THRESHOLD_M 0x000000e0
1010 +#define LED_SLOW_BLINK_MODE 0x00000100
1016 +#define AR5315_GPIO_DI (AR5315_DSLBASE + 0x0088)
1017 +#define AR5315_GPIO_DO (AR5315_DSLBASE + 0x0090)
1018 +#define AR5315_GPIO_CR (AR5315_DSLBASE + 0x0098)
1019 +#define AR5315_GPIO_INT (AR5315_DSLBASE + 0x00a0)
1021 +#define GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
1022 +#define GPIO_CR_O(x) (1 << (x)) /* output */
1023 +#define GPIO_CR_I(x) (0 << (x)) /* input */
1025 +#define GPIO_INT(x,Y) ((x) << (8 * (Y))) /* interrupt enable */
1026 +#define GPIO_INT_M(Y) ((0x3F) << (8 * (Y))) /* mask for int */
1027 +#define GPIO_INT_LVL(x,Y) ((x) << (8 * (Y) + 6)) /* interrupt level */
1028 +#define GPIO_INT_LVL_M(Y) ((0x3) << (8 * (Y) + 6)) /* mask for int level */
1030 +#define AR5315_RESET_GPIO 5
1031 +#define AR5315_NUM_GPIO 22
1035 + * PCI Clock Control
1038 +#define AR5315_PCICLK (AR5315_DSLBASE + 0x00a4)
1040 +#define PCICLK_INPUT_M 0x3
1041 +#define PCICLK_INPUT_S 0
1043 +#define PCICLK_PLLC_CLKM 0
1044 +#define PCICLK_PLLC_CLKM1 1
1045 +#define PCICLK_PLLC_CLKC 2
1046 +#define PCICLK_REF_CLK 3
1048 +#define PCICLK_DIV_M 0xc
1049 +#define PCICLK_DIV_S 2
1051 +#define PCICLK_IN_FREQ 0
1052 +#define PCICLK_IN_FREQ_DIV_6 1
1053 +#define PCICLK_IN_FREQ_DIV_8 2
1054 +#define PCICLK_IN_FREQ_DIV_10 3
1057 + * Observation Control Register
1059 +#define AR5315_OCR (AR5315_DSLBASE + 0x00b0)
1060 +#define OCR_GPIO0_IRIN 0x0040
1061 +#define OCR_GPIO1_IROUT 0x0080
1062 +#define OCR_GPIO3_RXCLR 0x0200
1065 + * General Clock Control
1068 +#define AR5315_MISCCLK (AR5315_DSLBASE + 0x00b4)
1069 +#define MISCCLK_PLLBYPASS_EN 0x00000001
1070 +#define MISCCLK_PROCREFCLK 0x00000002
1073 + * SDRAM Controller
1074 + * - No read or write buffers are included.
1076 +#define AR5315_MEM_CFG (AR5315_SDRAMCTL + 0x00)
1077 +#define AR5315_MEM_CTRL (AR5315_SDRAMCTL + 0x0c)
1078 +#define AR5315_MEM_REF (AR5315_SDRAMCTL + 0x10)
1080 +#define SDRAM_DATA_WIDTH_M 0x00006000
1081 +#define SDRAM_DATA_WIDTH_S 13
1083 +#define SDRAM_COL_WIDTH_M 0x00001E00
1084 +#define SDRAM_COL_WIDTH_S 9
1086 +#define SDRAM_ROW_WIDTH_M 0x000001E0
1087 +#define SDRAM_ROW_WIDTH_S 5
1089 +#define SDRAM_BANKADDR_BITS_M 0x00000018
1090 +#define SDRAM_BANKADDR_BITS_S 3
1094 + * SDRAM Memory Refresh (MEM_REF) value is computed as:
1095 + * MEMCTL_SREFR = (Tr * hclk_freq) / R
1096 + * where Tr is max. time of refresh of any single row
1097 + * R is number of rows in the DRAM
1098 + * For most 133MHz SDRAM parts, Tr=64ms, R=4096 or 8192
1100 +#if defined(COBRA_EMUL)
1101 +#define AR5315_SDRAM_MEMORY_REFRESH_VALUE 0x96
1103 +#if defined(DEFAULT_PLL)
1104 +#define AR5315_SDRAM_MEMORY_REFRESH_VALUE 0x200
1106 +#define AR5315_SDRAM_MEMORY_REFRESH_VALUE 0x61a
1107 +#endif /* ! DEFAULT_PLL */
1110 +#if defined(AR5315)
1112 +#define AR5315_SDRAM_DDR_SDRAM 0 /* Not DDR SDRAM */
1113 +#define AR5315_SDRAM_DATA_WIDTH 16 /* bits */
1114 +#define AR5315_SDRAM_COL_WIDTH 8
1115 +#define AR5315_SDRAM_ROW_WIDTH 12
1119 +#define AR5315_SDRAM_DDR_SDRAM 0 /* Not DDR SDRAM */
1120 +#define AR5315_SDRAM_DATA_WIDTH 16
1121 +#define AR5315_SDRAM_COL_WIDTH 8
1122 +#define AR5315_SDRAM_ROW_WIDTH 12
1124 +#endif /* ! AR5315 */
1127 + * SPI Flash Interface Registers
1130 +#define AR5315_SPI_CTL (AR5315_SPI + 0x00)
1131 +#define AR5315_SPI_OPCODE (AR5315_SPI + 0x04)
1132 +#define AR5315_SPI_DATA (AR5315_SPI + 0x08)
1134 +#define SPI_CTL_START 0x00000100
1135 +#define SPI_CTL_BUSY 0x00010000
1136 +#define SPI_CTL_TXCNT_MASK 0x0000000f
1137 +#define SPI_CTL_RXCNT_MASK 0x000000f0
1138 +#define SPI_CTL_TX_RX_CNT_MASK 0x000000ff
1139 +#define SPI_CTL_SIZE_MASK 0x00060000
1141 +#define SPI_CTL_CLK_SEL_MASK 0x03000000
1142 +#define SPI_OPCODE_MASK 0x000000ff
1145 + * PCI-MAC Configuration registers
1147 +#define PCI_MAC_RC (AR5315_PCI + 0x4000)
1148 +#define PCI_MAC_SCR (AR5315_PCI + 0x4004)
1149 +#define PCI_MAC_INTPEND (AR5315_PCI + 0x4008)
1150 +#define PCI_MAC_SFR (AR5315_PCI + 0x400C)
1151 +#define PCI_MAC_PCICFG (AR5315_PCI + 0x4010)
1152 +#define PCI_MAC_SREV (AR5315_PCI + 0x4020)
1154 +#define PCI_MAC_RC_MAC 0x00000001
1155 +#define PCI_MAC_RC_BB 0x00000002
1157 +#define PCI_MAC_SCR_SLMODE_M 0x00030000
1158 +#define PCI_MAC_SCR_SLMODE_S 16
1159 +#define PCI_MAC_SCR_SLM_FWAKE 0
1160 +#define PCI_MAC_SCR_SLM_FSLEEP 1
1161 +#define PCI_MAC_SCR_SLM_NORMAL 2
1163 +#define PCI_MAC_SFR_SLEEP 0x00000001
1165 +#define PCI_MAC_PCICFG_SPWR_DN 0x00010000
1171 + * PCI Bus Interface Registers
1173 +#define AR5315_PCI_1MS_REG (AR5315_PCI + 0x0008)
1174 +#define AR5315_PCI_1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1176 +#define AR5315_PCI_MISC_CONFIG (AR5315_PCI + 0x000c)
1177 +#define AR5315_PCIMISC_TXD_EN 0x00000001 /* Enable TXD for fragments */
1178 +#define AR5315_PCIMISC_CFG_SEL 0x00000002 /* mem or config cycles */
1179 +#define AR5315_PCIMISC_GIG_MASK 0x0000000C /* bits 31-30 for pci req */
1180 +#define AR5315_PCIMISC_RST_MODE 0x00000030
1181 +#define AR5315_PCIRST_INPUT 0x00000000 /* 4:5=0 rst is input */
1182 +#define AR5315_PCIRST_LOW 0x00000010 /* 4:5=1 rst to GND */
1183 +#define AR5315_PCIRST_HIGH 0x00000020 /* 4:5=2 rst to VDD */
1184 +#define AR5315_PCIGRANT_EN 0x00000000 /* 6:7=0 early grant en */
1185 +#define AR5315_PCIGRANT_FRAME 0x00000040 /* 6:7=1 grant waits 4 frame */
1186 +#define AR5315_PCIGRANT_IDLE 0x00000080 /* 6:7=2 grant waits 4 idle */
1187 +#define AR5315_PCIGRANT_GAP 0x00000000 /* 6:7=2 grant waits 4 idle */
1188 +#define AR5315_PCICACHE_DIS 0x00001000 /* PCI external access cache disable */
1190 +#define AR5315_PCI_OUT_TSTAMP (AR5315_PCI + 0x0010)
1192 +#define AR5315_PCI_UNCACHE_CFG (AR5315_PCI + 0x0014)
1194 +#define AR5315_PCI_IN_EN (AR5315_PCI + 0x0100)
1195 +#define AR5315_PCI_IN_EN0 0x01 /* Enable chain 0 */
1196 +#define AR5315_PCI_IN_EN1 0x02 /* Enable chain 1 */
1197 +#define AR5315_PCI_IN_EN2 0x04 /* Enable chain 2 */
1198 +#define AR5315_PCI_IN_EN3 0x08 /* Enable chain 3 */
1200 +#define AR5315_PCI_IN_DIS (AR5315_PCI + 0x0104)
1201 +#define AR5315_PCI_IN_DIS0 0x01 /* Disable chain 0 */
1202 +#define AR5315_PCI_IN_DIS1 0x02 /* Disable chain 1 */
1203 +#define AR5315_PCI_IN_DIS2 0x04 /* Disable chain 2 */
1204 +#define AR5315_PCI_IN_DIS3 0x08 /* Disable chain 3 */
1206 +#define AR5315_PCI_IN_PTR (AR5315_PCI + 0x0200)
1208 +#define AR5315_PCI_OUT_EN (AR5315_PCI + 0x0400)
1209 +#define AR5315_PCI_OUT_EN0 0x01 /* Enable chain 0 */
1211 +#define AR5315_PCI_OUT_DIS (AR5315_PCI + 0x0404)
1212 +#define AR5315_PCI_OUT_DIS0 0x01 /* Disable chain 0 */
1214 +#define AR5315_PCI_OUT_PTR (AR5315_PCI + 0x0408)
1216 +#define AR5315_PCI_INT_STATUS (AR5315_PCI + 0x0500) /* write one to clr */
1217 +#define AR5315_PCI_TXINT 0x00000001 /* Desc In Completed */
1218 +#define AR5315_PCI_TXOK 0x00000002 /* Desc In OK */
1219 +#define AR5315_PCI_TXERR 0x00000004 /* Desc In ERR */
1220 +#define AR5315_PCI_TXEOL 0x00000008 /* Desc In End-of-List */
1221 +#define AR5315_PCI_RXINT 0x00000010 /* Desc Out Completed */
1222 +#define AR5315_PCI_RXOK 0x00000020 /* Desc Out OK */
1223 +#define AR5315_PCI_RXERR 0x00000040 /* Desc Out ERR */
1224 +#define AR5315_PCI_RXEOL 0x00000080 /* Desc Out EOL */
1225 +#define AR5315_PCI_TXOOD 0x00000200 /* Desc In Out-of-Desc */
1226 +#define AR5315_PCI_MASK 0x0000FFFF /* Desc Mask */
1227 +#define AR5315_PCI_EXT_INT 0x02000000
1228 +#define AR5315_PCI_ABORT_INT 0x04000000
1230 +#define AR5315_PCI_INT_MASK (AR5315_PCI + 0x0504) /* same as INT_STATUS */
1232 +#define AR5315_PCI_INTEN_REG (AR5315_PCI + 0x0508)
1233 +#define AR5315_PCI_INT_DISABLE 0x00 /* disable pci interrupts */
1234 +#define AR5315_PCI_INT_ENABLE 0x01 /* enable pci interrupts */
1236 +#define AR5315_PCI_HOST_IN_EN (AR5315_PCI + 0x0800)
1237 +#define AR5315_PCI_HOST_IN_DIS (AR5315_PCI + 0x0804)
1238 +#define AR5315_PCI_HOST_IN_PTR (AR5315_PCI + 0x0810)
1239 +#define AR5315_PCI_HOST_OUT_EN (AR5315_PCI + 0x0900)
1240 +#define AR5315_PCI_HOST_OUT_DIS (AR5315_PCI + 0x0904)
1241 +#define AR5315_PCI_HOST_OUT_PTR (AR5315_PCI + 0x0908)
1245 + * Local Bus Interface Registers
1247 +#define AR5315_LB_CONFIG (AR5315_LOCAL + 0x0000)
1248 +#define AR5315_LBCONF_OE 0x00000001 /* =1 OE is low-true */
1249 +#define AR5315_LBCONF_CS0 0x00000002 /* =1 first CS is low-true */
1250 +#define AR5315_LBCONF_CS1 0x00000004 /* =1 2nd CS is low-true */
1251 +#define AR5315_LBCONF_RDY 0x00000008 /* =1 RDY is low-true */
1252 +#define AR5315_LBCONF_WE 0x00000010 /* =1 Write En is low-true */
1253 +#define AR5315_LBCONF_WAIT 0x00000020 /* =1 WAIT is low-true */
1254 +#define AR5315_LBCONF_ADS 0x00000040 /* =1 Adr Strobe is low-true */
1255 +#define AR5315_LBCONF_MOT 0x00000080 /* =0 Intel, =1 Motorola */
1256 +#define AR5315_LBCONF_8CS 0x00000100 /* =1 8 bits CS, 0= 16bits */
1257 +#define AR5315_LBCONF_8DS 0x00000200 /* =1 8 bits Data S, 0=16bits */
1258 +#define AR5315_LBCONF_ADS_EN 0x00000400 /* =1 Enable ADS */
1259 +#define AR5315_LBCONF_ADR_OE 0x00000800 /* =1 Adr cap on OE, WE or DS */
1260 +#define AR5315_LBCONF_ADDT_MUX 0x00001000 /* =1 Adr and Data share bus */
1261 +#define AR5315_LBCONF_DATA_OE 0x00002000 /* =1 Data cap on OE, WE, DS */
1262 +#define AR5315_LBCONF_16DATA 0x00004000 /* =1 Data is 16 bits wide */
1263 +#define AR5315_LBCONF_SWAPDT 0x00008000 /* =1 Byte swap data */
1264 +#define AR5315_LBCONF_SYNC 0x00010000 /* =1 Bus synchronous to clk */
1265 +#define AR5315_LBCONF_INT 0x00020000 /* =1 Intr is low true */
1266 +#define AR5315_LBCONF_INT_CTR0 0x00000000 /* GND high-Z, Vdd is high-Z */
1267 +#define AR5315_LBCONF_INT_CTR1 0x00040000 /* GND drive, Vdd is high-Z */
1268 +#define AR5315_LBCONF_INT_CTR2 0x00080000 /* GND high-Z, Vdd drive */
1269 +#define AR5315_LBCONF_INT_CTR3 0x000C0000 /* GND drive, Vdd drive */
1270 +#define AR5315_LBCONF_RDY_WAIT 0x00100000 /* =1 RDY is negative of WAIT */
1271 +#define AR5315_LBCONF_INT_PULSE 0x00200000 /* =1 Interrupt is a pulse */
1272 +#define AR5315_LBCONF_ENABLE 0x00400000 /* =1 Falcon respond to LB */
1274 +#define AR5315_LB_CLKSEL (AR5315_LOCAL + 0x0004)
1275 +#define AR5315_LBCLK_EXT 0x0001 /* use external clk for lb */
1277 +#define AR5315_LB_1MS (AR5315_LOCAL + 0x0008)
1278 +#define AR5315_LB1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1280 +#define AR5315_LB_MISCCFG (AR5315_LOCAL + 0x000C)
1281 +#define AR5315_LBM_TXD_EN 0x00000001 /* Enable TXD for fragments */
1282 +#define AR5315_LBM_RX_INTEN 0x00000002 /* Enable LB ints on RX ready */
1283 +#define AR5315_LBM_MBOXWR_INTEN 0x00000004 /* Enable LB ints on mbox wr */
1284 +#define AR5315_LBM_MBOXRD_INTEN 0x00000008 /* Enable LB ints on mbox rd */
1285 +#define AR5315_LMB_DESCSWAP_EN 0x00000010 /* Byte swap desc enable */
1286 +#define AR5315_LBM_TIMEOUT_MASK 0x00FFFF80
1287 +#define AR5315_LBM_TIMEOUT_SHFT 7
1288 +#define AR5315_LBM_PORTMUX 0x07000000
1291 +#define AR5315_LB_RXTSOFF (AR5315_LOCAL + 0x0010)
1293 +#define AR5315_LB_TX_CHAIN_EN (AR5315_LOCAL + 0x0100)
1294 +#define AR5315_LB_TXEN_0 0x01
1295 +#define AR5315_LB_TXEN_1 0x02
1296 +#define AR5315_LB_TXEN_2 0x04
1297 +#define AR5315_LB_TXEN_3 0x08
1299 +#define AR5315_LB_TX_CHAIN_DIS (AR5315_LOCAL + 0x0104)
1300 +#define AR5315_LB_TX_DESC_PTR (AR5315_LOCAL + 0x0200)
1302 +#define AR5315_LB_RX_CHAIN_EN (AR5315_LOCAL + 0x0400)
1303 +#define AR5315_LB_RXEN 0x01
1305 +#define AR5315_LB_RX_CHAIN_DIS (AR5315_LOCAL + 0x0404)
1306 +#define AR5315_LB_RX_DESC_PTR (AR5315_LOCAL + 0x0408)
1308 +#define AR5315_LB_INT_STATUS (AR5315_LOCAL + 0x0500)
1309 +#define AR5315_INT_TX_DESC 0x0001
1310 +#define AR5315_INT_TX_OK 0x0002
1311 +#define AR5315_INT_TX_ERR 0x0004
1312 +#define AR5315_INT_TX_EOF 0x0008
1313 +#define AR5315_INT_RX_DESC 0x0010
1314 +#define AR5315_INT_RX_OK 0x0020
1315 +#define AR5315_INT_RX_ERR 0x0040
1316 +#define AR5315_INT_RX_EOF 0x0080
1317 +#define AR5315_INT_TX_TRUNC 0x0100
1318 +#define AR5315_INT_TX_STARVE 0x0200
1319 +#define AR5315_INT_LB_TIMEOUT 0x0400
1320 +#define AR5315_INT_LB_ERR 0x0800
1321 +#define AR5315_INT_MBOX_WR 0x1000
1322 +#define AR5315_INT_MBOX_RD 0x2000
1324 +/* Bit definitions for INT MASK are the same as INT_STATUS */
1325 +#define AR5315_LB_INT_MASK (AR5315_LOCAL + 0x0504)
1327 +#define AR5315_LB_INT_EN (AR5315_LOCAL + 0x0508)
1328 +#define AR5315_LB_MBOX (AR5315_LOCAL + 0x0600)
1333 + * IR Interface Registers
1335 +#define AR5315_IR_PKTDATA (AR5315_IR + 0x0000)
1337 +#define AR5315_IR_PKTLEN (AR5315_IR + 0x07fc) /* 0 - 63 */
1339 +#define AR5315_IR_CONTROL (AR5315_IR + 0x0800)
1340 +#define AR5315_IRCTL_TX 0x00000000 /* use as tranmitter */
1341 +#define AR5315_IRCTL_RX 0x00000001 /* use as receiver */
1342 +#define AR5315_IRCTL_SAMPLECLK_MASK 0x00003ffe /* Sample clk divisor mask */
1343 +#define AR5315_IRCTL_SAMPLECLK_SHFT 1
1344 +#define AR5315_IRCTL_OUTPUTCLK_MASK 0x03ffc000 /* Output clk divisor mask */
1345 +#define AR5315_IRCTL_OUTPUTCLK_SHFT 14
1347 +#define AR5315_IR_STATUS (AR5315_IR + 0x0804)
1348 +#define AR5315_IRSTS_RX 0x00000001 /* receive in progress */
1349 +#define AR5315_IRSTS_TX 0x00000002 /* transmit in progress */
1351 +#define AR5315_IR_CONFIG (AR5315_IR + 0x0808)
1352 +#define AR5315_IRCFG_INVIN 0x00000001 /* invert input polarity */
1353 +#define AR5315_IRCFG_INVOUT 0x00000002 /* invert output polarity */
1354 +#define AR5315_IRCFG_SEQ_START_WIN_SEL 0x00000004 /* 1 => 28, 0 => 7 */
1355 +#define AR5315_IRCFG_SEQ_START_THRESH 0x000000f0 /* */
1356 +#define AR5315_IRCFG_SEQ_END_UNIT_SEL 0x00000100 /* */
1357 +#define AR5315_IRCFG_SEQ_END_UNIT_THRESH 0x00007e00 /* */
1358 +#define AR5315_IRCFG_SEQ_END_WIN_SEL 0x00008000 /* */
1359 +#define AR5315_IRCFG_SEQ_END_WIN_THRESH 0x001f0000 /* */
1360 +#define AR5315_IRCFG_NUM_BACKOFF_WORDS 0x01e00000 /* */
1363 + * PCI memory constants: Memory area 1 and 2 are the same size -
1364 + * (twice the PCI_TLB_PAGE_SIZE). The definition of
1365 + * CPU_TO_PCI_MEM_SIZE is coupled with the TLB setup routine
1366 + * sysLib.c/sysTlbInit(), in that it assumes that 2 pages of size
1367 + * PCI_TLB_PAGE_SIZE are set up in the TLB for each PCI memory space.
1370 +#define CPU_TO_PCI_MEM_BASE1 0xE0000000
1371 +#define CPU_TO_PCI_MEM_SIZE1 (2*PCI_TLB_PAGE_SIZE)
1374 +/* TLB attributes for PCI transactions */
1376 +#define PCI_MMU_PAGEMASK 0x00003FFF
1377 +#define MMU_PAGE_UNCACHED 0x00000010
1378 +#define MMU_PAGE_DIRTY 0x00000004
1379 +#define MMU_PAGE_VALID 0x00000002
1380 +#define MMU_PAGE_GLOBAL 0x00000001
1381 +#define PCI_MMU_PAGEATTRIB (MMU_PAGE_UNCACHED|MMU_PAGE_DIRTY|\
1382 + MMU_PAGE_VALID|MMU_PAGE_GLOBAL)
1383 +#define PCI_MEMORY_SPACE1_VIRT 0xE0000000 /* Used for non-prefet mem */
1384 +#define PCI_MEMORY_SPACE1_PHYS 0x80000000
1385 +#define PCI_TLB_PAGE_SIZE 0x01000000
1386 +#define TLB_HI_MASK 0xFFFFE000
1387 +#define TLB_LO_MASK 0x3FFFFFFF
1388 +#define PAGEMASK_SHIFT 11
1389 +#define TLB_LO_SHIFT 6
1391 +#define PCI_MAX_LATENCY 0xFFF /* Max PCI latency */
1393 +#define HOST_PCI_DEV_ID 3
1394 +#define HOST_PCI_MBAR0 0x10000000
1395 +#define HOST_PCI_MBAR1 0x20000000
1396 +#define HOST_PCI_MBAR2 0x30000000
1398 +#define HOST_PCI_SDRAM_BASEADDR HOST_PCI_MBAR1
1399 +#define PCI_DEVICE_MEM_SPACE 0x800000
1402 +typedef unsigned int AR531X_REG;
1404 +#define sysRegRead(phys) \
1405 + (*(volatile AR531X_REG *)PHYS_TO_K1(phys))
1407 +#define sysRegWrite(phys, val) \
1408 + ((*(volatile AR531X_REG *)PHYS_TO_K1(phys)) = (val))
1412 diff -urN linux-mips/arch/mips/ar531x/ar531xintr.S mips-linux-2.4.25/arch/mips/ar531x/ar531xintr.S
1413 --- linux-mips/arch/mips/ar531x/ar531xintr.S 1970-01-01 01:00:00.000000000 +0100
1414 +++ mips-linux-2.4.25/arch/mips/ar531x/ar531xintr.S 2005-12-30 17:26:31.000823952 +0000
1417 + * This file is subject to the terms and conditions of the GNU General Public
1418 + * License. See the file "COPYING" in the main directory of this archive
1419 + * for more details.
1421 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
1424 +#include <asm/asm.h>
1425 +#include <asm/mipsregs.h>
1426 +#include <asm/regdef.h>
1427 +#include <asm/stackframe.h>
1430 + * Glue code to save registers and get us to the interrupt dispatcher
1435 +NESTED(ar531x_interrupt_receive, PT_SIZE, sp)
1441 + jal ar531x_irq_dispatch
1445 + END(ar531x_interrupt_receive)
1446 diff -urN linux-mips/arch/mips/ar531x/ar531xirq.c mips-linux-2.4.25/arch/mips/ar531x/ar531xirq.c
1447 --- linux-mips/arch/mips/ar531x/ar531xirq.c 1970-01-01 01:00:00.000000000 +0100
1448 +++ mips-linux-2.4.25/arch/mips/ar531x/ar531xirq.c 2005-12-30 17:26:31.000823952 +0000
1451 + * This file is subject to the terms and conditions of the GNU General Public
1452 + * License. See the file "COPYING" in the main directory of this archive
1453 + * for more details.
1455 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
1459 + * Interrupt support for AR531X WiSOC.
1462 +#include <linux/config.h>
1463 +#include <linux/init.h>
1464 +#include <linux/kernel_stat.h>
1465 +#include <linux/signal.h>
1466 +#include <linux/sched.h>
1467 +#include <linux/interrupt.h>
1468 +#include <linux/slab.h>
1469 +#include <linux/random.h>
1470 +#include <linux/pm.h>
1471 +#include <linux/delay.h>
1472 +#include <linux/reboot.h>
1474 +#include <asm/irq.h>
1475 +#include <asm/mipsregs.h>
1476 +#include <asm/gdb-stub.h>
1478 +#include "ar531xlnx.h"
1479 +#include <asm/irq_cpu.h>
1481 +extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
1483 +static void ar531x_misc_intr_enable(unsigned int irq);
1484 +static void ar531x_misc_intr_disable(unsigned int irq);
1486 +/* Turn on the specified AR531X_MISC_IRQ interrupt */
1487 +static unsigned int
1488 +ar531x_misc_intr_startup(unsigned int irq)
1490 + ar531x_misc_intr_enable(irq);
1494 +/* Turn off the specified AR531X_MISC_IRQ interrupt */
1496 +ar531x_misc_intr_shutdown(unsigned int irq)
1498 + ar531x_misc_intr_disable(irq);
1501 +/* Enable the specified AR531X_MISC_IRQ interrupt */
1503 +ar531x_misc_intr_enable(unsigned int irq)
1508 + imr = sysRegRead(AR5315_IMR);
1511 + case AR531X_MISC_IRQ_TIMER:
1515 + case AR531X_MISC_IRQ_AHB_PROC:
1519 + case AR531X_MISC_IRQ_AHB_DMA:
1523 + case AR531X_ISR_GPIO:
1528 + case AR531X_MISC_IRQ_UART0:
1533 + case AR531X_MISC_IRQ_WATCHDOG:
1537 + case AR531X_MISC_IRQ_LOCAL:
1542 + sysRegWrite(AR5315_IMR, imr);
1543 + imr=sysRegRead(AR5315_IMR); /* flush write buffer */
1544 + //printk("enable Interrupt irq 0x%x imr 0x%x \n",irq,imr);
1547 + imr = sysRegRead(AR531X_IMR);
1548 + imr |= (1 << (irq - AR531X_MISC_IRQ_BASE - 1));
1549 + sysRegWrite(AR531X_IMR, imr);
1550 + sysRegRead(AR531X_IMR); /* flush write buffer */
1554 +/* Disable the specified AR531X_MISC_IRQ interrupt */
1556 +ar531x_misc_intr_disable(unsigned int irq)
1561 + imr = sysRegRead(AR5315_IMR);
1564 + case AR531X_MISC_IRQ_TIMER:
1565 + imr &= (~IMR_TIMER);
1568 + case AR531X_MISC_IRQ_AHB_PROC:
1569 + imr &= (~IMR_AHB);
1572 + case AR531X_MISC_IRQ_AHB_DMA:
1576 + case AR531X_ISR_GPIO:
1581 + case AR531X_MISC_IRQ_UART0:
1582 + imr &= (~IMR_UART0);
1585 + case AR531X_MISC_IRQ_WATCHDOG:
1589 + case AR531X_MISC_IRQ_LOCAL:
1590 + imr &= ~0/* ?? */;
1594 + sysRegWrite(AR5315_IMR, imr);
1595 + sysRegRead(AR5315_IMR); /* flush write buffer */
1597 + imr = sysRegRead(AR531X_IMR);
1598 + imr &= ~(1 << (irq - AR531X_MISC_IRQ_BASE - 1));
1599 + sysRegWrite(AR531X_IMR, imr);
1600 + sysRegRead(AR531X_IMR); /* flush write buffer */
1605 +ar531x_misc_intr_ack(unsigned int irq)
1607 + ar531x_misc_intr_disable(irq);
1611 +ar531x_misc_intr_end(unsigned int irq)
1613 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
1614 + ar531x_misc_intr_enable(irq);
1618 +ar531x_misc_intr_set_affinity(unsigned int irq, unsigned long mask)
1620 + /* Only 1 CPU; ignore affinity request */
1623 +struct hw_interrupt_type ar531x_misc_intr_controller = {
1625 + ar531x_misc_intr_startup,
1626 + ar531x_misc_intr_shutdown,
1627 + ar531x_misc_intr_enable,
1628 + ar531x_misc_intr_disable,
1629 + ar531x_misc_intr_ack,
1630 + ar531x_misc_intr_end,
1631 + ar531x_misc_intr_set_affinity,
1634 +int ar531x_misc_irq_base;
1637 + * Determine interrupt source among interrupts that use IP6
1640 +ar531x_misc_intr_init(int irq_base)
1644 + for (i = irq_base; i < irq_base + AR531X_MISC_IRQ_COUNT; i++) {
1645 + irq_desc[i].status = IRQ_DISABLED;
1646 + irq_desc[i].action = NULL;
1647 + irq_desc[i].depth = 1;
1648 + irq_desc[i].handler = &ar531x_misc_intr_controller;
1651 + ar531x_misc_irq_base = irq_base;
1656 +spurious_irq_handler(int cpl, void *dev_id, struct pt_regs *regs)
1659 + printk("spurious_irq_handler: %d cause=0x%8.8x status=0x%8.8x\n",
1660 + cpl, cause_intrs, status_intrs);
1666 +spurious_misc_handler(int cpl, void *dev_id, struct pt_regs *regs)
1669 + printk("spurious_misc_handler: 0x%x isr=0x%8.8x imr=0x%8.8x\n",
1670 + cpl, ar531x_isr, ar531x_imr);
1675 +ar531x_timer_handler(int cpl, void *dev_id, struct pt_regs *regs)
1678 + (void)sysRegRead(AR5315_TIMER); /* clear interrupt */
1680 + (void)sysRegRead(AR531X_TIMER); /* clear interrupt */
1685 +ar531x_ahb_proc_handler(int cpl, void *dev_id, struct pt_regs *regs)
1692 + sysRegWrite(AR5315_AHB_ERR0,AHB_ERROR_DET);
1693 + sysRegRead(AR5315_AHB_ERR1);
1695 + proc1 = sysRegRead(AR531X_PROC1);
1696 + procAddr = sysRegRead(AR531X_PROCADDR); /* clears error state */
1697 + dma1 = sysRegRead(AR531X_DMA1);
1698 + dmaAddr = sysRegRead(AR531X_DMAADDR); /* clears error state */
1701 + printk("AHB interrupt: PROCADDR=0x%8.8x PROC1=0x%8.8x DMAADDR=0x%8.8x DMA1=0x%8.8x\n",
1702 + procAddr, proc1, dmaAddr, dma1);
1704 + machine_restart("AHB error"); /* Catastrophic failure */
1707 +static struct irqaction cascade =
1708 + {no_action, SA_INTERRUPT, 0, "cascade",
1711 +static struct irqaction spurious_irq =
1712 + {spurious_irq_handler, SA_INTERRUPT, 0, "spurious_irq",
1715 +static struct irqaction spurious_misc =
1716 + {spurious_misc_handler, SA_INTERRUPT, 0, "spurious_misc",
1719 +static struct irqaction ar531x_timer_interrupt =
1720 + {ar531x_timer_handler, SA_INTERRUPT, 0, "ar531x_timer_interrupt",
1723 +static struct irqaction ar531x_ahb_proc_interrupt =
1724 + {ar531x_ahb_proc_handler, SA_INTERRUPT, 0, "ar531x_ahb_proc_interrupt",
1727 +extern asmlinkage void ar531x_interrupt_receive(void);
1730 + * Called when an interrupt is received, this function
1731 + * determines exactly which interrupt it was, and it
1732 + * invokes the appropriate handler.
1734 + * Implicitly, we also define interrupt priority by
1735 + * choosing which to dispatch first.
1737 +extern void dump_uart(void *);
1742 +ar531x_irq_dispatch(struct pt_regs *regs)
1744 + int cause_intrs = regs->cp0_cause;
1745 + int status_intrs = regs->cp0_status;
1746 + int pending = cause_intrs & status_intrs;
1748 + if (pending & CAUSEF_IP3) {
1749 + do_IRQ(AR531X_IRQ_WLAN0_INTRS, regs);
1751 + else if (pending & CAUSEF_IP4) {
1752 + do_IRQ(AR531X_IRQ_ENET0_INTRS, regs);
1754 + else if (pending & CAUSEF_IP2) {
1755 + AR531X_REG ar531x_isr = sysRegRead(AR5315_ISR);
1756 + AR531X_REG ar531x_imr = sysRegRead(AR5315_IMR);
1757 + unsigned int ar531x_misc_intrs = ar531x_isr & ar531x_imr;
1759 + if (ar531x_misc_intrs & ISR_TIMER)
1760 + do_IRQ(AR531X_MISC_IRQ_TIMER, regs);
1761 + else if (ar531x_misc_intrs & ISR_AHB)
1762 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC, regs);
1763 + else if (ar531x_misc_intrs & ISR_GPIO)
1766 + u32 gpioIntPending;
1768 + gpioIntPending = sysRegRead(AR5315_GPIO_DI) & gpioIntMask;
1769 + for (i=0; i<AR531X_GPIO_IRQ_COUNT; i++) {
1770 + if (gpioIntPending & (1 << i))
1771 + do_IRQ(AR531X_GPIO_IRQ(i), regs);
1774 + else if (ar531x_misc_intrs & ISR_UART0) {
1775 + do_IRQ(AR531X_MISC_IRQ_UART0, regs);
1777 + if (kgdbInterrupt()) {
1778 + if (!user_mode(regs))
1779 + set_async_breakpoint((unsigned long *)®s->cp0_epc);
1781 +#endif /* CONFIG_KGDB */
1783 + else if (ar531x_misc_intrs & ISR_WD)
1784 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG, regs);
1786 + do_IRQ(AR531X_MISC_IRQ_NONE, regs);
1787 + } else if (pending & CAUSEF_IP7) {
1788 + do_IRQ(AR531X_IRQ_CPU_CLOCK, regs);
1791 + do_IRQ(AR531X_IRQ_NONE, regs);
1798 +ar531x_irq_dispatch(struct pt_regs *regs)
1800 + int cause_intrs = regs->cp0_cause;
1801 + int status_intrs = regs->cp0_status;
1802 + int pending = cause_intrs & status_intrs;
1804 + if (pending & CAUSEF_IP2) {
1805 + do_IRQ(AR531X_IRQ_WLAN0_INTRS, regs);
1807 + else if (pending & CAUSEF_IP3) {
1808 + do_IRQ(AR531X_IRQ_ENET0_INTRS, regs);
1810 + else if (pending & CAUSEF_IP4) {
1811 + do_IRQ(AR531X_IRQ_ENET1_INTRS, regs);
1813 + else if (pending & CAUSEF_IP5) {
1814 + do_IRQ(AR531X_IRQ_WLAN1_INTRS, regs);
1816 + else if (pending & CAUSEF_IP6) {
1817 + AR531X_REG ar531x_isr = sysRegRead(AR531X_ISR);
1818 + AR531X_REG ar531x_imr = sysRegRead(AR531X_IMR);
1819 + unsigned int ar531x_misc_intrs = ar531x_isr & ar531x_imr;
1821 + if (ar531x_misc_intrs & AR531X_ISR_TIMER)
1822 + do_IRQ(AR531X_MISC_IRQ_TIMER, regs);
1823 + else if (ar531x_misc_intrs & AR531X_ISR_AHBPROC)
1824 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC, regs);
1825 + else if (ar531x_misc_intrs & AR531X_ISR_AHBDMA)
1826 + do_IRQ(AR531X_MISC_IRQ_AHB_DMA, regs);
1827 + else if (ar531x_misc_intrs & AR531X_ISR_GPIO)
1830 + u32 gpioIntPending;
1832 + gpioIntPending = sysRegRead(AR531X_GPIO_DI) & gpioIntMask;
1833 + for (i=0; i<AR531X_GPIO_IRQ_COUNT; i++) {
1834 + if (gpioIntPending & (1 << i))
1835 + do_IRQ(AR531X_GPIO_IRQ(i), regs);
1838 + else if ((ar531x_misc_intrs & AR531X_ISR_UART0) ||
1839 + (ar531x_misc_intrs & AR531X_ISR_UART0DMA)) {
1840 + do_IRQ(AR531X_MISC_IRQ_UART0, regs);
1842 + if (kgdbInterrupt()) {
1843 + if (!user_mode(regs))
1844 + set_async_breakpoint((unsigned long *)®s->cp0_epc);
1846 +#endif /* CONFIG_KGDB */
1848 + else if (ar531x_misc_intrs & AR531X_ISR_WD)
1849 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG, regs);
1850 + else if (ar531x_misc_intrs & AR531X_ISR_LOCAL)
1851 + do_IRQ(AR531X_MISC_IRQ_LOCAL, regs);
1853 + do_IRQ(AR531X_MISC_IRQ_NONE, regs);
1854 + } else if (pending & CAUSEF_IP7) {
1855 + do_IRQ(AR531X_IRQ_CPU_CLOCK, regs);
1857 + do_IRQ(AR531X_IRQ_NONE, regs);
1862 +void __init init_IRQ(void)
1864 + init_generic_irq();
1865 + set_except_vector(0, ar531x_interrupt_receive);
1867 + /* Initialize interrupt controllers */
1868 + mips_cpu_irq_init(MIPS_CPU_IRQ_BASE);
1869 + ar531x_misc_intr_init(AR531X_MISC_IRQ_BASE);
1870 + ar531x_gpio_intr_init(AR531X_GPIO_IRQ_BASE);
1871 + setup_irq(AR531X_IRQ_MISC_INTRS, &cascade);
1873 + * AR531X_IRQ_CPU_CLOCK is setup by ar531x_timer_setup.
1876 + /* Default "spurious interrupt" handlers */
1877 + setup_irq(AR531X_IRQ_NONE, &spurious_irq);
1878 + setup_irq(AR531X_MISC_IRQ_NONE, &spurious_misc);
1879 + setup_irq(AR531X_GPIO_IRQ_NONE, &spurious_gpio);
1880 +#ifndef CONFIG_AR5315
1881 + setup_irq(AR531X_MISC_IRQ_TIMER, &ar531x_timer_interrupt);
1883 + setup_irq(AR531X_MISC_IRQ_AHB_PROC, &ar531x_ahb_proc_interrupt);
1884 + setup_irq(AR531X_MISC_IRQ_GPIO, &cascade);
1887 +#if CONFIG_EARLY_STOP
1892 diff -urN linux-mips/arch/mips/ar531x/ar531xksyms.c mips-linux-2.4.25/arch/mips/ar531x/ar531xksyms.c
1893 --- linux-mips/arch/mips/ar531x/ar531xksyms.c 1970-01-01 01:00:00.000000000 +0100
1894 +++ mips-linux-2.4.25/arch/mips/ar531x/ar531xksyms.c 2005-12-30 17:26:31.001823800 +0000
1897 + * This file is subject to the terms and conditions of the GNU General Public
1898 + * License. See the file "COPYING" in the main directory of this archive
1899 + * for more details.
1901 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
1904 +#include <linux/module.h>
1905 +#include "asm/atheros/ar531xbsp.h"
1908 +EXPORT_SYMBOL(kgdbInit);
1909 +EXPORT_SYMBOL(kgdbEnabled);
1911 +EXPORT_SYMBOL(ar531x_sys_frequency);
1912 +EXPORT_SYMBOL(get_system_type);
1913 diff -urN linux-mips/arch/mips/ar531x/ar531xlnx.h mips-linux-2.4.25/arch/mips/ar531x/ar531xlnx.h
1914 --- linux-mips/arch/mips/ar531x/ar531xlnx.h 1970-01-01 01:00:00.000000000 +0100
1915 +++ mips-linux-2.4.25/arch/mips/ar531x/ar531xlnx.h 2005-12-30 17:26:31.001823800 +0000
1918 + * This file is subject to the terms and conditions of the GNU General Public
1919 + * License. See the file "COPYING" in the main directory of this archive
1920 + * for more details.
1922 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
1926 + * This file contains definitions needed in order to compile
1927 + * AR531X products for linux. Definitions that are largely
1928 + * AR531X-specific and independent of operating system belong
1929 + * in ar531x.h rather than this file.
1931 +#include "ar531x.h"
1933 +#define MIPS_CPU_IRQ_BASE 0x00
1934 +#define AR531X_HIGH_PRIO 0x10
1935 +#define AR531X_MISC_IRQ_BASE 0x20
1936 +#define AR531X_GPIO_IRQ_BASE 0x30
1938 +/* Software's idea of interrupts handled by "CPU Interrupt Controller" */
1940 +#define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
1941 +#define AR531X_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
1942 +#define AR531X_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
1943 +#define AR531X_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
1944 +#define AR531X_IRQ_LCBUS_PCI MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
1945 +#define AR531X_IRQ_WLAN0_POLL MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
1946 +#define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
1948 +#define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
1949 +#define AR531X_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
1950 +#define AR531X_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
1951 +#define AR531X_IRQ_ENET1_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
1952 +#define AR531X_IRQ_WLAN1_INTRS MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
1953 +#define AR531X_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
1954 +#define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
1956 +/* Miscellaneous interrupts, which share IP6 */
1957 +#define AR531X_MISC_IRQ_NONE AR531X_MISC_IRQ_BASE+0
1958 +#define AR531X_MISC_IRQ_TIMER AR531X_MISC_IRQ_BASE+1
1959 +#define AR531X_MISC_IRQ_AHB_PROC AR531X_MISC_IRQ_BASE+2
1960 +#define AR531X_MISC_IRQ_AHB_DMA AR531X_MISC_IRQ_BASE+3
1961 +#define AR531X_MISC_IRQ_GPIO AR531X_MISC_IRQ_BASE+4
1962 +#define AR531X_MISC_IRQ_UART0 AR531X_MISC_IRQ_BASE+5
1963 +#define AR531X_MISC_IRQ_UART0_DMA AR531X_MISC_IRQ_BASE+6
1964 +#define AR531X_MISC_IRQ_WATCHDOG AR531X_MISC_IRQ_BASE+7
1965 +#define AR531X_MISC_IRQ_LOCAL AR531X_MISC_IRQ_BASE+8
1966 +#define AR531X_MISC_IRQ_COUNT 9
1968 +/* GPIO Interrupts [0..7], share AR531X_MISC_IRQ_GPIO */
1969 +#define AR531X_GPIO_IRQ_NONE AR531X_MISC_IRQ_BASE+0
1970 +#define AR531X_GPIO_IRQ(n) AR531X_MISC_IRQ_BASE+(n)+1
1971 +#ifdef CONFIG_AR5315
1972 +#define AR531X_GPIO_IRQ_COUNT 2
1974 +#define AR531X_GPIO_IRQ_COUNT 9
1977 +#define PHYS_TO_K1(physaddr) KSEG1ADDR(physaddr)
1978 +#define PHYS_TO_K0(physaddr) KSEG0ADDR(physaddr)
1979 +#define UNMAPPED_TO_PHYS(vaddr) PHYSADDR(vaddr)
1980 +#define IS_UNMAPPED_VADDR(vaddr) \
1981 + ((KSEGX(vaddr) == KSEG0) || (KSEGX(vaddr) == KSEG1))
1983 +/* IOCTL commands for /proc/ar531x */
1984 +#define AR531X_CTRL_DO_BREAKPOINT 1
1985 +#define AR531X_CTRL_DO_MADWIFI 2
1988 + * Definitions for operating system portability.
1989 + * These are vxWorks-->Linux translations.
1991 +#define LOCAL static
1998 +#define PRINTF printk
2000 +#define DEBUG_PRINTF printk
2003 +DEBUG_PRINTF while (0) printk
2004 +#define INLINE inline
2006 +#define sysUDelay(usecs) udelay(usecs)
2007 +#define sysMsDelay(msecs) mdelay(msecs)
2008 +typedef volatile UINT8 *VIRT_ADDR;
2009 +#define MALLOC(sz) kmalloc(sz, GFP_KERNEL)
2010 +#define MALLOC_NOSLEEP(sz) kmalloc(sz, GFP_ATOMIC)
2011 +#define FREE(ptr) kfree((void *)ptr)
2012 +#define BSP_BUG() do { printk("kernel BSP BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0)
2013 +#define BSP_BUG_ON(condition) do { if (unlikely((condition)!=0)) BSP_BUG(); } while(0)
2014 +#define ASSERT(x) BSP_BUG_ON(!(x))
2016 +extern struct ar531x_boarddata *ar531x_board_configuration;
2017 +extern char *ar531x_radio_configuration;
2018 +extern char *enet_mac_address_get(int MACUnit);
2020 +extern void kgdbInit(void);
2021 +extern int kgdbEnabled(void);
2022 +extern void breakpoint(void);
2023 +extern int kgdbInterrupt(void);
2024 +extern unsigned int ar531x_cpu_frequency(void);
2025 +extern unsigned int ar531x_sys_frequency(void);
2028 +extern struct irqaction spurious_gpio;
2029 +extern unsigned int gpioIntMask;
2030 +extern void ar531x_gpio_intr_init(int irq_base);
2031 +extern void ar531x_gpio_ctrl_output(int gpio);
2032 +extern void ar531x_gpio_ctrl_input(int gpio);
2033 +extern void ar531x_gpio_set(int gpio, int val);
2034 +extern int ar531x_gpio_get(int gpio);
2035 +extern void ar531x_gpio_intr_enable(unsigned int irq);
2036 +extern void ar531x_gpio_intr_disable(unsigned int irq);
2038 +/* Watchdog Timer support */
2039 +extern int watchdog_start(unsigned int milliseconds);
2040 +extern int watchdog_stop(void);
2041 +extern int watchdog_is_enabled(void);
2042 +extern unsigned int watchdog_min_timer_reached(void);
2043 +extern void watchdog_notify_alive(void);
2045 +#define A_DATA_CACHE_INVAL(start, length) \
2046 + dma_cache_inv((UINT32)(start),(length))
2048 +#define sysWbFlush() mb()
2050 +#define intDisable(x) cli()
2051 +#define intEnable(x) sti()
2052 diff -urN linux-mips/arch/mips/ar531x/ar531xprom.c mips-linux-2.4.25/arch/mips/ar531x/ar531xprom.c
2053 --- linux-mips/arch/mips/ar531x/ar531xprom.c 1970-01-01 01:00:00.000000000 +0100
2054 +++ mips-linux-2.4.25/arch/mips/ar531x/ar531xprom.c 2005-12-30 17:26:31.001823800 +0000
2057 + * This file is subject to the terms and conditions of the GNU General Public
2058 + * License. See the file "COPYING" in the main directory of this archive
2059 + * for more details.
2061 + * Copyright MontaVista Software Inc
2062 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
2066 + * Prom setup file for ar531x
2069 +#include <linux/init.h>
2070 +#include <linux/config.h>
2071 +#include <linux/kernel.h>
2072 +#include <linux/string.h>
2073 +#include <linux/mm.h>
2074 +#include <linux/bootmem.h>
2076 +#include <asm/bootinfo.h>
2077 +#include <asm/addrspace.h>
2079 +#include "ar531xlnx.h"
2081 +#define COMMAND_LINE_SIZE 512
2083 +char arcs_cmdline[COMMAND_LINE_SIZE];
2085 +void __init prom_init(int argc, char *argv[])
2088 + unsigned int memcfg1;
2089 + int bank0AC, bank1AC;
2091 + strcpy(arcs_cmdline, "console=ttyS0,9600");
2092 + for (i=0; i<argc; i++) {
2093 + strcat(arcs_cmdline, " ");
2094 + strcat(arcs_cmdline, argv[i]);
2097 + mips_machgroup = MACH_GROUP_AR531X;
2098 +#ifdef CONFIG_APUNUSED
2099 + mips_machtype = MACH_ATHEROS_UNUSED;
2102 + mips_machtype = MACH_ATHEROS_AP30;
2105 + mips_machtype = MACH_ATHEROS_AP33;
2108 + mips_machtype = MACH_ATHEROS_AP38;
2111 + mips_machtype = MACH_ATHEROS_AP43;
2114 + mips_machtype = MACH_ATHEROS_AP48;
2117 + mips_machtype = MACH_ATHEROS_PB32;
2121 + /* Determine SDRAM size based on Address Checks done at startup */
2123 + /* TO-DO : compute the SDRAM size */
2126 + memcfg1 = sysRegRead(AR531X_MEM_CFG1);
2127 + bank0AC = (memcfg1 & MEM_CFG1_AC0) >> MEM_CFG1_AC0_S;
2128 + bank1AC = (memcfg1 & MEM_CFG1_AC1) >> MEM_CFG1_AC1_S;
2129 + memsz_in_mb = (bank0AC ? (1 << (bank0AC+1)) : 0)
2130 + + (bank1AC ? (1 << (bank1AC+1)) : 0);
2134 + * By default, use all available memory. You can override this
2135 + * to use, say, 8MB by specifying "mem=8M" as an argument on the
2136 + * linux bootup command line.
2138 + add_memory_region(0, memsz_in_mb << 20, BOOT_MEM_RAM);
2141 +void __init prom_free_prom_memory(void)
2144 diff -urN linux-mips/arch/mips/ar531x/ar531xsetup.c mips-linux-2.4.25/arch/mips/ar531x/ar531xsetup.c
2145 --- linux-mips/arch/mips/ar531x/ar531xsetup.c 1970-01-01 01:00:00.000000000 +0100
2146 +++ mips-linux-2.4.25/arch/mips/ar531x/ar531xsetup.c 2005-12-30 17:26:31.002823648 +0000
2149 + * This file is subject to the terms and conditions of the GNU General Public
2150 + * License. See the file "COPYING" in the main directory of this archive
2151 + * for more details.
2153 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
2157 + * Initialization for ar531x SOC.
2160 +#include <linux/config.h>
2161 +#include <linux/init.h>
2162 +#include <linux/delay.h>
2163 +#include <linux/irq.h>
2164 +#include <linux/interrupt.h>
2165 +#include <linux/serial.h>
2166 +#include <linux/types.h>
2167 +#include <linux/string.h>
2169 +#include <asm/reboot.h>
2170 +#include <asm/io.h>
2171 +#include <asm/time.h>
2172 +#include <asm/pgtable.h>
2173 +#include <asm/processor.h>
2174 +#include <asm/reboot.h>
2175 +#include <asm/system.h>
2176 +#include <asm/serial.h>
2178 +#include "ar531xlnx.h"
2181 +ar531x_restart(char *command)
2186 + ** Cold reset does not work,work around is to use the GPIO reset bit.
2189 + reg = sysRegRead(AR5315_GPIO_DO);
2190 + reg &= ~(1 << AR5315_RESET_GPIO);
2191 + sysRegWrite(AR5315_GPIO_DO, reg);
2192 + (void)sysRegRead(AR5315_GPIO_DO); /* flush write to hardware */
2195 + sysRegWrite(AR531X_RESET, AR531X_RESET_SYSTEM);
2203 + printk(KERN_NOTICE "\n** You can safely turn off the power\n");
2208 +ar531x_power_off(void)
2214 +get_system_type(void)
2217 + return "Atheros AR5315";
2219 + return "Atheros AR531X";
2224 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
2225 + * to determine the predevisor value.
2227 +static int CLOCKCTL1_PREDIVIDE_TABLE[4] = {
2235 +static int PLLC_DIVIDE_TABLE[5] = {
2244 +ar531x_cpu_frequency(void)
2246 + static unsigned int ar531x_calculated_cpu_freq=0;
2247 + unsigned int clockCtl,pllcCtrl,cpuDiv;
2248 + unsigned int pllcOut,refdiv,fdiv,divby2;
2250 + if(ar531x_calculated_cpu_freq)
2251 + return ar531x_calculated_cpu_freq;
2254 + pllcCtrl = sysRegRead(AR5315_PLLC_CTL);
2255 + refdiv = (pllcCtrl & PLLC_REF_DIV_M) >> PLLC_REF_DIV_S;
2256 + refdiv = CLOCKCTL1_PREDIVIDE_TABLE[refdiv];
2257 + fdiv = (pllcCtrl & PLLC_FDBACK_DIV_M) >> PLLC_FDBACK_DIV_S;
2258 + divby2 = (pllcCtrl & PLLC_ADD_FDBACK_DIV_M) >> PLLC_ADD_FDBACK_DIV_S;
2260 + pllcOut = (40000000/refdiv)*(2*divby2)*fdiv;
2262 + clockCtl = sysRegRead(AR5315_CPUCLK);
2264 + /* clkm input selected */
2265 + if((clockCtl & CPUCLK_CLK_SEL_M) == 0 || (clockCtl & CPUCLK_CLK_SEL_M) == 1 ) {
2266 + unsigned int clkMdiv;
2267 + clkMdiv = (pllcCtrl & PLLC_CLKM_DIV_M) >> PLLC_CLKM_DIV_S;
2268 + clkMdiv = PLLC_DIVIDE_TABLE[clkMdiv];
2270 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2271 + if(cpuDiv) cpuDiv *= 2;
2274 + ar531x_calculated_cpu_freq= (pllcOut/(clkMdiv * cpuDiv)) ;
2276 + return ar531x_calculated_cpu_freq;
2279 + /* clkc input selected */
2280 + if((clockCtl & CPUCLK_CLK_SEL_M) == 2 ) {
2281 + unsigned int clkCdiv;
2282 + clkCdiv = (pllcCtrl & PLLC_CLKC_DIV_M) >> PLLC_CLKC_DIV_S;
2283 + clkCdiv = PLLC_DIVIDE_TABLE[clkCdiv];
2285 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2286 + if(cpuDiv) cpuDiv *= 2;
2289 + ar531x_calculated_cpu_freq= (pllcOut/(clkCdiv * cpuDiv)) ;
2291 + return ar531x_calculated_cpu_freq;
2292 + } else { /* ref_clk selected */
2294 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2295 + if(cpuDiv) cpuDiv *= 2;
2298 + ar531x_calculated_cpu_freq= (40000000/(cpuDiv)) ;
2299 + return ar531x_calculated_cpu_freq;
2304 +ar531x_apb_frequency(void)
2306 + static unsigned int ar531x_calculated_cpu_freq=0;
2307 + unsigned int clockCtl,pllcCtrl,cpuDiv;
2308 + unsigned int pllcOut,refdiv,fdiv,divby2;
2310 + if(ar531x_calculated_cpu_freq)
2311 + return ar531x_calculated_cpu_freq;
2314 + pllcCtrl = sysRegRead(AR5315_PLLC_CTL);
2315 + refdiv = (pllcCtrl & PLLC_REF_DIV_M) >> PLLC_REF_DIV_S;
2316 + refdiv = CLOCKCTL1_PREDIVIDE_TABLE[refdiv];
2317 + fdiv = (pllcCtrl & PLLC_FDBACK_DIV_M) >> PLLC_FDBACK_DIV_S;
2318 + divby2 = (pllcCtrl & PLLC_ADD_FDBACK_DIV_M) >> PLLC_ADD_FDBACK_DIV_S;
2320 + pllcOut = (40000000/refdiv)*(2*divby2)*fdiv;
2322 + clockCtl = sysRegRead(AR5315_AMBACLK);
2324 + /* clkm input selected */
2325 + if((clockCtl & CPUCLK_CLK_SEL_M) == 0 || (clockCtl & CPUCLK_CLK_SEL_M) == 1 ) {
2326 + unsigned int clkMdiv;
2327 + clkMdiv = (pllcCtrl & PLLC_CLKM_DIV_M) >> PLLC_CLKM_DIV_S;
2328 + clkMdiv = PLLC_DIVIDE_TABLE[clkMdiv];
2330 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2331 + if(cpuDiv) cpuDiv *= 2;
2334 + ar531x_calculated_cpu_freq= (pllcOut/(clkMdiv * cpuDiv)) ;
2336 + return ar531x_calculated_cpu_freq;
2339 + /* clkc input selected */
2340 + if((clockCtl & CPUCLK_CLK_SEL_M) == 2 ) {
2341 + unsigned int clkCdiv;
2342 + clkCdiv = (pllcCtrl & PLLC_CLKC_DIV_M) >> PLLC_CLKC_DIV_S;
2343 + clkCdiv = PLLC_DIVIDE_TABLE[clkCdiv];
2345 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2346 + if(cpuDiv) cpuDiv *= 2;
2349 + ar531x_calculated_cpu_freq= (pllcOut/(clkCdiv * cpuDiv)) ;
2351 + return ar531x_calculated_cpu_freq;
2352 + } else { /* ref_clk selected */
2354 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2355 + if(cpuDiv) cpuDiv *= 2;
2358 + ar531x_calculated_cpu_freq= (40000000/(cpuDiv)) ;
2359 + return ar531x_calculated_cpu_freq;
2365 +ar531x_cpu_frequency(void)
2367 + static unsigned int ar531x_calculated_cpu_freq;
2368 + unsigned int clockctl1_predivide_mask;
2369 + unsigned int clockctl1_predivide_shift;
2370 + unsigned int clockctl1_multiplier_mask;
2371 + unsigned int clockctl1_multiplier_shift;
2372 + unsigned int clockctl1_doubler_mask;
2373 + int wisoc_revision;
2376 + * Trust the bootrom's idea of cpu frequency.
2378 + ar531x_calculated_cpu_freq = sysRegRead(AR5312_SCRATCH);
2379 + if (ar531x_calculated_cpu_freq)
2380 + return ar531x_calculated_cpu_freq;
2382 + wisoc_revision = (sysRegRead(AR531X_REV) & AR531X_REV_MAJ) >> AR531X_REV_MAJ_S;
2384 + if (wisoc_revision == AR531X_REV_MAJ_AR2313) {
2385 + clockctl1_predivide_mask = AR2313_CLOCKCTL1_PREDIVIDE_MASK;
2386 + clockctl1_predivide_shift = AR2313_CLOCKCTL1_PREDIVIDE_SHIFT;
2387 + clockctl1_multiplier_mask = AR2313_CLOCKCTL1_MULTIPLIER_MASK;
2388 + clockctl1_multiplier_shift = AR2313_CLOCKCTL1_MULTIPLIER_SHIFT;
2389 + clockctl1_doubler_mask = AR2313_CLOCKCTL1_DOUBLER_MASK;
2390 + } else { /* AR5312 and AR2312 */
2391 + clockctl1_predivide_mask = AR5312_CLOCKCTL1_PREDIVIDE_MASK;
2392 + clockctl1_predivide_shift = AR5312_CLOCKCTL1_PREDIVIDE_SHIFT;
2393 + clockctl1_multiplier_mask = AR5312_CLOCKCTL1_MULTIPLIER_MASK;
2394 + clockctl1_multiplier_shift = AR5312_CLOCKCTL1_MULTIPLIER_SHIFT;
2395 + clockctl1_doubler_mask = AR5312_CLOCKCTL1_DOUBLER_MASK;
2399 + * Clocking is derived from a fixed 40MHz input clock.
2400 + * cpuFreq = InputClock * MULT (where MULT is PLL multiplier)
2402 + * sysFreq = cpuFreq / 4 (used for APB clock, serial,
2403 + * flash, Timer, Watchdog Timer)
2405 + * cntFreq = cpuFreq / 2 (use for CPU count/compare)
2407 + * So, for example, with a PLL multiplier of 5, we have
2408 + * cpuFrez = 200MHz
2410 + * cntFreq = 100MHz
2412 + * We compute the CPU frequency, based on PLL settings.
2414 + if (ar531x_calculated_cpu_freq == 0) {
2415 + unsigned int clockCtl1 = sysRegRead(AR5312_CLOCKCTL1);
2417 + int preDivideSelect = (clockCtl1 & clockctl1_predivide_mask) >>
2418 + clockctl1_predivide_shift;
2420 + int preDivisor = CLOCKCTL1_PREDIVIDE_TABLE[preDivideSelect];
2422 + int multiplier = (clockCtl1 & clockctl1_multiplier_mask) >>
2423 + clockctl1_multiplier_shift;
2425 + if (clockCtl1 & clockctl1_doubler_mask) {
2426 + multiplier = multiplier << 1;
2429 + ar531x_calculated_cpu_freq = (40000000 / preDivisor) * multiplier;
2432 + return ar531x_calculated_cpu_freq;
2437 +ar531x_sys_frequency(void)
2439 + static unsigned int ar531x_calculated_sys_freq = 0;
2441 + if (ar531x_calculated_sys_freq == 0) {
2442 + ar531x_calculated_sys_freq = ar531x_cpu_frequency() / 4;
2445 + return ar531x_calculated_sys_freq;
2452 +#ifndef CONFIG_AR5315
2453 + /* Configure flash bank 0 */
2454 + flash_ctl = FLASHCTL_E |
2457 + (0x01 << FLASHCTL_IDCY_S) |
2458 + (0x07 << FLASHCTL_WST1_S) |
2459 + (0x07 << FLASHCTL_WST2_S) |
2460 + (sysRegRead(AR531X_FLASHCTL0) & FLASHCTL_MW);
2462 + sysRegWrite(AR531X_FLASHCTL0, flash_ctl);
2464 + /* Disable other flash banks */
2465 + sysRegWrite(AR531X_FLASHCTL1,
2466 + sysRegRead(AR531X_FLASHCTL1) & ~(FLASHCTL_E | FLASHCTL_AC));
2468 + sysRegWrite(AR531X_FLASHCTL2,
2469 + sysRegRead(AR531X_FLASHCTL2) & ~(FLASHCTL_E | FLASHCTL_AC));
2478 + struct serial_struct s;
2480 + memset(&s, 0, sizeof(s));
2482 + s.flags = STD_COM_FLAGS;
2483 + s.io_type = SERIAL_IO_MEM;
2485 + s.baud_base = ar531x_apb_frequency()/16;
2487 + s.baud_base = ar531x_sys_frequency()/16;
2489 + s.irq = AR531X_MISC_IRQ_UART0;
2490 + s.iomem_reg_shift = 2;
2492 + s.iomem_base = (u8 *)AR5315_UART0;
2494 + s.iomem_base = (u8 *)AR531X_UART0;
2497 + if (early_serial_setup(&s) != 0)
2498 + printk(KERN_ERR "early_serial_setup failed\n");
2501 +extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
2503 +ar531x_timer_setup(struct irqaction *irq)
2505 + unsigned int count;
2507 + /* Usually irq is timer_irqaction (timer_interrupt) */
2508 + setup_irq(AR531X_IRQ_CPU_CLOCK, irq);
2510 + /* to generate the first CPU timer interrupt */
2511 + count = read_c0_count();
2512 + write_c0_compare(count + 1000);
2515 +extern void (*board_time_init)(void);
2518 +ar531x_time_init(void)
2520 + mips_hpt_frequency = ar531x_cpu_frequency() / 2;
2526 + /* Clear any lingering AHB errors */
2528 + unsigned int config = read_c0_config();
2529 + write_c0_config(config & ~0x3);
2530 + sysRegWrite(AR5315_AHB_ERR0,AHB_ERROR_DET);
2531 + sysRegRead(AR5315_AHB_ERR1);
2532 + sysRegWrite(AR5315_WDC, WDC_IGNORE_EXPIRATION);
2534 + sysRegRead(AR531X_PROCADDR);
2535 + sysRegRead(AR531X_DMAADDR);
2537 + sysRegWrite(AR531X_WD_CTRL, AR531X_WD_CTRL_IGNORE_EXPIRATION);
2541 + /* Disable data watchpoints */
2542 + write_c0_watchlo0(0);
2544 + board_time_init = ar531x_time_init;
2545 + board_timer_setup = ar531x_timer_setup;
2547 + _machine_restart = ar531x_restart;
2548 + _machine_halt = ar531x_halt;
2549 + _machine_power_off = ar531x_power_off;
2554 diff -urN linux-mips/arch/mips/ar531x/Makefile mips-linux-2.4.25/arch/mips/ar531x/Makefile
2555 --- linux-mips/arch/mips/ar531x/Makefile 1970-01-01 01:00:00.000000000 +0100
2556 +++ mips-linux-2.4.25/arch/mips/ar531x/Makefile 2005-12-30 17:26:29.912989328 +0000
2559 +# This file is subject to the terms and conditions of the GNU General Public
2560 +# License. See the file "COPYING" in the main directory of this archive
2561 +# for more details.
2563 +# Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
2566 +# Makefile for Atheros ar531x boards
2568 +# Note! Dependencies are done automagically by 'make dep', which also
2569 +# removes any old dependencies. DON'T put your own dependencies here
2570 +# unless it's something special (ie not a .c file).
2574 + $(CPP) $(CFLAGS) $< -o $*.s
2576 + $(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $*.o
2578 +O_TARGET:= ar531x.o
2580 +export-objs = ar531xksyms.o
2582 +obj-y := ar531xdbg_io.o \
2590 +include $(TOPDIR)/Rules.make
2591 diff -urN linux-mips/arch/mips/ar531x/README mips-linux-2.4.25/arch/mips/ar531x/README
2592 --- linux-mips/arch/mips/ar531x/README 1970-01-01 01:00:00.000000000 +0100
2593 +++ mips-linux-2.4.25/arch/mips/ar531x/README 2005-12-30 17:26:30.478903296 +0000
2595 +Basic information for the AR531X Board Support Package
2597 +This directory contains the "LBSP" -- Linux Board Support Package --
2598 +for Linux on the Atheros AR531X Wireless System-On-a-Chip. It is intended
2599 +primarily as a building block for wireless products. At this time, the
2600 +AR531X Linux BSP is experimental code, and is actively UNDER CONSTRUCTION.
2602 +Some components that are supported by this LBSP along with a standard 2.4
2603 +Linux MIPS kernel include
2605 + instruction and data caches
2607 + flash (Macronix, AMD, STS, etc.)
2610 + ethernet PHY or PHY Switch (RealTek, Kendin, Marvell)
2611 + General-Purpose I/O pins
2612 + kernel debugging with kgdb
2614 +This LBSP code does NOT include drivers for the wireless components of the
2615 +chip/boards! Drivers for those components may be distributed separately.
2616 +In particular, the MADWiFi project under SourceForge supports (not yet!)
2617 +wireless functions on the AR531X chipset. See
2618 + http://www.sourceforge.net/projects/madwifi
2620 +Files included in this BSP:
2621 +ae531xlnx.c - Linux-specific portions of the ethernet driver
2622 +ae531xmac.c - OS-independent AR531X ethernet MAC code
2623 +ae531xmac.h - OS-independent AR531X ethernet MAC software definitions
2624 +ae531xreg.h - OS-independent AR531X ethernet MAC hardware definitions
2625 +ar531x.h - OS-independent AR531X system hardware definitions
2626 +ar531xlnx.h - Linux-specific AR531X system definitions and externs
2627 +defconfig-ar531x - Default Linux configuration file
2628 +intr_recv.S - Linux interrupt "glue" code
2629 +ar531xirq.c - Linux Interrupt Request management
2630 +Makefile - Linux makefile
2631 +mvPhy.c - OS-independent ethernet PHY code for Marvell Switch
2632 +mvPhy.h - OS-independent ethernet PHY definitions for Marvell Switch
2633 +ar531xprom.c - Linux prom "glue" code
2634 +ar531xsetup.c - Linux startup code
2635 +ar531xdbg_io.c - Support for kgdb-based debugging and for EARLY_PRINTK_HACK
2636 +ar531xproc.c - Pseudo-device driver for /proc/ar531x device
2637 +ar531xgpio.c - Support for General Purpose I/O pins
2638 +ar531xwmacsl.c - Wireless MAC Support Layer
2640 +Additional files, distributed with the BSP:
2642 +README.BUILD - Instructions for building a linux kernel from source
2643 +README.EXECUTE - Instructions for testing your linux kernel
2644 +README.RAMDISK - Instructions for building a root ramdisk image
2646 +ramdisk.gz - A binary ramdisk image, suitable for use with AR531X.
2647 +DIFFS - Directory that contains "patch" files (See README.BUILD)
2650 +There are several ways to boot a vmlinux image on an AR531X board:
2651 + -You can boot in over ethernet from the vxWorks bootrom, which is preloaded
2652 + on all Atheros boards
2653 + -You can use an ICE (e.g. VisionICE) to load the vmlinux image. You will
2654 + need appropriate register initialization (e.g. AP30.ini file)
2655 + -You can use the eCos RedBoot bootrom loader. This is a full-featured
2656 + bootrom which as been ported to AR531x. It can boot vmlinux over ethernet
2657 + or from flash. Source code is available from Atheros.
2659 +Please send comments, corrections, complaints, criticisms, suggestions,
2660 +enhancements, requests, or any other reasonable communications regarding
2661 +this effort, to "linux@atheros.com". Your email will be received by a
2662 +couple of engineers, and redirected as appropriate.
2663 diff -urN linux-mips/arch/mips/ar531x/README.BUILD mips-linux-2.4.25/arch/mips/ar531x/README.BUILD
2664 --- linux-mips/arch/mips/ar531x/README.BUILD 1970-01-01 01:00:00.000000000 +0100
2665 +++ mips-linux-2.4.25/arch/mips/ar531x/README.BUILD 2005-12-30 17:26:30.478903296 +0000
2667 + How to BUILD a linux kernel for an AR531X system
2669 +It is expected that you will build Linux on an existing Linux system, which
2670 +has all of the standard Linux tools.
2672 +01) Obtain a MIPS BigEndian ELF gcc-compatible toolchain. For example,
2673 + if you're cross-compiling on a x86 Linux system, you could use:
2674 + ftp://ftp.mips.com/pub/tools/software/sde-for-linux/sdelinux-5.01-4eb.i386.rpm
2676 +02) Obtain the latest working MIPS Linux kernel
2677 + cvs -d :pserver:cvs@ftp.linux-mips.org:/home/cvs login (password "cvs")
2678 + cvs -d :pserver:cvs@ftp.linux-mips.org:/home/cvs co -r linux_2_4 linux
2680 + Now "cd linux". The remainder of these instructions assume
2681 + that you are in the linux directory.
2683 +03) Place the contents of this directory at arch/mips/ar531x.
2685 +04) Use the patch command to patch generic linux files according
2686 + to the DIFFS directory
2687 + for i in arch/mips/ar531x/DIFFS/*.diff
2691 + NOTE: This version of the AR531X Linux BSP was tested with
2692 + MIPS Linux 2.4.22 as of 11/14/03. If you use a different
2693 + (e.g. more recent) version of Linux source, you may need to
2694 + resolve some minor patch and compilation issues.
2696 +05) Set up a RAMDISK image.
2697 + See the instructions in README.RAMDISK.
2699 +06) Set up a linux configuration using ar531x/defconfig-ar531x.
2700 + cp arch/mips/ar531x/defconfig-ar531x .config
2701 + make oldconfig (answer all questions that are asked)
2702 + NOTE: For development/debug purposes, you may want to
2703 + enable CONFIG_RUNTIME_DEBUG and CONFIG_KGDB.
2705 +07) Make dependencies.
2708 +08) Build the linux kernel
2711 +09) The linux image you just built is in vmlinux.
2712 + See instructions in README.EXECUTE to run your vmlinux
2713 + image on an AP531X-based board.
2714 diff -urN linux-mips/arch/mips/ar531x/README.EXECUTE mips-linux-2.4.25/arch/mips/ar531x/README.EXECUTE
2715 --- linux-mips/arch/mips/ar531x/README.EXECUTE 1970-01-01 01:00:00.000000000 +0100
2716 +++ mips-linux-2.4.25/arch/mips/ar531x/README.EXECUTE 2005-12-30 17:26:30.479903144 +0000
2718 + How to EXECUTE a linux image on an AR531X system
2720 +There are currently three ways to run you vmlinux image:
2721 + 1) Load it using the vxWorks bootrom that is supplied with the board.
2722 + You can load it over ethernet or from the TFFS file system, if you
2723 + have sufficient flash to store the image.
2724 + 2) Load it using an ICE (e.g. VisionICE).
2725 + 3) Use a bootrom loader, such as eCos RedBoot.
2727 +After you have booted linux:
2728 + By default, the root filesystem on ramdisk is read-only.
2729 + To make it writable, use "mount -o remount w /".
2731 + The user-level commands are slightly non-standard, as they
2732 + are based on "busybox".
2734 + The "wget" command is included. You can use wget to fetch
2735 + files from any ftp server. So, for instance, you can fetch
2736 + a kernel module and then "insmod" it.
2738 +Note that the standard source-level kernel debugger, kgdb, works well
2739 +over the serial line with this port. We use kgdb and the kgdb_demux perl
2740 +script -- available over the www -- for debugging.
2741 diff -urN linux-mips/arch/mips/ar531x/README.VERSION mips-linux-2.4.25/arch/mips/ar531x/README.VERSION
2742 --- linux-mips/arch/mips/ar531x/README.VERSION 1970-01-01 01:00:00.000000000 +0100
2743 +++ mips-linux-2.4.25/arch/mips/ar531x/README.VERSION 2005-12-30 17:26:30.479903144 +0000
2745 +Source release last modified: 12/16/03
2746 diff -urN linux-mips/arch/mips/config-shared.in mips-linux-2.4.25/arch/mips/config-shared.in
2747 --- linux-mips/arch/mips/config-shared.in 2005-12-24 15:11:15.963885864 +0000
2748 +++ mips-linux-2.4.25/arch/mips/config-shared.in 2005-12-30 17:26:31.611731080 +0000
2750 dep_bool 'Support for Alchemy PB1550 board' CONFIG_MIPS_PB1550 $CONFIG_MIPS32
2751 dep_bool 'Support for Alchemy PB1200 board' CONFIG_MIPS_PB1200 $CONFIG_MIPS32
2752 dep_bool 'Support for Alchemy Hydrogen3 board' CONFIG_MIPS_HYDROGEN3 $CONFIG_MIPS32
2753 +dep_bool 'Support for Atheros AR5312/AR2312 WiSoC (EXPERIMENTAL)' CONFIG_AR531X $CONFIG_AR531X $CONFIG_EXPERIMENTAL
2754 dep_bool 'Support for MyCable XXS1500 board' CONFIG_MIPS_XXS1500 $CONFIG_MIPS32
2755 dep_bool 'Support for 4G Systems MTX-1 board' CONFIG_MIPS_MTX1 $CONFIG_MIPS32
2756 dep_bool 'Support for Cogent CSB250 board' CONFIG_COGENT_CSB250 $CONFIG_MIPS32
2757 @@ -238,6 +239,63 @@
2758 define_bool CONFIG_PC_KEYB y
2759 define_bool CONFIG_OLD_TIME_C y
2761 +if [ "$CONFIG_AR531X" = "y" ]; then
2762 + define_bool CONFIG_IRQ_CPU y
2763 + define_bool CONFIG_CPU_R4X00 y
2764 + define_bool CONFIG_SERIAL y
2765 + define_bool CONFIG_NEW_IRQ y
2766 + define_bool CONFIG_NEW_TIME_C y
2767 + define_bool CONFIG_AR5312
2768 + define_bool CONFIG_NONCOHERENT_IO y
2769 + bool 'Enable early printk hack' CONFIG_EARLY_PRINTK_HACK
2770 + define_bool CONFIG_SCSI n
2771 + mainmenu_option next_comment
2772 + comment 'Board selection'
2773 + choice 'Board type' \
2774 + "UNKNOWN CONFIG_APUNKNOWN \
2775 + AP30 CONFIG_AP30 \
2776 + AP31 CONFIG_AP31 \
2777 + AP33 CONFIG_AP33 \
2778 + AP38 CONFIG_AP38 \
2779 + AP43 CONFIG_AP43 \
2780 + AP48 CONFIG_AP48 \
2781 + AP51 CONFIG_AP51 \
2782 + AP30-ASK CONFIG_AP30ASK" AP30
2783 + if [ "$CONFIG_AP30" = "y" -o "$CONFIG_AP30ASK" = "y" ]; then
2784 + define_int CONFIG_MTD_PHYSMAP_BUSWIDTH 2
2786 + if [ "$CONFIG_AP33" = "y" ]; then
2787 + define_int CONFIG_MTD_PHYSMAP_BUSWIDTH 1
2789 + if [ "$CONFIG_AP38" = "y" ]; then
2790 + define_int CONFIG_MTD_PHYSMAP_BUSWIDTH 1
2792 + if [ "$CONFIG_AP43" = "y" ]; then
2793 + define_int CONFIG_MTD_PHYSMAP_BUSWIDTH 1
2795 + if [ "$CONFIG_AP48" = "y" ]; then
2796 + define_int CONFIG_MTD_PHYSMAP_BUSWIDTH 1
2798 + if [ "$CONFIG_AP51" = "y" ]; then
2799 + define_int CONFIG_MTD_PHYSMAP_BUSWIDTH 1
2800 + define_bool CONFIG_MTD_REDBOOT_PARTS y
2801 + define_bool CONFIG_AR5315 y
2802 + define_bool CONFIG_MTD_SPIFLASH y
2803 + define_bool CONFIG_MTD_CFI n
2804 + define_bool CONFIG_MTD_JEDECPROBE n
2805 + define_bool CONFIG_MTD_CFI_INTELEXT n
2806 + define_bool CONFIG_MTD_CFI_AMDSTD n
2807 + define_bool CONFIG_MTD_OBSOLETE_CHIPS n
2808 + define_bool CONFIG_MTD_AMDSTD n
2809 + define_bool CONFIG_MTD_JEDEC n
2810 + define_bool CONFIG_MTD_PHYSMAP n
2812 + mainmenu_option next_comment
2813 + comment 'Flash Selection'
2814 + choice 'Flash Size' \
2815 + "2MB CONFIG_FLASH_2MB \
2816 + 4MB CONFIG_FLASH_4MB" 2MB
2818 if [ "$CONFIG_CASIO_E55" = "y" ]; then
2819 define_bool CONFIG_IRQ_CPU y
2820 define_bool CONFIG_NEW_TIME_C y
2822 diff -urN linux-mips/arch/mips/kernel/setup.c mips-linux-2.4.25/arch/mips/kernel/setup.c
2823 --- linux-mips/arch/mips/kernel/setup.c 2005-12-24 15:11:16.188851664 +0000
2824 +++ mips-linux-2.4.25/arch/mips/kernel/setup.c 2005-12-30 17:26:33.536438480 +0000
2826 void hp_setup(void);
2827 void au1x00_setup(void);
2828 void frame_info_init(void);
2829 + void ar531x_setup(void);
2832 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE)
2833 @@ -693,6 +694,12 @@
2834 pmc_yosemite_setup();
2838 +#ifdef CONFIG_AR531X
2839 + case MACH_GROUP_AR531X:
2844 panic("Unsupported architecture");
2846 diff -urN linux-mips/arch/mips/Makefile mips-linux-2.4.25/arch/mips/Makefile
2847 --- linux-mips/arch/mips/Makefile 2005-12-24 15:11:15.903894984 +0000
2848 +++ mips-linux-2.4.25/arch/mips/Makefile 2005-12-30 17:26:29.911989480 +0000
2849 @@ -701,6 +701,17 @@
2850 LOADADDR += 0x80020000
2853 +ifdef CONFIG_AR531X
2854 +SUBDIRS += arch/mips/ar531x
2855 +LIBS += arch/mips/ar531x/ar531x.o
2857 +LOADADDR += 0x80041000
2859 +LOADADDR += 0x80002000
2865 # Choosing incompatible machines durings configuration will result in
2866 # error messages during linking. Select a default linkscript if
2867 diff -urN linux-mips/ath_version.mk mips-linux-2.4.25/ath_version.mk
2868 --- linux-mips/ath_version.mk 1970-01-01 01:00:00.000000000 +0100
2869 +++ mips-linux-2.4.25/ath_version.mk 2005-12-30 17:27:00.579327336 +0000
2871 +EXTRAVERSION=-LSDK-5.0.0-RC5
2872 diff -urN linux-mips/drivers/char/serial.c mips-linux-2.4.25/drivers/char/serial.c
2873 --- linux-mips/drivers/char/serial.c 2005-12-24 15:11:21.796999096 +0000
2874 +++ mips-linux-2.4.25/drivers/char/serial.c 2005-12-30 17:27:10.815771160 +0000
2875 @@ -3441,7 +3441,7 @@
2877 static _INLINE_ void show_serial_version(void)
2879 - printk(KERN_INFO "%s version %s%s (%s) with%s", serial_name,
2880 + printk(KERN_INFO "%s version %s%s (%s) with%s\n", serial_name,
2881 serial_version, LOCAL_VERSTRING, serial_revdate,
2884 @@ -5567,7 +5567,7 @@
2885 printk(KERN_INFO"ttyS%02d%s at 0x%p (irq = %d) is a %s\n",
2886 state->line + SERIAL_DEV_OFFSET,
2887 (state->flags & ASYNC_FOURPORT) ? " FourPort" : "",
2888 - state->iomem_base, state->irq,
2889 + (void *)state->iomem_base, state->irq,
2890 uart_config[state->type].name);
2893 diff -urN linux-mips/drivers/mtd/chips/cfi_cmdset_0002.c mips-linux-2.4.25/drivers/mtd/chips/cfi_cmdset_0002.c
2894 --- linux-mips/drivers/mtd/chips/cfi_cmdset_0002.c 2005-12-24 15:11:25.102496584 +0000
2895 +++ mips-linux-2.4.25/drivers/mtd/chips/cfi_cmdset_0002.c 2005-12-30 17:27:21.333172272 +0000
2897 or tells us why it failed. */
2900 - timeo = jiffies + (HZ/1000); /* setting timeout to 1ms for now */
2901 + timeo = jiffies + (HZ/1000) + 1; /* setting timeout to 1ms for now */
2903 oldstatus = cfi_read(map, adr);
2904 status = cfi_read(map, adr);
2905 @@ -536,16 +536,18 @@
2906 if( (status & dq5) == dq5 ) {
2907 /* When DQ5 raises, we must check once again
2908 if DQ6 is toggling. If not, the erase has been
2909 - completed OK. If not, reset chip. */
2910 + completed OK. But if so, reset chip. */
2911 oldstatus = cfi_read(map, adr);
2912 status = cfi_read(map, adr);
2914 if ( (oldstatus & 0x00FF) == (status & 0x00FF) ) {
2916 printk(KERN_WARNING "Warning: DQ5 raised while program operation was in progress, however operation completed OK\n" );
2919 /* DQ5 is active so we can do a reset and stop the erase */
2920 cfi_write(map, CMD(0xF0), chip->start);
2921 - printk(KERN_WARNING "Internal flash device timeout occurred or write operation was performed while flash was programming.\n" );
2922 + printk(KERN_WARNING "Internal flash device timeout pt A occurred or write operation was performed while flash was programming. timeout=%d\n",chip->word_write_time );
2925 printk(KERN_WARNING "Waiting for write to complete timed out in do_write_oneword.");
2928 /* DQ5 is active so we can do a reset and stop the erase */
2929 cfi_write(map, CMD(0xF0), chip->start);
2930 - printk( KERN_WARNING "Internal flash device timeout occured or write operation was performed while flash was erasing\n" );
2931 + printk( KERN_WARNING "Internal flash device timeout pt B occured or write operation was performed while flash was erasing\n" );
2935 diff -urN linux-mips/drivers/mtd/chips/cfi_probe.c mips-linux-2.4.25/drivers/mtd/chips/cfi_probe.c
2936 --- linux-mips/drivers/mtd/chips/cfi_probe.c 2005-12-24 15:11:25.103496432 +0000
2937 +++ mips-linux-2.4.25/drivers/mtd/chips/cfi_probe.c 2005-12-30 17:27:21.507145824 +0000
2939 struct flchip *chips, struct cfi_private *cfi)
2944 if ((base + 0) >= map->size) {
2946 "Probe at base[0x00](0x%08lx) past the end of the map(0x%08lx)\n",
2947 @@ -221,12 +221,10 @@
2949 static void print_cfi_ident(struct cfi_ident *cfip)
2952 if (cfip->qry[0] != 'Q' || cfip->qry[1] != 'R' || cfip->qry[2] != 'Y') {
2953 printk("Invalid CFI ident structure.\n");
2957 printk("Primary Vendor Command Set: %4.4X (%s)\n", cfip->P_ID, vendorname(cfip->P_ID));
2959 printk("Primary Algorithm Table at %4.4X\n", cfip->P_ADR);
2960 diff -urN linux-mips/drivers/mtd/chips/jedec_probe.c mips-linux-2.4.25/drivers/mtd/chips/jedec_probe.c
2961 --- linux-mips/drivers/mtd/chips/jedec_probe.c 2005-12-24 15:11:25.126492936 +0000
2962 +++ mips-linux-2.4.25/drivers/mtd/chips/jedec_probe.c 2005-12-30 17:27:21.532142024 +0000
2964 #define SST29LE512 0x003d
2965 #define SST39LF800 0x2781
2966 #define SST39LF160 0x2782
2967 +#define SST39LF1601 0x234b
2968 #define SST39LF512 0x00D4
2969 #define SST39LF010 0x00D5
2970 #define SST39LF020 0x00D6
2972 #define SST49LF030A 0x001C
2973 #define SST49LF040A 0x0051
2974 #define SST49LF080A 0x005B
2975 +#define SST39VF3201 0x235B
2976 +#define SST39VF3202 0x235A
2979 #define TC58FVT160 0x00C2
2980 @@ -900,7 +903,43 @@
2982 regions: {ERASEINFO(0x01000,256),
2986 + mfr_id: MANUFACTURER_SST,
2987 + dev_id: SST39LF160,
2988 + name: "SST 39LF160",
2989 + DevSize: SIZE_2MiB,
2990 + CmdSet: P_ID_AMD_STD,
2991 + NumEraseRegions: 1,
2992 + regions: {ERASEINFO(0x01000,512),
2995 + mfr_id: MANUFACTURER_SST,
2996 + dev_id: SST39LF1601,
2997 + name: "SST 39LF1601",
2998 + DevSize: SIZE_2MiB,
2999 + CmdSet: P_ID_AMD_STD,
3000 + NumEraseRegions: 1,
3001 + regions: {ERASEINFO(0x01000,512),
3004 + mfr_id: MANUFACTURER_SST,
3005 + dev_id: SST39VF3201,
3006 + name: "SST 39VF3201",
3007 + DevSize: SIZE_4MiB,
3008 + CmdSet: P_ID_AMD_STD,
3009 + NumEraseRegions: 1,
3010 + regions: {ERASEINFO(0x01000,1024),
3013 + mfr_id: MANUFACTURER_SST,
3014 + dev_id: SST39VF3202,
3015 + name: "SST 39VF3202",
3016 + DevSize: SIZE_4MiB,
3017 + CmdSet: P_ID_AMD_STD,
3018 + NumEraseRegions: 1,
3019 + regions: {ERASEINFO(0x01000,1024),
3025 @@ -967,6 +1006,35 @@
3026 p_cfi->cfiq->DevSize = jedec_table[index].DevSize;
3027 p_cfi->cfi_mode = CFI_MODE_JEDEC;
3030 + * Add the following code to set the flash timing parameters.
3031 + * Maybe this is done in a table somwehere else? I can't find it.
3035 + switch(jedec_table[index].dev_id) {
3038 + p_cfi->cfiq->WordWriteTimeoutTyp = 3; /* 8 us */
3039 + p_cfi->cfiq->WordWriteTimeoutMax = 4; /* 16 us */
3040 + p_cfi->cfiq->BlockEraseTimeoutTyp = 15; /* Actually 18ms, max 25 */
3041 + p_cfi->cfiq->BlockEraseTimeoutMax = 15; /* Actually 25ms */
3042 + p_cfi->cfiq->ChipEraseTimeoutTyp = 16; /* Max is 50ms, typical is 40ms */
3043 + p_cfi->cfiq->ChipEraseTimeoutMax = 16;
3047 + p_cfi->cfiq->WordWriteTimeoutTyp = 4; /* 14 us */
3048 + p_cfi->cfiq->WordWriteTimeoutMax = 5; /* 20 us */
3049 + p_cfi->cfiq->BlockEraseTimeoutTyp = 15; /* Actually 18ms, max 25 */
3050 + p_cfi->cfiq->BlockEraseTimeoutMax = 15; /* Actually 25ms */
3051 + p_cfi->cfiq->ChipEraseTimeoutTyp = 17; /* Max is 70ms, typical is 40ms */
3052 + p_cfi->cfiq->ChipEraseTimeoutMax = 17;
3058 for (i=0; i<num_erase_regions; i++){
3059 p_cfi->cfiq->EraseRegionInfo[i] = jedec_table[index].regions[i];
3061 diff -urN linux-mips/drivers/mtd/Config.in mips-linux-2.4.25/drivers/mtd/Config.in
3062 --- linux-mips/drivers/mtd/Config.in 2005-12-24 15:11:25.091498256 +0000
3063 +++ mips-linux-2.4.25/drivers/mtd/Config.in 2005-12-30 17:27:21.182195224 +0000
3065 dep_tristate ' MTD partitioning support' CONFIG_MTD_PARTITIONS $CONFIG_MTD
3066 dep_tristate ' MTD concatenating support' CONFIG_MTD_CONCAT $CONFIG_MTD
3067 dep_tristate ' RedBoot partition table parsing' CONFIG_MTD_REDBOOT_PARTS $CONFIG_MTD_PARTITIONS
3068 + if [ "$CONFIG_MTD_END_RESERVED" != "" ]; then
3069 + define_int CONFIG_MTD_END_RESERVED $CONFIG_MTD_END_RESERVED
3071 dep_tristate ' Command line partition table parsing' CONFIG_MTD_CMDLINE_PARTS $CONFIG_MTD_PARTITIONS
3072 if [ "$CONFIG_ARM" = "y" ]; then
3073 dep_tristate ' ARM Firmware Suite partition parsing' CONFIG_MTD_AFS_PARTS $CONFIG_MTD_PARTITIONS
3074 diff -urN linux-mips/drivers/mtd/devices/Makefile mips-linux-2.4.25/drivers/mtd/devices/Makefile
3075 --- linux-mips/drivers/mtd/devices/Makefile 2005-12-24 15:11:25.128492632 +0000
3076 +++ mips-linux-2.4.25/drivers/mtd/devices/Makefile 2005-12-30 17:27:21.561137616 +0000
3078 obj-$(CONFIG_MTD_MTDRAM) += mtdram.o
3079 obj-$(CONFIG_MTD_LART) += lart.o
3080 obj-$(CONFIG_MTD_BLKMTD) += blkmtd.o
3081 +obj-$(CONFIG_MTD_SPIFLASH) += spiflash.o
3083 include $(TOPDIR)/Rules.make
3084 diff -urN linux-mips/drivers/mtd/devices/spiflash.c mips-linux-2.4.25/drivers/mtd/devices/spiflash.c
3085 --- linux-mips/drivers/mtd/devices/spiflash.c 1970-01-01 01:00:00.000000000 +0100
3086 +++ mips-linux-2.4.25/drivers/mtd/devices/spiflash.c 2005-12-30 17:27:21.652123784 +0000
3090 + * MTD driver for the SPI Flash Memory support.
3092 + * $Id: //depot/sw/releases/linuxsrc/src/kernels/mips-linux-2.4.25/drivers/mtd/devices/spiflash.c#3 $
3095 + * Copyright (c) 2005-2006 Atheros Communications Inc.
3097 + * This code is free software; you can redistribute it and/or modify
3098 + * it under the terms of the GNU General Public License version 2 as
3099 + * published by the Free Software Foundation.
3103 +/*===========================================================================
3104 +** !!!! VERY IMPORTANT NOTICE !!!! FLASH DATA STORED IN LITTLE ENDIAN FORMAT
3106 +** This module contains the Serial Flash access routines for the Atheros SOC.
3107 +** The Atheros SOC integrates a SPI flash controller that is used to access
3108 +** serial flash parts. The SPI flash controller executes in "Little Endian"
3109 +** mode. THEREFORE, all WRITES and READS from the MIPS CPU must be
3110 +** BYTESWAPPED! The SPI Flash controller hardware by default performs READ
3111 +** ONLY byteswapping when accessed via the SPI Flash Alias memory region
3112 +** (Physical Address 0x0800_0000 - 0x0fff_ffff). The data stored in the
3113 +** flash sectors is stored in "Little Endian" format.
3115 +** The spiflash_write() routine performs byteswapping on all write
3117 +**===========================================================================*/
3119 +#include <linux/kernel.h>
3120 +#include <linux/module.h>
3121 +#include <linux/types.h>
3122 +#include <linux/version.h>
3123 +#include <linux/errno.h>
3124 +#include <linux/slab.h>
3125 +#include <linux/mtd/mtd.h>
3126 +#include <linux/mtd/partitions.h>
3127 +#include <asm/delay.h>
3128 +#include <asm/io.h>
3129 +#include "spiflash.h"
3132 +/* #define SPIFLASH_DEBUG */
3134 +#ifndef __BIG_ENDIAN
3135 +#error This driver currently only works with big endian CPU.
3138 +static char module_name[] = "spiflash";
3140 +#define MIN(a,b) ((a) < (b) ? (a) : (b))
3144 +#define ROOTFS_NAME "rootfs"
3146 +static __u32 spiflash_regread32(int reg);
3147 +static void spiflash_regwrite32(int reg, __u32 data);
3148 +static __u32 spiflash_sendcmd (int op);
3150 +int __init spiflash_init (void);
3151 +void __exit spiflash_exit (void);
3152 +static int spiflash_probe (void);
3153 +static int spiflash_erase (struct mtd_info *mtd,struct erase_info *instr);
3154 +static int spiflash_read (struct mtd_info *mtd, loff_t from,size_t len,size_t *retlen,u_char *buf);
3155 +static int spiflash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const u_char *buf);
3157 +/* Flash configuration table */
3158 +struct flashconfig {
3161 + __u32 sector_size;
3162 + __u32 cs_addrmask;
3163 +} flashconfig_tbl[MAX_FLASH] =
3166 + { STM_1MB_BYTE_COUNT, STM_1MB_SECTOR_COUNT, STM_1MB_SECTOR_SIZE, 0x0},
3167 + { STM_2MB_BYTE_COUNT, STM_2MB_SECTOR_COUNT, STM_2MB_SECTOR_SIZE, 0x0},
3168 + { STM_4MB_BYTE_COUNT, STM_4MB_SECTOR_COUNT, STM_4MB_SECTOR_SIZE, 0x0}
3171 +/* Mapping of generic opcodes to STM serial flash opcodes */
3176 +} stm_opcodes[] = {
3177 + {STM_OP_WR_ENABLE, 1, 0},
3178 + {STM_OP_WR_DISABLE, 1, 0},
3179 + {STM_OP_RD_STATUS, 1, 1},
3180 + {STM_OP_WR_STATUS, 1, 0},
3181 + {STM_OP_RD_DATA, 4, 4},
3182 + {STM_OP_FAST_RD_DATA, 1, 0},
3183 + {STM_OP_PAGE_PGRM, 8, 0},
3184 + {STM_OP_SECTOR_ERASE, 4, 0},
3185 + {STM_OP_BULK_ERASE, 1, 0},
3186 + {STM_OP_DEEP_PWRDOWN, 1, 0},
3187 + {STM_OP_RD_SIG, 4, 1}
3190 +/* Driver private data structure */
3191 +struct spiflash_data {
3192 + struct mtd_info *mtd;
3193 + struct mtd_partition *parsed_parts; /* parsed partitions */
3194 + void *spiflash_readaddr; /* memory mapped data for read */
3195 + void *spiflash_mmraddr; /* memory mapped register space */
3198 +static struct spiflash_data *spidata;
3200 +extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);
3202 +/***************************************************************************************************/
3205 +spiflash_regread32(int reg)
3207 + volatile __u32 *data = (__u32 *)(spidata->spiflash_mmraddr + reg);
3213 +spiflash_regwrite32(int reg, __u32 data)
3215 + volatile __u32 *addr = (__u32 *)(spidata->spiflash_mmraddr + reg);
3222 +spiflash_sendcmd (int op)
3226 + struct opcodes *ptr_opcode;
3228 + ptr_opcode = &stm_opcodes[op];
3231 + reg = spiflash_regread32(SPI_FLASH_CTL);
3232 + } while (reg & SPI_CTL_BUSY);
3234 + spiflash_regwrite32(SPI_FLASH_OPCODE, ptr_opcode->code);
3236 + reg = (reg & ~SPI_CTL_TX_RX_CNT_MASK) | ptr_opcode->tx_cnt |
3237 + (ptr_opcode->rx_cnt << 4) | SPI_CTL_START;
3239 + spiflash_regwrite32(SPI_FLASH_CTL, reg);
3241 + if (ptr_opcode->rx_cnt > 0) {
3243 + reg = spiflash_regread32(SPI_FLASH_CTL);
3244 + } while (reg & SPI_CTL_BUSY);
3246 + reg = (__u32) spiflash_regread32(SPI_FLASH_DATA);
3248 + switch (ptr_opcode->rx_cnt) {
3250 + mask = 0x000000ff;
3253 + mask = 0x0000ffff;
3256 + mask = 0x00ffffff;
3259 + mask = 0xffffffff;
3272 +/* Probe SPI flash device
3273 + * Function returns 0 for failure.
3274 + * and flashconfig_tbl array index for success.
3277 +spiflash_probe (void)
3282 + /* Read the signature on the flash device */
3283 + sig = spiflash_sendcmd(SPI_RD_SIG);
3286 + case STM_8MBIT_SIGNATURE:
3287 + flash_size = FLASH_1MB;
3289 + case STM_16MBIT_SIGNATURE:
3290 + flash_size = FLASH_2MB;
3292 + case STM_32MBIT_SIGNATURE:
3293 + flash_size = FLASH_4MB;
3296 + printk (KERN_WARNING "%s: Read of flash device signature failed!\n", module_name);
3300 + return (flash_size);
3305 +spiflash_erase (struct mtd_info *mtd,struct erase_info *instr)
3307 + struct opcodes *ptr_opcode;
3309 + int finished = FALSE;
3311 +#ifdef SPIFLASH_DEBUG
3312 + printk (KERN_DEBUG "%s(addr = 0x%.8x, len = %d)\n",__FUNCTION__,instr->addr,instr->len);
3315 + /* sanity checks */
3316 + if (instr->addr + instr->len > mtd->size) return (-EINVAL);
3318 + ptr_opcode = &stm_opcodes[SPI_SECTOR_ERASE];
3320 + temp = ((__u32)instr->addr << 8) | (__u32)(ptr_opcode->code);
3321 + spiflash_sendcmd(SPI_WRITE_ENABLE);
3323 + reg = spiflash_regread32(SPI_FLASH_CTL);
3324 + } while (reg & SPI_CTL_BUSY);
3326 + spiflash_regwrite32(SPI_FLASH_OPCODE, temp);
3328 + reg = (reg & ~SPI_CTL_TX_RX_CNT_MASK) | ptr_opcode->tx_cnt | SPI_CTL_START;
3329 + spiflash_regwrite32(SPI_FLASH_CTL, reg);
3332 + reg = spiflash_sendcmd(SPI_RD_STATUS);
3333 + if (!(reg & SPI_STATUS_WIP)) {
3336 + } while (!finished);
3338 + instr->state = MTD_ERASE_DONE;
3339 + if (instr->callback) instr->callback (instr);
3341 +#ifdef SPIFLASH_DEBUG
3342 + printk (KERN_DEBUG "%s return\n",__FUNCTION__);
3348 +spiflash_read (struct mtd_info *mtd, loff_t from,size_t len,size_t *retlen,u_char *buf)
3350 + u_char *read_addr;
3352 +#ifdef SPIFLASH_DEBUG
3353 + printk (KERN_DEBUG "%s(from = 0x%.8x, len = %d)\n",__FUNCTION__,(__u32) from,(int)len);
3356 + /* sanity checks */
3357 + if (!len) return (0);
3358 + if (from + len > mtd->size) return (-EINVAL);
3361 + /* we always read len bytes */
3364 + read_addr = (u_char *)(spidata->spiflash_readaddr + from);
3365 + memcpy(buf, read_addr, len);
3371 +spiflash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const u_char *buf)
3373 + int done = FALSE, page_offset, bytes_left, finished;
3374 + __u32 xact_len, spi_data = 0, opcode, reg;
3376 +#ifdef SPIFLASH_DEBUG
3377 + printk (KERN_DEBUG "%s(to = 0x%.8x, len = %d)\n",__FUNCTION__,(__u32) to,len);
3382 + /* sanity checks */
3383 + if (!len) return (0);
3384 + if (to + len > mtd->size) return (-EINVAL);
3386 + opcode = stm_opcodes[SPI_PAGE_PROGRAM].code;
3389 + while (done == FALSE) {
3390 + xact_len = MIN(bytes_left, sizeof(__u32));
3392 + /* 32-bit writes cannot span across a page boundary
3393 + * (256 bytes). This types of writes require two page
3394 + * program operations to handle it correctly. The STM part
3395 + * will write the overflow data to the beginning of the
3396 + * current page as opposed to the subsequent page.
3398 + page_offset = (to & (STM_PAGE_SIZE - 1)) + xact_len;
3400 + if (page_offset > STM_PAGE_SIZE) {
3401 + xact_len -= (page_offset - STM_PAGE_SIZE);
3404 + spiflash_sendcmd(SPI_WRITE_ENABLE);
3407 + reg = spiflash_regread32(SPI_FLASH_CTL);
3408 + } while (reg & SPI_CTL_BUSY);
3410 + switch (xact_len) {
3412 + (__u8)spi_data = *buf;
3415 + spi_data = (buf[1] << 8) | buf[0];
3418 + spi_data = (buf[2] << 16) | (buf[1] << 8) | buf[0];
3421 + spi_data = (buf[3] << 24) | (buf[2] << 16) |
3422 + (buf[1] << 8) | buf[0];
3425 + printk("spiflash_write: default case\n");
3429 + spiflash_regwrite32(SPI_FLASH_DATA, spi_data);
3430 + opcode = (opcode & SPI_OPCODE_MASK) | ((__u32)to << 8);
3431 + spiflash_regwrite32(SPI_FLASH_OPCODE, opcode);
3433 + reg = (reg & ~SPI_CTL_TX_RX_CNT_MASK) | (xact_len + 4) | SPI_CTL_START;
3434 + spiflash_regwrite32(SPI_FLASH_CTL, reg);
3439 + reg = spiflash_sendcmd(SPI_RD_STATUS);
3440 + if (!(reg & SPI_STATUS_WIP)) {
3443 + } while (!finished);
3445 + bytes_left -= xact_len;
3449 + *retlen += xact_len;
3451 + if (bytes_left == 0) {
3461 +spiflash_init (void)
3464 + int index, num_parts;
3465 + struct mtd_info *mtd;
3466 + struct mtd_partition *mtd_parts;
3468 + spidata = kmalloc(sizeof(struct spiflash_data), GFP_KERNEL);
3472 + spidata->spiflash_mmraddr = ioremap_nocache(SPI_FLASH_MMR, SPI_FLASH_MMR_SIZE);
3473 + if (!spidata->spiflash_mmraddr) {
3474 + printk (KERN_WARNING "%s: Failed to map flash device\n", module_name);
3479 + mtd = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
3485 + memset (mtd,0,sizeof (*mtd));
3487 + printk ("MTD driver for SPI flash.\n");
3488 + printk ("%s: Probing for Serial flash ...\n", module_name);
3489 + if (!(index = spiflash_probe ())) {
3490 + printk (KERN_WARNING "%s: Found no serial flash device\n", module_name);
3495 + printk ("%s: Found SPI serial Flash.\n", module_name);
3496 + printk ("%d: size\n", flashconfig_tbl[index].byte_cnt);
3498 + spidata->spiflash_readaddr = ioremap_nocache(SPI_FLASH_READ, flashconfig_tbl[index].byte_cnt);
3499 + if (!spidata->spiflash_readaddr) {
3500 + printk (KERN_WARNING "%s: Failed to map flash device\n", module_name);
3506 + mtd->name = module_name;
3507 + mtd->type = MTD_NORFLASH;
3508 + mtd->flags = (MTD_CAP_NORFLASH|MTD_WRITEABLE);
3509 + mtd->size = flashconfig_tbl[index].byte_cnt;
3510 + mtd->erasesize = flashconfig_tbl[index].sector_size;
3511 + mtd->numeraseregions = 0;
3512 + mtd->eraseregions = NULL;
3513 + mtd->module = THIS_MODULE;
3514 + mtd->erase = spiflash_erase;
3515 + mtd->read = spiflash_read;
3516 + mtd->write = spiflash_write;
3518 +#ifdef SPIFLASH_DEBUG
3519 + printk (KERN_DEBUG
3520 + "mtd->name = %s\n"
3521 + "mtd->size = 0x%.8x (%uM)\n"
3522 + "mtd->erasesize = 0x%.8x (%uK)\n"
3523 + "mtd->numeraseregions = %d\n",
3525 + mtd->size, mtd->size / (1024*1024),
3526 + mtd->erasesize, mtd->erasesize / 1024,
3527 + mtd->numeraseregions);
3529 + if (mtd->numeraseregions) {
3530 + for (result = 0; result < mtd->numeraseregions; result++) {
3531 + printk (KERN_DEBUG
3533 + "mtd->eraseregions[%d].offset = 0x%.8x\n"
3534 + "mtd->eraseregions[%d].erasesize = 0x%.8x (%uK)\n"
3535 + "mtd->eraseregions[%d].numblocks = %d\n",
3536 + result,mtd->eraseregions[result].offset,
3537 + result,mtd->eraseregions[result].erasesize,mtd->eraseregions[result].erasesize / 1024,
3538 + result,mtd->eraseregions[result].numblocks);
3543 +#ifndef CONFIG_BLK_DEV_INITRD
3544 + /* parse redboot partitions */
3545 + num_parts = parse_redboot_partitions(mtd, &spidata->parsed_parts);
3547 +#ifdef SPIFLASH_DEBUG
3548 + printk (KERN_DEBUG "Found %d redboot partitions\n", num_parts);
3552 + result = add_mtd_partitions(mtd, spidata->parsed_parts, num_parts);
3553 + /* Find root partition */
3554 + mtd_parts = spidata->parsed_parts;
3555 + for (i=0; i < num_parts; i++) {
3556 + if (!strcmp(mtd_parts[i].name, ROOTFS_NAME)) {
3557 + /* Create root device */
3558 + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, i);
3563 +#ifdef SPIFLASH_DEBUG
3564 + printk (KERN_DEBUG "Did not find any redboot partitions\n");
3572 + spidata->mtd = mtd;
3578 +spiflash_exit (void)
3580 + if (spidata && spidata->parsed_parts) {
3581 + del_mtd_partitions (spidata->mtd);
3582 + kfree(spidata->mtd);
3587 +module_init (spiflash_init);
3588 +module_exit (spiflash_exit);
3590 +MODULE_LICENSE("GPL");
3591 +MODULE_AUTHOR("Atheros Communications Inc");
3592 +MODULE_DESCRIPTION("MTD driver for SPI Flash on Atheros SOC");
3594 diff -urN linux-mips/drivers/mtd/devices/spiflash.h mips-linux-2.4.25/drivers/mtd/devices/spiflash.h
3595 --- linux-mips/drivers/mtd/devices/spiflash.h 1970-01-01 01:00:00.000000000 +0100
3596 +++ mips-linux-2.4.25/drivers/mtd/devices/spiflash.h 2005-12-30 17:27:21.652123784 +0000
3599 + * SPI Flash Memory support header file.
3601 + * $Id: //depot/sw/releases/linuxsrc/src/kernels/mips-linux-2.4.25/drivers/mtd/devices/spiflash.h#3 $
3604 + * Copyright (c) 2005, Atheros Communications Inc.
3606 + * This code is free software; you can redistribute it and/or modify
3607 + * it under the terms of the GNU General Public License version 2 as
3608 + * published by the Free Software Foundation.
3611 +#define FLASH_1MB 1
3612 +#define FLASH_2MB 2
3613 +#define FLASH_4MB 3
3614 +#define MAX_FLASH 4
3616 +#define STM_PAGE_SIZE 256
3618 +#define STM_8MBIT_SIGNATURE 0x13
3619 +#define STM_M25P80_BYTE_COUNT 1048576
3620 +#define STM_M25P80_SECTOR_COUNT 16
3621 +#define STM_M25P80_SECTOR_SIZE 0x10000
3623 +#define STM_16MBIT_SIGNATURE 0x14
3624 +#define STM_M25P16_BYTE_COUNT 2097152
3625 +#define STM_M25P16_SECTOR_COUNT 32
3626 +#define STM_M25P16_SECTOR_SIZE 0x10000
3628 +#define STM_32MBIT_SIGNATURE 0x15
3629 +#define STM_M25P32_BYTE_COUNT 4194304
3630 +#define STM_M25P32_SECTOR_COUNT 64
3631 +#define STM_M25P32_SECTOR_SIZE 0x10000
3633 +#define STM_1MB_BYTE_COUNT STM_M25P80_BYTE_COUNT
3634 +#define STM_1MB_SECTOR_COUNT STM_M25P80_SECTOR_COUNT
3635 +#define STM_1MB_SECTOR_SIZE STM_M25P80_SECTOR_SIZE
3636 +#define STM_2MB_BYTE_COUNT STM_M25P16_BYTE_COUNT
3637 +#define STM_2MB_SECTOR_COUNT STM_M25P16_SECTOR_COUNT
3638 +#define STM_2MB_SECTOR_SIZE STM_M25P16_SECTOR_SIZE
3639 +#define STM_4MB_BYTE_COUNT STM_M25P32_BYTE_COUNT
3640 +#define STM_4MB_SECTOR_COUNT STM_M25P32_SECTOR_COUNT
3641 +#define STM_4MB_SECTOR_SIZE STM_M25P32_SECTOR_SIZE
3643 +#define SPI_WRITE_ENABLE 0
3644 +#define SPI_WRITE_DISABLE 1
3645 +#define SPI_RD_STATUS 2
3646 +#define SPI_WR_STATUS 3
3647 +#define SPI_RD_DATA 4
3648 +#define SPI_FAST_RD_DATA 5
3649 +#define SPI_PAGE_PROGRAM 6
3650 +#define SPI_SECTOR_ERASE 7
3651 +#define SPI_BULK_ERASE 8
3652 +#define SPI_DEEP_PWRDOWN 9
3653 +#define SPI_RD_SIG 10
3654 +#define SPI_MAX_OPCODES 11
3656 +#define SFI_WRITE_BUFFER_SIZE 4
3657 +#define SFI_FLASH_ADDR_MASK 0x00ffffff
3660 + * ST Microelectronics Opcodes for Serial Flash
3663 +#define STM_OP_WR_ENABLE 0x06 /* Write Enable */
3664 +#define STM_OP_WR_DISABLE 0x04 /* Write Disable */
3665 +#define STM_OP_RD_STATUS 0x05 /* Read Status */
3666 +#define STM_OP_WR_STATUS 0x01 /* Write Status */
3667 +#define STM_OP_RD_DATA 0x03 /* Read Data */
3668 +#define STM_OP_FAST_RD_DATA 0x0b /* Fast Read Data */
3669 +#define STM_OP_PAGE_PGRM 0x02 /* Page Program */
3670 +#define STM_OP_SECTOR_ERASE 0xd8 /* Sector Erase */
3671 +#define STM_OP_BULK_ERASE 0xc7 /* Bulk Erase */
3672 +#define STM_OP_DEEP_PWRDOWN 0xb9 /* Deep Power-Down Mode */
3673 +#define STM_OP_RD_SIG 0xab /* Read Electronic Signature */
3675 +#define STM_STATUS_WIP 0x01 /* Write-In-Progress */
3676 +#define STM_STATUS_WEL 0x02 /* Write Enable Latch */
3677 +#define STM_STATUS_BP0 0x04 /* Block Protect 0 */
3678 +#define STM_STATUS_BP1 0x08 /* Block Protect 1 */
3679 +#define STM_STATUS_BP2 0x10 /* Block Protect 2 */
3680 +#define STM_STATUS_SRWD 0x80 /* Status Register Write Disable */
3683 + * SPI Flash Interface Registers
3685 +#define AR531XPLUS_SPI_READ 0x1fc00000
3686 +#define AR531XPLUS_SPI_MMR 0x11300000
3687 +#define AR531XPLUS_SPI_MMR_SIZE 12
3689 +#define AR531XPLUS_SPI_CTL 0x00
3690 +#define AR531XPLUS_SPI_OPCODE 0x04
3691 +#define AR531XPLUS_SPI_DATA 0x08
3693 +#define SPI_FLASH_READ AR531XPLUS_SPI_READ
3694 +#define SPI_FLASH_MMR AR531XPLUS_SPI_MMR
3695 +#define SPI_FLASH_MMR_SIZE AR531XPLUS_SPI_MMR_SIZE
3696 +#define SPI_FLASH_CTL AR531XPLUS_SPI_CTL
3697 +#define SPI_FLASH_OPCODE AR531XPLUS_SPI_OPCODE
3698 +#define SPI_FLASH_DATA AR531XPLUS_SPI_DATA
3700 +#define SPI_CTL_START 0x00000100
3701 +#define SPI_CTL_BUSY 0x00010000
3702 +#define SPI_CTL_TXCNT_MASK 0x0000000f
3703 +#define SPI_CTL_RXCNT_MASK 0x000000f0
3704 +#define SPI_CTL_TX_RX_CNT_MASK 0x000000ff
3705 +#define SPI_CTL_SIZE_MASK 0x00060000
3707 +#define SPI_CTL_CLK_SEL_MASK 0x03000000
3708 +#define SPI_OPCODE_MASK 0x000000ff
3710 +#define SPI_STATUS_WIP STM_STATUS_WIP
3711 diff -urN linux-mips/drivers/mtd/maps/Config.in mips-linux-2.4.25/drivers/mtd/maps/Config.in
3712 --- linux-mips/drivers/mtd/maps/Config.in 2005-12-24 15:11:25.158488072 +0000
3713 +++ mips-linux-2.4.25/drivers/mtd/maps/Config.in 2005-12-30 17:27:21.660122568 +0000
3715 dep_tristate ' CFI Flash device in physical memory map' CONFIG_MTD_PHYSMAP $CONFIG_MTD_GEN_PROBE
3716 if [ "$CONFIG_MTD_PHYSMAP" = "y" -o "$CONFIG_MTD_PHYSMAP" = "m" ]; then
3717 hex ' Physical start address of flash mapping' CONFIG_MTD_PHYSMAP_START 0x8000000
3718 - hex ' Physical length of flash mapping' CONFIG_MTD_PHYSMAP_LEN 0x4000000
3719 + if [ "$CONFIG_FLASH_2MB" = "y" ]; then
3720 + define_hex CONFIG_MTD_PHYSMAP_LEN 200000
3722 + if [ "$CONFIG_FLASH_4MB" = "y" ]; then
3723 + define_hex CONFIG_MTD_PHYSMAP_LEN 400000
3726 +# hex ' Physical length of flash mapping' CONFIG_MTD_PHYSMAP_LEN 0x4000000
3727 int ' Bus width in octets' CONFIG_MTD_PHYSMAP_BUSWIDTH 2
3730 diff -urN linux-mips/drivers/mtd/maps/physmap.c mips-linux-2.4.25/drivers/mtd/maps/physmap.c
3731 --- linux-mips/drivers/mtd/maps/physmap.c 2005-12-24 15:11:25.217479104 +0000
3732 +++ mips-linux-2.4.25/drivers/mtd/maps/physmap.c 2005-12-30 17:27:22.044064200 +0000
3736 #ifdef CONFIG_MTD_PARTITIONS
3737 -#ifdef CONFIG_MTD_CMDLINE_PARTS
3738 +#if defined(CONFIG_MTD_CMDLINE_PARTS) || defined(CONFIG_MTD_REDBOOT_PARTS)
3739 static struct mtd_partition *mtd_parts = 0;
3740 static int mtd_parts_nb = 0;
3742 static struct mtd_partition physmap_partitions[] = {
3743 /* Put your own partition definitions here */
3746 +#ifdef CONFIG_FLASH_2MB
3748 + offset: 0x000f0000,
3750 +#ifdef CONFIG_FLASH_4MB
3752 + offset: 0x00100000,
3755 + /* Allow file system to be mounted for writing */
3760 @@ -138,6 +151,22 @@
3762 add_mtd_device(mymtd);
3763 #ifdef CONFIG_MTD_PARTITIONS
3764 +#ifdef CONFIG_MTD_REDBOOT_PARTS
3766 + extern int parse_redboot_partitions(struct mtd_info *master,
3767 + struct mtd_partition **pparts);
3769 + struct mtd_partition *rb_parts = 0;
3770 + int rb_parts_nb = 0;
3772 + rb_parts_nb = parse_redboot_partitions(mymtd, &rb_parts);
3773 + if (rb_parts_nb > 0) {
3774 + printk(KERN_NOTICE
3775 + "Using redboot flash partitioning");
3776 + add_mtd_partitions (mymtd, rb_parts, rb_parts_nb);
3780 #ifdef CONFIG_MTD_CMDLINE_PARTS
3781 mtd_parts_nb = parse_cmdline_partitions(mymtd, &mtd_parts,
3784 "Using command line partition definition\n");
3785 add_mtd_partitions (mymtd, mtd_parts, mtd_parts_nb);
3789 +#if !defined(CONFIG_MTD_CMDLINE_PARTS) && !defined(CONFIG_MTD_REDBOOT_PARTS)
3790 if (NUM_PARTITIONS != 0)
3793 diff -urN linux-mips/drivers/mtd/redboot.c mips-linux-2.4.25/drivers/mtd/redboot.c
3794 --- linux-mips/drivers/mtd/redboot.c 2005-12-24 15:11:25.249474240 +0000
3795 +++ mips-linux-2.4.25/drivers/mtd/redboot.c 2005-12-30 17:27:22.517992152 +0000
3799 /* Read the start of the last erase block */
3800 - ret = master->read(master, master->size - master->erasesize,
3802 + u_int32_t part_table_start = master->size - master->erasesize;
3803 +#if defined(CONFIG_MTD_END_RESERVED)
3804 + part_table_start -= CONFIG_MTD_END_RESERVED;
3806 + ret = master->read(master, part_table_start,
3807 PAGE_SIZE, &retlen, (void *)buf);
3812 diff -urN linux-mips/drivers/net/Config.in mips-linux-2.4.25/drivers/net/Config.in
3813 --- linux-mips/drivers/net/Config.in 2005-12-24 15:11:25.725401888 +0000
3814 +++ mips-linux-2.4.25/drivers/net/Config.in 2005-12-30 17:27:22.684966768 +0000
3816 comment 'Ethernet (10 or 100Mbit)'
3817 bool 'Ethernet (10 or 100Mbit)' CONFIG_NET_ETHERNET
3818 if [ "$CONFIG_NET_ETHERNET" = "y" ]; then
3819 + define_bool CONFIG_VENETDEV n
3820 + tristate ' BUILT-IN ATHEROS ENET DRIVER' CONFIG_NET_ATHEROS_ETHER
3821 + if [ "$CONFIG_AP38" = "y" -o "$CONFIG_AP48" = "y" ]; then
3822 + define_bool CONFIG_KENDIN_ENET_PHY y
3823 + elif [ "$CONFIG_AP30ASK" = "y" ]; then
3824 + define_bool CONFIG_KENDIN_KS8995XA_ENET_PHY y
3825 + bool 'Multiple Ethernet address hack ' CONFIG_ASK_MULT_MAC_HACK
3826 + elif [ "$CONFIG_AP51" = "y" ]; then
3827 + define_bool CONFIG_ICPLUS_ENET_PHY y
3829 + define_bool CONFIG_MARVELL_ENET_PHY y
3831 if [ "$CONFIG_ARM" = "y" ]; then
3832 dep_bool ' ARM EBSA110 AM79C961A support' CONFIG_ARM_AM79C961A $CONFIG_ARCH_EBSA110
3833 tristate ' Cirrus Logic CS8900A support' CONFIG_ARM_CIRRUS
3834 diff -urN linux-mips/drivers/net/Makefile mips-linux-2.4.25/drivers/net/Makefile
3835 --- linux-mips/drivers/net/Makefile 2005-12-24 15:11:25.726401736 +0000
3836 +++ mips-linux-2.4.25/drivers/net/Makefile 2005-12-30 17:27:22.709962968 +0000
3838 obj-y += e1000/e1000.o
3841 +ifeq ($(CONFIG_NET_ATHEROS_ETHER),y)
3842 + obj-y += ath/ae531x.o
3845 ifeq ($(CONFIG_BONDING),y)
3846 obj-y += bonding/bonding.o
3849 subdir-$(CONFIG_SKFP) += skfp
3850 subdir-$(CONFIG_E100) += e100
3851 subdir-$(CONFIG_E1000) += e1000
3852 +subdir-$(CONFIG_NET_ATHEROS_ETHER) += ath
3853 subdir-$(CONFIG_BONDING) += bonding
3855 +ifeq ($(CONFIG_ATHAP33),y)
3856 +subdir-$(CONFIG_ATHAP33) += athap33
3860 # link order important here
3862 @@ -242,6 +251,10 @@
3863 obj-$(CONFIG_R8169) += r8169.o
3864 obj-$(CONFIG_AMD8111_ETH) += amd8111e.o mii.o
3866 +ifeq ($(CONFIG_ATHAP33),y)
3867 +obj-$(CONFIG_ATHAP33) += athap33/ath_ap_mips.o
3870 # non-drivers/net drivers who want mii lib
3871 obj-$(CONFIG_PCMCIA_SMC91C92) += mii.o
3872 obj-$(CONFIG_USB_USBNET) += mii.o
3873 diff -urN linux-mips/fs/jffs2/nodelist.h mips-linux-2.4.25/fs/jffs2/nodelist.h
3874 --- linux-mips/fs/jffs2/nodelist.h 2005-12-24 15:11:50.407649616 +0000
3875 +++ mips-linux-2.4.25/fs/jffs2/nodelist.h 2005-12-30 17:27:51.289618200 +0000
3877 * provisions above, a recipient may use your version of this file
3878 * under either the RHEPL or the GPL.
3880 - * $Id: nodelist.h,v 1.46.2.5 2003/11/02 13:54:20 dwmw2 Exp $
3881 + * $Id: //depot/sw/releases/linuxsrc/src/kernels/mips-linux-2.4.25/fs/jffs2/nodelist.h#3 $
3886 #define ALLOC_DELETION 1 /* Deletion node. Best to allow it */
3887 #define ALLOC_GC 2 /* Space requested for GC. Give it or die */
3889 -#define JFFS2_RESERVED_BLOCKS_BASE 3 /* Number of free blocks there must be before we... */
3890 -#define JFFS2_RESERVED_BLOCKS_WRITE (JFFS2_RESERVED_BLOCKS_BASE + 2) /* ... allow a normal filesystem write */
3891 +#define JFFS2_RESERVED_BLOCKS_BASE 2 /* Number of free blocks there must be before we... */
3892 +#define JFFS2_RESERVED_BLOCKS_WRITE (JFFS2_RESERVED_BLOCKS_BASE + 1) /* ... allow a normal filesystem write */
3893 #define JFFS2_RESERVED_BLOCKS_DELETION (JFFS2_RESERVED_BLOCKS_BASE + 1) /* ... allow a normal filesystem deletion */
3894 #define JFFS2_RESERVED_BLOCKS_GCTRIGGER (JFFS2_RESERVED_BLOCKS_BASE + 3) /* ... wake up the GC thread */
3895 #define JFFS2_RESERVED_BLOCKS_GCBAD (JFFS2_RESERVED_BLOCKS_BASE + 1) /* ... pick a block from the bad_list to GC */
3896 diff -urN linux-mips/fs/partitions/Config.in mips-linux-2.4.25/fs/partitions/Config.in
3897 --- linux-mips/fs/partitions/Config.in 2005-12-24 15:11:52.366351848 +0000
3898 +++ mips-linux-2.4.25/fs/partitions/Config.in 2005-12-30 17:27:52.279467720 +0000
3901 if [ "$CONFIG_AMIGA" != "y" -a "$CONFIG_ATARI" != "y" -a \
3902 "$CONFIG_MAC" != "y" -a "$CONFIG_SGI_IP22" != "y" -a \
3903 - "$CONFIG_SGI_IP27" != "y" ]; then
3904 + "$CONFIG_SGI_IP27" != "y" -a "$CONFIG_AR531X" != "y" ]; then
3905 define_bool CONFIG_MSDOS_PARTITION y
3907 if [ "$CONFIG_AMIGA" = "y" -o "$CONFIG_AFFS_FS" = "y" ]; then
3908 diff -urN linux-mips/include/asm-mips/atheros/ar531xbsp.h mips-linux-2.4.25/include/asm-mips/atheros/ar531xbsp.h
3909 --- linux-mips/include/asm-mips/atheros/ar531xbsp.h 1970-01-01 01:00:00.000000000 +0100
3910 +++ mips-linux-2.4.25/include/asm-mips/atheros/ar531xbsp.h 2005-12-30 17:28:01.523062480 +0000
3912 +#ifndef __ASM_ATHEROS_BSP_SUPPORT_H
3913 +#define __ASM_ATHEROS_BSP_SUPPORT_H
3915 + * These are definitions and functions provided by the bsp to support the
3916 + * AR5312 WiSoC running LSDK. For different BSP implementations, different
3917 + * BSP functions will be needed.
3920 +extern unsigned int ar531x_sys_frequency(void);
3921 +extern const char* get_system_type(void);
3924 +extern void kgdbInit(void);
3925 +extern int kgdbEnabled(void);
3928 +#endif /* __ASM_ATHEROS_BSP_SUPPORT_H */
3929 diff -urN linux-mips/include/asm-mips/bootinfo.h mips-linux-2.4.25/include/asm-mips/bootinfo.h
3930 --- linux-mips/include/asm-mips/bootinfo.h 2005-12-24 15:12:00.645093288 +0000
3931 +++ mips-linux-2.4.25/include/asm-mips/bootinfo.h 2005-12-30 17:28:01.534060808 +0000
3933 #define MACH_GROUP_HP_LJ 20 /* Hewlett Packard LaserJet */
3934 #define MACH_GROUP_LASAT 21
3935 #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
3936 +#define MACH_GROUP_AR531X 23 /* Atheros AR531X */
3939 * Valid machtype values for group unknown (low order halfword of mips_machtype)
3940 @@ -198,6 +199,17 @@
3942 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
3945 + * Valid machtype for group MACH_GROUP_AR5312
3947 +#define MACH_ATHEROS_UNUSED 0
3948 +#define MACH_ATHEROS_AP30 1 /* AP30 */
3949 +#define MACH_ATHEROS_AP33 2 /* AP33 */
3950 +#define MACH_ATHEROS_AP38 3 /* AP38 */
3951 +#define MACH_ATHEROS_AP43 4 /* AP43 */
3952 +#define MACH_ATHEROS_AP48 5 /* AP48 */
3953 +#define MACH_ATHEROS_PB32 6 /* PB32 */
3955 #define CL_SIZE (256)
3957 const char *get_system_type(void);
3958 diff -urN linux-mips/include/asm-mips/page.h mips-linux-2.4.25/include/asm-mips/page.h
3959 --- linux-mips/include/asm-mips/page.h 2005-12-24 15:12:01.097024584 +0000
3960 +++ mips-linux-2.4.25/include/asm-mips/page.h 2005-12-30 17:28:01.898005480 +0000
3962 #include <linux/config.h>
3963 #include <asm/break.h>
3968 * PAGE_SHIFT determines the page size
3970 #define PAGE_SIZE (1L << PAGE_SHIFT)
3971 #define PAGE_MASK (~(PAGE_SIZE-1))
3974 #ifndef __ASSEMBLY__
3976 #include <asm/cacheflush.h>
3977 diff -urN linux-mips/include/asm-mips/serial.h mips-linux-2.4.25/include/asm-mips/serial.h
3978 --- linux-mips/include/asm-mips/serial.h 2005-12-24 15:12:01.130019568 +0000
3979 +++ mips-linux-2.4.25/include/asm-mips/serial.h 2005-12-30 17:28:02.143968088 +0000
3980 @@ -410,6 +410,11 @@
3981 #define DDB5477_SERIAL_PORT_DEFNS
3984 +#if defined(CONFIG_AR531X)
3985 +#undef RS_TABLE_SIZE
3986 +#define RS_TABLE_SIZE 1
3989 #define SERIAL_PORT_DFNS \
3990 ATLAS_SERIAL_PORT_DEFNS \
3991 AU1000_SERIAL_PORT_DEFNS \
3992 diff -urN linux-mips/kernel/printk.c mips-linux-2.4.25/kernel/printk.c
3993 --- linux-mips/kernel/printk.c 2005-12-24 15:12:09.361768152 +0000
3994 +++ mips-linux-2.4.25/kernel/printk.c 2005-12-30 17:28:11.943478336 +0000
3995 @@ -383,6 +383,18 @@
3996 _call_console_drivers(start_print, end, msg_level);
3999 +#if CONFIG_EARLY_PRINTK_HACK
4000 +void putDebugChar(char byte);
4001 +static void emit_log_char(char c)
4004 + putDebugChar('\r');
4005 + putDebugChar('\n');
4011 static void emit_log_char(char c)
4013 LOG_BUF(log_end) = c;
4015 if (logged_chars < LOG_BUF_LEN)
4021 * This is printk. It can be called from any context. We want it to work.
4023 tty->driver.write(tty, 0, msg, strlen(msg));
4027 diff -urN linux-mips-orig/drivers/net/ath/ae531x.h linux-mips-new/drivers/net/ath/ae531x.h
4028 --- linux-mips-orig/drivers/net/ath/ae531x.h 1970-01-01 01:00:00.000000000 +0100
4029 +++ linux-mips-new/drivers/net/ath/ae531x.h 2005-12-31 12:33:57.672538976 +0000
4034 +#include <linux/config.h>
4035 +#include <linux/types.h>
4036 +#include <linux/delay.h>
4037 +#include <linux/netdevice.h>
4038 +#include <linux/etherdevice.h>
4039 +#include <linux/init.h>
4040 +#include <linux/skbuff.h>
4041 +#include <asm/io.h>
4043 +#include "ar531xlnx.h"
4044 +#include "ae531xreg.h"
4045 +#include "ae531xmac.h"
4047 +extern void *ae531x_rxbuf_alloc(ae531x_MAC_t *MACInfo, char **rxBuffp,
4048 + int *rxBuffSizep);
4049 +extern void ae531x_swptr_free(VIRT_ADDR desc);
4050 +extern BOOL ae531x_twisted_enet(void);
4051 +extern void ae531x_MiiWrite(UINT32 phyBase, UINT32 phyAddr, UINT8 reg,
4053 +extern UINT16 ae531x_MiiRead(UINT32 phyBase, UINT32 phyAddr, UINT8 reg);
4054 +extern void ae531x_unitLinkGained(int ethUnit);
4055 +extern void ae531x_unitLinkLost(int ethUnit);
4056 +extern void ae531x_WriteDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 data);
4057 +extern void ae531x_MACReset(ae531x_MAC_t *MACInfo);
4058 +extern void ae531x_DisableComm(ae531x_MAC_t *MACInfo);
4059 +extern void ae531x_FreeQueues(ae531x_MAC_t *MACInfo);
4060 +extern void ae531x_reset(ae531x_MAC_t *MACInfo);
4061 +extern int ae531x_AllocateQueues(ae531x_MAC_t *MACInfo);
4062 +extern void ae531x_EnableComm(ae531x_MAC_t *MACInfo);
4063 +extern void ae531x_DmaIntEnable(ae531x_MAC_t *MACInfo);
4064 +extern void ae531x_DmaIntDisable(ae531x_MAC_t *MACInfo);
4065 +extern void ae531x_DmaReset(ae531x_MAC_t *MACInfo);
4066 +extern void ae531x_BeginResetMode(ae531x_MAC_t *MACInfo);
4067 +extern void ae531x_AckIntr(ae531x_MAC_t *MACInfo, UINT32 data);
4068 +extern void ae531x_SetDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val);
4069 +extern BOOL ae531x_IsInResetMode(ae531x_MAC_t *MACInfo);
4070 +extern UINT32 ae531x_ReadDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg);
4071 +extern void ae531x_ClearDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val);
4073 +#endif /* __AE531X_H */
4074 diff -urN linux-mips-orig/drivers/net/ath/ae531xlnx.c linux-mips-new/drivers/net/ath/ae531xlnx.c
4075 --- linux-mips-orig/drivers/net/ath/ae531xlnx.c 1970-01-01 01:00:00.000000000 +0100
4076 +++ linux-mips-new/drivers/net/ath/ae531xlnx.c 2005-12-31 12:33:57.673538824 +0000
4079 + * This file is subject to the terms and conditions of the GNU General Public
4080 + * License. See the file "COPYING" in the main directory of this archive
4081 + * for more details.
4083 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
4087 + * Ethernet driver for Atheros' ae531x ethernet MAC.
4088 + * This is a fairly generic driver, but it's intended
4089 + * for use in typical Atheros products.
4092 +#include <linux/config.h>
4093 +#include <linux/module.h>
4094 +#include <linux/types.h>
4095 +#include <linux/delay.h>
4096 +#include <linux/netdevice.h>
4097 +#include <linux/etherdevice.h>
4098 +#include <linux/init.h>
4099 +#include <linux/skbuff.h>
4100 +#include <asm/io.h>
4102 +#include "ar531xlnx.h"
4103 +#include "ae531xreg.h"
4104 +#include "ae531xmac.h"
4105 +#include "ae531x.h"
4107 +#ifndef EXPORT_SYMTAB
4108 +#define EXPORT_SYMTAB
4112 +void my_mvPhyShow(int ethUnit);
4115 +static struct ar531x_boarddata *ar531x_boardConfig=NULL;
4117 +static char *radioConfig=NULL;
4119 +#define AE531X_LAN_PORT 0
4120 +#define AE531X_DEV_PER_MAC 1
4123 + * ae531x_MAC_state contains driver-specific linux-specific per-MAC information.
4124 + * The OSinfo member of ae531x_MAC_t points to one of these.
4126 +typedef struct ae531x_MAC_state {
4128 + struct tq_struct restart_task;
4129 + struct net_device_stats stats;
4130 + struct ae531x_dev_sw_state *dev_sw_state[AE531X_DEV_PER_MAC];
4132 + ae531x_MAC_t MACInfo; /* hardware state */
4133 +} ae531x_MAC_state_t;
4136 + * ae531x_dev_sw_state contains driver-specific linux-specific per-device
4137 + * information. The net_device priv member points to one of these, and
4138 + * this structure contains a pointer to the associated MAC information.
4141 +typedef struct ae531x_dev_sw_state {
4142 + int enetUnit; /* system unit number "eth%d" */
4143 + int unit_on_MAC; /* MAC-relative unit number */
4144 + struct net_device *dev;
4145 + ae531x_MAC_state_t *MAC_state; /* underlying MAC hw/sw state */
4146 +} ae531x_dev_sw_state_t;
4149 + * Driver-independent linux-specific per-ethernet device software information.
4151 +static struct net_device *ae531x_MAC_dev[AR531X_NUM_ENET_MAC * AE531X_DEV_PER_MAC];
4153 +/* Driver-dependent per-MAC information */
4154 +static ae531x_MAC_state_t per_MAC_info[AR531X_NUM_ENET_MAC];
4157 + * Receive buffers need enough room to hold the following:
4158 + * 1) a max MTU-sized packet.
4159 + * 2) space for an ethernet header
4160 + * 3) room at the beginning of the receive buffer in order
4161 + * to facilitate cooperating drivers that need to PREpend
4163 + * 4) Depending on configuration, we may need some additional
4164 + * room at the END of the rx buffer for phy-supplied
4165 + * trailers (if any). (c.f. CONFIG_VENETDEV)
4167 + * The DMA engine insists on 32-bit aligned RX buffers.
4168 + * TBDXXX: With current code, the IP stack ends up looking
4169 + * at misaligned headers with word operations. The misaligned
4170 + * reads are software-emulated via handle_adel_int. We'd
4171 + * rather align the buffers on a 16-bit boundary, but the
4172 + * DMA engine doesn't permit it???
4174 +#define ETH_MAX_MTU 1518
4175 +#define AE531X_RX_BUF_SIZE \
4176 + (((RXBUFF_RESERVE + ETH_HLEN + ETH_MAX_MTU + PHY_TRAILER_SIZE) + 3) & ~3)
4178 +/* Forward references to local functions */
4179 +static void ae531x_TxReap(ae531x_MAC_state_t *MAC_state);
4180 +static int ae531x_phy_poll(void *data);
4181 +static int ae531x_MAC_stop(struct net_device *dev);
4182 +static int ae531x_MAC_open(struct net_device *dev);
4184 +/*******************************************************************************
4185 +* ae531x_MAC_poll checks for received packets, and sends data
4189 +ae531x_MAC_poll(struct net_device *dev, int *budget)
4191 + struct sk_buff *skb;
4192 + struct sk_buff *newskb;
4194 + int unused_length;
4197 + ae531x_dev_sw_state_t *dev_sw_state;
4198 + ae531x_MAC_state_t *MAC_state;
4199 + ae531x_MAC_t *MACInfo;
4204 + struct net_device *rxdev;
4208 + static int rxDescCountMax = 0;
4213 + dev_sw_state = (ae531x_dev_sw_state_t *)dev->priv;
4214 + MAC_state = dev_sw_state->MAC_state;
4215 + MACInfo = &MAC_state->MACInfo;
4216 + rx_limit = MAC_state->dev_sw_state[MAC_state->primary_dev]->dev->quota;
4223 + ae531x_AckIntr(MACInfo, DmaIntRxCompleted);
4225 + for(;!early_stop;) {
4226 + rxDesc = MACInfo->rxQueue.curDescAddr;
4227 + cmdsts = AE531X_DESC_STATUS_GET(KSEG1ADDR(rxDesc));
4229 + AE531X_PRINT(AE531X_DEBUG_RX,
4230 + ("examine rxDesc %p with cmdsts=0x%x\n",
4231 + (void *)rxDesc, cmdsts));
4233 + if (cmdsts & DescOwnByDma) {
4234 + /* There's nothing left to process in the RX ring */
4240 + AE531X_CONSUME_DESC((&MACInfo->rxQueue));
4242 + A_DATA_CACHE_INVAL(rxDesc, AE531X_DESC_SIZE);
4244 + /* Process a packet */
4245 + length = AE531X_DESC_STATUS_RX_SIZE(cmdsts) - ETH_CRC_LEN;
4246 + if ( (cmdsts & (DescRxFirst |DescRxLast | DescRxErrors)) ==
4247 + (DescRxFirst | DescRxLast) ) {
4248 + /* Descriptor status indicates "NO errors" */
4249 + skb = AE531X_DESC_SWPTR_GET(rxDesc);
4252 + * Allocate a replacement skb.
4253 + * We want to get another buffer ready for Rx ASAP.
4255 + newskb = (struct sk_buff *)ae531x_rxbuf_alloc(MACInfo, &rxBufp, &unused_length);
4256 + if(newskb == NULL ) {
4258 + * Give this descriptor back to the DMA engine,
4259 + * and drop the received packet.
4261 + MAC_state->stats.rx_dropped++;
4262 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4263 + ("Can't allocate new skb\n"));
4265 + AE531X_DESC_BUFPTR_SET(rxDesc, virt_to_bus(rxBufp));
4266 + AE531X_DESC_SWPTR_SET(rxDesc, newskb);
4269 + AE531X_DESC_STATUS_SET(rxDesc, DescOwnByDma);
4270 + rxDesc = NULL; /* sanity -- cannot use rxDesc now */
4273 + if (newskb == NULL) {
4277 + /* Sync data cache w.r.t. DMA */
4278 + A_DATA_CACHE_INVAL(skb->data, length);
4280 + rxdev = dev_sw_state->dev;
4282 + if (rxdev == NULL) {
4284 + * We received a packet for a virtual enet device
4285 + * that is no longer up. Ignore it.
4291 + /* Advance data pointer to show that there's data here */
4292 + skb_put(skb, length);
4293 + skb->protocol = eth_type_trans(skb, rxdev);
4295 + rxdev->last_rx = jiffies;
4298 + if (rx_limit-- < 0) {
4300 + /* We've done enough for now -- more later */
4301 + AE531X_PRINT(AE531X_DEBUG_RX_STOP,
4302 + ("Enet%d RX early stop. Quota=%d rxDescCount=%d budget=%d\n",
4303 + MACInfo->unit, dev->quota, rxDescCount, *budget));
4307 + /* Send the data up the stack */
4308 + AE531X_PRINT(AE531X_DEBUG_RX,
4309 + ("Send data up stack: skb=%p data=%p length=%d\n",
4310 + (void *)skb, (void *)skb->data, length));
4312 + netif_receive_skb(skb);
4314 + MAC_state->stats.rx_packets++;
4315 + MAC_state->stats.rx_bytes += length;
4318 + /* Descriptor status indicates ERRORS */
4319 + MAC_state->stats.rx_errors++;
4321 + if (cmdsts & (DescRxRunt | DescRxLateColl)) {
4322 + MAC_state->stats.collisions++;
4325 + if (cmdsts & DescRxLengthError) {
4326 + MAC_state->stats.rx_length_errors++;
4329 + if (cmdsts & DescRxCrc) {
4330 + MAC_state->stats.rx_crc_errors++;
4333 + if (cmdsts & DescRxDribbling) {
4334 + MAC_state->stats.rx_frame_errors++;
4337 + AE531X_DESC_STATUS_SET(rxDesc, DescOwnByDma);
4339 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4340 + ("Bad receive. rxDesc=%p cmdsts=0x%8.8x\n",
4341 + (void *)rxDesc, cmdsts));
4344 + } while ((!early_stop) &&
4345 + ae531x_ReadDmaReg(MACInfo, DmaStatus) & DmaIntRxCompleted);
4348 + AE531X_PRINT(AE531X_DEBUG_RX,
4349 + ("rx done (%d)\n", rxDescCount));
4350 + *budget -= rxDescCount;
4352 + if (!early_stop) {
4353 + netif_rx_complete(dev);
4355 + ae531x_SetDmaReg(MACInfo, DmaIntrEnb,
4356 + DmaIeRxCompleted | DmaIeRxNoBuffer);
4357 + ae531x_WriteDmaReg(MACInfo, DmaRxPollDemand, 0);
4360 + retval = early_stop;
4367 + if (rxDescCount > rxDescCountMax) {
4368 + printk("max rx %d\n", rxDescCount);
4369 + rxDescCountMax = rxDescCount;
4376 +/*******************************************************************************
4377 +* ae531x_restart stops all ethernet devices associated with a physical MAC,
4378 +* then shuts down the MAC. Then it re-opens all devices that were in use.
4379 +* TBDXXX: needs testing!
4382 +ae531x_restart(void *data)
4384 + ae531x_MAC_t *MACInfo = (ae531x_MAC_t *)data;
4385 + ae531x_MAC_state_t *MAC_state = (ae531x_MAC_state_t *)MACInfo->OSinfo;
4386 + struct net_device *saved_dev[AE531X_DEV_PER_MAC];
4389 + for (i=0; i<AE531X_DEV_PER_MAC; i++) {
4390 + if ((saved_dev[i] = MAC_state->dev_sw_state[i]->dev) != NULL) {
4391 + ae531x_MAC_stop(saved_dev[i]);
4395 + for (i=0; i<AE531X_DEV_PER_MAC; i++) {
4397 + ae531x_MAC_open(saved_dev[i]);
4401 +/*******************************************************************************
4402 +* ae531x_MAC_intr handle interrupts from an ethernet MAC.
4403 +* It checks MAC status registers, and dispatches as appropriate.
4406 +ae531x_MAC_intr(int cpl, void *dev_id, struct pt_regs *regs)
4408 + ae531x_MAC_state_t *MAC_state;
4409 + ae531x_MAC_t *MACInfo;
4415 + MACInfo = (ae531x_MAC_t *)dev_id;
4416 + MAC_state = (ae531x_MAC_state_t *)MACInfo->OSinfo;
4418 + /* Clear any unhandled intr causes. */
4419 + ae531x_WriteDmaReg(MACInfo, DmaStatus, UnhandledIntrMask);
4421 + regIsr = ae531x_ReadDmaReg(MACInfo, DmaStatus);
4422 + regImr = ae531x_ReadDmaReg(MACInfo, DmaIntrEnb);
4423 + pendIntrs = regIsr & regImr;
4425 + AE531X_PRINT(AE531X_DEBUG_INT,
4426 + ("ethmac%d: intIsr=0x%8.8x intImr=0x%8.8x pendIntrs=0x%8.8x\n",
4427 + MACInfo->unit, regIsr, regImr, pendIntrs ));
4429 + if ((pendIntrs & DmaAllIntCauseMask) == 0)
4432 + if ((pendIntrs & DmaIntRxCompleted) ||
4433 + (pendIntrs & DmaIntRxNoBuffer)) {
4434 + if (netif_rx_schedule_prep(MAC_state->dev_sw_state[MAC_state->primary_dev]->dev)) {
4435 + ae531x_ClearDmaReg(MACInfo,
4437 + DmaIeRxCompleted | DmaIeRxNoBuffer);
4438 + ae531x_AckIntr(MACInfo,
4439 + DmaIntRxCompleted | DmaIntRxNoBuffer);
4440 + (void)ae531x_ReadDmaReg(MACInfo, DmaIntrEnb);
4441 + __netif_rx_schedule(MAC_state->dev_sw_state[MAC_state->primary_dev]->dev);
4444 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4445 + ("%s: Interrupt (0x%8.8x/0x%8.8x) while in poll. regs@%p, pc=%p, ra=%p\n",
4448 + ae531x_ReadDmaReg(MACInfo, DmaIntrEnb),
4450 + (void *)regs->cp0_epc,
4451 + (void *)regs->regs[31]));
4453 + ae531x_AckIntr(MACInfo,
4454 + DmaIntRxCompleted | DmaIntRxNoBuffer);
4459 + (DmaIntTxStopped | DmaIntTxJabber | DmaIntTxUnderflow)) {
4460 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4461 + ("ethmac%d: TX Error Intr (0x%x)\n",
4462 + MACInfo->unit, pendIntrs));
4463 + ae531x_AckIntr(MACInfo,
4464 + (DmaIntTxStopped | DmaIntTxJabber | DmaIntTxUnderflow));
4467 + if (pendIntrs & DmaIntBusError) {
4468 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4469 + ("ethmac%d: DMA Bus Error Intr (0x%x)\n",
4470 + MACInfo->unit, pendIntrs));
4471 + ae531x_AckIntr(MACInfo, DmaIntBusError);
4472 + /* Reset the chip, if it's not already being done */
4473 + if (ae531x_IsInResetMode(MACInfo)) {
4476 + ae531x_BeginResetMode(MACInfo);
4477 + schedule_task(&MAC_state->restart_task);
4480 + if (pendIntrs & DmaIntRxStopped) {
4481 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4482 + ("ethmac%d: RX Stopped Intr (0x%x)\n",
4483 + MACInfo->unit, pendIntrs));
4484 + ae531x_AckIntr(MACInfo, DmaIntRxStopped);
4492 +/*******************************************************************************
4493 +* ae531x_MAC_get_stats returns statistics for a specified device
4495 +static struct net_device_stats*
4496 +ae531x_MAC_get_stats(struct net_device *dev)
4498 + ae531x_dev_sw_state_t *dev_sw_state;
4499 + ae531x_MAC_state_t *MAC_state;
4502 + dev_sw_state = (ae531x_dev_sw_state_t *)dev->priv;
4503 + MAC_state = dev_sw_state->MAC_state;
4506 + return &MAC_state->stats;
4509 +#define AE531X_PHY_POLL_SECONDS 2
4513 +/*******************************************************************************
4514 +* ae531x_getMACInfo returns the MACInfo of the interface given by unit
4516 +ae531x_MAC_t *ae531x_getMAcInfo(int ethUnit)
4519 + for(i=0;i<AR531X_NUM_ENET_MAC;++i) {
4520 + if(per_MAC_info[i].dev_sw_state) {
4521 + for(j=0;j<AE531X_DEV_PER_MAC;++j) {
4522 + if(per_MAC_info[i].dev_sw_state[j]
4523 + && per_MAC_info[i].dev_sw_state[j]->enetUnit == ethUnit)
4524 + return (&(per_MAC_info[i].MACInfo));
4534 +/*******************************************************************************
4535 +* ae531x_phy_poll periodically checks for changes in phy status
4536 +* (e.g. dropped link).
4539 +ae531x_phy_poll(void *data)
4541 + ae531x_dev_sw_state_t *dev_sw_state = (ae531x_dev_sw_state_t *)data;
4542 + ae531x_MAC_t *MACInfo = &dev_sw_state->MAC_state->MACInfo;
4543 + int unit = dev_sw_state->enetUnit;
4545 + while(dev_sw_state->dev!=NULL) {
4546 + if (MACInfo->port_is_up) {
4547 + phyCheckStatusChange(unit);
4550 + set_current_state(TASK_UNINTERRUPTIBLE);
4551 + schedule_timeout(AE531X_PHY_POLL_SECONDS * HZ);
4558 +static char invalid_enet_MAC_addr[] = {0, 0, 0, 0, 0, 0};
4561 + * Fetch a pointer to an ethernet's MAC address
4562 + * in the Board Configuration data (in flash).
4565 +ae531x_enet_mac_address_get(int MACUnit)
4567 + /* XXX: Hack for poorly configured boards.
4568 + * Cannot setup bridging properly (brctl) when both enet
4569 + * interfaces share the same MAC address.
4573 +#ifdef CONFIG_ASK_MULT_MAC_HACK
4574 + static u8 enet0Mac[6] = {0x00, 0x0d, 0x0b, 0x13, 0x6b, 0x16};
4575 + static u8 enet1Mac[6] = {0x00, 0x0d, 0x0b, 0x13, 0x6b, 0x17};
4578 + if (!ar531x_boardConfig)
4579 + return invalid_enet_MAC_addr;
4580 + if (MACUnit == 0) {
4581 +#ifndef CONFIG_ASK_MULT_MAC_HACK
4582 + return ar531x_boardConfig->enet0Mac;
4587 + if (MACUnit == 1) {
4588 +#ifndef CONFIG_ASK_MULT_MAC_HACK
4589 + return ar531x_boardConfig->enet1Mac;
4594 + printk("Invalid ethernet MAC unit number (%d)!\n", MACUnit);
4595 + return invalid_enet_MAC_addr;
4600 +/*******************************************************************************
4601 +* ae531x_MAC_open is the standard Linux open function. It puts
4602 +* hardware into a known good state, allocates queues, starts
4603 +* the phy polling task, and arranges for interrupts to be handled.
4606 +ae531x_MAC_open(struct net_device *dev)
4608 + ae531x_dev_sw_state_t *dev_sw_state;
4609 + ae531x_MAC_state_t *MAC_state;
4610 + ae531x_MAC_t *MACInfo;
4613 + struct tq_struct *restart_task;
4614 + pid_t phy_poll_pid;
4617 + dev_sw_state = (ae531x_dev_sw_state_t *)dev->priv;
4618 + dev_sw_state->dev = dev;
4619 + MAC_state = dev_sw_state->MAC_state;
4620 + MACInfo = &MAC_state->MACInfo;
4622 + restart_task = &MAC_state->restart_task;
4623 + restart_task->routine = ae531x_restart;
4624 + restart_task->data = (void *)MACInfo;
4626 + AE531X_PRINT(AE531X_DEBUG_RESET,
4627 + ("ae531x_MAC_open eth%d ethmac%d macBase=0x%x dmaBase=0x%x irq=0x%x\n",
4628 + dev_sw_state->enetUnit,
4634 + /* Default MAC address */
4635 + MACAddr = ae531x_enet_mac_address_get(MACInfo->unit);
4636 + memcpy(dev->dev_addr, MACAddr, dev->addr_len );
4638 + if (!MACInfo->port_is_up) {
4639 + /* Bring MAC and PHY out of reset */
4640 + ae531x_reset(MACInfo);
4642 + /* Attach interrupt handler */
4643 + rv = request_irq(MAC_state->irq, ae531x_MAC_intr, SA_INTERRUPT,
4644 + "ae531x_MAC_intr", (void *)MACInfo);
4646 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4647 + ("request_irq(0x%x) failed (%d)\n",
4648 + MAC_state->irq, rv));
4649 + goto open_failure;
4652 + /* Initialize PHY */
4653 + AE531X_PRINT(AE531X_DEBUG_RESET, ("\n --- phyBase: %08x\n", MACInfo->phyBase));
4654 + phySetup(MACInfo->unit, MACInfo->phyBase);
4656 + /* Start thread to poll for phy link status changes */
4657 + phy_poll_pid = kernel_thread(ae531x_phy_poll, dev_sw_state, 0);
4658 + if (phy_poll_pid < 0) {
4659 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4660 + ("ethmac%d unable to start Phy Poll thread\n",
4664 + /* Allocate RX/TX Queues */
4665 + if (ae531x_AllocateQueues(MACInfo) < 0) {
4666 + AE531X_PRINT(AE531X_DEBUG_RESET, ("Queue allocation failed"));
4667 + free_irq(MAC_state->irq, (void *)MACInfo);
4668 + goto open_failure;
4671 + /* Initialize DMA and descriptors */
4672 + ae531x_DmaReset(MACInfo);
4674 + /* Initialize MAC */
4675 + ae531x_MACReset(MACInfo);
4677 + /* Enable Receive/Transmit */
4678 + ae531x_EnableComm(MACInfo);
4680 + MAC_state->primary_dev = dev_sw_state->unit_on_MAC;
4681 + MACInfo->port_is_up = TRUE;
4684 + dev->trans_start = jiffies;
4685 + SET_MODULE_OWNER(dev);
4696 + * Shut down MAC hardware.
4699 +ae531x_MAC_shutdown(ae531x_MAC_state_t *MAC_state)
4701 + ae531x_MAC_t *MACInfo;
4703 + MACInfo = &MAC_state->MACInfo;
4704 + MACInfo->port_is_up = FALSE;
4706 + /* Disable Receive/Transmit */
4707 + ae531x_DisableComm(MACInfo);
4709 + /* Disable Interrupts */
4710 + ae531x_DmaIntDisable(MACInfo);
4712 + free_irq(MAC_state->irq, (void *)MACInfo);
4714 + /* Free Transmit & Receive skb's/descriptors */
4715 + ae531x_TxReap(MAC_state); /* one last time */
4716 + ae531x_FreeQueues(MACInfo);
4719 +/*******************************************************************************
4720 +* ae531x_MAC_stop is the standard Linux stop function. It undoes
4721 +* everything set up by ae531x_MAC_open.
4724 +ae531x_MAC_stop(struct net_device *dev)
4726 + ae531x_dev_sw_state_t *dev_sw_state;
4727 + ae531x_MAC_state_t *MAC_state;
4728 + ae531x_MAC_t *MACInfo;
4733 + dev_sw_state = (ae531x_dev_sw_state_t *)dev->priv;
4734 + MAC_state = dev_sw_state->MAC_state;
4735 + MACInfo = &MAC_state->MACInfo;
4737 + for (i=0; i<AE531X_DEV_PER_MAC; i++) {
4738 + if ((MAC_state->dev_sw_state[i]->dev) &&
4739 + (MAC_state->dev_sw_state[i]->dev != dev_sw_state->dev)) {
4744 + if (i < AE531X_DEV_PER_MAC) {
4745 + /* Physical MAC is still in use */
4746 + if (MAC_state->primary_dev == dev_sw_state->unit_on_MAC) {
4748 + * If the primary_dev is being stopped
4749 + * then we need to assign a new one.
4751 + MAC_state->primary_dev = i;
4754 + /* Physical MAC is no longer in use */
4755 + ae531x_MAC_shutdown(MAC_state);
4758 + dev_sw_state->dev = NULL;
4763 +/*******************************************************************************
4764 +* ae531x_rxbuf_alloc - Allocate an skb to be associated with an RX descriptor.
4766 +* RETURNS: A pointer to the skb. Also returns a pointer to the underlying
4767 +* buffer and the size of that buffer.
4770 +ae531x_rxbuf_alloc(ae531x_MAC_t *MACInfo, char **rxBuffp, int *rxBuffSizep)
4773 + struct sk_buff *skb;
4777 + buf_size = AE531X_RX_BUF_SIZE;
4779 + skb = dev_alloc_skb(buf_size);
4781 + /* skb->dev = dev; */
4782 + skb_reserve(skb, RXBUFF_RESERVE);
4784 + rxBuffSize = skb_tailroom(skb);
4785 + rxBuff = skb->tail;
4787 + *rxBuffp = rxBuff;
4788 + *rxBuffSizep = rxBuffSize;
4794 +/*******************************************************************************
4795 +* ae531x_swptr_free - Free the skb, if any, associated with a descriptor.
4798 +ae531x_swptr_free(VIRT_ADDR desc)
4800 + struct sk_buff *skb;
4802 + skb = (struct sk_buff *)AE531X_DESC_SWPTR_GET(desc);
4804 + AE531X_DESC_SWPTR_SET(desc, NULL);
4809 +/*******************************************************************************
4811 +* ae531x_TxReap - the driver Tx completion routine.
4813 +* This routine reaps sk_buffs which have already been transmitted.
4817 +ae531x_TxReap(ae531x_MAC_state_t *MAC_state)
4819 + AE531X_QUEUE *txq;
4822 + struct sk_buff *skb;
4824 + ae531x_MAC_t *MACInfo;
4825 + static int aeUselessReap = 0;
4827 + static int aeMaxReap = 0;
4831 + MACInfo = &MAC_state->MACInfo;
4832 + txq = &MACInfo->txQueue;
4837 + txDesc = AE531X_QUEUE_ELE_NEXT_GET(txq, txq->reapDescAddr);
4838 + if (txDesc == txq->curDescAddr) {
4842 + cmdsts = AE531X_DESC_STATUS_GET(KSEG1ADDR(txDesc));
4843 + if (cmdsts & DescOwnByDma) {
4847 + /* Release sk_buff associated with completed transmit */
4848 + skb = (struct sk_buff *)AE531X_DESC_SWPTR_GET(txDesc);
4851 + AE531X_DESC_SWPTR_SET(txDesc, NULL);
4854 + /* Update statistics according to completed transmit desc */
4855 + if (cmdsts & DescTxErrors) {
4856 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4857 + ("enetmac%d Tx prior error: 0x%8.8x <0x%8.8x> 0x%8.8x\n",
4863 + //my_mvPhyShow(MACInfo->unit);
4864 + printk ("ae531xMacControl: 0x%08x\tMacFlowControl: 0x%08x\n",
4865 + ae531x_ReadMacReg(MACInfo, MacControl),
4866 + ae531x_ReadMacReg(MACInfo, MacFlowControl));
4868 + MAC_state->stats.tx_errors++;
4869 + if (cmdsts & (DescTxLateCollision | DescTxExcCollisions)) {
4870 + MAC_state->stats.tx_aborted_errors++;
4872 + if (cmdsts & (DescTxLostCarrier | DescTxNoCarrier)) {
4873 + MAC_state->stats.tx_carrier_errors++;
4876 + MAC_state->stats.tx_bytes += AE531X_DESC_STATUS_RX_SIZE(cmdsts);
4877 + MAC_state->stats.tx_packets++;
4880 + MAC_state->stats.collisions +=
4881 + ((cmdsts & DescTxCollMask) >> DescTxCollShift);
4883 + txq->reapDescAddr = txDesc;
4891 + if (reaped > aeMaxReap) {
4892 + aeMaxReap = reaped;
4893 + printk("max reaped = %d\n", reaped);
4896 + AE531X_PRINT(AE531X_DEBUG_TX_REAP,
4897 + ("reaped %d\n", reaped));
4900 + * Re-start transmit queues for all ethernet devices
4901 + * associated with this MAC.
4903 + for (i=0; i<AE531X_DEV_PER_MAC; i++) {
4904 + if (MAC_state->dev_sw_state[i]->dev)
4905 + netif_start_queue(MAC_state->dev_sw_state[i]->dev);
4915 +/*******************************************************************************
4916 +* ae531x_MAC_start_xmit sends a packet.
4919 +ae531x_MAC_start_xmit(struct sk_buff *skb, struct net_device *dev)
4921 + ae531x_dev_sw_state_t *dev_sw_state;
4922 + ae531x_MAC_state_t *MAC_state;
4923 + ae531x_MAC_t *MACInfo;
4933 + dev_sw_state = (ae531x_dev_sw_state_t *)dev->priv;
4934 + MAC_state = dev_sw_state->MAC_state;
4935 + MACInfo = &MAC_state->MACInfo;
4937 + length = skb->len;
4939 + /* Check if this port is up, else toss packet */
4940 + if (!MACInfo->port_is_up) {
4941 + buf = virt_to_bus(skb->data);
4942 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4943 + ("eth%d Tx Down, dropping buf=0x%8.8x, length=0x%8.8x, skb=%p\n",
4944 + dev_sw_state->enetUnit, buf, length, (void *)skb));
4946 + MAC_state->stats.tx_dropped++;
4947 + MAC_state->stats.tx_carrier_errors++;
4951 + if (ae531x_IsInResetMode(MACInfo)) {
4952 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4953 + ("eth%d Tx: In Chip reset - drop frame\n",
4954 + dev_sw_state->enetUnit));
4956 + MAC_state->stats.tx_dropped++;
4957 + MAC_state->stats.tx_aborted_errors++;
4961 + /* Check if we can transport this packet */
4962 + length = max((u32)60, length); /* total length */
4964 + max_buf_size = mtu + ETH_HLEN;
4965 + if (length > max_buf_size) {
4966 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4967 + ("eth%d Tx: length %d too long. mtu=%d, trailer=%d\n",
4968 + dev_sw_state->enetUnit, length, mtu, PHY_TRAILER_SIZE));
4970 + MAC_state->stats.tx_errors++;
4971 + MAC_state->stats.tx_aborted_errors++;
4976 + /* Reap any old, completed Tx descriptors */
4977 + ae531x_TxReap(MAC_state);
4979 + txDesc = MACInfo->txQueue.curDescAddr;
4980 + if (txDesc == MACInfo->txQueue.reapDescAddr) {
4983 + AE531X_PRINT(AE531X_DEBUG_ERROR,
4984 + ("eth%d Tx: cannot get txDesc\n",
4985 + dev_sw_state->enetUnit));
4987 + MAC_state->stats.tx_dropped++;
4988 + MAC_state->stats.tx_fifo_errors++;
4991 + * Stop transmit queues for any ethernet devices
4992 + * associated with this MAC.
4994 +#if 0 /* XXX: no way to recover from queue stop until ae531x_MAC_tx_timeout()
4995 + * is rewritten to avoid calls to shedule().
4997 + for (i=0; i<AE531X_DEV_PER_MAC; i++) {
4998 + if (MAC_state->dev_sw_state[i]->dev)
4999 + netif_stop_queue(MAC_state->dev_sw_state[i]->dev);
5005 + /* We won't fail now; so consume this descriptor */
5006 + AE531X_CONSUME_DESC((&MACInfo->txQueue));
5008 + /* Update the descriptor */
5009 + buf = virt_to_bus(skb->data);
5010 + AE531X_DESC_BUFPTR_SET(txDesc, buf);
5011 + AE531X_DESC_SWPTR_SET(txDesc, skb);
5012 + ctrlen = AE531X_DESC_CTRLEN_GET(txDesc);
5013 + ctrlen = (ctrlen & (DescEndOfRing)) |
5018 + ctrlen |= ((length << DescSize1Shift) & DescSize1Mask);
5020 + AE531X_DESC_CTRLEN_SET(txDesc, ctrlen);
5021 + AE531X_DESC_STATUS_SET(txDesc, DescOwnByDma);
5023 + /* Alert DMA engine to resume Tx */
5024 + ae531x_WriteDmaReg(MACInfo, DmaTxPollDemand, 0);
5027 + AE531X_PRINT(AE531X_DEBUG_TX,
5028 + ("eth%d Tx: Desc=0x%8.8x, L=0x%8.8x, D=0x%8.8x, d=0x%8.8x, length=0x%8.8x\n",
5029 + dev_sw_state->enetUnit,
5031 + AE531X_DESC_CTRLEN_GET(txDesc),
5033 + AE531X_DESC_LNKBUF_GET(txDesc),
5036 + /* Tell upper layers to keep it coming */
5037 + dev->trans_start = jiffies;
5050 +/*******************************************************************************
5051 +* ae531x_MAC_tx_timeout handles transmit timeouts
5054 +ae531x_MAC_tx_timeout(struct net_device *dev)
5056 + ae531x_dev_sw_state_t *dev_sw_state;
5057 + ae531x_MAC_state_t *MAC_state;
5058 + ae531x_MAC_t *MACInfo;
5062 + dev_sw_state = (ae531x_dev_sw_state_t *)dev->priv;
5063 + MAC_state = dev_sw_state->MAC_state;
5064 + MACInfo = &MAC_state->MACInfo;
5066 + AE531X_PRINT(AE531X_DEBUG_ERROR,
5067 + ("enet%d: Tx timeout\n", dev_sw_state->enetUnit));
5069 + ae531x_restart(MACInfo);
5075 +/*******************************************************************************
5076 +* ae531x_MAC_do_ioctl is a placeholder for future ioctls.
5079 +ae531x_MAC_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
5082 + ae531x_MAC_t *MACInfo;
5083 + struct ioctl_data {
5088 + ae531x_dev_sw_state_t *dev_sw_state;
5089 + ae531x_MAC_state_t *MAC_state;
5093 + dev_sw_state = (ae531x_dev_sw_state_t *)dev->priv;
5094 + MAC_state = dev_sw_state->MAC_state;
5095 + MACInfo = &MAC_state->MACInfo;
5097 + req = (struct ioctl_data *)ifr->ifr_data;
5101 + AE531X_PRINT(AE531X_DEBUG_ERROR,
5102 + ("Unsupported ioctl: 0x%x\n", cmd));
5111 +ae531x_MAC_setup_fntable(struct net_device *dev)
5115 + dev->get_stats = ae531x_MAC_get_stats;
5116 + dev->open = ae531x_MAC_open;
5117 + dev->stop = ae531x_MAC_stop;
5118 + dev->hard_start_xmit = ae531x_MAC_start_xmit;
5119 + dev->do_ioctl = ae531x_MAC_do_ioctl;
5120 + dev->poll = ae531x_MAC_poll;
5122 +#if 0 /* XXX: currently, ae531x_MAC_tx_timeout() will call functions
5123 + * that in turn call schedule(). this is BAD, since the
5124 + * timeout call runs at interrupt time. until ae531x_MAC_tx_timeout
5125 + * is rewritten to avoid schedule() calls, we do not use it.
5127 + dev->tx_timeout = ae531x_MAC_tx_timeout;
5129 + dev->tx_timeout = NULL;
5131 + dev->features = NETIF_F_HW_CSUM |\
5138 +ar5312EepromRead(char *EepromAddr, u_int16_t id, unsigned int off,
5139 + unsigned int nbytes, char *data)
5143 + for (i=0; i<nbytes; i++, off++) {
5144 + data[i] = EepromAddr[off];
5149 +ae531x_get_numMACs(void)
5154 + /* Probe to find out the silicon revision and enable the
5155 + correct number of macs */
5156 + devid = ((u_int16_t) ((sysRegRead(AR531X_REV) >>8) &
5157 + (AR531X_REV_MAJ | AR531X_REV_MIN)));
5159 + case AR5212_AR5312_REV2:
5160 + case AR5212_AR5312_REV7:
5161 + /* Need to determine if we have a 5312 or a 2312 since they
5162 + have the same Silicon Rev ID*/
5163 + ar5312EepromRead(radioConfig,0,2*AR531X_RADIO_MASK_OFF,2,
5164 + (char *) &radioMask);
5165 + if ((radioMask & AR531X_RADIO0_MASK) != 0) {
5169 + case AR5212_AR2313_REV8:
5173 + /* default to 1 */
5178 +ae531x_twisted_enet(void)
5180 + int wisoc_revision;
5182 + wisoc_revision = (sysRegRead(AR531X_REV) & AR531X_REV_MAJ) >> AR531X_REV_MAJ_S;
5183 + if ( (wisoc_revision == AR531X_REV_MAJ_AR2313) ||
5184 + /* next clause is used to determine AR2312, based on number of MACs.
5185 + * must do this since revision is same for 5312 and 2312.
5187 + (wisoc_revision == AR531X_REV_MAJ_AR5312 && ae531x_get_numMACs() == 1) ) {
5195 +ae531x_get_board_config(void)
5201 + * Find start of Board Configuration data, using heuristics:
5202 + * Search back from the (aliased) end of flash by 0x1000 bytes
5203 + * at a time until we find the string "5311", which marks the
5204 + * start of Board Configuration. Give up if we've searched
5205 + * more than 500KB.
5208 + for (bd_config = (char *)0xbffff000;
5209 + bd_config > (char *)0xbff80000;
5210 + bd_config -= 0x1000)
5212 + if ( *(int *)bd_config == AR531X_BD_MAGIC) {
5219 + printk("Could not find Board Configuration Data\n");
5223 + ar531x_boardConfig = (struct ar531x_boarddata *) bd_config;
5225 + return(dataFound);
5229 +ae531x_get_radio_config(void)
5232 + char *radio_config;
5235 + * Now find the start of Radio Configuration data, using heuristics:
5236 + * Search forward from Board Configuration data by 0x1000 bytes
5237 + * at a time until we find non-0xffffffff.
5240 + for (radio_config = ((char *) ar531x_boardConfig) + 0x1000;
5241 + radio_config < (char *)0xbffff000;
5242 + radio_config += 0x1000)
5244 + if (*(int *)radio_config != 0xffffffff) {
5250 + if (!dataFound) { /* AR2316 relocates radio config to new location */
5252 + for (radio_config = ((char *) ar531x_boardConfig) + 0xf8;
5253 + radio_config < (char *)0xbffff0f8;
5254 + radio_config += 0x1000)
5256 + if (*(int *)radio_config != 0xffffffff) {
5264 + printk("Could not find Radio Configuration data\n");
5265 + radio_config = NULL;
5267 + radioConfig = radio_config;
5268 + return(dataFound);
5272 +ae531x_MAC_setup(void)
5275 + struct net_device *dev;
5276 + ae531x_dev_sw_state_t *dev_sw_state;
5277 + ae531x_MAC_state_t *MAC_state;
5278 + ae531x_MAC_t *MACInfo;
5283 + MOD_INC_USE_COUNT;
5284 + for (i=0;i<AR531X_NUM_ENET_MAC * AE531X_DEV_PER_MAC; i++) {
5285 + ae531x_MAC_dev[i] = NULL;
5288 + if (!ae531x_get_board_config()) {
5292 + if (!ae531x_get_radio_config()) {
5296 + for(i=0, next_dev = AR531X_NUM_ENET_MAC-1;
5297 + i<ae531x_get_numMACs() && next_dev>=0;
5300 + /* if MAC is bogus in config data, skip */
5301 + addr = ae531x_enet_mac_address_get(next_dev);
5302 + if((*(u32 *)addr == 0xffffffff) && (*(u16 *)(addr+4)==0xffff)){
5303 + /* bogus MAC config data */
5307 + dev = ae531x_MAC_dev[next_dev] =
5308 + init_etherdev(NULL, sizeof(ae531x_dev_sw_state_t));
5310 + if (dev == NULL) {
5315 + ae531x_MAC_setup_fntable(dev);
5317 + dev_sw_state = (ae531x_dev_sw_state_t *)dev->priv;
5318 + dev_sw_state->enetUnit = next_dev;
5319 + dev_sw_state->unit_on_MAC = 0;
5320 + MAC_state = &per_MAC_info[next_dev];
5321 + dev_sw_state->MAC_state = MAC_state;
5322 + MAC_state->dev_sw_state[AE531X_LAN_PORT] = dev_sw_state;
5323 + MAC_state->primary_dev = -1;
5325 + /* Initialize per-MAC information */
5326 + MACInfo = &MAC_state->MACInfo;
5328 + MACInfo->unit = next_dev;
5330 + if (MACInfo->unit == 0) {
5331 + MACInfo->macBase = (u32)(PHYS_TO_K1(AR531X_ENET0)+AE531X_MAC_OFFSET);
5332 + MACInfo->dmaBase = (u32)(PHYS_TO_K1(AR531X_ENET0)+AE531X_DMA_OFFSET);
5333 + MACInfo->phyBase = (u32)(PHYS_TO_K1(AR531X_ENET0)+AE531X_PHY_OFFSET);
5334 + MAC_state->irq = AR531X_IRQ_ENET0_INTRS;
5336 +#ifndef CONFIG_AR5315
5337 + MACInfo->macBase = (u32) (PHYS_TO_K1(AR531X_ENET1)+AE531X_MAC_OFFSET);
5338 + MACInfo->dmaBase = (u32) (PHYS_TO_K1(AR531X_ENET1)+AE531X_DMA_OFFSET);
5339 + if (ae531x_twisted_enet()) {
5340 + MACInfo->phyBase = (u32)(PHYS_TO_K1(AR531X_ENET0)+AE531X_PHY_OFFSET);
5342 + MACInfo->phyBase = (u32)(PHYS_TO_K1(AR531X_ENET1)+AE531X_PHY_OFFSET);
5344 + MAC_state->irq = AR531X_IRQ_ENET1_INTRS;
5348 + MACInfo->OSinfo = (void *)MAC_state;
5355 +module_init(ae531x_MAC_setup);
5357 +/*******************************************************************************
5358 +* ae531x_MAC_unload is the module unload function
5361 +ae531x_MAC_unload(void)
5365 + for (i=0;i<AR531X_NUM_ENET_MAC * AE531X_DEV_PER_MAC; i++) {
5366 + if (ae531x_MAC_dev[i] != NULL) {
5367 + if( (((ae531x_dev_sw_state_t *)ae531x_MAC_dev[i]->priv)->dev) != NULL)
5368 + ae531x_MAC_stop(ae531x_MAC_dev[i]);
5369 + ae531x_MAC_dev[i] = NULL;
5372 + MOD_DEC_USE_COUNT;
5375 +MODULE_AUTHOR("Atheros Communications, Inc.");
5376 +MODULE_DESCRIPTION("Support for Atheros WiSoC Ethernet device");
5377 +#ifdef MODULE_LICENSE
5378 +MODULE_LICENSE("Atheros");
5380 +module_exit(ae531x_MAC_unload);
5381 diff -urN linux-mips-orig/drivers/net/ath/ae531xmac.c linux-mips-new/drivers/net/ath/ae531xmac.c
5382 --- linux-mips-orig/drivers/net/ath/ae531xmac.c 1970-01-01 01:00:00.000000000 +0100
5383 +++ linux-mips-new/drivers/net/ath/ae531xmac.c 2005-12-31 12:33:57.673538824 +0000
5386 + * This file is subject to the terms and conditions of the GNU General Public
5387 + * License. See the file "COPYING" in the main directory of this archive
5388 + * for more details.
5390 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
5395 + * Ethernet driver for Atheros' ae531x ethernet MAC.
5399 +#include <linux/config.h>
5400 +#include <linux/types.h>
5401 +#include <linux/delay.h>
5402 +#include <linux/netdevice.h>
5403 +#include <linux/etherdevice.h>
5404 +#include <linux/init.h>
5405 +#include <asm/io.h>
5407 +#include "ar531xlnx.h"
5410 +#include "ae531xreg.h"
5411 +#include "ae531xmac.h"
5414 +int ae531x_MAC_debug = AE531X_DEBUG_ERROR;
5416 +int ae531x_MAC_debug = 0;
5419 +extern char *ae531x_enet_mac_address_get(int);
5421 +/* Forward references to local functions */
5422 +static void ae531x_QueueDestroy(AE531X_QUEUE *q);
5425 +/******************************************************************************
5427 +* ae531x_ReadMacReg - read AE MAC register
5429 +* RETURNS: register value
5432 +ae531x_ReadMacReg(ae531x_MAC_t *MACInfo, UINT32 reg)
5434 + UINT32 addr = MACInfo->macBase+reg;
5437 + data = RegRead(addr);
5442 +/******************************************************************************
5444 +* ae531x_WriteMacReg - write AE MAC register
5449 +ae531x_WriteMacReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 data)
5451 + UINT32 addr = MACInfo->macBase+reg;
5453 + RegWrite(data, addr);
5457 +/******************************************************************************
5459 +* ae531x_SetMacReg - set bits in AE MAC register
5464 +ae531x_SetMacReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val)
5466 + UINT32 addr = MACInfo->macBase+reg;
5467 + UINT32 data = RegRead(addr);
5470 + RegWrite(data, addr);
5474 +/******************************************************************************
5476 +* ae531x_ClearMacReg - clear bits in AE MAC register
5481 +ae531x_ClearMacReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val)
5483 + UINT32 addr = MACInfo->macBase+reg;
5484 + UINT32 data = RegRead(addr);
5487 + RegWrite(data, addr);
5491 +/******************************************************************************
5493 +* ae531x_ReadDmaReg - read AE DMA register
5495 +* RETURNS: register value
5498 +ae531x_ReadDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg)
5500 + UINT32 addr = MACInfo->dmaBase+reg;
5501 + UINT32 data = RegRead(addr);
5507 +/******************************************************************************
5509 +* ae531x_WriteDmaReg - write AE DMA register
5514 +ae531x_WriteDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 data)
5516 + UINT32 addr = MACInfo->dmaBase+reg;
5518 + RegWrite(data, addr);
5522 +/******************************************************************************
5524 + * ae531x_AckIntr - clear interrupt bits in the status register.
5525 + * Note: Interrupt bits are *cleared* by writing a 1.
5528 +ae531x_AckIntr(ae531x_MAC_t *MACInfo, UINT32 data)
5530 + ae531x_WriteDmaReg(MACInfo, DmaStatus, data);
5534 +/******************************************************************************
5536 +* ae531x_SetDmaReg - set bits in an AE DMA register
5541 +ae531x_SetDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val)
5543 + UINT32 addr = MACInfo->dmaBase+reg;
5544 + UINT32 data = RegRead(addr);
5547 + RegWrite(data, addr);
5551 +/******************************************************************************
5553 +* ae531x_ClearDmaReg - clear bits in an AE DMA register
5558 +ae531x_ClearDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val)
5560 + UINT32 addr = MACInfo->dmaBase+reg;
5561 + UINT32 data = RegRead(addr);
5564 + RegWrite(data, addr);
5568 +/******************************************************************************
5570 +* ae531x_ReadMiiReg - read PHY registers via AE MAC Mii addr/data registers
5572 +* RETURNS: register value
5575 +ae531x_ReadMiiReg(UINT32 phyBase, UINT32 reg)
5578 + UINT32 addr = phyBase+reg;
5580 + data = RegRead(addr);
5585 +/******************************************************************************
5587 +* ae531x_WriteMiiReg - write PHY registers via AE MAC Mii addr/data registers
5592 +ae531x_WriteMiiReg(UINT32 phyBase, UINT32 reg, UINT32 data)
5594 + UINT32 addr = phyBase+reg;
5596 + RegWrite(data, addr);
5600 +/******************************************************************************
5602 +* ae531x_MiiRead - read AE Mii register
5604 +* RETURNS: register value
5607 +ae531x_MiiRead(UINT32 phyBase, UINT32 phyAddr, UINT8 reg)
5612 + addr = ((phyAddr << MiiDevShift) & MiiDevMask) | ((reg << MiiRegShift) & MiiRegMask);
5614 + ae531x_WriteMiiReg(phyBase, MacMiiAddr, addr );
5617 + } while ((ae531x_ReadMiiReg(phyBase, MacMiiAddr ) & MiiBusy) == MiiBusy);
5619 + data = ae531x_ReadMiiReg(phyBase, MacMiiData) & 0xFFFF;
5625 +/******************************************************************************
5627 +* ae531x_MiiWrite - write AE Mii register
5632 +ae531x_MiiWrite(UINT32 phyBase, UINT32 phyAddr, UINT8 reg, UINT16 data)
5636 + ae531x_WriteMiiReg(phyBase, MacMiiData, data );
5638 + addr = ((phyAddr << MiiDevShift) & MiiDevMask) |
5639 + ((reg << MiiRegShift) & MiiRegMask) | MiiWrite;
5640 + ae531x_WriteMiiReg(phyBase, MacMiiAddr, addr );
5644 + } while ((ae531x_ReadMiiReg(phyBase, MacMiiAddr ) & MiiBusy) == MiiBusy);
5648 +/*******************************************************************************
5649 +* ae531x_BeginResetMode - enter a special "reset mode" in which
5650 +* -no interrupts are expected from the device
5651 +* -the device will not transmit nor receive
5652 +* -attempts to send or receive will return with an error and
5653 +* -the device will be reset at the next convenient opportunity.
5656 +ae531x_BeginResetMode(ae531x_MAC_t *MACInfo)
5658 + /* Set the reset flag */
5659 + MACInfo->aeProcessRst = 1;
5663 +/*******************************************************************************
5664 +* ae531x_EndResetMode - exit the special "reset mode" entered
5665 +* earlier via a call to ae531x_BeginResetMode.
5668 +ae531x_EndResetMode(ae531x_MAC_t *MACInfo)
5670 + MACInfo->aeProcessRst = 0;
5674 +/*******************************************************************************
5675 +* ae531x_IsInResetMode - determine whether or not the device is
5676 +* currently in "reset mode" (i.e. that a device reset is pending)
5679 +ae531x_IsInResetMode(ae531x_MAC_t *MACInfo)
5681 + return MACInfo->aeProcessRst;
5685 +/******************************************************************************
5687 +* ae531x_DmaRxStart - Start Rx
5692 +ae531x_DmaRxStart(ae531x_MAC_t *MACInfo)
5694 + ae531x_SetDmaReg(MACInfo, DmaControl, DmaRxStart);
5699 +/******************************************************************************
5701 +* ae531x_DmaRxStop - Stop Rx
5706 +ae531x_DmaRxStop(ae531x_MAC_t *MACInfo)
5708 + ae531x_ClearDmaReg(MACInfo, DmaControl, DmaRxStart);
5713 +/******************************************************************************
5715 +* ae531x_DmaTxStart - Start Tx
5720 +ae531x_DmaTxStart(ae531x_MAC_t *MACInfo)
5722 + ae531x_SetDmaReg(MACInfo, DmaControl, DmaTxStart);
5727 +/******************************************************************************
5729 +* ae531x_DmaTxStop - Stop Tx
5734 +ae531x_DmaTxStop(ae531x_MAC_t *MACInfo)
5736 + ae531x_ClearDmaReg(MACInfo, DmaControl, DmaTxStart);
5741 +/******************************************************************************
5743 +* ae531x_DmaIntEnable - Enable DMA interrupts
5748 +ae531x_DmaIntEnable(ae531x_MAC_t *MACInfo)
5750 + ae531x_WriteDmaReg(MACInfo, DmaIntrEnb, DmaIntEnable);
5754 +/******************************************************************************
5756 +* ae531x_DmaIntDisable - Disable DMA interrupts
5761 +ae531x_DmaIntDisable(ae531x_MAC_t *MACInfo)
5763 + ae531x_WriteDmaReg(MACInfo, DmaIntrEnb, DmaIntDisable);
5767 +/******************************************************************************
5769 +* ae531x_DmaIntClear - Clear DMA interrupts
5774 +ae531x_DmaIntClear(ae531x_MAC_t *MACInfo)
5776 + /* clear all interrupt requests */
5777 + ae531x_WriteDmaReg(MACInfo, DmaStatus,
5778 + ae531x_ReadDmaReg(MACInfo, DmaStatus));
5782 +/******************************************************************************
5783 +* Initialize generic queue data
5786 +ae531x_QueueInit(AE531X_QUEUE *q, char *pMem, int count)
5789 + q->firstDescAddr = pMem;
5790 + q->lastDescAddr = (VIRT_ADDR)((UINT32)q->firstDescAddr +
5791 + (count - 1) * AE531X_QUEUE_ELE_SIZE);
5792 + q->curDescAddr = q->firstDescAddr;
5798 +/******************************************************************************
5799 +* ae531x_TxQueueCreate - create a circular queue of descriptors for Transmit
5802 +ae531x_TxQueueCreate(ae531x_MAC_t *MACInfo,
5808 + VIRT_ADDR descAddr;
5812 + ae531x_QueueInit(q, pMem, count);
5813 + q->reapDescAddr = q->lastDescAddr;
5815 + /* Initialize Tx buffer descriptors. */
5816 + for (i=0, descAddr=q->firstDescAddr;
5818 + i++, descAddr=(VIRT_ADDR)((UINT32)descAddr + AE531X_QUEUE_ELE_SIZE))
5820 + /* Update the size, BUFPTR, and SWPTR fields */
5822 + AE531X_DESC_STATUS_SET(descAddr, 0);
5823 + AE531X_DESC_CTRLEN_SET(descAddr, 0);
5825 + AE531X_DESC_BUFPTR_SET(descAddr, (UINT32)0);
5826 + AE531X_DESC_LNKBUF_SET(descAddr, (UINT32)0);
5827 + AE531X_DESC_SWPTR_SET(descAddr, (void *)0);
5828 + } /* for each desc */
5830 + /* Make the queue circular */
5831 + AE531X_DESC_CTRLEN_SET(q->lastDescAddr,
5832 + DescEndOfRing|AE531X_DESC_CTRLEN_GET(q->lastDescAddr));
5834 + AE531X_PRINT(AE531X_DEBUG_RESET,
5835 + ("ethmac%d Txbuf begin = %x, end = %x\n",
5837 + (UINT32)q->firstDescAddr,
5838 + (UINT32)q->lastDescAddr));
5845 +/******************************************************************************
5846 +* ae531x_RxQueueCreate - create a circular queue of Rx descriptors
5849 +ae531x_RxQueueCreate(ae531x_MAC_t *MACInfo,
5855 + VIRT_ADDR descAddr;
5859 + ae531x_QueueInit(q, pMem, count);
5860 + q->reapDescAddr = NULL;
5863 + /* Initialize Rx buffer descriptors */
5864 + for (i=0, descAddr=q->firstDescAddr;
5866 + i++, descAddr=(VIRT_ADDR)((UINT32)descAddr + AE531X_QUEUE_ELE_SIZE))
5872 + swptr = ae531x_rxbuf_alloc(MACInfo, &rxBuffer, &rxBufferSize);
5873 + if (swptr == NULL) {
5874 + AE531X_PRINT(AE531X_DEBUG_RESET,
5875 + ("ethmac%d RX queue: ae531x_rxbuf_alloc failed\n",
5877 + ae531x_QueueDestroy(q);
5880 + AE531X_DESC_SWPTR_SET(descAddr, swptr);
5882 + AE531X_DESC_STATUS_SET(descAddr, DescOwnByDma);
5883 + AE531X_DESC_CTRLEN_SET(descAddr, rxBufferSize);
5884 + AE531X_DESC_BUFPTR_SET(descAddr, virt_to_bus(rxBuffer));
5885 + AE531X_DESC_LNKBUF_SET(descAddr, (UINT32)0);
5886 + } /* for each desc */
5888 + /* Make the queue circular */
5889 + AE531X_DESC_CTRLEN_SET(q->lastDescAddr,
5890 + DescEndOfRing|AE531X_DESC_CTRLEN_GET(q->lastDescAddr));
5892 + AE531X_PRINT(AE531X_DEBUG_RESET,
5893 + ("ethmac%d Rxbuf begin = %x, end = %x\n",
5895 + (UINT32)q->firstDescAddr,
5896 + (UINT32)q->lastDescAddr));
5903 +/******************************************************************************
5904 +* ae531x_QueueDestroy -- Free all buffers and descriptors associated
5908 +ae531x_QueueDestroy(AE531X_QUEUE *q)
5912 + VIRT_ADDR descAddr;
5918 + for (i=0, descAddr=q->firstDescAddr;
5920 + i++, descAddr=(VIRT_ADDR)((UINT32)descAddr + AE531X_QUEUE_ELE_SIZE)) {
5922 + AE531X_DESC_STATUS_SET(descAddr, 0);
5923 + AE531X_DESC_CTRLEN_SET(descAddr, 0);
5924 + AE531X_DESC_BUFPTR_SET(descAddr, (UINT32)0);
5925 + AE531X_DESC_LNKBUF_SET(descAddr, (UINT32)0);
5927 + ae531x_swptr_free(descAddr); /* Free OS-specific software pointer */
5934 +ae531x_TxQueueDestroy(ae531x_MAC_t *MACInfo)
5936 + ae531x_QueueDestroy(&MACInfo->txQueue);
5940 +ae531x_RxQueueDestroy(ae531x_MAC_t *MACInfo)
5942 + ae531x_QueueDestroy(&MACInfo->rxQueue);
5946 +/******************************************************************************
5947 +* ae531x_AllocateQueues - Allocate receive and transmit queues
5950 +ae531x_AllocateQueues(ae531x_MAC_t *MACInfo)
5953 + char *pTxBuf = NULL;
5954 + char *pRxBuf = NULL;
5958 + MACInfo->txDescCount = AE531X_TX_DESC_COUNT_DEFAULT;
5959 + QMemSize = AE531X_QUEUE_ELE_SIZE * MACInfo->txDescCount;
5960 + pTxBuf = MALLOC(QMemSize);
5961 + if (pTxBuf == NULL) {
5962 + AE531X_PRINT(AE531X_DEBUG_RESET,
5963 + ("ethmac%d Failed to allocate TX queue\n", MACInfo->unit));
5967 + if (ae531x_TxQueueCreate(MACInfo, &MACInfo->txQueue, pTxBuf,
5968 + MACInfo->txDescCount) < 0)
5970 + AE531X_PRINT(AE531X_DEBUG_RESET,
5971 + ("ethmac%d Failed to create TX queue\n", MACInfo->unit));
5975 + MACInfo->rxDescCount = AE531X_RX_DESC_COUNT_DEFAULT;
5976 + QMemSize = AE531X_QUEUE_ELE_SIZE * MACInfo->rxDescCount;
5977 + pRxBuf = MALLOC(QMemSize);
5978 + if (pRxBuf == NULL) {
5979 + AE531X_PRINT(AE531X_DEBUG_RESET,
5980 + ("ethmac%d Failed to allocate RX queue\n", MACInfo->unit));
5984 + if (ae531x_RxQueueCreate(MACInfo, &MACInfo->rxQueue, pRxBuf,
5985 + MACInfo->rxDescCount) < 0)
5987 + AE531X_PRINT(AE531X_DEBUG_RESET,
5988 + ("ethmac%d Failed to create RX queue\n", MACInfo->unit));
5992 + AE531X_PRINT(AE531X_DEBUG_RESET,
5993 + ("ethmac%d Memory setup complete.\n", MACInfo->unit));
5999 + MACInfo->txDescCount = 0; /* sanity */
6000 + MACInfo->rxDescCount = 0; /* sanity */
6014 +/******************************************************************************
6016 +* ae531x_FreeQueues - Free Transmit & Receive queues
6019 +ae531x_FreeQueues(ae531x_MAC_t *MACInfo)
6021 + ae531x_TxQueueDestroy(MACInfo);
6022 + FREE(MACInfo->txQueue.firstDescAddr);
6024 + ae531x_RxQueueDestroy(MACInfo);
6025 + FREE(MACInfo->rxQueue.firstDescAddr);
6028 +/******************************************************************************
6030 +* ae531x_DmaReset - Reset DMA and TLI controllers
6035 +ae531x_DmaReset(ae531x_MAC_t *MACInfo)
6042 + /* Disable device interrupts prior to any errors during stop */
6043 + intDisable(MACInfo->ilevel);
6045 + /* Disable MAC rx and tx */
6046 + ae531x_ClearMacReg(MACInfo, MacControl, (MacRxEnable | MacTxEnable));
6050 + /* Reset dma controller */
6052 + ae531x_WriteDmaReg(MACInfo, DmaBusMode, DmaResetOn);
6054 + /* Delay 2 usec */
6057 + /* Flush the rx queue */
6058 + descAddr = (UINT32)MACInfo->rxQueue.firstDescAddr;
6059 + MACInfo->rxQueue.curDescAddr = MACInfo->rxQueue.firstDescAddr;
6061 + i<(MACInfo->rxDescCount);
6062 + i++, descAddr += AE531X_QUEUE_ELE_SIZE) {
6063 + AE531X_DESC_STATUS_SET(descAddr, DescOwnByDma);
6066 + /* Flush the tx queue */
6067 + descAddr = (UINT32)MACInfo->txQueue.firstDescAddr;
6068 + MACInfo->txQueue.curDescAddr = MACInfo->txQueue.firstDescAddr;
6069 + MACInfo->txQueue.reapDescAddr = MACInfo->txQueue.lastDescAddr;
6071 + i<(MACInfo->txDescCount);
6072 + i++, descAddr += AE531X_QUEUE_ELE_SIZE) {
6073 + AE531X_DESC_STATUS_SET (descAddr, 0);
6076 + /* Set init register values */
6077 + ae531x_WriteDmaReg(MACInfo, DmaBusMode, DmaBusModeInit);
6079 + /* Install the first Tx and Rx queues on the device */
6080 + ae531x_WriteDmaReg(MACInfo, DmaRxBaseAddr,
6081 + virt_to_bus(MACInfo->rxQueue.firstDescAddr));
6082 + ae531x_WriteDmaReg(MACInfo, DmaTxBaseAddr,
6083 + virt_to_bus(MACInfo->txQueue.firstDescAddr));
6086 + ae531x_WriteDmaReg(MACInfo, DmaControl, DmaStoreAndForward);
6088 + ae531x_WriteDmaReg(MACInfo, DmaIntrEnb, DmaIntDisable);
6090 + AE531X_PRINT(AE531X_DEBUG_RESET,
6091 + ("ethmac%d: DMA RESET!\n", MACInfo->unit));
6093 + /* Turn on device interrupts -- enable most errors */
6094 + ae531x_DmaIntClear(MACInfo); /* clear interrupt requests */
6095 + ae531x_DmaIntEnable(MACInfo); /* enable interrupts */
6097 + ae531x_EndResetMode(MACInfo);
6099 + intEnable(MACInfo->ilevel);
6105 +/******************************************************************************
6107 +* ae531x_MACAddressSet - Set the ethernet address
6109 +* Sets the ethernet address according to settings in flash.
6114 +ae531x_MACAddressSet(ae531x_MAC_t *MACInfo)
6116 + unsigned int data;
6121 + macAddr = ae531x_enet_mac_address_get(MACInfo->unit);
6123 + /* set our MAC address */
6124 + data = (macAddr[5]<<8) | macAddr[4];
6125 + ae531x_WriteMacReg(MACInfo, MacAddrHigh, data );
6127 + data = (macAddr[3]<<24) | (macAddr[2]<<16) | (macAddr[1]<<8) | macAddr[0];
6128 + ae531x_WriteMacReg(MACInfo, MacAddrLow, data );
6130 + AE531X_PRINT(AE531X_DEBUG_RESET,
6131 + ("ethmac%d Verify MAC address %8.8X %8.8X \n",
6133 + ae531x_ReadMacReg(MACInfo, MacAddrLow),
6134 + ae531x_ReadMacReg(MACInfo, MacAddrHigh)));
6136 + AE531X_PRINT(AE531X_DEBUG_RESET,
6137 + (" sb = %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X\n",
6143 + 0xff&macAddr[5]));
6148 +/******************************************************************************
6150 +* ae_SetMACFromPhy - read Phy settings and update Mac
6151 +* with current duplex and speed.
6156 +ae531x_SetMACFromPhy(ae531x_MAC_t *MACInfo)
6164 + timeout = jiffies+(HZ/1000)*AE531X_NEGOT_TIMEOUT;
6166 + /* Get duplex mode from Phy */
6167 + while (((fullDuplex = phyIsFullDuplex(MACInfo->unit)) == -1) &&
6168 + (jiffies <= timeout));
6170 + /* Flag is set for full duplex mode, else cleared */
6171 + macCtl = ae531x_ReadMacReg(MACInfo, MacControl);
6174 + /* set values of control registers */
6175 + macCtl &= ~MacDisableRxOwn;
6176 + macCtl |= MacFullDuplex;
6177 + ae531x_WriteMacReg(MACInfo, MacControl, macCtl);
6178 + ae531x_WriteMacReg(MACInfo, MacFlowControl, MacFlowControlInitFdx);
6180 + /* set values of control registers */
6181 + ae531x_WriteMacReg(MACInfo, MacFlowControl, MacFlowControlInitHdx);
6182 + macCtl |= MacDisableRxOwn;
6183 + macCtl &= ~MacFullDuplex;
6184 + ae531x_WriteMacReg(MACInfo, MacControl, macCtl);
6191 +/******************************************************************************
6192 +* ae531x_MACReset -- sets MAC address and duplex.
6195 +ae531x_MACReset(ae531x_MAC_t *MACInfo)
6197 + ae531x_MACAddressSet(MACInfo);
6198 +#ifndef CONFIG_AR5315
6199 + ae531x_SetMACFromPhy(MACInfo);
6204 +/******************************************************************************
6205 +* ae531x_EnableComm -- enable Transmit and Receive
6208 +ae531x_EnableComm(ae531x_MAC_t *MACInfo)
6210 + ae531x_SetMacReg(MACInfo, MacControl, (MacRxEnable | MacTxEnable));
6211 + ae531x_DmaRxStart(MACInfo); /* start receiver */
6212 + ae531x_DmaTxStart(MACInfo); /* start transmitter */
6216 +/******************************************************************************
6217 +* ae531x_DisableComm -- disable Transmit and Receive
6220 +ae531x_DisableComm(ae531x_MAC_t *MACInfo)
6222 + ae531x_ClearMacReg(MACInfo, MacControl, (MacRxEnable | MacTxEnable));
6226 +/******************************************************************************
6227 +* ae531x_reset -- Cold reset ethernet interface
6230 +ae531x_reset(ae531x_MAC_t *MACInfo)
6234 +#ifndef CONFIG_AR5315
6236 + if (MACInfo->unit == 0) {
6237 + mask = AR531X_RESET_ENET0 | AR531X_RESET_EPHY0;
6239 + mask = AR531X_RESET_ENET1 | AR531X_RESET_EPHY1;
6242 + /* Put into reset */
6243 + regtmp = sysRegRead(AR531X_RESET);
6244 + sysRegWrite(AR531X_RESET, regtmp | mask);
6247 + /* Pull out of reset */
6248 + regtmp = sysRegRead(AR531X_RESET);
6249 + sysRegWrite(AR531X_RESET, regtmp & ~mask);
6253 + if (MACInfo->unit == 0) {
6254 + mask = AR531X_ENABLE_ENET0;
6256 + mask = AR531X_ENABLE_ENET1;
6258 + regtmp = sysRegRead(AR531X_ENABLE);
6259 + sysRegWrite(AR531X_ENABLE, regtmp | mask);
6261 + if (MACInfo->unit == 0) {
6262 + mask = AR531X_RESET_ENET0 | AR531X_RESET_EPHY0;
6264 + /* Enable Arbitration for Ethernet bus */
6265 + regtmp = sysRegRead(AR531XPLUS_AHB_ARB_CTL);
6266 + regtmp |= ARB_ETHERNET;
6267 + sysRegWrite(AR531XPLUS_AHB_ARB_CTL, regtmp);
6269 + /* Put into reset */
6270 + regtmp = sysRegRead(AR531X_RESET);
6271 + sysRegWrite(AR531X_RESET, regtmp | mask);
6274 + /* Pull out of reset */
6275 + regtmp = sysRegRead(AR531X_RESET);
6276 + sysRegWrite(AR531X_RESET, regtmp & ~mask);
6279 + regtmp = sysRegRead(AR531XPLUS_IF_CTL);
6280 + regtmp |= IF_TS_LOCAL;
6281 + sysRegWrite(AR531XPLUS_IF_CTL, regtmp);
6286 +/******************************************************************************
6287 +* ae531x_unitLinkLost -- Called from PHY layer to notify the MAC layer
6288 +* that there are no longer any live links associated with a MAC.
6291 +ae531x_unitLinkLost(int ethUnit)
6293 + AE531X_PRINT(AE531X_DEBUG_LINK_CHANGE,
6294 + ("enetmac%d link down\n", ethUnit));
6298 +/******************************************************************************
6299 +* ae531x_unitLinkGained -- Called from PHY layer to notify the MAC layer
6300 +* that there are 1 or more live links associated with a MAC.
6303 +ae531x_unitLinkGained(int ethUnit)
6306 +#define AE531X_POLL_MILLI_SECONDS 200
6307 + ae531x_MAC_t *MACInfo = ae531x_getMAcInfo(ethUnit);
6308 + while(!MACInfo || !MACInfo->port_is_up)
6310 + set_current_state(TASK_UNINTERRUPTIBLE);
6311 + schedule_timeout((AE531X_POLL_MILLI_SECONDS * HZ)/1000);
6312 + MACInfo = ae531x_getMAcInfo(ethUnit);
6314 + ae531x_SetMACFromPhy(MACInfo);
6316 + AE531X_PRINT(AE531X_DEBUG_LINK_CHANGE,
6317 + ("enet%d link up\n", ethUnit));
6320 +/******************************************************************************
6321 +* ae531x_ethMacDefault -- Called from PHY layer to determine the default
6322 +* ethernet MAC. On some "twisted" platforms, the only usable MAC is 1,
6323 +* while on others the usable MAC is 0. Future boards may allow both MACs
6324 +* to be used; in this case, return -1 to indicate that there IS NO default
6328 +ae531x_ethMacDefault(void)
6330 + if (ae531x_twisted_enet())
6336 diff -urN linux-mips-orig/drivers/net/ath/ae531xmac.h linux-mips-new/drivers/net/ath/ae531xmac.h
6337 --- linux-mips-orig/drivers/net/ath/ae531xmac.h 1970-01-01 01:00:00.000000000 +0100
6338 +++ linux-mips-new/drivers/net/ath/ae531xmac.h 2005-12-31 12:33:57.674538672 +0000
6341 + * This file is subject to the terms and conditions of the GNU General Public
6342 + * License. See the file "COPYING" in the main directory of this archive
6343 + * for more details.
6345 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
6349 + * See README to understand the decomposition of the ethernet driver.
6351 + * This file contains OS-independent pure software definitions for
6352 + * ethernet support on the AR531X platform.
6355 +#ifndef _AE531XMAC_H_
6356 +#define _AE531XMAC_H_
6358 +#include <linux/config.h>
6359 +#include <linux/module.h>
6362 + * DEBUG switches to control verbosity.
6363 + * Just modify the value of ae531x_MAC_debug.
6365 +#define AE531X_DEBUG_ALL 0xffffffff
6366 +#define AE531X_DEBUG_ERROR 0x00000001 /* Unusual conditions and Errors */
6367 +#define AE531X_DEBUG_ARRIVE 0x00000002 /* Arrive into a function */
6368 +#define AE531X_DEBUG_LEAVE 0x00000004 /* Leave a function */
6369 +#define AE531X_DEBUG_RESET 0x00000008 /* Reset */
6370 +#define AE531X_DEBUG_TX 0x00000010 /* Transmit */
6371 +#define AE531X_DEBUG_TX_REAP 0x00000020 /* Transmit Descriptor Reaping */
6372 +#define AE531X_DEBUG_RX 0x00000040 /* Receive */
6373 +#define AE531X_DEBUG_RX_STOP 0x00000080 /* Receive Early Stop */
6374 +#define AE531X_DEBUG_INT 0x00000100 /* Interrupts */
6375 +#define AE531X_DEBUG_LINK_CHANGE 0x00000200 /* PHY Link status changed */
6377 +#define AE531X_NEGOT_TIMEOUT 500 /* ms to wait for autonegotiation */
6379 +extern int ae531x_MAC_debug;
6381 +#define AE531X_PRINT(FLG, X) \
6383 + if (ae531x_MAC_debug & (FLG)) { \
6384 + DEBUG_PRINTF("%s#%d:%s ", \
6392 +#define ARRIVE() AE531X_PRINT(AE531X_DEBUG_ARRIVE, ("Arrive{\n"))
6393 +#define LEAVE() AE531X_PRINT(AE531X_DEBUG_LEAVE, ("}Leave\n"))
6395 +#define RegRead(addr) \
6396 + (*(volatile unsigned int *)(addr))
6398 +#define RegWrite(val,addr) \
6399 + ((*(volatile unsigned int *)(addr)) = (val))
6401 +/*****************************************************************
6402 + * Phy code is broken out into a separate layer, so that different
6403 + * PHY hardware can easily be supported.
6405 + * These functions are provided by the PHY layer for use by the MAC layer.
6406 + * phySetup -- Set phy hardware appropriately for a MAC unit
6408 + * phyCheckStatusChange -- Look for dropped/initiated links on any
6409 + * phy port associated with a MAC unit
6411 + * phyIsSpeed100 -- Determines whether or not a PHY is up and
6412 + * running at 100Mbit
6414 + * phyIsFullDuplex -- Determines whether or not a PHY is up and
6415 + * running in Full Duplex mode
6418 +#if CONFIG_MARVELL_ENET_PHY
6420 + * Mapping of generic phy APIs to Marvell Ethernet Switch phy functions.
6423 +#define phySetup(ethUnit, phyBase) mv_phySetup((ethUnit), (phyBase))
6424 +#define phyCheckStatusChange(ethUnit) mv_phyCheckStatusChange(ethUnit)
6425 +#define phyIsSpeed100(ethUnit) mv_phyIsSpeed100(ethUnit)
6426 +#define phyIsFullDuplex(ethUnit) mv_phyIsFullDuplex(ethUnit)
6428 +#if CONFIG_VENETDEV
6429 +#define PHY_TRAILER_SIZE MV_PHY_TRAILER_SIZE
6430 +extern void mv_phyDetermineSource(char *data, int len, int *pFromLAN);
6431 +extern void mv_phySetDestinationPort(char *data, int len, int fromLAN);
6432 +#define phyDetermineSource(data, len, pFromLAN) mv_phyDetermineSource((data), (len), (pFromLAN))
6433 +#define phySetDestinationPort(data, len, fromLAN) mv_phySetDestinationPort((data), (len), (fromLAN))
6435 +#define PHY_TRAILER_SIZE 0
6437 +#endif /* CONFIG_MARVELL_ENET_PHY */
6439 +#if CONFIG_KENDIN_ENET_PHY || CONFIG_REALTEK_ENET_PHY || CONFIG_KENDIN_KS8995XA_ENET_PHY
6441 + * Mapping of generic phy APIs to Kendin KS8721B and RealTek RTL8201BL phys.
6444 +#define phySetup(ethUnit, phyBase) rt_phySetup((ethUnit), (phyBase))
6445 +#define phyCheckStatusChange(ethUnit) rt_phyCheckStatusChange(ethUnit)
6446 +#define phyIsSpeed100(ethUnit) rt_phyIsSpeed100(ethUnit)
6447 +#define phyIsFullDuplex(ethUnit) rt_phyIsFullDuplex(ethUnit)
6450 +#if CONFIG_ICPLUS_ENET_PHY
6452 + * Mapping of generic phy APIs to Icplus phys.
6455 +#define phySetup(ethUnit, phyBase) ip_phySetup((ethUnit), (phyBase))
6456 +#define phyCheckStatusChange(ethUnit) ip_phyCheckStatusChange(ethUnit)
6457 +#define phyIsSpeed100(ethUnit) ip_phyIsSpeed100(ethUnit)
6458 +#define phyIsFullDuplex(ethUnit) ip_phyIsFullDuplex(ethUnit)
6461 +#if !defined(PHY_TRAILER_SIZE)
6462 +#define PHY_TRAILER_SIZE 0
6465 +/*****************************************************************
6466 + * MAC-independent interface to be used by PHY code
6468 + * These functions are provided by the MAC layer for use by the PHY layer.
6470 +#define phyRegRead ae531x_MiiRead
6471 +#define phyRegWrite ae531x_MiiWrite
6472 +#define phyLinkLost(ethUnit) ae531x_unitLinkLost(ethUnit)
6473 +#define phyLinkGained(ethUnit) ae531x_unitLinkGained(ethUnit)
6474 +#define phyEthMacDefault() ae531x_ethMacDefault()
6476 +void ae531x_unitLinkLost(int unit);
6477 +void ae531x_unitLinkGained(int unit);
6478 +int ae531x_ethMacDefault(void);
6482 + * RXBUFF_RESERVE enables building header on WLAN-side in place
6483 + * NB: Divisible by 2 but NOT 4. Otherwise handle_adel_int() will
6484 + * be used by the ip layer for misaligned word accesses and
6485 + * performance will suffer - a lot.
6487 +#define ETH_CRC_LEN 4
6488 +#define RXBUFF_RESERVE 98
6489 +// #define RXBUFF_RESERVE 98
6491 +/*****************************************************************
6492 + * Descriptor queue
6494 +typedef struct ae531x_queue {
6495 + VIRT_ADDR firstDescAddr; /* descriptor array address */
6496 + VIRT_ADDR lastDescAddr; /* last descriptor address */
6497 + VIRT_ADDR curDescAddr; /* current descriptor address */
6498 + VIRT_ADDR reapDescAddr; /* current tail of tx descriptors reaped */
6499 + UINT16 count; /* number of elements */
6502 +/* Given a descriptor, return the next one in a circular list */
6503 +#define AE531X_QUEUE_ELE_NEXT_GET(q, descAddr) \
6504 + ((descAddr) == (q)->lastDescAddr) ? (q)->firstDescAddr : \
6505 + (VIRT_ADDR)((UINT32)(descAddr) + AE531X_QUEUE_ELE_SIZE)
6507 +/* Move the "current descriptor" forward to the next one */
6508 +#define AE531X_CONSUME_DESC(q) \
6509 + q->curDescAddr = AE531X_QUEUE_ELE_NEXT_GET(q, q->curDescAddr)
6511 +/*****************************************************************
6512 + * Per-ethernet-MAC OS-independent information
6514 +typedef struct ae531x_MAC_s {
6515 + u32 unit; /* MAC unit ID */
6516 + u32 macBase; /* MAC base address */
6517 + u32 dmaBase; /* DMA base address */
6518 + u32 phyBase; /* PHY base address */
6519 + AE531X_QUEUE txQueue; /* Transmit descriptor queue */
6520 + AE531X_QUEUE rxQueue; /* Receive descriptor queue */
6521 + UINT16 txDescCount; /* Transmit descriptor count */
6522 + UINT16 rxDescCount; /* Receive descriptor count */
6523 + BOOL aeProcessRst; /* flag to indicate reset in progress */
6524 + BOOL port_is_up; /* flag to indicate port is up */
6525 + void *OSinfo; /* OS-dependent data */
6528 +#define AE531X_TX_DESC_COUNT_DEFAULT 128 /* Transmit descriptors */
6529 +#define AE531X_RX_DESC_COUNT_DEFAULT 128 /* Receive descriptors */
6532 +/*****************************************************************
6533 + * Interfaces exported by the OS-independent MAC layer
6535 +void ae531x_BeginResetMode(ae531x_MAC_t *MACInfo);
6536 +void ae531x_EndResetMode(ae531x_MAC_t *MACInfo);
6537 +BOOL ae531x_IsInResetMode(ae531x_MAC_t *MACInfo);
6538 +int ae531x_RxQueueCreate(ae531x_MAC_t *MACInfo, AE531X_QUEUE *q,
6539 + char *pMem, int count);
6540 +int ae531x_QueueDelete(struct ae531x_queue *q);
6541 +void ae531x_DmaReset(ae531x_MAC_t *MACInfo);
6542 +void ae531x_MACReset(ae531x_MAC_t *MACInfo);
6543 +void ae531x_EnableComm(ae531x_MAC_t *MACInfo);
6544 +void ae531x_DisableComm(ae531x_MAC_t *MACInfo);
6545 +void ae531x_reset(ae531x_MAC_t *MACInfo);
6546 +int ae531x_AllocateQueues(ae531x_MAC_t *MACInfo);
6547 +void ae531x_FreeQueues(ae531x_MAC_t *MACInfo);
6548 +void ae531x_QueueInit(AE531X_QUEUE *q, char *pMem, int count);
6549 +UINT32 ae531x_ReadMacReg(ae531x_MAC_t *MACInfo, UINT32 reg);
6550 +void ae531x_WriteMacReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 data);
6551 +void ae531x_SetMacReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val);
6552 +void ae531x_ClearMacReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val);
6553 +void ae531x_SetDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val);
6554 +void ae531x_ClearDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 val);
6555 +UINT32 ae531x_ReadDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg);
6556 +void ae531x_WriteDmaReg(ae531x_MAC_t *MACInfo, UINT32 reg, UINT32 data);
6557 +UINT32 ae531x_ReadMiiReg(UINT32 phyBase, UINT32 reg);
6558 +void ae531x_WriteMiiReg(UINT32 phyBase, UINT32 reg, UINT32 data);
6559 +UINT16 ae531x_MiiRead(UINT32 phyBase, UINT32 phyAddr, UINT8 reg);
6560 +void ae531x_MiiWrite(UINT32 phyBase, UINT32 phyAddr, UINT8 reg, UINT16 data);
6561 +void ae531x_DmaIntEnable(ae531x_MAC_t *MACInfo);
6562 +void ae531x_DmaIntDisable(ae531x_MAC_t *MACInfo);
6563 +void ae531x_AckIntr(ae531x_MAC_t *MACInfo, UINT32 val);
6564 +void *ae531x_rxbuf_alloc(ae531x_MAC_t *MACInfo, char **rxBptr, int *rxBSize);
6565 +void ae531x_swptr_free(VIRT_ADDR txDesc);
6566 +BOOL ae531x_twisted_enet(void);
6568 +#endif /* _AE531XMAC_H_ */
6569 diff -urN linux-mips-orig/drivers/net/ath/ae531xreg.h linux-mips-new/drivers/net/ath/ae531xreg.h
6570 --- linux-mips-orig/drivers/net/ath/ae531xreg.h 1970-01-01 01:00:00.000000000 +0100
6571 +++ linux-mips-new/drivers/net/ath/ae531xreg.h 2005-12-31 12:33:57.675538520 +0000
6574 + * This file is subject to the terms and conditions of the GNU General Public
6575 + * License. See the file "COPYING" in the main directory of this archive
6576 + * for more details.
6578 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
6582 + * See README to understand the decomposition of the ethernet driver.
6584 + * Register definitions for Atheros AR531X Ethernet MAC.
6587 +#ifndef _AE531XREG_H_
6588 +#define _AE531XREG_H_
6590 +#define AE531X_MAC_OFFSET 0x0000
6591 +#define AE531X_PHY_OFFSET 0x0000 /* Same as MAC offset */
6592 +#define AE531X_DMA_OFFSET 0x1000
6594 +/***********************************************************/
6595 +/* MAC110 registers, base address is BAR+AE531X_MAC_OFFSET */
6596 +/***********************************************************/
6597 +#define MacControl 0x00 /* control */
6598 +#define MacAddrHigh 0x04 /* address high */
6599 +#define MacAddrLow 0x08 /* address low */
6600 +#define MacMultiHashHigh 0x0C /* multicast hash table high */
6601 +#define MacMultiHashLow 0x10 /* multicast hash table low */
6602 +#define MacMiiAddr 0x14 /* MII address */
6603 +#define MacMiiData 0x18 /* MII data */
6604 +#define MacFlowControl 0x1C /* Flow control */
6605 +#define MacVlan1Tag 0x4C /* VLAN1 tag */
6606 +#define MacVlan2Tag 0x50 /* VLAN2 tag */
6609 +/***************************************************************/
6610 +/* DMA engine registers, base address is BAR+AE531X_DMA_OFFSET */
6611 +/***************************************************************/
6612 +#define DmaBusMode 0x00 /* CSR0 - Bus Mode */
6613 +#define DmaTxPollDemand 0x04 /* CSR1 - Transmit Poll Demand */
6614 +#define DmaRxPollDemand 0x08 /* CSR2 - Receive Poll Demand */
6615 +#define DmaRxBaseAddr 0x0C /* CSR3 - Receive list base address */
6616 +#define DmaTxBaseAddr 0x10 /* CSR4 - Transmit list base address */
6617 +#define DmaStatus 0x14 /* CSR5 - Dma status */
6618 +#define DmaControl 0x18 /* CSR6 - Dma control */
6619 +#define DmaIntrEnb 0x1C /* CSR7 - Interrupt enable */
6620 +#define DmaOverflowCnt 0x20 /* CSR8 - Missed Frame and Buff Overflow counter */
6621 +#define DmaTxCurrAddr 0x50 /* CSR20 - Current host transmit buffer address */
6622 +#define DmaRxCurrAddr 0x54 /* CSR21 - Current host receive buffer address */
6624 +/**********************************************************/
6625 +/* MAC Control register layout */
6626 +/**********************************************************/
6627 +#define MacFilterOff 0x80000000 /* Receive all incoming packets RW */
6628 +#define MacFilterOn 0 /* Receive filtered packets only 0 */
6629 +#define MacBigEndian 0x40000000 /* Big endian mode RW */
6630 +#define MacLittleEndian 0 /* Little endian 0 */
6631 +#define MacHeartBeatOff 0x10000000 /* Heartbeat signal qual disable RW*/
6632 +#define MacHeartBeatOn 0 /* Heartbeat signal qual enable 0 */
6633 +#define MacSelectSrl 0x08000000 /* Select SRL port RW */
6634 +#define MacSelectMii 0 /* Select MII port 0 */
6635 +#define MacDisableRxOwn 0x00800000 /* Disable receive own packets RW */
6636 +#define MacEnableRxOwn 0 /* Enable receive own packets 0 */
6637 +#define MacLoopbackExt 0x00400000 /* External loopback RW */
6638 +#define MacLoopbackInt 0x00200000 /* Internal loopback */
6639 +#define MacLoopbackOff 0 /* Normal mode 00 */
6640 +#define MacFullDuplex 0x00100000 /* Full duplex mode RW */
6641 +#define MacHalfDuplex 0 /* Half duplex mode 0 */
6642 +#define MacMulticastFilterOff 0x00080000 /* Pass all multicast packets RW */
6643 +#define MacMulticastFilterOn 0 /* Pass filtered mcast packets 0 */
6644 +#define MacPromiscuousModeOn 0x00040000 /* Receive all valid packets RW 1 */
6645 +#define MacPromiscuousModeOff 0 /* Receive filtered packets only */
6646 +#define MacFilterInverse 0x00020000 /* Inverse filtering RW */
6647 +#define MacFilterNormal 0 /* Normal filtering 0 */
6648 +#define MacBadFramesEnable 0x00010000 /* Pass bad frames RW */
6649 +#define MacBadFramesDisable 0 /* Do not pass bad frames 0 */
6650 +#define MacPerfectFilterOff 0x00008000 /* Hash filtering only RW */
6651 +#define MacPerfectFilterOn 0 /* Both perfect and hash filtering 0 */
6652 +#define MacHashFilterOn 0x00002000 /* perform hash filtering RW */
6653 +#define MacHashFilterOff 0 /* perfect filtering only 0 */
6654 +#define MacLateCollisionOn 0x00001000 /* Enable late collision control RW */
6655 +#define MacLateCollisionOff 0 /* Disable late collision control 0 */
6656 +#define MacBroadcastDisable 0x00000800 /* Disable reception of bcast frames RW */
6657 +#define MacBroadcastEnable 0 /* Enable broadcast frames 0 */
6658 +#define MacRetryDisable 0x00000400 /* Disable retransmission RW */
6659 +#define MacRetryEnable 0 /* Enable retransmission 0 */
6660 +#define MacPadStripEnable 0x00000100 /* Pad stripping enable RW */
6661 +#define MacPadStripDisable 0 /* Pad stripping disable 0 */
6662 +#define MacBackoff 0 /* Backoff Limit RW 00 */
6663 +#define MacDeferralCheckEnable 0x00000020 /* Deferral check enable RW */
6664 +#define MacDeferralCheckDisable 0 /* Deferral check disable 0 */
6665 +#define MacTxEnable 0x00000008 /* Transmitter enable RW */
6666 +#define MacTxDisable 0 /* Transmitter disable 0 */
6667 +#define MacRxEnable 0x00000004 /* Receiver enable RW */
6668 +#define MacRxDisable 0 /* Receiver disable 0 */
6671 +/**********************************************************/
6672 +/* MII address register layout */
6673 +/**********************************************************/
6674 +#define MiiDevMask 0x0000F800 /* MII device address */
6675 +#define MiiDevShift 11
6676 +#define MiiRegMask 0x000007C0 /* MII register */
6677 +#define MiiRegShift 6
6678 +#define MiiWrite 0x00000002 /* Write to register */
6679 +#define MiiRead 0 /* Read from register */
6680 +#define MiiBusy 0x00000001 /* MII interface is busy */
6682 +/**********************************************************/
6683 +/* MII Data register layout */
6684 +/**********************************************************/
6685 +#define MiiDataMask 0x0000FFFF /* MII Data */
6687 +/**********************************************************/
6688 +/* MAC flow control register layout */
6689 +/**********************************************************/
6690 +#define MacPauseTimeMask 0xFFFF0000 /* PAUSE TIME field in ctrl frame */
6691 +#define MacPauseTimeShift 15
6692 +#define MacControlFrameEnable 0x00000004 /* Enable pass ctrl frames to host */
6693 +#define MacControlFrameDisable 0 /* Do not pass ctrl frames to host */
6694 +#define MacFlowControlEnable 0x00000002 /* Enable flow control */
6695 +#define MacFlowControlDisable 0 /* Disable flow control */
6696 +#define MacSendPauseFrame 0x00000001 /* send pause frame */
6698 +/**********************************************************/
6699 +/* DMA bus mode register layout */
6700 +/**********************************************************/
6701 +#define DmaRxAlign16 0x01000000 /* Force all rx buffers to align on odd hw bndry */
6702 +#define DmaBigEndianDes 0x00100000 /* Big endian data buffer descriptors RW */
6703 +#define DmaLittleEndianDesc 0 /* Little endian data descriptors */
6704 +#define DmaBurstLength32 0x00002000 /* Dma burst length 32 RW */
6705 +#define DmaBurstLength16 0x00001000 /* Dma burst length 16 */
6706 +#define DmaBurstLength8 0x00000800 /* Dma burst length 8 */
6707 +#define DmaBurstLength4 0x00000400 /* Dma burst length 4 */
6708 +#define DmaBurstLength2 0x00000200 /* Dma burst length 2 */
6709 +#define DmaBurstLength1 0x00000100 /* Dma burst length 1 */
6710 +#define DmaBurstLength0 0x00000000 /* Dma burst length 0 */
6711 +#define DmaBigEndianData 0x00000080 /* Big endian data buffers RW */
6712 +#define DmaLittleEndianData 0 /* Little endian data buffers 0 */
6713 +#define DmaDescriptorSkip16 0x00000040 /* number of dwords to skip RW */
6714 +#define DmaDescriptorSkip8 0x00000020 /* between two unchained descriptors */
6715 +#define DmaDescriptorSkip4 0x00000010
6716 +#define DmaDescriptorSkip2 0x00000008
6717 +#define DmaDescriptorSkip1 0x00000004
6718 +#define DmaDescriptorSkip0 0
6719 +#define DmaReceivePriorityOff 0x00000002 /* equal rx and tx priorities RW */
6720 +#define DmaReceivePriorityOn 0 /* Rx has prioryty over Tx 0 */
6721 +#define DmaResetOn 0x00000001 /* Reset DMA engine RW */
6722 +#define DmaResetOff 0
6724 +/**********************************************************/
6725 +/* DMA Status register layout */
6726 +/**********************************************************/
6727 +#define DmaRxAbort 0x01000000 /* receiver bus abort R 0 */
6728 +#define DmaTxAbort 0x00800000 /* transmitter bus abort R 0 */
6729 +#define DmaTxState 0x00700000 /* Transmit process state R 000 */
6730 +#define DmaTxStopped 0x00000000 /* Stopped */
6731 +#define DmaTxFetching 0x00100000 /* Running - fetching the descriptor */
6732 +#define DmaTxWaiting 0x00200000 /* Running - waiting for end of transmission */
6733 +#define DmaTxReading 0x00300000 /* Running - reading the data from memory */
6734 +#define DmaTxSuspended 0x00600000 /* Suspended */
6735 +#define DmaTxClosing 0x00700000 /* Running - closing descriptor */
6736 +#define DmaRxState 0x000E0000 /* Receive process state 000 */
6737 +#define DmaRxStopped 0x00000000 /* Stopped */
6738 +#define DmaRxFetching 0x00020000 /* Running - fetching the descriptor */
6739 +#define DmaRxChecking 0x00040000 /* Running - checking for end of packet */
6740 +#define DmaRxWaiting 0x00060000 /* Running - waiting for packet */
6741 +#define DmaRxSuspended 0x00080000 /* Suspended */
6742 +#define DmaRxClosing 0x000A0000 /* Running - closing descriptor */
6743 +#define DmaRxFlushing 0x000C0000 /* Running - flushing the current frame */
6744 +#define DmaRxQueuing 0x000E0000 /* Running - queuing the recieve frame into host memory */
6745 +#define DmaIntNormal 0x00010000 /* Normal interrupt summary RW 0 */
6746 +#define DmaIntAbnormal 0x00008000 /* Abnormal interrupt summary RW 0 */
6747 +#define DmaIntEarlyRx 0x00004000 /* Early receive interrupt (Normal) RW 0 */
6748 +#define DmaIntBusError 0x00002000 /* Fatal bus error (Abnormal) RW 0 */
6749 +#define DmaIntEarlyTx 0x00000400 /* Early transmit interrupt RW 0 */
6750 +#define DmaIntRxStopped 0x00000100 /* Receive process stopped (Abnormal) RW 0 */
6751 +#define DmaIntRxNoBuffer 0x00000080 /* Receive buffer unavailable (Abnormal) RW 0*/
6752 +#define DmaIntRxCompleted 0x00000040 /* Completion of frame reception(Normal) RW 0*/
6753 +#define DmaIntTxUnderflow 0x00000020 /* Transmit underflow (Abnormal) RW 0 */
6754 +#define DmaIntTxJabber 0x00000008 /* Transmit Jabber Timeout (Abnormal) RW 0 */
6755 +#define DmaIntTxNoBuffer 0x00000004 /* Transmit buffer unavailable (Normal) RW 0*/
6756 +#define DmaIntTxStopped 0x00000002 /* Transmit process stopped (Abnormal) RW 0 */
6757 +#define DmaIntTxCompleted 0x00000001 /* Transmit completed (Normal) RW 0 */
6759 +/**********************************************************/
6760 +/* DMA control register layout */
6761 +/**********************************************************/
6762 +#define DmaStoreAndForward 0x00000000 /* Store and forward RW 0 */
6763 +#define DmaTxThreshCtl256 0x0000c000 /* Non-SF threshold is 256 words */
6764 +#define DmaTxThreshCtl128 0x00008000 /* Non-SF threshold is 128 words */
6765 +#define DmaTxThreshCtl064 0x00004000 /* Non-SF threshold is 64 words */
6766 +#define DmaTxThreshCtl032 0x00000000 /* Non-SF threshold is 32 words */
6767 +#define DmaTxStart 0x00002000 /* Start/Stop transmission RW 0 */
6768 +#define DmaTxSecondFrame 0x00000004 /* Operate on second frame RW 0 */
6769 +#define DmaRxStart 0x00000002 /* Start/Stop reception RW 0 */
6771 +/**********************************************************/
6772 +/* DMA interrupt enable register layout */
6773 +/**********************************************************/
6774 +#define DmaIeNormal DmaIntNormal /* Normal interrupt enable RW 0 */
6775 +#define DmaIeAbnormal DmaIntAbnormal /* Abnormal interrupt enable RW 0 */
6776 +#define DmaIeEarlyRx DmaIntEarlyRx /* Early receive interrupt enable RW 0 */
6777 +#define DmaIeBusError DmaIntBusError /* Fatal bus error enable RW 0 */
6778 +#define DmaIeEarlyTx DmaIntEarlyTx /* Early transmit interrupt enable RW 0 */
6779 +#define DmaIeRxStopped DmaIntRxStopped /* Receive process stopped enable RW 0 */
6780 +#define DmaIeRxNoBuffer DmaIntRxNoBuffer /* Receive buffer unavailable enable RW 0 */
6781 +#define DmaIeRxCompleted DmaIntRxCompleted /* Completion of frame reception enable RW 0 */
6782 +#define DmaIeTxUnderflow DmaIntTxUnderflow /* Transmit underflow enable RW 0 */
6783 +#define DmaIeTxJabber DmaIntTxJabber /* Transmit jabber timeout RW 0 */
6784 +#define DmaIeTxNoBuffer DmaIntTxNoBuffer /* Transmit buffer unavailable enable RW 0 */
6785 +#define DmaIeTxStopped DmaIntTxStopped /* Transmit process stopped enable RW 0 */
6786 +#define DmaIeTxCompleted DmaIntTxCompleted /* Transmit completed enable RW 0 */
6788 +/****************************************************************/
6789 +/* DMA Missed Frame and Buffer Overflow Counter register layout */
6790 +/****************************************************************/
6791 +#define DmaRxBufferMissedFrame 0xffff0000 /* cleared on read */
6792 +#define DmaMissedFrameShift 16
6793 +#define DmaRxBufferOverflowCnt 0x0000ffff /* cleared on read */
6794 +#define DmaMissedFrameCountMask 0x0000ffff
6796 +/**********************************************************/
6797 +/* DMA Engine descriptor layout */
6798 +/**********************************************************/
6799 +/* status word of DMA descriptor */
6800 +#define DescOwnByDma 0x80000000 /* Descriptor is owned by DMA engine */
6801 +#define DescFrameLengthMask 0x3FFF0000 /* Receive descriptor frame length */
6802 +#define DescFrameLengthShift 16
6803 +#define DescError 0x00008000 /* Error summary bit OR of following bits */
6804 +#define DescRxTruncated 0x00004000 /* Rx - no more descs for receive frame */
6805 +#define DescRxLengthError 0x00001000 /* Rx - frame size not matching with length field */
6806 +#define DescRxRunt 0x00000800 /* Rx - runt frame, damaged by a
6807 + collision or term before 64 bytes */
6808 +#define DescRxMulticast 0x00000400 /* Rx - received frame is multicast */
6809 +#define DescRxFirst 0x00000200 /* Rx - first descriptor of the frame */
6810 +#define DescRxLast 0x00000100 /* Rx - last descriptor of the frame */
6811 +#define DescRxLongFrame 0x00000080 /* Rx - frame is longer than 1518 bytes */
6812 +#define DescRxLateColl 0x00000040 /* Rx - frame was damaged by a late collision */
6813 +#define DescRxFrameEther 0x00000020 /* Rx - Frame type Ethernet 802.3*/
6814 +#define DescRxMiiError 0x00000008 /* Rx - error reported by MII interface */
6815 +#define DescRxDribbling 0x00000004 /* Rx - frame contains noninteger multiple of 8 bits */
6816 +#define DescRxCrc 0x00000002 /* Rx - CRC error */
6817 +#define DescTxTimeout 0x00004000 /* Tx - Transmit jabber timeout */
6818 +#define DescTxLostCarrier 0x00000800 /* Tx - carrier lost during tramsmission */
6819 +#define DescTxNoCarrier 0x00000400 /* Tx - no carrier signal from tranceiver */
6820 +#define DescTxLateCollision 0x00000200 /* Tx - transmission aborted due to collision */
6821 +#define DescTxExcCollisions 0x00000100 /* Tx - transmission aborted after 16 collisions */
6822 +#define DescTxHeartbeatFail 0x00000080 /* Tx - heartbeat collision check failure */
6823 +#define DescTxCollMask 0x00000078 /* Tx - Collision count */
6824 +#define DescTxCollShift 3
6825 +#define DescTxExcDeferral 0x00000004 /* Tx - excessive deferral */
6826 +#define DescTxUnderflow 0x00000002 /* Tx - late data arrival from memory */
6827 +#define DescTxDeferred 0x00000001 /* Tx - frame transmision deferred */
6829 +/* length word of DMA descriptor */
6830 +#define DescTxIntEnable 0x80000000 /* Tx - interrupt on completion */
6831 +#define DescTxLast 0x40000000 /* Tx - Last segment of the frame */
6832 +#define DescTxFirst 0x20000000 /* Tx - First segment of the frame */
6833 +#define DescTxDisableCrc 0x04000000 /* Tx - Add CRC disabled (first segment only) */
6834 +#define DescEndOfRing 0x02000000 /* End of descriptors ring */
6835 +#define DescChain 0x01000000 /* Second buffer address is chain address */
6836 +#define DescTxDisablePadd 0x00800000 /* disable padding */
6837 +#define DescSize2Mask 0x003FF800 /* Buffer 2 size */
6838 +#define DescSize2Shift 11
6839 +#define DescSize1Mask 0x000007FF /* Buffer 1 size */
6840 +#define DescSize1Shift 0
6842 +/**********************************************************/
6843 +/* Initial register values */
6844 +/**********************************************************/
6845 +/* Full-duplex mode with perfect filter on */
6846 +#define MacControlInitFdx \
6848 + | MacLittleEndian \
6849 + | MacHeartBeatOn \
6851 + | MacEnableRxOwn \
6852 + | MacLoopbackOff \
6854 + | MacMulticastFilterOn \
6855 + | MacPromiscuousModeOff \
6856 + | MacFilterNormal \
6857 + | MacBadFramesDisable \
6858 + | MacPerfectFilterOn \
6859 + | MacHashFilterOff \
6860 + | MacLateCollisionOff \
6861 + | MacBroadcastEnable \
6862 + | MacRetryEnable \
6863 + | MacPadStripDisable \
6864 + | MacDeferralCheckDisable \
6868 +/* Full-duplex mode */
6869 +#define MacFlowControlInitFdx \
6870 + ( MacControlFrameDisable \
6871 + | MacFlowControlEnable)
6873 +/* Half-duplex mode with perfect filter on */
6874 +#define MacControlInitHdx \
6876 + | MacLittleEndian \
6877 + | MacHeartBeatOn \
6879 + | MacDisableRxOwn \
6880 + | MacLoopbackOff \
6882 + | MacMulticastFilterOn \
6883 + | MacPromiscuousModeOff \
6884 + | MacFilterNormal \
6885 + | MacBadFramesDisable \
6886 + | MacPerfectFilterOn \
6887 + | MacHashFilterOff \
6888 + | MacLateCollisionOff \
6889 + | MacBroadcastEnable \
6890 + | MacRetryEnable \
6891 + | MacPadStripDisable \
6892 + | MacDeferralCheckDisable \
6896 +/* Half-duplex mode */
6897 +#define MacFlowControlInitHdx \
6898 + ( MacControlFrameDisable \
6899 + | MacFlowControlDisable)
6901 +/* Bus Mode Rx odd half word align */
6902 +#define DmaBusModeInit \
6903 + ( DmaLittleEndianDesc \
6905 + | DmaBurstLength32 \
6906 + | DmaBigEndianData \
6907 + | DmaDescriptorSkip1 \
6908 + | DmaReceivePriorityOn \
6911 +#define DmaControlInit (DmaStoreAndForward)
6913 +/* Interrupt groups */
6914 +#define DmaIntEnable \
6917 + | DmaIntBusError \
6918 + | DmaIntRxStopped \
6919 + | DmaIntRxNoBuffer \
6920 + | DmaIntRxCompleted \
6921 + | DmaIntTxUnderflow \
6922 + | DmaIntTxStopped)
6924 +#define DmaIntDisable 0
6926 +#define DmaAllIntCauseMask \
6930 + | DmaIntBusError \
6932 + | DmaIntRxStopped \
6933 + | DmaIntRxNoBuffer \
6934 + | DmaIntRxCompleted \
6935 + | DmaIntTxUnderflow \
6936 + | DmaIntTxJabber \
6937 + | DmaIntTxNoBuffer \
6938 + | DmaIntTxStopped \
6939 + | DmaIntTxCompleted)
6941 +#define UnhandledIntrMask \
6942 + (DmaAllIntCauseMask \
6943 + & ~(DmaIntRxNoBuffer \
6944 + | DmaIntTxStopped \
6945 + | DmaIntTxJabber \
6946 + | DmaIntTxUnderflow \
6947 + | DmaIntBusError \
6948 + | DmaIntRxCompleted ))
6950 +#define DescRxErrors \
6951 + (DescRxTruncated \
6953 + | DescRxLateColl \
6954 + | DescRxMiiError \
6957 +#define DescTxErrors \
6959 + | DescTxLateCollision \
6960 + | DescTxExcCollisions \
6961 + | DescTxExcDeferral \
6962 + | DescTxUnderflow)
6964 +/**********************************************************/
6965 +/* Descriptor Layout */
6966 +/**********************************************************/
6967 +#define AE531X_DESC_STATUS 0x00 /* Status offset */
6968 +#define AE531X_DESC_CTRLEN 0x04 /* Control and Length offset */
6969 +#define AE531X_DESC_BUFPTR 0x08 /* Buffer pointer offset */
6970 +#define AE531X_DESC_LNKBUF 0x0c /* Link field offset, or ptr to 2nd buf */
6971 +#define AE531X_DESC_SWPTR 0x10 /* OS-Dependent software pointer */
6973 +#define AE531X_DESC_SIZE 0x10 /* 4 words, 16 bytes */
6974 +#define AE531X_QUEUE_ELE_SIZE 0x14 /* with software pointer extension */
6976 +/* Accessors to the dma descriptor fields */
6977 +#define AE531X_DESC_STATUS_GET(ptr) \
6978 + *(volatile UINT32 *)((UINT32)(ptr) + AE531X_DESC_STATUS)
6980 +#define AE531X_DESC_STATUS_SET(ptr, val) \
6981 + AE531X_DESC_STATUS_GET(ptr) = (val)
6983 +#define AE531X_DESC_CTRLEN_GET(ptr) \
6984 + *(volatile UINT32 *)((UINT32)ptr + AE531X_DESC_CTRLEN)
6986 +#define AE531X_DESC_CTRLEN_SET(ptr, val) \
6987 + AE531X_DESC_CTRLEN_GET(ptr) = (val)
6989 +#define AE531X_DESC_BUFPTR_GET(ptr) \
6990 + *(volatile UINT32 *)((UINT32)ptr + AE531X_DESC_BUFPTR)
6992 +#define AE531X_DESC_BUFPTR_SET(ptr,val) \
6993 + AE531X_DESC_BUFPTR_GET(ptr) = (UINT32)(val)
6995 +#define AE531X_DESC_LNKBUF_GET(ptr) \
6996 + *(volatile UINT32 *)((UINT32)ptr + AE531X_DESC_LNKBUF)
6998 +#define AE531X_DESC_LNKBUF_SET(ptr, val) \
6999 + AE531X_DESC_LNKBUF_GET(ptr) = (val)
7001 +#define AE531X_DESC_SWPTR_GET(ptr) \
7002 + (void *)(*(volatile UINT32 *) ((UINT32)ptr + AE531X_DESC_SWPTR))
7004 +#define AE531X_DESC_SWPTR_SET(ptr,val) \
7005 + AE531X_DESC_SWPTR_GET(ptr) = (void *)(val)
7007 +/* Get size of Rx data from desc, in bytes */
7008 +#define AE531X_DESC_STATUS_RX_SIZE(x) \
7009 + (((x) & DescFrameLengthMask) >> DescFrameLengthShift)
7011 +#endif /* _AE531XREG_H_ */
7012 diff -urN linux-mips-orig/drivers/net/ath/ar531x.h linux-mips-new/drivers/net/ath/ar531x.h
7013 --- linux-mips-orig/drivers/net/ath/ar531x.h 1970-01-01 01:00:00.000000000 +0100
7014 +++ linux-mips-new/drivers/net/ath/ar531x.h 2005-12-31 12:33:57.676538368 +0000
7017 + * This file is subject to the terms and conditions of the GNU General Public
7018 + * License. See the file "COPYING" in the main directory of this archive
7019 + * for more details.
7021 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
7028 +#ifndef CONFIG_AR5315
7030 +#include <asm/addrspace.h>
7033 +#define AR531X_WLAN0 0x18000000
7034 +#define AR531X_WLAN1 0x18500000
7035 +#define AR531X_ENET0 0x18100000
7036 +#define AR531X_ENET1 0x18200000
7037 +#define AR531X_SDRAMCTL 0x18300000
7038 +#define AR531X_FLASHCTL 0x18400000
7039 +#define AR531X_APBBASE 0x1c000000
7040 +#define AR531X_FLASH 0x1e000000
7043 + * AR531X_NUM_ENET_MAC defines the number of ethernet MACs that
7044 + * should be considered available. The AR5312 supports 2 enet MACS,
7045 + * even though many reference boards only actually use 1 of them
7046 + * (i.e. Only MAC 0 is actually connected to an enet PHY or PHY switch.
7047 + * The AR2312 supports 1 enet MAC.
7049 +#define AR531X_NUM_ENET_MAC 2
7052 + * Need these defines to determine true number of ethernet MACs
7054 +#define AR5212_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
7055 +#define AR5212_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
7056 +#define AR5212_AR2313_REV8 0x0058 /* AR2313 WMAC (AP43-030) */
7057 +#define AR531X_RADIO_MASK_OFF 0xc8
7058 +#define AR531X_RADIO0_MASK 0x0003
7059 +#define AR531X_RADIO1_MASK 0x000c
7060 +#define AR531X_RADIO1_S 2
7063 + * AR531X_NUM_WMAC defines the number of Wireless MACs that\
7064 + * should be considered available.
7066 +#define AR531X_NUM_WMAC 2
7068 +/* Reset/Timer Block Address Map */
7069 +#define AR531X_RESETTMR (AR531X_APBBASE + 0x3000)
7070 +#define AR531X_TIMER (AR531X_RESETTMR + 0x0000) /* countdown timer */
7071 +#define AR531X_WD_CTRL (AR531X_RESETTMR + 0x0008) /* watchdog cntrl */
7072 +#define AR531X_WD_TIMER (AR531X_RESETTMR + 0x000c) /* watchdog timer */
7073 +#define AR531X_ISR (AR531X_RESETTMR + 0x0010) /* Intr Status Reg */
7074 +#define AR531X_IMR (AR531X_RESETTMR + 0x0014) /* Intr Mask Reg */
7075 +#define AR531X_RESET (AR531X_RESETTMR + 0x0020)
7076 +#define AR5312_CLOCKCTL1 (AR531X_RESETTMR + 0x0064)
7077 +#define AR5312_SCRATCH (AR531X_RESETTMR + 0x006c)
7078 +#define AR531X_PROCADDR (AR531X_RESETTMR + 0x0070)
7079 +#define AR531X_PROC1 (AR531X_RESETTMR + 0x0074)
7080 +#define AR531X_DMAADDR (AR531X_RESETTMR + 0x0078)
7081 +#define AR531X_DMA1 (AR531X_RESETTMR + 0x007c)
7082 +#define AR531X_ENABLE (AR531X_RESETTMR + 0x0080) /* interface enb */
7083 +#define AR531X_REV (AR531X_RESETTMR + 0x0090) /* revision */
7085 +/* AR531X_WD_CTRL register bit field definitions */
7086 +#define AR531X_WD_CTRL_IGNORE_EXPIRATION 0x0000
7087 +#define AR531X_WD_CTRL_NMI 0x0001
7088 +#define AR531X_WD_CTRL_RESET 0x0002
7090 +/* AR531X_ISR register bit field definitions */
7091 +#define AR531X_ISR_NONE 0x0000
7092 +#define AR531X_ISR_TIMER 0x0001
7093 +#define AR531X_ISR_AHBPROC 0x0002
7094 +#define AR531X_ISR_AHBDMA 0x0004
7095 +#define AR531X_ISR_GPIO 0x0008
7096 +#define AR531X_ISR_UART0 0x0010
7097 +#define AR531X_ISR_UART0DMA 0x0020
7098 +#define AR531X_ISR_WD 0x0040
7099 +#define AR531X_ISR_LOCAL 0x0080
7101 +/* AR531X_RESET register bit field definitions */
7102 +#define AR531X_RESET_SYSTEM 0x00000001 /* cold reset full system */
7103 +#define AR531X_RESET_PROC 0x00000002 /* cold reset MIPS core */
7104 +#define AR531X_RESET_WLAN0 0x00000004 /* cold reset WLAN MAC and BB */
7105 +#define AR531X_RESET_EPHY0 0x00000008 /* cold reset ENET0 phy */
7106 +#define AR531X_RESET_EPHY1 0x00000010 /* cold reset ENET1 phy */
7107 +#define AR531X_RESET_ENET0 0x00000020 /* cold reset ENET0 mac */
7108 +#define AR531X_RESET_ENET1 0x00000040 /* cold reset ENET1 mac */
7109 +#define AR531X_RESET_UART0 0x00000100 /* cold reset UART0 (high speed) */
7110 +#define AR531X_RESET_WLAN1 0x00000200 /* cold reset WLAN MAC/BB */
7111 +#define AR531X_RESET_APB 0x00000400 /* cold reset APB (ar5312) */
7112 +#define AR531X_RESET_WARM_PROC 0x00001000 /* warm reset MIPS core */
7113 +#define AR531X_RESET_WARM_WLAN0_MAC 0x00002000 /* warm reset WLAN0 MAC */
7114 +#define AR531X_RESET_WARM_WLAN0_BB 0x00004000 /* warm reset WLAN0 BaseBand */
7115 +#define AR531X_RESET_NMI 0x00010000 /* send an NMI to the processor */
7116 +#define AR531X_RESET_WARM_WLAN1_MAC 0x00020000 /* warm reset WLAN1 mac */
7117 +#define AR531X_RESET_WARM_WLAN1_BB 0x00040000 /* warm reset WLAN1 baseband */
7118 +#define AR531X_RESET_LOCAL_BUS 0x00080000 /* reset local bus */
7119 +#define AR531X_RESET_WDOG 0x00100000 /* last reset was a watchdog */
7121 +#define AR531X_RESET_WMAC0_BITS \
7122 + AR531X_RESET_WLAN0 |\
7123 + AR531X_RESET_WARM_WLAN0_MAC |\
7124 + AR531X_RESET_WARM_WLAN0_BB
7126 +#define AR531X_RESERT_WMAC1_BITS \
7127 + AR531X_RESET_WLAN1 |\
7128 + AR531X_RESET_WARM_WLAN1_MAC |\
7129 + AR531X_RESET_WARM_WLAN1_BB
7131 +/* AR5312_CLOCKCTL1 register bit field definitions */
7132 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
7133 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
7134 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
7135 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
7136 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
7138 +/* Valid for AR5312 and AR2312 */
7139 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
7140 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
7141 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
7142 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
7143 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
7145 +/* Valid for AR2313 */
7146 +#define AR2313_CLOCKCTL1_PREDIVIDE_MASK 0x00003000
7147 +#define AR2313_CLOCKCTL1_PREDIVIDE_SHIFT 12
7148 +#define AR2313_CLOCKCTL1_MULTIPLIER_MASK 0x001f0000
7149 +#define AR2313_CLOCKCTL1_MULTIPLIER_SHIFT 16
7150 +#define AR2313_CLOCKCTL1_DOUBLER_MASK 0x00000000
7153 +/* AR531X_ENABLE register bit field definitions */
7154 +#define AR531X_ENABLE_WLAN0 0x0001
7155 +#define AR531X_ENABLE_ENET0 0x0002
7156 +#define AR531X_ENABLE_ENET1 0x0004
7157 +#define AR531X_ENABLE_UART_AND_WLAN1_PIO 0x0008 /* UART, and WLAN1 PIOs */
7158 +#define AR531X_ENABLE_WLAN1_DMA 0x0010 /* WLAN1 DMAs */
7159 +#define AR531X_ENABLE_WLAN1 \
7160 + (AR531X_ENABLE_UART_AND_WLAN1_PIO | AR531X_ENABLE_WLAN1_DMA)
7162 +/* AR531X_REV register bit field definitions */
7163 +#define AR531X_REV_WMAC_MAJ 0xf000
7164 +#define AR531X_REV_WMAC_MAJ_S 12
7165 +#define AR531X_REV_WMAC_MIN 0x0f00
7166 +#define AR531X_REV_WMAC_MIN_S 8
7167 +#define AR531X_REV_MAJ 0x00f0
7168 +#define AR531X_REV_MAJ_S 4
7169 +#define AR531X_REV_MIN 0x000f
7170 +#define AR531X_REV_MIN_S 0
7171 +#define AR531X_REV_CHIP (REV_MAJ|REV_MIN)
7173 +/* Major revision numbers, bits 7..4 of Revision ID register */
7174 +#define AR531X_REV_MAJ_AR5312 0x4
7175 +#define AR531X_REV_MAJ_AR2313 0x5
7177 +/* Minor revision numbers, bits 3..0 of Revision ID register */
7178 +#define AR5312_REV_MIN_DUAL 0x0 /* Dual WLAN version */
7179 +#define AR5312_REV_MIN_SINGLE 0x1 /* Single WLAN version */
7181 +/* AR531X_FLASHCTL register bit field definitions */
7182 +#define FLASHCTL_IDCY 0x0000000f /* Idle cycle turn around time */
7183 +#define FLASHCTL_IDCY_S 0
7184 +#define FLASHCTL_WST1 0x000003e0 /* Wait state 1 */
7185 +#define FLASHCTL_WST1_S 5
7186 +#define FLASHCTL_RBLE 0x00000400 /* Read byte lane enable */
7187 +#define FLASHCTL_WST2 0x0000f800 /* Wait state 2 */
7188 +#define FLASHCTL_WST2_S 11
7189 +#define FLASHCTL_AC 0x00070000 /* Flash address check (added) */
7190 +#define FLASHCTL_AC_S 16
7191 +#define FLASHCTL_AC_128K 0x00000000
7192 +#define FLASHCTL_AC_256K 0x00010000
7193 +#define FLASHCTL_AC_512K 0x00020000
7194 +#define FLASHCTL_AC_1M 0x00030000
7195 +#define FLASHCTL_AC_2M 0x00040000
7196 +#define FLASHCTL_AC_4M 0x00050000
7197 +#define FLASHCTL_AC_8M 0x00060000
7198 +#define FLASHCTL_AC_RES 0x00070000 /* 16MB is not supported */
7199 +#define FLASHCTL_E 0x00080000 /* Flash bank enable (added) */
7200 +#define FLASHCTL_BUSERR 0x01000000 /* Bus transfer error status flag */
7201 +#define FLASHCTL_WPERR 0x02000000 /* Write protect error status flag */
7202 +#define FLASHCTL_WP 0x04000000 /* Write protect */
7203 +#define FLASHCTL_BM 0x08000000 /* Burst mode */
7204 +#define FLASHCTL_MW 0x30000000 /* Memory width */
7205 +#define FLASHCTL_MWx8 0x00000000 /* Memory width x8 */
7206 +#define FLASHCTL_MWx16 0x10000000 /* Memory width x16 */
7207 +#define FLASHCTL_MWx32 0x20000000 /* Memory width x32 (not supported) */
7208 +#define FLASHCTL_ATNR 0x00000000 /* Access type == no retry */
7209 +#define FLASHCTL_ATR 0x80000000 /* Access type == retry every */
7210 +#define FLASHCTL_ATR4 0xc0000000 /* Access type == retry every 4 */
7212 +/* ARM Flash Controller -- 3 flash banks with either x8 or x16 devices. */
7213 +#define AR531X_FLASHCTL0 (AR531X_FLASHCTL + 0x00)
7214 +#define AR531X_FLASHCTL1 (AR531X_FLASHCTL + 0x04)
7215 +#define AR531X_FLASHCTL2 (AR531X_FLASHCTL + 0x08)
7217 +/* ARM SDRAM Controller -- just enough to determine memory size */
7218 +#define AR531X_MEM_CFG1 (AR531X_SDRAMCTL + 0x04)
7219 +#define MEM_CFG1_AC0 0x00000700 /* bank 0: SDRAM addr check (added) */
7220 +#define MEM_CFG1_AC0_S 8
7221 +#define MEM_CFG1_AC1 0x00007000 /* bank 1: SDRAM addr check (added) */
7222 +#define MEM_CFG1_AC1_S 12
7224 +/* GPIO Address Map */
7225 +#define AR531X_GPIO (AR531X_APBBASE + 0x2000)
7226 +#define AR531X_GPIO_DO (AR531X_GPIO + 0x00) /* output register */
7227 +#define AR531X_GPIO_DI (AR531X_GPIO + 0x04) /* intput register */
7228 +#define AR531X_GPIO_CR (AR531X_GPIO + 0x08) /* control register */
7230 +/* GPIO Control Register bit field definitions */
7231 +#define GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
7232 +#define GPIO_CR_O(x) (0 << (x)) /* mask for output */
7233 +#define GPIO_CR_I(x) (1 << (x)) /* mask for input */
7234 +#define GPIO_CR_INT(x) (1 << ((x)+8)) /* mask for interrupt */
7235 +#define GPIO_CR_UART(x) (1 << ((x)+16)) /* uart multiplex */
7238 +typedef unsigned int AR531X_REG;
7240 +#define sysRegRead(phys) \
7241 + (*(volatile AR531X_REG *)PHYS_TO_K1(phys))
7243 +#define sysRegWrite(phys, val) \
7244 + ((*(volatile AR531X_REG *)PHYS_TO_K1(phys)) = (val))
7248 + * This is board-specific data that is stored in a "fixed" location in flash.
7249 + * It is shared across operating systems, so it should not be changed lightly.
7250 + * The main reason we need it is in order to extract the ethernet MAC
7253 +struct ar531x_boarddata {
7254 + u32 magic; /* board data is valid */
7255 +#define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
7256 + u16 cksum; /* checksum (starting with BD_REV 2) */
7257 + u16 rev; /* revision of this struct */
7259 + char boardName[64]; /* Name of board */
7260 + u16 major; /* Board major number */
7261 + u16 minor; /* Board minor number */
7262 + u32 config; /* Board configuration */
7263 +#define BD_ENET0 0x00000001 /* ENET0 is stuffed */
7264 +#define BD_ENET1 0x00000002 /* ENET1 is stuffed */
7265 +#define BD_UART1 0x00000004 /* UART1 is stuffed */
7266 +#define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
7267 +#define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
7268 +#define BD_SYSLED 0x00000020 /* System LED stuffed */
7269 +#define BD_EXTUARTCLK 0x00000040 /* External UART clock */
7270 +#define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
7271 +#define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
7272 +#define BD_WLAN0 0x00000200 /* Enable WLAN0 */
7273 +#define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
7274 +#define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
7275 +#define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
7276 +#define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
7277 +#define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
7278 +#define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
7279 +#define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
7280 +#define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
7281 + u16 resetConfigGpio; /* Reset factory GPIO pin */
7282 + u16 sysLedGpio; /* System LED GPIO pin */
7284 + u32 cpuFreq; /* CPU core frequency in Hz */
7285 + u32 sysFreq; /* System frequency in Hz */
7286 + u32 cntFreq; /* Calculated C0_COUNT frequency */
7292 + u16 pciId; /* Pseudo PCIID for common code */
7293 + u16 memCap; /* cap bank1 in MB */
7296 + u8 wlan1Mac[6]; /* (ar5212) */
7302 + * Add support for Cobra
7304 + * AR531XPLUSreg.h Register definitions for Atheros AR5311 and AR5312 chipsets.
7305 + * - WLAN registers are listed in
7306 + * hal/ar5211/ar5211Reg.h
7307 + * hal/ar5212/ar5212Reg.h
7308 + * - Ethernet registers are listed in ar531xenet.h
7309 + * - Standard UART is 16550 compatible.
7316 +#define AR531XPLUS_SDRAM0 0x00000000 /* DRAM */
7317 +#define AR531XPLUS_SPI_READ 0x08000000 /* SPI FLASH */
7318 +#define AR531XPLUS_WLAN0 0xB0000000 /* Wireless MMR */
7319 +#define AR531XPLUS_PCI 0xB0100000 /* PCI MMR */
7320 +#define AR531XPLUS_SDRAMCTL 0xB0300000 /* SDRAM MMR */
7321 +#define AR531XPLUS_LOCAL 0xB0400000 /* LOCAL BUS MMR */
7322 +#define AR531XPLUS_ENET0 0xB0500000 /* ETHERNET MMR */
7323 +#define AR531XPLUS_DSLBASE 0xB1000000 /* RESET CONTROL MMR */
7324 +#define AR531XPLUS_UART0 0xB1100003 /* UART MMR */
7325 +#define AR531XPLUS_SPI 0xB1300000 /* SPI FLASH MMR */
7326 +#define AR531XPLUS_FLASHBT 0xBfc00000 /* ro boot alias to FLASH */
7327 +#define AR531XPLUS_RAM1 0x40000000 /* ram alias */
7328 +#define AR531XPLUS_PCIEXT 0x80000000 /* pci external */
7329 +#define AR531XPLUS_RAM2 0xc0000000 /* ram alias */
7330 +#define AR531XPLUS_RAM3 0xe0000000 /* ram alias */
7332 +#define AR531X_ENET0 AR531XPLUS_ENET0
7333 +#define AR531X_ENET1 0
7337 +#define AR531XPLUS_COLD_RESET (AR531XPLUS_DSLBASE + 0x0000)
7340 +#define RESET_COLD_AHB 0x00000001
7341 +#define RESET_COLD_APB 0x00000002
7342 +#define RESET_COLD_CPU 0x00000004
7343 +#define RESET_COLD_CPUWARM 0x00000008
7344 +#define RESET_SYSTEM (RESET_COLD_CPU | RESET_COLD_APB | RESET_COLD_AHB) /* full system */
7348 +#define AR531XPLUS_RESET (AR531XPLUS_DSLBASE + 0x0004)
7349 +#define AR531X_RESET AR531XPLUS_RESET
7351 +#define RESET_WARM_WLAN0_MAC 0x00000001 /* warm reset WLAN0 MAC */
7352 +#define RESET_WARM_WLAN0_BB 0x00000002 /* warm reset WLAN0 BaseBand */
7353 +#define RESET_MPEGTS_RSVD 0x00000004 /* warm reset MPEG-TS */
7354 +#define RESET_PCIDMA 0x00000008 /* warm reset PCI ahb/dma */
7355 +#define RESET_MEMCTL 0x00000010 /* warm reset memory controller */
7356 +#define RESET_LOCAL 0x00000020 /* warm reset local bus */
7357 +#define RESET_I2C_RSVD 0x00000040 /* warm reset I2C bus */
7358 +#define RESET_SPI 0x00000080 /* warm reset SPI interface */
7359 +#define RESET_UART0 0x00000100 /* warm reset UART0 */
7360 +#define RESET_IR_RSVD 0x00000200 /* warm reset IR interface */
7361 +#define RESET_EPHY0 0x00000400 /* cold reset ENET0 phy */
7362 +#define RESET_ENET0 0x00000800 /* cold reset ENET0 mac */
7364 +#define AR531X_RESET_ENET0 RESET_ENET0
7365 +#define AR531X_RESET_EPHY0 RESET_EPHY0
7366 +#define AR531X_RESET_ENET1 0
7367 +#define AR531X_RESET_EPHY1 0
7370 + * AHB master arbitration control
7372 +#define AR531XPLUS_AHB_ARB_CTL (AR531XPLUS_DSLBASE + 0x0008)
7374 +#define ARB_CPU 0x00000001 /* CPU, default */
7375 +#define ARB_WLAN 0x00000002 /* WLAN */
7376 +#define ARB_MPEGTS_RSVD 0x00000004 /* MPEG-TS */
7377 +#define ARB_LOCAL 0x00000008 /* LOCAL */
7378 +#define ARB_PCI 0x00000010 /* PCI */
7379 +#define ARB_ETHERNET 0x00000020 /* Ethernet */
7380 +#define ARB_RETRY 0x00000100 /* retry policy, debug only */
7385 +#define AR531XPLUS_ENDIAN_CTL (AR531XPLUS_DSLBASE + 0x000c)
7387 +#define CONFIG_AHB 0x00000001 /* EC - AHB bridge endianess */
7388 +#define CONFIG_WLAN 0x00000002 /* WLAN byteswap */
7389 +#define CONFIG_MPEGTS_RSVD 0x00000004 /* MPEG-TS byteswap */
7390 +#define CONFIG_PCI 0x00000008 /* PCI byteswap */
7391 +#define CONFIG_MEMCTL 0x00000010 /* Memory controller endianess */
7392 +#define CONFIG_LOCAL 0x00000020 /* Local bus byteswap */
7393 +#define CONFIG_ETHERNET 0x00000040 /* Ethernet byteswap */
7395 +#define CONFIG_MERGE 0x00000200 /* CPU write buffer merge */
7396 +#define CONFIG_CPU 0x00000400 /* CPU big endian */
7397 +#define CONFIG_PCIAHB 0x00000800
7398 +#define CONFIG_PCIAHB_BRIDGE 0x00001000
7399 +#define CONFIG_SPI 0x00008000 /* SPI byteswap */
7400 +#define CONFIG_CPU_DRAM 0x00010000
7401 +#define CONFIG_CPU_PCI 0x00020000
7402 +#define CONFIG_CPU_MMR 0x00040000
7403 +#define CONFIG_BIG 0x00000400
7409 +#define AR531XPLUS_NMI_CTL (AR531XPLUS_DSLBASE + 0x0010)
7414 + * Revision Register - Initial value is 0x3010 (WMAC 3.0, AR531X 1.0).
7416 +#define AR531XPLUS_SREV (AR531XPLUS_DSLBASE + 0x0014)
7418 +#define AR531X_REV AR531XPLUS_SREV
7420 +#define REV_MAJ 0x00f0
7421 +#define REV_MAJ_S 4
7422 +#define REV_MIN 0x000f
7423 +#define REV_MIN_S 0
7424 +#define REV_CHIP (REV_MAJ|REV_MIN)
7426 +#define AR531X_REV_MAJ REV_MAJ
7427 +#define AR531X_REV_MAJ_S REV_MAJ_S
7428 +#define AR531X_REV_MIN REV_MIN
7429 +#define AR531X_REV_MIN_S REV_MIN_S
7430 +#define REV_CHIP (REV_MAJ|REV_MIN)
7432 + * Need these defines to determine true number of ethernet MACs
7434 +#define AR5212_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
7435 +#define AR5212_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
7436 +#define AR5212_AR2313_REV8 0x0058 /* AR2313 WMAC (AP43-030) */
7437 +#define AR531X_RADIO_MASK_OFF 0xc8
7438 +#define AR531X_RADIO0_MASK 0x0003
7439 +#define AR531X_RADIO1_MASK 0x000c
7440 +#define AR531X_RADIO1_S 2
7442 +/* Major revision numbers, bits 7..4 of Revision ID register */
7443 +#define AR531X_REV_MAJ_AR5312 0x4
7444 +#define AR531X_REV_MAJ_AR2313 0x5
7447 + * AR531X_NUM_ENET_MAC defines the number of ethernet MACs that
7448 + * should be considered available. The AR5312 supports 2 enet MACS,
7449 + * even though many reference boards only actually use 1 of them
7450 + * (i.e. Only MAC 0 is actually connected to an enet PHY or PHY switch.
7451 + * The AR2312 supports 1 enet MAC.
7453 +#define AR531X_NUM_ENET_MAC 1
7456 + * Interface Enable
7458 +#define AR531XPLUS_IF_CTL (AR531XPLUS_DSLBASE + 0x0018)
7460 +#define IF_MASK 0x00000007
7461 +#define IF_DISABLED 0
7463 +#define IF_TS_LOCAL 2
7464 +#define IF_ALL 3 /* only for emulation with separate pins */
7465 +#define IF_LOCAL_HOST 0x00000008
7466 +#define IF_PCI_HOST 0x00000010
7467 +#define IF_PCI_INTR 0x00000020
7468 +#define IF_PCI_CLK_MASK 0x00030000
7469 +#define IF_PCI_CLK_INPUT 0
7470 +#define IF_PCI_CLK_OUTPUT_LOW 1
7471 +#define IF_PCI_CLK_OUTPUT_CLK 2
7472 +#define IF_PCI_CLK_OUTPUT_HIGH 3
7473 +#define IF_PCI_CLK_SHIFT 16
7476 +/* Major revision numbers, bits 7..4 of Revision ID register */
7477 +#define REV_MAJ_AR5311 0x01
7478 +#define REV_MAJ_AR5312 0x04
7479 +#define REV_MAJ_AR5315 0x0B
7482 + * APB Interrupt control
7485 +#define AR531XPLUS_ISR (AR531XPLUS_DSLBASE + 0x0020)
7486 +#define AR531XPLUS_IMR (AR531XPLUS_DSLBASE + 0x0024)
7487 +#define AR531XPLUS_GISR (AR531XPLUS_DSLBASE + 0x0028)
7489 +#define ISR_UART0 0x0001 /* high speed UART */
7490 +#define ISR_I2C_RSVD 0x0002 /* I2C bus */
7491 +#define ISR_SPI 0x0004 /* SPI bus */
7492 +#define ISR_AHB 0x0008 /* AHB error */
7493 +#define ISR_APB 0x0010 /* APB error */
7494 +#define ISR_TIMER 0x0020 /* timer */
7495 +#define ISR_GPIO 0x0040 /* GPIO */
7496 +#define ISR_WD 0x0080 /* watchdog */
7497 +#define ISR_IR_RSVD 0x0100 /* IR */
7499 +#define IMR_UART0 ISR_UART0
7500 +#define IMR_I2C_RSVD ISR_I2C_RSVD
7501 +#define IMR_SPI ISR_SPI
7502 +#define IMR_AHB ISR_AHB
7503 +#define IMR_APB ISR_APB
7504 +#define IMR_TIMER ISR_TIMER
7505 +#define IMR_GPIO ISR_GPIO
7506 +#define IMR_WD ISR_WD
7507 +#define IMR_IR_RSVD ISR_IR_RSVD
7509 +#define GISR_MISC 0x0001
7510 +#define GISR_WLAN0 0x0002
7511 +#define GISR_MPEGTS_RSVD 0x0004
7512 +#define GISR_LOCALPCI 0x0008
7513 +#define GISR_WMACPOLL 0x0010
7514 +#define GISR_TIMER 0x0020
7515 +#define GISR_ETHERNET 0x0040
7518 + * Interrupt routing from IO to the processor IP bits
7519 + * Define our inter mask and level
7521 +#define AR531XPLUS_INTR_MISCIO SR_IBIT3
7522 +#define AR531XPLUS_INTR_WLAN0 SR_IBIT4
7523 +#define AR531XPLUS_INTR_ENET0 SR_IBIT5
7524 +#define AR531XPLUS_INTR_LOCALPCI SR_IBIT6
7525 +#define AR531XPLUS_INTR_WMACPOLL SR_IBIT7
7526 +#define AR531XPLUS_INTR_COMPARE SR_IBIT8
7531 +#define AR531XPLUS_TIMER (AR531XPLUS_DSLBASE + 0x0030)
7532 +#define AR531XPLUS_RELOAD (AR531XPLUS_DSLBASE + 0x0034)
7533 +#define AR531XPLUS_WD (AR531XPLUS_DSLBASE + 0x0038)
7534 +#define AR531XPLUS_WDC (AR531XPLUS_DSLBASE + 0x003c)
7536 +#define WDC_RESET 0x00000002 /* reset on watchdog */
7537 +#define WDC_NMI 0x00000001 /* NMI on watchdog */
7538 +#define WDC_IGNORE_EXPIRATION 0x00000000
7543 +#define AR531X_FLASHDBG (AR531X_RESETTMR + 0x0040)
7544 +#define AR531X_MIIDBG (AR531X_RESETTMR + 0x0044)
7548 + * CPU Performance Counters
7550 +#define AR531XPLUS_PERFCNT0 (AR531XPLUS_DSLBASE + 0x0048)
7551 +#define AR531XPLUS_PERFCNT1 (AR531XPLUS_DSLBASE + 0x004c)
7553 +#define PERF_DATAHIT 0x0001 /* Count Data Cache Hits */
7554 +#define PERF_DATAMISS 0x0002 /* Count Data Cache Misses */
7555 +#define PERF_INSTHIT 0x0004 /* Count Instruction Cache Hits */
7556 +#define PERF_INSTMISS 0x0008 /* Count Instruction Cache Misses */
7557 +#define PERF_ACTIVE 0x0010 /* Count Active Processor Cycles */
7558 +#define PERF_WBHIT 0x0020 /* Count CPU Write Buffer Hits */
7559 +#define PERF_WBMISS 0x0040 /* Count CPU Write Buffer Misses */
7561 +#define PERF_EB_ARDY 0x0001 /* Count EB_ARdy signal */
7562 +#define PERF_EB_AVALID 0x0002 /* Count EB_AValid signal */
7563 +#define PERF_EB_WDRDY 0x0004 /* Count EB_WDRdy signal */
7564 +#define PERF_EB_RDVAL 0x0008 /* Count EB_RdVal signal */
7565 +#define PERF_VRADDR 0x0010 /* Count valid read address cycles */
7566 +#define PERF_VWADDR 0x0020 /* Count valid write address cycles */
7567 +#define PERF_VWDATA 0x0040 /* Count valid write data cycles */
7570 + * AHB Error Reporting.
7572 +#define AR531XPLUS_AHB_ERR0 (AR531XPLUS_DSLBASE + 0x0050) /* error */
7573 +#define AR531XPLUS_AHB_ERR1 (AR531XPLUS_DSLBASE + 0x0054) /* haddr */
7574 +#define AR531XPLUS_AHB_ERR2 (AR531XPLUS_DSLBASE + 0x0058) /* hwdata */
7575 +#define AR531XPLUS_AHB_ERR3 (AR531XPLUS_DSLBASE + 0x005c) /* hrdata */
7576 +#define AR531XPLUS_AHB_ERR4 (AR531XPLUS_DSLBASE + 0x0060) /* status */
7578 +#define AHB_ERROR_DET 1 /* AHB Error has been detected, */
7579 + /* write 1 to clear all bits in ERR0 */
7580 +#define AHB_ERROR_OVR 2 /* AHB Error overflow has been detected */
7581 +#define AHB_ERROR_WDT 4 /* AHB Error due to wdt instead of hresp */
7583 +#define PROCERR_HMAST 0x0000000f
7584 +#define PROCERR_HMAST_DFLT 0
7585 +#define PROCERR_HMAST_WMAC 1
7586 +#define PROCERR_HMAST_ENET 2
7587 +#define PROCERR_HMAST_PCIENDPT 3
7588 +#define PROCERR_HMAST_LOCAL 4
7589 +#define PROCERR_HMAST_CPU 5
7590 +#define PROCERR_HMAST_PCITGT 6
7592 +#define PROCERR_HMAST_S 0
7593 +#define PROCERR_HWRITE 0x00000010
7594 +#define PROCERR_HSIZE 0x00000060
7595 +#define PROCERR_HSIZE_S 5
7596 +#define PROCERR_HTRANS 0x00000180
7597 +#define PROCERR_HTRANS_S 7
7598 +#define PROCERR_HBURST 0x00000e00
7599 +#define PROCERR_HBURST_S 9
7606 +#define AR531XPLUS_PLLC_CTL (AR531XPLUS_DSLBASE + 0x0064)
7607 +#define AR531XPLUS_PLLV_CTL (AR531XPLUS_DSLBASE + 0x0068)
7608 +#define AR531XPLUS_CPUCLK (AR531XPLUS_DSLBASE + 0x006c)
7609 +#define AR531XPLUS_AMBACLK (AR531XPLUS_DSLBASE + 0x0070)
7610 +#define AR531XPLUS_SYNCCLK (AR531XPLUS_DSLBASE + 0x0074)
7611 +#define AR531XPLUS_DSL_SLEEP_CTL (AR531XPLUS_DSLBASE + 0x0080)
7612 +#define AR531XPLUS_DSL_SLEEP_DUR (AR531XPLUS_DSLBASE + 0x0084)
7614 +/* PLLc Control fields */
7615 +#define PLLC_REF_DIV_M 0x00000003
7616 +#define PLLC_REF_DIV_S 0
7617 +#define PLLC_FDBACK_DIV_M 0x0000007C
7618 +#define PLLC_FDBACK_DIV_S 2
7619 +#define PLLC_ADD_FDBACK_DIV_M 0x00000080
7620 +#define PLLC_ADD_FDBACK_DIV_S 7
7621 +#define PLLC_CLKC_DIV_M 0x0001c000
7622 +#define PLLC_CLKC_DIV_S 14
7623 +#define PLLC_CLKM_DIV_M 0x00700000
7624 +#define PLLC_CLKM_DIV_S 20
7626 +/* CPU CLK Control fields */
7627 +#define CPUCLK_CLK_SEL_M 0x00000003
7628 +#define CPUCLK_CLK_SEL_S 0
7629 +#define CPUCLK_CLK_DIV_M 0x0000000c
7630 +#define CPUCLK_CLK_DIV_S 2
7632 +/* AMBA CLK Control fields */
7633 +#define AMBACLK_CLK_SEL_M 0x00000003
7634 +#define AMBACLK_CLK_SEL_S 0
7635 +#define AMBACLK_CLK_DIV_M 0x0000000c
7636 +#define AMBACLK_CLK_DIV_S 2
7638 +#if defined(COBRA_EMUL)
7639 +#define AR531XPLUS_AMBA_CLOCK_RATE 20000000
7640 +#define AR531XPLUS_CPU_CLOCK_RATE 40000000
7642 +#if defined(DEFAULT_PLL)
7643 +#define AR531XPLUS_AMBA_CLOCK_RATE 40000000
7644 +#define AR531XPLUS_CPU_CLOCK_RATE 40000000
7646 +#define AR531XPLUS_AMBA_CLOCK_RATE 92000000
7647 +#define AR531XPLUS_CPU_CLOCK_RATE 184000000
7648 +#endif /* ! DEFAULT_PLL */
7649 +#endif /* ! COBRA_EMUL */
7651 +#define AR531XPLUS_UART_CLOCK_RATE AR531XPLUS_AMBA_CLOCK_RATE
7652 +#define AR531XPLUS_SDRAM_CLOCK_RATE AR531XPLUS_AMBA_CLOCK_RATE
7655 + * The UART computes baud rate as:
7656 + * baud = clock / (16 * divisor)
7657 + * where divisor is specified as a High Byte (DLM) and a Low Byte (DLL).
7659 +#define DESIRED_BAUD_RATE 38400
7662 + * The WATCHDOG value is computed as
7663 + * 10 seconds * AR531X_WATCHDOG_CLOCK_RATE
7665 +#define DESIRED_WATCHDOG_SECONDS 10
7666 +#define AR531X_WATCHDOG_TIME \
7667 + (DESIRED_WATCHDOG_SECONDS * AR531X_WATCHDOG_CLOCK_RATE)
7670 +#define CLOCKCTL_UART0 0x0010 /* enable UART0 external clock */
7674 + * Applicable "PCICFG" bits for WLAN(s). Assoc status and LED mode.
7676 +#define AR531X_PCICFG (AR531X_RESETTMR + 0x00b0)
7677 +#define ASSOC_STATUS_M 0x00000003
7678 +#define ASSOC_STATUS_NONE 0
7679 +#define ASSOC_STATUS_PENDING 1
7680 +#define ASSOC_STATUS_ASSOCIATED 2
7681 +#define LED_MODE_M 0x0000001c
7682 +#define LED_BLINK_THRESHOLD_M 0x000000e0
7683 +#define LED_SLOW_BLINK_MODE 0x00000100
7689 +#define AR531XPLUS_GPIO_DI (AR531XPLUS_DSLBASE + 0x0088)
7690 +#define AR531XPLUS_GPIO_DO (AR531XPLUS_DSLBASE + 0x0090)
7691 +#define AR531XPLUS_GPIO_CR (AR531XPLUS_DSLBASE + 0x0098)
7692 +#define AR531XPLUS_GPIO_INT (AR531XPLUS_DSLBASE + 0x00a0)
7694 +#define GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
7695 +#define GPIO_CR_O(x) (1 << (x)) /* output */
7696 +#define GPIO_CR_I(x) (0 << (x)) /* input */
7698 +#define GPIO_INT(x,Y) ((x) << (8 * (Y))) /* interrupt enable */
7699 +#define GPIO_INT_M(Y) ((0x3F) << (8 * (Y))) /* mask for int */
7700 +#define GPIO_INT_LVL(x,Y) ((x) << (8 * (Y) + 6)) /* interrupt level */
7701 +#define GPIO_INT_LVL_M(Y) ((0x3) << (8 * (Y) + 6)) /* mask for int level */
7703 +#define AR531XPLUS_RESET_GPIO 5
7704 +#define AR531XPLUS_NUM_GPIO 22
7708 + * PCI Clock Control
7711 +#define AR531XPLUS_PCICLK (AR531XPLUS_DSLBASE + 0x00a4)
7713 +#define PCICLK_INPUT_M 0x3
7714 +#define PCICLK_INPUT_S 0
7716 +#define PCICLK_PLLC_CLKM 0
7717 +#define PCICLK_PLLC_CLKM1 1
7718 +#define PCICLK_PLLC_CLKC 2
7719 +#define PCICLK_REF_CLK 3
7721 +#define PCICLK_DIV_M 0xc
7722 +#define PCICLK_DIV_S 2
7724 +#define PCICLK_IN_FREQ 0
7725 +#define PCICLK_IN_FREQ_DIV_6 1
7726 +#define PCICLK_IN_FREQ_DIV_8 2
7727 +#define PCICLK_IN_FREQ_DIV_10 3
7730 + * Observation Control Register
7732 +#define AR531XPLUS_OCR (AR531XPLUS_DSLBASE + 0x00b0)
7733 +#define OCR_GPIO0_IRIN 0x0040
7734 +#define OCR_GPIO1_IROUT 0x0080
7735 +#define OCR_GPIO3_RXCLR 0x0200
7738 + * General Clock Control
7741 +#define AR531XPLUS_MISCCLK (AR531XPLUS_DSLBASE + 0x00b4)
7742 +#define MISCCLK_PLLBYPASS_EN 0x00000001
7743 +#define MISCCLK_PROCREFCLK 0x00000002
7746 + * SDRAM Controller
7747 + * - No read or write buffers are included.
7749 +#define AR531XPLUS_MEM_CFG (AR531XPLUS_SDRAMCTL + 0x00)
7750 +#define AR531XPLUS_MEM_CTRL (AR531XPLUS_SDRAMCTL + 0x0c)
7751 +#define AR531XPLUS_MEM_REF (AR531XPLUS_SDRAMCTL + 0x10)
7753 +#define SDRAM_DATA_WIDTH_M 0x00006000
7754 +#define SDRAM_DATA_WIDTH_S 13
7756 +#define SDRAM_COL_WIDTH_M 0x00001E00
7757 +#define SDRAM_COL_WIDTH_S 9
7759 +#define SDRAM_ROW_WIDTH_M 0x000001E0
7760 +#define SDRAM_ROW_WIDTH_S 5
7762 +#define SDRAM_BANKADDR_BITS_M 0x00000018
7763 +#define SDRAM_BANKADDR_BITS_S 3
7767 + * SDRAM Memory Refresh (MEM_REF) value is computed as:
7768 + * MEMCTL_SREFR = (Tr * hclk_freq) / R
7769 + * where Tr is max. time of refresh of any single row
7770 + * R is number of rows in the DRAM
7771 + * For most 133MHz SDRAM parts, Tr=64ms, R=4096 or 8192
7773 +#if defined(COBRA_EMUL)
7774 +#define AR531XPLUS_SDRAM_MEMORY_REFRESH_VALUE 0x96
7776 +#if defined(DEFAULT_PLL)
7777 +#define AR531XPLUS_SDRAM_MEMORY_REFRESH_VALUE 0x200
7779 +#define AR531XPLUS_SDRAM_MEMORY_REFRESH_VALUE 0x61a
7780 +#endif /* ! DEFAULT_PLL */
7783 +#if defined(AR531XPLUS)
7785 +#define AR531XPLUS_SDRAM_DDR_SDRAM 0 /* Not DDR SDRAM */
7786 +#define AR531XPLUS_SDRAM_DATA_WIDTH 16 /* bits */
7787 +#define AR531XPLUS_SDRAM_COL_WIDTH 8
7788 +#define AR531XPLUS_SDRAM_ROW_WIDTH 12
7792 +#define AR531XPLUS_SDRAM_DDR_SDRAM 0 /* Not DDR SDRAM */
7793 +#define AR531XPLUS_SDRAM_DATA_WIDTH 16
7794 +#define AR531XPLUS_SDRAM_COL_WIDTH 8
7795 +#define AR531XPLUS_SDRAM_ROW_WIDTH 12
7797 +#endif /* ! AR531XPLUS */
7800 + * SPI Flash Interface Registers
7803 +#define AR531XPLUS_SPI_CTL (AR531XPLUS_SPI + 0x00)
7804 +#define AR531XPLUS_SPI_OPCODE (AR531XPLUS_SPI + 0x04)
7805 +#define AR531XPLUS_SPI_DATA (AR531XPLUS_SPI + 0x08)
7807 +#define SPI_CTL_START 0x00000100
7808 +#define SPI_CTL_BUSY 0x00010000
7809 +#define SPI_CTL_TXCNT_MASK 0x0000000f
7810 +#define SPI_CTL_RXCNT_MASK 0x000000f0
7811 +#define SPI_CTL_TX_RX_CNT_MASK 0x000000ff
7812 +#define SPI_CTL_SIZE_MASK 0x00060000
7814 +#define SPI_CTL_CLK_SEL_MASK 0x03000000
7815 +#define SPI_OPCODE_MASK 0x000000ff
7818 + * PCI-MAC Configuration registers
7820 +#define PCI_MAC_RC (AR531XPLUS_PCI + 0x4000)
7821 +#define PCI_MAC_SCR (AR531XPLUS_PCI + 0x4004)
7822 +#define PCI_MAC_INTPEND (AR531XPLUS_PCI + 0x4008)
7823 +#define PCI_MAC_SFR (AR531XPLUS_PCI + 0x400C)
7824 +#define PCI_MAC_PCICFG (AR531XPLUS_PCI + 0x4010)
7825 +#define PCI_MAC_SREV (AR531XPLUS_PCI + 0x4020)
7827 +#define PCI_MAC_RC_MAC 0x00000001
7828 +#define PCI_MAC_RC_BB 0x00000002
7830 +#define PCI_MAC_SCR_SLMODE_M 0x00030000
7831 +#define PCI_MAC_SCR_SLMODE_S 16
7832 +#define PCI_MAC_SCR_SLM_FWAKE 0
7833 +#define PCI_MAC_SCR_SLM_FSLEEP 1
7834 +#define PCI_MAC_SCR_SLM_NORMAL 2
7836 +#define PCI_MAC_SFR_SLEEP 0x00000001
7838 +#define PCI_MAC_PCICFG_SPWR_DN 0x00010000
7844 + * PCI Bus Interface Registers
7846 +#define AR531XPLUS_PCI_1MS_REG (AR531XPLUS_PCI + 0x0008)
7847 +#define AR531XPLUS_PCI_1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
7849 +#define AR531XPLUS_PCI_MISC_CONFIG (AR531XPLUS_PCI + 0x000c)
7850 +#define AR531XPLUS_PCIMISC_TXD_EN 0x00000001 /* Enable TXD for fragments */
7851 +#define AR531XPLUS_PCIMISC_CFG_SEL 0x00000002 /* mem or config cycles */
7852 +#define AR531XPLUS_PCIMISC_GIG_MASK 0x0000000C /* bits 31-30 for pci req */
7853 +#define AR531XPLUS_PCIMISC_RST_MODE 0x00000030
7854 +#define AR531XPLUS_PCIRST_INPUT 0x00000000 /* 4:5=0 rst is input */
7855 +#define AR531XPLUS_PCIRST_LOW 0x00000010 /* 4:5=1 rst to GND */
7856 +#define AR531XPLUS_PCIRST_HIGH 0x00000020 /* 4:5=2 rst to VDD */
7857 +#define AR531XPLUS_PCIGRANT_EN 0x00000000 /* 6:7=0 early grant en */
7858 +#define AR531XPLUS_PCIGRANT_FRAME 0x00000040 /* 6:7=1 grant waits 4 frame */
7859 +#define AR531XPLUS_PCIGRANT_IDLE 0x00000080 /* 6:7=2 grant waits 4 idle */
7860 +#define AR531XPLUS_PCIGRANT_GAP 0x00000000 /* 6:7=2 grant waits 4 idle */
7861 +#define AR531XPLUS_PCICACHE_DIS 0x00001000 /* PCI external access cache disable */
7863 +#define AR531XPLUS_PCI_OUT_TSTAMP (AR531XPLUS_PCI + 0x0010)
7865 +#define AR531XPLUS_PCI_UNCACHE_CFG (AR531XPLUS_PCI + 0x0014)
7867 +#define AR531XPLUS_PCI_IN_EN (AR531XPLUS_PCI + 0x0100)
7868 +#define AR531XPLUS_PCI_IN_EN0 0x01 /* Enable chain 0 */
7869 +#define AR531XPLUS_PCI_IN_EN1 0x02 /* Enable chain 1 */
7870 +#define AR531XPLUS_PCI_IN_EN2 0x04 /* Enable chain 2 */
7871 +#define AR531XPLUS_PCI_IN_EN3 0x08 /* Enable chain 3 */
7873 +#define AR531XPLUS_PCI_IN_DIS (AR531XPLUS_PCI + 0x0104)
7874 +#define AR531XPLUS_PCI_IN_DIS0 0x01 /* Disable chain 0 */
7875 +#define AR531XPLUS_PCI_IN_DIS1 0x02 /* Disable chain 1 */
7876 +#define AR531XPLUS_PCI_IN_DIS2 0x04 /* Disable chain 2 */
7877 +#define AR531XPLUS_PCI_IN_DIS3 0x08 /* Disable chain 3 */
7879 +#define AR531XPLUS_PCI_IN_PTR (AR531XPLUS_PCI + 0x0200)
7881 +#define AR531XPLUS_PCI_OUT_EN (AR531XPLUS_PCI + 0x0400)
7882 +#define AR531XPLUS_PCI_OUT_EN0 0x01 /* Enable chain 0 */
7884 +#define AR531XPLUS_PCI_OUT_DIS (AR531XPLUS_PCI + 0x0404)
7885 +#define AR531XPLUS_PCI_OUT_DIS0 0x01 /* Disable chain 0 */
7887 +#define AR531XPLUS_PCI_OUT_PTR (AR531XPLUS_PCI + 0x0408)
7889 +#define AR531XPLUS_PCI_INT_STATUS (AR531XPLUS_PCI + 0x0500) /* write one to clr */
7890 +#define AR531XPLUS_PCI_TXINT 0x00000001 /* Desc In Completed */
7891 +#define AR531XPLUS_PCI_TXOK 0x00000002 /* Desc In OK */
7892 +#define AR531XPLUS_PCI_TXERR 0x00000004 /* Desc In ERR */
7893 +#define AR531XPLUS_PCI_TXEOL 0x00000008 /* Desc In End-of-List */
7894 +#define AR531XPLUS_PCI_RXINT 0x00000010 /* Desc Out Completed */
7895 +#define AR531XPLUS_PCI_RXOK 0x00000020 /* Desc Out OK */
7896 +#define AR531XPLUS_PCI_RXERR 0x00000040 /* Desc Out ERR */
7897 +#define AR531XPLUS_PCI_RXEOL 0x00000080 /* Desc Out EOL */
7898 +#define AR531XPLUS_PCI_TXOOD 0x00000200 /* Desc In Out-of-Desc */
7899 +#define AR531XPLUS_PCI_MASK 0x0000FFFF /* Desc Mask */
7900 +#define AR531XPLUS_PCI_EXT_INT 0x02000000
7901 +#define AR531XPLUS_PCI_ABORT_INT 0x04000000
7903 +#define AR531XPLUS_PCI_INT_MASK (AR531XPLUS_PCI + 0x0504) /* same as INT_STATUS */
7905 +#define AR531XPLUS_PCI_INTEN_REG (AR531XPLUS_PCI + 0x0508)
7906 +#define AR531XPLUS_PCI_INT_DISABLE 0x00 /* disable pci interrupts */
7907 +#define AR531XPLUS_PCI_INT_ENABLE 0x01 /* enable pci interrupts */
7909 +#define AR531XPLUS_PCI_HOST_IN_EN (AR531XPLUS_PCI + 0x0800)
7910 +#define AR531XPLUS_PCI_HOST_IN_DIS (AR531XPLUS_PCI + 0x0804)
7911 +#define AR531XPLUS_PCI_HOST_IN_PTR (AR531XPLUS_PCI + 0x0810)
7912 +#define AR531XPLUS_PCI_HOST_OUT_EN (AR531XPLUS_PCI + 0x0900)
7913 +#define AR531XPLUS_PCI_HOST_OUT_DIS (AR531XPLUS_PCI + 0x0904)
7914 +#define AR531XPLUS_PCI_HOST_OUT_PTR (AR531XPLUS_PCI + 0x0908)
7918 + * Local Bus Interface Registers
7920 +#define AR531XPLUS_LB_CONFIG (AR531XPLUS_LOCAL + 0x0000)
7921 +#define AR531XPLUS_LBCONF_OE 0x00000001 /* =1 OE is low-true */
7922 +#define AR531XPLUS_LBCONF_CS0 0x00000002 /* =1 first CS is low-true */
7923 +#define AR531XPLUS_LBCONF_CS1 0x00000004 /* =1 2nd CS is low-true */
7924 +#define AR531XPLUS_LBCONF_RDY 0x00000008 /* =1 RDY is low-true */
7925 +#define AR531XPLUS_LBCONF_WE 0x00000010 /* =1 Write En is low-true */
7926 +#define AR531XPLUS_LBCONF_WAIT 0x00000020 /* =1 WAIT is low-true */
7927 +#define AR531XPLUS_LBCONF_ADS 0x00000040 /* =1 Adr Strobe is low-true */
7928 +#define AR531XPLUS_LBCONF_MOT 0x00000080 /* =0 Intel, =1 Motorola */
7929 +#define AR531XPLUS_LBCONF_8CS 0x00000100 /* =1 8 bits CS, 0= 16bits */
7930 +#define AR531XPLUS_LBCONF_8DS 0x00000200 /* =1 8 bits Data S, 0=16bits */
7931 +#define AR531XPLUS_LBCONF_ADS_EN 0x00000400 /* =1 Enable ADS */
7932 +#define AR531XPLUS_LBCONF_ADR_OE 0x00000800 /* =1 Adr cap on OE, WE or DS */
7933 +#define AR531XPLUS_LBCONF_ADDT_MUX 0x00001000 /* =1 Adr and Data share bus */
7934 +#define AR531XPLUS_LBCONF_DATA_OE 0x00002000 /* =1 Data cap on OE, WE, DS */
7935 +#define AR531XPLUS_LBCONF_16DATA 0x00004000 /* =1 Data is 16 bits wide */
7936 +#define AR531XPLUS_LBCONF_SWAPDT 0x00008000 /* =1 Byte swap data */
7937 +#define AR531XPLUS_LBCONF_SYNC 0x00010000 /* =1 Bus synchronous to clk */
7938 +#define AR531XPLUS_LBCONF_INT 0x00020000 /* =1 Intr is low true */
7939 +#define AR531XPLUS_LBCONF_INT_CTR0 0x00000000 /* GND high-Z, Vdd is high-Z */
7940 +#define AR531XPLUS_LBCONF_INT_CTR1 0x00040000 /* GND drive, Vdd is high-Z */
7941 +#define AR531XPLUS_LBCONF_INT_CTR2 0x00080000 /* GND high-Z, Vdd drive */
7942 +#define AR531XPLUS_LBCONF_INT_CTR3 0x000C0000 /* GND drive, Vdd drive */
7943 +#define AR531XPLUS_LBCONF_RDY_WAIT 0x00100000 /* =1 RDY is negative of WAIT */
7944 +#define AR531XPLUS_LBCONF_INT_PULSE 0x00200000 /* =1 Interrupt is a pulse */
7945 +#define AR531XPLUS_LBCONF_ENABLE 0x00400000 /* =1 Falcon respond to LB */
7947 +#define AR531XPLUS_LB_CLKSEL (AR531XPLUS_LOCAL + 0x0004)
7948 +#define AR531XPLUS_LBCLK_EXT 0x0001 /* use external clk for lb */
7950 +#define AR531XPLUS_LB_1MS (AR531XPLUS_LOCAL + 0x0008)
7951 +#define AR531XPLUS_LB1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
7953 +#define AR531XPLUS_LB_MISCCFG (AR531XPLUS_LOCAL + 0x000C)
7954 +#define AR531XPLUS_LBM_TXD_EN 0x00000001 /* Enable TXD for fragments */
7955 +#define AR531XPLUS_LBM_RX_INTEN 0x00000002 /* Enable LB ints on RX ready */
7956 +#define AR531XPLUS_LBM_MBOXWR_INTEN 0x00000004 /* Enable LB ints on mbox wr */
7957 +#define AR531XPLUS_LBM_MBOXRD_INTEN 0x00000008 /* Enable LB ints on mbox rd */
7958 +#define AR531XPLUS_LMB_DESCSWAP_EN 0x00000010 /* Byte swap desc enable */
7959 +#define AR531XPLUS_LBM_TIMEOUT_MASK 0x00FFFF80
7960 +#define AR531XPLUS_LBM_TIMEOUT_SHFT 7
7961 +#define AR531XPLUS_LBM_PORTMUX 0x07000000
7964 +#define AR531XPLUS_LB_RXTSOFF (AR531XPLUS_LOCAL + 0x0010)
7966 +#define AR531XPLUS_LB_TX_CHAIN_EN (AR531XPLUS_LOCAL + 0x0100)
7967 +#define AR531XPLUS_LB_TXEN_0 0x01
7968 +#define AR531XPLUS_LB_TXEN_1 0x02
7969 +#define AR531XPLUS_LB_TXEN_2 0x04
7970 +#define AR531XPLUS_LB_TXEN_3 0x08
7972 +#define AR531XPLUS_LB_TX_CHAIN_DIS (AR531XPLUS_LOCAL + 0x0104)
7973 +#define AR531XPLUS_LB_TX_DESC_PTR (AR531XPLUS_LOCAL + 0x0200)
7975 +#define AR531XPLUS_LB_RX_CHAIN_EN (AR531XPLUS_LOCAL + 0x0400)
7976 +#define AR531XPLUS_LB_RXEN 0x01
7978 +#define AR531XPLUS_LB_RX_CHAIN_DIS (AR531XPLUS_LOCAL + 0x0404)
7979 +#define AR531XPLUS_LB_RX_DESC_PTR (AR531XPLUS_LOCAL + 0x0408)
7981 +#define AR531XPLUS_LB_INT_STATUS (AR531XPLUS_LOCAL + 0x0500)
7982 +#define AR531XPLUS_INT_TX_DESC 0x0001
7983 +#define AR531XPLUS_INT_TX_OK 0x0002
7984 +#define AR531XPLUS_INT_TX_ERR 0x0004
7985 +#define AR531XPLUS_INT_TX_EOF 0x0008
7986 +#define AR531XPLUS_INT_RX_DESC 0x0010
7987 +#define AR531XPLUS_INT_RX_OK 0x0020
7988 +#define AR531XPLUS_INT_RX_ERR 0x0040
7989 +#define AR531XPLUS_INT_RX_EOF 0x0080
7990 +#define AR531XPLUS_INT_TX_TRUNC 0x0100
7991 +#define AR531XPLUS_INT_TX_STARVE 0x0200
7992 +#define AR531XPLUS_INT_LB_TIMEOUT 0x0400
7993 +#define AR531XPLUS_INT_LB_ERR 0x0800
7994 +#define AR531XPLUS_INT_MBOX_WR 0x1000
7995 +#define AR531XPLUS_INT_MBOX_RD 0x2000
7997 +/* Bit definitions for INT MASK are the same as INT_STATUS */
7998 +#define AR531XPLUS_LB_INT_MASK (AR531XPLUS_LOCAL + 0x0504)
8000 +#define AR531XPLUS_LB_INT_EN (AR531XPLUS_LOCAL + 0x0508)
8001 +#define AR531XPLUS_LB_MBOX (AR531XPLUS_LOCAL + 0x0600)
8006 + * IR Interface Registers
8008 +#define AR531XPLUS_IR_PKTDATA (AR531XPLUS_IR + 0x0000)
8010 +#define AR531XPLUS_IR_PKTLEN (AR531XPLUS_IR + 0x07fc) /* 0 - 63 */
8012 +#define AR531XPLUS_IR_CONTROL (AR531XPLUS_IR + 0x0800)
8013 +#define AR531XPLUS_IRCTL_TX 0x00000000 /* use as tranmitter */
8014 +#define AR531XPLUS_IRCTL_RX 0x00000001 /* use as receiver */
8015 +#define AR531XPLUS_IRCTL_SAMPLECLK_MASK 0x00003ffe /* Sample clk divisor mask */
8016 +#define AR531XPLUS_IRCTL_SAMPLECLK_SHFT 1
8017 +#define AR531XPLUS_IRCTL_OUTPUTCLK_MASK 0x03ffc000 /* Output clk divisor mask */
8018 +#define AR531XPLUS_IRCTL_OUTPUTCLK_SHFT 14
8020 +#define AR531XPLUS_IR_STATUS (AR531XPLUS_IR + 0x0804)
8021 +#define AR531XPLUS_IRSTS_RX 0x00000001 /* receive in progress */
8022 +#define AR531XPLUS_IRSTS_TX 0x00000002 /* transmit in progress */
8024 +#define AR531XPLUS_IR_CONFIG (AR531XPLUS_IR + 0x0808)
8025 +#define AR531XPLUS_IRCFG_INVIN 0x00000001 /* invert input polarity */
8026 +#define AR531XPLUS_IRCFG_INVOUT 0x00000002 /* invert output polarity */
8027 +#define AR531XPLUS_IRCFG_SEQ_START_WIN_SEL 0x00000004 /* 1 => 28, 0 => 7 */
8028 +#define AR531XPLUS_IRCFG_SEQ_START_THRESH 0x000000f0 /* */
8029 +#define AR531XPLUS_IRCFG_SEQ_END_UNIT_SEL 0x00000100 /* */
8030 +#define AR531XPLUS_IRCFG_SEQ_END_UNIT_THRESH 0x00007e00 /* */
8031 +#define AR531XPLUS_IRCFG_SEQ_END_WIN_SEL 0x00008000 /* */
8032 +#define AR531XPLUS_IRCFG_SEQ_END_WIN_THRESH 0x001f0000 /* */
8033 +#define AR531XPLUS_IRCFG_NUM_BACKOFF_WORDS 0x01e00000 /* */
8036 + * PCI memory constants: Memory area 1 and 2 are the same size -
8037 + * (twice the PCI_TLB_PAGE_SIZE). The definition of
8038 + * CPU_TO_PCI_MEM_SIZE is coupled with the TLB setup routine
8039 + * sysLib.c/sysTlbInit(), in that it assumes that 2 pages of size
8040 + * PCI_TLB_PAGE_SIZE are set up in the TLB for each PCI memory space.
8043 +#define CPU_TO_PCI_MEM_BASE1 0xE0000000
8044 +#define CPU_TO_PCI_MEM_SIZE1 (2*PCI_TLB_PAGE_SIZE)
8047 +/* TLB attributes for PCI transactions */
8049 +#define PCI_MMU_PAGEMASK 0x00003FFF
8050 +#define MMU_PAGE_UNCACHED 0x00000010
8051 +#define MMU_PAGE_DIRTY 0x00000004
8052 +#define MMU_PAGE_VALID 0x00000002
8053 +#define MMU_PAGE_GLOBAL 0x00000001
8054 +#define PCI_MMU_PAGEATTRIB (MMU_PAGE_UNCACHED|MMU_PAGE_DIRTY|\
8055 + MMU_PAGE_VALID|MMU_PAGE_GLOBAL)
8056 +#define PCI_MEMORY_SPACE1_VIRT 0xE0000000 /* Used for non-prefet mem */
8057 +#define PCI_MEMORY_SPACE1_PHYS 0x80000000
8058 +#define PCI_TLB_PAGE_SIZE 0x01000000
8059 +#define TLB_HI_MASK 0xFFFFE000
8060 +#define TLB_LO_MASK 0x3FFFFFFF
8061 +#define PAGEMASK_SHIFT 11
8062 +#define TLB_LO_SHIFT 6
8064 +#define PCI_MAX_LATENCY 0xFFF /* Max PCI latency */
8066 +#define HOST_PCI_DEV_ID 3
8067 +#define HOST_PCI_MBAR0 0x10000000
8068 +#define HOST_PCI_MBAR1 0x20000000
8069 +#define HOST_PCI_MBAR2 0x30000000
8071 +#define HOST_PCI_SDRAM_BASEADDR HOST_PCI_MBAR1
8072 +#define PCI_DEVICE_MEM_SPACE 0x800000
8075 +typedef unsigned int AR531X_REG;
8077 +#define sysRegRead(phys) \
8078 + (*(volatile AR531X_REG *)PHYS_TO_K1(phys))
8080 +#define sysRegWrite(phys, val) \
8081 + ((*(volatile AR531X_REG *)PHYS_TO_K1(phys)) = (val))
8086 + * This is board-specific data that is stored in a "fixed" location in flash.
8087 + * It is shared across operating systems, so it should not be changed lightly.
8088 + * The main reason we need it is in order to extract the ethernet MAC
8091 +struct ar531x_boarddata {
8092 + u32 magic; /* board data is valid */
8093 +#define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
8094 + u16 cksum; /* checksum (starting with BD_REV 2) */
8095 + u16 rev; /* revision of this struct */
8097 + char boardName[64]; /* Name of board */
8098 + u16 major; /* Board major number */
8099 + u16 minor; /* Board minor number */
8100 + u32 config; /* Board configuration */
8101 +#define BD_ENET0 0x00000001 /* ENET0 is stuffed */
8102 +#define BD_ENET1 0x00000002 /* ENET1 is stuffed */
8103 +#define BD_UART1 0x00000004 /* UART1 is stuffed */
8104 +#define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
8105 +#define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
8106 +#define BD_SYSLED 0x00000020 /* System LED stuffed */
8107 +#define BD_EXTUARTCLK 0x00000040 /* External UART clock */
8108 +#define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
8109 +#define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
8110 +#define BD_WLAN0 0x00000200 /* Enable WLAN0 */
8111 +#define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
8112 +#define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
8113 +#define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
8114 +#define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
8115 +#define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
8116 +#define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
8117 +#define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
8118 +#define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
8119 + u16 resetConfigGpio; /* Reset factory GPIO pin */
8120 + u16 sysLedGpio; /* System LED GPIO pin */
8122 + u32 cpuFreq; /* CPU core frequency in Hz */
8123 + u32 sysFreq; /* System frequency in Hz */
8124 + u32 cntFreq; /* Calculated C0_COUNT frequency */
8130 + u16 pciId; /* Pseudo PCIID for common code */
8131 + u16 memCap; /* cap bank1 in MB */
8134 + u8 wlan1Mac[6]; /* (ar5212) */
8139 +#endif /* AR531X_H */
8140 diff -urN linux-mips-orig/drivers/net/ath/ar531xlnx.h linux-mips-new/drivers/net/ath/ar531xlnx.h
8141 --- linux-mips-orig/drivers/net/ath/ar531xlnx.h 1970-01-01 01:00:00.000000000 +0100
8142 +++ linux-mips-new/drivers/net/ath/ar531xlnx.h 2005-12-31 12:33:57.676538368 +0000
8145 + * This file is subject to the terms and conditions of the GNU General Public
8146 + * License. See the file "COPYING" in the main directory of this archive
8147 + * for more details.
8149 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
8153 + * This file contains definitions needed in order to compile
8154 + * AR531X products for linux. Definitions that are largely
8155 + * AR531X-specific and independent of operating system belong
8156 + * in ar531x.h rather than this file.
8158 +#ifndef __AR531XLNX_H
8159 +#define __AR531XLNX_H
8160 +#include "ar531x.h"
8162 +#define MIPS_CPU_IRQ_BASE 0x00
8163 +#define AR531X_HIGH_PRIO 0x10
8164 +#define AR531X_MISC_IRQ_BASE 0x20
8165 +#define AR531X_GPIO_IRQ_BASE 0x30
8167 +/* Software's idea of interrupts handled by "CPU Interrupt Controller" */
8169 +#define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
8170 +#define AR531X_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
8171 +#define AR531X_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
8172 +#define AR531X_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
8173 +#define AR531X_IRQ_LCBUS_PCI MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
8174 +#define AR531X_IRQ_WLAN0_POLL MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
8175 +#define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
8177 +#define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
8178 +#define AR531X_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
8179 +#define AR531X_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
8180 +#define AR531X_IRQ_ENET1_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
8181 +#define AR531X_IRQ_WLAN1_INTRS MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
8182 +#define AR531X_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
8183 +#define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
8186 +/* Miscellaneous interrupts, which share IP6 or IP2 */
8187 +#define AR531X_MISC_IRQ_NONE AR531X_MISC_IRQ_BASE+0
8188 +#define AR531X_MISC_IRQ_TIMER AR531X_MISC_IRQ_BASE+1
8189 +#define AR531X_MISC_IRQ_AHB_PROC AR531X_MISC_IRQ_BASE+2
8190 +#define AR531X_MISC_IRQ_AHB_DMA AR531X_MISC_IRQ_BASE+3
8191 +#define AR531X_MISC_IRQ_GPIO AR531X_MISC_IRQ_BASE+4
8192 +#define AR531X_MISC_IRQ_UART0 AR531X_MISC_IRQ_BASE+5
8193 +#define AR531X_MISC_IRQ_UART0_DMA AR531X_MISC_IRQ_BASE+6
8194 +#define AR531X_MISC_IRQ_WATCHDOG AR531X_MISC_IRQ_BASE+7
8195 +#define AR531X_MISC_IRQ_LOCAL AR531X_MISC_IRQ_BASE+8
8196 +#define AR531X_MISC_IRQ_COUNT 9
8198 +/* GPIO Interrupts [0..7], share AR531X_MISC_IRQ_GPIO */
8199 +#define AR531X_GPIO_IRQ_NONE AR531X_MISC_IRQ_BASE+0
8200 +#define AR531X_GPIO_IRQ(n) AR531X_MISC_IRQ_BASE+(n)+1
8201 +#define AR531X_GPIO_IRQ_COUNT 9
8203 +#define PHYS_TO_K1(physaddr) KSEG1ADDR(physaddr)
8204 +#define PHYS_TO_K0(physaddr) KSEG0ADDR(physaddr)
8205 +#define UNMAPPED_TO_PHYS(vaddr) PHYSADDR(vaddr)
8206 +#define IS_UNMAPPED_VADDR(vaddr) \
8207 + ((KSEGX(vaddr) == KSEG0) || (KSEGX(vaddr) == KSEG1))
8209 +/* IOCTL commands for /proc/ar531x */
8210 +#define AR531X_CTRL_DO_BREAKPOINT 1
8211 +#define AR531X_CTRL_DO_MADWIFI 2
8214 + * Definitions for operating system portability.
8215 + * These are vxWorks-->Linux translations.
8217 +#define LOCAL static
8224 +#define PRINTF printk
8226 +#define DEBUG_PRINTF printk
8227 +#define printf printk
8230 +DEBUG_PRINTF while (0) printk
8231 +#define INLINE inline
8233 +#define sysUDelay(usecs) udelay(usecs)
8234 +#define sysMsDelay(msecs) mdelay(msecs)
8235 +typedef volatile UINT8 *VIRT_ADDR;
8236 +#define MALLOC(sz) kmalloc(sz, GFP_KERNEL)
8237 +#define MALLOC_NOSLEEP(sz) kmalloc(sz, GFP_ATOMIC)
8238 +#define FREE(ptr) kfree((void *)ptr)
8239 +#define BSP_BUG() do { printk("kernel BSP BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0)
8240 +#define BSP_BUG_ON(condition) do { if (unlikely((condition)!=0)) BSP_BUG(); } while(0)
8241 +#define ASSERT(x) BSP_BUG_ON(!(x))
8243 +extern struct ar531x_boarddata *ar531x_board_configuration;
8244 +extern char *ar531x_radio_configuration;
8245 +extern char *enet_mac_address_get(int MACUnit);
8247 +extern void kgdbInit(void);
8248 +extern int kgdbEnabled(void);
8249 +extern void breakpoint(void);
8250 +extern int kgdbInterrupt(void);
8251 +extern unsigned int ar531x_cpu_frequency(void);
8252 +extern unsigned int ar531x_sys_frequency(void);
8255 +extern struct irqaction spurious_gpio;
8256 +extern unsigned int gpioIntMask;
8257 +extern void ar531x_gpio_intr_init(int irq_base);
8258 +extern void ar531x_gpio_ctrl_output(int gpio);
8259 +extern void ar531x_gpio_ctrl_input(int gpio);
8260 +extern void ar531x_gpio_set(int gpio, int val);
8261 +extern int ar531x_gpio_get(int gpio);
8262 +extern void ar531x_gpio_intr_enable(unsigned int irq);
8263 +extern void ar531x_gpio_intr_disable(unsigned int irq);
8265 +/* Watchdog Timer support */
8266 +extern int watchdog_start(unsigned int milliseconds);
8267 +extern int watchdog_stop(void);
8268 +extern int watchdog_is_enabled(void);
8269 +extern unsigned int watchdog_min_timer_reached(void);
8270 +extern void watchdog_notify_alive(void);
8272 +#define A_DATA_CACHE_INVAL(start, length) \
8273 + dma_cache_inv((UINT32)(start),(length))
8275 +#define sysWbFlush() mb()
8277 +#define intDisable(x) cli()
8278 +#define intEnable(x) sti()
8280 +#endif /* __AR531XLNX_H */
8281 diff -urN linux-mips-orig/drivers/net/ath/ipPhy.c linux-mips-new/drivers/net/ath/ipPhy.c
8282 --- linux-mips-orig/drivers/net/ath/ipPhy.c 1970-01-01 01:00:00.000000000 +0100
8283 +++ linux-mips-new/drivers/net/ath/ipPhy.c 2005-12-31 12:33:57.677538216 +0000
8286 + * This file is subject to the terms and conditions of the GNU General Public
8287 + * License. See the file "COPYING" in the main directory of this archive
8288 + * for more details.
8290 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
8294 + * Manage the ICPLUS ethernet PHY.
8296 + * All definitions in this file are operating system independent!
8300 +#include <linux/config.h>
8301 +#include <linux/types.h>
8302 +#include <linux/netdevice.h>
8303 +#include <linux/etherdevice.h>
8304 +#include <linux/delay.h>
8306 +#include "ar531xlnx.h"
8309 +#include "ae531xmac.h"
8310 +#include "ae531xreg.h"
8313 +/* PHY selections and access functions */
8317 + PHY_PORTINFO_SIZE,
8322 + PHY_SRCPORT_VLANTAG,
8323 + PHY_SRCPORT_TRAILER,
8324 +} PHY_SRCPORT_TYPE;
8327 +#define DRV_DEBUG 1
8329 +#define DRV_DEBUG 1
8332 +#define DRV_DEBUG_PHYERROR 0x00000001
8333 +#define DRV_DEBUG_PHYCHANGE 0x00000002
8334 +#define DRV_DEBUG_PHYSETUP 0x00000004
8336 +int ipPhyDebug = DRV_DEBUG_PHYERROR;
8338 +#define DRV_LOG(FLG, X0, X1, X2, X3, X4, X5, X6) \
8340 + if (ipPhyDebug & (FLG)) { \
8341 + logMsg(X0, X1, X2, X3, X4, X5, X6); \
8345 +#define DRV_MSG(x,a,b,c,d,e,f) \
8346 + logMsg(x,a,b,c,d,e,f)
8348 +#define DRV_PRINT(FLG, X) \
8350 + if (ipPhyDebug & (FLG)) { \
8355 +#else /* !DRV_DEBUG */
8356 +#define DRV_LOG(DBG_SW, X0, X1, X2, X3, X4, X5, X6)
8357 +#define DRV_MSG(x,a,b,c,d,e,f)
8358 +#define DRV_PRINT(DBG_SW,X)
8361 +#define IP_LAN_PORT_VLAN 1
8362 +#define IP_WAN_PORT_VLAN 2
8364 +#define ENET_UNIT_DEFAULT 0
8367 + * Track per-PHY port information.
8370 + BOOL isEnetPort; /* normal enet port */
8371 + BOOL isPhyAlive; /* last known state of link */
8372 + int ethUnit; /* MAC associated with this phy port */
8374 + UINT32 phyAddr; /* PHY registers associated with this phy port */
8375 + UINT32 VLANTableSetting; /* Value to be written to VLAN table */
8379 + * Per-PHY information, indexed by PHY unit number.
8381 +ipPhyInfo_t ipPhyInfo[] = {
8383 + * On AP30/AR5312, all PHYs are associated with MAC0.
8384 + * AP30/AR5312's MAC1 isn't used for anything.
8385 + * CONFIG_VENETDEV==1 (router) configuration:
8386 + * Ports 0,1,2, and 3 are "LAN ports"
8387 + * Port 4 is a WAN port
8388 + * Port 5 connects to MAC0 in the AR5312
8389 + * CONFIG_VENETDEV==0 (bridge) configuration:
8390 + * Ports 0,1,2,3,4 are "LAN ports"
8391 + * Port 5 connects to the MAC0 in the AR5312
8393 + {TRUE, /* phy port 0 -- LAN port 0 */
8395 + ENET_UNIT_DEFAULT,
8396 + (UINT32) (PHYS_TO_K1(AR531X_ENET0)+AE531X_PHY_OFFSET),
8401 + {TRUE, /* phy port 1 -- LAN port 1 */
8403 + ENET_UNIT_DEFAULT,
8404 + (UINT32) (PHYS_TO_K1(AR531X_ENET0)+AE531X_PHY_OFFSET),
8409 + {TRUE, /* phy port 2 -- LAN port 2 */
8411 + ENET_UNIT_DEFAULT,
8412 + (UINT32) (PHYS_TO_K1(AR531X_ENET0)+AE531X_PHY_OFFSET),
8417 + {TRUE, /* phy port 3 -- LAN port 3 */
8419 + ENET_UNIT_DEFAULT,
8420 + (UINT32) (PHYS_TO_K1(AR531X_ENET0)+AE531X_PHY_OFFSET),
8425 + {TRUE, /* phy port 4 -- WAN port or LAN port 4 */
8427 + ENET_UNIT_DEFAULT,
8428 + (UINT32) (PHYS_TO_K1(AR531X_ENET0)+AE531X_PHY_OFFSET),
8430 + IP_LAN_PORT_VLAN /* Send to all ports */
8433 + {FALSE, /* phy port 5 -- CPU port (no RJ45 connector) */
8435 + ENET_UNIT_DEFAULT,
8436 + (UINT32) (PHYS_TO_K1(AR531X_ENET0)+AE531X_PHY_OFFSET),
8438 + IP_LAN_PORT_VLAN /* Send to all ports */
8442 +#define IP_GLOBALREGBASE ((UINT32) (PHYS_TO_K1(AR531X_ENET0)))
8444 +#define IP_PHY_MAX (sizeof(ipPhyInfo) / sizeof(ipPhyInfo[0]))
8446 +/* Range of valid PHY IDs is [MIN..MAX] */
8447 +#define IP_ID_MIN 0
8448 +#define IP_ID_MAX (IP_PHY_MAX-1)
8450 +/* Convenience macros to access myPhyInfo */
8451 +#define IP_IS_ENET_PORT(phyUnit) (ipPhyInfo[phyUnit].isEnetPort)
8452 +#define IP_IS_PHY_ALIVE(phyUnit) (ipPhyInfo[phyUnit].isPhyAlive)
8453 +#define IP_ETHUNIT(phyUnit) (ipPhyInfo[phyUnit].ethUnit)
8454 +#define IP_PHYBASE(phyUnit) (ipPhyInfo[phyUnit].phyBase)
8455 +#define IP_PHYADDR(phyUnit) (ipPhyInfo[phyUnit].phyAddr)
8456 +#define IP_VLAN_TABLE_SETTING(phyUnit) (ipPhyInfo[phyUnit].VLANTableSetting)
8459 +#define IP_IS_ETHUNIT(phyUnit, ethUnit) \
8460 + (IP_IS_ENET_PORT(phyUnit) && \
8461 + IP_ETHUNIT(phyUnit) == (ethUnit))
8463 +/* Forward references */
8464 +BOOL ip_phyIsLinkAlive(int phyUnit);
8465 +LOCAL void ip_VLANInit(int ethUnit);
8466 +LOCAL void ip_verifyReady(int ethUnit);
8468 +void ip_phyShow(int phyUnit);
8469 +void ip_phySet(int phyUnit, UINT32 regnum, UINT32 value);
8470 +void ip_globalSet(UINT32 phyAddr, UINT32 regnum, UINT32 value);
8473 +/******************************************************************************
8475 +* ip_phyIsLinkAlive - test to see if the specified link is alive
8478 +* TRUE --> link is alive
8479 +* FALSE --> link is down
8482 +ip_phyIsLinkAlive(int phyUnit)
8484 + UINT16 phyHwStatus;
8488 + phyBase = IP_PHYBASE(phyUnit);
8489 + phyAddr = IP_PHYADDR(phyUnit);
8491 + phyHwStatus = phyRegRead(phyBase, phyAddr, IP_PHY_STATUS);
8493 + if (phyHwStatus & IP_STATUS_LINK_PASS) {
8500 +/******************************************************************************
8502 +* ip_VLANInit - initialize "port-based VLANs" for the specified enet unit.
8505 +ip_VLANInit(int ethUnit)
8511 + phyBase = IP_GLOBALREGBASE;
8513 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8514 + if (IP_ETHUNIT(phyUnit) != ethUnit) {
8517 + phyRegWrite(phyBase, IP_GLOBAL_PHY29_ADDR,
8518 + IP_GLOBAL_PHY29_24_REG + ((phyUnit == 5) ? (phyUnit + 1) : phyUnit),
8519 + IP_VLAN_TABLE_SETTING(phyUnit));
8521 + /* Send all packets to all ports */
8522 + phyReg = phyRegRead(phyBase, IP_GLOBAL_PHY30_ADDR, IP_GLOBAL_PHY30_1_REG);
8523 + phyReg = phyReg | ((1 << phyUnit) << IP_VLAN1_OUTPUT_PORT_MASK_S);
8524 + phyRegWrite(phyBase, IP_GLOBAL_PHY30_ADDR, IP_GLOBAL_PHY30_1_REG, phyReg);
8526 + phyReg = phyRegRead(phyBase, IP_GLOBAL_PHY30_ADDR, IP_GLOBAL_PHY30_9_REG);
8527 + phyReg = phyReg | TAG_VLAN_ENABLE;
8528 + phyReg = phyReg & ~VID_INDX_SEL_M;
8529 + phyRegWrite(phyBase, IP_GLOBAL_PHY30_ADDR, IP_GLOBAL_PHY30_9_REG, phyReg);
8535 +ip_verifyReady(int ethUnit)
8538 + UINT32 phyBase = 0;
8544 + * The first read to the Phy port registers always fails and
8545 + * returns 0. So get things started with a bogus read.
8547 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8548 + if (!IP_IS_ETHUNIT(phyUnit, ethUnit)) {
8552 + phyBase = IP_PHYBASE(phyUnit);
8553 + phyAddr = IP_PHYADDR(phyUnit);
8555 + phyID1 = phyRegRead(phyBase, phyAddr, IP_PHY_ID1); /* returns 0 */
8559 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8560 + if (!IP_IS_ETHUNIT(phyUnit, ethUnit)) {
8564 + /*******************/
8565 + /* Verify phy port */
8566 + /*******************/
8567 + phyBase = IP_PHYBASE(phyUnit);
8568 + phyAddr = IP_PHYADDR(phyUnit);
8570 + phyID1 = phyRegRead(phyBase, phyAddr, IP_PHY_ID1);
8571 + if (phyID1 != IP_PHY_ID1_EXPECTATION) {
8572 + DRV_PRINT(DRV_DEBUG_PHYERROR,
8573 + ("Invalid PHY ID1 for enet%d port%d. Expected 0x%04x, read 0x%04x\n",
8576 + IP_PHY_ID1_EXPECTATION,
8581 + phyID2 = phyRegRead(phyBase, phyAddr, IP_PHY_ID2);
8582 + if ((phyID2 & IP_OUI_LSB_MASK) != IP_OUI_LSB_EXPECTATION) {
8583 + DRV_PRINT(DRV_DEBUG_PHYERROR,
8584 + ("Invalid PHY ID2 for enet%d port %d. Expected 0x%04x, read 0x%04x\n",
8587 + IP_OUI_LSB_EXPECTATION,
8592 + DRV_PRINT(DRV_DEBUG_PHYSETUP,
8593 + ("Found PHY enet%d port%d: model 0x%x revision 0x%x\n",
8596 + (phyID2 & IP_MODEL_NUM_MASK) >> IP_MODEL_NUM_SHIFT,
8597 + (phyID2 & IP_REV_NUM_MASK) >> IP_REV_NUM_SHIFT));
8603 +/******************************************************************************
8605 +* ip_phySetup - reset and setup the PHY associated with
8606 +* the specified MAC unit number.
8608 +* Resets the associated PHY port.
8611 +* TRUE --> associated PHY is alive
8612 +* FALSE --> no LINKs on this ethernet unit
8616 +ip_phySetup(int ethUnit, UINT32 _phyBase)
8619 + UINT16 phyHwStatus;
8621 + int liveLinks = 0;
8622 + UINT32 phyBase = 0;
8623 + BOOL foundPhy = FALSE;
8627 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8628 + if (!IP_IS_ETHUNIT(phyUnit, ethUnit)) {
8632 + phyBase = IP_PHYBASE(phyUnit);
8633 + phyAddr = IP_PHYADDR(phyUnit);
8635 + phyRegWrite(phyBase, phyAddr, IP_PHY_CONTROL,
8636 + IP_CTRL_SOFTWARE_RESET);
8639 + * After the phy is reset, it takes a little while before
8640 + * it can respond properly.
8643 + /* Verify that the switch is what we think it is, and that it's ready */
8644 + ip_verifyReady(ethUnit);
8646 + /* See if there's any configuration data for this enet */
8647 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8648 + if (IP_ETHUNIT(phyUnit) != ethUnit) {
8652 + phyBase = IP_PHYBASE(phyUnit);
8658 + return FALSE; /* No PHY's configured for this ethUnit */
8662 + /* Initialize global switch settings */
8664 + /* Initialize the aging time */
8666 + /* Set the learning properties */
8669 + /* start auto negogiation on each phy */
8670 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8671 + if (!IP_IS_ETHUNIT(phyUnit, ethUnit)) {
8675 + phyBase = IP_PHYBASE(phyUnit);
8676 + phyAddr = IP_PHYADDR(phyUnit);
8678 + phyRegWrite(phyBase, phyAddr, IP_AUTONEG_ADVERT,
8679 + IP_ADVERTISE_ALL);
8680 + phyRegWrite(phyBase, phyAddr, IP_PHY_CONTROL,
8681 + IP_CTRL_AUTONEGOTIATION_ENABLE | IP_CTRL_START_AUTONEGOTIATION);
8685 + * Wait up to .75 seconds for ALL associated PHYs to finish
8686 + * autonegotiation. The only way we get out of here sooner is
8687 + * if ALL PHYs are connected AND finish autonegotiation.
8690 + for (phyUnit=0; (phyUnit < IP_PHY_MAX) /*&& (timeout > 0) */; phyUnit++) {
8691 + if (!IP_IS_ETHUNIT(phyUnit, ethUnit)) {
8695 + phyBase = IP_PHYBASE(phyUnit);
8696 + phyAddr = IP_PHYADDR(phyUnit);
8698 + phyHwStatus = phyRegRead(phyBase, phyAddr, IP_PHY_STATUS);
8700 + if (IP_AUTONEG_DONE(phyHwStatus)) {
8701 + DRV_PRINT(DRV_DEBUG_PHYSETUP,
8702 + ("Port %d, Neg Success\n", phyUnit));
8705 + if (timeout == 0) {
8706 + DRV_PRINT(DRV_DEBUG_PHYSETUP,
8707 + ("Port %d, Negogiation timeout\n", phyUnit));
8710 + if (--timeout == 0) {
8711 + DRV_PRINT(DRV_DEBUG_PHYSETUP,
8712 + ("Port %d, Negogiation timeout\n", phyUnit));
8721 + * All PHYs have had adequate time to autonegotiate.
8722 + * Now initialize software status.
8724 + * It's possible that some ports may take a bit longer
8725 + * to autonegotiate; but we can't wait forever. They'll
8726 + * get noticed by mv_phyCheckStatusChange during regular
8727 + * polling activities.
8729 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8730 + if (!IP_IS_ETHUNIT(phyUnit, ethUnit)) {
8734 + if (ip_phyIsLinkAlive(phyUnit)) {
8736 + IP_IS_PHY_ALIVE(phyUnit) = TRUE;
8738 + IP_IS_PHY_ALIVE(phyUnit) = FALSE;
8741 + DRV_PRINT(DRV_DEBUG_PHYSETUP,
8742 + ("eth%d: Phy Status=%4.4x\n",
8744 + phyRegRead(IP_PHYBASE(phyUnit),
8745 + IP_PHYADDR(phyUnit),
8749 + /* XXX Divy. Disable WAN/LAN seggregation. See bug 17866 */
8750 + ip_VLANInit(ethUnit);
8752 + return (liveLinks > 0);
8755 +/******************************************************************************
8757 +* ip_phyIsDuplexFull - Determines whether the phy ports associated with the
8758 +* specified device are FULL or HALF duplex.
8765 +ip_phyIsFullDuplex(int ethUnit)
8770 + UINT16 phyHwStatus;
8772 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8773 + if (!IP_IS_ETHUNIT(phyUnit, ethUnit)) {
8777 + if (ip_phyIsLinkAlive(phyUnit)) {
8779 + phyBase = IP_PHYBASE(phyUnit);
8780 + phyAddr = IP_PHYADDR(phyUnit);
8782 + phyHwStatus = phyRegRead(phyBase, phyAddr, IP_LINK_PARTNER_ABILITY);
8783 + printk("ipPhy.c: phyHwStatus 0x%x\n",phyHwStatus);
8784 + if ((phyHwStatus & IP_LINK_100BASETX_FULL_DUPLEX) ||
8785 + (phyHwStatus & IP_LINK_10BASETX_FULL_DUPLEX)) {
8797 +/******************************************************************************
8799 +* ip_phyIsSpeed100 - Determines the speed of phy ports associated with the
8800 +* specified device.
8808 +ip_phyIsSpeed100(int ethUnit)
8811 + UINT16 phyHwStatus;
8815 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8816 + if (!IP_IS_ETHUNIT(phyUnit, ethUnit)) {
8820 + if (ip_phyIsLinkAlive(phyUnit)) {
8822 + phyBase = IP_PHYBASE(phyUnit);
8823 + phyAddr = IP_PHYADDR(phyUnit);
8825 + phyHwStatus = phyRegRead(phyBase, phyAddr, IP_LINK_PARTNER_ABILITY);
8827 + if (phyHwStatus & IP_LINK_100BASETX) {
8836 +/*****************************************************************************
8838 +* ip_phyCheckStatusChange -- checks for significant changes in PHY state.
8840 +* A "significant change" is:
8841 +* dropped link (e.g. ethernet cable unplugged) OR
8842 +* autonegotiation completed + link (e.g. ethernet cable plugged in)
8844 +* When a PHY is plugged in, phyLinkGained is called.
8845 +* When a PHY is unplugged, phyLinkLost is called.
8849 +ip_phyCheckStatusChange(int ethUnit)
8853 + UINT16 phyHwStatus;
8854 + ipPhyInfo_t *lastStatus;
8855 + int linkCount = 0;
8856 + int lostLinks = 0;
8857 + int gainedLinks = 0;
8861 + for (phyUnit=0; phyUnit < IP_PHY_MAX; phyUnit++) {
8862 + if (!IP_IS_ETHUNIT(phyUnit, ethUnit)) {
8866 + phyBase = IP_PHYBASE(phyUnit);
8867 + phyAddr = IP_PHYADDR(phyUnit);
8869 + lastStatus = &ipPhyInfo[phyUnit];
8870 + phyHwStatus = phyRegRead(phyBase, phyAddr, IP_PHY_STATUS);
8872 + if (lastStatus->isPhyAlive) { /* last known link status was ALIVE */
8873 + /* See if we've lost link */
8874 + if (phyHwStatus & IP_STATUS_LINK_PASS) {
8879 + mv_flushATUDB(phyUnit);
8881 + DRV_PRINT(DRV_DEBUG_PHYCHANGE,("\nenet%d port%d down\n",
8882 + ethUnit, phyUnit));
8883 + lastStatus->isPhyAlive = FALSE;
8885 + } else { /* last known link status was DEAD */
8886 + /* Check for AutoNegotiation complete */
8887 + if (IP_AUTONEG_DONE(phyHwStatus)) {
8890 + DRV_PRINT(DRV_DEBUG_PHYCHANGE,("\nenet%d port%d up\n",
8891 + ethUnit, phyUnit));
8892 + lastStatus->isPhyAlive = TRUE;
8897 + if (linkCount == 0) {
8899 + /* We just lost the last link for this MAC */
8900 + phyLinkLost(ethUnit);
8903 + if (gainedLinks == linkCount) {
8904 + /* We just gained our first link(s) for this MAC */
8905 + phyLinkGained(ethUnit);
8913 +/* Define the registers of interest for a phyShow command */
8914 +typedef struct ipRegisterTableEntry_s {
8916 + char *regIdString;
8917 +} ipRegisterTableEntry_t;
8919 +ipRegisterTableEntry_t ipPhyRegisterTable[] = {
8920 + {IP_PHY_CONTROL, "PHY Control "},
8921 + {IP_PHY_STATUS, "PHY Status "},
8922 + {IP_PHY_ID1, "PHY Identifier 1 "},
8923 + {IP_PHY_ID2, "PHY Identifier 2 "},
8924 + {IP_AUTONEG_ADVERT, "Auto-Negotiation Advertisement "},
8925 + {IP_LINK_PARTNER_ABILITY, "Link Partner Ability "},
8926 + {IP_AUTONEG_EXPANSION, "Auto-Negotiation Expansion "},
8928 +int ipPhyNumRegs = sizeof(ipPhyRegisterTable) / sizeof(ipPhyRegisterTable[0]);
8931 +ipRegisterTableEntry_t ipPhy29GlobalRegisterTable[] = {
8932 + {IP_GLOBAL_PHY29_18_REG, "29_18_REG "},
8933 + {IP_GLOBAL_PHY29_19_REG, "29_19_REG "},
8934 + {IP_GLOBAL_PHY29_20_REG, "29_20_REG "},
8935 + {IP_GLOBAL_PHY29_21_REG, "29_21_REG "},
8936 + {IP_GLOBAL_PHY29_22_REG, "29_22_REG "},
8937 + {IP_GLOBAL_PHY29_23_REG, "29_23_REG "},
8938 + {IP_GLOBAL_PHY29_24_REG, "29_24_REG "},
8939 + {IP_GLOBAL_PHY29_25_REG, "29_25_REG "},
8940 + {IP_GLOBAL_PHY29_26_REG, "29_26_REG "},
8941 + {IP_GLOBAL_PHY29_27_REG, "29_27_REG "},
8942 + {IP_GLOBAL_PHY29_28_REG, "29_28_REG "},
8943 + {IP_GLOBAL_PHY29_29_REG, "29_29_REG "},
8944 + {IP_GLOBAL_PHY29_30_REG, "29_30_REG "},
8945 + {IP_GLOBAL_PHY29_31_REG, "29_31_REG "},
8947 +int ipPhy29GlobalNumRegs =
8948 + sizeof(ipPhy29GlobalRegisterTable) / sizeof(ipPhy29GlobalRegisterTable[0]);
8951 +ipRegisterTableEntry_t ipPhy30GlobalRegisterTable[] = {
8952 + {IP_GLOBAL_PHY30_0_REG, "30_0_REG "},
8953 + {IP_GLOBAL_PHY30_1_REG, "30_1_REG "},
8954 + {IP_GLOBAL_PHY30_2_REG, "30_2_REG "},
8955 + {IP_GLOBAL_PHY30_3_REG, "30_3_REG "},
8956 + {IP_GLOBAL_PHY30_4_REG, "30_4_REG "},
8957 + {IP_GLOBAL_PHY30_5_REG, "30_5_REG "},
8958 + {IP_GLOBAL_PHY30_6_REG, "30_6_REG "},
8959 + {IP_GLOBAL_PHY30_7_REG, "30_7_REG "},
8960 + {IP_GLOBAL_PHY30_8_REG, "30_8_REG "},
8961 + {IP_GLOBAL_PHY30_9_REG, "30_9_REG "},
8962 + {IP_GLOBAL_PHY30_10_REG, "30_10_REG "},
8963 + {IP_GLOBAL_PHY30_11_REG, "30_11_REG "},
8964 + {IP_GLOBAL_PHY30_12_REG, "30_12_REG "},
8965 + {IP_GLOBAL_PHY30_13_REG, "30_13_REG "},
8966 + {IP_GLOBAL_PHY30_16_REG, "30_16_REG "},
8967 + {IP_GLOBAL_PHY30_17_REG, "30_17_REG "},
8968 + {IP_GLOBAL_PHY30_18_REG, "30_18_REG "},
8969 + {IP_GLOBAL_PHY30_20_REG, "30_20_REG "},
8970 + {IP_GLOBAL_PHY30_21_REG, "30_21_REG "},
8971 + {IP_GLOBAL_PHY30_22_REG, "30_22_REG "},
8972 + {IP_GLOBAL_PHY30_23_REG, "30_23_REG "},
8973 + {IP_GLOBAL_PHY30_24_REG, "30_24_REG "},
8974 + {IP_GLOBAL_PHY30_25_REG, "30_25_REG "},
8975 + {IP_GLOBAL_PHY30_26_REG, "30_26_REG "},
8976 + {IP_GLOBAL_PHY30_27_REG, "30_27_REG "},
8977 + {IP_GLOBAL_PHY30_28_REG, "30_28_REG "},
8978 + {IP_GLOBAL_PHY30_29_REG, "30_29_REG "},
8979 + {IP_GLOBAL_PHY30_30_REG, "30_30_REG "},
8980 + {IP_GLOBAL_PHY30_31_REG, "30_31_REG "},
8982 +int ipPhy30GlobalNumRegs =
8983 + sizeof(ipPhy30GlobalRegisterTable) / sizeof(ipPhy30GlobalRegisterTable[0]);
8985 +ipRegisterTableEntry_t ipPhy31GlobalRegisterTable[] = {
8986 + {IP_GLOBAL_PHY31_0_REG, "31_0_REG "},
8987 + {IP_GLOBAL_PHY31_1_REG, "31_1_REG "},
8988 + {IP_GLOBAL_PHY31_2_REG, "31_2_REG "},
8989 + {IP_GLOBAL_PHY31_3_REG, "31_3_REG "},
8990 + {IP_GLOBAL_PHY31_4_REG, "31_4_REG "},
8991 + {IP_GLOBAL_PHY31_5_REG, "31_5_REG "},
8992 + {IP_GLOBAL_PHY31_6_REG, "31_6_REG "},
8995 +int ipPhy31GlobalNumRegs =
8996 + sizeof(ipPhy31GlobalRegisterTable) / sizeof(ipPhy31GlobalRegisterTable[0]);
8999 +/*****************************************************************************
9001 +* ip_phyShow - Dump the state of a PHY.
9002 +* There are two sets of registers for each phy port:
9003 +* "phy registers" and
9004 +* "switch port registers"
9005 +* We dump 'em all, plus the switch global registers.
9008 +ip_phyShow(int phyUnit)
9015 + if (!ip_validPhyId(phyUnit)) {
9019 + phyBase = IP_PHYBASE(phyUnit);
9020 + phyAddr = IP_PHYADDR(phyUnit);
9022 + printf("PHY state for PHY%d (enet%d, phyBase 0x%8x, phyAddr 0x%x)\n",
9024 + IP_ETHUNIT(phyUnit),
9025 + IP_PHYBASE(phyUnit),
9026 + IP_PHYADDR(phyUnit));
9028 + printf("PHY Registers:\n");
9029 + for (i=0; i < ipPhyNumRegs; i++) {
9031 + value = phyRegRead(phyBase, phyAddr, ipPhyRegisterTable[i].regNum);
9033 + printf("Reg %02d (0x%02x) %s = 0x%08x\n",
9034 + ipPhyRegisterTable[i].regNum,
9035 + ipPhyRegisterTable[i].regNum,
9036 + ipPhyRegisterTable[i].regIdString,
9040 + phyBase = IP_GLOBALREGBASE;
9042 + printf("Switch Global Registers:\n");
9043 + printf("Phy29 Registers:\n");
9044 + for (i=0; i < ipPhy29GlobalNumRegs; i++) {
9046 + value = phyRegRead(phyBase, IP_GLOBAL_PHY29_ADDR,
9047 + ipPhy29GlobalRegisterTable[i].regNum);
9049 + printf("Reg %02d (0x%02x) %s = 0x%08x\n",
9050 + ipPhy29GlobalRegisterTable[i].regNum,
9051 + ipPhy29GlobalRegisterTable[i].regNum,
9052 + ipPhy29GlobalRegisterTable[i].regIdString,
9056 + printf("Phy30 Registers:\n");
9057 + for (i=0; i < ipPhy30GlobalNumRegs; i++) {
9059 + value = phyRegRead(phyBase, IP_GLOBAL_PHY30_ADDR,
9060 + ipPhy30GlobalRegisterTable[i].regNum);
9062 + printf("Reg %02d (0x%02x) %s = 0x%08x\n",
9063 + ipPhy30GlobalRegisterTable[i].regNum,
9064 + ipPhy30GlobalRegisterTable[i].regNum,
9065 + ipPhy30GlobalRegisterTable[i].regIdString,
9068 + printf("Phy31 Registers:\n");
9069 + for (i=0; i < ipPhy31GlobalNumRegs; i++) {
9071 + value = phyRegRead(phyBase, IP_GLOBAL_PHY31_ADDR,
9072 + ipPhy31GlobalRegisterTable[i].regNum);
9074 + printf("Reg %02d (0x%02x) %s = 0x%08x\n",
9075 + ipPhy31GlobalRegisterTable[i].regNum,
9076 + ipPhy31GlobalRegisterTable[i].regNum,
9077 + ipPhy31GlobalRegisterTable[i].regIdString,
9082 +/*****************************************************************************
9084 +* ip_phySet - Modify the value of a PHY register (debug only).
9087 +ip_phySet(int phyUnit, UINT32 regnum, UINT32 value)
9092 + if (ip_validPhyId(phyUnit)) {
9094 + phyBase = IP_PHYBASE(phyUnit);
9095 + phyAddr = IP_PHYADDR(phyUnit);
9097 + phyRegWrite(phyBase, phyAddr, regnum, value);
9101 +/*****************************************************************************
9103 +* ip_globalSet - Modify the value of a global register
9107 +ip_globalSet(UINT32 phyAddr, UINT32 regnum, UINT32 value)
9111 + phyBase = IP_GLOBALREGBASE;
9113 + phyRegWrite(phyBase, phyAddr, regnum, value);
9118 diff -urN linux-mips-orig/drivers/net/ath/ipPhy.h linux-mips-new/drivers/net/ath/ipPhy.h
9119 --- linux-mips-orig/drivers/net/ath/ipPhy.h 1970-01-01 01:00:00.000000000 +0100
9120 +++ linux-mips-new/drivers/net/ath/ipPhy.h 2005-12-31 12:33:57.678538064 +0000
9123 + * This file is subject to the terms and conditions of the GNU General Public
9124 + * License. See the file "COPYING" in the main directory of this archive
9125 + * for more details.
9127 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
9131 + * icPhy.h - definitions for the ethernet PHY.
9132 + * This code supports a simple 1-port ethernet phy, ICPLUS,
9133 + * All definitions in this file are operating system independent!
9139 +/*****************/
9140 +/* PHY Registers */
9141 +/*****************/
9142 +#define IP_PHY_CONTROL 0
9143 +#define IP_PHY_STATUS 1
9144 +#define IP_PHY_ID1 2
9145 +#define IP_PHY_ID2 3
9146 +#define IP_AUTONEG_ADVERT 4
9147 +#define IP_LINK_PARTNER_ABILITY 5
9148 +#define IP_AUTONEG_EXPANSION 6
9151 +/* IP_PHY_CONTROL fields */
9152 +#define IP_CTRL_SOFTWARE_RESET 0x8000
9153 +#define IP_CTRL_SPEED_100 0x2000
9154 +#define IP_CTRL_AUTONEGOTIATION_ENABLE 0x1000
9155 +#define IP_CTRL_START_AUTONEGOTIATION 0x0200
9156 +#define IP_CTRL_SPEED_FULL_DUPLEX 0x0100
9158 +/* Phy status fields */
9159 +#define IP_STATUS_AUTO_NEG_DONE 0x0020
9160 +#define IP_STATUS_LINK_PASS 0x0004
9162 +#define IP_AUTONEG_DONE(ip_phy_status) \
9163 + (((ip_phy_status) & \
9164 + (IP_STATUS_AUTO_NEG_DONE)) == \
9165 + (IP_STATUS_AUTO_NEG_DONE))
9167 +/* ICPLUS_PHY_ID1 fields */
9168 +#define IP_PHY_ID1_EXPECTATION 0x0243 /* OUI >> 6 */
9170 +/* ICPLUS_PHY_ID2 fields */
9171 +#define IP_OUI_LSB_MASK 0xfc00
9172 +#define IP_OUI_LSB_EXPECTATION 0x0c00
9173 +#define IP_OUI_LSB_SHIFT 10
9174 +#define IP_MODEL_NUM_MASK 0x03f0
9175 +#define IP_MODEL_NUM_SHIFT 4
9176 +#define IP_REV_NUM_MASK 0x000f
9177 +#define IP_REV_NUM_SHIFT 0
9179 +/* Link Partner ability */
9180 +#define IP_LINK_100BASETX_FULL_DUPLEX 0x0100
9181 +#define IP_LINK_100BASETX 0x0080
9182 +#define IP_LINK_10BASETX_FULL_DUPLEX 0x0040
9183 +#define IP_LINK_10BASETX 0x0020
9185 +/* Advertisement register. */
9186 +#define IP_ADVERTISE_100FULL 0x0100
9187 +#define IP_ADVERTISE_100HALF 0x0080
9188 +#define IP_ADVERTISE_10FULL 0x0040
9189 +#define IP_ADVERTISE_10HALF 0x0020
9191 +#define IP_ADVERTISE_ALL (IP_ADVERTISE_10HALF | IP_ADVERTISE_10FULL | \
9192 + IP_ADVERTISE_100HALF | IP_ADVERTISE_100FULL)
9195 +#define IP_VLAN_TAG_VALID 0x81
9196 +#define IP_VLAN_TAG_SIZE 4
9197 +#define IP_VLAN_TAG_OFFSET 12 /* After DA & SA */
9198 +#define IP_SPECIAL_TAG_VALID 0x81
9200 +/****************************/
9201 +/* Global Control Registers */
9202 +/****************************/
9203 +/* IP Global register doesn't have names based on functionality
9204 + * hence has to live with this names for now */
9205 +#define IP_GLOBAL_PHY29_18_REG 18
9206 +#define IP_GLOBAL_PHY29_19_REG 19
9207 +#define IP_GLOBAL_PHY29_20_REG 20
9208 +#define IP_GLOBAL_PHY29_21_REG 21
9209 +#define IP_GLOBAL_PHY29_22_REG 22
9210 +#define IP_GLOBAL_PHY29_23_REG 23
9211 +#define IP_GLOBAL_PHY29_24_REG 24
9212 +#define IP_GLOBAL_PHY29_25_REG 25
9213 +#define IP_GLOBAL_PHY29_26_REG 26
9214 +#define IP_GLOBAL_PHY29_27_REG 27
9215 +#define IP_GLOBAL_PHY29_28_REG 28
9216 +#define IP_GLOBAL_PHY29_29_REG 29
9217 +#define IP_GLOBAL_PHY29_30_REG 30
9218 +#define IP_GLOBAL_PHY29_31_REG 31
9221 +#define IP_GLOBAL_PHY30_0_REG 0
9222 +#define IP_GLOBAL_PHY30_1_REG 1
9223 +#define IP_GLOBAL_PHY30_2_REG 2
9224 +#define IP_GLOBAL_PHY30_3_REG 3
9225 +#define IP_GLOBAL_PHY30_4_REG 4
9226 +#define IP_GLOBAL_PHY30_5_REG 5
9227 +#define IP_GLOBAL_PHY30_6_REG 6
9228 +#define IP_GLOBAL_PHY30_7_REG 7
9229 +#define IP_GLOBAL_PHY30_8_REG 8
9230 +#define IP_GLOBAL_PHY30_9_REG 9
9231 +#define IP_GLOBAL_PHY30_10_REG 10
9232 +#define IP_GLOBAL_PHY30_11_REG 11
9233 +#define IP_GLOBAL_PHY30_12_REG 12
9234 +#define IP_GLOBAL_PHY30_13_REG 13
9235 +#define IP_GLOBAL_PHY30_16_REG 16
9236 +#define IP_GLOBAL_PHY30_17_REG 17
9237 +#define IP_GLOBAL_PHY30_18_REG 18
9238 +#define IP_GLOBAL_PHY30_20_REG 20
9239 +#define IP_GLOBAL_PHY30_21_REG 21
9240 +#define IP_GLOBAL_PHY30_22_REG 22
9241 +#define IP_GLOBAL_PHY30_23_REG 23
9242 +#define IP_GLOBAL_PHY30_24_REG 24
9243 +#define IP_GLOBAL_PHY30_25_REG 25
9244 +#define IP_GLOBAL_PHY30_26_REG 26
9245 +#define IP_GLOBAL_PHY30_27_REG 27
9246 +#define IP_GLOBAL_PHY30_28_REG 28
9247 +#define IP_GLOBAL_PHY30_29_REG 29
9248 +#define IP_GLOBAL_PHY30_30_REG 30
9249 +#define IP_GLOBAL_PHY30_31_REG 31
9251 +#define IP_GLOBAL_PHY31_0_REG 0
9252 +#define IP_GLOBAL_PHY31_1_REG 1
9253 +#define IP_GLOBAL_PHY31_2_REG 2
9254 +#define IP_GLOBAL_PHY31_3_REG 3
9255 +#define IP_GLOBAL_PHY31_4_REG 4
9256 +#define IP_GLOBAL_PHY31_5_REG 5
9257 +#define IP_GLOBAL_PHY31_6_REG 6
9259 +#define IP_GLOBAL_PHY29_31_REG 31
9262 +#define IP_VLAN0_OUTPUT_PORT_MASK_S 0
9263 +#define IP_VLAN1_OUTPUT_PORT_MASK_S 8
9264 +#define IP_VLAN2_OUTPUT_PORT_MASK_S 0
9265 +#define IP_VLAN3_OUTPUT_PORT_MASK_S 8
9267 +/* Masks and shifts for 29.23 register */
9268 +#define IP_PORTX_ADD_TAG_S 11
9269 +#define IP_PORTX_REMOVE_TAG_S 6
9270 +#define IP_PORT5_ADD_TAG_S 1
9271 +#define IP_PORT5_REMOVE_TAG_S 0
9274 + * 30.9 Definitions
9276 +#define TAG_VLAN_ENABLE 0x0080
9277 +#define VID_INDX_SEL_M 0x0070
9278 +#define VID_INDX_SEL_S 4
9281 +/* PHY Addresses */
9282 +#define IP_PHY0_ADDR 0
9283 +#define IP_PHY1_ADDR 1
9284 +#define IP_PHY2_ADDR 2
9285 +#define IP_PHY3_ADDR 3
9286 +#define IP_PHY4_ADDR 4
9288 +#define IP_GLOBAL_PHY29_ADDR 29
9289 +#define IP_GLOBAL_PHY30_ADDR 30
9290 +#define IP_GLOBAL_PHY31_ADDR 31
9294 diff -urN linux-mips-orig/drivers/net/ath/kendSwitchPhy.c linux-mips-new/drivers/net/ath/kendSwitchPhy.c
9295 --- linux-mips-orig/drivers/net/ath/kendSwitchPhy.c 1970-01-01 01:00:00.000000000 +0100
9296 +++ linux-mips-new/drivers/net/ath/kendSwitchPhy.c 2005-12-31 12:33:57.678538064 +0000
9299 + * This file is subject to the terms and conditions of the GNU General Public
9300 + * License. See the file "COPYING" in the main directory of this archive
9301 + * for more details.
9303 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
9307 + * Manage the ethernet PHY.
9308 + * This code supports a simple 1-port ethernet phy, Realtek RTL8201BL,
9309 + * and compatible PHYs, such as the Kendin KS8721B.
9310 + * All definitions in this file are operating system independent!
9314 +#include <linux/config.h>
9315 +#include <linux/types.h>
9316 +#include <linux/netdevice.h>
9317 +#include <linux/etherdevice.h>
9318 +#include <linux/delay.h>
9320 +#include "ar531xlnx.h"
9323 +#if defined(__ECOS)
9324 +#include "ae531xecos.h"
9328 +#include "ae531xmac.h"
9329 +#include "ae531xreg.h"
9332 +#define RT_MAX_PORTS 5 /* max addressable ports per MIIM */
9335 +#define RT_DEBUG_ERROR 0x00000001
9336 +#define RT_DEBUG_PHYSETUP 0x00000002
9337 +#define RT_DEBUG_PHYCHANGE 0x00000004
9339 +/* XXX: must hardcode this since same MIIM for all ethUnits */
9340 +const UINT32 phyBase = 0xb8100000;
9342 +int rtPhyDebug = RT_DEBUG_ERROR;
9344 +#define RT_PRINT(FLG, X) \
9346 + if (rtPhyDebug & (FLG)) { \
9351 +#define RT_PRINT(FLG, X)
9355 + * Track per-PHY state.
9357 +static BOOL rtPhyAlive[RT_MAX_PORTS];
9360 +/******************************************************************************
9362 +* rt_phySetup - reset and setup the PHY associated with
9363 +* the specified MAC unit number.
9365 +* Resets the associated PHY port.
9368 +* TRUE --> associated PHY is alive
9369 +* FALSE --> no LINKs on this ethernet unit
9373 +rt_phySetup(int ethUnit, UINT32 phyBaseIgnored)
9375 + BOOL linkAlive = FALSE;
9378 + if (ethUnit == 0) {
9380 + for (i=1; i<5; i++) {
9381 + phyRegWrite(phyBase, i, GEN_ctl, AUTONEGENA);
9383 + if (phyRegRead(phyBase, i, GEN_sts) & (AUTOCMPLT | LINK)) {
9384 + rtPhyAlive[i] = TRUE;
9387 + rtPhyAlive[i] = FALSE;
9392 + phyRegWrite(phyBase, 5, GEN_ctl, AUTONEGENA);
9394 + if (phyRegRead(phyBase, 5, GEN_sts) & (AUTOCMPLT | LINK)) {
9395 + rtPhyAlive[5] = TRUE;
9398 + rtPhyAlive[5] = FALSE;
9405 +/******************************************************************************
9407 +* rt_phyIsDuplexFull - Determines whether the phy ports associated with the
9408 +* specified device are FULL or HALF duplex.
9415 +rt_phyIsFullDuplex(int ethUnit)
9417 + UINT16 phyLpa = 0;
9419 + if (ethUnit == 0) {
9421 + /* 4 ports connected. If any are half-duplex report half. */
9422 + for (i=1; i<5; i++) {
9423 + phyLpa = phyRegRead(phyBase, i, AN_lpa);
9424 + if ( (!(phyLpa & (LPA_TXFD | LPA_10FD))) &&
9425 + (phyLpa & (LPA_TX | LPA_10)) ) {
9432 + phyLpa = phyRegRead(phyBase, 5, AN_lpa);
9433 + if (phyLpa & (LPA_TXFD | LPA_10FD) ) {
9442 +/******************************************************************************
9444 +* rt_phyIsSpeed100 - Determines the speed of phy ports associated with the
9445 +* specified device.
9452 +rt_phyIsSpeed100(int ethUnit)
9456 + if (ethUnit == 0) {
9458 + /* 4 ports connected. If any are not 100 report 10. */
9459 + for (i=1; i<5; i++) {
9460 + phyLpa = phyRegRead(phyBase, i, AN_lpa);
9461 + if ( (!(phyLpa & (LPA_TXFD | LPA_TX))) &&
9462 + (phyLpa & (LPA_10FD | LPA_10)) ) {
9471 + phyLpa = phyRegRead(phyBase, 5, AN_lpa);
9472 + if (phyLpa & (LPA_TXFD | LPA_TX) ) {
9483 +/*****************************************************************************
9485 +* rt_phyCheckStatusChange -- checks for significant changes in PHY state.
9487 +* A "significant change" is:
9488 +* dropped link (e.g. ethernet cable unplugged) OR
9489 +* autonegotiation completed + link (e.g. ethernet cable plugged in)
9491 +* When a PHY is plugged in, phyLinkGained is called.
9492 +* When a PHY is unplugged, phyLinkLost is called.
9495 +rt_phyCheckStatusChange(int ethUnit)
9497 + UINT16 phyHwStatus;
9498 + int i, loopLower, loopUpper;
9500 + if (ethUnit == 0) {
9509 + for (i=loopLower; i<=loopUpper; i++) {
9510 + phyHwStatus = phyRegRead(phyBase, i, GEN_sts);
9512 + if (rtPhyAlive[i]) { /* last known status was ALIVE */
9513 + /* See if we've lost link */
9514 + if (!(phyHwStatus & LINK)) {
9515 + RT_PRINT(RT_DEBUG_PHYCHANGE,("\nethmac%d link down\n", ethUnit));
9516 + rtPhyAlive[i] = FALSE;
9517 + phyLinkLost(ethUnit);
9519 + } else { /* last known status was DEAD */
9520 + /* Check for AN complete */
9521 + if ((phyHwStatus & (AUTOCMPLT | LINK)) == (AUTOCMPLT | LINK)) {
9522 + RT_PRINT(RT_DEBUG_PHYCHANGE,("\nethmac%d link up\n", ethUnit));
9523 + rtPhyAlive[i] = TRUE;
9524 + phyLinkGained(ethUnit);
9532 +/* Define the PHY registers of interest for a phyShow command */
9533 +struct rtRegisterTable_s {
9535 + char *regIdString;
9536 +} rtRegisterTable[] =
9538 + {GEN_ctl, "Basic Mode Control (GEN_ctl) "},
9539 + {GEN_sts, "Basic Mode Status (GEN_sts) "},
9540 + {GEN_id_hi, "PHY Identifier 1 (GET_id_hi) "},
9541 + {GEN_id_lo, "PHY Identifier 2 (GET_id_lo) "},
9542 + {AN_adv, "Auto-Neg Advertisement (AN_adv) "},
9543 + {AN_lpa, "Auto-Neg Link Partner Ability "},
9544 + {AN_exp, "Auto-Neg Expansion "},
9547 +int rtNumRegs = sizeof(rtRegisterTable) / sizeof(rtRegisterTable[0]);
9550 + * Dump the state of a PHY.
9553 +rt_phyShow(int phyUnit)
9557 + int j, loopLower, loopUpper;
9559 + printf("PHY state for ethphy%d\n", phyUnit);
9561 + if (phyUnit == 0) {
9570 + for (j=loopLower; j<=loopUpper; j++) {
9571 + printk("PHY port %d:\n", j);
9572 + for (i=0; i<rtNumRegs; i++) {
9574 + value = phyRegRead(phyBase, j, rtRegisterTable[i].regNum);
9576 + printf("Reg %02d (0x%02x) %s = 0x%08x\n",
9577 + rtRegisterTable[i].regNum, rtRegisterTable[i].regNum,
9578 + rtRegisterTable[i].regIdString, value);
9584 diff -urN linux-mips-orig/drivers/net/ath/Makefile linux-mips-new/drivers/net/ath/Makefile
9585 --- linux-mips-orig/drivers/net/ath/Makefile 1970-01-01 01:00:00.000000000 +0100
9586 +++ linux-mips-new/drivers/net/ath/Makefile 2005-12-31 12:33:57.678538064 +0000
9588 +################################################################################
9590 +# This file is subject to the terms and conditions of the GNU General Public
9591 +# License. See the file "COPYING" in the main directory of this archive
9592 +# for more details.
9594 +# Copyright © 2004 Atheros Communications, Inc., All Rights Reserved.
9596 +# Makefile for Atheros ar531x ethernet driver
9598 +# Note! Dependencies are done automagically by 'make dep', which also
9599 +# removes any old dependencies. DON'T put your own dependencies here
9600 +# unless it's something special (ie not a .c file).
9602 +################################################################################
9605 +# Makefile for the Atheros ar531x ethernet driver
9611 +ae531x-objs := ae531xlnx.o ae531xmac.o
9612 +export-objs := ae531xlnx.o
9613 +list-multi := ae531x.o
9615 +ifeq ($(CONFIG_KENDIN_ENET_PHY),y)
9616 + ae531x-objs += rtPhy.o
9618 +ifeq ($(CONFIG_KENDIN_KS8995XA_ENET_PHY),y)
9619 + ae531x-objs += kendSwitchPhy.o
9621 +ifeq ($(CONFIG_MARVELL_ENET_PHY),y)
9622 + ae531x-objs += mvPhy.o
9624 +ifeq ($(CONFIG_ICPLUS_ENET_PHY),y)
9625 + ae531x-objs += ipPhy.o
9629 +# If building directly into kernel
9631 +ifneq ($(MAKING_MODULES),1)
9632 +obj-$(CONFIG_NET_ATHEROS_ETHER) := ae531x.o $(ae531x-objs)
9633 +O_TARGET := ae531x.o
9638 +EXTRA_CFLAGS+=$(INCS) ${COPTS} -g
9639 +ifeq ($(DEBUG_BUILD),1)
9640 +EXTRA_CFLAGS+=-DDEBUG
9643 +# release tag versioning
9644 +-include $(KERNELPATH)/ath_version.mk
9646 +-include $(TOPDIR)/Rules.make
9647 +STRIP= ${TOOLPREFIX}strip
9650 +MODPATH = ${KERNELPATH}/arch/mips/ar531x/ROOTDISK/rootdir/lib/modules/${KERNELRELEASE}/
9654 + $(MAKE) -C ${KERNELPATH} SUBDIRS=$(shell pwd) modules
9657 + $(STRIP) -S ae531x.o
9658 + cp ae531x.o ${KERNELPATH}/arch/mips/ar531x/ROOTDISK/rootdir/lib/modules/$(strip $(shell head -n 1 $(KERNELPATH)/Makefile | cut -f 2 -d'=')).$(strip $(shell head -n 2 $(KERNELPATH)/Makefile | tail -1 | cut -f 2 -d'=')).$(strip $(shell head -n 3 $(KERNELPATH)/Makefile | tail -1 | cut -f 2 -d'='))${EXTRAVERSION}/net/.
9661 + -rm -f *~ *.o *.ko *.mod.c
9662 + -rm -f .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
9664 +ae531x.o : $(ae531x-objs)
9665 + $(LD) -o ae531x.o -r $(ae531x-objs)
9666 diff -urN linux-mips-orig/drivers/net/ath/mvPhy.c linux-mips-new/drivers/net/ath/mvPhy.c
9667 --- linux-mips-orig/drivers/net/ath/mvPhy.c 1970-01-01 01:00:00.000000000 +0100
9668 +++ linux-mips-new/drivers/net/ath/mvPhy.c 2005-12-31 12:33:57.726530768 +0000
9671 + * This file is subject to the terms and conditions of the GNU General Public
9672 + * License. See the file "COPYING" in the main directory of this archive
9673 + * for more details.
9675 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
9679 +* Manage the ethernet PHY switch, Marvell 88E6060.
9681 +* This module is intended to be largely OS and platform-independent.
9685 +#include <linux/config.h>
9686 +#include <linux/types.h>
9687 +#include <linux/netdevice.h>
9688 +#include <linux/etherdevice.h>
9689 +#include <linux/delay.h>
9691 +#include "ar531xlnx.h"
9694 +#if defined(__ECOS)
9695 +#include "ae531xecos.h"
9699 +#include "ae531xmac.h"
9700 +#include "ae531xreg.h"
9704 +#define MV_DEBUG_ERROR 0x00000001
9705 +#define MV_DEBUG_PHYSETUP 0x00000002
9706 +#define MV_DEBUG_PHYCHANGE 0x00000004
9708 +int mvPhyDebug = MV_DEBUG_ERROR;
9710 +#define MV_PRINT(FLG, X) \
9712 + if (mvPhyDebug & (FLG)) { \
9717 +#define MV_PRINT(FLG, X)
9720 +#if CONFIG_VENETDEV
9722 + * On AR5312 with CONFIG_VENETDEV==1,
9723 + * ports 0..3 are LAN ports (accessed through ae0)
9724 + * port 4 is the WAN port. (accessed through ae1)
9726 + * The phy switch settings in the mvPhyInfo table are set accordingly.
9728 +#define MV_WAN_PORT 4
9729 +#define MV_IS_LAN_PORT(port) ((port) < MV_WAN_PORT)
9730 +#define MV_IS_WAN_PORT(port) ((port) == MV_WAN_PORT)
9734 + * Track per-PHY port information.
9737 + BOOL isEnetPort; /* normal enet port */
9738 + BOOL isPhyAlive; /* last known state of link */
9739 + int ethUnit; /* MAC associated with this phy port */
9741 + UINT32 phyAddr; /* PHY registers associated with this phy port */
9742 + UINT32 switchPortAddr; /* switch port regs assoc'ed with this phy port */
9743 + UINT32 VLANTableSetting; /* Value to be written to VLAN table */
9746 +/******************************************************************************
9747 + * Per-PHY information, indexed by PHY unit number.
9749 + * This table is board-dependent. It includes information
9750 + * about which enet MAC controls which PHY port.
9752 +mvPhyInfo_t mvPhyInfo[] = {
9754 + * On AP30/AR5312, all PHYs are associated with MAC0.
9755 + * AP30/AR5312's MAC1 isn't used for anything.
9756 + * CONFIG_VENETDEV==1 (router) configuration:
9757 + * Ports 0,1,2, and 3 are "LAN ports"
9758 + * Port 4 is a WAN port
9759 + * Port 5 connects to MAC0 in the AR5312
9760 + * CONFIG_VENETDEV==0 (bridge) configuration:
9761 + * Ports 0,1,2,3,4 are "LAN ports"
9762 + * Port 5 connects to the MAC0 in the AR5312
9764 + {isEnetPort: TRUE, /* phy port 0 -- LAN port 0 */
9765 + isPhyAlive: FALSE,
9769 + switchPortAddr: 0x18,
9770 +#if CONFIG_VENETDEV
9771 + VLANTableSetting: 0x2e
9773 + VLANTableSetting: 0x3e
9777 + {isEnetPort: TRUE, /* phy port 1 -- LAN port 1 */
9778 + isPhyAlive: FALSE,
9782 + switchPortAddr: 0x19,
9783 +#if CONFIG_VENETDEV
9784 + VLANTableSetting: 0x2d
9786 + VLANTableSetting: 0x3d
9790 + {isEnetPort: TRUE, /* phy port 2 -- LAN port 2 */
9791 + isPhyAlive: FALSE,
9795 + switchPortAddr: 0x1a,
9796 +#if CONFIG_VENETDEV
9797 + VLANTableSetting: 0x2b
9799 + VLANTableSetting: 0x3b
9803 + {isEnetPort: TRUE, /* phy port 3 -- LAN port 3 */
9804 + isPhyAlive: FALSE,
9808 + switchPortAddr: 0x1b,
9809 +#if CONFIG_VENETDEV
9810 + VLANTableSetting: 0x27
9812 + VLANTableSetting: 0x37
9816 + {isEnetPort: TRUE, /* phy port 4 -- WAN port or LAN port 4 */
9817 + isPhyAlive: FALSE,
9821 + switchPortAddr: 0x1c,
9822 +#if CONFIG_VENETDEV
9823 + VLANTableSetting: 0x1020 /* WAN port */
9825 + VLANTableSetting: 0x2f /* LAN port 4 */
9829 + {isEnetPort: FALSE, /* phy port 5 -- CPU port (no RJ45 connector) */
9834 + switchPortAddr: 0x1d,
9835 +#if CONFIG_VENETDEV
9836 + VLANTableSetting: 0x0f /* Send only to LAN ports */
9838 + VLANTableSetting: 0x1f /* Send to all ports */
9843 +#define MV_PHY_MAX (sizeof(mvPhyInfo) / sizeof(mvPhyInfo[0]))
9845 +/* Range of valid PHY IDs is [MIN..MAX] */
9846 +#define MV_ID_MIN 0
9847 +#define MV_ID_MAX (MV_PHY_MAX-1)
9849 +/* Convenience macros to access myPhyInfo */
9850 +#define MV_IS_ENET_PORT(phyUnit) (mvPhyInfo[phyUnit].isEnetPort)
9851 +#define MV_IS_PHY_ALIVE(phyUnit) (mvPhyInfo[phyUnit].isPhyAlive)
9852 +#define MV_ETHUNIT(phyUnit) (mvPhyInfo[phyUnit].ethUnit)
9853 +#define MV_PHYBASE(phyUnit) (mvPhyInfo[phyUnit].phyBase)
9854 +#define MV_PHYADDR(phyUnit) (mvPhyInfo[phyUnit].phyAddr)
9855 +#define MV_SWITCH_PORT_ADDR(phyUnit) (mvPhyInfo[phyUnit].switchPortAddr)
9856 +#define MV_VLAN_TABLE_SETTING(phyUnit) (mvPhyInfo[phyUnit].VLANTableSetting)
9858 +#define MV_IS_ETHUNIT(phyUnit, ethUnit) \
9859 + (MV_IS_ENET_PORT(phyUnit) && \
9860 + MV_ETHUNIT(phyUnit) == (ethUnit))
9863 +/* Forward references */
9864 +BOOL mv_phyIsLinkAlive(int phyUnit);
9865 +LOCAL void mv_VLANInit(int ethUnit);
9866 +LOCAL void mv_enableConfiguredPorts(int ethUnit);
9867 +LOCAL void mv_verifyReady(int ethUnit);
9868 +BOOL mv_phySetup(int ethUnit, UINT32 phyBase);
9869 +int mv_phyIsFullDuplex(int ethUnit);
9870 +BOOL mv_phyIsSpeed100(int phyUnit);
9871 +LOCAL BOOL mv_validPhyId(int phyUnit);
9872 +void mv_flushATUDB(int phyUnit);
9873 +void mv_phyCheckStatusChange(int ethUnit);
9875 +void mv_phyShow(int phyUnit);
9876 +void mv_phySet(int phyUnit, UINT32 regnum, UINT32 value);
9877 +void mv_switchPortSet(int phyUnit, UINT32 regnum, UINT32 value);
9878 +void mv_switchGlobalSet(int phyUnit, UINT32 regnum, UINT32 value);
9879 +void mv_showATUDB(int phyUnit);
9880 +void mv_countGoodFrames(int phyUnit);
9881 +void mv_countBadFrames(int phyUnit);
9882 +void mv_showFrameCounts(int phyUnit);
9886 +/******************************************************************************
9888 +* mv_phyIsLinkAlive - test to see if the specified link is alive
9891 +* TRUE --> link is alive
9892 +* FALSE --> link is down
9895 +mv_phyIsLinkAlive(int phyUnit)
9897 + UINT16 phyHwStatus;
9901 + phyBase = MV_PHYBASE(phyUnit);
9902 + phyAddr = MV_PHYADDR(phyUnit);
9904 + phyHwStatus = phyRegRead(phyBase, phyAddr, MV_PHY_SPECIFIC_STATUS);
9906 + if (phyHwStatus & MV_STATUS_REAL_TIME_LINK_UP) {
9913 +/******************************************************************************
9915 +* mv_VLANInit - initialize "port-based VLANs" for the specified enet unit.
9918 +mv_VLANInit(int ethUnit)
9922 + UINT32 switchPortAddr;
9924 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
9925 + if (MV_ETHUNIT(phyUnit) != ethUnit) {
9929 + phyBase = MV_PHYBASE(phyUnit);
9930 + switchPortAddr = MV_SWITCH_PORT_ADDR(phyUnit);
9932 + phyRegWrite(phyBase, switchPortAddr, MV_PORT_BASED_VLAN_MAP,
9933 + MV_VLAN_TABLE_SETTING(phyUnit));
9937 +#define phyPortConfigured(phyUnit) TRUE /* TBDFREEDOM2 */
9939 +/******************************************************************************
9941 +* mv_enableConfiguredPorts - enable whichever PHY ports are supposed
9942 +* to be enabled according to administrative configuration.
9945 +mv_enableConfiguredPorts(int ethUnit)
9949 + UINT32 switchPortAddr;
9950 + UINT16 portControl;
9951 + UINT16 portAssociationVector;
9953 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
9954 + if (MV_ETHUNIT(phyUnit) != ethUnit) {
9958 + phyBase = MV_PHYBASE(phyUnit);
9959 + switchPortAddr = MV_SWITCH_PORT_ADDR(phyUnit);
9961 + if (phyPortConfigured(phyUnit)) {
9963 + portControl = MV_PORT_CONTROL_PORT_STATE_FORWARDING;
9964 +#if CONFIG_VENETDEV
9965 + if (!MV_IS_ENET_PORT(phyUnit)) { /* CPU port */
9966 + portControl |= MV_PORT_CONTROL_INGRESS_TRAILER
9967 + | MV_PORT_CONTROL_EGRESS_MODE;
9970 + phyRegWrite(phyBase, switchPortAddr, MV_PORT_CONTROL, portControl);
9972 + portAssociationVector = 1 << phyUnit;
9974 + phyRegWrite(phyBase, switchPortAddr,
9975 + MV_PORT_ASSOCIATION_VECTOR, portAssociationVector);
9980 +/******************************************************************************
9982 +* mv_verifyReady - validates that we're dealing with the device
9983 +* we think we're dealing with, and that it's ready.
9986 +mv_verifyReady(int ethUnit)
9989 + UINT16 globalStatus;
9990 + UINT32 phyBase = 0;
9992 + UINT32 switchPortAddr;
9998 + * The first read to the Phy port registers always fails and
9999 + * returns 0. So get things started with a bogus read.
10001 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
10002 + if (!MV_IS_ETHUNIT(phyUnit, ethUnit)) {
10005 + phyBase = MV_PHYBASE(phyUnit);
10006 + phyAddr = MV_PHYADDR(phyUnit);
10008 + (void)phyRegRead(phyBase, phyAddr, MV_PHY_ID1); /* returns 0 */
10012 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
10013 + if (!MV_IS_ETHUNIT(phyUnit, ethUnit)) {
10017 + /*******************/
10018 + /* Verify phy port */
10019 + /*******************/
10020 + phyBase = MV_PHYBASE(phyUnit);
10021 + phyAddr = MV_PHYADDR(phyUnit);
10023 + phyID1 = phyRegRead(phyBase, phyAddr, MV_PHY_ID1);
10024 + if (phyID1 != MV_PHY_ID1_EXPECTATION) {
10025 + MV_PRINT(MV_DEBUG_PHYSETUP,
10026 + ("Invalid PHY ID1 for ethmac%d port%d. Expected 0x%04x, read 0x%04x\n",
10029 + MV_PHY_ID1_EXPECTATION,
10034 + phyID2 = phyRegRead(phyBase, phyAddr, MV_PHY_ID2);
10035 + if ((phyID2 & MV_OUI_LSB_MASK) != MV_OUI_LSB_EXPECTATION) {
10036 + MV_PRINT(MV_DEBUG_PHYSETUP,
10037 + ("Invalid PHY ID2 for ethmac%d port %d. Expected 0x%04x, read 0x%04x\n",
10040 + MV_OUI_LSB_EXPECTATION,
10045 + MV_PRINT(MV_DEBUG_PHYSETUP,
10046 + ("Found PHY ethmac%d port%d: model 0x%x revision 0x%x\n",
10049 + (phyID2 & MV_MODEL_NUM_MASK) >> MV_MODEL_NUM_SHIFT,
10050 + (phyID2 & MV_REV_NUM_MASK) >> MV_REV_NUM_SHIFT));
10053 + /**********************/
10054 + /* Verify switch port */
10055 + /**********************/
10056 + switchPortAddr = MV_SWITCH_PORT_ADDR(phyUnit);
10058 + switchID = phyRegRead(phyBase, switchPortAddr, MV_SWITCH_ID);
10059 + if ((switchID & MV_SWITCH_ID_DEV_MASK) !=
10060 + MV_SWITCH_ID_DEV_EXPECTATION) {
10062 + MV_PRINT(MV_DEBUG_PHYSETUP,
10063 + ("Invalid switch ID for ethmac%d port %d. Expected 0x%04x, read 0x%04x\n",
10066 + MV_SWITCH_ID_DEV_EXPECTATION,
10071 + MV_PRINT(MV_DEBUG_PHYSETUP,
10072 + ("Found PHY switch for enet %d port %d deviceID 0x%x revision 0x%x\n",
10075 + (switchID & MV_SWITCH_ID_DEV_MASK) >> MV_SWITCH_ID_DEV_SHIFT,
10076 + (switchID & MV_SWITCH_ID_REV_MASK) >> MV_SWITCH_ID_REV_SHIFT))
10079 + /*******************************/
10080 + /* Verify that switch is ready */
10081 + /*******************************/
10083 + globalStatus = phyRegRead(phyBase, MV_SWITCH_GLOBAL_ADDR,
10084 + MV_SWITCH_GLOBAL_STATUS);
10086 + if (!(globalStatus & MV_SWITCH_STATUS_READY_MASK)) {
10087 + MV_PRINT(MV_DEBUG_PHYSETUP,
10088 + ("PHY switch for ethmac%d NOT ready!\n",
10092 + MV_PRINT(MV_DEBUG_PHYSETUP,
10093 + ("No ports configured for ethmac%d\n", ethUnit));
10097 +/******************************************************************************
10099 +* mv_phySetup - reset and setup the PHY switch.
10101 +* Resets each PHY port.
10104 +* TRUE --> at least 1 PHY with LINK
10105 +* FALSE --> no LINKs on this ethernet unit
10108 +mv_phySetup(int ethUnit, UINT32 phyBase)
10111 + int liveLinks = 0;
10112 + BOOL foundPhy = FALSE;
10114 + UINT16 atuControl;
10117 + * Allow platform-specific code to determine the default Ethernet MAC
10118 + * at run-time. If phyEthMacDefault returns a negative value, use the
10119 + * static mvPhyInfo table "as is". But if phyEthMacDefault returns a
10120 + * non-negative value, use it as the default ethernet unit.
10123 + int ethMacDefault = phyEthMacDefault();
10125 + if (ethMacDefault >= 0) {
10126 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
10127 + MV_ETHUNIT(phyUnit)=ethMacDefault;
10133 + * See if there's any configuration data for this enet,
10134 + * and set up phyBase in table.
10136 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
10137 + if (MV_ETHUNIT(phyUnit) != ethUnit) {
10141 + MV_PHYBASE(phyUnit) = phyBase;
10146 + return FALSE; /* No PHY's configured for this ethUnit */
10149 + /* Verify that the switch is what we think it is, and that it's ready */
10150 + mv_verifyReady(ethUnit);
10152 + /* Initialize global switch settings */
10153 + atuControl = MV_ATUCTRL_AGE_TIME_DEFAULT << MV_ATUCTRL_AGE_TIME_SHIFT;
10154 + atuControl |= MV_ATUCTRL_ATU_SIZE_DEFAULT << MV_ATUCTRL_ATU_SIZE_SHIFT;
10155 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_CONTROL, atuControl);
10157 + /* Reset PHYs and start autonegoation on each. */
10158 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
10159 + if (MV_ETHUNIT(phyUnit) != ethUnit) {
10163 + phyBase = MV_PHYBASE(phyUnit);
10164 + phyAddr = MV_PHYADDR(phyUnit);
10166 + phyRegWrite(phyBase, phyAddr, MV_PHY_CONTROL,
10167 + MV_CTRL_SOFTWARE_RESET | MV_CTRL_AUTONEGOTIATION_ENABLE);
10170 +#if 0 /* Don't wait -- we'll detect shortly after the link comes up */
10173 + UINT16 phyHwStatus;
10176 + * Wait 5 seconds for ALL associated PHYs to finish autonegotiation.
10179 + for (phyUnit=0; (phyUnit < MV_PHY_MAX) && (timeout > 0); phyUnit++) {
10180 + if (!MV_IS_ETHUNIT(phyUnit, ethUnit)) {
10184 + phyBase = MV_PHYBASE(phyUnit);
10185 + phyAddr = MV_PHYADDR(phyUnit);
10187 + phyHwStatus = phyRegRead(phyBase, phyAddr, MV_PHY_SPECIFIC_STATUS);
10189 + if (MV_AUTONEG_DONE(phyHwStatus)) {
10193 + if (--timeout == 0) {
10204 + * All PHYs have had adequate time to autonegotiate.
10205 + * Now initialize software status.
10207 + * It's possible that some ports may take a bit longer
10208 + * to autonegotiate; but we can't wait forever. They'll
10209 + * get noticed by mv_phyCheckStatusChange during regular
10210 + * polling activities.
10212 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
10213 + if (!MV_IS_ETHUNIT(phyUnit, ethUnit)) {
10217 + if (mv_phyIsLinkAlive(phyUnit)) {
10219 + MV_IS_PHY_ALIVE(phyUnit) = TRUE;
10221 + MV_IS_PHY_ALIVE(phyUnit) = FALSE;
10224 + MV_PRINT(MV_DEBUG_PHYSETUP,
10225 + ("ethmac%d: Phy Status=%4.4x\n",
10227 + phyRegRead(MV_PHYBASE(phyUnit),
10228 + MV_PHYADDR(phyUnit),
10229 + MV_PHY_SPECIFIC_STATUS)));
10232 + mv_VLANInit(ethUnit);
10234 + mv_enableConfiguredPorts(ethUnit);
10236 + return (liveLinks > 0);
10240 +/******************************************************************************
10242 +* mv_phyIsDuplexFull - Determines whether the phy ports associated with the
10243 +* specified device are FULL or HALF duplex.
10246 +* 1 --> at least one associated PHY in FULL DUPLEX
10247 +* 0 --> all half duplex
10251 +mv_phyIsFullDuplex(int ethUnit)
10256 + UINT16 phyHwStatus;
10257 + int oneIsReady=0;
10259 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
10260 + if (!MV_IS_ETHUNIT(phyUnit, ethUnit)) {
10264 + if (mv_phyIsLinkAlive(phyUnit)) {
10267 + phyBase = MV_PHYBASE(phyUnit);
10268 + phyAddr = MV_PHYADDR(phyUnit);
10270 + phyHwStatus = phyRegRead(phyBase, phyAddr, MV_PHY_SPECIFIC_STATUS);
10272 + if (phyHwStatus & MV_STATUS_RESOLVED_DUPLEX_FULL) {
10283 +/******************************************************************************
10285 +* mv_phyIsSpeed100 - Determines the speed of a phy port
10288 +* TRUE --> PHY operating at 100 Mbit
10289 +* FALSE --> link down, or not operating at 100 Mbit
10292 +mv_phyIsSpeed100(int phyUnit)
10294 + UINT16 phyHwStatus;
10298 + if (MV_IS_ENET_PORT(phyUnit)) {
10299 + if (mv_phyIsLinkAlive(phyUnit)) {
10301 + phyBase = MV_PHYBASE(phyUnit);
10302 + phyAddr = MV_PHYADDR(phyUnit);
10304 + phyHwStatus = phyRegRead(phyBase, phyAddr, MV_PHY_SPECIFIC_STATUS);
10306 + if (phyHwStatus & MV_STATUS_RESOLVED_SPEED_100) {
10315 +#if CONFIG_VENETDEV
10316 +/******************************************************************************
10318 +* mv_phyDetermineSource - Examine a received frame's Egress Trailer
10319 +* to determine whether it came from a LAN or WAN port.
10322 +* Sets *pFromLAN: 1-->LAN, 0-->WAN
10323 +* Modifies *pLen to remove PHY trailer from frame
10326 +mv_phyDetermineSource(char *data, int len, int *pFromLAN)
10328 + unsigned char *phyTrailer;
10329 + unsigned char incomingPort;
10331 + phyTrailer = &data[len - MV_PHY_TRAILER_SIZE];
10332 + ASSERT(phyTrailer[0] == MV_EGRESS_TRAILER_VALID);
10334 + incomingPort = phyTrailer[1];
10335 + if (MV_IS_LAN_PORT(incomingPort)) {
10338 + ASSERT(MV_IS_WAN_PORT(incomingPort));
10344 +/******************************************************************************
10346 +* mv_phySetDestinationPort - Set the Ingress Trailer to force the
10347 +* frame to be sent to LAN or WAN, as specified.
10351 +mv_phySetDestinationPort(char *data, int len, int fromLAN)
10353 + char *phyTrailer;
10355 + phyTrailer = &data[len];
10357 + /* LAN ports: Use default settings, as per mvPhyInfo */
10358 + phyTrailer[0] = 0x00;
10359 + phyTrailer[1] = 0x00;
10361 + /* WAN port: Direct to WAN port */
10362 + phyTrailer[0] = MV_INGRESS_TRAILER_OVERRIDE;
10363 + phyTrailer[1] = 1 << MV_WAN_PORT;
10365 + phyTrailer[2] = 0x00;
10366 + phyTrailer[3] = 0x00;
10371 +/*****************************************************************************
10373 +* Validate that the specified PHY unit number is a valid PHY ID.
10374 +* Print a message if it is invalid.
10377 +* FALSE --> invalid
10380 +mv_validPhyId(int phyUnit)
10382 + if ((phyUnit >= MV_ID_MIN) && (phyUnit <= MV_ID_MAX)) {
10385 + PRINTF("PHY unit number must be in the range [%d..%d]\n",
10386 + MV_ID_MIN, MV_ID_MAX);
10392 +/*****************************************************************************
10394 +* mv_waitWhileATUBusy - spins until the ATU completes
10395 +* its previous operation.
10398 +mv_waitWhileATUBusy(UINT32 phyBase)
10401 + UINT16 ATUOperation;
10405 + ATUOperation = phyRegRead(phyBase, MV_SWITCH_GLOBAL_ADDR,
10406 + MV_ATU_OPERATION);
10408 + isBusy = (ATUOperation & MV_ATU_BUSY_MASK) == MV_ATU_IS_BUSY;
10413 +/*****************************************************************************
10415 +* mv_flushATUDB - flushes ALL entries in the Address Translation Unit
10416 +* DataBase associated with phyUnit. [Since we use a single DB for
10417 +* all PHYs, this flushes the entire shared DataBase.]
10419 +* The current implementation flushes even more than absolutely needed --
10420 +* it flushes all entries for all phyUnits on the same ethernet as the
10421 +* specified phyUnit.
10423 +* It is called only when a link failure is detected on a port that was
10424 +* previously working. In other words, when the cable is unplugged.
10427 +mv_flushATUDB(int phyUnit)
10431 + if (!mv_validPhyId(phyUnit)) {
10432 + PRINTF("Invalid port number: %d\n", phyUnit);
10436 + phyBase = MV_PHYBASE(phyUnit);
10438 + /* Wait for previous operation (if any) to complete */
10439 + mv_waitWhileATUBusy(phyBase);
10441 + /* Tell hardware to flush all entries */
10442 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_OPERATION,
10443 + MV_ATU_OP_FLUSH_ALL | MV_ATU_IS_BUSY);
10445 + mv_waitWhileATUBusy(phyBase);
10448 +/*****************************************************************************
10450 +* mv_phyCheckStatusChange -- checks for significant changes in PHY state.
10452 +* A "significant change" is:
10453 +* dropped link (e.g. ethernet cable unplugged) OR
10454 +* autonegotiation completed + link (e.g. ethernet cable plugged in)
10457 +mv_phyCheckStatusChange(int ethUnit)
10460 + UINT16 phyHwStatus;
10461 + mvPhyInfo_t *lastStatus;
10462 + int linkCount = 0;
10463 + int lostLinks = 0;
10464 + int gainedLinks = 0;
10468 + for (phyUnit=0; phyUnit < MV_PHY_MAX; phyUnit++) {
10469 + if (!MV_IS_ETHUNIT(phyUnit, ethUnit)) {
10473 + phyBase = MV_PHYBASE(phyUnit);
10474 + phyAddr = MV_PHYADDR(phyUnit);
10476 + lastStatus = &mvPhyInfo[phyUnit];
10477 + phyHwStatus = phyRegRead(phyBase, phyAddr, MV_PHY_SPECIFIC_STATUS);
10479 + if (lastStatus->isPhyAlive) { /* last known link status was ALIVE */
10480 + /* See if we've lost link */
10481 + if (phyHwStatus & MV_STATUS_REAL_TIME_LINK_UP) {
10485 + mv_flushATUDB(phyUnit);
10486 + MV_PRINT(MV_DEBUG_PHYCHANGE,("\nethmac%d port%d down\n",
10487 + ethUnit, phyUnit));
10488 + lastStatus->isPhyAlive = FALSE;
10490 + } else { /* last known link status was DEAD */
10491 + /* Check for AutoNegotiation complete */
10492 + if (MV_AUTONEG_DONE(phyHwStatus)) {
10495 + MV_PRINT(MV_DEBUG_PHYCHANGE,("\nethmac%d port%d up\n",
10496 + ethUnit, phyUnit));
10497 + lastStatus->isPhyAlive = TRUE;
10502 + if (linkCount == 0) {
10504 + /* We just lost the last link for this MAC */
10505 + phyLinkLost(ethUnit);
10508 + if (gainedLinks == linkCount) {
10509 + /* We just gained our first link(s) for this MAC */
10510 + phyLinkGained(ethUnit);
10517 +/* Define the registers of interest for a phyShow command */
10518 +typedef struct mvRegisterTableEntry_s {
10520 + char *regIdString;
10521 +} mvRegisterTableEntry_t;
10523 +mvRegisterTableEntry_t mvPhyRegisterTable[] = {
10524 + {MV_PHY_CONTROL, "PHY Control "},
10525 + {MV_PHY_STATUS, "PHY Status "},
10526 + {MV_PHY_ID1, "PHY Identifier 1 "},
10527 + {MV_PHY_ID2, "PHY Identifier 2 "},
10528 + {MV_AUTONEG_ADVERT, "Auto-Negotiation Advertisement "},
10529 + {MV_LINK_PARTNER_ABILITY, "Link Partner Ability "},
10530 + {MV_AUTONEG_EXPANSION, "Auto-Negotiation Expansion "},
10531 + {MV_NEXT_PAGE_TRANSMIT, "Next Page Transmit "},
10532 + {MV_LINK_PARTNER_NEXT_PAGE, "Link Partner Next Page "},
10533 + {MV_PHY_SPECIFIC_CONTROL_1, "PHY-Specific Control Register 1 "},
10534 + {MV_PHY_SPECIFIC_STATUS, "PHY-Specific Status "},
10535 + {MV_PHY_INTERRUPT_ENABLE, "PHY Interrupt Enable "},
10536 + {MV_PHY_INTERRUPT_STATUS, "PHY Interrupt Status "},
10537 + {MV_PHY_INTERRUPT_PORT_SUMMARY, "PHY Interrupt Port Summary "},
10538 + {MV_RECEIVE_ERROR_COUNTER, "Receive Error Counter "},
10539 + {MV_LED_PARALLEL_SELECT, "LED Parallel Select "},
10540 + {MV_LED_STREAM_SELECT_LEDS, "LED Stream Select "},
10541 + {MV_PHY_LED_CONTROL, "PHY LED Control "},
10542 + {MV_PHY_MANUAL_LED_OVERRIDE, "PHY Manual LED Override "},
10543 + {MV_VCT_CONTROL, "VCT Control "},
10544 + {MV_VCT_STATUS, "VCT Status "},
10545 + {MV_PHY_SPECIFIC_CONTROL_2, "PHY-Specific Control Register 2 "},
10547 +int mvPhyNumRegs = sizeof(mvPhyRegisterTable) / sizeof(mvPhyRegisterTable[0]);
10550 +mvRegisterTableEntry_t mvSwitchPortRegisterTable[] = {
10551 + {MV_PORT_STATUS, "Port Status "},
10552 + {MV_SWITCH_ID, "Switch ID "},
10553 + {MV_PORT_CONTROL, "Port Control "},
10554 + {MV_PORT_BASED_VLAN_MAP, "Port-Based VLAN Map "},
10555 + {MV_PORT_ASSOCIATION_VECTOR, "Port Association Vector "},
10556 + {MV_RX_COUNTER, "RX Counter "},
10557 + {MV_TX_COUNTER, "TX Counter "},
10559 +int mvSwitchPortNumRegs =
10560 + sizeof(mvSwitchPortRegisterTable) / sizeof(mvSwitchPortRegisterTable[0]);
10563 +mvRegisterTableEntry_t mvSwitchGlobalRegisterTable[] = {
10564 + {MV_SWITCH_GLOBAL_STATUS, "Switch Global Status "},
10565 + {MV_SWITCH_MAC_ADDR0, "Switch MAC Addr 0 & 1 "},
10566 + {MV_SWITCH_MAC_ADDR2, "Switch MAC Addr 2 & 3 "},
10567 + {MV_SWITCH_MAC_ADDR4, "Switch MAC Addr 4 & 5 "},
10568 + {MV_SWITCH_GLOBAL_CONTROL, "Switch Global Control "},
10569 + {MV_ATU_CONTROL, "ATU Control "},
10570 + {MV_ATU_OPERATION, "ATU Operation "},
10571 + {MV_ATU_DATA, "ATU Data "},
10572 + {MV_ATU_MAC_ADDR0, "ATU MAC Addr 0 & 1 "},
10573 + {MV_ATU_MAC_ADDR2, "ATU MAC Addr 2 & 3 "},
10574 + {MV_ATU_MAC_ADDR4, "ATU MAC Addr 4 & 5 "},
10576 +int mvSwitchGlobalNumRegs =
10577 + sizeof(mvSwitchGlobalRegisterTable) / sizeof(mvSwitchGlobalRegisterTable[0]);
10579 +void my_mvPhyShow(int ethUnit)
10582 + for (phyUnit=0; (phyUnit < MV_PHY_MAX); phyUnit++) {
10583 + if (!MV_IS_ETHUNIT(phyUnit, ethUnit)) {
10586 + mv_phyShow(phyUnit);
10590 +/*****************************************************************************
10592 +* mv_phyShow - Dump the state of a PHY.
10593 +* There are two sets of registers for each phy port:
10594 +* "phy registers" and
10595 +* "switch port registers"
10596 +* We dump 'em all, plus the switch global registers.
10599 +mv_phyShow(int phyUnit)
10605 + UINT32 switchPortAddr;
10607 + if (!mv_validPhyId(phyUnit)) {
10611 + phyBase = MV_PHYBASE(phyUnit);
10612 + phyAddr = MV_PHYADDR(phyUnit);
10613 + switchPortAddr = MV_SWITCH_PORT_ADDR(phyUnit);
10615 + printk("PHY state for PHY%d (ethmac%d, phyBase 0x%8x, phyAddr 0x%x, switchAddr 0x%x)\n",
10617 + MV_ETHUNIT(phyUnit),
10618 + MV_PHYBASE(phyUnit),
10619 + MV_PHYADDR(phyUnit),
10620 + MV_SWITCH_PORT_ADDR(phyUnit));
10622 + printk("PHY Registers:\n");
10623 + for (i=0; i < mvPhyNumRegs; i++) {
10625 + value = phyRegRead(phyBase, phyAddr, mvPhyRegisterTable[i].regNum);
10627 + printk("Reg %02d (0x%02x) %s = 0x%08x\n",
10628 + mvPhyRegisterTable[i].regNum,
10629 + mvPhyRegisterTable[i].regNum,
10630 + mvPhyRegisterTable[i].regIdString,
10634 + printk("Switch Port Registers:\n");
10635 + for (i=0; i < mvSwitchPortNumRegs; i++) {
10637 + value = phyRegRead(phyBase, switchPortAddr,
10638 + mvSwitchPortRegisterTable[i].regNum);
10640 + printk("Reg %02d (0x%02x) %s = 0x%08x\n",
10641 + mvSwitchPortRegisterTable[i].regNum,
10642 + mvSwitchPortRegisterTable[i].regNum,
10643 + mvSwitchPortRegisterTable[i].regIdString,
10647 + printk("Switch Global Registers:\n");
10648 + for (i=0; i < mvSwitchGlobalNumRegs; i++) {
10650 + value = phyRegRead(phyBase, MV_SWITCH_GLOBAL_ADDR,
10651 + mvSwitchGlobalRegisterTable[i].regNum);
10653 + printk("Reg %02d (0x%02x) %s = 0x%08x\n",
10654 + mvSwitchGlobalRegisterTable[i].regNum,
10655 + mvSwitchGlobalRegisterTable[i].regNum,
10656 + mvSwitchGlobalRegisterTable[i].regIdString,
10661 +/*****************************************************************************
10663 +* mv_phySet - Modify the value of a PHY register (debug only).
10666 +mv_phySet(int phyUnit, UINT32 regnum, UINT32 value)
10671 + if (mv_validPhyId(phyUnit)) {
10673 + phyBase = MV_PHYBASE(phyUnit);
10674 + phyAddr = MV_PHYADDR(phyUnit);
10676 + phyRegWrite(phyBase, phyAddr, regnum, value);
10681 +/*****************************************************************************
10683 +* mv_switchPortSet - Modify the value of a switch port register (debug only).
10686 +mv_switchPortSet(int phyUnit, UINT32 regnum, UINT32 value)
10689 + UINT32 switchPortAddr;
10691 + if (mv_validPhyId(phyUnit)) {
10693 + phyBase = MV_PHYBASE(phyUnit);
10694 + switchPortAddr = MV_SWITCH_PORT_ADDR(phyUnit);
10696 + phyRegWrite(phyBase, switchPortAddr, regnum, value);
10700 +/*****************************************************************************
10702 +* mv_switchGlobalSet - Modify the value of a switch global register
10706 +mv_switchGlobalSet(int phyUnit, UINT32 regnum, UINT32 value)
10710 + if (mv_validPhyId(phyUnit)) {
10712 + phyBase = MV_PHYBASE(phyUnit);
10714 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR, regnum, value);
10718 +/*****************************************************************************
10720 +* mv_showATUDB - Dump the contents of the Address Translation Unit DataBase
10721 +* for the PHY switch associated with the specified phy.
10724 +mv_showATUDB(int phyUnit)
10734 + if (!mv_validPhyId(phyUnit)) {
10735 + printk("Invalid port number: %d\n", phyUnit);
10739 + phyBase = MV_PHYBASE(phyUnit);
10741 + /* Wait for previous operation (if any) to complete */
10742 + mv_waitWhileATUBusy(phyBase);
10744 + /* Initialize ATU MAC to all 1's */
10745 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_MAC_ADDR0, 0xffff);
10746 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_MAC_ADDR2, 0xffff);
10747 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_MAC_ADDR4, 0xffff);
10749 + printk(" MAC ADDRESS EntryState PortVector\n");
10752 + /* Tell hardware to get next MAC info */
10753 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_OPERATION,
10754 + MV_ATU_OP_GET_NEXT | MV_ATU_IS_BUSY);
10756 + mv_waitWhileATUBusy(phyBase);
10758 + ATUData = phyRegRead(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_DATA);
10759 + entryState = (ATUData & MV_ENTRYSTATE_MASK) >> MV_ENTRYSTATE_SHIFT;
10761 + if (entryState == 0) {
10762 + /* We've hit the end of the list */
10766 + ATUMac0 = phyRegRead(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_MAC_ADDR0);
10767 + ATUMac2 = phyRegRead(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_MAC_ADDR2);
10768 + ATUMac4 = phyRegRead(phyBase, MV_SWITCH_GLOBAL_ADDR, MV_ATU_MAC_ADDR4);
10770 + portVec = (ATUData & MV_PORTVEC_MASK) >> MV_PORTVEC_SHIFT;
10772 + printk("%02x:%02x:%02x:%02x:%02x:%02x 0x%02x 0x%02x\n",
10773 + ATUMac0 >> 8, /* MAC byte 0 */
10774 + ATUMac0 & 0xff, /* MAC byte 1 */
10775 + ATUMac2 >> 8, /* MAC byte 2 */
10776 + ATUMac2 & 0xff, /* MAC byte 3 */
10777 + ATUMac4 >> 8, /* MAC byte 4 */
10778 + ATUMac4 & 0xff, /* MAC byte 5 */
10784 +LOCAL BOOL countingGoodFrames;
10786 +/*****************************************************************************
10788 +* mv_countGoodFrames - starts counting GOOD RX/TX frames per port
10791 +mv_countGoodFrames(int phyUnit)
10794 + UINT16 globalControl;
10796 + if (mv_validPhyId(phyUnit)) {
10798 + * Guarantee that counters are cleared by
10799 + * forcing CtrMode to toggle and end on GOODFRAMES.
10802 + phyBase = MV_PHYBASE(phyUnit);
10804 + /* Read current Switch Global Control Register */
10805 + globalControl = phyRegRead(phyBase, MV_SWITCH_GLOBAL_ADDR,
10806 + MV_SWITCH_GLOBAL_CONTROL);
10808 + /* Set CtrMode to count BAD frames */
10809 + globalControl = ((globalControl & ~MV_CTRMODE_MASK) |
10810 + MV_CTRMODE_BADFRAMES);
10812 + /* Push new value out to hardware */
10813 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR,
10814 + MV_SWITCH_GLOBAL_CONTROL, globalControl);
10816 + /* Now toggle CtrMode to count GOOD frames */
10817 + globalControl = ((globalControl & ~MV_CTRMODE_MASK) |
10818 + MV_CTRMODE_GOODFRAMES);
10820 + /* Push new value out to hardware */
10821 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR,
10822 + MV_SWITCH_GLOBAL_CONTROL, globalControl);
10824 + countingGoodFrames = TRUE;
10828 +/*****************************************************************************
10830 +* mv_countBadFrames - starts counting BAD RX/TX frames per port
10833 +mv_countBadFrames(int phyUnit)
10836 + UINT16 globalControl;
10838 + if (mv_validPhyId(phyUnit)) {
10840 + * Guarantee that counters are cleared by
10841 + * forcing CtrMode to toggle and end on BADFRAMES.
10844 + phyBase = MV_PHYBASE(phyUnit);
10846 + /* Read current Switch Global Control Register */
10847 + globalControl = phyRegRead(phyBase, MV_SWITCH_GLOBAL_ADDR,
10848 + MV_SWITCH_GLOBAL_CONTROL);
10850 + /* Set CtrMode to count GOOD frames */
10851 + globalControl = ((globalControl & ~MV_CTRMODE_MASK) |
10852 + MV_CTRMODE_GOODFRAMES);
10854 + /* Push new value out to hardware */
10855 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR,
10856 + MV_SWITCH_GLOBAL_CONTROL, globalControl);
10858 + /* Now toggle CtrMode to count BAD frames */
10859 + globalControl = ((globalControl & ~MV_CTRMODE_MASK) |
10860 + MV_CTRMODE_BADFRAMES);
10862 + /* Push new value out to hardware */
10863 + phyRegWrite(phyBase, MV_SWITCH_GLOBAL_ADDR,
10864 + MV_SWITCH_GLOBAL_CONTROL, globalControl);
10866 + countingGoodFrames = FALSE;
10870 +/*****************************************************************************
10872 +* mv_showFrameCounts - shows current GOOD/BAD Frame counts
10875 +mv_showFrameCounts(int phyUnit)
10877 + UINT16 rxCounter;
10878 + UINT16 txCounter;
10880 + UINT32 switchPortAddr;
10882 + if (!mv_validPhyId(phyUnit)) {
10886 + phyBase = MV_PHYBASE(phyUnit);
10887 + switchPortAddr = MV_SWITCH_PORT_ADDR(phyUnit);
10889 + rxCounter = phyRegRead(phyBase, switchPortAddr, MV_RX_COUNTER);
10891 + txCounter = phyRegRead(phyBase, switchPortAddr, MV_TX_COUNTER);
10893 + printk("port%d %s frames: receive: %05d transmit: %05d\n",
10895 + (countingGoodFrames ? "good" : "error"),
10900 diff -urN linux-mips-orig/drivers/net/ath/mvPhy.h linux-mips-new/drivers/net/ath/mvPhy.h
10901 --- linux-mips-orig/drivers/net/ath/mvPhy.h 1970-01-01 01:00:00.000000000 +0100
10902 +++ linux-mips-new/drivers/net/ath/mvPhy.h 2005-12-31 12:33:57.727530616 +0000
10905 + * This file is subject to the terms and conditions of the GNU General Public
10906 + * License. See the file "COPYING" in the main directory of this archive
10907 + * for more details.
10909 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
10913 + * mvPhy.h - definitions for the ethernet PHY -- Marvell 88E6060
10914 + * All definitions in this file are operating system independent!
10920 +/*****************/
10921 +/* PHY Registers */
10922 +/*****************/
10923 +#define MV_PHY_CONTROL 0
10924 +#define MV_PHY_STATUS 1
10925 +#define MV_PHY_ID1 2
10926 +#define MV_PHY_ID2 3
10927 +#define MV_AUTONEG_ADVERT 4
10928 +#define MV_LINK_PARTNER_ABILITY 5
10929 +#define MV_AUTONEG_EXPANSION 6
10930 +#define MV_NEXT_PAGE_TRANSMIT 7
10931 +#define MV_LINK_PARTNER_NEXT_PAGE 8
10932 +#define MV_PHY_SPECIFIC_CONTROL_1 16
10933 +#define MV_PHY_SPECIFIC_STATUS 17
10934 +#define MV_PHY_INTERRUPT_ENABLE 18
10935 +#define MV_PHY_INTERRUPT_STATUS 19
10936 +#define MV_PHY_INTERRUPT_PORT_SUMMARY 20
10937 +#define MV_RECEIVE_ERROR_COUNTER 21
10938 +#define MV_LED_PARALLEL_SELECT 22
10939 +#define MV_LED_STREAM_SELECT_LEDS 23
10940 +#define MV_PHY_LED_CONTROL 24
10941 +#define MV_PHY_MANUAL_LED_OVERRIDE 25
10943 +#define MV_VCT_CONTROL 26
10944 +#define MV_VCT_STATUS 27
10945 +#define MV_PHY_SPECIFIC_CONTROL_2 28
10947 +/* MV_PHY_CONTROL fields */
10948 +#define MV_CTRL_SOFTWARE_RESET 0x8000
10949 +#define MV_CTRL_AUTONEGOTIATION_ENABLE 0x1000
10950 +#define MV_CTRL_FULL_DUPLEX 0x0100
10951 +#define MV_CTRL_100_MBPS 0x2000
10953 +/* MV_PHY_ID1 fields */
10954 +#define MV_PHY_ID1_EXPECTATION 0x0141 /* OUI >> 6 */
10956 +/* MV_PHY_ID2 fields */
10957 +#define MV_OUI_LSB_MASK 0xfc00
10958 +#define MV_OUI_LSB_EXPECTATION 0x0c00
10959 +#define MV_OUI_LSB_SHIFT 10
10960 +#define MV_MODEL_NUM_MASK 0x03f0
10961 +#define MV_MODEL_NUM_SHIFT 4
10962 +#define MV_REV_NUM_MASK 0x000f
10963 +#define MV_REV_NUM_SHIFT 0
10965 +/* MV_PHY_SPECIFIC_STATUS fields */
10966 +#define MV_STATUS_RESOLVED_SPEED_100 0x4000
10967 +#define MV_STATUS_RESOLVED_DUPLEX_FULL 0x2000
10968 +#define MV_STATUS_RESOLVED 0x0800
10969 +#define MV_STATUS_REAL_TIME_LINK_UP 0x0400
10971 +/* Check if autonegotiation is complete and link is up */
10972 +#define MV_AUTONEG_DONE(mv_phy_specific_status) \
10973 + (((mv_phy_specific_status) & \
10974 + (MV_STATUS_RESOLVED | MV_STATUS_REAL_TIME_LINK_UP)) == \
10975 + (MV_STATUS_RESOLVED | MV_STATUS_REAL_TIME_LINK_UP))
10978 +/*************************/
10979 +/* Switch Port Registers */
10980 +/*************************/
10981 +#define MV_PORT_STATUS 0
10982 +#define MV_SWITCH_ID 3
10983 +#define MV_PORT_CONTROL 4
10984 +#define MV_PORT_BASED_VLAN_MAP 6
10985 +#define MV_PORT_ASSOCIATION_VECTOR 11
10986 +#define MV_RX_COUNTER 16
10987 +#define MV_TX_COUNTER 17
10989 +/* MV_SWITCH_ID fields */
10990 +#define MV_SWITCH_ID_DEV_MASK 0xfff0
10991 +#define MV_SWITCH_ID_DEV_EXPECTATION 0x0600
10992 +#define MV_SWITCH_ID_DEV_SHIFT 4
10993 +#define MV_SWITCH_ID_REV_MASK 0x000f
10994 +#define MV_SWITCH_ID_REV_SHIFT 0
10996 +/* MV_PORT_CONTROL fields */
10997 +#define MV_PORT_CONTROL_PORT_STATE_MASK 0x0003
10998 +#define MV_PORT_CONTROL_PORT_STATE_DISABLED 0x0000
10999 +#define MV_PORT_CONTROL_PORT_STATE_FORWARDING 0x0003
11001 +#define MV_PORT_CONTROL_EGRESS_MODE 0x0100 /* Receive */
11002 +#define MV_PORT_CONTROL_INGRESS_TRAILER 0x4000 /* Transmit */
11004 +#define MV_EGRESS_TRAILER_VALID 0x80
11005 +#define MV_INGRESS_TRAILER_OVERRIDE 0x80
11007 +#define MV_PHY_TRAILER_SIZE 4
11010 +/***************************/
11011 +/* Switch Global Registers */
11012 +/***************************/
11013 +#define MV_SWITCH_GLOBAL_STATUS 0
11014 +#define MV_SWITCH_MAC_ADDR0 1
11015 +#define MV_SWITCH_MAC_ADDR2 2
11016 +#define MV_SWITCH_MAC_ADDR4 3
11017 +#define MV_SWITCH_GLOBAL_CONTROL 4
11018 +#define MV_ATU_CONTROL 10
11019 +#define MV_ATU_OPERATION 11
11020 +#define MV_ATU_DATA 12
11021 +#define MV_ATU_MAC_ADDR0 13
11022 +#define MV_ATU_MAC_ADDR2 14
11023 +#define MV_ATU_MAC_ADDR4 15
11025 +/* MV_SWITCH_GLOBAL_STATUS fields */
11026 +#define MV_SWITCH_STATUS_READY_MASK 0x0800
11028 +/* MV_SWITCH_GLOBAL_CONTROL fields */
11029 +#define MV_CTRMODE_MASK 0x0100
11030 +#define MV_CTRMODE_GOODFRAMES 0x0000
11031 +#define MV_CTRMODE_BADFRAMES 0x0100
11033 +/* MV_ATU_CONTROL fields */
11034 +#define MV_ATUCTRL_ATU_SIZE_MASK 0x3000
11035 +#define MV_ATUCTRL_ATU_SIZE_SHIFT 12
11036 +#define MV_ATUCTRL_ATU_SIZE_DEFAULT 2 /* 1024 entry database */
11037 +#define MV_ATUCTRL_AGE_TIME_MASK 0x0ff0
11038 +#define MV_ATUCTRL_AGE_TIME_SHIFT 4
11039 +#define MV_ATUCTRL_AGE_TIME_DEFAULT 19 /* 19 * 16 = 304 seconds */
11041 +/* MV_ATU_OPERATION fields */
11042 +#define MV_ATU_BUSY_MASK 0x8000
11043 +#define MV_ATU_IS_BUSY 0x8000
11044 +#define MV_ATU_IS_FREE 0x0000
11045 +#define MV_ATU_OP_MASK 0x7000
11046 +#define MV_ATU_OP_FLUSH_ALL 0x1000
11047 +#define MV_ATU_OP_GET_NEXT 0x4000
11049 +/* MV_ATU_DATA fields */
11050 +#define MV_ENTRYPRI_MASK 0xc000
11051 +#define MV_ENTRYPRI_SHIFT 14
11052 +#define MV_PORTVEC_MASK 0x03f0
11053 +#define MV_PORTVEC_SHIFT 4
11054 +#define MV_ENTRYSTATE_MASK 0x000f
11055 +#define MV_ENTRYSTATE_SHIFT 0
11057 +/* PHY Address for the switch itself */
11058 +#define MV_SWITCH_GLOBAL_ADDR 0x1f
11060 +BOOL mv_phySetup(int ethUnit, UINT32 phyBase);
11061 +void mv_phyCheckStatusChange(int ethUnit);
11062 +BOOL mv_phyIsSpeed100(int ethUnit);
11063 +int mv_phyIsFullDuplex(int ethUnit);
11065 +#endif /* MVPHY_H */
11066 diff -urN linux-mips-orig/drivers/net/ath/rtPhy.c linux-mips-new/drivers/net/ath/rtPhy.c
11067 --- linux-mips-orig/drivers/net/ath/rtPhy.c 1970-01-01 01:00:00.000000000 +0100
11068 +++ linux-mips-new/drivers/net/ath/rtPhy.c 2005-12-31 12:33:57.727530616 +0000
11071 + * This file is subject to the terms and conditions of the GNU General Public
11072 + * License. See the file "COPYING" in the main directory of this archive
11073 + * for more details.
11075 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
11079 + * Manage the ethernet PHY.
11080 + * This code supports a simple 1-port ethernet phy, Realtek RTL8201BL,
11081 + * and compatible PHYs, such as the Kendin KS8721B.
11082 + * All definitions in this file are operating system independent!
11085 +#if defined(linux)
11086 +#include <linux/config.h>
11087 +#include <linux/types.h>
11088 +#include <linux/netdevice.h>
11089 +#include <linux/etherdevice.h>
11090 +#include <linux/delay.h>
11092 +#include "ar531xlnx.h"
11095 +#if defined(__ECOS)
11096 +#include "ae531xecos.h"
11100 +#include "ae531xmac.h"
11101 +#include "ae531xreg.h"
11102 +#include "rtPhy.h"
11105 +#define RT_DEBUG_ERROR 0x00000001
11106 +#define RT_DEBUG_PHYSETUP 0x00000002
11107 +#define RT_DEBUG_PHYCHANGE 0x00000004
11109 +int rtPhyDebug = RT_DEBUG_ERROR;
11111 +#define RT_PRINT(FLG, X) \
11113 + if (rtPhyDebug & (FLG)) { \
11114 + DEBUG_PRINTF X; \
11118 +#define RT_PRINT(FLG, X)
11122 + * Track per-PHY port information.
11125 + BOOL phyAlive; /* last known state of link */
11130 +#define ETH_PHY_ADDR 1
11133 + * This table defines the mapping from phy units to
11134 + * per-PHY information.
11136 + * This table is somewhat board-dependent.
11138 +rtPhyInfo_t rtPhyInfo[] = {
11139 + {phyAlive: FALSE, /* PHY 0 */
11140 + phyBase: 0, /* filled in by rt_phySetup */
11141 + phyAddr: ETH_PHY_ADDR},
11143 + {phyAlive: FALSE, /* PHY 1 */
11144 + phyBase: 0, /* filled in by rt_phySetup */
11145 + phyAddr: ETH_PHY_ADDR}
11148 +/* Convert from phy unit# to (phyBase, phyAddr) pair */
11149 +#define RT_PHYBASE(phyUnit) (rtPhyInfo[phyUnit].phyBase)
11150 +#define RT_PHYADDR(phyUnit) (rtPhyInfo[phyUnit].phyAddr)
11153 +/******************************************************************************
11155 +* rt_phySetup - reset and setup the PHY associated with
11156 +* the specified MAC unit number.
11158 +* Resets the associated PHY port.
11161 +* TRUE --> associated PHY is alive
11162 +* FALSE --> no LINKs on this ethernet unit
11166 +rt_phySetup(int ethUnit, UINT32 phyBase)
11168 + BOOL linkAlive = FALSE;
11171 + RT_PHYBASE(ethUnit) = phyBase;
11173 + phyAddr = RT_PHYADDR(ethUnit);
11176 + phyRegWrite(phyBase, phyAddr, GEN_ctl, PHY_SW_RST | AUTONEGENA);
11178 + sysMsDelay(1500);
11180 + return linkAlive;
11183 +/******************************************************************************
11185 +* rt_phyIsDuplexFull - Determines whether the phy ports associated with the
11186 +* specified device are FULL or HALF duplex.
11193 +rt_phyIsFullDuplex(int ethUnit)
11199 + phyBase = RT_PHYBASE(ethUnit);
11200 + phyAddr = RT_PHYADDR(ethUnit);
11202 + phyCtl = phyRegRead(phyBase, phyAddr, GEN_ctl);
11204 + if (phyCtl & DUPLEX) {
11211 +/******************************************************************************
11213 +* rt_phyIsSpeed100 - Determines the speed of phy ports associated with the
11214 +* specified device.
11217 +* TRUE --> 100Mbit
11218 +* FALSE --> 10Mbit
11221 +rt_phyIsSpeed100(int phyUnit)
11227 + phyBase = RT_PHYBASE(phyUnit);
11228 + phyAddr = RT_PHYADDR(phyUnit);
11230 + phyLpa = phyRegRead(phyBase, phyAddr, AN_lpa);
11232 + if (phyLpa & (LPA_TXFD | LPA_TX)) {
11239 +/*****************************************************************************
11241 +* rt_phyCheckStatusChange -- checks for significant changes in PHY state.
11243 +* A "significant change" is:
11244 +* dropped link (e.g. ethernet cable unplugged) OR
11245 +* autonegotiation completed + link (e.g. ethernet cable plugged in)
11247 +* On AR5311, there is a 1-to-1 mapping of ethernet units to PHYs.
11248 +* When a PHY is plugged in, phyLinkGained is called.
11249 +* When a PHY is unplugged, phyLinkLost is called.
11252 +rt_phyCheckStatusChange(int ethUnit)
11254 + UINT16 phyHwStatus;
11255 + rtPhyInfo_t *lastStatus = &rtPhyInfo[ethUnit];
11259 + phyBase = RT_PHYBASE(ethUnit);
11260 + phyAddr = RT_PHYADDR(ethUnit);
11262 + phyHwStatus = phyRegRead(phyBase, phyAddr, GEN_sts);
11264 + if (lastStatus->phyAlive) { /* last known status was ALIVE */
11265 + /* See if we've lost link */
11266 + if (!(phyHwStatus & LINK)) {
11267 + RT_PRINT(RT_DEBUG_PHYCHANGE,("\nethmac%d link down\n", ethUnit));
11268 + lastStatus->phyAlive = FALSE;
11269 + phyLinkLost(ethUnit);
11271 + } else { /* last known status was DEAD */
11272 + /* Check for AN complete */
11273 + if ((phyHwStatus & (AUTOCMPLT | LINK)) == (AUTOCMPLT | LINK)) {
11274 + RT_PRINT(RT_DEBUG_PHYCHANGE,("\nethmac%d link up\n", ethUnit));
11275 + lastStatus->phyAlive = TRUE;
11276 + phyLinkGained(ethUnit);
11283 +/* Define the PHY registers of interest for a phyShow command */
11284 +struct rtRegisterTable_s {
11286 + char *regIdString;
11287 +} rtRegisterTable[] =
11289 + {GEN_ctl, "Basic Mode Control (GEN_ctl) "},
11290 + {GEN_sts, "Basic Mode Status (GEN_sts) "},
11291 + {GEN_id_hi, "PHY Identifier 1 (GET_id_hi) "},
11292 + {GEN_id_lo, "PHY Identifier 2 (GET_id_lo) "},
11293 + {AN_adv, "Auto-Neg Advertisement (AN_adv) "},
11294 + {AN_lpa, "Auto-Neg Link Partner Ability "},
11295 + {AN_exp, "Auto-Neg Expansion "},
11298 +int rtNumRegs = sizeof(rtRegisterTable) / sizeof(rtRegisterTable[0]);
11301 + * Dump the state of a PHY.
11304 +rt_phyShow(int phyUnit)
11311 + phyBase = RT_PHYBASE(phyUnit);
11312 + phyAddr = RT_PHYADDR(phyUnit);
11314 + printf("PHY state for ethphy%d\n", phyUnit);
11316 + for (i=0; i<rtNumRegs; i++) {
11318 + value = phyRegRead(phyBase, phyAddr, rtRegisterTable[i].regNum);
11320 + printf("Reg %02d (0x%02x) %s = 0x%08x\n",
11321 + rtRegisterTable[i].regNum, rtRegisterTable[i].regNum,
11322 + rtRegisterTable[i].regIdString, value);
11327 + * Modify the value of a PHY register.
11328 + * This makes it a bit easier to modify PHY values during debug.
11331 +rt_phySet(int phyUnit, UINT32 regnum, UINT32 value)
11336 + phyBase = RT_PHYBASE(phyUnit);
11337 + phyAddr = RT_PHYADDR(phyUnit);
11339 + phyRegWrite(phyBase, phyAddr, regnum, value);
11342 diff -urN linux-mips-orig/drivers/net/ath/rtPhy.h linux-mips-new/drivers/net/ath/rtPhy.h
11343 --- linux-mips-orig/drivers/net/ath/rtPhy.h 1970-01-01 01:00:00.000000000 +0100
11344 +++ linux-mips-new/drivers/net/ath/rtPhy.h 2005-12-31 12:33:57.727530616 +0000
11347 + * This file is subject to the terms and conditions of the GNU General Public
11348 + * License. See the file "COPYING" in the main directory of this archive
11349 + * for more details.
11351 + * Copyright © 2003 Atheros Communications, Inc., All Rights Reserved.
11355 + * rtPhy.h - definitions for the ethernet PHY.
11356 + * This code supports a simple 1-port ethernet phy, Realtek RTL8201BL,
11357 + * and compatible PHYs, such as the Kendin KS8721B.
11358 + * All definitions in this file are operating system independent!
11364 +/* MII Registers */
11366 +#define GEN_ctl 00
11367 +#define GEN_sts 01
11368 +#define GEN_id_hi 02
11369 +#define GEN_id_lo 03
11375 +#define PHY_SW_RST 0x8000
11376 +#define LOOPBACK 0x4000
11377 +#define SPEED 0x2000 /* 100 Mbit/s */
11378 +#define AUTONEGENA 0x1000
11379 +#define DUPLEX 0x0100 /* Duplex mode */
11383 +#define AUTOCMPLT 0x0020 /* Autonegotiation completed */
11384 +#define LINK 0x0004 /* Link status */
11387 +#define RT_PHY_ID1_EXPECTATION 0x22
11390 +#define LPA_TXFD 0x0100 /* Link partner supports 100 TX Full Duplex */
11391 +#define LPA_TX 0x0080 /* Link partner supports 100 TX Half Duplex */
11392 +#define LPA_10FD 0x0040 /* Link partner supports 10 BT Full Duplex */
11393 +#define LPA_10 0x0020 /* Link partner supports 10 BT Half Duplex */
11395 +#endif /* RTPHY_H */
11396 diff -urN linux-mips/include/linux/raid/md_p.h mips-linux-2.4.25/include/linux/raid/md_p.h
11397 --- linux-mips/include/linux/raid/md_p.h 2005-12-24 15:12:07.189098448 +0000
11398 +++ mips-linux-2.4.25/include/linux/raid/md_p.h 2005-12-30 17:28:10.345721232 +0000
11399 @@ -151,10 +151,12 @@
11401 mdp_disk_t disks[MD_SB_DISKS];
11403 +#if MD_SB_RESERVED_WORDS
11407 __u32 reserved[MD_SB_RESERVED_WORDS];
11411 * Active descriptor