1 diff -urN linux.old/arch/mips/ar7/ar7/jump.S linux.dev/arch/mips/ar7/ar7/jump.S
2 --- linux.old/arch/mips/ar7/ar7/jump.S 1970-01-01 01:00:00.000000000 +0100
3 +++ linux.dev/arch/mips/ar7/ar7/jump.S 2005-07-12 02:59:26.167672328 +0200
7 + * Copyright (C) $Date$ $Author$
9 + * This program is free software; you can redistribute it and/or modify
10 + * it under the terms of the GNU General Public License as published by
11 + * the Free Software Foundation; either version 2 of the License, or
12 + * (at your option) any later version.
14 + * This program is distributed in the hope that it will be useful,
15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 + * GNU General Public License for more details.
19 + * You should have received a copy of the GNU General Public License
20 + * along with this program; if not, write to the Free Software
21 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 +#include <linux/config.h>
26 +#include <linux/threads.h>
29 +#include <asm/cacheops.h>
30 +#include <asm/current.h>
31 +#include <asm/offset.h>
32 +#include <asm/processor.h>
33 +#include <asm/regdef.h>
34 +#include <asm/cachectl.h>
35 +#include <asm/mipsregs.h>
36 +#include <asm/stackframe.h>
43 +/* TLB Miss Vector */
53 + /* Unused TLB Miss Vector */
55 +LEAF(jump_tlb_miss_unused)
61 +END(jump_tlb_miss_unused)
63 + /* Cache Error Vector */
65 +LEAF(jump_cache_error)
71 +END(jump_cache_error)
73 + /* General Exception */
75 +LEAF(jump_general_exception)
81 +END(jump_general_exception)
83 + /* Dedicated Interrupt */
85 +LEAF(jump_dedicated_interrupt)
91 +END(jump_dedicated_interrupt)
94 diff -urN linux.old/arch/mips/ar7/ar7/Makefile linux.dev/arch/mips/ar7/ar7/Makefile
95 --- linux.old/arch/mips/ar7/ar7/Makefile 1970-01-01 01:00:00.000000000 +0100
96 +++ linux.dev/arch/mips/ar7/ar7/Makefile 2005-07-12 02:59:26.167672328 +0200
99 +# Copyright (C) $Date$ $Author$
101 +# This program is free software; you can redistribute it and/or modify
102 +# it under the terms of the GNU General Public License as published by
103 +# the Free Software Foundation; either version 2 of the License, or
104 +# (at your option) any later version.
106 +# This program is distributed in the hope that it will be useful,
107 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
108 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
109 +# GNU General Public License for more details.
111 +# You should have received a copy of the GNU General Public License
112 +# along with this program; if not, write to the Free Software
113 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
116 + $(CPP) $(AFLAGS) $< -o $*.s
119 + $(CC) $(AFLAGS) -c $< -o $*.o
121 +EXTRA_CFLAGS := -DLITTLE_ENDIAN -D_LINK_KSEG0_
125 +export-objs := misc.o
126 +obj-y += paging.o jump.o misc.o
128 +include $(TOPDIR)/Rules.make
129 diff -urN linux.old/arch/mips/ar7/ar7/misc.c linux.dev/arch/mips/ar7/ar7/misc.c
130 --- linux.old/arch/mips/ar7/ar7/misc.c 1970-01-01 01:00:00.000000000 +0100
131 +++ linux.dev/arch/mips/ar7/ar7/misc.c 2005-07-12 02:59:26.168672176 +0200
133 +#include <asm/ar7/sangam.h>
134 +#include <asm/ar7/avalanche_misc.h>
135 +#include <linux/module.h>
136 +#include <linux/spinlock.h>
140 +static unsigned int avalanche_vbus_freq;
142 +REMOTE_VLYNQ_DEV_RESET_CTRL_FN p_remote_vlynq_dev_reset_ctrl = NULL;
144 +/*****************************************************************************
145 + * Reset Control Module.
146 + *****************************************************************************/
147 +void avalanche_reset_ctrl(unsigned int module_reset_bit,
148 + AVALANCHE_RESET_CTRL_T reset_ctrl)
150 + volatile unsigned int *reset_reg = (unsigned int*) AVALANCHE_RST_CTRL_PRCR;
152 + if(module_reset_bit >= 32 && module_reset_bit < 64)
155 + if(module_reset_bit >= 64)
157 + if(p_remote_vlynq_dev_reset_ctrl)
158 + return(p_remote_vlynq_dev_reset_ctrl(module_reset_bit - 64, reset_ctrl));
163 + if(reset_ctrl == OUT_OF_RESET)
164 + *reset_reg |= 1 << module_reset_bit;
166 + *reset_reg &= ~(1 << module_reset_bit);
169 +AVALANCHE_RESET_CTRL_T avalanche_get_reset_status(unsigned int module_reset_bit)
171 + volatile unsigned int *reset_reg = (unsigned int*) AVALANCHE_RST_CTRL_PRCR;
173 + return (((*reset_reg) & (1 << module_reset_bit)) ? OUT_OF_RESET : IN_RESET );
176 +void avalanche_sys_reset(AVALANCHE_SYS_RST_MODE_T mode)
178 + volatile unsigned int *sw_reset_reg = (unsigned int*) AVALANCHE_RST_CTRL_SWRCR;
179 + *sw_reset_reg = mode;
182 +#define AVALANCHE_RST_CTRL_RSR_MASK 0x3
184 +AVALANCHE_SYS_RESET_STATUS_T avalanche_get_sys_last_reset_status()
186 + volatile unsigned int *sys_reset_status = (unsigned int*) AVALANCHE_RST_CTRL_RSR;
188 + return ( (AVALANCHE_SYS_RESET_STATUS_T) (*sys_reset_status & AVALANCHE_RST_CTRL_RSR_MASK) );
192 +/*****************************************************************************
193 + * Power Control Module
194 + *****************************************************************************/
195 +#define AVALANCHE_GLOBAL_POWER_DOWN_MASK 0x3FFFFFFF /* bit 31, 30 masked */
196 +#define AVALANCHE_GLOBAL_POWER_DOWN_BIT 30 /* shift to bit 30, 31 */
199 +void avalanche_power_ctrl(unsigned int module_power_bit, AVALANCHE_POWER_CTRL_T power_ctrl)
201 + volatile unsigned int *power_reg = (unsigned int*)AVALANCHE_POWER_CTRL_PDCR;
203 + if (power_ctrl == POWER_CTRL_POWER_DOWN)
204 + /* power down the module */
205 + *power_reg |= (1 << module_power_bit);
207 + /* power on the module */
208 + *power_reg &= (~(1 << module_power_bit));
211 +AVALANCHE_POWER_CTRL_T avalanche_get_power_status(unsigned int module_power_bit)
213 + volatile unsigned int *power_status_reg = (unsigned int*)AVALANCHE_POWER_CTRL_PDCR;
215 + return (((*power_status_reg) & (1 << module_power_bit)) ? POWER_CTRL_POWER_DOWN : POWER_CTRL_POWER_UP);
218 +void avalanche_set_global_power_mode(AVALANCHE_SYS_POWER_MODE_T power_mode)
220 + volatile unsigned int *power_status_reg = (unsigned int*)AVALANCHE_POWER_CTRL_PDCR;
222 + *power_status_reg &= AVALANCHE_GLOBAL_POWER_DOWN_MASK;
223 + *power_status_reg |= ( power_mode << AVALANCHE_GLOBAL_POWER_DOWN_BIT);
226 +AVALANCHE_SYS_POWER_MODE_T avalanche_get_global_power_mode(void)
228 + volatile unsigned int *power_status_reg = (unsigned int*)AVALANCHE_POWER_CTRL_PDCR;
230 + return((AVALANCHE_SYS_POWER_MODE_T) (((*power_status_reg) & (~AVALANCHE_GLOBAL_POWER_DOWN_MASK))
231 + >> AVALANCHE_GLOBAL_POWER_DOWN_BIT));
234 +/*****************************************************************************
236 + *****************************************************************************/
238 +/****************************************************************************
239 + * FUNCTION: avalanche_gpio_init
240 + ***************************************************************************/
241 +void avalanche_gpio_init(void)
243 + spinlock_t closeLock;
244 + unsigned int closeFlag;
245 + volatile unsigned int *reset_reg = (unsigned int*) AVALANCHE_RST_CTRL_PRCR;
246 + spin_lock_irqsave(&closeLock, closeFlag);
247 + *reset_reg |= (1 << AVALANCHE_GPIO_RESET_BIT);
248 + spin_unlock_irqrestore(&closeLock, closeFlag);
251 +/****************************************************************************
252 + * FUNCTION: avalanche_gpio_ctrl
253 + ***************************************************************************/
254 +int avalanche_gpio_ctrl(unsigned int gpio_pin,
255 + AVALANCHE_GPIO_PIN_MODE_T pin_mode,
256 + AVALANCHE_GPIO_PIN_DIRECTION_T pin_direction)
258 + spinlock_t closeLock;
259 + unsigned int closeFlag;
260 + volatile unsigned int *gpio_ctrl = (unsigned int*)AVALANCHE_GPIO_ENBL;
265 + spin_lock_irqsave(&closeLock, closeFlag);
267 + if(pin_mode == GPIO_PIN)
269 + *gpio_ctrl |= (1 << gpio_pin);
271 + gpio_ctrl = (unsigned int*)AVALANCHE_GPIO_DIR;
273 + if(pin_direction == GPIO_INPUT_PIN)
274 + *gpio_ctrl |= (1 << gpio_pin);
276 + *gpio_ctrl &= ~(1 << gpio_pin);
278 + else /* FUNCTIONAL PIN */
280 + *gpio_ctrl &= ~(1 << gpio_pin);
283 + spin_unlock_irqrestore(&closeLock, closeFlag);
288 +/****************************************************************************
289 + * FUNCTION: avalanche_gpio_out
290 + ***************************************************************************/
291 +int avalanche_gpio_out_bit(unsigned int gpio_pin, int value)
293 + spinlock_t closeLock;
294 + unsigned int closeFlag;
295 + volatile unsigned int *gpio_out = (unsigned int*) AVALANCHE_GPIO_DATA_OUT;
300 + spin_lock_irqsave(&closeLock, closeFlag);
302 + *gpio_out |= 1 << gpio_pin;
304 + *gpio_out &= ~(1 << gpio_pin);
305 + spin_unlock_irqrestore(&closeLock, closeFlag);
310 +/****************************************************************************
311 + * FUNCTION: avalanche_gpio_in
312 + ***************************************************************************/
313 +int avalanche_gpio_in_bit(unsigned int gpio_pin)
315 + spinlock_t closeLock;
316 + unsigned int closeFlag;
317 + volatile unsigned int *gpio_in = (unsigned int*) AVALANCHE_GPIO_DATA_IN;
323 + spin_lock_irqsave(&closeLock, closeFlag);
324 + ret_val = ((*gpio_in) & (1 << gpio_pin));
325 + spin_unlock_irqrestore(&closeLock, closeFlag);
330 +/****************************************************************************
331 + * FUNCTION: avalanche_gpio_out_val
332 + ***************************************************************************/
333 +int avalanche_gpio_out_value(unsigned int out_val, unsigned int out_mask,
334 + unsigned int reg_index)
336 + spinlock_t closeLock;
337 + unsigned int closeFlag;
338 + volatile unsigned int *gpio_out = (unsigned int*) AVALANCHE_GPIO_DATA_OUT;
343 + spin_lock_irqsave(&closeLock, closeFlag);
344 + *gpio_out &= ~out_mask;
345 + *gpio_out |= out_val;
346 + spin_unlock_irqrestore(&closeLock, closeFlag);
351 +/****************************************************************************
352 + * FUNCTION: avalanche_gpio_in_value
353 + ***************************************************************************/
354 +int avalanche_gpio_in_value(unsigned int* in_val, unsigned int reg_index)
356 + spinlock_t closeLock;
357 + unsigned int closeFlag;
358 + volatile unsigned int *gpio_in = (unsigned int*) AVALANCHE_GPIO_DATA_IN;
363 + spin_lock_irqsave(&closeLock, closeFlag);
364 + *in_val = *gpio_in;
365 + spin_unlock_irqrestore(&closeLock, closeFlag);
370 +/***********************************************************************
372 + * Wakeup Control Module for TNETV1050 Communication Processor
374 + ***********************************************************************/
376 +#define AVALANCHE_WAKEUP_POLARITY_BIT 16
378 +void avalanche_wakeup_ctrl(AVALANCHE_WAKEUP_INTERRUPT_T wakeup_int,
379 + AVALANCHE_WAKEUP_CTRL_T wakeup_ctrl,
380 + AVALANCHE_WAKEUP_POLARITY_T wakeup_polarity)
382 + volatile unsigned int *wakeup_status_reg = (unsigned int*) AVALANCHE_WAKEUP_CTRL_WKCR;
384 + /* enable/disable */
385 + if (wakeup_ctrl == WAKEUP_ENABLED)
386 + /* enable wakeup */
387 + *wakeup_status_reg |= wakeup_int;
389 + /* disable wakeup */
390 + *wakeup_status_reg &= (~wakeup_int);
393 + if (wakeup_polarity == WAKEUP_ACTIVE_LOW)
394 + *wakeup_status_reg |= (wakeup_int << AVALANCHE_WAKEUP_POLARITY_BIT);
396 + *wakeup_status_reg &= ~(wakeup_int << AVALANCHE_WAKEUP_POLARITY_BIT);
399 +void avalanche_set_vbus_freq(unsigned int new_vbus_freq)
401 + avalanche_vbus_freq = new_vbus_freq;
404 +unsigned int avalanche_get_vbus_freq()
406 + return(avalanche_vbus_freq);
409 +unsigned int avalanche_get_chip_version_info()
411 + return(*(volatile unsigned int*)AVALANCHE_CVR);
414 +SET_MDIX_ON_CHIP_FN_T p_set_mdix_on_chip_fn = NULL;
416 +int avalanche_set_mdix_on_chip(unsigned int base_addr, unsigned int operation)
418 + if(p_set_mdix_on_chip_fn)
419 + return (p_set_mdix_on_chip_fn(base_addr, operation));
424 +unsigned int avalanche_is_mdix_on_chip(void)
426 + return(p_set_mdix_on_chip_fn ? 1:0);
429 +EXPORT_SYMBOL(avalanche_reset_ctrl);
430 +EXPORT_SYMBOL(avalanche_get_reset_status);
431 +EXPORT_SYMBOL(avalanche_sys_reset);
432 +EXPORT_SYMBOL(avalanche_get_sys_last_reset_status);
433 +EXPORT_SYMBOL(avalanche_power_ctrl);
434 +EXPORT_SYMBOL(avalanche_get_power_status);
435 +EXPORT_SYMBOL(avalanche_set_global_power_mode);
436 +EXPORT_SYMBOL(avalanche_get_global_power_mode);
437 +EXPORT_SYMBOL(avalanche_set_mdix_on_chip);
438 +EXPORT_SYMBOL(avalanche_is_mdix_on_chip);
440 +EXPORT_SYMBOL(avalanche_gpio_init);
441 +EXPORT_SYMBOL(avalanche_gpio_ctrl);
442 +EXPORT_SYMBOL(avalanche_gpio_out_bit);
443 +EXPORT_SYMBOL(avalanche_gpio_in_bit);
444 +EXPORT_SYMBOL(avalanche_gpio_out_value);
445 +EXPORT_SYMBOL(avalanche_gpio_in_value);
447 +EXPORT_SYMBOL(avalanche_set_vbus_freq);
448 +EXPORT_SYMBOL(avalanche_get_vbus_freq);
450 +EXPORT_SYMBOL(avalanche_get_chip_version_info);
452 diff -urN linux.old/arch/mips/ar7/ar7/paging.c linux.dev/arch/mips/ar7/ar7/paging.c
453 --- linux.old/arch/mips/ar7/ar7/paging.c 1970-01-01 01:00:00.000000000 +0100
454 +++ linux.dev/arch/mips/ar7/ar7/paging.c 2005-07-12 02:59:26.168672176 +0200
458 + * This file is subject to the terms and conditions of the GNU General Public
459 + * License. See the file "COPYING" in the main directory of this archive
460 + * for more details.
462 + * Copyright (C) 2002 by Jeff Harrell (jharrell@ti.com)
463 + * Copyright (C) 2002 Texas Instruments, Inc.
468 + * This file takes care of the "memory hole" issue that exists with the standard
469 + * linux kernel and the TI Avalanche ASIC. The Avalanche ASIC requires an offset
470 + * of 0x14000000 due to the ASIC's memory map constraints. This file corrects the
471 + * paging tables so that the only reflect valid memory (i.e. > 0x14000000)
475 +#include <linux/config.h>
476 +#include <linux/signal.h>
477 +#include <linux/sched.h>
478 +#include <linux/kernel.h>
479 +#include <linux/errno.h>
480 +#include <linux/string.h>
481 +#include <linux/types.h>
482 +#include <linux/ptrace.h>
483 +#include <linux/mman.h>
484 +#include <linux/mm.h>
485 +#include <linux/swap.h>
486 +#include <linux/smp.h>
487 +#include <linux/init.h>
488 +#ifdef CONFIG_BLK_DEV_INITRD
489 +#include <linux/blk.h>
490 +#endif /* CONFIG_BLK_DEV_INITRD */
491 +#include <linux/highmem.h>
492 +#include <linux/bootmem.h>
494 +#include <asm/processor.h>
495 +#include <asm/system.h>
496 +#include <asm/uaccess.h>
497 +#include <asm/pgtable.h>
498 +#include <asm/pgalloc.h>
499 +#include <asm/mmu_context.h>
501 +#include <asm/tlb.h>
502 +#include <asm/cpu.h>
504 +#define __MEMORY_START CONFIG_AR7_MEMORY
506 +#ifdef CONFIG_DISCONTIGMEM
507 +pg_data_t discontig_page_data[NR_NODES];
508 +bootmem_data_t discontig_node_bdata[NR_NODES];
511 +static unsigned long totalram_pages;
512 +/* static unsigned long totalhigh_pages; */
514 +#define START_PFN (NODE_DATA(0)->bdata->node_boot_start >> PAGE_SHIFT)
515 +#define MAX_LOW_PFN (NODE_DATA(0)->bdata->node_low_pfn)
517 +#define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
518 +#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
519 +#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
521 +unsigned long bootmap_size;
523 +extern char *prom_getenv(char *envname);
526 + * We have upto 8 empty zeroed pages so we can map one of the right colour
527 + * when needed. This is necessary only on R4000 / R4400 SC and MC versions
528 + * where we have to avoid VCED / VECI exceptions for good performance at
529 + * any price. Since page is never written to after the initialization we
530 + * don't have to care about aliases on other CPUs.
533 +static inline unsigned long setup_zero_pages(void)
535 + unsigned long order, size;
537 + if(current_cpu_data.options & MIPS_CPU_VCE)
542 + empty_zero_page = __get_free_pages(GFP_KERNEL, order);
544 + if (!empty_zero_page)
545 + panic("Oh boy, that early out of memory?");
547 + page = virt_to_page(empty_zero_page);
549 + while (page < virt_to_page(empty_zero_page + (PAGE_SIZE << order))) {
550 + set_bit(PG_reserved, &page->flags);
551 + set_page_count(page, 0);
555 + size = PAGE_SIZE << order;
556 + zero_page_mask = (size - 1) & PAGE_MASK;
557 + memset((void *)empty_zero_page, 0, size);
559 + return 1UL << order;
563 + * paging_init() sets up the page tables
565 + * This routines also unmaps the page at virtual kernel address 0, so
566 + * that we can trap those pesky NULL-reference errors in the kernel.
568 +void __init paging_init(void)
570 + unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
571 + unsigned long low, start_pfn;
573 + /* Initialize the entire pgd. */
574 + pgd_init((unsigned long)swapper_pg_dir);
575 + pgd_init((unsigned long)swapper_pg_dir + PAGE_SIZE / 2);
578 + start_pfn = START_PFN;
579 + // max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
582 + /* Avalanche DMA-able memory 0x14000000+memsize */
584 + zones_size[ZONE_DMA] = low - start_pfn;
586 + free_area_init_node(0, NODE_DATA(0), 0, zones_size, __MEMORY_START, 0);
588 +#ifdef CONFIG_DISCONTIGMEM
589 + zones_size[ZONE_DMA] = __MEMORY_SIZE_2ND >> PAGE_SHIFT;
590 + zones_size[ZONE_NORMAL] = 0;
591 + free_area_init_node(1, NODE_DATA(1), 0, zones_size, __MEMORY_START_2ND, 0);
592 +#endif /* CONFIG_DISCONTIGMEM */
596 +extern char _ftext, _etext, _fdata, _edata, _end;
597 +extern char __init_begin, __init_end;
599 +void __init mem_init(void)
601 + int codesize, reservedpages, datasize, initsize;
604 + max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN;
605 + high_memory = (void *)__va(MAX_LOW_PFN * PAGE_SIZE);
607 + /* free up the memory associated with Adam2 -
608 + * that is the, after the first page that is
609 + * reserved all the way up to the start of the kernel
611 + free_bootmem_node(NODE_DATA(0), (__MEMORY_START+PAGE_SIZE),
612 + (__pa(&_ftext))-(__MEMORY_START+PAGE_SIZE) );
614 + /* this will put all low memory onto the freelists */
615 + totalram_pages += free_all_bootmem_node(NODE_DATA(0));
617 + /* Setup zeroed pages */
618 + totalram_pages -= setup_zero_pages();
621 +#ifdef CONFIG_DISCONTIGMEM
622 + totalram_pages += free_all_bootmem_node(NODE_DATA(1));
625 + for (tmp = 0; tmp < num_physpages; tmp++)
627 + * Only count reserved RAM pages
629 + if (PageReserved(mem_map+tmp))
632 + codesize = (unsigned long) &_etext - (unsigned long) &_ftext;
633 + datasize = (unsigned long) &_edata - (unsigned long) &_fdata;
634 + initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
636 + printk("Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk data, %dk init)\n",
637 + (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
638 + max_mapnr << (PAGE_SHIFT-10),
640 + reservedpages << (PAGE_SHIFT-10),
646 +/* fixes paging routines for avalanche (utilized in /arch/mips/kernel/setup.c) */
648 +void avalanche_bootmem_init(void)
650 + unsigned long start_pfn, max_pfn;
651 + unsigned long max_low_pfn;
652 + unsigned int memsize,memory_end,memory_start;
655 + memsize_str = prom_getenv("memsize");
656 + if (!memsize_str) {
657 + memsize = 0x02000000;
659 + memsize = simple_strtol(memsize_str, NULL, 0);
663 + memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START;
664 + memory_end = memory_start + memsize;
667 + * Find the highest memory page fram number we have available
670 + max_pfn = PFN_DOWN(__pa(memory_end));
673 + * Determine the low and high memory ranges
676 + max_low_pfn = max_pfn;
679 + * Partially used pages are not usable - thus we are
680 + * rounding upwards:
683 + start_pfn = PFN_UP(__pa(&_end));
686 + * Find a proper area for the bootmem bitmap. After this
687 + * bootstrap step all allocations (until the page allocator is
688 + * intact) must be done via bootmem_alloc().
691 + bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
692 + __MEMORY_START>>PAGE_SHIFT, max_low_pfn);
696 + * Register fully available low RAM pages with the bootmem allocator.
700 + unsigned long curr_pfn, last_pfn, pages;
703 + * We are rounding up the start address of usable memory:
705 + curr_pfn = PFN_UP(__MEMORY_START);
708 + * ... and at the end of the usable range downwards:
710 + last_pfn = PFN_DOWN(__pa(memory_end));
712 + if (last_pfn > max_low_pfn)
713 + last_pfn = max_low_pfn;
715 + pages = last_pfn - curr_pfn;
718 + free_bootmem_node(NODE_DATA(0), PFN_PHYS(curr_pfn),
723 + * Reserve the kernel text and
724 + * Reserve the bootmem bitmap. We do this in two steps (first step
725 + * was init_bootmem()), because this catches the (definitely buggy)
726 + * case of us accidentally initializing the bootmem allocator with
727 + * an invalid RAM area.
729 + reserve_bootmem_node(NODE_DATA(0), __MEMORY_START+PAGE_SIZE,
730 + (PFN_PHYS(start_pfn)+bootmap_size+PAGE_SIZE-1)-__MEMORY_START);
733 + * reserve physical page 0 - it's a special BIOS page on many boxes,
734 + * enabling clean reboots, SMP operation, laptop functions.
736 + reserve_bootmem_node(NODE_DATA(0), __MEMORY_START, PAGE_SIZE);
739 +extern char __init_begin, __init_end;
741 +void free_initmem(void)
743 + unsigned long addr;
744 + // prom_free_prom_memory ();
746 + addr = (unsigned long) &__init_begin;
747 + while (addr < (unsigned long) &__init_end) {
748 + ClearPageReserved(virt_to_page(addr));
749 + set_page_count(virt_to_page(addr), 1);
754 + printk("Freeing unused kernel memory: %dk freed\n",
755 + (&__init_end - &__init_begin) >> 10);
758 +void si_meminfo(struct sysinfo *val)
760 + val->totalram = totalram_pages;
761 + val->sharedram = 0;
762 + val->freeram = nr_free_pages();
763 + val->bufferram = atomic_read(&buffermem_pages);
764 + val->totalhigh = 0;
765 + val->freehigh = nr_free_highpages();
766 + val->mem_unit = PAGE_SIZE;
770 diff -urN linux.old/arch/mips/ar7/cmdline.c linux.dev/arch/mips/ar7/cmdline.c
771 --- linux.old/arch/mips/ar7/cmdline.c 1970-01-01 01:00:00.000000000 +0100
772 +++ linux.dev/arch/mips/ar7/cmdline.c 2005-07-12 02:59:26.169672024 +0200
775 + * Carsten Langgaard, carstenl@mips.com
776 + * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
778 + * This program is free software; you can distribute it and/or modify it
779 + * under the terms of the GNU General Public License (Version 2) as
780 + * published by the Free Software Foundation.
782 + * This program is distributed in the hope it will be useful, but WITHOUT
783 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
784 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
785 + * for more details.
787 + * You should have received a copy of the GNU General Public License along
788 + * with this program; if not, write to the Free Software Foundation, Inc.,
789 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
791 + * Kernel command line creation using the prom monitor (YAMON) argc/argv.
793 +#include <linux/init.h>
794 +#include <linux/string.h>
796 +#include <asm/bootinfo.h>
798 +extern int prom_argc;
799 +extern int *_prom_argv;
802 + * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer.
803 + * This macro take care of sign extension.
805 +#define prom_argv(index) ((char *)(((int *)(int)_prom_argv)[(index)]))
807 +char arcs_cmdline[CL_SIZE];
809 +char * __init prom_getcmdline(void)
811 + return &(arcs_cmdline[0]);
815 +void __init prom_init_cmdline(void)
820 + actr = 1; /* Always ignore argv[0] */
822 + cp = &(arcs_cmdline[0]);
823 +#ifdef CONFIG_CMDLINE_BOOL
824 + strcpy(cp, CONFIG_CMDLINE);
825 + cp += strlen(CONFIG_CMDLINE);
828 + while(actr < prom_argc) {
829 + strcpy(cp, prom_argv(actr));
830 + cp += strlen(prom_argv(actr));
834 + if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
838 diff -urN linux.old/arch/mips/ar7/init.c linux.dev/arch/mips/ar7/init.c
839 --- linux.old/arch/mips/ar7/init.c 1970-01-01 01:00:00.000000000 +0100
840 +++ linux.dev/arch/mips/ar7/init.c 2005-07-12 02:59:26.169672024 +0200
843 + * Carsten Langgaard, carstenl@mips.com
844 + * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
846 + * This program is free software; you can distribute it and/or modify it
847 + * under the terms of the GNU General Public License (Version 2) as
848 + * published by the Free Software Foundation.
850 + * This program is distributed in the hope it will be useful, but WITHOUT
851 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
852 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
853 + * for more details.
855 + * You should have received a copy of the GNU General Public License along
856 + * with this program; if not, write to the Free Software Foundation, Inc.,
857 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
859 + * PROM library initialisation code.
861 +#include <linux/config.h>
862 +#include <linux/init.h>
863 +#include <linux/string.h>
864 +#include <linux/kernel.h>
865 +#include <linux/module.h>
868 +#include <asm/mips-boards/prom.h>
869 +#include <asm/mips-boards/generic.h>
871 +/* Environment variable */
878 +int *_prom_argv, *_prom_envp;
880 +/* max # of Adam2 environment variables */
881 +#define MAX_ENV_ENTRY 80
883 +static t_env_var local_envp[MAX_ENV_ENTRY];
886 +char *prom_getenv(char *envname)
889 + * Return a pointer to the given environment variable.
890 + * In 64-bit mode: we're using 64-bit pointers, but all pointers
891 + * in the PROM structures are only 32-bit, so we need some
892 + * workarounds, if we are running in 64-bit mode.
895 + t_env_var *env = (t_env_var *) local_envp;
897 + i = strlen(envname);
898 + while (env->name) {
899 + if(strncmp(envname, env->name, i) == 0) {
908 +static inline unsigned char str2hexnum(unsigned char c)
910 + if (c >= '0' && c <= '9')
912 + if (c >= 'a' && c <= 'f')
913 + return c - 'a' + 10;
914 + return 0; /* foo */
917 +static inline void str2eaddr(unsigned char *ea, unsigned char *str)
921 + for (i = 0; i < 6; i++) {
924 + if((*str == '.') || (*str == ':'))
926 + num = str2hexnum(*str++) << 4;
927 + num |= (str2hexnum(*str++));
932 +int get_ethernet_addr(char *ethernet_addr)
936 + ethaddr_str = prom_getenv("ethaddr");
937 + if (!ethaddr_str) {
938 + printk("ethaddr not set in boot prom\n");
941 + str2eaddr(ethernet_addr, ethaddr_str);
943 + if (init_debug > 1) {
945 + printk("get_ethernet_addr: ");
946 + for (i=0; i<5; i++)
947 + printk("%02x:", (unsigned char)*(ethernet_addr+i));
948 + printk("%02x\n", *(ethernet_addr+i));
954 +int __init prom_init(int argc, char **argv, char **envp)
957 + t_env_var *env = (t_env_var *) envp;
960 + _prom_argv = (int *)argv;
961 + _prom_envp = (int *)envp;
963 + /* Copy what we need locally so we are not dependent on
964 + * bootloader RAM. In Adam2, the environment parameters
965 + * are in flash but the table that references them is in
968 + for(i=0; i < MAX_ENV_ENTRY; i++, env++) {
970 + local_envp[i].name = env->name;
971 + local_envp[i].val = env->val;
973 + local_envp[i].name = NULL;
974 + local_envp[i].val = NULL;
978 + set_io_port_base(0);
980 + prom_printf("\nLINUX started...\n");
981 + prom_init_cmdline();
986 diff -urN linux.old/arch/mips/ar7/irq.c linux.dev/arch/mips/ar7/irq.c
987 --- linux.old/arch/mips/ar7/irq.c 1970-01-01 01:00:00.000000000 +0100
988 +++ linux.dev/arch/mips/ar7/irq.c 2005-07-12 02:59:26.190668832 +0200
991 + * Nitin Dhingra, iamnd@ti.com
992 + * Copyright (C) 2002 Texas Instruments, Inc. All rights reserved.
994 + * ########################################################################
996 + * This program is free software; you can distribute it and/or modify it
997 + * under the terms of the GNU General Public License (Version 2) as
998 + * published by the Free Software Foundation.
1000 + * This program is distributed in the hope it will be useful, but WITHOUT
1001 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1002 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1003 + * for more details.
1005 + * You should have received a copy of the GNU General Public License along
1006 + * with this program; if not, write to the Free Software Foundation, Inc.,
1007 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
1009 + * ########################################################################
1011 + * Routines for generic manipulation of the interrupts found on the Texas
1012 + * Instruments avalanche board
1016 +#include <linux/config.h>
1017 +#include <linux/init.h>
1018 +#include <linux/sched.h>
1019 +#include <linux/slab.h>
1020 +#include <linux/interrupt.h>
1021 +#include <linux/kernel_stat.h>
1022 +#include <linux/proc_fs.h>
1023 +#include <asm/irq.h>
1024 +#include <asm/mips-boards/prom.h>
1025 +#include <asm/ar7/ar7.h>
1026 +#include <asm/ar7/avalanche_intc.h>
1027 +#include <asm/gdb-stub.h>
1030 +#define shutdown_avalanche_irq disable_avalanche_irq
1031 +#define mask_and_ack_avalanche_irq disable_avalanche_irq
1033 +static unsigned int startup_avalanche_irq(unsigned int irq);
1034 +static void end_avalanche_irq(unsigned int irq);
1035 +void enable_avalanche_irq(unsigned int irq_nr);
1036 +void disable_avalanche_irq(unsigned int irq_nr);
1038 +static struct hw_interrupt_type avalanche_irq_type = {
1040 + startup_avalanche_irq,
1041 + shutdown_avalanche_irq,
1042 + enable_avalanche_irq,
1043 + disable_avalanche_irq,
1044 + mask_and_ack_avalanche_irq,
1045 + end_avalanche_irq,
1049 +irq_desc_t irq_desc_ti[AVALANCHE_INT_END+1] __cacheline_aligned =
1050 +{ [0 ... AVALANCHE_INT_END] = { 0, &avalanche_irq_type, NULL, 0, SPIN_LOCK_UNLOCKED}};
1053 +unsigned long spurious_count = 0;
1055 +struct avalanche_ictrl_regs *avalanche_hw0_icregs; /* Interrupt control regs (primary) */
1056 +struct avalanche_exctrl_regs *avalanche_hw0_ecregs; /* Exception control regs (secondary) */
1057 +struct avalanche_ipace_regs *avalanche_hw0_ipaceregs;
1058 +struct avalanche_channel_int_number *avalanche_hw0_chregs; /* Channel control registers */
1060 +extern asmlinkage void mipsIRQ(void);
1064 + * The avalanche/MIPS interrupt line numbers are used to represent the
1065 + * interrupts within the irqaction arrays. The index notation is
1068 + * 0-7 MIPS CPU Exceptions (HW/SW)
1069 + * 8-47 Primary Interrupts (Avalanche)
1070 + * 48-79 Secondary Interrupts (Avalanche)
1075 +static struct irqaction *hw0_irq_action_primary[AVINTNUM(AVALANCHE_INT_END_PRIMARY)] =
1077 + NULL, NULL, NULL, NULL,
1078 + NULL, NULL, NULL, NULL,
1079 + NULL, NULL, NULL, NULL,
1080 + NULL, NULL, NULL, NULL,
1081 + NULL, NULL, NULL, NULL,
1082 + NULL, NULL, NULL, NULL,
1083 + NULL, NULL, NULL, NULL,
1084 + NULL, NULL, NULL, NULL,
1085 + NULL, NULL, NULL, NULL,
1086 + NULL, NULL, NULL, NULL
1089 +static struct irqaction *hw0_irq_action_secondary[AVINTNUM(AVALANCHE_INT_END_SECONDARY)] =
1091 + NULL, NULL, NULL, NULL,
1092 + NULL, NULL, NULL, NULL,
1093 + NULL, NULL, NULL, NULL,
1094 + NULL, NULL, NULL, NULL,
1095 + NULL, NULL, NULL, NULL,
1096 + NULL, NULL, NULL, NULL,
1097 + NULL, NULL, NULL, NULL,
1098 + NULL, NULL, NULL, NULL
1102 + This remaps interrupts to exist on other channels than the default
1103 + channels. essentially we can use the line # as the index for this
1108 +static unsigned long line_to_channel[AVINTNUM(AVALANCHE_INT_END_PRIMARY)];
1109 +unsigned long uni_secondary_interrupt = 0;
1111 +static struct irqaction r4ktimer_action = {
1112 + NULL, 0, 0, "R4000 timer/counter", NULL, NULL,
1115 +static struct irqaction *irq_action[8] = {
1116 + NULL, /* SW int 0 */
1117 + NULL, /* SW int 1 */
1118 + NULL, /* HW int 0 */
1121 + NULL, /* HW int 3 */
1122 + NULL, /* HW int 4 */
1123 + &r4ktimer_action /* HW int 5 */
1126 +static void end_avalanche_irq(unsigned int irq)
1128 + if (!(irq_desc_ti[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
1129 + enable_avalanche_irq(irq);
1132 +void disable_avalanche_irq(unsigned int irq_nr)
1134 + unsigned long flags;
1135 + unsigned long chan_nr=0;
1136 + unsigned long int_bit=0;
1138 + if(irq_nr >= AVALANCHE_INT_END)
1140 + printk("whee, invalid irq_nr %d\n", irq_nr);
1141 + panic("IRQ, you lose...");
1144 + save_and_cli(flags);
1147 + if(irq_nr < MIPS_EXCEPTION_OFFSET)
1149 + /* disable mips exception */
1151 + int_bit = read_c0_status() & ~(1 << (8+irq_nr));
1152 + change_c0_status(ST0_IM,int_bit);
1153 + restore_flags(flags);
1157 + /* irq_nr represents the line number for the interrupt. We must
1158 + * disable the channel number associated with that line number.
1161 + if(irq_nr > AVALANCHE_INT_END_PRIMARY_REG2)
1162 + chan_nr = AVINTNUM(irq_nr); /*CHECK THIS ALSO*/
1164 + chan_nr = line_to_channel[AVINTNUM(irq_nr)];/* WE NEED A LINE TO CHANNEL MAPPING FUNCTION HERE*/
1166 + /* disable the interrupt channel bit */
1168 + /* primary interrupt #'s 0-31 */
1170 + if(chan_nr <= AVINTNUM(AVALANCHE_INT_END_PRIMARY_REG1))
1171 + avalanche_hw0_icregs->intecr1 = (1 << chan_nr);
1173 + /* primary interrupt #'s 32-39 */
1175 + else if ((chan_nr <= AVINTNUM(AVALANCHE_INT_END_PRIMARY_REG2)) &&
1176 + (chan_nr > AVINTNUM(AVALANCHE_INT_END_PRIMARY_REG1)))
1177 + avalanche_hw0_icregs->intecr2 = (1 << (chan_nr - AVINTNUM(AVALANCHE_INT_END_SECONDARY)));
1179 + else /* secondary interrupt #'s 0-31 */
1180 + avalanche_hw0_ecregs->exiecr = (1 << (chan_nr - AVINTNUM(AVALANCHE_INT_END_PRIMARY)));
1182 + restore_flags(flags);
1185 +void enable_avalanche_irq(unsigned int irq_nr)
1187 + unsigned long flags;
1188 + unsigned long chan_nr=0;
1189 + unsigned long int_bit=0;
1191 + if(irq_nr > AVALANCHE_INT_END) {
1192 + printk("whee, invalid irq_nr %d\n", irq_nr);
1193 + panic("IRQ, you lose...");
1196 + save_and_cli(flags);
1199 + if(irq_nr < MIPS_EXCEPTION_OFFSET)
1201 + /* Enable MIPS exceptions */
1202 + int_bit = read_c0_status();
1203 + change_c0_status(ST0_IM,int_bit | (1<<(8+irq_nr)));
1204 + restore_flags(flags);
1208 + /* irq_nr represents the line number for the interrupt. We must
1209 + * disable the channel number associated with that line number.
1212 + if(irq_nr > AVALANCHE_INT_END_PRIMARY_REG2)
1213 + chan_nr = AVINTNUM(irq_nr);
1215 + chan_nr = line_to_channel[AVINTNUM(irq_nr)];
1217 + /* enable the interrupt channel bit */
1219 + /* primary interrupt #'s 0-31 */
1220 + if(chan_nr <= AVINTNUM(AVALANCHE_INT_END_PRIMARY_REG1))
1221 + avalanche_hw0_icregs->intesr1 = (1 << chan_nr);
1223 + /* primary interrupt #'s 32 throuth 39 */
1224 + else if ((chan_nr <= AVINTNUM(AVALANCHE_INT_END_PRIMARY_REG2)) &&
1225 + (chan_nr > AVINTNUM(AVALANCHE_INT_END_PRIMARY_REG1)))
1226 + avalanche_hw0_icregs->intesr2 = (1 << (chan_nr - AVINTNUM(AVALANCHE_INT_END_SECONDARY)));
1228 + else /* secondary interrupt #'s 0-31 */
1229 + avalanche_hw0_ecregs->exiesr = (1 << (chan_nr - AVINTNUM(AVALANCHE_INT_END_PRIMARY)));
1231 + restore_flags(flags);
1234 +static unsigned int startup_avalanche_irq(unsigned int irq)
1236 + enable_avalanche_irq(irq);
1237 + return 0; /* never anything pending */
1241 +int get_irq_list(char *buf)
1245 + struct irqaction *action;
1247 + for (i = 0; i < MIPS_EXCEPTION_OFFSET; i++, num++)
1249 + action = irq_action[i];
1252 + len += sprintf(buf+len, "%2d: %8d %c %s",
1253 + num, kstat.irqs[0][num],
1254 + (action->flags & SA_INTERRUPT) ? '+' : ' ',
1256 + for (action=action->next; action; action = action->next) {
1257 + len += sprintf(buf+len, ",%s %s",
1258 + (action->flags & SA_INTERRUPT) ? " +" : "",
1261 + len += sprintf(buf+len, " [MIPS interrupt]\n");
1265 + for (i = 0; i < AVINTNUM(AVALANCHE_INT_END); i++,num++)
1267 + if(i < AVINTNUM(AVALANCHE_INT_END_PRIMARY))
1268 + action = hw0_irq_action_primary[i];
1270 + action = hw0_irq_action_secondary[i-AVINTNUM(AVALANCHE_INT_END_PRIMARY)];
1273 + len += sprintf(buf+len, "%2d: %8d %c %s",
1274 + num, kstat.irqs[0][ LNXINTNUM(i) ],
1275 + (action->flags & SA_INTERRUPT) ? '+' : ' ',
1278 + for (action=action->next; action; action = action->next)
1280 + len += sprintf(buf+len, ",%s %s",
1281 + (action->flags & SA_INTERRUPT) ? " +" : "",
1285 + if(i < AVINTNUM(AVALANCHE_INT_END_PRIMARY))
1286 + len += sprintf(buf+len, " [hw0 (Avalanche Primary)]\n");
1288 + len += sprintf(buf+len, " [hw0 (Avalanche Secondary)]\n");
1295 +int request_irq(unsigned int irq,
1296 + void (*handler)(int, void *, struct pt_regs *),
1297 + unsigned long irqflags,
1298 + const char * devname,
1301 + struct irqaction *action;
1303 + if (irq > AVALANCHE_INT_END)
1308 + action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
1312 + action->handler = handler;
1313 + action->flags = irqflags;
1315 + action->name = devname;
1316 + irq_desc_ti[irq].action = action;
1317 + action->dev_id = dev_id;
1321 + if(irq < MIPS_EXCEPTION_OFFSET)
1323 + irq_action[irq] = action;
1324 + enable_avalanche_irq(irq);
1328 + if(irq < AVALANCHE_INT_END_PRIMARY)
1329 + hw0_irq_action_primary[line_to_channel[AVINTNUM(irq)]] = action;
1331 + hw0_irq_action_secondary[irq - AVALANCHE_INT_END_PRIMARY] = action;
1333 + enable_avalanche_irq(irq);
1338 +void free_irq(unsigned int irq, void *dev_id)
1340 + struct irqaction *action;
1342 + if (irq > AVALANCHE_INT_END) {
1343 + printk("Trying to free IRQ%d\n",irq);
1347 + if(irq < MIPS_EXCEPTION_OFFSET)
1349 + action = irq_action[irq];
1350 + irq_action[irq] = NULL;
1351 + irq_desc_ti[irq].action = NULL;
1352 + disable_avalanche_irq(irq);
1357 + if(irq < AVALANCHE_INT_END_PRIMARY) {
1358 + action = hw0_irq_action_primary[line_to_channel[AVINTNUM(irq)]];
1359 + hw0_irq_action_primary[line_to_channel[AVINTNUM(irq)]] = NULL;
1360 + irq_desc_ti[irq].action = NULL;
1363 + action = hw0_irq_action_secondary[irq - AVALANCHE_INT_END_PRIMARY];
1364 + hw0_irq_action_secondary[irq - AVALANCHE_INT_END_PRIMARY] = NULL;
1365 + irq_desc_ti[irq].action = NULL;
1368 + disable_avalanche_irq(irq);
1373 +extern void breakpoint(void);
1374 +extern int remote_debug;
1377 +//void init_IRQ(void) __init;
1378 +void __init init_IRQ(void)
1382 + avalanche_hw0_icregs = (struct avalanche_ictrl_regs *)AVALANCHE_ICTRL_REGS_BASE;
1383 + avalanche_hw0_ecregs = (struct avalanche_exctrl_regs *)AVALANCHE_ECTRL_REGS_BASE;
1384 + avalanche_hw0_ipaceregs = (struct avalanche_ipace_regs *)AVALANCHE_IPACE_REGS_BASE;
1385 + avalanche_hw0_chregs = (struct avalanche_channel_int_number *)AVALANCHE_CHCTRL_REGS_BASE;
1387 + /* Disable interrupts and clear pending
1390 + avalanche_hw0_icregs->intecr1 = 0xffffffff; /* disable interrupts 0:31 */
1391 + avalanche_hw0_icregs->intcr1 = 0xffffffff; /* clear interrupts 0:31 */
1392 + avalanche_hw0_icregs->intecr2 = 0xff; /* disable interrupts 32:39 */
1393 + avalanche_hw0_icregs->intcr2 = 0xff; /* clear interrupts 32:39 */
1394 + avalanche_hw0_ecregs->exiecr = 0xffffffff; /* disable secondary interrupts 0:31 */
1395 + avalanche_hw0_ecregs->excr = 0xffffffff; /* clear secondary interrupts 0:31 */
1398 + /* Channel to line mapping, Line to Channel mapping */
1400 + for(i = 0; i < 40; i++)
1401 + avalanche_int_set(i,i);
1403 + /* Now safe to set the exception vector. */
1404 + set_except_vector(0, mipsIRQ);
1406 + /* Setup the IRQ description array. These will be mapped
1407 + * as flat interrupts numbers. The mapping is as follows
1409 + * 0-7 MIPS CPU Exceptions (HW/SW)
1410 + * 8-46 Primary Interrupts (Avalanche)
1411 + * 47-78 Secondary Interrupts (Avalanche)
1414 + for (i = 0; i <= AVALANCHE_INT_END; i++)
1416 + irq_desc_ti[i].status = IRQ_DISABLED;
1417 + irq_desc_ti[i].action = 0;
1418 + irq_desc_ti[i].depth = 1;
1419 + irq_desc_ti[i].handler = &avalanche_irq_type;
1425 + set_debug_traps();
1432 +void avalanche_hw0_irqdispatch(struct pt_regs *regs)
1434 + struct irqaction *action;
1435 + int irq, cpu = smp_processor_id();
1436 + unsigned long int_line_number,status;
1437 + int i,secondary = 0;
1440 + int_line_number = ((avalanche_hw0_icregs->pintir >> 16) & 0x3F);
1441 + chan_nr = ((avalanche_hw0_icregs->pintir) & 0x3F);
1446 + if( chan_nr != uni_secondary_interrupt)
1447 + avalanche_hw0_icregs->intcr1 = (1<<chan_nr);
1451 + if((chan_nr < 40) && (chan_nr > 31))
1453 + avalanche_hw0_icregs->intcr2 = (1<<(chan_nr-AVINTNUM(AVALANCHE_INT_END_SECONDARY)));
1457 + /* If the Priority Interrupt Index Register returns 40 then no
1458 + * interrupts are pending
1464 + if(chan_nr == uni_secondary_interrupt)
1466 + status = avalanche_hw0_ecregs->exsr;
1467 + for(i=0; i < AVINTNUM(AVALANCHE_INT_END_SECONDARY); i++)
1469 + if (status & 1<<i)
1471 + /* clear secondary interrupt */
1472 + avalanche_hw0_ecregs->excr = 1 << i;
1479 + /* clear the universal secondary interrupt */
1480 + avalanche_hw0_icregs->intcr1 = 1 << uni_secondary_interrupt;
1486 + /* Suraj Add code to clear secondary interrupt */
1489 + action = hw0_irq_action_secondary[irq];
1491 + action = hw0_irq_action_primary[irq];
1493 + /* if action == NULL, then we don't have a handler for the irq */
1495 + if ( action == NULL ) {
1496 + printk("No handler for hw0 irq: %i\n", irq);
1500 + irq_enter(cpu,irq);
1503 + kstat.irqs[0][(irq + AVINTNUM(AVALANCHE_INT_END_PRIMARY)) + 8]++;
1504 + action->handler((irq + AVALANCHE_INT_END_PRIMARY), action->dev_id, regs);
1508 + kstat.irqs[0][irq + 8]++;
1509 + action->handler(LNXINTNUM(irq), action->dev_id, regs);
1512 + irq_exit(cpu,irq);
1514 + if(softirq_pending(cpu))
1520 +void avalanche_int_set(int channel, int line)
1525 + avalanche_hw0_chregs->cintnr0 = line;
1528 + avalanche_hw0_chregs->cintnr1 = line;
1531 + avalanche_hw0_chregs->cintnr2 = line;
1534 + avalanche_hw0_chregs->cintnr3 = line;
1537 + avalanche_hw0_chregs->cintnr4 = line;
1540 + avalanche_hw0_chregs->cintnr5 = line;
1543 + avalanche_hw0_chregs->cintnr6 = line;
1546 + avalanche_hw0_chregs->cintnr7 = line;
1549 + avalanche_hw0_chregs->cintnr8 = line;
1552 + avalanche_hw0_chregs->cintnr9 = line;
1555 + avalanche_hw0_chregs->cintnr10 = line;
1558 + avalanche_hw0_chregs->cintnr11 = line;
1561 + avalanche_hw0_chregs->cintnr12 = line;
1564 + avalanche_hw0_chregs->cintnr13 = line;
1567 + avalanche_hw0_chregs->cintnr14 = line;
1570 + avalanche_hw0_chregs->cintnr15 = line;
1573 + avalanche_hw0_chregs->cintnr16 = line;
1576 + avalanche_hw0_chregs->cintnr17 = line;
1579 + avalanche_hw0_chregs->cintnr18 = line;
1582 + avalanche_hw0_chregs->cintnr19 = line;
1585 + avalanche_hw0_chregs->cintnr20 = line;
1588 + avalanche_hw0_chregs->cintnr21 = line;
1591 + avalanche_hw0_chregs->cintnr22 = line;
1594 + avalanche_hw0_chregs->cintnr23 = line;
1597 + avalanche_hw0_chregs->cintnr24 = line;
1600 + avalanche_hw0_chregs->cintnr25 = line;
1603 + avalanche_hw0_chregs->cintnr26 = line;
1606 + avalanche_hw0_chregs->cintnr27 = line;
1609 + avalanche_hw0_chregs->cintnr28 = line;
1612 + avalanche_hw0_chregs->cintnr29 = line;
1615 + avalanche_hw0_chregs->cintnr30 = line;
1618 + avalanche_hw0_chregs->cintnr31 = line;
1621 + avalanche_hw0_chregs->cintnr32 = line;
1624 + avalanche_hw0_chregs->cintnr33 = line;
1627 + avalanche_hw0_chregs->cintnr34 = line;
1630 + avalanche_hw0_chregs->cintnr35 = line;
1633 + avalanche_hw0_chregs->cintnr36 = line;
1636 + avalanche_hw0_chregs->cintnr37 = line;
1639 + avalanche_hw0_chregs->cintnr38 = line;
1642 + avalanche_hw0_chregs->cintnr39 = line;
1645 + printk("Error: Unknown Avalanche interrupt channel\n");
1648 + line_to_channel[line] = channel; /* Suraj check */
1650 + if (channel == UNIFIED_SECONDARY_INTERRUPT)
1651 + uni_secondary_interrupt = line;
1656 +#define AVALANCHE_MAX_PACING_BLK 3
1657 +#define AVALANCHE_PACING_LOW_VAL 2
1658 +#define AVALANCHE_PACING_HIGH_VAL 63
1660 +int avalanche_request_pacing(int irq_nr, unsigned int blk_num,
1661 + unsigned int pace_value)
1663 + unsigned int blk_offset;
1664 + unsigned long flags;
1666 + if(irq_nr < MIPS_EXCEPTION_OFFSET &&
1667 + irq_nr >= AVALANCHE_INT_END_PRIMARY)
1670 + if(blk_num > AVALANCHE_MAX_PACING_BLK)
1673 + if(pace_value > AVALANCHE_PACING_HIGH_VAL &&
1674 + pace_value < AVALANCHE_PACING_LOW_VAL)
1677 + blk_offset = blk_num*8;
1679 + save_and_cli(flags);
1681 + /* disable the interrupt pacing, if enabled previously */
1682 + avalanche_hw0_ipaceregs->ipacemax &= ~(0xff << blk_offset);
1684 + /* clear the pacing map */
1685 + avalanche_hw0_ipaceregs->ipacemap &= ~(0xff << blk_offset);
1687 + /* setup the new values */
1688 + avalanche_hw0_ipaceregs->ipacemap |= ((AVINTNUM(irq_nr)) << blk_offset);
1689 + avalanche_hw0_ipaceregs->ipacemax |= ((0x80 | pace_value) << blk_offset);
1691 + restore_flags(flags);
1695 diff -urN linux.old/arch/mips/ar7/Makefile linux.dev/arch/mips/ar7/Makefile
1696 --- linux.old/arch/mips/ar7/Makefile 1970-01-01 01:00:00.000000000 +0100
1697 +++ linux.dev/arch/mips/ar7/Makefile 2005-07-12 02:59:43.730002448 +0200
1700 + $(CPP) $(AFLAGS) $< -o $*.s
1703 + $(CC) $(AFLAGS) -c $< -o $*.o
1705 +EXTRA_CFLAGS := -I$(TOPDIR)/include/asm/ar7 -DLITTLE_ENDIAN -D_LINK_KSEG0_
1708 +obj-y := tnetd73xx_misc.o
1709 +obj-y += setup.o irq.o mipsIRQ.o reset.o init.o memory.o printf.o cmdline.o time.o
1711 +include $(TOPDIR)/Rules.make
1712 diff -urN linux.old/arch/mips/ar7/memory.c linux.dev/arch/mips/ar7/memory.c
1713 --- linux.old/arch/mips/ar7/memory.c 1970-01-01 01:00:00.000000000 +0100
1714 +++ linux.dev/arch/mips/ar7/memory.c 2005-07-12 02:59:26.190668832 +0200
1717 + * Carsten Langgaard, carstenl@mips.com
1718 + * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
1720 + * ########################################################################
1722 + * This program is free software; you can distribute it and/or modify it
1723 + * under the terms of the GNU General Public License (Version 2) as
1724 + * published by the Free Software Foundation.
1726 + * This program is distributed in the hope it will be useful, but WITHOUT
1727 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1728 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1729 + * for more details.
1731 + * You should have received a copy of the GNU General Public License along
1732 + * with this program; if not, write to the Free Software Foundation, Inc.,
1733 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
1735 + * ########################################################################
1737 + * PROM library functions for acquiring/using memory descriptors given to
1738 + * us from the YAMON.
1741 +#include <linux/config.h>
1742 +#include <linux/init.h>
1743 +#include <linux/mm.h>
1744 +#include <linux/bootmem.h>
1746 +#include <asm/bootinfo.h>
1747 +#include <asm/page.h>
1748 +#include <asm/mips-boards/prom.h>
1749 +#include <asm/ar7/ar7.h>
1751 +enum yamon_memtypes {
1756 +struct prom_pmemblock mdesc[PROM_MAX_PMEMBLOCKS];
1758 +/* References to section boundaries */
1761 +#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
1764 +struct prom_pmemblock * __init prom_getmdesc(void)
1766 + char *memsize_str;
1767 + unsigned int memsize;
1769 + memsize_str = prom_getenv("memsize");
1770 + if (!memsize_str) {
1771 + memsize = 0x02000000;
1773 + memsize = simple_strtol(memsize_str, NULL, 0);
1776 + memset(mdesc, 0, sizeof(mdesc));
1778 + mdesc[0].type = yamon_dontuse;
1779 + mdesc[0].base = 0x00000000;
1780 + mdesc[0].size = CONFIG_AR7_MEMORY;
1782 + mdesc[1].type = yamon_prom;
1783 + mdesc[1].base = CONFIG_AR7_MEMORY;
1784 + mdesc[1].size = 0x00020000;
1786 + mdesc[2].type = yamon_free;
1787 + mdesc[2].base = CONFIG_AR7_MEMORY + 0x00020000;
1788 + mdesc[2].size = (memsize + CONFIG_AR7_MEMORY) - mdesc[2].base;
1793 +static int __init prom_memtype_classify (unsigned int type)
1797 + return BOOT_MEM_RAM;
1799 + return BOOT_MEM_ROM_DATA;
1801 + return BOOT_MEM_RESERVED;
1805 +void __init prom_meminit(void)
1807 + struct prom_pmemblock *p;
1809 + p = prom_getmdesc();
1813 + unsigned long base, size;
1815 + type = prom_memtype_classify (p->type);
1819 + add_memory_region(base, size, type);
1824 +void __init prom_free_prom_memory (void)
1827 + unsigned long freed = 0;
1828 + unsigned long addr;
1830 + for (i = 0; i < boot_mem_map.nr_map; i++) {
1831 + if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA)
1834 + addr = boot_mem_map.map[i].addr;
1835 + while (addr < boot_mem_map.map[i].addr
1836 + + boot_mem_map.map[i].size) {
1837 + ClearPageReserved(virt_to_page(__va(addr)));
1838 + set_page_count(virt_to_page(__va(addr)), 1);
1839 + free_page((unsigned long)__va(addr));
1840 + addr += PAGE_SIZE;
1841 + freed += PAGE_SIZE;
1844 + printk("Freeing prom memory: %ldkb freed\n", freed >> 10);
1846 diff -urN linux.old/arch/mips/ar7/mipsIRQ.S linux.dev/arch/mips/ar7/mipsIRQ.S
1847 --- linux.old/arch/mips/ar7/mipsIRQ.S 1970-01-01 01:00:00.000000000 +0100
1848 +++ linux.dev/arch/mips/ar7/mipsIRQ.S 2005-07-12 02:59:26.191668680 +0200
1851 + * Carsten Langgaard, carstenl@mips.com
1852 + * Copyright (C) 1999, 2000 MIPS Technologies, Inc. All rights reserved.
1854 + * ########################################################################
1856 + * This program is free software; you can distribute it and/or modify it
1857 + * under the terms of the GNU General Public License (Version 2) as
1858 + * published by the Free Software Foundation.
1860 + * This program is distributed in the hope it will be useful, but WITHOUT
1861 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1862 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1863 + * for more details.
1865 + * You should have received a copy of the GNU General Public License along
1866 + * with this program; if not, write to the Free Software Foundation, Inc.,
1867 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
1869 + * ########################################################################
1871 + * Interrupt exception dispatch code.
1874 +#include <linux/config.h>
1876 +#include <asm/asm.h>
1877 +#include <asm/mipsregs.h>
1878 +#include <asm/regdef.h>
1879 +#include <asm/stackframe.h>
1881 +/* A lot of complication here is taken away because:
1883 + * 1) We handle one interrupt and return, sitting in a loop and moving across
1884 + * all the pending IRQ bits in the cause register is _NOT_ the answer, the
1885 + * common case is one pending IRQ so optimize in that direction.
1887 + * 2) We need not check against bits in the status register IRQ mask, that
1888 + * would make this routine slow as hell.
1890 + * 3) Linux only thinks in terms of all IRQs on or all IRQs off, nothing in
1891 + * between like BSD spl() brain-damage.
1893 + * Furthermore, the IRQs on the MIPS board look basically (barring software
1894 + * IRQs which we don't use at all and all external interrupt sources are
1895 + * combined together on hardware interrupt 0 (MIPS IRQ 2)) like:
1899 + * 0 Software (ignored)
1900 + * 1 Software (ignored)
1901 + * 2 Combined hardware interrupt (hw0)
1902 + * 3 Hardware (ignored)
1903 + * 4 Hardware (ignored)
1904 + * 5 Hardware (ignored)
1905 + * 6 Hardware (ignored)
1906 + * 7 R4k timer (what we use)
1908 + * Note: On the SEAD board thing are a little bit different.
1909 + * Here IRQ 2 (hw0) is wired to the UART0 and IRQ 3 (hw1) is wired
1912 + * We handle the IRQ according to _our_ priority which is:
1914 + * Highest ---- R4k Timer
1915 + * Lowest ---- Combined hardware interrupt
1917 + * then we just return, if multiple IRQs are pending then we will just take
1918 + * another exception, big deal.
1925 +NESTED(mipsIRQ, PT_SIZE, sp)
1930 + mfc0 s0, CP0_CAUSE # get irq bits
1932 + /* First we check for r4k counter/timer IRQ. */
1933 + andi a0, s0, CAUSEF_IP7
1935 + andi a0, s0, CAUSEF_IP2 # delay slot, check hw0 interrupt
1937 + /* Wheee, a timer interrupt. */
1939 + jal ar7_timer_interrupt
1946 + beq a0, zero, 1f # delay slot, check hw3 interrupt
1949 + /* Wheee, combined hardware level zero interrupt. */
1950 + jal avalanche_hw0_irqdispatch
1951 + move a0, sp # delay slot
1958 + * Here by mistake? This is possible, what can happen is that by the
1959 + * time we take the exception the IRQ pin goes low, so just leave if
1960 + * this is the case.
1963 + PRINT("Got interrupt: c0_cause = %08x\n")
1965 + PRINT("c0_epc = %08x\n")
1970 diff -urN linux.old/arch/mips/ar7/printf.c linux.dev/arch/mips/ar7/printf.c
1971 --- linux.old/arch/mips/ar7/printf.c 1970-01-01 01:00:00.000000000 +0100
1972 +++ linux.dev/arch/mips/ar7/printf.c 2005-07-12 02:59:26.191668680 +0200
1975 + * Carsten Langgaard, carstenl@mips.com
1976 + * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
1978 + * This program is free software; you can distribute it and/or modify it
1979 + * under the terms of the GNU General Public License (Version 2) as
1980 + * published by the Free Software Foundation.
1982 + * This program is distributed in the hope it will be useful, but WITHOUT
1983 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1984 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1985 + * for more details.
1987 + * You should have received a copy of the GNU General Public License along
1988 + * with this program; if not, write to the Free Software Foundation, Inc.,
1989 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
1991 + * Putting things on the screen/serial line using Adam2 facilities.
1994 +#include <linux/config.h>
1995 +#include <linux/init.h>
1996 +#include <linux/kernel.h>
1997 +#include <linux/serial_reg.h>
1998 +#include <linux/spinlock.h>
1999 +#include <asm/io.h>
2000 +#include <asm/serial.h>
2001 +#include <asm/addrspace.h>
2002 +#include <asm/ar7/ar7.h>
2004 +#define AVALANCHE_YAMON_FUNCTION_BASE (KSEG1ADDR(0x10000500))
2005 +#define AVALANCHE_YAMON_PROM_PRINT_COUNT_ADDR (AVALANCHE_YAMON_FUNCTION_BASE + 0x4) /* print_count function */
2007 +static char ppbuf[1024];
2009 +void (*prom_print_str)(unsigned int out, char *s, int len);
2011 +void prom_printf(char *fmt, ...) __init;
2012 +void prom_printf(char *fmt, ...)
2016 + prom_print_str = (void *)*(unsigned int *)AVALANCHE_YAMON_PROM_PRINT_COUNT_ADDR;
2018 + va_start(args, fmt);
2019 + vsprintf(ppbuf, fmt, args);
2020 + len = strlen(ppbuf);
2022 + prom_print_str(1, ppbuf, len);
2028 diff -urN linux.old/arch/mips/ar7/reset.c linux.dev/arch/mips/ar7/reset.c
2029 --- linux.old/arch/mips/ar7/reset.c 1970-01-01 01:00:00.000000000 +0100
2030 +++ linux.dev/arch/mips/ar7/reset.c 2005-07-12 02:59:26.191668680 +0200
2033 + * Carsten Langgaard, carstenl@mips.com
2034 + * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
2036 + * ########################################################################
2038 + * This program is free software; you can distribute it and/or modify it
2039 + * under the terms of the GNU General Public License (Version 2) as
2040 + * published by the Free Software Foundation.
2042 + * This program is distributed in the hope it will be useful, but WITHOUT
2043 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2044 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2045 + * for more details.
2047 + * You should have received a copy of the GNU General Public License along
2048 + * with this program; if not, write to the Free Software Foundation, Inc.,
2049 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
2051 + * ########################################################################
2053 + * Reset the MIPS boards.
2056 +#include <linux/config.h>
2058 +#include <asm/reboot.h>
2059 +#include <asm/mips-boards/generic.h>
2061 +static void ar7_machine_restart(char *command);
2062 +static void ar7_machine_halt(void);
2063 +static void ar7_machine_power_off(void);
2065 +static void ar7_machine_restart(char *command)
2070 +static void ar7_machine_halt(void)
2075 +static void ar7_machine_power_off(void)
2080 +void ar7_reboot_setup(void)
2082 + _machine_restart = ar7_machine_restart;
2083 + _machine_halt = ar7_machine_halt;
2084 + _machine_power_off = ar7_machine_power_off;
2086 diff -urN linux.old/arch/mips/ar7/setup.c linux.dev/arch/mips/ar7/setup.c
2087 --- linux.old/arch/mips/ar7/setup.c 1970-01-01 01:00:00.000000000 +0100
2088 +++ linux.dev/arch/mips/ar7/setup.c 2005-07-12 02:59:26.191668680 +0200
2091 + * Carsten Langgaard, carstenl@mips.com
2092 + * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
2094 + * This program is free software; you can distribute it and/or modify it
2095 + * under the terms of the GNU General Public License (Version 2) as
2096 + * published by the Free Software Foundation.
2098 + * This program is distributed in the hope it will be useful, but WITHOUT
2099 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2100 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2101 + * for more details.
2103 + * You should have received a copy of the GNU General Public License along
2104 + * with this program; if not, write to the Free Software Foundation, Inc.,
2105 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
2107 +#include <linux/config.h>
2108 +#include <linux/init.h>
2109 +#include <linux/sched.h>
2110 +#include <linux/mc146818rtc.h>
2111 +#include <linux/ioport.h>
2113 +#include <asm/cpu.h>
2114 +#include <asm/bootinfo.h>
2115 +#include <asm/irq.h>
2116 +#include <asm/mips-boards/generic.h>
2117 +#include <asm/mips-boards/prom.h>
2119 +#include <asm/dma.h>
2120 +#include <asm/time.h>
2121 +#include <asm/traps.h>
2124 +extern void rs_kgdb_hook(int);
2125 +int remote_debug = 0;
2128 +extern struct rtc_ops no_rtc_ops;
2130 +extern void ar7_reboot_setup(void);
2132 +extern void ar7_time_init(void);
2133 +extern void ar7_timer_setup(struct irqaction *irq);
2135 +const char *get_system_type(void)
2137 + return "Texas Instruments AR7";
2140 +void __init ar7_setup(void)
2143 + int rs_putDebugChar(char);
2144 + char rs_getDebugChar(void);
2145 + extern int (*generic_putDebugChar)(char);
2146 + extern char (*generic_getDebugChar)(void);
2149 +#ifdef CONFIG_SERIAL_CONSOLE
2150 + argptr = prom_getcmdline();
2151 + if ((argptr = strstr(argptr, "console=")) == NULL) {
2156 + s = prom_getenv("modetty0");
2157 + strcpy(console, "38400");
2160 + while (s[i] >= '0' && s[i] <= '9')
2164 + strncpy(console, s, i);
2169 + argptr = prom_getcmdline();
2170 + strcat(argptr, " console=ttyS0,");
2171 + strcat(argptr, console);
2176 + argptr = prom_getcmdline();
2177 + if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
2179 + argptr += strlen("kgdb=ttyS");
2180 + if (*argptr != '0' && *argptr != '1')
2181 + printk("KGDB: Uknown serial line /dev/ttyS%c, "
2182 + "falling back to /dev/ttyS1\n", *argptr);
2183 + line = *argptr == '0' ? 0 : 1;
2184 + printk("KGDB: Using serial line /dev/ttyS%d for session\n",
2187 + rs_kgdb_hook(line);
2188 + generic_putDebugChar = rs_putDebugChar;
2189 + generic_getDebugChar = rs_getDebugChar;
2191 + prom_printf("KGDB: Using serial line /dev/ttyS%d for session, "
2192 + "please connect your debugger\n", line ? 1 : 0);
2195 + /* Breakpoints are in init_IRQ() */
2199 + argptr = prom_getcmdline();
2200 + if ((argptr = strstr(argptr, "nofpu")) != NULL)
2201 + cpu_data[0].options &= ~MIPS_CPU_FPU;
2203 + rtc_ops = &no_rtc_ops;
2205 + ar7_reboot_setup();
2207 + board_time_init = ar7_time_init;
2208 + board_timer_setup = ar7_timer_setup;
2210 diff -urN linux.old/arch/mips/ar7/time.c linux.dev/arch/mips/ar7/time.c
2211 --- linux.old/arch/mips/ar7/time.c 1970-01-01 01:00:00.000000000 +0100
2212 +++ linux.dev/arch/mips/ar7/time.c 2005-07-12 02:59:26.192668528 +0200
2215 + * Carsten Langgaard, carstenl@mips.com
2216 + * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
2218 + * ########################################################################
2220 + * This program is free software; you can distribute it and/or modify it
2221 + * under the terms of the GNU General Public License (Version 2) as
2222 + * published by the Free Software Foundation.
2224 + * This program is distributed in the hope it will be useful, but WITHOUT
2225 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2226 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2227 + * for more details.
2229 + * You should have received a copy of the GNU General Public License along
2230 + * with this program; if not, write to the Free Software Foundation, Inc.,
2231 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
2233 + * ########################################################################
2235 + * Setting up the clock on the MIPS boards.
2239 +#include <linux/types.h>
2240 +#include <linux/config.h>
2241 +#include <linux/init.h>
2242 +#include <linux/kernel_stat.h>
2243 +#include <linux/sched.h>
2244 +#include <linux/spinlock.h>
2246 +#include <asm/mipsregs.h>
2247 +#include <asm/ptrace.h>
2248 +#include <asm/hardirq.h>
2249 +#include <asm/div64.h>
2251 +#include <linux/interrupt.h>
2252 +#include <linux/mc146818rtc.h>
2253 +#include <linux/timex.h>
2255 +#include <asm/mips-boards/generic.h>
2256 +#include <asm/mips-boards/prom.h>
2257 +#include <asm/ar7/ar7.h>
2259 +extern asmlinkage void mipsIRQ(void);
2261 +static unsigned long r4k_offset; /* Amount to increment compare reg each time */
2262 +static unsigned long r4k_cur; /* What counter should be at next timer irq */
2264 +#define MIPS_CPU_TIMER_IRQ 7
2265 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
2267 +static inline void ack_r4ktimer(unsigned long newval)
2269 + write_c0_compare(newval);
2272 +void ar7_timer_interrupt(struct pt_regs *regs)
2274 + int cpu = smp_processor_id();
2276 + irq_enter(cpu, MIPS_CPU_TIMER_IRQ);
2278 + if (r4k_offset == 0)
2282 + kstat.irqs[cpu][MIPS_CPU_TIMER_IRQ]++;
2284 + r4k_cur += r4k_offset;
2285 + ack_r4ktimer(r4k_cur);
2287 + } while (((unsigned long)read_c0_count()
2288 + - r4k_cur) < 0x7fffffff);
2290 + irq_exit(cpu, MIPS_CPU_TIMER_IRQ);
2292 + if (softirq_pending(cpu))
2302 + * Figure out the r4k offset, the amount to increment the compare
2303 + * register for each time tick.
2305 +static unsigned long __init cal_r4koff(void)
2307 + return ((CONFIG_AR7_CPU_FREQUENCY*500000)/HZ);
2310 +void __init ar7_time_init(void)
2312 + unsigned long flags;
2313 + unsigned int est_freq;
2315 + set_except_vector(0, mipsIRQ);
2316 + write_c0_count(0);
2318 + printk("calculating r4koff... ");
2319 + r4k_offset = cal_r4koff();
2320 + printk("%08lx(%d)\n", r4k_offset, (int) r4k_offset);
2322 + est_freq = 2*r4k_offset*HZ;
2323 + est_freq += 5000; /* round */
2324 + est_freq -= est_freq%10000;
2325 + printk("CPU frequency %d.%02d MHz\n", est_freq/1000000,
2326 + (est_freq%1000000)*100/1000000);
2329 +void __init ar7_timer_setup(struct irqaction *irq)
2331 + /* we are using the cpu counter for timer interrupts */
2332 + irq->handler = no_action; /* we use our own handler */
2333 + setup_irq(MIPS_CPU_TIMER_IRQ, irq);
2335 + r4k_cur = (read_c0_count() + r4k_offset);
2336 + write_c0_compare(r4k_cur);
2337 + set_c0_status(ALLINTS);
2339 diff -urN linux.old/arch/mips/ar7/tnetd73xx_misc.c linux.dev/arch/mips/ar7/tnetd73xx_misc.c
2340 --- linux.old/arch/mips/ar7/tnetd73xx_misc.c 1970-01-01 01:00:00.000000000 +0100
2341 +++ linux.dev/arch/mips/ar7/tnetd73xx_misc.c 2005-07-12 02:59:43.731002296 +0200
2343 +/******************************************************************************
2344 + * FILE PURPOSE: TNETD73xx Misc modules API Source
2345 + ******************************************************************************
2346 + * FILE NAME: tnetd73xx_misc.c
2348 + * DESCRIPTION: Clock Control, Reset Control, Power Management, GPIO
2349 + * FSER Modules API
2350 + * As per TNETD73xx specifications
2352 + * REVISION HISTORY:
2353 + * 27 Nov 02 - Sharath Kumar PSP TII
2354 + * 14 Feb 03 - Anant Gole PSP TII
2356 + * (C) Copyright 2002, Texas Instruments, Inc
2357 + *******************************************************************************/
2359 +#define LITTLE_ENDIAN
2360 +#define _LINK_KSEG0_
2362 +#include <linux/types.h>
2363 +#include <asm/ar7/tnetd73xx.h>
2364 +#include <asm/ar7/tnetd73xx_misc.h>
2366 +/* TNETD73XX Revision */
2367 +u32 tnetd73xx_get_revision(void)
2369 + /* Read Chip revision register - This register is from GPIO module */
2370 + return ( (u32) REG32_DATA(TNETD73XX_CVR));
2373 +/*****************************************************************************
2374 + * Reset Control Module
2375 + *****************************************************************************/
2378 +void tnetd73xx_reset_ctrl(TNETD73XX_RESET_MODULE_T reset_module, TNETD73XX_RESET_CTRL_T reset_ctrl)
2382 + /* read current reset register */
2383 + REG32_READ(TNETD73XX_RST_CTRL_PRCR, reset_status);
2385 + if (reset_ctrl == OUT_OF_RESET)
2387 + /* bring module out of reset */
2388 + reset_status |= (1 << reset_module);
2392 + /* put module in reset */
2393 + reset_status &= (~(1 << reset_module));
2396 + /* write to the reset register */
2397 + REG32_WRITE(TNETD73XX_RST_CTRL_PRCR, reset_status);
2401 +TNETD73XX_RESET_CTRL_T tnetd73xx_get_reset_status (TNETD73XX_RESET_MODULE_T reset_module)
2405 + REG32_READ(TNETD73XX_RST_CTRL_PRCR, reset_status);
2406 + return ( (reset_status & (1 << reset_module)) ? OUT_OF_RESET : IN_RESET );
2409 +void tnetd73xx_sys_reset(TNETD73XX_SYS_RST_MODE_T mode)
2411 + REG32_WRITE(TNETD73XX_RST_CTRL_SWRCR, mode);
2414 +#define TNETD73XX_RST_CTRL_RSR_MASK 0x3
2416 +TNETD73XX_SYS_RESET_STATUS_T tnetd73xx_get_sys_last_reset_status()
2418 + u32 sys_reset_status;
2420 + REG32_READ(TNETD73XX_RST_CTRL_RSR, sys_reset_status);
2422 + return ( (TNETD73XX_SYS_RESET_STATUS_T) (sys_reset_status & TNETD73XX_RST_CTRL_RSR_MASK) );
2426 +/*****************************************************************************
2427 + * Power Control Module
2428 + *****************************************************************************/
2429 +#define TNETD73XX_GLOBAL_POWER_DOWN_MASK 0x3FFFFFFF /* bit 31, 30 masked */
2430 +#define TNETD73XX_GLOBAL_POWER_DOWN_BIT 30 /* shift to bit 30, 31 */
2433 +void tnetd73xx_power_ctrl(TNETD73XX_POWER_MODULE_T power_module, TNETD73XX_POWER_CTRL_T power_ctrl)
2437 + /* read current power down control register */
2438 + REG32_READ(TNETD73XX_POWER_CTRL_PDCR, power_status);
2440 + if (power_ctrl == POWER_CTRL_POWER_DOWN)
2442 + /* power down the module */
2443 + power_status |= (1 << power_module);
2447 + /* power on the module */
2448 + power_status &= (~(1 << power_module));
2451 + /* write to the reset register */
2452 + REG32_WRITE(TNETD73XX_POWER_CTRL_PDCR, power_status);
2455 +TNETD73XX_POWER_CTRL_T tnetd73xx_get_pwr_status(TNETD73XX_POWER_MODULE_T power_module)
2459 + /* read current power down control register */
2460 + REG32_READ(TNETD73XX_POWER_CTRL_PDCR, power_status);
2462 + return ( (power_status & (1 << power_module)) ? POWER_CTRL_POWER_DOWN : POWER_CTRL_POWER_UP );
2465 +void tnetd73xx_set_global_pwr_mode(TNETD73XX_SYS_POWER_MODE_T power_mode)
2469 + /* read current power down control register */
2470 + REG32_READ(TNETD73XX_POWER_CTRL_PDCR, power_status);
2472 + power_status &= TNETD73XX_GLOBAL_POWER_DOWN_MASK;
2473 + power_status |= ( power_mode << TNETD73XX_GLOBAL_POWER_DOWN_BIT);
2475 + /* write to power down control register */
2476 + REG32_WRITE(TNETD73XX_POWER_CTRL_PDCR, power_status);
2479 +TNETD73XX_SYS_POWER_MODE_T tnetd73xx_get_global_pwr_mode()
2483 + /* read current power down control register */
2484 + REG32_READ(TNETD73XX_POWER_CTRL_PDCR, power_status);
2486 + power_status &= (~TNETD73XX_GLOBAL_POWER_DOWN_MASK);
2487 + power_status = ( power_status >> TNETD73XX_GLOBAL_POWER_DOWN_BIT);
2489 + return ( (TNETD73XX_SYS_POWER_MODE_T) power_status );
2493 +/*****************************************************************************
2495 + *****************************************************************************/
2497 +#define TNETD73XX_WAKEUP_POLARITY_BIT 16
2499 +void tnetd73xx_wakeup_ctrl(TNETD73XX_WAKEUP_INTERRUPT_T wakeup_int,
2500 + TNETD73XX_WAKEUP_CTRL_T wakeup_ctrl,
2501 + TNETD73XX_WAKEUP_POLARITY_T wakeup_polarity)
2503 + u32 wakeup_status;
2505 + /* read the wakeup control register */
2506 + REG32_READ(TNETD73XX_POWER_CTRL_WKCR, wakeup_status);
2508 + /* enable/disable */
2509 + if (wakeup_ctrl == WAKEUP_ENABLED)
2511 + /* enable wakeup */
2512 + wakeup_status |= wakeup_int;
2516 + /* disable wakeup */
2517 + wakeup_status &= (~wakeup_int);
2520 + /* set polarity */
2521 + if (wakeup_polarity == WAKEUP_ACTIVE_LOW)
2523 + wakeup_status |= (wakeup_int << TNETD73XX_WAKEUP_POLARITY_BIT);
2527 + wakeup_status &= ~(wakeup_int << TNETD73XX_WAKEUP_POLARITY_BIT);
2530 + /* write the wakeup control register */
2531 + REG32_WRITE(TNETD73XX_POWER_CTRL_WKCR, wakeup_status);
2535 +/*****************************************************************************
2537 + *****************************************************************************/
2539 +void tnetd73xx_fser_ctrl(TNETD73XX_FSER_MODE_T fser_mode)
2541 + REG32_WRITE(TNETD73XX_FSER_BASE, fser_mode);
2544 +/*****************************************************************************
2546 + *****************************************************************************/
2548 +#define MIN(x,y) ( ((x) < (y)) ? (x) : (y) )
2549 +#define MAX(x,y) ( ((x) > (y)) ? (x) : (y) )
2550 +#define ABS(x) ( ((signed)(x) > 0) ? (x) : (-(x)) )
2551 +#define CEIL(x,y) ( ((x) + (y) / 2) / (y) )
2553 +#define CLKC_CLKCR(x) (TNETD73XX_CLOCK_CTRL_BASE + 0x20 + (0x20 * (x)))
2554 +#define CLKC_CLKPLLCR(x) (TNETD73XX_CLOCK_CTRL_BASE + 0x30 + (0x20 * (x)))
2556 +#define CLKC_PRE_DIVIDER 0x0000001F
2557 +#define CLKC_POST_DIVIDER 0x001F0000
2559 +#define CLKC_PLL_STATUS 0x1
2560 +#define CLKC_PLL_FACTOR 0x0000F000
2562 +#define BOOTCR_PLL_BYPASS (1 << 5)
2563 +#define BOOTCR_MIPS_ASYNC_MODE (1 << 25)
2565 +#define MIPS_PLL_SELECT 0x00030000
2566 +#define SYSTEM_PLL_SELECT 0x0000C000
2567 +#define USB_PLL_SELECT 0x000C0000
2568 +#define ADSLSS_PLL_SELECT 0x00C00000
2570 +#define MIPS_AFECLKI_SELECT 0x00000000
2571 +#define MIPS_REFCLKI_SELECT 0x00010000
2572 +#define MIPS_XTAL3IN_SELECT 0x00020000
2574 +#define SYSTEM_AFECLKI_SELECT 0x00000000
2575 +#define SYSTEM_REFCLKI_SELECT 0x00004000
2576 +#define SYSTEM_XTAL3IN_SELECT 0x00008000
2577 +#define SYSTEM_MIPSPLL_SELECT 0x0000C000
2579 +#define USB_SYSPLL_SELECT 0x00000000
2580 +#define USB_REFCLKI_SELECT 0x00040000
2581 +#define USB_XTAL3IN_SELECT 0x00080000
2582 +#define USB_MIPSPLL_SELECT 0x000C0000
2584 +#define ADSLSS_AFECLKI_SELECT 0x00000000
2585 +#define ADSLSS_REFCLKI_SELECT 0x00400000
2586 +#define ADSLSS_XTAL3IN_SELECT 0x00800000
2587 +#define ADSLSS_MIPSPLL_SELECT 0x00C00000
2589 +#define SYS_MAX CLK_MHZ(150)
2590 +#define SYS_MIN CLK_MHZ(1)
2592 +#define MIPS_SYNC_MAX SYS_MAX
2593 +#define MIPS_ASYNC_MAX CLK_MHZ(160)
2594 +#define MIPS_MIN CLK_MHZ(1)
2596 +#define USB_MAX CLK_MHZ(100)
2597 +#define USB_MIN CLK_MHZ(1)
2599 +#define ADSL_MAX CLK_MHZ(180)
2600 +#define ADSL_MIN CLK_MHZ(1)
2602 +#define PLL_MUL_MAXFACTOR 15
2603 +#define MAX_DIV_VALUE 32
2604 +#define MIN_DIV_VALUE 1
2606 +#define MIN_PLL_INP_FREQ CLK_MHZ(8)
2607 +#define MAX_PLL_INP_FREQ CLK_MHZ(100)
2609 +#define DIVIDER_LOCK_TIME 10100
2610 +#define PLL_LOCK_TIME 10100 * 75
2614 + /****************************************************************************
2615 + * DATA PURPOSE: PRIVATE Variables
2616 + **************************************************************************/
2617 + static u32 *clk_src[4];
2618 + static u32 mips_pll_out;
2619 + static u32 sys_pll_out;
2620 + static u32 afeclk_inp;
2621 + static u32 refclk_inp;
2622 + static u32 xtal_inp;
2623 + static u32 present_min;
2624 + static u32 present_max;
2626 + /* Forward References */
2627 + static u32 find_gcd(u32 min, u32 max);
2628 + static u32 compute_prediv( u32 divider, u32 min, u32 max);
2629 + static void get_val(u32 base_freq, u32 output_freq,u32 *multiplier, u32 *divider);
2630 + static u32 get_base_frequency(TNETD73XX_CLKC_ID_T clk_id);
2631 + static void find_approx(u32 *,u32 *,u32);
2633 + /****************************************************************************
2634 + * FUNCTION: tnetd73xx_clkc_init
2635 + ****************************************************************************
2636 + * Description: The routine initializes the internal variables depending on
2637 + * on the sources selected for different clocks.
2638 + ***************************************************************************/
2639 +void tnetd73xx_clkc_init(u32 afeclk, u32 refclk, u32 xtal3in)
2644 + afeclk_inp = afeclk;
2645 + refclk_inp = refclk;
2646 + xtal_inp = xtal3in;
2648 + choice = REG32_DATA(TNETD73XX_DCL_BOOTCR) & MIPS_PLL_SELECT;
2651 + case MIPS_AFECLKI_SELECT:
2652 + clk_src[CLKC_MIPS] = &afeclk_inp;
2655 + case MIPS_REFCLKI_SELECT:
2656 + clk_src[CLKC_MIPS] = &refclk_inp;
2659 + case MIPS_XTAL3IN_SELECT:
2660 + clk_src[CLKC_MIPS] = &xtal_inp;
2664 + clk_src[CLKC_MIPS] = 0;
2668 + choice = REG32_DATA(TNETD73XX_DCL_BOOTCR) & SYSTEM_PLL_SELECT;
2671 + case SYSTEM_AFECLKI_SELECT:
2672 + clk_src[CLKC_SYS] = &afeclk_inp;
2675 + case SYSTEM_REFCLKI_SELECT:
2676 + clk_src[CLKC_SYS] = &refclk_inp;
2679 + case SYSTEM_XTAL3IN_SELECT:
2680 + clk_src[CLKC_SYS] = &xtal_inp;
2683 + case SYSTEM_MIPSPLL_SELECT:
2684 + clk_src[CLKC_SYS] = &mips_pll_out;
2688 + clk_src[CLKC_SYS] = 0;
2693 + choice = REG32_DATA(TNETD73XX_DCL_BOOTCR) & ADSLSS_PLL_SELECT;
2696 + case ADSLSS_AFECLKI_SELECT:
2697 + clk_src[CLKC_ADSLSS] = &afeclk_inp;
2700 + case ADSLSS_REFCLKI_SELECT:
2701 + clk_src[CLKC_ADSLSS] = &refclk_inp;
2704 + case ADSLSS_XTAL3IN_SELECT:
2705 + clk_src[CLKC_ADSLSS] = &xtal_inp;
2708 + case ADSLSS_MIPSPLL_SELECT:
2709 + clk_src[CLKC_ADSLSS] = &mips_pll_out;
2713 + clk_src[CLKC_ADSLSS] = 0;
2718 + choice = REG32_DATA(TNETD73XX_DCL_BOOTCR) & USB_PLL_SELECT;
2721 + case USB_SYSPLL_SELECT:
2722 + clk_src[CLKC_USB] = &sys_pll_out ;
2725 + case USB_REFCLKI_SELECT:
2726 + clk_src[CLKC_USB] = &refclk_inp;
2729 + case USB_XTAL3IN_SELECT:
2730 + clk_src[CLKC_USB] = &xtal_inp;
2733 + case USB_MIPSPLL_SELECT:
2734 + clk_src[CLKC_USB] = &mips_pll_out;
2738 + clk_src[CLKC_USB] = 0;
2745 +/****************************************************************************
2746 + * FUNCTION: tnetd73xx_clkc_set_freq
2747 + ****************************************************************************
2748 + * Description: The above routine is called to set the output_frequency of the
2749 + * selected clock(using clk_id) to the required value given
2750 + * by the variable output_freq.
2751 + ***************************************************************************/
2752 +TNETD73XX_ERR tnetd73xx_clkc_set_freq
2754 + TNETD73XX_CLKC_ID_T clk_id,
2767 + /* check if PLLs are bypassed*/
2768 + if(REG32_DATA(TNETD73XX_DCL_BOOTCR) & BOOTCR_PLL_BYPASS)
2770 + return TNETD73XX_ERR_ERROR;
2773 + /*check if the requested output_frequency is in valid range*/
2777 + if( output_freq < SYS_MIN || output_freq > SYS_MAX)
2779 + return TNETD73XX_ERR_ERROR;
2781 + present_min = SYS_MIN;
2782 + present_max = SYS_MAX;
2786 + if((output_freq < MIPS_MIN) ||
2787 + (output_freq > ((REG32_DATA(TNETD73XX_DCL_BOOTCR) & BOOTCR_MIPS_ASYNC_MODE) ? MIPS_ASYNC_MAX: MIPS_SYNC_MAX)))
2789 + return TNETD73XX_ERR_ERROR;
2791 + present_min = MIPS_MIN;
2792 + present_max = (REG32_DATA(TNETD73XX_DCL_BOOTCR) & BOOTCR_MIPS_ASYNC_MODE) ? MIPS_ASYNC_MAX: MIPS_SYNC_MAX;
2796 + if( output_freq < USB_MIN || output_freq > USB_MAX)
2798 + return TNETD73XX_ERR_ERROR;
2800 + present_min = USB_MIN;
2801 + present_max = USB_MAX;
2805 + if( output_freq < ADSL_MIN || output_freq > ADSL_MAX)
2807 + return TNETD73XX_ERR_ERROR;
2809 + present_min = ADSL_MIN;
2810 + present_max = ADSL_MAX;
2815 + base_freq = get_base_frequency(clk_id);
2818 + /* check for minimum base frequency value */
2819 + if( base_freq < MIN_PLL_INP_FREQ)
2821 + return TNETD73XX_ERR_ERROR;
2824 + get_val(output_freq, base_freq, &multiplier, ÷r);
2826 + /* check multiplier range */
2827 + if( (multiplier > PLL_MUL_MAXFACTOR) || (multiplier <= 0) )
2829 + return TNETD73XX_ERR_ERROR;
2832 + /* check divider value */
2833 + if( divider == 0 )
2835 + return TNETD73XX_ERR_ERROR;
2838 + /*compute minimum and maximum predivider values */
2839 + min_prediv = MAX(base_freq / MAX_PLL_INP_FREQ + 1, divider / MAX_DIV_VALUE + 1);
2840 + max_prediv = MIN(base_freq / MIN_PLL_INP_FREQ, MAX_DIV_VALUE);
2842 + /*adjust the value of divider so that it not less than minimum predivider value*/
2843 + if (divider < min_prediv)
2845 + temp = CEIL(min_prediv, divider);
2846 + if ((temp * multiplier) > PLL_MUL_MAXFACTOR)
2848 + return TNETD73XX_ERR_ERROR ;
2852 + multiplier = temp * multiplier;
2853 + divider = min_prediv;
2858 + /* compute predivider and postdivider values */
2859 + prediv = compute_prediv (divider, min_prediv, max_prediv);
2860 + postdiv = CEIL(divider,prediv);
2862 + /*return fail if postdivider value falls out of range */
2863 + if(postdiv > MAX_DIV_VALUE)
2865 + return TNETD73XX_ERR_ERROR;
2869 + /*write predivider and postdivider values*/
2870 + /* pre-Divider and post-divider are 5 bit N+1 dividers */
2871 + REG32_WRITE(CLKC_CLKCR(clk_id), ((postdiv -1) & 0x1F) << 16 | ((prediv -1) & 0x1F) );
2873 + /*wait for divider output to stabilise*/
2874 + for(temp =0; temp < DIVIDER_LOCK_TIME; temp++);
2876 + /*write to PLL clock register*/
2878 + if(clk_id == CLKC_SYS)
2880 + /* but before writing put DRAM to hold mode */
2881 + REG32_DATA(TNETD73XX_EMIF_SDRAM_CFG) |= 0x80000000;
2883 + /*Bring PLL into div mode */
2884 + REG32_WRITE(CLKC_CLKPLLCR(clk_id), 0x4);
2886 + /*compute the word to be written to PLLCR
2887 + *corresponding to multiplier value
2889 + multiplier = (((multiplier - 1) & 0xf) << 12)| ((255 <<3) | 0x0e);
2891 + /* wait till PLL enters div mode */
2892 + while(REG32_DATA(CLKC_CLKPLLCR(clk_id)) & CLKC_PLL_STATUS)
2895 + REG32_WRITE(CLKC_CLKPLLCR(clk_id), multiplier);
2897 + while(!REG32_DATA(CLKC_CLKPLLCR(clk_id)) & CLKC_PLL_STATUS)
2901 + /*wait for External pll to lock*/
2902 + for(temp =0; temp < PLL_LOCK_TIME; temp++);
2904 + if(clk_id == CLKC_SYS)
2906 + /* Bring DRAM out of hold */
2907 + REG32_DATA(TNETD73XX_EMIF_SDRAM_CFG) &= ~0x80000000;
2910 + return TNETD73XX_ERR_OK ;
2913 +/****************************************************************************
2914 + * FUNCTION: tnetd73xx_clkc_get_freq
2915 + ****************************************************************************
2916 + * Description: The above routine is called to get the output_frequency of the
2917 + * selected clock( clk_id)
2918 + ***************************************************************************/
2919 +u32 tnetd73xx_clkc_get_freq
2921 + TNETD73XX_CLKC_ID_T clk_id
2925 + u32 clk_ctrl_register;
2926 + u32 clk_pll_setting;
2927 + u32 clk_predivider;
2928 + u32 clk_postdivider;
2933 + base_freq = get_base_frequency(clk_id);
2935 + clk_ctrl_register = REG32_DATA(CLKC_CLKCR(clk_id));
2937 + /* pre-Divider and post-divider are 5 bit N+1 dividers */
2938 + clk_predivider = (CLKC_PRE_DIVIDER & clk_ctrl_register) + 1;
2939 + clk_postdivider = ((CLKC_POST_DIVIDER & clk_ctrl_register) >> 16) + 1;
2941 + divider = clk_predivider * clk_postdivider;
2944 + if( (REG32_DATA(TNETD73XX_DCL_BOOTCR) & BOOTCR_PLL_BYPASS))
2946 + return (CEIL(base_freq, divider)); /* PLLs bypassed.*/
2952 + /* return the current clock speed based upon the PLL setting */
2953 + clk_pll_setting = REG32_DATA(CLKC_CLKPLLCR(clk_id));
2955 + /* Get the PLL multiplication factor */
2956 + pll_factor = ((clk_pll_setting & CLKC_PLL_FACTOR) >> 12) + 1;
2958 + /* Check if we're in divide mode or multiply mode */
2959 + if((clk_pll_setting & 0x1) == 0)
2961 + /* We're in divide mode */
2962 + if(pll_factor < 0x10)
2963 + return (CEIL(base_freq >> 1, divider));
2965 + return (CEIL(base_freq >> 2, divider));
2968 + else /* We're in PLL mode */
2970 + /* See if PLLNDIV & PLLDIV are set */
2971 + if((clk_pll_setting & 0x0800) && (clk_pll_setting & 0x2))
2973 + if(clk_pll_setting & 0x1000)
2975 + /* clk = base_freq * k/2 */
2976 + return(CEIL((base_freq * pll_factor) >> 1, divider));
2980 + /* clk = base_freq * (k-1) / 4)*/
2981 + return(CEIL((base_freq * (pll_factor - 1)) >>2, divider));
2986 + if(pll_factor < 0x10)
2988 + /* clk = base_freq * k */
2989 + return(CEIL(base_freq * pll_factor, divider));
2994 + /* clk = base_freq */
2995 + return(CEIL(base_freq, divider));
2999 + return(0); /* Should never reach here */
3006 +/* local helper functions */
3008 +/****************************************************************************
3009 + * FUNCTION: get_base_frequency
3010 + ****************************************************************************
3011 + * Description: The above routine is called to get base frequency of the clocks.
3012 + ***************************************************************************/
3014 +static u32 get_base_frequency(TNETD73XX_CLKC_ID_T clk_id)
3016 + /* update the current MIPs PLL output value, if the required
3017 + * source is MIPS PLL
3019 + if ( clk_src[clk_id] == &mips_pll_out)
3021 + *clk_src[clk_id] = tnetd73xx_clkc_get_freq(CLKC_MIPS);
3025 + /* update the current System PLL output value, if the required
3026 + * source is system PLL
3028 + if ( clk_src[clk_id] == &sys_pll_out)
3030 + *clk_src[clk_id] = tnetd73xx_clkc_get_freq(CLKC_SYS);
3033 + return (*clk_src[clk_id]);
3039 +/****************************************************************************
3040 + * FUNCTION: find_gcd
3041 + ****************************************************************************
3042 + * Description: The above routine is called to find gcd of 2 numbers.
3043 + ***************************************************************************/
3044 +static u32 find_gcd
3050 + if (max % min == 0)
3056 + return find_gcd(max % min, min);
3060 +/****************************************************************************
3061 + * FUNCTION: compute_prediv
3062 + ****************************************************************************
3063 + * Description: The above routine is called to compute predivider value
3064 + ***************************************************************************/
3065 +static u32 compute_prediv(u32 divider, u32 min, u32 max)
3069 + /* return the divider itself it it falls within the range of predivider*/
3070 + if (min <= divider && divider <= max)
3075 + /* find a value for prediv such that it is a factor of divider */
3076 + for (prediv = max; prediv >= min ; prediv--)
3078 + if ( (divider % prediv) == 0 )
3084 + /* No such factor exists, return min as prediv */
3088 +/****************************************************************************
3089 + * FUNCTION: get_val
3090 + ****************************************************************************
3091 + * Description: This routine is called to get values of divider and multiplier.
3092 + ***************************************************************************/
3094 +static void get_val(u32 output_freq, u32 base_freq,u32 *multiplier, u32 *divider)
3102 + /* find gcd of base_freq, output_freq */
3103 + min_freq = (base_freq < output_freq) ? base_freq : output_freq;
3104 + max_freq = (base_freq > output_freq) ? base_freq : output_freq;
3105 + gcd = find_gcd(min_freq , max_freq);
3108 + return; /* ERROR */
3110 + /* compute values of multiplier and divider */
3111 + temp_mul = output_freq / gcd;
3112 + temp_div = base_freq / gcd;
3115 + /* set multiplier such that 1 <= multiplier <= PLL_MUL_MAXFACTOR */
3116 + if( temp_mul > PLL_MUL_MAXFACTOR )
3118 + if((temp_mul / temp_div) > PLL_MUL_MAXFACTOR)
3121 + find_approx(&temp_mul,&temp_div,base_freq);
3124 + *multiplier = temp_mul;
3125 + *divider = temp_div;
3128 +/****************************************************************************
3129 + * FUNCTION: find_approx
3130 + ****************************************************************************
3131 + * Description: This function gets the approx value of num/denom.
3132 + ***************************************************************************/
3134 +static void find_approx(u32 *num,u32 *denom,u32 base_freq)
3141 + int32_t prev_closest;
3151 + prev_closest = 0x7fffffff; /* maximum possible value */
3155 + /* start with max */
3156 + for(temp_num = 15; temp_num >=1; temp_num--)
3159 + temp_denom = CEIL(temp_num * denom1, num1);
3160 + output_freq = (temp_num * base_freq) / temp_denom;
3162 + if(temp_denom < 1)
3168 + normalize = CEIL(num1,temp_num);
3169 + closest = (ABS((num1 * (temp_denom) ) - (temp_num * denom1))) * normalize;
3170 + if(closest < prev_closest && output_freq > present_min && output_freq <present_max)
3172 + prev_closest = closest;
3174 + denom2 = temp_denom;
3181 + gcd = find_gcd(num2,denom2);
3182 + num2 = num2 / gcd;
3183 + denom2 = denom2 /gcd;
3190 +/*****************************************************************************
3192 + *****************************************************************************/
3194 +/****************************************************************************
3195 + * FUNCTION: tnetd73xx_gpio_init
3196 + ***************************************************************************/
3197 +void tnetd73xx_gpio_init()
3199 + /* Bring module out of reset */
3200 + tnetd73xx_reset_ctrl(RESET_MODULE_GPIO, OUT_OF_RESET);
3201 + REG32_WRITE(TNETD73XX_GPIOENR, 0xFFFFFFFF);
3204 +/****************************************************************************
3205 + * FUNCTION: tnetd73xx_gpio_ctrl
3206 + ***************************************************************************/
3207 +void tnetd73xx_gpio_ctrl(TNETD73XX_GPIO_PIN_T gpio_pin,
3208 + TNETD73XX_GPIO_PIN_MODE_T pin_mode,
3209 + TNETD73XX_GPIO_PIN_DIRECTION_T pin_direction)
3212 + REG32_READ(TNETD73XX_GPIOENR, pin_status);
3213 + if (pin_mode == GPIO_PIN)
3215 + pin_status |= (1 << gpio_pin);
3216 + REG32_WRITE(TNETD73XX_GPIOENR, pin_status);
3218 + /* Set pin direction */
3219 + REG32_READ(TNETD73XX_GPIOPDIRR, pin_status);
3220 + if (pin_direction == GPIO_INPUT_PIN)
3222 + pin_status |= (1 << gpio_pin);
3224 + else /* GPIO_OUTPUT_PIN */
3226 + pin_status &= (~(1 << gpio_pin));
3228 + REG32_WRITE(TNETD73XX_GPIOPDIRR, pin_status);
3230 + else /* FUNCTIONAL PIN */
3232 + pin_status &= (~(1 << gpio_pin));
3233 + REG32_WRITE(TNETD73XX_GPIOENR, pin_status);
3238 +/****************************************************************************
3239 + * FUNCTION: tnetd73xx_gpio_out
3240 + ***************************************************************************/
3241 +void tnetd73xx_gpio_out(TNETD73XX_GPIO_PIN_T gpio_pin, int value)
3245 + REG32_READ(TNETD73XX_GPIODOUTR, pin_value);
3248 + pin_value |= (1 << gpio_pin);
3252 + pin_value &= (~(1 << gpio_pin));
3254 + REG32_WRITE(TNETD73XX_GPIODOUTR, pin_value);
3257 +/****************************************************************************
3258 + * FUNCTION: tnetd73xx_gpio_in
3259 + ***************************************************************************/
3260 +int tnetd73xx_gpio_in(TNETD73XX_GPIO_PIN_T gpio_pin)
3263 + REG32_READ(TNETD73XX_GPIODINR, pin_value);
3264 + return ( (pin_value & (1 << gpio_pin)) ? 1 : 0 );
3267 diff -urN linux.old/arch/mips/config-shared.in linux.dev/arch/mips/config-shared.in
3268 --- linux.old/arch/mips/config-shared.in 2005-07-10 03:00:44.784181376 +0200
3269 +++ linux.dev/arch/mips/config-shared.in 2005-07-12 02:59:26.192668528 +0200
3271 mainmenu_option next_comment
3272 comment 'Machine selection'
3273 dep_bool 'Support for Acer PICA 1 chipset (EXPERIMENTAL)' CONFIG_ACER_PICA_61 $CONFIG_EXPERIMENTAL
3274 +dep_bool 'Support for Texas Instruments AR7 (EXPERIMENTAL)' CONFIG_AR7 $CONFIG_MIPS32 $CONFIG_EXPERIMENTAL
3275 +if [ "$CONFIG_AR7" = "y" ]; then
3276 + choice 'Texas Instruments Reference Platform' \
3277 + "AR7DB CONFIG_AR7DB \
3278 + AR7RD CONFIG_AR7RD \
3279 + AR7WRD CONFIG_AR7WRD" AR7DB
3280 + int 'Texas Instruments AR7 CPU Frequency' CONFIG_AR7_CPU_FREQUENCY 150
3281 + int 'Texas Instruments AR7 System Frequency' CONFIG_AR7_SYS_FREQUENCY 125
3282 + hex 'Texas Instruments AR7 SDRAM Start' CONFIG_AR7_MEMORY 0x14000000
3284 dep_bool 'Support for Alchemy Bosporus board' CONFIG_MIPS_BOSPORUS $CONFIG_MIPS32
3285 dep_bool 'Support for FIC Multimedia Player board' CONFIG_MIPS_FICMMP $CONFIG_MIPS32
3286 dep_bool 'Support for Alchemy Mirage board' CONFIG_MIPS_MIRAGE $CONFIG_MIPS32
3287 @@ -239,6 +249,11 @@
3288 define_bool CONFIG_NONCOHERENT_IO y
3289 define_bool CONFIG_PC_KEYB y
3291 +if [ "$CONFIG_AR7" = "y" ]; then
3292 + define_bool CONFIG_NONCOHERENT_IO y
3293 + define_bool CONFIG_SWAP_IO_SPACE y
3294 + define_bool CONFIG_AR7_PAGING y
3296 if [ "$CONFIG_CASIO_E55" = "y" ]; then
3297 define_bool CONFIG_IRQ_CPU y
3298 define_bool CONFIG_NONCOHERENT_IO y
3300 mainmenu_option next_comment
3301 comment 'General setup'
3302 if [ "$CONFIG_ACER_PICA_61" = "y" -o \
3303 + "$CONFIG_AR7" = "y" -o \
3304 "$CONFIG_CASIO_E55" = "y" -o \
3305 "$CONFIG_DDB5074" = "y" -o \
3306 "$CONFIG_DDB5476" = "y" -o \
3308 bool 'Networking support' CONFIG_NET
3310 if [ "$CONFIG_ACER_PICA_61" = "y" -o \
3311 + "$CONFIG_AR7" = "y" -o \
3312 "$CONFIG_CASIO_E55" = "y" -o \
3313 "$CONFIG_DECSTATION" = "y" -o \
3314 "$CONFIG_IBM_WORKPAD" = "y" -o \
3315 diff -urN linux.old/arch/mips/kernel/irq.c linux.dev/arch/mips/kernel/irq.c
3316 --- linux.old/arch/mips/kernel/irq.c 2005-07-10 03:00:44.784181376 +0200
3317 +++ linux.dev/arch/mips/kernel/irq.c 2005-07-12 02:59:26.193668376 +0200
3319 * Generic, controller-independent functions:
3323 int get_irq_list(char *buf)
3327 p += sprintf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
3333 int global_irq_holder = NO_PROC_ID;
3339 int request_irq(unsigned int irq,
3340 void (*handler)(int, void *, struct pt_regs *),
3341 unsigned long irqflags,
3349 * free_irq - free an interrupt
3355 void free_irq(unsigned int irq, void *dev_id)
3365 * IRQ autodetection code..
3366 diff -urN linux.old/arch/mips/kernel/mips_ksyms.c linux.dev/arch/mips/kernel/mips_ksyms.c
3367 --- linux.old/arch/mips/kernel/mips_ksyms.c 2004-02-18 14:36:30.000000000 +0100
3368 +++ linux.dev/arch/mips/kernel/mips_ksyms.c 2005-07-12 02:59:26.193668376 +0200
3370 extern long __strnlen_user_nocheck_asm(const char *s);
3371 extern long __strnlen_user_asm(const char *s);
3374 +int avalanche_request_pacing(int irq_nr, unsigned int blk_num, unsigned int pace_value);
3375 +char *prom_getenv(char *envname);
3379 EXPORT_SYMBOL(mips_machtype);
3381 EXPORT_SYMBOL(EISA_bus);
3385 EXPORT_SYMBOL(get_wchan);
3388 +EXPORT_SYMBOL_NOVERS(avalanche_request_pacing);
3389 +EXPORT_SYMBOL_NOVERS(prom_getenv);
3392 diff -urN linux.old/arch/mips/kernel/setup.c linux.dev/arch/mips/kernel/setup.c
3393 --- linux.old/arch/mips/kernel/setup.c 2005-07-10 03:00:44.785181224 +0200
3394 +++ linux.dev/arch/mips/kernel/setup.c 2005-07-12 02:59:26.194668224 +0200
3396 unsigned long isa_slot_offset;
3397 EXPORT_SYMBOL(isa_slot_offset);
3399 +extern void avalanche_bootmem_init(void);
3400 extern void SetUpBootInfo(void);
3401 extern void load_mmu(void);
3402 extern asmlinkage void start_kernel(void);
3404 #endif /* CONFIG_BLK_DEV_INITRD */
3406 /* Find the highest page frame number we have available. */
3407 +#ifdef CONFIG_AR7_PAGING
3408 + avalanche_bootmem_init();
3411 first_usable_pfn = -1UL;
3412 for (i = 0; i < boot_mem_map.nr_map; i++) {
3414 /* Reserve the bootmap memory. */
3415 reserve_bootmem(PFN_PHYS(first_usable_pfn), bootmap_size);
3418 #ifdef CONFIG_BLK_DEV_INITRD
3419 /* Board specific code should have set up initrd_start and initrd_end */
3420 ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
3422 void hp_setup(void);
3423 void au1x00_setup(void);
3424 void frame_info_init(void);
3425 + void ar7_setup(void);
3428 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE)
3429 @@ -691,6 +697,11 @@
3430 pmc_yosemite_setup();
3434 + case MACH_GROUP_UNKNOWN:
3439 panic("Unsupported architecture");
3441 diff -urN linux.old/arch/mips/kernel/traps.c linux.dev/arch/mips/kernel/traps.c
3442 --- linux.old/arch/mips/kernel/traps.c 2005-07-10 03:00:44.786181072 +0200
3443 +++ linux.dev/arch/mips/kernel/traps.c 2005-07-12 02:59:26.194668224 +0200
3445 #include <asm/uaccess.h>
3446 #include <asm/mmu_context.h>
3449 +#include <asm/ar7/ar7.h>
3452 extern asmlinkage void handle_mod(void);
3453 extern asmlinkage void handle_tlbl(void);
3454 extern asmlinkage void handle_tlbs(void);
3455 @@ -869,9 +873,15 @@
3457 exception_handlers[n] = handler;
3458 if (n == 0 && cpu_has_divec) {
3460 + *(volatile u32 *)(AVALANCHE_VECS_KSEG0+0x200) = 0x08000000 |
3461 + (0x03ffffff & (handler >> 2));
3462 + flush_icache_range(AVALANCHE_VECS_KSEG0+0x200, AVALANCHE_VECS_KSEG0 + 0x204);
3464 *(volatile u32 *)(KSEG0+0x200) = 0x08000000 |
3465 (0x03ffffff & (handler >> 2));
3466 flush_icache_range(KSEG0+0x200, KSEG0 + 0x204);
3469 return (void *)old_handler;
3471 @@ -920,14 +930,46 @@
3472 void __init trap_init(void)
3474 extern char except_vec1_generic;
3475 + extern char except_vec2_generic;
3476 extern char except_vec3_generic, except_vec3_r4000;
3477 extern char except_vec_ejtag_debug;
3478 extern char except_vec4;
3482 + extern char jump_tlb_miss, jump_tlb_miss_unused;
3483 + extern char jump_cache_error,jump_general_exception;
3484 + extern char jump_dedicated_interrupt;
3485 + clear_c0_status(ST0_BEV);
3488 /* Copy the generic exception handler code to it's final destination. */
3489 memcpy((void *)(KSEG0 + 0x80), &except_vec1_generic, 0x80);
3490 + memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80);
3491 + memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80);
3493 + memcpy((void *)(KSEG0 + 0x0), &jump_tlb_miss, 0x80);
3494 + memcpy((void *)(KSEG0 + 0x80), &jump_tlb_miss_unused, 0x80);
3495 + memcpy((void *)(KSEG0 + 0x100), &jump_cache_error, 0x80);
3496 + memcpy((void *)(KSEG0 + 0x180), &jump_general_exception, 0x80);
3497 + memcpy((void *)(KSEG0 + 0x200), &jump_dedicated_interrupt, 0x80);
3500 + memcpy((void *)(AVALANCHE_VECS_KSEG0 + 0x80), &except_vec1_generic, 0x80);
3501 + memcpy((void *)(AVALANCHE_VECS_KSEG0 + 0x100), &except_vec2_generic, 0x80);
3502 + memcpy((void *)(AVALANCHE_VECS_KSEG0 + 0x180), &except_vec3_generic, 0x80);
3503 + flush_icache_range(AVALANCHE_VECS_KSEG0, AVALANCHE_VECS_KSEG0 + 0x200);
3505 + memcpy((void *)(KSEG0 + 0x0), &jump_tlb_miss, 0x80);
3506 + memcpy((void *)(KSEG0 + 0x80), &jump_tlb_miss_unused, 0x80);
3507 + memcpy((void *)(KSEG0 + 0x100), &jump_cache_error, 0x80);
3508 + memcpy((void *)(KSEG0 + 0x180), &jump_general_exception, 0x80);
3509 + memcpy((void *)(KSEG0 + 0x200), &jump_dedicated_interrupt, 0x80);
3511 + memcpy((void *)(KSEG0 + 0x80), &except_vec1_generic, 0x80);
3513 + flush_icache_range(KSEG0 + 0x80, KSEG0 + 0x200);
3516 * Setup default vectors
3518 @@ -951,8 +993,12 @@
3519 * Some MIPS CPUs have a dedicated interrupt vector which reduces the
3520 * interrupt processing overhead. Use it where available.
3523 + memcpy((void *)(AVALANCHE_VECS_KSEG0 + 0x200), &except_vec4, 8);
3526 memcpy((void *)(KSEG0 + 0x200), &except_vec4, 8);
3530 * Some CPUs can enable/disable for cache parity detection, but does
3531 @@ -991,12 +1037,17 @@
3533 set_except_vector(24, handle_mcheck);
3535 +memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80);
3537 + memcpy((void *)(AVALANCHE_VECS_KSEG0 + 0x180), &except_vec3_generic, 0x80);
3540 memcpy((void *)(KSEG0 + 0x180), &except_vec3_r4000, 0x80);
3541 else if (cpu_has_4kex)
3542 memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80);
3544 memcpy((void *)(KSEG0 + 0x080), &except_vec3_generic, 0x80);
3547 if (current_cpu_data.cputype == CPU_R6000 ||
3548 current_cpu_data.cputype == CPU_R6000A) {
3549 @@ -1023,7 +1074,11 @@
3550 if (board_nmi_handler_setup)
3551 board_nmi_handler_setup();
3554 + flush_icache_range(AVALANCHE_VECS_KSEG0, AVALANCHE_VECS_KSEG0 + 0x200);
3556 flush_icache_range(KSEG0, KSEG0 + 0x400);
3559 per_cpu_trap_init();
3561 diff -urN linux.old/arch/mips/lib/promlib.c linux.dev/arch/mips/lib/promlib.c
3562 --- linux.old/arch/mips/lib/promlib.c 2005-07-10 03:00:44.786181072 +0200
3563 +++ linux.dev/arch/mips/lib/promlib.c 2005-07-12 02:59:26.195668072 +0200
3567 #include <linux/kernel.h>
3574 diff -urN linux.old/arch/mips/Makefile linux.dev/arch/mips/Makefile
3575 --- linux.old/arch/mips/Makefile 2005-07-10 03:00:44.786181072 +0200
3576 +++ linux.dev/arch/mips/Makefile 2005-07-12 02:59:26.195668072 +0200
3577 @@ -369,6 +369,16 @@
3581 +# Texas Instruments AR7
3585 +LIBS += arch/mips/ar7/ar7.o arch/mips/ar7/ar7/ar7.o
3586 +SUBDIRS += arch/mips/ar7 arch/mips/ar7/ar7
3587 +LOADADDR += 0x94020000
3593 ifdef CONFIG_DECSTATION
3594 diff -urN linux.old/arch/mips/mm/init.c linux.dev/arch/mips/mm/init.c
3595 --- linux.old/arch/mips/mm/init.c 2005-07-10 03:00:44.787180920 +0200
3596 +++ linux.dev/arch/mips/mm/init.c 2005-07-12 02:59:26.195668072 +0200
3599 mmu_gather_t mmu_gathers[NR_CPUS];
3600 unsigned long highstart_pfn, highend_pfn;
3601 +#ifndef CONFIG_AR7_PAGING
3602 static unsigned long totalram_pages;
3603 static unsigned long totalhigh_pages;
3606 void pgd_init(unsigned long page)
3612 +#ifndef CONFIG_AR7_PAGING
3613 void __init paging_init(void)
3615 unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
3618 free_area_init(zones_size);
3622 #define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
3623 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
3628 +#ifndef CONFIG_AR7_PAGING
3629 void __init mem_init(void)
3631 unsigned long codesize, reservedpages, datasize, initsize;
3634 (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
3638 #ifdef CONFIG_BLK_DEV_INITRD
3639 void free_initrd_mem(unsigned long start, unsigned long end)
3644 +#ifndef CONFIG_AR7_PAGING
3645 extern char __init_begin, __init_end;
3646 extern void prom_free_prom_memory(void) __init;
3653 prom_free_prom_memory ();
3656 addr = (unsigned long) &__init_begin;
3657 while (addr < (unsigned long) &__init_end) {
3663 diff -urN linux.old/arch/mips/mm/tlb-r4k.c linux.dev/arch/mips/mm/tlb-r4k.c
3664 --- linux.old/arch/mips/mm/tlb-r4k.c 2005-07-10 03:00:44.787180920 +0200
3665 +++ linux.dev/arch/mips/mm/tlb-r4k.c 2005-07-12 02:59:26.196667920 +0200
3667 #include <asm/pgtable.h>
3668 #include <asm/system.h>
3671 +#include <asm/ar7/ar7.h>
3674 extern char except_vec0_nevada, except_vec0_r4000, except_vec0_r4600;
3676 /* CP0 hazard avoidance. */
3677 @@ -375,7 +379,12 @@
3678 else if (current_cpu_data.cputype == CPU_R4600)
3679 memcpy((void *)KSEG0, &except_vec0_r4600, 0x80);
3682 + memcpy((void *)AVALANCHE_VECS_KSEG0, &except_vec0_r4000, 0x80);
3683 + flush_icache_range(AVALANCHE_VECS_KSEG0, AVALANCHE_VECS_KSEG0 + 0x80);
3685 memcpy((void *)KSEG0, &except_vec0_r4000, 0x80);
3686 flush_icache_range(KSEG0, KSEG0 + 0x80);
3690 diff -urN linux.old/drivers/char/serial.c linux.dev/drivers/char/serial.c
3691 --- linux.old/drivers/char/serial.c 2005-07-10 03:00:44.789180616 +0200
3692 +++ linux.dev/drivers/char/serial.c 2005-07-12 02:59:26.198667616 +0200
3693 @@ -419,7 +419,40 @@
3697 -#if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_SEAD)
3698 +#if defined(CONFIG_AR7)
3700 +static _INLINE_ unsigned int serial_in(struct async_struct *info, int offset)
3702 + return (inb(info->port + (offset * 4)) & 0xff);
3706 +static _INLINE_ unsigned int serial_inp(struct async_struct *info, int offset)
3708 +#ifdef CONFIG_SERIAL_NOPAUSE_IO
3709 + return (inb(info->port + (offset * 4)) & 0xff);
3711 + return (inb_p(info->port + (offset * 4)) & 0xff);
3715 +static _INLINE_ void serial_out(struct async_struct *info, int offset, int value)
3717 + outb(value, info->port + (offset * 4));
3721 +static _INLINE_ void serial_outp(struct async_struct *info, int offset,
3724 +#ifdef CONFIG_SERIAL_NOPAUSE_IO
3725 + outb(value, info->port + (offset * 4));
3727 + outb_p(value, info->port + (offset * 4));
3731 +#elif defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_SEAD)
3733 #include <asm/mips-boards/atlas.h>
3735 @@ -478,8 +511,10 @@
3736 * needed for certain old 386 machines, I've left these #define's
3740 #define serial_inp(info, offset) serial_in(info, offset)
3741 #define serial_outp(info, offset, value) serial_out(info, offset, value)
3746 @@ -1728,7 +1763,16 @@
3747 /* Special case since 134 is really 134.5 */
3748 quot = (2*baud_base / 269);
3751 + quot = (CONFIG_AR7_SYS_FREQUENCY*500000) / baud;
3752 + //quot = get_avalanche_vbus_freq() / baud;
3758 quot = baud_base / baud;
3761 /* If the quotient is zero refuse the change */
3762 if (!quot && old_termios) {
3763 @@ -5552,8 +5596,10 @@
3764 state->irq = irq_cannonicalize(state->irq);
3766 state->io_type = SERIAL_IO_HUB6;
3768 if (state->port && check_region(state->port,8))
3772 if ((state->flags & ASYNC_BOOT_ONLYMCA) && !MCA_bus)
3774 @@ -6009,7 +6055,16 @@
3775 info->io_type = state->io_type;
3776 info->iomem_base = state->iomem_base;
3777 info->iomem_reg_shift = state->iomem_reg_shift;
3779 + //quot = get_avalanche_vbus_freq() / baud;
3780 + quot = (CONFIG_AR7_SYS_FREQUENCY*500000) / baud;
3786 quot = state->baud_base / baud;
3788 cval = cflag & (CSIZE | CSTOPB);
3789 #if defined(__powerpc__) || defined(__alpha__)
3791 diff -urN linux.old/include/asm-mips/ar7/ar7.h linux.dev/include/asm-mips/ar7/ar7.h
3792 --- linux.old/include/asm-mips/ar7/ar7.h 1970-01-01 01:00:00.000000000 +0100
3793 +++ linux.dev/include/asm-mips/ar7/ar7.h 2005-07-12 02:59:26.199667464 +0200
3797 + * Copyright (C) $Date$ $Author$
3799 + * This program is free software; you can redistribute it and/or modify
3800 + * it under the terms of the GNU General Public License as published by
3801 + * the Free Software Foundation; either version 2 of the License, or
3802 + * (at your option) any later version.
3804 + * This program is distributed in the hope that it will be useful,
3805 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3806 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3807 + * GNU General Public License for more details.
3809 + * You should have received a copy of the GNU General Public License
3810 + * along with this program; if not, write to the Free Software
3811 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3818 +#include <asm/addrspace.h>
3819 +#include <linux/config.h>
3821 +#define AVALANCHE_VECS_KSEG0 (KSEG0ADDR(CONFIG_AR7_MEMORY))
3823 +#define AR7_UART0_REGS_BASE (KSEG1ADDR(0x08610E00))
3824 +#define AR7_UART1_REGS_BASE (KSEG1ADDR(0x08610E00))
3825 +#define AR7_BASE_BAUD ( 3686400 / 16 )
3828 diff -urN linux.old/include/asm-mips/ar7/avalanche_intc.h linux.dev/include/asm-mips/ar7/avalanche_intc.h
3829 --- linux.old/include/asm-mips/ar7/avalanche_intc.h 1970-01-01 01:00:00.000000000 +0100
3830 +++ linux.dev/include/asm-mips/ar7/avalanche_intc.h 2005-07-12 02:59:26.199667464 +0200
3833 + * Nitin Dhingra, iamnd@ti.com
3834 + * Copyright (C) 2000 Texas Instruments Inc.
3837 + * ########################################################################
3839 + * This program is free software; you can distribute it and/or modify it
3840 + * under the terms of the GNU General Public License (Version 2) as
3841 + * published by the Free Software Foundation.
3843 + * This program is distributed in the hope it will be useful, but WITHOUT
3844 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3845 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3846 + * for more details.
3848 + * You should have received a copy of the GNU General Public License along
3849 + * with this program; if not, write to the Free Software Foundation, Inc.,
3850 + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
3852 + * ########################################################################
3854 + * Defines of the Sead board specific address-MAP, registers, etc.
3857 +#ifndef _AVALANCHE_INTC_H
3858 +#define _AVALANCHE_INTC_H
3860 +#define MIPS_EXCEPTION_OFFSET 8
3862 +/******************************************************************************
3863 + Avalanche Interrupt number
3864 +******************************************************************************/
3865 +#define AVINTNUM(x) ((x) - MIPS_EXCEPTION_OFFSET)
3867 +/*******************************************************************************
3868 +*Linux Interrupt number
3869 +*******************************************************************************/
3870 +#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
3874 +#define AVALANCHE_INT_END_PRIMARY (40 + MIPS_EXCEPTION_OFFSET)
3875 +#define AVALANCHE_INT_END_SECONDARY (32 + MIPS_EXCEPTION_OFFSET)
3877 +#define AVALANCHE_INT_END_PRIMARY_REG1 (31 + MIPS_EXCEPTION_OFFSET)
3878 +#define AVALANCHE_INT_END_PRIMARY_REG2 (39 + MIPS_EXCEPTION_OFFSET)
3881 +#define AVALANCHE_INT_END (AVINTNUM(AVALANCHE_INT_END_PRIMARY) + \
3882 + AVINTNUM(AVALANCHE_INT_END_SECONDARY) \
3883 + + MIPS_EXCEPTION_OFFSET - 1) /* Suraj, check */
3887 + * Avalanche interrupt controller register base (primary)
3889 +#define KSEG1_BASE 0xA0000000
3890 +#define KSEG_INV_MASK 0x1FFFFFFF /* Inverted mask for kseg address */
3891 +#define PHYS_ADDR(addr) ((addr) & KSEG_INV_MASK)
3892 +#define PHYS_TO_K1(addr) (PHYS_ADDR(addr)|KSEG1_BASE)
3894 +#define AVALANCHE_ICTRL_REGS_BASE KSEG1ADDR(0x08612400)// AVALANCHE_INTC_BASE
3896 +/******************************************************************************
3897 + * Avalanche exception controller register base (secondary)
3898 + ******************************************************************************/
3899 +#define AVALANCHE_ECTRL_REGS_BASE (AVALANCHE_ICTRL_REGS_BASE + 0x80)
3902 +/******************************************************************************
3903 + * Avalanche Interrupt pacing register base (secondary)
3904 + ******************************************************************************/
3905 +#define AVALANCHE_IPACE_REGS_BASE (AVALANCHE_ICTRL_REGS_BASE + 0xA0)
3909 +/******************************************************************************
3910 + * Avalanche Interrupt Channel Control register base
3911 + *****************************************************************************/
3912 +#define AVALANCHE_CHCTRL_REGS_BASE (AVALANCHE_ICTRL_REGS_BASE + 0x200)
3915 +struct avalanche_ictrl_regs /* Avalanche Interrupt control registers */
3917 + volatile unsigned long intsr1; /* Interrupt Status/Set Register 1 0x00 */
3918 + volatile unsigned long intsr2; /* Interrupt Status/Set Register 2 0x04 */
3919 + volatile unsigned long unused1; /*0x08 */
3920 + volatile unsigned long unused2; /*0x0C */
3921 + volatile unsigned long intcr1; /* Interrupt Clear Register 1 0x10 */
3922 + volatile unsigned long intcr2; /* Interrupt Clear Register 2 0x14 */
3923 + volatile unsigned long unused3; /*0x18 */
3924 + volatile unsigned long unused4; /*0x1C */
3925 + volatile unsigned long intesr1; /* Interrupt Enable (Set) Register 1 0x20 */
3926 + volatile unsigned long intesr2; /* Interrupt Enable (Set) Register 2 0x24 */
3927 + volatile unsigned long unused5; /*0x28 */
3928 + volatile unsigned long unused6; /*0x2C */
3929 + volatile unsigned long intecr1; /* Interrupt Enable Clear Register 1 0x30 */
3930 + volatile unsigned long intecr2; /* Interrupt Enable Clear Register 2 0x34 */
3931 + volatile unsigned long unused7; /* 0x38 */
3932 + volatile unsigned long unused8; /* 0x3c */
3933 + volatile unsigned long pintir; /* Priority Interrupt Index Register 0x40 */
3934 + volatile unsigned long intmsr; /* Priority Interrupt Mask Index Reg 0x44 */
3935 + volatile unsigned long unused9; /* 0x48 */
3936 + volatile unsigned long unused10; /* 0x4C */
3937 + volatile unsigned long intpolr1; /* Interrupt Polarity Mask register 10x50 */
3938 + volatile unsigned long intpolr2; /* Interrupt Polarity Mask register 20x54 */
3939 + volatile unsigned long unused11; /* 0x58 */
3940 + volatile unsigned long unused12; /*0x5C */
3941 + volatile unsigned long inttypr1; /* Interrupt Type Mask register 10x60 */
3942 + volatile unsigned long inttypr2; /* Interrupt Type Mask register 20x64 */
3945 +struct avalanche_exctrl_regs /* Avalanche Exception control registers */
3947 + volatile unsigned long exsr; /* Exceptions Status/Set register 0x80 */
3948 + volatile unsigned long reserved; /*0x84 */
3949 + volatile unsigned long excr; /* Exceptions Clear Register 0x88 */
3950 + volatile unsigned long reserved1; /*0x8c */
3951 + volatile unsigned long exiesr; /* Exceptions Interrupt Enable (set) 0x90 */
3952 + volatile unsigned long reserved2; /*0x94 */
3953 + volatile unsigned long exiecr; /* Exceptions Interrupt Enable(clear)0x98 */
3955 +struct avalanche_ipace_regs
3958 + volatile unsigned long ipacep; /* Interrupt pacing register 0xa0 */
3959 + volatile unsigned long ipacemap; /*Interrupt Pacing Map Register 0xa4 */
3960 + volatile unsigned long ipacemax; /*Interrupt Pacing Max Register 0xa8 */
3962 +struct avalanche_channel_int_number
3964 + volatile unsigned long cintnr0; /* Channel Interrupt Number Register0x200 */
3965 + volatile unsigned long cintnr1; /* Channel Interrupt Number Register0x204 */
3966 + volatile unsigned long cintnr2; /* Channel Interrupt Number Register0x208 */
3967 + volatile unsigned long cintnr3; /* Channel Interrupt Number Register0x20C */
3968 + volatile unsigned long cintnr4; /* Channel Interrupt Number Register0x210 */
3969 + volatile unsigned long cintnr5; /* Channel Interrupt Number Register0x214 */
3970 + volatile unsigned long cintnr6; /* Channel Interrupt Number Register0x218 */
3971 + volatile unsigned long cintnr7; /* Channel Interrupt Number Register0x21C */
3972 + volatile unsigned long cintnr8; /* Channel Interrupt Number Register0x220 */
3973 + volatile unsigned long cintnr9; /* Channel Interrupt Number Register0x224 */
3974 + volatile unsigned long cintnr10; /* Channel Interrupt Number Register0x228 */
3975 + volatile unsigned long cintnr11; /* Channel Interrupt Number Register0x22C */
3976 + volatile unsigned long cintnr12; /* Channel Interrupt Number Register0x230 */
3977 + volatile unsigned long cintnr13; /* Channel Interrupt Number Register0x234 */
3978 + volatile unsigned long cintnr14; /* Channel Interrupt Number Register0x238 */
3979 + volatile unsigned long cintnr15; /* Channel Interrupt Number Register0x23C */
3980 + volatile unsigned long cintnr16; /* Channel Interrupt Number Register0x240 */
3981 + volatile unsigned long cintnr17; /* Channel Interrupt Number Register0x244 */
3982 + volatile unsigned long cintnr18; /* Channel Interrupt Number Register0x248 */
3983 + volatile unsigned long cintnr19; /* Channel Interrupt Number Register0x24C */
3984 + volatile unsigned long cintnr20; /* Channel Interrupt Number Register0x250 */
3985 + volatile unsigned long cintnr21; /* Channel Interrupt Number Register0x254 */
3986 + volatile unsigned long cintnr22; /* Channel Interrupt Number Register0x358 */
3987 + volatile unsigned long cintnr23; /* Channel Interrupt Number Register0x35C */
3988 + volatile unsigned long cintnr24; /* Channel Interrupt Number Register0x260 */
3989 + volatile unsigned long cintnr25; /* Channel Interrupt Number Register0x264 */
3990 + volatile unsigned long cintnr26; /* Channel Interrupt Number Register0x268 */
3991 + volatile unsigned long cintnr27; /* Channel Interrupt Number Register0x26C */
3992 + volatile unsigned long cintnr28; /* Channel Interrupt Number Register0x270 */
3993 + volatile unsigned long cintnr29; /* Channel Interrupt Number Register0x274 */
3994 + volatile unsigned long cintnr30; /* Channel Interrupt Number Register0x278 */
3995 + volatile unsigned long cintnr31; /* Channel Interrupt Number Register0x27C */
3996 + volatile unsigned long cintnr32; /* Channel Interrupt Number Register0x280 */
3997 + volatile unsigned long cintnr33; /* Channel Interrupt Number Register0x284 */
3998 + volatile unsigned long cintnr34; /* Channel Interrupt Number Register0x288 */
3999 + volatile unsigned long cintnr35; /* Channel Interrupt Number Register0x28C */
4000 + volatile unsigned long cintnr36; /* Channel Interrupt Number Register0x290 */
4001 + volatile unsigned long cintnr37; /* Channel Interrupt Number Register0x294 */
4002 + volatile unsigned long cintnr38; /* Channel Interrupt Number Register0x298 */
4003 + volatile unsigned long cintnr39; /* Channel Interrupt Number Register0x29C */
4006 +struct avalanche_interrupt_line_to_channel
4008 + unsigned long int_line0; /* Start of primary interrupts */
4009 + unsigned long int_line1;
4010 + unsigned long int_line2;
4011 + unsigned long int_line3;
4012 + unsigned long int_line4;
4013 + unsigned long int_line5;
4014 + unsigned long int_line6;
4015 + unsigned long int_line7;
4016 + unsigned long int_line8;
4017 + unsigned long int_line9;
4018 + unsigned long int_line10;
4019 + unsigned long int_line11;
4020 + unsigned long int_line12;
4021 + unsigned long int_line13;
4022 + unsigned long int_line14;
4023 + unsigned long int_line15;
4024 + unsigned long int_line16;
4025 + unsigned long int_line17;
4026 + unsigned long int_line18;
4027 + unsigned long int_line19;
4028 + unsigned long int_line20;
4029 + unsigned long int_line21;
4030 + unsigned long int_line22;
4031 + unsigned long int_line23;
4032 + unsigned long int_line24;
4033 + unsigned long int_line25;
4034 + unsigned long int_line26;
4035 + unsigned long int_line27;
4036 + unsigned long int_line28;
4037 + unsigned long int_line29;
4038 + unsigned long int_line30;
4039 + unsigned long int_line31;
4040 + unsigned long int_line32;
4041 + unsigned long int_line33;
4042 + unsigned long int_line34;
4043 + unsigned long int_line35;
4044 + unsigned long int_line36;
4045 + unsigned long int_line37;
4046 + unsigned long int_line38;
4047 + unsigned long int_line39;
4051 +/* Interrupt Line #'s (Sangam peripherals) */
4053 +/*------------------------------*/
4054 +/* Sangam primary interrupts */
4055 +/*------------------------------*/
4057 +#define UNIFIED_SECONDARY_INTERRUPT 0
4058 +#define AVALANCHE_EXT_INT_0 1
4059 +#define AVALANCHE_EXT_INT_1 2
4060 +/* Line #3 Reserved */
4061 +/* Line #4 Reserved */
4062 +#define AVALANCHE_TIMER_0_INT 5
4063 +#define AVALANCHE_TIMER_1_INT 6
4064 +#define AVALANCHE_UART0_INT 7
4065 +#define AVALANCHE_UART1_INT 8
4066 +#define AVALANCHE_PDMA_INT0 9
4067 +#define AVALANCHE_PDMA_INT1 10
4068 +/* Line #11 Reserved */
4069 +/* Line #12 Reserved */
4070 +/* Line #13 Reserved */
4071 +/* Line #14 Reserved */
4072 +#define AVALANCHE_ATM_SAR_INT 15
4073 +/* Line #16 Reserved */
4074 +/* Line #17 Reserved */
4075 +/* Line #18 Reserved */
4076 +#define AVALANCHE_MAC0_INT 19
4077 +/* Line #20 Reserved */
4078 +#define AVALANCHE_VLYNQ0_INT 21
4079 +#define AVALANCHE_CODEC_WAKE_INT 22
4080 +/* Line #23 Reserved */
4081 +#define AVALANCHE_USB_INT 24
4082 +#define AVALANCHE_VLYNQ1_INT 25
4083 +/* Line #26 Reserved */
4084 +/* Line #27 Reserved */
4085 +#define AVALANCHE_MAC1_INT 28
4086 +#define AVALANCHE_I2CM_INT 29
4087 +#define AVALANCHE_PDMA_INT2 30
4088 +#define AVALANCHE_PDMA_INT3 31
4089 +/* Line #32 Reserved */
4090 +/* Line #33 Reserved */
4091 +/* Line #34 Reserved */
4092 +/* Line #35 Reserved */
4093 +/* Line #36 Reserved */
4094 +#define AVALANCHE_VDMA_VT_RX_INT 37
4095 +#define AVALANCHE_VDMA_VT_TX_INT 38
4096 +#define AVALANCHE_ADSLSS_INT 39
4098 +/*-----------------------------------*/
4099 +/* Sangam Secondary Interrupts */
4100 +/*-----------------------------------*/
4101 +#define PRIMARY_INTS 40
4103 +#define EMIF_INT (7 + PRIMARY_INTS)
4106 +extern void avalanche_int_set(int channel, int line);
4109 +#endif /* _AVALANCHE_INTC_H */
4110 diff -urN linux.old/include/asm-mips/ar7/avalanche_misc.h linux.dev/include/asm-mips/ar7/avalanche_misc.h
4111 --- linux.old/include/asm-mips/ar7/avalanche_misc.h 1970-01-01 01:00:00.000000000 +0100
4112 +++ linux.dev/include/asm-mips/ar7/avalanche_misc.h 2005-07-12 02:59:26.200667312 +0200
4114 +#ifndef _AVALANCHE_MISC_H_
4115 +#define _AVALANCHE_MISC_H_
4117 +typedef enum AVALANCHE_ERR_t
4119 + AVALANCHE_ERR_OK = 0, /* OK or SUCCESS */
4120 + AVALANCHE_ERR_ERROR = -1, /* Unspecified/Generic ERROR */
4122 + /* Pointers and args */
4123 + AVALANCHE_ERR_INVARG = -2, /* Invaild argument to the call */
4124 + AVALANCHE_ERR_NULLPTR = -3, /* NULL pointer */
4125 + AVALANCHE_ERR_BADPTR = -4, /* Bad (out of mem) pointer */
4127 + /* Memory issues */
4128 + AVALANCHE_ERR_ALLOC_FAIL = -10, /* allocation failed */
4129 + AVALANCHE_ERR_FREE_FAIL = -11, /* free failed */
4130 + AVALANCHE_ERR_MEM_CORRUPT = -12, /* corrupted memory */
4131 + AVALANCHE_ERR_BUF_LINK = -13, /* buffer linking failed */
4133 + /* Device issues */
4134 + AVALANCHE_ERR_DEVICE_TIMEOUT = -20, /* device timeout on read/write */
4135 + AVALANCHE_ERR_DEVICE_MALFUNC = -21, /* device malfunction */
4137 + AVALANCHE_ERR_INVID = -30 /* Invalid ID */
4141 +/*****************************************************************************
4142 + * Reset Control Module
4143 + *****************************************************************************/
4145 +typedef enum AVALANCHE_RESET_MODULE_tag
4147 + RESET_MODULE_UART0 = 0,
4148 + RESET_MODULE_UART1 = 1,
4149 + RESET_MODULE_I2C = 2,
4150 + RESET_MODULE_TIMER0 = 3,
4151 + RESET_MODULE_TIMER1 = 4,
4152 + RESET_MODULE_GPIO = 6,
4153 + RESET_MODULE_ADSLSS = 7,
4154 + RESET_MODULE_USBS = 8,
4155 + RESET_MODULE_SAR = 9,
4156 + RESET_MODULE_VDMA_VT = 11,
4157 + RESET_MODULE_FSER = 12,
4158 + RESET_MODULE_VLYNQ1 = 16,
4159 + RESET_MODULE_EMAC0 = 17,
4160 + RESET_MODULE_DMA = 18,
4161 + RESET_MODULE_BIST = 19,
4162 + RESET_MODULE_VLYNQ0 = 20,
4163 + RESET_MODULE_EMAC1 = 21,
4164 + RESET_MODULE_MDIO = 22,
4165 + RESET_MODULE_ADSLSS_DSP = 23,
4166 + RESET_MODULE_EPHY = 26
4167 +} AVALANCHE_RESET_MODULE_T;
4169 +typedef enum AVALANCHE_RESET_CTRL_tag
4173 +} AVALANCHE_RESET_CTRL_T;
4175 +typedef enum AVALANCHE_SYS_RST_MODE_tag
4177 + RESET_SOC_WITH_MEMCTRL = 1, /* SW0 bit in SWRCR register */
4178 + RESET_SOC_WITHOUT_MEMCTRL = 2 /* SW1 bit in SWRCR register */
4179 +} AVALANCHE_SYS_RST_MODE_T;
4181 +typedef enum AVALANCHE_SYS_RESET_STATUS_tag
4183 + HARDWARE_RESET = 0,
4184 + SOFTWARE_RESET0, /* Caused by writing 1 to SW0 bit in SWRCR register */
4186 + SOFTWARE_RESET1 /* Caused by writing 1 to SW1 bit in SWRCR register */
4187 +} AVALANCHE_SYS_RESET_STATUS_T;
4189 +AVALANCHE_RESET_CTRL_T avalanche_get_reset_status(AVALANCHE_RESET_MODULE_T reset_module);
4190 +void avalanche_sys_reset(AVALANCHE_SYS_RST_MODE_T mode);
4191 +AVALANCHE_SYS_RESET_STATUS_T avalanche_get_sys_last_reset_status(void);
4193 +typedef int (*REMOTE_VLYNQ_DEV_RESET_CTRL_FN)(unsigned int reset_module, AVALANCHE_RESET_CTRL_T reset_ctrl);
4195 +/*****************************************************************************
4196 + * Power Control Module
4197 + *****************************************************************************/
4199 +typedef enum AVALANCHE_POWER_CTRL_tag
4201 + POWER_CTRL_POWER_UP = 0,
4202 + POWER_CTRL_POWER_DOWN
4203 +} AVALANCHE_POWER_CTRL_T;
4205 +typedef enum AVALANCHE_SYS_POWER_MODE_tag
4207 + GLOBAL_POWER_MODE_RUN = 0, /* All system is up */
4208 + GLOBAL_POWER_MODE_IDLE, /* MIPS is power down, all peripherals working */
4209 + GLOBAL_POWER_MODE_STANDBY, /* Chip in power down, but clock to ADSKL subsystem is running */
4210 + GLOBAL_POWER_MODE_POWER_DOWN /* Total chip is powered down */
4211 +} AVALANCHE_SYS_POWER_MODE_T;
4213 +void avalanche_power_ctrl(unsigned int power_module, AVALANCHE_POWER_CTRL_T power_ctrl);
4214 +AVALANCHE_POWER_CTRL_T avalanche_get_power_status(unsigned int power_module);
4215 +void avalanche_set_global_power_mode(AVALANCHE_SYS_POWER_MODE_T power_mode);
4216 +AVALANCHE_SYS_POWER_MODE_T avalanche_get_global_power_mode(void);
4218 +/*****************************************************************************
4220 + *****************************************************************************/
4222 +typedef enum AVALANCHE_WAKEUP_INTERRUPT_tag
4228 +} AVALANCHE_WAKEUP_INTERRUPT_T;
4230 +typedef enum TNETV1050_WAKEUP_CTRL_tag
4232 + WAKEUP_DISABLED = 0,
4234 +} AVALANCHE_WAKEUP_CTRL_T;
4236 +typedef enum TNETV1050_WAKEUP_POLARITY_tag
4238 + WAKEUP_ACTIVE_HIGH = 0,
4240 +} AVALANCHE_WAKEUP_POLARITY_T;
4242 +void avalanche_wakeup_ctrl(AVALANCHE_WAKEUP_INTERRUPT_T wakeup_int,
4243 + AVALANCHE_WAKEUP_CTRL_T wakeup_ctrl,
4244 + AVALANCHE_WAKEUP_POLARITY_T wakeup_polarity);
4246 +/*****************************************************************************
4248 + *****************************************************************************/
4250 +typedef enum AVALANCHE_GPIO_PIN_MODE_tag
4252 + FUNCTIONAL_PIN = 0,
4254 +} AVALANCHE_GPIO_PIN_MODE_T;
4256 +typedef enum AVALANCHE_GPIO_PIN_DIRECTION_tag
4258 + GPIO_OUTPUT_PIN = 0,
4259 + GPIO_INPUT_PIN = 1
4260 +} AVALANCHE_GPIO_PIN_DIRECTION_T;
4262 +typedef enum { GPIO_FALSE, GPIO_TRUE } AVALANCHE_GPIO_BOOL_T;
4264 +void avalanche_gpio_init(void);
4265 +int avalanche_gpio_ctrl(unsigned int gpio_pin,
4266 + AVALANCHE_GPIO_PIN_MODE_T pin_mode,
4267 + AVALANCHE_GPIO_PIN_DIRECTION_T pin_direction);
4268 +int avalanche_gpio_ctrl_with_link_count(unsigned int gpio_pin,
4269 + AVALANCHE_GPIO_PIN_MODE_T pin_mode,
4270 + AVALANCHE_GPIO_PIN_DIRECTION_T pin_direction);
4271 +int avalanche_gpio_out_bit(unsigned int gpio_pin, int value);
4272 +int avalanche_gpio_in_bit(unsigned int gpio_pin);
4273 +int avalanche_gpio_out_value(unsigned int out_val, unsigned int set_mask, unsigned int reg_index);
4274 +int avalanche_gpio_out_value_with_link_count(unsigned int out_val, unsigned int set_mask, unsigned int reg_index);
4275 +int avalanche_gpio_in_value(unsigned int *in_val, unsigned int reg_index);
4277 +unsigned int avalanche_get_chip_version_info(void);
4279 +unsigned int avalanche_get_vbus_freq(void);
4280 +void avalanche_set_vbus_freq(unsigned int);
4283 +typedef int (*SET_MDIX_ON_CHIP_FN_T)(unsigned int base_addr, unsigned int operation);
4284 +int avalanche_set_mdix_on_chip(unsigned int base_addr, unsigned int operation);
4285 +unsigned int avalanche_is_mdix_on_chip(void);
4288 diff -urN linux.old/include/asm-mips/ar7/avalanche_regs.h linux.dev/include/asm-mips/ar7/avalanche_regs.h
4289 --- linux.old/include/asm-mips/ar7/avalanche_regs.h 1970-01-01 01:00:00.000000000 +0100
4290 +++ linux.dev/include/asm-mips/ar7/avalanche_regs.h 2005-07-12 02:59:26.201667160 +0200
4294 + * Avalanche Register Descriptions
4296 + * Jeff Harrell, jharrell@ti.com
4297 + * 2000 (c) Texas Instruments Inc.
4300 +#ifndef __AVALANCHE_REGS_H
4301 +#define __AVALANCHE_REGS_H
4303 +#include <asm/addrspace.h>
4304 +#include <linux/config.h>
4306 +/*----------------------------------------*/
4307 +/* Base offsets within the Avalanche ASIC */
4308 +/*----------------------------------------*/
4310 +#define BBIF_SPACE0 (KSEG1ADDR(0x01000000))
4311 +#define BBIF_SPACE1 (KSEG1ADDR(0x01800000))
4312 +#define BBIF_CONTROL (KSEG1ADDR(0x02000000))
4313 +#define ATM_SAR_BASE (KSEG1ADDR(0x03000000))
4314 +#define USB_MCU_BASE (KSEG1ADDR(0x03400000))
4315 +#define DES_BASE (KSEG1ADDR(0x08600000))
4316 +#define ETH_MACA_BASE (KSEG1ADDR(0x08610000))
4317 +#define ETH_MACB_BASE (KSEG1ADDR(0x08612800))
4318 +#define MEM_CTRLR_BASE (KSEG1ADDR(0x08610800))
4319 +#define GPIO_BASE (KSEG1ADDR(0x08610900))
4320 +#define CLK_CTRL_BASE (KSEG1ADDR(0x08610A00))
4321 +#define WATCH_DOG_BASE (KSEG1ADDR(0x08610B00))
4322 +#define TMR1_BASE (KSEG1ADDR(0x08610C00))
4323 +#define TRM2_BASE (KSEG1ADDR(0x08610D00))
4324 +#define UARTA_BASE (KSEG1ADDR(0x08610E00))
4325 +#define UARTB_BASE (KSEG1ADDR(0x08610F00))
4326 +#define I2C_BASE (KSEG1ADDR(0x08611000))
4327 +#define DEV_ID_BASE (KSEG1ADDR(0x08611100))
4328 +#define USB_BASE (KSEG1ADDR(0x08611200))
4329 +#define PCI_CONFIG_BASE (KSEG1ADDR(0x08611300))
4330 +#define DMA_BASE (KSEG1ADDR(0x08611400))
4331 +#define RESET_CTRL_BASE (KSEG1ADDR(0x08611600))
4332 +#define DSL_IF_BASE (KSEG1ADDR(0x08611B00))
4333 +#define INT_CTL_BASE (KSEG1ADDR(0x08612400))
4334 +#define PHY_BASE (KSEG1ADDR(0x1E000000))
4336 +/*---------------------------------*/
4337 +/* Device ID, chip version number */
4338 +/*---------------------------------*/
4340 +#define AVALANCHE_CHVN (*(volatile unsigned int *)(DEV_ID_BASE+0x14))
4341 +#define AVALANCHE_DEVID1 (*(volatile unsigned int *)(DEV_ID_BASE+0x18))
4342 +#define AVALANCHE_DEVID2 (*(volatile unsigned int *)(DEV_ID_BASE+0x1C))
4344 +/*----------------------------------*/
4345 +/* Reset Control VW changed to ptrs */
4346 +/*----------------------------------*/
4348 +#define AVALANCHE_PRCR (*(volatile unsigned int *)(RESET_CTRL_BASE + 0x0)) /* Peripheral reset control */
4349 +#define AVALANCHE_SWRCR (*(volatile unsigned int *)(RESET_CTRL_BASE + 0x4)) /* Software reset control */
4350 +#define AVALANCHE_RSR (*(volatile unsigned int *)(RESET_CTRL_BASE + 0x8)) /* Reset status register */
4352 +/* reset control bits */
4354 +#define AV_RST_UART0 (1<<0) /* Brings UART0 out of reset */
4355 +#define AV_RST_UART1 (1<<1) /* Brings UART1 out of reset */
4356 +#define AV_RST_IICM (1<<2) /* Brings the I2CM out of reset */
4357 +#define AV_RST_TIMER0 (1<<3) /* Brings Timer 0 out of reset */
4358 +#define AV_RST_TIMER1 (1<<4) /* Brings Timer 1 out of reset */
4359 +#define AV_RST_DES (1<<5) /* Brings the DES module out of reset */
4360 +#define AV_RST_GPIO (1<<6) /* Brings the GPIO module out of reset (see note below) */
4362 + JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE
4363 + If you reset the GPIO interface all of the directions (i/o) of the UART B
4364 + interface pins are inputs and must be reconfigured so as not to lose the
4365 + serial console interface
4366 + JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE
4368 +#define AV_RST_BBIF (1<<7) /* Brings the Broadband interface out of reset */
4369 +#define AV_RST_USB (1<<8) /* Brings the USB module out of reset */
4370 +#define AV_RST_SAR (1<<9) /* Brings the SAR out of reset */
4371 +#define AV_RST_HDLC (1<<10) /* Brings the HDLC module out of reset */
4372 +#define AV_RST_PCI (1<<16) /* Brings the PCI module out of reset */
4373 +#define AV_RST_ETH_MAC0 (1<<17) /* Brings the Ethernet MAC0 out of reset */
4374 +#define AV_RST_PICO_DMA (1<<18) /* Brings the PICO DMA module out of reset */
4375 +#define AV_RST_BIST (1<<19) /* Brings the BIST module out of reset */
4376 +#define AV_RST_DSP (1<<20) /* Brings the DSP sub system out of reset */
4377 +#define AV_RST_ETH_MAC1 (1<<21) /* Brings the Ethernet MAC1 out of reset */
4379 +/*----------------------*/
4380 +/* Physical interfaces */
4381 +/*----------------------*/
4384 +#define PHY_LOOPBACK 1
4388 +#define PHY0BASE (PHY_BASE)
4389 +#define PHY0RST (*(volatile unsigned char *) (PHY0BASE)) /* reset */
4390 +#define PHY0CTRL (*(volatile unsigned char *) (PHY0BASE+0x5)) /* control */
4391 +#define PHY0RACPCTRL (*(volatile unsigned char *) (PHY0BASE+0x50)) /* RACP control/status */
4392 +#define PHY0TACPCTRL (*(volatile unsigned char *) (PHY0BASE+0x60)) /* TACP idle/unassigned cell hdr */
4393 +#define PHY0RACPINT (*(volatile unsigned char *) (PHY0BASE+0x51)) /* RACP interrupt enable/Status */
4398 +#define PHY1BASE (PHY_BASE + 0x100000)
4399 +#define PHY1RST (*(volatile unsigned char *) (PHY1BASE)) /* reset */
4400 +#define PHY1CTRL (*(volatile unsigned char *) (PHY1BASE+0x5)) /* control */
4401 +#define PHY1RACPCTRL (*(volatile unsigned char *) (PHY1BASE+0x50))
4402 +#define PHY1TACPCTRL (*(volatile unsigned char *) (PHY1BASE+0x60))
4403 +#define PHY1RACPINT (*(volatile unsigned char *) (PHY1BASE+0x51))
4407 +#define PHY2BASE (PHY_BASE + 0x200000)
4408 +#define PHY2RST (*(volatile unsigned char *) (PHY2BASE)) /* reset */
4409 +#define PHY2CTRL (*(volatile unsigned char *) (PHY2BASE+0x5)) /* control */
4410 +#define PHY2RACPCTRL (*(volatile unsigned char *) (PHY2BASE+0x50))
4411 +#define PHY2TACPCTRL (*(volatile unsigned char *) (PHY2BASE+0x60))
4412 +#define PHY2RACPINT (*(volatile unsigned char *) (PHY2BASE+0x51))
4414 +/*-------------------*/
4415 +/* Avalanche ATM SAR */
4416 +/*-------------------*/
4418 +#define AVSAR_SYSCONFIG (*(volatile unsigned int*)(ATM_SAR_BASE+0x00000000)) /* SAR system config register */
4419 +#define AVSAR_SYSSTATUS (*(volatile unsigned int*)(ATM_SAR_BASE+0x00000004)) /* SAR system status register */
4420 +#define AVSAR_INT_ENABLE (*(volatile unsigned int*)(ATM_SAR_BASE+0x00000008)) /* SAR interrupt enable register */
4421 +#define AVSAR_CONN_VPI_VCI (*(volatile unsigned int*)(ATM_SAR_BASE+0x0000000c)) /* VPI/VCI connection config */
4422 +#define AVSAR_CONN_CONFIG (*(volatile unsigned int*)(ATM_SAR_BASE+0x00000010)) /* Connection config register */
4423 +#define AVSAR_OAM_CONFIG (*(volatile unsigned int*)(ATM_SAR_BASE+0x00000018)) /* OAM configuration register */
4425 +/* Transmit completion ring registers */
4427 +#define AVSAR_TCRAPTR (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000100))
4428 +#define AVSAR_TCRASIZE (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000104))
4429 +#define AVSAR_TCRAINTTHRESH (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000108))
4430 +#define AVSAR_TCRATOTENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x0000010c))
4431 +#define AVSAR_TCRAFREEENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000110))
4432 +#define AVSAR_TCRAPENDENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000114))
4433 +#define AVSAR_TCRAENTINC (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000118))
4434 +#define AVSAR_TCRBPTR (*(volatile unsigned int *)(ATM_SAR_BASE+0x0000011c))
4435 +#define AVSAR_TCRBSIZE (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000120))
4436 +#define AVSAR_TCRBINTTHRESH (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000124))
4437 +#define AVSAR_TCRBTOTENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000128))
4438 +#define AVSAR_TCRBFREEENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x0000012c))
4439 +#define AVSAR_TCRBPENDENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000130))
4440 +#define AVSAR_TCRBENTINC (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000134))
4442 +/* Transmit Queue Packet registers */
4443 +#define AVSAR_TXQUEUE_PKT0 (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000140))
4444 +#define AVSAR_TXQUEUE_PKT1 (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000144))
4445 +#define AVSAR_TXQUEUE_PKT2 (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000148))
4446 +#define AVSAR_TX_FLUSH (*(volatile unsigned int *)(ATM_SAR_BASE+0x0000014C))
4447 +/* Receive completion ring registers */
4449 +#define AVSAR_RCRAPTR (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000200))
4450 +#define AVSAR_RCRASIZE (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000204))
4451 +#define AVSAR_RCRAINTTHRESH (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000208))
4452 +#define AVSAR_RCRATOTENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x0000020c))
4453 +#define AVSAR_RCRAFREEENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000210))
4454 +#define AVSAR_RCRAPENDENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000214))
4455 +#define AVSAR_RCRAENTINC (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000218))
4456 +#define AVSAR_RCRBPTR (*(volatile unsigned int *)(ATM_SAR_BASE+0x0000021c))
4457 +#define AVSAR_RCRBSIZE (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000220))
4458 +#define AVSAR_RCRBINTTHRESH (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000224))
4459 +#define AVSAR_RCRBTOTENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000228))
4460 +#define AVSAR_RCRBFREEENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x0000022c))
4461 +#define AVSAR_RCRBPENDENT (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000230))
4462 +#define AVSAR_RCRBENTINC (*(volatile unsigned int *)(ATM_SAR_BASE+0x00000234))
4464 +#define AVSAR_RXFBL_ADD0 (*(volatile unsigned int*)(ATM_SAR_BASE+0x00000240)) /* Rx Free buffer list add 0 */
4465 +#define AVSAR_RXFBL_ADD1 (*(volatile unsigned int*)(ATM_SAR_BASE+0x00000244)) /* Rx Free buffer list add 1 */
4466 +#define AVSAR_RXFBL_ADD2 (*(volatile unsigned int*)(ATM_SAR_BASE+0x00000248)) /* Rx Free buffer list add 2 */
4467 +#define AVSAR_RXFBLSIZE_0 (*(volatile unsigned int*)(ATM_SAR_BASE+0x0000028c)) /* Rx Free buffer list size 0 */
4468 +#define AVSAR_RXFBLSIZE_1 (*(volatile unsigned int*)(ATM_SAR_BASE+0x0000029c)) /* Rx Free buffer list size 1 */
4469 +#define AVSAR_RXFBLSIZE_2 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000002ac)) /* Rx Free buffer list size 2 */
4470 +#define AVSAR_RXFBLSIZE_3 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000002bc)) /* Rx Free buffer list size 3 */
4473 +#if defined(CONFIG_MIPS_EVM3D) || defined(CONFIG_MIPS_AR5D01) || defined(CONFIG_MIPS_AR5W01)
4475 +#define AVSAR_SAR_FREQUENCY (*(volatile unsigned int*)(ATM_SAR_BASE+0x00010480))
4476 +#define AVSAR_OAM_CC_SINK (*(volatile unsigned int*)(ATM_SAR_BASE+0x00010484))
4477 +#define AVSAR_OAM_AIS_RDI_RX (*(volatile unsigned int*)(ATM_SAR_BASE+0x00010488))
4478 +#define AVSAR_OAM_CPID0 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000104E0))
4479 +#define AVSAR_OAM_LLID0 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000104F0))
4480 +#define AVSAR_OAM_CPID1 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000104E4))
4481 +#define AVSAR_OAM_LLID1 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000104F4))
4482 +#define AVSAR_OAM_CPID2 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000104E8))
4483 +#define AVSAR_OAM_LLID2 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000104F8))
4484 +#define AVSAR_OAM_CPID3 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000104EC))
4485 +#define AVSAR_OAM_LLID3 (*(volatile unsigned int*)(ATM_SAR_BASE+0x000104FC))
4486 +#define AVSAR_OAM_CORR_TAG (*(volatile unsigned int*)(ATM_SAR_BASE+0x00010500))
4487 +#define AVSAR_OAM_FAR_COUNT (*(volatile unsigned int*)(ATM_SAR_BASE+0x00010520))
4488 +#define AVSAR_OAM_NEAR_COUNT (*(volatile unsigned int*)(ATM_SAR_BASE+0x00010540))
4489 +#define AVSAR_OAM_CONFIG_REG (*(volatile unsigned int*)(ATM_SAR_BASE+0x00000018))
4490 +#define AVSAR_FAIRNESS_REG (*(volatile unsigned int*)(ATM_SAR_BASE+0x000104B8))
4491 +#define AVSAR_UBR_PCR_REG (*(volatile unsigned int*)(ATM_SAR_BASE+0x00010490))
4496 +#define OAM_CPID_ADD 0xa30104e0
4498 +#define OAM_LLID_ADD 0xa30104f0
4500 +#define OAM_LLID_VAL 0xffffffff
4502 +#define OAM_CORR_TAG 0xa3010500
4504 +#define OAM_FAR_COUNT_ADD 0xa3010520
4506 +#define OAM_NEAR_COUNT_ADD 0xa3010540
4508 +#define OAM_CONFIG_REG_ADD 0xa3000018
4512 +#else /* CONFIG_MIPS_EVM3 || CONFIG_MIPS_ACPEP */
4514 +#define AVSAR_SAR_FREQUENCY (*(volatile unsigned int*)(ATM_SAR_BASE+0x00012000))
4515 +#define AVSAR_OAM_CC_SINK (*(volatile unsigned int*)(ATM_SAR_BASE+0x00012004))
4516 +#define AVSAR_OAM_AIS_RDI_RX (*(volatile unsigned int*)(ATM_SAR_BASE+0x00012008))
4517 +#define AVSAR_OAM_CPID (*(volatile unsigned int*)(ATM_SAR_BASE+0x00012300))
4519 +#endif /* CONFIG_MIPS_EVM3D || CONFIG_MIPS_AR5D01 || CONFIG_MIPS_AR5W01 */
4522 +#define AVSAR_STATE_RAM (ATM_SAR_BASE + 0x010000) /* SAR state RAM */
4523 +#define AVSAR_PDSP_BASE (ATM_SAR_BASE + 0x020000) /* SAR PDSP base address */
4524 +#define AVSAR_TXDMA_BASE (ATM_SAR_BASE + 0x030000) /* Transmit DMA state base */
4525 +#define AVSAR_TDMASTATE6 0x18 /* Transmit DMA state word 6 */
4526 +#define AVSAR_RXDMA_BASE (ATM_SAR_BASE + 0x040000) /* Receive DMA state base */
4527 +#define AVSAR_RDMASTATE0 0x0 /* Receive DMA state word 0 */
4529 +/*------------------------------------------*/
4530 +/* DSL Interface */
4531 +/*------------------------------------------*/
4533 +#define AVDSL_TX_EN (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000000))
4534 +#define AVDSL_RX_EN (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000004))
4535 +#define AVDSL_POLL (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000008))
4539 +#define AVDSL_TX_FIFO_ADDR0 (*(volatile unsigned int *)(DSL_IF_BASE + 0x0000000C))
4540 +#define AVDSL_TX_FIFO_BASE0 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000010))
4541 +#define AVDSL_TX_FIFO_LEN0 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000014))
4542 +#define AVDSL_TX_FIFO_PR0 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000018))
4543 +#define AVDSL_RX_FIFO_ADDR0 (*(volatile unsigned int *)(DSL_IF_BASE + 0x0000001C))
4544 +#define AVDSL_RX_FIFO_BASE0 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000020))
4545 +#define AVDSL_RX_FIFO_LEN0 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000024))
4546 +#define AVDSL_RX_FIFO_PR0 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000028))
4550 +#define AVDSL_TX_FIFO_ADDR1 (*(volatile unsigned int *)(DSL_IF_BASE + 0x0000002C))
4551 +#define AVDSL_TX_FIFO_BASE1 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000030))
4552 +#define AVDSL_TX_FIFO_LEN1 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000034))
4553 +#define AVDSL_TX_FIFO_PR1 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000038))
4554 +#define AVDSL_RX_FIFO_ADDR1 (*(volatile unsigned int *)(DSL_IF_BASE + 0x0000003C))
4555 +#define AVDSL_RX_FIFO_BASE1 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000040))
4556 +#define AVDSL_RX_FIFO_LEN1 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000044))
4557 +#define AVDSL_RX_FIFO_PR1 (*(volatile unsigned int *)(DSL_IF_BASE + 0x00000048))
4559 +/*------------------------------------------*/
4560 +/* Broadband I/F */
4561 +/*------------------------------------------*/
4563 +#define AVBBIF_BBIF_CNTRL (*(volatile unsigned int *)(BBIF_CONTROL + 0x00000000))
4564 +#define AVBBIF_ADDR_TRANS_0 (*(volatile unsigned int *)(BBIF_CONTROL + 0x00000004))
4565 +#define AVBBIF_ADDR_TRANS_1 (*(volatile unsigned int *)(BBIF_CONTROL + 0x00000008))
4566 +#define AVBBIF_ADDR_XB_MX_BL (*(volatile unsigned int *)(BBIF_CONTROL + 0x0000000C))
4567 +#define AVBBIF_INFIFO_LVL (*(volatile unsigned int *)(BBIF_CONTROL + 0x00000010))
4568 +#define AVBBIF_OUTFIFO_LVL (*(volatile unsigned int *)(BBIF_CONTROL + 0x00000014))
4570 +#define AVBBIF_DISABLED 0x0
4571 +#define AVBBIF_LBT4040_INT 0x1
4572 +#define AVBBIF_XBUS 0x2
4573 +#define AVBBIF_LBT4040_EXT 0x4
4575 +#define AVBBIF_ADDR_MASK0 0xff000000 /* handles upper bits of BBIF 0 address */
4576 +#define AVBBIF_ADDR_MASK1 0xff800000 /* handles upper bits of BBIF 1 address */
4577 +#define AVBBIF_TRANS_MASK 0xff000000
4578 +/*------------------------------------------*/
4580 +/*------------------------------------------*/
4582 +#define GPIO_DATA_INPUT (*(volatile unsigned int *)(GPIO_BASE + 0x00000000))
4583 +#define GPIO_DATA_OUTPUT (*(volatile unsigned int *)(GPIO_BASE + 0x00000004))
4584 +#define GPIO_DATA_DIR (*(volatile unsigned int *)(GPIO_BASE + 0x00000008)) /* 0=output 1=input */
4585 +#define GPIO_DATA_ENABLE (*(volatile unsigned int *)(GPIO_BASE + 0x0000000C)) /* 0=GPIO Mux 1=GPIO */
4587 +#define GPIO_0 (1<<21)
4588 +#define GPIO_1 (1<<22)
4589 +#define GPIO_2 (1<<23)
4590 +#define GPIO_3 (1<<24)
4591 +#define EINT_1 (1<<18)
4594 + JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE
4595 + If you reset the GPIO interface all of the directions (i/o) of the UART B
4596 + interface pins are inputs and must be reconfigured so as not to lose the
4597 + serial console interface
4598 + JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE JAH NOTE
4601 +/*------------------------------------------*/
4603 +/*------------------------------------------*/
4604 +#define PERIPH_CLK_CTL (*(volatile unsigned int *)(CLK_CTRL_BASE + 0x00000004))
4606 +#define PCLK_0_HALF_VBUS (0<<16)
4607 +#define PCLK_EQ_INPUT (1<<16)
4608 +#define BBIF_CLK_HALF_VBUS (0<<17)
4609 +#define BBIF_CLK_EQ_VBUS (1<<17)
4610 +#define BBIF_CLK_EQ_BBCLK (3<<17)
4611 +#define DSP_MODCLK_DSPCLKI (0<<20)
4612 +#define DSP_MODCLK_REFCLKI (1<<20)
4613 +#define USB_CLK_EQ_USBCLKI (0<<21)
4614 +#define USB_CLK_EQ_REFCLKI (1<<21)
4616 +/*------------------------------------------*/
4617 +/* PCI Control Registers */
4618 +/*------------------------------------------*/
4619 +#define PCIC_CONTROL (*(volatile unsigned int *)(PCI_CONFIG_BASE))
4620 +#define PCIC_CONTROL_CFG_DONE (1<<0)
4621 +#define PCIC_CONTROL_DIS_SLAVE_TO (1<<1)
4622 +#define PCIC_CONTROL_FORCE_DELAY_READ (1<<2)
4623 +#define PCIC_CONTROL_FORCE_DELAY_READ_LINE (1<<3)
4624 +#define PCIC_CONTROL_FORCE_DELAY_READ_MULT (1<<4)
4625 +#define PCIC_CONTROL_MEM_SPACE_EN (1<<5)
4626 +#define PCIC_CONTROL_MEM_MASK (1<<6)
4627 +#define PCIC_CONTROL_IO_SPACE_EN (1<<7)
4628 +#define PCIC_CONTROL_IO_MASK (1<<8)
4629 +/* PCIC_CONTROL_RESERVED (1<<9) */
4630 +#define PCIC_CONTROL_BASE0_EN (1<<10)
4631 +#define PCIC_CONTROL_BASE1_EN (1<<11)
4632 +#define PCIC_CONTROL_BASE2_EN (1<<12)
4633 +#define PCIC_CONTROL_HOLD_MASTER_WRITE (1<<13)
4634 +#define PCIC_CONTROL_ARBITER_EN (1<<14)
4635 +#define PCIC_INT_SOURCE (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000004))
4636 +#define PCIC_INT_SOURCE_PWR_MGMT (1<<0)
4637 +#define PCIC_INT_SOURCE_PCI_TARGET (1<<1)
4638 +#define PCIC_INT_SOURCE_PCI_MASTER (1<<2)
4639 +#define PCIC_INT_SOURCE_POWER_WAKEUP (1<<3)
4640 +#define PCIC_INT_SOURCE_PMEIN (1<<4)
4641 +/* PCIC_INT_SOURCE_RESERVED (1<<5) */
4642 +/* PCIC_INT_SOURCE_RESERVED (1<<6) */
4643 +#define PCIC_INT_SOURCE_PIC_INTA (1<<7)
4644 +#define PCIC_INT_SOURCE_PIC_INTB (1<<8)
4645 +#define PCIC_INT_SOURCE_PIC_INTC (1<<9)
4646 +#define PCIC_INT_SOURCE_PIC_INTD (1<<10)
4647 +#define PCIC_INT_SOURCE_SOFT_INT0 (1<<11)
4648 +#define PCIC_INT_SOURCE_SOFT_INT1 (1<<12)
4649 +#define PCIC_INT_SOURCE_SOFT_INT2 (1<<13)
4650 +#define PCIC_INT_SOURCE_SOFT_INT3 (1<<14)
4651 +#define PCIC_INT_CLEAR (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000008))
4652 +#define PCIC_INT_CLEAR_PM (1<<0)
4653 +#define PCIC_INT_CLEAR_PCI_TARGET (1<<1)
4654 +#define PCIC_INT_CLEAR_PCI_MASTER (1<<2)
4655 +/* PCIC_INT_CLEAR_RESERVED (1<<3) */
4656 +#define PCIC_INT_CLEAR_PMEIN (1<<4)
4657 +/* PCIC_INT_CLEAR_RESERVED (1<<5) */
4658 +/* PCIC_INT_CLEAR_RESERVED (1<<6) */
4659 +#define PCIC_INT_CLEAR_PCI_INTA (1<<7)
4660 +#define PCIC_INT_CLEAR_PCI_INTB (1<<8)
4661 +#define PCIC_INT_CLEAR_PCI_INTC (1<<9)
4662 +#define PCIC_INT_CLEAR_PCI_INTD (1<<10)
4663 +#define PCIC_INT_CLEAR_SOFT_INT0 (1<<11)
4664 +#define PCIC_INT_CLEAR_SOFT_INT1 (1<<12)
4665 +#define PCIC_INT_CLEAR_SOFT_INT2 (1<<13)
4666 +#define PCIC_INT_CLEAR_SOFT_INT3 (1<<14)
4667 +#define PCIC_INT_EN_AVAL (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x0000000c))
4668 +#define PCIC_INT_EN_AVAL_PM (1<<0)
4669 +#define PCIC_INT_EN_AVAL_PCI_TARGET (1<<1)
4670 +#define PCIC_INT_EN_AVAL_PCI_MASTER (1<<2)
4671 +/* PCIC_INT_EN_AVAL_RESERVED (1<<3) */
4672 +#define PCIC_INT_EN_AVAL_PMEIN (1<<4)
4673 +/* PCIC_INT_EN_AVAL_RESERVED (1<<5) */
4674 +/* PCIC_INT_EN_AVAL_RESERVED (1<<6) */
4675 +#define PCIC_INT_EN_AVAL_PCI_INTA (1<<7)
4676 +#define PCIC_INT_EN_AVAL_PCI_INTB (1<<8)
4677 +#define PCIC_INT_EN_AVAL_PCI_INTC (1<<9)
4678 +#define PCIC_INT_EN_AVAL_PCI_INTD (1<<10)
4679 +#define PCIC_INT_EN_AVAL_SOFT_INT0 (1<<11)
4680 +#define PCIC_INT_EN_AVAL_SOFT_INT1 (1<<12)
4681 +#define PCIC_INT_EN_AVAL_SOFT_INT2 (1<<13)
4682 +#define PCIC_INT_EN_AVAL_SOFT_INT3 (1<<14)
4683 +#define PCIC_INT_EN_PCI (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000010))
4684 +#define PCIC_INT_EN_PCI_PM (1<<0)
4685 +#define PCIC_INT_EN_PCI_PCI_TARGET (1<<1)
4686 +#define PCIC_INT_EN_PCI_PCI_MASTER (1<<2)
4687 +/* PCIC_INT_EN_PCI_RESERVED (1<<3) */
4688 +#define PCIC_INT_EN_PCI_PMEIN (1<<4)
4689 +/* PCIC_INT_EN_PCI_RESERVED (1<<5) */
4690 +/* PCIC_INT_EN_PCI_RESERVED (1<<6) */
4691 +#define PCIC_INT_EN_PCI_PCI_INTA (1<<7)
4692 +#define PCIC_INT_EN_PCI_PCI_INTB (1<<8)
4693 +#define PCIC_INT_EN_PCI_PCI_INTC (1<<9)
4694 +#define PCIC_INT_EN_PCI_PCI_INTD (1<<10)
4695 +#define PCIC_INT_EN_PCI_SOFT_INT0 (1<<11)
4696 +#define PCIC_INT_EN_PCI_SOFT_INT1 (1<<12)
4697 +#define PCIC_INT_EN_PCI_SOFT_INT2 (1<<13)
4698 +#define PCIC_INT_EN_PCI_SOFT_INT3 (1<<14)
4699 +#define PCIC_INT_SWSET (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000014))
4700 +#define PCIC_INT_SWSET_SOFT_INT0 (1<<0)
4701 +#define PCIC_INT_SWSET_SOFT_INT1 (1<<1)
4702 +#define PCIC_INT_SWSET_SOFT_INT2 (1<<2)
4703 +#define PCIC_INT_SWSET_SOFT_INT3 (1<<3)
4704 +#define PCIC_PM_CTL (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000018))
4705 +#define PCIC_PM_CTL_PWR_STATE_MASK (0x02)
4706 +/* PCIC_PM_CTL_RESERVED (1<<2) */
4707 +/* PCIC_PM_CTL_RESERVED (1<<3) */
4708 +/* PCIC_PM_CTL_RESERVED (1<<4) */
4709 +/* PCIC_PM_CTL_RESERVED (1<<5) */
4710 +/* PCIC_PM_CTL_RESERVED (1<<6) */
4711 +/* PCIC_PM_CTL_RESERVED (1<<7) */
4712 +/* PCIC_PM_CTL_RESERVED (1<<8) */
4713 +/* PCIC_PM_CTL_RESERVED (1<<9) */
4714 +#define PCIC_PM_CTL_PWR_SUPPORT (1<<10)
4715 +#define PCIC_PM_CTL_PMEIN (1<<11)
4716 +#define PCIC_PM_CTL_CAP_MASK (*(volatile unsigned short int *)(PCI_CONFIG_BASE + 0x0000001a))
4717 +#define PCIC_PM_CONSUME (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x0000001c))
4718 +#define PCIC_PM_CONSUME_D0 (*(volatile unsigned char *)(PCI_CONFIG_BASE + 0x0000001c))
4719 +#define PCIC_PM_CONSUME_D1 (*(volatile unsigned char *)(PCI_CONFIG_BASE + 0x0000001d))
4720 +#define PCIC_PM_CONSUME_D2 (*(volatile unsigned char *)(PCI_CONFIG_BASE + 0x0000001e))
4721 +#define PCIC_PM_CONSUME_D3 (*(volatile unsigned char *)(PCI_CONFIG_BASE + 0x0000001f))
4722 +#define PCIC_PM_DISSAPATED (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000020))
4723 +#define PCIC_PM_DISSAPATED_D0 (*(volatile unsigned char *)(PCI_CONFIG_BASE + 0x00000020))
4724 +#define PCIC_PM_DISSAPATED_D1 (*(volatile unsigned char *)(PCI_CONFIG_BASE + 0x00000021))
4725 +#define PCIC_PM_DISSAPATED_D2 (*(volatile unsigned char *)(PCI_CONFIG_BASE + 0x00000022))
4726 +#define PCIC_PM_DISSAPATED_D3 (*(volatile unsigned char *)(PCI_CONFIG_BASE + 0x00000023))
4727 +#define PCIC_PM_DATA_SCALE (*(volatile unsigned short int *)(PCI_CONFIG_BASE + 0x00000024))
4728 +#define PCIC_VEND_DEV_ID (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000028))
4729 +#define PCIC_SUB_VEND_DEV_ID (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x0000002c))
4730 +#define PCIC_CLASS_REV_ID (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000030))
4731 +#define PCIC_MAX_MIN (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000034))
4732 +#define PCIC_MAST_MEM_AT0 (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x0000003c))
4733 +#define PCIC_MAST_MEM_AT1 (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000040))
4734 +#define PCIC_MAST_MEM_AT2 (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000044))
4735 +#define PCIC_SLAVE_MASK0 (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x0000004c))
4736 +#define PCIC_SLAVE_MASK1 (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000050))
4737 +#define PCIC_SLAVE_MASK2 (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000054))
4738 +#define PCIC_SLAVE_BASE_AT0 (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000058))
4739 +#define PCIC_SLAVE_BASE_AT1 (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x0000005c))
4740 +#define PCIC_SLAVE_BASE_AT2 (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000060))
4741 +#define PCIC_CONF_COMMAND (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000090))
4742 +#define PCIC_CONF_ADDR (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000094))
4743 +#define PCIC_CONF_DATA (*(volatile unsigned int *)(PCI_CONFIG_BASE + 0x00000098))
4745 +/*------------------------------------------*/
4746 +/* IIC_INTERFACE */
4747 +/*------------------------------------------*/
4748 +#define I2C_DATA_HI (*(volatile unsigned int *)(I2C_BASE + 0x0))
4749 +#define I2C_DATA_LOW (*(volatile unsigned int *)(I2C_BASE + 0x4))
4750 +#define I2C_CONFIG (*(volatile unsigned int *)(I2C_BASE + 0x8))
4751 +#define I2C_DATA_READ (*(volatile unsigned int *)(I2C_BASE + 0xC))
4752 +#define I2C_CLOCK_DIV (*(volatile unsigned int *)(I2C_BASE + 0x10))
4754 +#define I2CWRITE 0x200
4755 +#define I2CREAD 0x300
4756 +#define I2C_END_BURST 0x400
4759 +#define I2C_READ_ERROR 0x8000
4760 +#define I2C_READ_COMPLETE 0x4000
4761 +#define I2C_READ_BUSY 0x2000
4764 +#define I2C_IO_EXPANDER 0x2
4765 +#define I2C_RTC 0xd
4767 +/* device Addresses on I2C bus (EVM3) */
4768 +#define SEVEN_SEGMENT_DISP 0x23 /* Device type = 0x2, Addr = 3 */
4769 +#define EVM3_RTC 0xd0 /* Device type = 0xd, Addr = 0 */
4770 +#define EVM3_RTC_I2C_ADDR 0x0
4772 +/*------------------------------------------*/
4773 +/* Ethernet MAC register offset definitions */
4774 +/*------------------------------------------*/
4775 +#define VMAC_DMACONFIG(X) (*(volatile unsigned int *)(X + 0x00000000))
4776 +#define VMAC_INTSTS(X) (*(volatile unsigned int *)(X + 0x00000004))
4777 +#define VMAC_INTMASK(X) (*(volatile unsigned int *)(X + 0x00000008))
4779 +#define VMAC_WRAPCLK(X) (*(volatile unsigned int *)(X + 0x00000340))
4780 +#define VMAC_STATSBASE(X) (*(volatile unsigned int *)(X + 0x00000400))
4782 +#define VMAC_TCRPTR(X) (*(volatile unsigned int *)(X + 0x00000100))
4783 +#define VMAC_TCRSIZE(X) (*(volatile unsigned int *)(X + 0x00000104))
4784 +#define VMAC_TCRINTTHRESH(X) (*(volatile unsigned int *)(X + 0x00000108))
4785 +#define VMAC_TCRTOTENT(X) (*(volatile unsigned int *)(X + 0x0000010C))
4786 +#define VMAC_TCRFREEENT(X) (*(volatile unsigned int *)(X + 0x00000110))
4787 +#define VMAC_TCRPENDENT(X) (*(volatile unsigned int *)(X + 0x00000114))
4788 +#define VMAC_TCRENTINC(X) (*(volatile unsigned int *)(X + 0x00000118))
4789 +#define VMAC_TXISRPACE(X) (*(volatile unsigned int *)(X + 0x0000011c))
4792 +#define VMAC_TDMASTATE0(X) (*(volatile unsigned int *)(X + 0x00000120))
4793 +#define VMAC_TDMASTATE1(X) (*(volatile unsigned int *)(X + 0x00000124))
4794 +#define VMAC_TDMASTATE2(X) (*(volatile unsigned int *)(X + 0x00000128))
4795 +#define VMAC_TDMASTATE3(X) (*(volatile unsigned int *)(X + 0x0000012C))
4796 +#define VMAC_TDMASTATE4(X) (*(volatile unsigned int *)(X + 0x00000130))
4797 +#define VMAC_TDMASTATE5(X) (*(volatile unsigned int *)(X + 0x00000134))
4798 +#define VMAC_TDMASTATE6(X) (*(volatile unsigned int *)(X + 0x00000138))
4799 +#define VMAC_TDMASTATE7(X) (*(volatile unsigned int *)(X + 0x0000013C))
4800 +#define VMAC_TXPADDCNT(X) (*(volatile unsigned int *)(X + 0x00000140))
4801 +#define VMAC_TXPADDSTART(X) (*(volatile unsigned int *)(X + 0x00000144))
4802 +#define VMAC_TXPADDEND(X) (*(volatile unsigned int *)(X + 0x00000148))
4803 +#define VMAC_TXQFLUSH(X) (*(volatile unsigned int *)(X + 0x0000014C))
4805 +#define VMAC_RCRPTR(X) (*(volatile unsigned int *)(X + 0x00000200))
4806 +#define VMAC_RCRSIZE(X) (*(volatile unsigned int *)(X + 0x00000204))
4807 +#define VMAC_RCRINTTHRESH(X) (*(volatile unsigned int *)(X + 0x00000208))
4808 +#define VMAC_RCRTOTENT(X) (*(volatile unsigned int *)(X + 0x0000020C))
4809 +#define VMAC_RCRFREEENT(X) (*(volatile unsigned int *)(X + 0x00000210))
4810 +#define VMAC_RCRPENDENT(X) (*(volatile unsigned int *)(X + 0x00000214))
4811 +#define VMAC_RCRENTINC(X) (*(volatile unsigned int *)(X + 0x00000218))
4812 +#define VMAC_RXISRPACE(X) (*(volatile unsigned int *)(X + 0x0000021c))
4814 +#define VMAC_RDMASTATE0(X) (*(volatile unsigned int *)(X + 0x00000220))
4815 +#define VMAC_RDMASTATE1(X) (*(volatile unsigned int *)(X + 0x00000224))
4816 +#define VMAC_RDMASTATE2(X) (*(volatile unsigned int *)(X + 0x00000228))
4817 +#define VMAC_RDMASTATE3(X) (*(volatile unsigned int *)(X + 0x0000022C))
4818 +#define VMAC_RDMASTATE4(X) (*(volatile unsigned int *)(X + 0x00000230))
4819 +#define VMAC_RDMASTATE5(X) (*(volatile unsigned int *)(X + 0x00000234))
4820 +#define VMAC_RDMASTATE6(X) (*(volatile unsigned int *)(X + 0x00000238))
4821 +#define VMAC_RDMASTATE7(X) (*(volatile unsigned int *)(X + 0x0000023C))
4822 +#define VMAC_FBLADDCNT(X) (*(volatile unsigned int *)(X + 0x00000240))
4823 +#define VMAC_FBLADDSTART(X) (*(volatile unsigned int *)(X + 0x00000244))
4824 +#define VMAC_FBLADDEND(X) (*(volatile unsigned int *)(X + 0x00000248))
4825 +#define VMAC_RXONOFF(X) (*(volatile unsigned int *)(X + 0x0000024C))
4827 +#define VMAC_FBL0NEXTD(X) (*(volatile unsigned int *)(X + 0x00000280))
4828 +#define VMAC_FBL0LASTD(X) (*(volatile unsigned int *)(X + 0x00000284))
4829 +#define VMAC_FBL0COUNTD(X) (*(volatile unsigned int *)(X + 0x00000288))
4830 +#define VMAC_FBL0BUFSIZE(X) (*(volatile unsigned int *)(X + 0x0000028C))
4832 +#define VMAC_MACCONTROL(X) (*(volatile unsigned int *)(X + 0x00000300))
4833 +#define VMAC_MACSTATUS(X) (*(volatile unsigned int *)(X + 0x00000304))
4834 +#define VMAC_MACADDRHI(X) (*(volatile unsigned int *)(X + 0x00000308))
4835 +#define VMAC_MACADDRLO(X) (*(volatile unsigned int *)(X + 0x0000030C))
4836 +#define VMAC_MACHASH1(X) (*(volatile unsigned int *)(X + 0x00000310))
4837 +#define VMAC_MACHASH2(X) (*(volatile unsigned int *)(X + 0x00000314))
4839 +#define VMAC_WRAPCLK(X) (*(volatile unsigned int *)(X + 0x00000340))
4840 +#define VMAC_BOFTEST(X) (*(volatile unsigned int *)(X + 0x00000344))
4841 +#define VMAC_PACTEST(X) (*(volatile unsigned int *)(X + 0x00000348))
4842 +#define VMAC_PAUSEOP(X) (*(volatile unsigned int *)(X + 0x0000034C))
4844 +#define VMAC_MDIOCONTROL(X) (*(volatile unsigned int *)(X + 0x00000380))
4845 +#define VMAC_MDIOUSERACCESS(X) (*(volatile unsigned int *)(X +0x00000384))
4846 +#define VMAC_MDIOACK(X) (*(volatile unsigned int *)(X + 0x00000388))
4847 +#define VMAC_MDIOLINK(X) (*(volatile unsigned int *)(X + 0x0000038C))
4848 +#define VMAC_MDIOMACPHY(X) (*(volatile unsigned int *)(X + 0x00000390))
4850 +#define VMAC_STATS_BASE(X) (X + 0x00000400)
4852 +#endif __AVALANCHE_REGS_H
4859 diff -urN linux.old/include/asm-mips/ar7/if_port.h linux.dev/include/asm-mips/ar7/if_port.h
4860 --- linux.old/include/asm-mips/ar7/if_port.h 1970-01-01 01:00:00.000000000 +0100
4861 +++ linux.dev/include/asm-mips/ar7/if_port.h 2005-07-12 02:59:26.201667160 +0200
4863 +/*******************************************************************************
4864 + * FILE PURPOSE: Interface port id Header file
4865 + *******************************************************************************
4866 + * FILE NAME: if_port.h
4868 + * DESCRIPTION: Header file carrying information about port ids of interfaces
4871 + * (C) Copyright 2003, Texas Instruments, Inc
4872 + ******************************************************************************/
4873 +#ifndef _IF_PORT_H_
4874 +#define _IF_PORT_H_
4876 +#define AVALANCHE_CPMAC_LOW_PORT_ID 0
4877 +#define AVALANCHE_CPMAC_HIGH_PORT_ID 1
4878 +#define AVALANCHE_USB_PORT_ID 2
4879 +#define AVALANCHE_WLAN_PORT_ID 3
4882 +#define AVALANCHE_MARVELL_BASE_PORT_ID 4
4884 +/* The marvell ports occupy port ids from 4 to 8 */
4885 +/* so the next port id number should start at 9 */
4888 +#endif /* _IF_PORT_H_ */
4889 diff -urN linux.old/include/asm-mips/ar7/sangam_boards.h linux.dev/include/asm-mips/ar7/sangam_boards.h
4890 --- linux.old/include/asm-mips/ar7/sangam_boards.h 1970-01-01 01:00:00.000000000 +0100
4891 +++ linux.dev/include/asm-mips/ar7/sangam_boards.h 2005-07-12 02:59:26.201667160 +0200
4893 +#ifndef _SANGAM_BOARDS_H
4894 +#define _SANGAM_BOARDS_H
4896 +// Let us define board specific information here.
4899 +#if defined(CONFIG_AR7DB)
4901 +#define AFECLK_FREQ 35328000
4902 +#define REFCLK_FREQ 25000000
4903 +#define OSC3_FREQ 24000000
4904 +#define AVALANCHE_LOW_CPMAC_PHY_MASK 0x80000000
4905 +#define AVALANCHE_HIGH_CPMAC_PHY_MASK 0x55555555
4906 +#define AVALANCHE_LOW_CPMAC_MDIX_MASK 0x80000000
4911 +#if defined(CONFIG_AR7RD)
4912 +#define AFECLK_FREQ 35328000
4913 +#define REFCLK_FREQ 25000000
4914 +#define OSC3_FREQ 24000000
4915 +#define AVALANCHE_LOW_CPMAC_PHY_MASK 0x80000000
4916 +#define AVALANCHE_HIGH_CPMAC_PHY_MASK 0x2
4917 +#define AVALANCHE_LOW_CPMAC_MDIX_MASK 0x80000000
4921 +#if defined(CONFIG_AR7WI)
4922 +#define AFECLK_FREQ 35328000
4923 +#define REFCLK_FREQ 25000000
4924 +#define OSC3_FREQ 24000000
4925 +#define AVALANCHE_LOW_CPMAC_PHY_MASK 0x80000000
4926 +#define AVALANCHE_HIGH_CPMAC_PHY_MASK 0x2
4927 +#define AVALANCHE_LOW_CPMAC_MDIX_MASK 0x80000000
4931 +#if defined(CONFIG_AR7V)
4932 +#define AFECLK_FREQ 35328000
4933 +#define REFCLK_FREQ 25000000
4934 +#define OSC3_FREQ 24000000
4935 +#define AVALANCHE_LOW_CPMAC_PHY_MASK 0x80000000
4936 +#define AVALANCHE_HIGH_CPMAC_PHY_MASK 0x2
4937 +#define AVALANCHE_LOW_CPMAC_MDIX_MASK 0x80000000
4941 +#if defined(CONFIG_AR7WRD)
4942 +#define AFECLK_FREQ 35328000
4943 +#define REFCLK_FREQ 25000000
4944 +#define OSC3_FREQ 24000000
4945 +#define AVALANCHE_LOW_CPMAC_PHY_MASK 0x80000000
4946 +#define AVALANCHE_HIGH_CPMAC_PHY_MASK 0x00010000
4947 +#define AVALANCHE_LOW_CPMAC_MDIX_MASK 0x80000000
4951 +#if defined(CONFIG_AR7VWI)
4952 +#define AFECLK_FREQ 35328000
4953 +#define REFCLK_FREQ 25000000
4954 +#define OSC3_FREQ 24000000
4955 +#define AVALANCHE_LOW_CPMAC_PHY_MASK 0x80000000
4956 +#define AVALANCHE_HIGH_CPMAC_PHY_MASK 0x00010000
4957 +#define AVALANCHE_LOW_CPMAC_MDIX_MASK 0x80000000
4961 +#if defined CONFIG_SEAD2
4962 +#define AVALANCHE_LOW_CPMAC_PHY_MASK 0xAAAAAAAA
4963 +#define AVALANCHE_HIGH_CPMAC_PHY_MASK 0x55555555
4964 +#define AVALANCHE_LOW_CPMAC_MDIX_MASK 0
4965 +#include <asm/mips-boards/sead.h>
4970 diff -urN linux.old/include/asm-mips/ar7/sangam.h linux.dev/include/asm-mips/ar7/sangam.h
4971 --- linux.old/include/asm-mips/ar7/sangam.h 1970-01-01 01:00:00.000000000 +0100
4972 +++ linux.dev/include/asm-mips/ar7/sangam.h 2005-07-12 02:59:26.201667160 +0200
4977 +#include <linux/config.h>
4978 +#include <asm/addrspace.h>
4980 +/*----------------------------------------------------
4981 + * Sangam's Module Base Addresses
4982 + *--------------------------------------------------*/
4983 +#define AVALANCHE_ADSL_SUB_SYS_MEM_BASE (KSEG1ADDR(0x01000000)) /* AVALANCHE ADSL Mem Base */
4984 +#define AVALANCHE_BROADBAND_INTERFACE__BASE (KSEG1ADDR(0x02000000)) /* AVALANCHE BBIF */
4985 +#define AVALANCHE_ATM_SAR_BASE (KSEG1ADDR(0x03000000)) /* AVALANCHE ATM SAR */
4986 +#define AVALANCHE_USB_SLAVE_BASE (KSEG1ADDR(0x03400000)) /* AVALANCHE USB SLAVE */
4987 +#define AVALANCHE_LOW_VLYNQ_MEM_MAP_BASE (KSEG1ADDR(0x04000000)) /* AVALANCHE VLYNQ 0 Mem map */
4988 +#define AVALANCHE_LOW_CPMAC_BASE (KSEG1ADDR(0x08610000)) /* AVALANCHE CPMAC 0 */
4989 +#define AVALANCHE_EMIF_CONTROL_BASE (KSEG1ADDR(0x08610800)) /* AVALANCHE EMIF */
4990 +#define AVALANCHE_GPIO_BASE (KSEG1ADDR(0x08610900)) /* AVALANCHE GPIO */
4991 +#define AVALANCHE_CLOCK_CONTROL_BASE (KSEG1ADDR(0x08610A00)) /* AVALANCHE Clock Control */
4992 +#define AVALANCHE_WATCHDOG_TIMER_BASE (KSEG1ADDR(0x08610B00)) /* AVALANCHE Watch Dog Timer */
4993 +#define AVALANCHE_TIMER0_BASE (KSEG1ADDR(0x08610C00)) /* AVALANCHE Timer 1 */
4994 +#define AVALANCHE_TIMER1_BASE (KSEG1ADDR(0x08610D00)) /* AVALANCHE Timer 2 */
4995 +#define AVALANCHE_UART0_REGS_BASE (KSEG1ADDR(0x08610E00)) /* AVALANCHE UART 0 */
4996 +#define AVALANCHE_UART1_REGS_BASE (KSEG1ADDR(0x08610F00)) /* AVALANCHE UART 0 */
4997 +#define AVALANCHE_I2C_BASE (KSEG1ADDR(0x08611000)) /* AVALANCHE I2C */
4998 +#define AVALANCHE_USB_SLAVE_CONTROL_BASE (KSEG1ADDR(0x08611200)) /* AVALANCHE USB DMA */
4999 +#define AVALANCHE_MCDMA0_CTRL_BASE (KSEG1ADDR(0x08611400)) /* AVALANCHE MC DMA 0 (channels 0-3) */
5000 +#define AVALANCHE_RESET_CONTROL_BASE (KSEG1ADDR(0x08611600)) /* AVALANCHE Reset Control */
5001 +#define AVALANCHE_BIST_CONTROL_BASE (KSEG1ADDR(0x08611700)) /* AVALANCHE BIST Control */
5002 +#define AVALANCHE_LOW_VLYNQ_CONTROL_BASE (KSEG1ADDR(0x08611800)) /* AVALANCHE VLYNQ0 Control */
5003 +#define AVALANCHE_DEVICE_CONFIG_LATCH_BASE (KSEG1ADDR(0x08611A00)) /* AVALANCHE Device Config Latch */
5004 +#define AVALANCHE_HIGH_VLYNQ_CONTROL_BASE (KSEG1ADDR(0x08611C00)) /* AVALANCHE VLYNQ1 Control */
5005 +#define AVALANCHE_MDIO_BASE (KSEG1ADDR(0x08611E00)) /* AVALANCHE MDIO */
5006 +#define AVALANCHE_FSER_BASE (KSEG1ADDR(0x08612000)) /* AVALANCHE FSER base */
5007 +#define AVALANCHE_INTC_BASE (KSEG1ADDR(0x08612400)) /* AVALANCHE INTC */
5008 +#define AVALANCHE_HIGH_CPMAC_BASE (KSEG1ADDR(0x08612800)) /* AVALANCHE CPMAC 1 */
5009 +#define AVALANCHE_HIGH_VLYNQ_MEM_MAP_BASE (KSEG1ADDR(0x0C000000)) /* AVALANCHE VLYNQ 1 Mem map */
5011 +#define AVALANCHE_SDRAM_BASE 0x14000000UL
5014 +/*----------------------------------------------------
5015 + * Sangam Interrupt Map (Primary Interrupts)
5016 + *--------------------------------------------------*/
5018 +#define AVALANCHE_UNIFIED_SECONDARY_INT 0
5019 +#define AVALANCHE_EXT_INT_0 1
5020 +#define AVALANCHE_EXT_INT_1 2
5021 +/* Line# 3 to 4 are reserved */
5022 +#define AVALANCHE_TIMER_0_INT 5
5023 +#define AVALANCHE_TIMER_1_INT 6
5024 +#define AVALANCHE_UART0_INT 7
5025 +#define AVALANCHE_UART1_INT 8
5026 +#define AVALANCHE_DMA_INT0 9
5027 +#define AVALANCHE_DMA_INT1 10
5028 +/* Line# 11 to 14 are reserved */
5029 +#define AVALANCHE_ATM_SAR_INT 15
5030 +/* Line# 16 to 18 are reserved */
5031 +#define AVALANCHE_LOW_CPMAC_INT 19
5032 +/* Line# 20 is reserved */
5033 +#define AVALANCHE_LOW_VLYNQ_INT 21
5034 +#define AVALANCHE_CODEC_WAKEUP_INT 22
5035 +/* Line# 23 is reserved */
5036 +#define AVALANCHE_USB_SLAVE_INT 24
5037 +#define AVALANCHE_HIGH_VLYNQ_INT 25
5038 +/* Line# 26 to 27 are reserved */
5039 +#define AVALANCHE_UNIFIED_PHY_INT 28
5040 +#define AVALANCHE_I2C_INT 29
5041 +#define AVALANCHE_DMA_INT2 30
5042 +#define AVALANCHE_DMA_INT3 31
5043 +/* Line# 32 is reserved */
5044 +#define AVALANCHE_HIGH_CPMAC_INT 33
5045 +/* Line# 34 to 36 is reserved */
5046 +#define AVALANCHE_VDMA_VT_RX_INT 37
5047 +#define AVALANCHE_VDMA_VT_TX_INT 38
5048 +#define AVALANCHE_ADSL_SUB_SYSTEM_INT 39
5051 +#define AVALANCHE_EMIF_INT 47
5055 +/*-----------------------------------------------------------
5056 + * Sangam's Reset Bits
5057 + *---------------------------------------------------------*/
5059 +#define AVALANCHE_UART0_RESET_BIT 0
5060 +#define AVALANCHE_UART1_RESET_BIT 1
5061 +#define AVALANCHE_I2C_RESET_BIT 2
5062 +#define AVALANCHE_TIMER0_RESET_BIT 3
5063 +#define AVALANCHE_TIMER1_RESET_BIT 4
5064 +/* Reset bit 5 is reserved. */
5065 +#define AVALANCHE_GPIO_RESET_BIT 6
5066 +#define AVALANCHE_ADSL_SUB_SYS_RESET_BIT 7
5067 +#define AVALANCHE_USB_SLAVE_RESET_BIT 8
5068 +#define AVALANCHE_ATM_SAR_RESET_BIT 9
5069 +/* Reset bit 10 is reserved. */
5070 +#define AVALANCHE_VDMA_VT_RESET_BIT 11
5071 +#define AVALANCHE_FSER_RESET_BIT 12
5072 +/* Reset bit 13 to 15 are reserved */
5073 +#define AVALANCHE_HIGH_VLYNQ_RESET_BIT 16
5074 +#define AVALANCHE_LOW_CPMAC_RESET_BIT 17
5075 +#define AVALANCHE_MCDMA_RESET_BIT 18
5076 +#define AVALANCHE_BIST_RESET_BIT 19
5077 +#define AVALANCHE_LOW_VLYNQ_RESET_BIT 20
5078 +#define AVALANCHE_HIGH_CPMAC_RESET_BIT 21
5079 +#define AVALANCHE_MDIO_RESET_BIT 22
5080 +#define AVALANCHE_ADSL_SUB_SYS_DSP_RESET_BIT 23
5081 +/* Reset bit 24 to 25 are reserved */
5082 +#define AVALANCHE_LOW_EPHY_RESET_BIT 26
5083 +/* Reset bit 27 to 31 are reserved */
5086 +#define AVALANCHE_POWER_MODULE_USBSP 0
5087 +#define AVALANCHE_POWER_MODULE_WDTP 1
5088 +#define AVALANCHE_POWER_MODULE_UT0P 2
5089 +#define AVALANCHE_POWER_MODULE_UT1P 3
5090 +#define AVALANCHE_POWER_MODULE_IICP 4
5091 +#define AVALANCHE_POWER_MODULE_VDMAP 5
5092 +#define AVALANCHE_POWER_MODULE_GPIOP 6
5093 +#define AVALANCHE_POWER_MODULE_VLYNQ1P 7
5094 +#define AVALANCHE_POWER_MODULE_SARP 8
5095 +#define AVALANCHE_POWER_MODULE_ADSLP 9
5096 +#define AVALANCHE_POWER_MODULE_EMIFP 10
5097 +#define AVALANCHE_POWER_MODULE_ADSPP 12
5098 +#define AVALANCHE_POWER_MODULE_RAMP 13
5099 +#define AVALANCHE_POWER_MODULE_ROMP 14
5100 +#define AVALANCHE_POWER_MODULE_DMAP 15
5101 +#define AVALANCHE_POWER_MODULE_BISTP 16
5102 +#define AVALANCHE_POWER_MODULE_TIMER0P 18
5103 +#define AVALANCHE_POWER_MODULE_TIMER1P 19
5104 +#define AVALANCHE_POWER_MODULE_EMAC0P 20
5105 +#define AVALANCHE_POWER_MODULE_EMAC1P 22
5106 +#define AVALANCHE_POWER_MODULE_EPHYP 24
5107 +#define AVALANCHE_POWER_MODULE_VLYNQ0P 27
5114 + * Sangam board vectors
5117 +#define AVALANCHE_VECS (KSEG1ADDR(AVALANCHE_SDRAM_BASE))
5118 +#define AVALANCHE_VECS_KSEG0 (KSEG0ADDR(AVALANCHE_SDRAM_BASE))
5120 +/*-----------------------------------------------------------------------------
5121 + * Sangam's system register.
5123 + *---------------------------------------------------------------------------*/
5124 +#define AVALANCHE_DCL_BOOTCR (KSEG1ADDR(0x08611A00))
5125 +#define AVALANCHE_EMIF_SDRAM_CFG (AVALANCHE_EMIF_CONTROL_BASE + 0x8)
5126 +#define AVALANCHE_RST_CTRL_PRCR (KSEG1ADDR(0x08611600))
5127 +#define AVALANCHE_RST_CTRL_SWRCR (KSEG1ADDR(0x08611604))
5128 +#define AVALANCHE_RST_CTRL_RSR (KSEG1ADDR(0x08611600))
5130 +#define AVALANCHE_POWER_CTRL_PDCR (KSEG1ADDR(0x08610A00))
5131 +#define AVALANCHE_WAKEUP_CTRL_WKCR (KSEG1ADDR(0x08610A0C))
5133 +#define AVALANCHE_GPIO_DATA_IN (AVALANCHE_GPIO_BASE + 0x0)
5134 +#define AVALANCHE_GPIO_DATA_OUT (AVALANCHE_GPIO_BASE + 0x4)
5135 +#define AVALANCHE_GPIO_DIR (AVALANCHE_GPIO_BASE + 0x8)
5136 +#define AVALANCHE_GPIO_ENBL (AVALANCHE_GPIO_BASE + 0xC)
5137 +#define AVALANCHE_CVR (AVALANCHE_GPIO_BASE + 0x14)
5140 + * Yamon Prom print address.
5142 +#define AVALANCHE_YAMON_FUNCTION_BASE (KSEG1ADDR(0x10000500))
5143 +#define AVALANCHE_YAMON_PROM_PRINT_COUNT_ADDR (AVALANCHE_YAMON_FUNCTION_BASE + 0x4) /* print_count function */
5144 +#define AVALANCHE_YAMON_PROM_PRINT_ADDR (AVALANCHE_YAMON_FUNCTION_BASE + 0x34)
5146 +#define AVALANCHE_BASE_BAUD ( 3686400 / 16 )
5148 +#define AVALANCHE_GPIO_PIN_COUNT 32
5149 +#define AVALANCHE_GPIO_OFF_MAP {0xF34FFFC0}
5151 +#include "sangam_boards.h"
5153 +#endif /*_SANGAM_H_ */
5154 diff -urN linux.old/include/asm-mips/ar7/tnetd73xx_err.h linux.dev/include/asm-mips/ar7/tnetd73xx_err.h
5155 --- linux.old/include/asm-mips/ar7/tnetd73xx_err.h 1970-01-01 01:00:00.000000000 +0100
5156 +++ linux.dev/include/asm-mips/ar7/tnetd73xx_err.h 2005-07-12 03:01:26.109438408 +0200
5158 +/******************************************************************************
5159 + * FILE PURPOSE: TNETD73xx Error Definations Header File
5160 + ******************************************************************************
5161 + * FILE NAME: tnetd73xx_err.h
5163 + * DESCRIPTION: Error definations for TNETD73XX
5165 + * REVISION HISTORY:
5166 + * 27 Nov 02 - PSP TII
5168 + * (C) Copyright 2002, Texas Instruments, Inc
5169 + *******************************************************************************/
5172 +#ifndef __TNETD73XX_ERR_H__
5173 +#define __TNETD73XX_ERR_H__
5175 +typedef enum TNETD73XX_ERR_t
5177 + TNETD73XX_ERR_OK = 0, /* OK or SUCCESS */
5178 + TNETD73XX_ERR_ERROR = -1, /* Unspecified/Generic ERROR */
5180 + /* Pointers and args */
5181 + TNETD73XX_ERR_INVARG = -2, /* Invaild argument to the call */
5182 + TNETD73XX_ERR_NULLPTR = -3, /* NULL pointer */
5183 + TNETD73XX_ERR_BADPTR = -4, /* Bad (out of mem) pointer */
5185 + /* Memory issues */
5186 + TNETD73XX_ERR_ALLOC_FAIL = -10, /* allocation failed */
5187 + TNETD73XX_ERR_FREE_FAIL = -11, /* free failed */
5188 + TNETD73XX_ERR_MEM_CORRUPT = -12, /* corrupted memory */
5189 + TNETD73XX_ERR_BUF_LINK = -13, /* buffer linking failed */
5191 + /* Device issues */
5192 + TNETD73XX_ERR_DEVICE_TIMEOUT = -20, /* device timeout on read/write */
5193 + TNETD73XX_ERR_DEVICE_MALFUNC = -21, /* device malfunction */
5195 + TNETD73XX_ERR_INVID = -30 /* Invalid ID */
5199 +#endif /* __TNETD73XX_ERR_H__ */
5200 diff -urN linux.old/include/asm-mips/ar7/tnetd73xx.h linux.dev/include/asm-mips/ar7/tnetd73xx.h
5201 --- linux.old/include/asm-mips/ar7/tnetd73xx.h 1970-01-01 01:00:00.000000000 +0100
5202 +++ linux.dev/include/asm-mips/ar7/tnetd73xx.h 2005-07-12 03:01:26.110438256 +0200
5204 +/******************************************************************************
5205 + * FILE PURPOSE: TNETD73xx Common Header File
5206 + ******************************************************************************
5207 + * FILE NAME: tnetd73xx.h
5209 + * DESCRIPTION: shared typedef's, constants and API for TNETD73xx
5211 + * REVISION HISTORY:
5212 + * 27 Nov 02 - PSP TII
5214 + * (C) Copyright 2002, Texas Instruments, Inc
5215 + *******************************************************************************/
5220 + * These are const, typedef, and api definitions for tnetd73xx.
5223 + * 1. This file may be included into both C and Assembly files.
5224 + * - for .s files, please do #define _ASMLANGUAGE in your ASM file to
5225 + * avoid C data types (typedefs) below;
5226 + * - for .c files, you don't have to do anything special.
5228 + * 2. This file has a number of sections for each SOC subsystem. When adding
5229 + * a new constant, find the subsystem you are working on and follow the
5230 + * name pattern. If you are adding another typedef for your interface, please,
5231 + * place it with other typedefs and function prototypes.
5233 + * 3. Please, DO NOT add any macros or types that are local to a subsystem to avoid
5234 + * cluttering. Include such items directly into the module's .c file or have a
5235 + * local .h file to pass data between smaller modules. This file defines only
5239 +#ifndef __TNETD73XX_H__
5240 +#define __TNETD73XX_H__
5242 +#ifndef _ASMLANGUAGE /* This part not for assembly language */
5244 +extern unsigned int tnetd73xx_mips_freq;
5245 +extern unsigned int tnetd73xx_vbus_freq;
5247 +#include "tnetd73xx_err.h"
5249 +#endif /* _ASMLANGUAGE */
5252 +/*******************************************************************************************
5253 +* Emerald core specific
5254 +******************************************************************************************** */
5257 +#elif defined(LITTLE_ENDIAN)
5259 +#error Need to define endianism
5263 +#define KSEG_MSK 0xE0000000 /* Most significant 3 bits denote kseg choice */
5266 +#ifndef KSEG_INV_MASK
5267 +#define KSEG_INV_MASK 0x1FFFFFFF /* Inverted mask for kseg address */
5271 +#define KSEG0_BASE 0x80000000
5275 +#define KSEG1_BASE 0xA0000000
5279 +#define KSEG0(addr) (((__u32)(addr) & ~KSEG_MSK) | KSEG0_BASE)
5283 +#define KSEG1(addr) (((__u32)(addr) & ~KSEG_MSK) | KSEG1_BASE)
5287 +#define KUSEG(addr) ((__u32)(addr) & ~KSEG_MSK)
5291 +#define PHYS_ADDR(addr) ((addr) & KSEG_INV_MASK)
5295 +#define PHYS_TO_K0(addr) (PHYS_ADDR(addr)|KSEG0_BASE)
5299 +#define PHYS_TO_K1(addr) (PHYS_ADDR(addr)|KSEG1_BASE)
5303 +#define REG8_ADDR(addr) (volatile __u8 *)(PHYS_TO_K1(addr))
5304 +#define REG8_DATA(addr) (*(volatile __u8 *)(PHYS_TO_K1(addr)))
5305 +#define REG8_WRITE(addr, data) REG8_DATA(addr) = data;
5306 +#define REG8_READ(addr, data) data = (__u8) REG8_DATA(addr);
5310 +#define REG16_ADDR(addr) (volatile __u16 *)(PHYS_TO_K1(addr))
5311 +#define REG16_DATA(addr) (*(volatile __u16 *)(PHYS_TO_K1(addr)))
5312 +#define REG16_WRITE(addr, data) REG16_DATA(addr) = data;
5313 +#define REG16_READ(addr, data) data = (__u16) REG16_DATA(addr);
5317 +#define REG32_ADDR(addr) (volatile __u32 *)(PHYS_TO_K1(addr))
5318 +#define REG32_DATA(addr) (*(volatile __u32 *)(PHYS_TO_K1(addr)))
5319 +#define REG32_WRITE(addr, data) REG32_DATA(addr) = data;
5320 +#define REG32_READ(addr, data) data = (__u32) REG32_DATA(addr);
5323 +#ifdef _LINK_KSEG0_ /* Application is linked into KSEG0 space */
5324 +#define VIRT_ADDR(addr) PHYS_TO_K0(PHYS_ADDR(addr))
5327 +#ifdef _LINK_KSEG1_ /* Application is linked into KSEG1 space */
5328 +#define VIRT_ADDR(addr) PHYS_TO_K1(PHYS_ADDR(addr))
5331 +#if !defined(_LINK_KSEG0_) && !defined(_LINK_KSEG1_)
5332 +#error You must define _LINK_KSEG0_ or _LINK_KSEG1_ to compile the code.
5335 +/* TNETD73XX chip definations */
5337 +#define FREQ_1MHZ 1000000
5338 +#define TNETD73XX_MIPS_FREQ tnetd73xx_mips_freq /* CPU clock frequency */
5339 +#define TNETD73XX_VBUS_FREQ tnetd73xx_vbus_freq /* originally (TNETD73XX_MIPS_FREQ/2) */
5342 +#define TNETD73XX_MIPS_FREQ_DEFAULT 25000000 /* 25 Mhz for sead2 board crystal */
5344 +#define TNETD73XX_MIPS_FREQ_DEFAULT 125000000 /* 125 Mhz */
5346 +#define TNETD73XX_VBUS_FREQ_DEFAULT (TNETD73XX_MIPS_FREQ_DEFAULT / 2) /* Sync mode */
5350 +/* Module base addresses */
5351 +#define TNETD73XX_ADSLSS_BASE PHYS_TO_K1(0x01000000) /* ADSLSS Module */
5352 +#define TNETD73XX_BBIF_CTRL_BASE PHYS_TO_K1(0x02000000) /* BBIF Control */
5353 +#define TNETD73XX_ATMSAR_BASE PHYS_TO_K1(0x03000000) /* ATM SAR */
5354 +#define TNETD73XX_USB_BASE PHYS_TO_K1(0x03400000) /* USB Module */
5355 +#define TNETD73XX_VLYNQ0_BASE PHYS_TO_K1(0x04000000) /* VLYNQ0 Module */
5356 +#define TNETD73xx_EMAC0_BASE PHYS_TO_K1(0x08610000) /* EMAC0 Module*/
5357 +#define TNETD73XX_EMIF_BASE PHYS_TO_K1(0x08610800) /* EMIF Module */
5358 +#define TNETD73XX_GPIO_BASE PHYS_TO_K1(0x08610900) /* GPIO control */
5359 +#define TNETD73XX_CLOCK_CTRL_BASE PHYS_TO_K1(0x08610A00) /* Clock Control */
5360 +#define TNETD73XX_WDTIMER_BASE PHYS_TO_K1(0x08610B00) /* WDTIMER Module */
5361 +#define TNETD73XX_TIMER0_BASE PHYS_TO_K1(0x08610C00) /* TIMER0 Module */
5362 +#define TNETD73XX_TIMER1_BASE PHYS_TO_K1(0x08610D00) /* TIMER1 Module */
5363 +#define TNETD73XX_UARTA_BASE PHYS_TO_K1(0x08610E00) /* UART A */
5364 +#define TNETD73XX_UARTB_BASE PHYS_TO_K1(0x08610F00) /* UART B */
5365 +#define TNETD73XX_I2C_BASE PHYS_TO_K1(0x08611000) /* I2C Module */
5366 +#define TNETD73XX_USB_DMA_BASE PHYS_TO_K1(0x08611200) /* USB Module */
5367 +#define TNETD73XX_MCDMA_BASE PHYS_TO_K1(0x08611400) /* MC-DMA */
5368 +#define TNETD73xx_VDMAVT_BASE PHYS_TO_K1(0x08611500) /* VDMAVT Control */
5369 +#define TNETD73XX_RST_CTRL_BASE PHYS_TO_K1(0x08611600) /* Reset Control */
5370 +#define TNETD73xx_BIST_CTRL_BASE PHYS_TO_K1(0x08611700) /* BIST Control */
5371 +#define TNETD73xx_VLYNQ0_CTRL_BASE PHYS_TO_K1(0x08611800) /* VLYNQ0 Control */
5372 +#define TNETD73XX_DCL_BASE PHYS_TO_K1(0x08611A00) /* Device Configuration Latch */
5373 +#define TNETD73xx_VLYNQ1_CTRL_BASE PHYS_TO_K1(0x08611C00) /* VLYNQ1 Control */
5374 +#define TNETD73xx_MDIO_BASE PHYS_TO_K1(0x08611E00) /* MDIO Control */
5375 +#define TNETD73XX_FSER_BASE PHYS_TO_K1(0x08612000) /* FSER Control */
5376 +#define TNETD73XX_INTC_BASE PHYS_TO_K1(0x08612400) /* Interrupt Controller */
5377 +#define TNETD73xx_EMAC1_BASE PHYS_TO_K1(0x08612800) /* EMAC1 Module*/
5378 +#define TNETD73XX_VLYNQ1_BASE PHYS_TO_K1(0x0C000000) /* VLYNQ1 Module */
5380 +/* BBIF Registers */
5381 +#define TNETD73XX_BBIF_ADSLADR (TNETD73XX_BBIF_CTRL_BASE + 0x0)
5383 +/* Device Configuration Latch Registers */
5384 +#define TNETD73XX_DCL_BOOTCR (TNETD73XX_DCL_BASE + 0x0)
5385 +#define TNETD73XX_DCL_DPLLSELR (TNETD73XX_DCL_BASE + 0x10)
5386 +#define TNETD73XX_DCL_SPEEDCTLR (TNETD73XX_DCL_BASE + 0x14)
5387 +#define TNETD73XX_DCL_SPEEDPWDR (TNETD73XX_DCL_BASE + 0x18)
5388 +#define TNETD73XX_DCL_SPEEDCAPR (TNETD73XX_DCL_BASE + 0x1C)
5391 +#define TNETD73XX_GPIODINR (TNETD73XX_GPIO_BASE + 0x0)
5392 +#define TNETD73XX_GPIODOUTR (TNETD73XX_GPIO_BASE + 0x4)
5393 +#define TNETD73XX_GPIOPDIRR (TNETD73XX_GPIO_BASE + 0x8)
5394 +#define TNETD73XX_GPIOENR (TNETD73XX_GPIO_BASE + 0xC)
5395 +#define TNETD73XX_CVR (TNETD73XX_GPIO_BASE + 0x14)
5396 +#define TNETD73XX_DIDR1 (TNETD73XX_GPIO_BASE + 0x18)
5397 +#define TNETD73XX_DIDR2 (TNETD73XX_GPIO_BASE + 0x1C)
5399 +/* Reset Control */
5400 +#define TNETD73XX_RST_CTRL_PRCR (TNETD73XX_RST_CTRL_BASE + 0x0)
5401 +#define TNETD73XX_RST_CTRL_SWRCR (TNETD73XX_RST_CTRL_BASE + 0x4)
5402 +#define TNETD73XX_RST_CTRL_RSR (TNETD73XX_RST_CTRL_BASE + 0x8)
5404 +/* Power Control */
5405 +#define TNETD73XX_POWER_CTRL_PDCR (TNETD73XX_CLOCK_CTRL_BASE + 0x0)
5406 +#define TNETD73XX_POWER_CTRL_PCLKCR (TNETD73XX_CLOCK_CTRL_BASE + 0x4)
5407 +#define TNETD73XX_POWER_CTRL_PDUCR (TNETD73XX_CLOCK_CTRL_BASE + 0x8)
5408 +#define TNETD73XX_POWER_CTRL_WKCR (TNETD73XX_CLOCK_CTRL_BASE + 0xC)
5410 +/* Clock Control */
5411 +#define TNETD73XX_CLK_CTRL_SCLKCR (TNETD73XX_CLOCK_CTRL_BASE + 0x20)
5412 +#define TNETD73XX_CLK_CTRL_SCLKPLLCR (TNETD73XX_CLOCK_CTRL_BASE + 0x30)
5413 +#define TNETD73XX_CLK_CTRL_MCLKCR (TNETD73XX_CLOCK_CTRL_BASE + 0x40)
5414 +#define TNETD73XX_CLK_CTRL_MCLKPLLCR (TNETD73XX_CLOCK_CTRL_BASE + 0x50)
5415 +#define TNETD73XX_CLK_CTRL_UCLKCR (TNETD73XX_CLOCK_CTRL_BASE + 0x60)
5416 +#define TNETD73XX_CLK_CTRL_UCLKPLLCR (TNETD73XX_CLOCK_CTRL_BASE + 0x70)
5417 +#define TNETD73XX_CLK_CTRL_ACLKCR0 (TNETD73XX_CLOCK_CTRL_BASE + 0x80)
5418 +#define TNETD73XX_CLK_CTRL_ACLKPLLCR0 (TNETD73XX_CLOCK_CTRL_BASE + 0x90)
5419 +#define TNETD73XX_CLK_CTRL_ACLKCR1 (TNETD73XX_CLOCK_CTRL_BASE + 0xA0)
5420 +#define TNETD73XX_CLK_CTRL_ACLKPLLCR1 (TNETD73XX_CLOCK_CTRL_BASE + 0xB0)
5423 +#define TNETD73XX_EMIF_SDRAM_CFG ( TNETD73XX_EMIF_BASE + 0x08 )
5427 +#define TNETD73XX_UART_FREQ 3686400
5429 +#define TNETD73XX_UART_FREQ TNETD73XX_VBUS_FREQ
5432 +/* Interrupt Controller */
5434 +/* Primary interrupts */
5435 +#define TNETD73XX_INTC_UNIFIED_SECONDARY 0 /* Unified secondary interrupt */
5436 +#define TNETD73XX_INTC_EXTERNAL0 1 /* External Interrupt Line 0 */
5437 +#define TNETD73XX_INTC_EXTERNAL1 2 /* External Interrupt Line 1 */
5438 +#define TNETD73XX_INTC_RESERVED3 3 /* Reserved */
5439 +#define TNETD73XX_INTC_RESERVED4 4 /* Reserved */
5440 +#define TNETD73XX_INTC_TIMER0 5 /* TIMER 0 int */
5441 +#define TNETD73XX_INTC_TIMER1 6 /* TIMER 1 int */
5442 +#define TNETD73XX_INTC_UART0 7 /* UART 0 int */
5443 +#define TNETD73XX_INTC_UART1 8 /* UART 1 int */
5444 +#define TNETD73XX_INTC_MCDMA0 9 /* MCDMA 0 int */
5445 +#define TNETD73XX_INTC_MCDMA1 10 /* MCDMA 1 int */
5446 +#define TNETD73XX_INTC_RESERVED11 11 /* Reserved */
5447 +#define TNETD73XX_INTC_RESERVED12 12 /* Reserved */
5448 +#define TNETD73XX_INTC_RESERVED13 13 /* Reserved */
5449 +#define TNETD73XX_INTC_RESERVED14 14 /* Reserved */
5450 +#define TNETD73XX_INTC_ATMSAR 15 /* ATM SAR int */
5451 +#define TNETD73XX_INTC_RESERVED16 16 /* Reserved */
5452 +#define TNETD73XX_INTC_RESERVED17 17 /* Reserved */
5453 +#define TNETD73XX_INTC_RESERVED18 18 /* Reserved */
5454 +#define TNETD73XX_INTC_EMAC0 19 /* EMAC 0 int */
5455 +#define TNETD73XX_INTC_RESERVED20 20 /* Reserved */
5456 +#define TNETD73XX_INTC_VLYNQ0 21 /* VLYNQ 0 int */
5457 +#define TNETD73XX_INTC_CODEC 22 /* CODEC int */
5458 +#define TNETD73XX_INTC_RESERVED23 23 /* Reserved */
5459 +#define TNETD73XX_INTC_USBSLAVE 24 /* USB Slave int */
5460 +#define TNETD73XX_INTC_VLYNQ1 25 /* VLYNQ 1 int */
5461 +#define TNETD73XX_INTC_RESERVED26 26 /* Reserved */
5462 +#define TNETD73XX_INTC_RESERVED27 27 /* Reserved */
5463 +#define TNETD73XX_INTC_ETH_PHY 28 /* Ethernet PHY */
5464 +#define TNETD73XX_INTC_I2C 29 /* I2C int */
5465 +#define TNETD73XX_INTC_MCDMA2 30 /* MCDMA 2 int */
5466 +#define TNETD73XX_INTC_MCDMA3 31 /* MCDMA 3 int */
5467 +#define TNETD73XX_INTC_RESERVED32 32 /* Reserved */
5468 +#define TNETD73XX_INTC_EMAC1 33 /* EMAC 1 int */
5469 +#define TNETD73XX_INTC_RESERVED34 34 /* Reserved */
5470 +#define TNETD73XX_INTC_RESERVED35 35 /* Reserved */
5471 +#define TNETD73XX_INTC_RESERVED36 36 /* Reserved */
5472 +#define TNETD73XX_INTC_VDMAVTRX 37 /* VDMAVTRX */
5473 +#define TNETD73XX_INTC_VDMAVTTX 38 /* VDMAVTTX */
5474 +#define TNETD73XX_INTC_ADSLSS 39 /* ADSLSS */
5476 +/* Secondary interrupts */
5477 +#define TNETD73XX_INTC_SEC0 40 /* Secondary */
5478 +#define TNETD73XX_INTC_SEC1 41 /* Secondary */
5479 +#define TNETD73XX_INTC_SEC2 42 /* Secondary */
5480 +#define TNETD73XX_INTC_SEC3 43 /* Secondary */
5481 +#define TNETD73XX_INTC_SEC4 44 /* Secondary */
5482 +#define TNETD73XX_INTC_SEC5 45 /* Secondary */
5483 +#define TNETD73XX_INTC_SEC6 46 /* Secondary */
5484 +#define TNETD73XX_INTC_EMIF 47 /* EMIF */
5485 +#define TNETD73XX_INTC_SEC8 48 /* Secondary */
5486 +#define TNETD73XX_INTC_SEC9 49 /* Secondary */
5487 +#define TNETD73XX_INTC_SEC10 50 /* Secondary */
5488 +#define TNETD73XX_INTC_SEC11 51 /* Secondary */
5489 +#define TNETD73XX_INTC_SEC12 52 /* Secondary */
5490 +#define TNETD73XX_INTC_SEC13 53 /* Secondary */
5491 +#define TNETD73XX_INTC_SEC14 54 /* Secondary */
5492 +#define TNETD73XX_INTC_SEC15 55 /* Secondary */
5493 +#define TNETD73XX_INTC_SEC16 56 /* Secondary */
5494 +#define TNETD73XX_INTC_SEC17 57 /* Secondary */
5495 +#define TNETD73XX_INTC_SEC18 58 /* Secondary */
5496 +#define TNETD73XX_INTC_SEC19 59 /* Secondary */
5497 +#define TNETD73XX_INTC_SEC20 60 /* Secondary */
5498 +#define TNETD73XX_INTC_SEC21 61 /* Secondary */
5499 +#define TNETD73XX_INTC_SEC22 62 /* Secondary */
5500 +#define TNETD73XX_INTC_SEC23 63 /* Secondary */
5501 +#define TNETD73XX_INTC_SEC24 64 /* Secondary */
5502 +#define TNETD73XX_INTC_SEC25 65 /* Secondary */
5503 +#define TNETD73XX_INTC_SEC26 66 /* Secondary */
5504 +#define TNETD73XX_INTC_SEC27 67 /* Secondary */
5505 +#define TNETD73XX_INTC_SEC28 68 /* Secondary */
5506 +#define TNETD73XX_INTC_SEC29 69 /* Secondary */
5507 +#define TNETD73XX_INTC_SEC30 70 /* Secondary */
5508 +#define TNETD73XX_INTC_SEC31 71 /* Secondary */
5510 +/* These ugly macros are to access the -1 registers, like config1 */
5511 +#define MFC0_SEL1_OPCODE(dst, src)\
5512 + .word (0x40000000 | ((dst)<<16) | ((src)<<11) | 1);\
5517 +#define MTC0_SEL1_OPCODE(dst, src)\
5518 + .word (0x40800000 | ((dst)<<16) | ((src)<<11) | 1);\
5524 +/* Below are Jade core specific */
5525 +#define CFG0_4K_IL_MASK 0x00380000
5526 +#define CFG0_4K_IL_SHIFT 19
5527 +#define CFG0_4K_IA_MASK 0x00070000
5528 +#define CFG0_4K_IA_SHIFT 16
5529 +#define CFG0_4K_IS_MASK 0x01c00000
5530 +#define CFG0_4K_IS_SHIFT 22
5532 +#define CFG0_4K_DL_MASK 0x00001c00
5533 +#define CFG0_4K_DL_SHIFT 10
5534 +#define CFG0_4K_DA_MASK 0x00000380
5535 +#define CFG0_4K_DA_SHIFT 7
5536 +#define CFG0_4K_DS_MASK 0x0000E000
5537 +#define CFG0_4K_DS_SHIFT 13
5541 +#endif /* __TNETD73XX_H_ */
5542 diff -urN linux.old/include/asm-mips/ar7/tnetd73xx_misc.h linux.dev/include/asm-mips/ar7/tnetd73xx_misc.h
5543 --- linux.old/include/asm-mips/ar7/tnetd73xx_misc.h 1970-01-01 01:00:00.000000000 +0100
5544 +++ linux.dev/include/asm-mips/ar7/tnetd73xx_misc.h 2005-07-12 03:01:26.110438256 +0200
5546 +/******************************************************************************
5547 + * FILE PURPOSE: TNETD73xx Misc modules API Header
5548 + ******************************************************************************
5549 + * FILE NAME: tnetd73xx_misc.h
5551 + * DESCRIPTION: Clock Control, Reset Control, Power Management, GPIO
5552 + * FSER Modules API
5553 + * As per TNETD73xx specifications
5555 + * REVISION HISTORY:
5556 + * 27 Nov 02 - Sharath Kumar PSP TII
5557 + * 14 Feb 03 - Anant Gole PSP TII
5559 + * (C) Copyright 2002, Texas Instruments, Inc
5560 + *******************************************************************************/
5562 +#ifndef __TNETD73XX_MISC_H__
5563 +#define __TNETD73XX_MISC_H__
5565 +/*****************************************************************************
5566 + * Reset Control Module
5567 + *****************************************************************************/
5569 +typedef enum TNETD73XX_RESET_MODULE_tag
5571 + RESET_MODULE_UART0 = 0,
5572 + RESET_MODULE_UART1 = 1,
5573 + RESET_MODULE_I2C = 2,
5574 + RESET_MODULE_TIMER0 = 3,
5575 + RESET_MODULE_TIMER1 = 4,
5576 + RESET_MODULE_GPIO = 6,
5577 + RESET_MODULE_ADSLSS = 7,
5578 + RESET_MODULE_USBS = 8,
5579 + RESET_MODULE_SAR = 9,
5580 + RESET_MODULE_VDMA_VT = 11,
5581 + RESET_MODULE_FSER = 12,
5582 + RESET_MODULE_VLYNQ1 = 16,
5583 + RESET_MODULE_EMAC0 = 17,
5584 + RESET_MODULE_DMA = 18,
5585 + RESET_MODULE_BIST = 19,
5586 + RESET_MODULE_VLYNQ0 = 20,
5587 + RESET_MODULE_EMAC1 = 21,
5588 + RESET_MODULE_MDIO = 22,
5589 + RESET_MODULE_ADSLSS_DSP = 23,
5590 + RESET_MODULE_EPHY = 26
5591 +} TNETD73XX_RESET_MODULE_T;
5593 +typedef enum TNETD73XX_RESET_CTRL_tag
5597 +} TNETD73XX_RESET_CTRL_T;
5599 +typedef enum TNETD73XX_SYS_RST_MODE_tag
5601 + RESET_SOC_WITH_MEMCTRL = 1, /* SW0 bit in SWRCR register */
5602 + RESET_SOC_WITHOUT_MEMCTRL = 2 /* SW1 bit in SWRCR register */
5603 +} TNETD73XX_SYS_RST_MODE_T;
5605 +typedef enum TNETD73XX_SYS_RESET_STATUS_tag
5607 + HARDWARE_RESET = 0,
5608 + SOFTWARE_RESET0, /* Caused by writing 1 to SW0 bit in SWRCR register */
5610 + SOFTWARE_RESET1 /* Caused by writing 1 to SW1 bit in SWRCR register */
5611 +} TNETD73XX_SYS_RESET_STATUS_T;
5613 +void tnetd73xx_reset_ctrl(TNETD73XX_RESET_MODULE_T reset_module,
5614 + TNETD73XX_RESET_CTRL_T reset_ctrl);
5615 +TNETD73XX_RESET_CTRL_T tnetd73xx_get_reset_status(TNETD73XX_RESET_MODULE_T reset_module);
5616 +void tnetd73xx_sys_reset(TNETD73XX_SYS_RST_MODE_T mode);
5617 +TNETD73XX_SYS_RESET_STATUS_T tnetd73xx_get_sys_last_reset_status(void);
5619 +/*****************************************************************************
5620 + * Power Control Module
5621 + *****************************************************************************/
5623 +typedef enum TNETD73XX_POWER_MODULE_tag
5625 + POWER_MODULE_USBSP = 0,
5626 + POWER_MODULE_WDTP = 1,
5627 + POWER_MODULE_UT0P = 2,
5628 + POWER_MODULE_UT1P = 3,
5629 + POWER_MODULE_IICP = 4,
5630 + POWER_MODULE_VDMAP = 5,
5631 + POWER_MODULE_GPIOP = 6,
5632 + POWER_MODULE_VLYNQ1P = 7,
5633 + POWER_MODULE_SARP = 8,
5634 + POWER_MODULE_ADSLP = 9,
5635 + POWER_MODULE_EMIFP = 10,
5636 + POWER_MODULE_ADSPP = 12,
5637 + POWER_MODULE_RAMP = 13,
5638 + POWER_MODULE_ROMP = 14,
5639 + POWER_MODULE_DMAP = 15,
5640 + POWER_MODULE_BISTP = 16,
5641 + POWER_MODULE_TIMER0P = 18,
5642 + POWER_MODULE_TIMER1P = 19,
5643 + POWER_MODULE_EMAC0P = 20,
5644 + POWER_MODULE_EMAC1P = 22,
5645 + POWER_MODULE_EPHYP = 24,
5646 + POWER_MODULE_VLYNQ0P = 27,
5647 +} TNETD73XX_POWER_MODULE_T;
5649 +typedef enum TNETD73XX_POWER_CTRL_tag
5651 + POWER_CTRL_POWER_UP = 0,
5652 + POWER_CTRL_POWER_DOWN
5653 +} TNETD73XX_POWER_CTRL_T;
5655 +typedef enum TNETD73XX_SYS_POWER_MODE_tag
5657 + GLOBAL_POWER_MODE_RUN = 0, /* All system is up */
5658 + GLOBAL_POWER_MODE_IDLE, /* MIPS is power down, all peripherals working */
5659 + GLOBAL_POWER_MODE_STANDBY, /* Chip in power down, but clock to ADSKL subsystem is running */
5660 + GLOBAL_POWER_MODE_POWER_DOWN /* Total chip is powered down */
5661 +} TNETD73XX_SYS_POWER_MODE_T;
5663 +void tnetd73xx_power_ctrl(TNETD73XX_POWER_MODULE_T power_module, TNETD73XX_POWER_CTRL_T power_ctrl);
5664 +TNETD73XX_POWER_CTRL_T tnetd73xx_get_pwr_status(TNETD73XX_POWER_MODULE_T power_module);
5665 +void tnetd73xx_set_global_pwr_mode(TNETD73XX_SYS_POWER_MODE_T power_mode);
5666 +TNETD73XX_SYS_POWER_MODE_T tnetd73xx_get_global_pwr_mode(void);
5668 +/*****************************************************************************
5670 + *****************************************************************************/
5672 +typedef enum TNETD73XX_WAKEUP_INTERRUPT_tag
5678 +} TNETD73XX_WAKEUP_INTERRUPT_T;
5680 +typedef enum TNETD73XX_WAKEUP_CTRL_tag
5682 + WAKEUP_DISABLED = 0,
5684 +} TNETD73XX_WAKEUP_CTRL_T;
5686 +typedef enum TNETD73XX_WAKEUP_POLARITY_tag
5688 + WAKEUP_ACTIVE_HIGH = 0,
5690 +} TNETD73XX_WAKEUP_POLARITY_T;
5692 +void tnetd73xx_wakeup_ctrl(TNETD73XX_WAKEUP_INTERRUPT_T wakeup_int,
5693 + TNETD73XX_WAKEUP_CTRL_T wakeup_ctrl,
5694 + TNETD73XX_WAKEUP_POLARITY_T wakeup_polarity);
5696 +/*****************************************************************************
5698 + *****************************************************************************/
5700 +typedef enum TNETD73XX_FSER_MODE_tag
5704 +} TNETD73XX_FSER_MODE_T;
5706 +void tnetd73xx_fser_ctrl(TNETD73XX_FSER_MODE_T fser_mode);
5708 +/*****************************************************************************
5710 + *****************************************************************************/
5712 +#define CLK_MHZ(x) ( (x) * 1000000 )
5714 +typedef enum TNETD73XX_CLKC_ID_tag
5720 +} TNETD73XX_CLKC_ID_T;
5722 +void tnetd73xx_clkc_init(__u32 afeclk, __u32 refclk, __u32 xtal3in);
5723 +TNETD73XX_ERR tnetd73xx_clkc_set_freq(TNETD73XX_CLKC_ID_T clk_id, __u32 output_freq);
5724 +__u32 tnetd73xx_clkc_get_freq(TNETD73XX_CLKC_ID_T clk_id);
5726 +/*****************************************************************************
5728 + *****************************************************************************/
5730 +typedef enum TNETD73XX_GPIO_PIN_tag
5732 + GPIO_UART0_RD = 0,
5733 + GPIO_UART0_TD = 1,
5734 + GPIO_UART0_RTS = 2,
5735 + GPIO_UART0_CTS = 3,
5736 + GPIO_FSER_CLK = 4,
5738 + GPIO_EXT_AFE_SCLK = 6,
5739 + GPIO_EXT_AFE_TX_FS = 7,
5740 + GPIO_EXT_AFE_TXD = 8,
5741 + GPIO_EXT_AFE_RS_FS = 9,
5742 + GPIO_EXT_AFE_RXD1 = 10,
5743 + GPIO_EXT_AFE_RXD0 = 11,
5744 + GPIO_EXT_AFE_CDIN = 12,
5745 + GPIO_EXT_AFE_CDOUT = 13,
5746 + GPIO_EPHY_SPEED100 = 14,
5747 + GPIO_EPHY_LINKON = 15,
5748 + GPIO_EPHY_ACTIVITY = 16,
5749 + GPIO_EPHY_FDUPLEX = 17,
5752 + GPIO_MBSP0_TCLK = 20,
5753 + GPIO_MBSP0_RCLK = 21,
5754 + GPIO_MBSP0_RD = 22,
5755 + GPIO_MBSP0_TD = 23,
5756 + GPIO_MBSP0_RFS = 24,
5757 + GPIO_MBSP0_TFS = 25,
5758 + GPIO_MII_DIO = 26,
5759 + GPIO_MII_DCLK = 27,
5760 +} TNETD73XX_GPIO_PIN_T;
5762 +typedef enum TNETD73XX_GPIO_PIN_MODE_tag
5764 + FUNCTIONAL_PIN = 0,
5766 +} TNETD73XX_GPIO_PIN_MODE_T;
5768 +typedef enum TNETD73XX_GPIO_PIN_DIRECTION_tag
5770 + GPIO_OUTPUT_PIN = 0,
5771 + GPIO_INPUT_PIN = 1
5772 +} TNETD73XX_GPIO_PIN_DIRECTION_T;
5774 +void tnetd73xx_gpio_init(void);
5775 +void tnetd73xx_gpio_ctrl(TNETD73XX_GPIO_PIN_T gpio_pin,
5776 + TNETD73XX_GPIO_PIN_MODE_T pin_mode,
5777 + TNETD73XX_GPIO_PIN_DIRECTION_T pin_direction);
5778 +void tnetd73xx_gpio_out(TNETD73XX_GPIO_PIN_T gpio_pin, int value);
5779 +int tnetd73xx_gpio_in(TNETD73XX_GPIO_PIN_T gpio_pin);
5781 +/* TNETD73XX Revision */
5782 +__u32 tnetd73xx_get_revision(void);
5784 +#endif /* __TNETD73XX_MISC_H__ */
5785 diff -urN linux.old/include/asm-mips/io.h linux.dev/include/asm-mips/io.h
5786 --- linux.old/include/asm-mips/io.h 2005-07-10 03:00:44.797179400 +0200
5787 +++ linux.dev/include/asm-mips/io.h 2005-07-12 02:59:26.202667008 +0200
5789 #ifdef CONFIG_64BIT_PHYS_ADDR
5790 #define page_to_phys(page) ((u64)(page - mem_map) << PAGE_SHIFT)
5792 +#ifdef CONFIG_AR7_PAGING
5793 +#define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + CONFIG_AR7_MEMORY)
5795 #define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
5799 #define IO_SPACE_LIMIT 0xffff
5801 diff -urN linux.old/include/asm-mips/irq.h linux.dev/include/asm-mips/irq.h
5802 --- linux.old/include/asm-mips/irq.h 2005-07-10 03:00:44.798179248 +0200
5803 +++ linux.dev/include/asm-mips/irq.h 2005-07-12 02:59:26.202667008 +0200
5805 #include <linux/config.h>
5806 #include <linux/linkage.h>
5809 +#include <asm/ar7/avalanche_intc.h>
5810 +#define NR_IRQS AVALANCHE_INT_END + 1
5812 #define NR_IRQS 128 /* Largest number of ints of all machines. */
5816 static inline int irq_cannonicalize(int irq)
5817 diff -urN linux.old/include/asm-mips/page.h linux.dev/include/asm-mips/page.h
5818 --- linux.old/include/asm-mips/page.h 2005-07-10 03:00:44.798179248 +0200
5819 +++ linux.dev/include/asm-mips/page.h 2005-07-12 02:59:26.202667008 +0200
5820 @@ -129,7 +129,11 @@
5822 #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
5823 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
5824 +#ifdef CONFIG_AR7_PAGING
5825 +#define virt_to_page(kaddr) phys_to_page(__pa(kaddr))
5827 #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
5829 #define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
5831 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
5832 diff -urN linux.old/include/asm-mips/pgtable-32.h linux.dev/include/asm-mips/pgtable-32.h
5833 --- linux.old/include/asm-mips/pgtable-32.h 2005-07-10 03:00:44.798179248 +0200
5834 +++ linux.dev/include/asm-mips/pgtable-32.h 2005-07-12 02:59:26.203666856 +0200
5835 @@ -108,7 +108,18 @@
5836 * and a page entry and page directory to the page they refer to.
5839 -#ifdef CONFIG_CPU_VR41XX
5840 +#if defined(CONFIG_AR7_PAGING)
5841 +#define mk_pte(page, pgprot) \
5845 + pte_val(__pte) = ((phys_t)(page - mem_map) << (PAGE_SHIFT) | \
5846 + CONFIG_AR7_MEMORY) | \
5847 + pgprot_val(pgprot); \
5851 +#elif defined(CONFIG_CPU_VR41XX)
5852 #define mk_pte(page, pgprot) \
5860 static inline pte_t mk_pte_phys(phys_t physpage, pgprot_t pgprot)
5862 #ifdef CONFIG_CPU_VR41XX
5863 @@ -175,7 +187,10 @@
5864 set_pte(ptep, __pte(0));
5867 -#ifdef CONFIG_CPU_VR41XX
5868 +#if defined(CONFIG_AR7_PAGING)
5869 +#define phys_to_page(phys) (mem_map + (((phys)-CONFIG_AR7_MEMORY) >> PAGE_SHIFT))
5870 +#define pte_page(x) phys_to_page(pte_val(x))
5871 +#elif defined(CONFIG_CPU_VR41XX)
5872 #define pte_page(x) (mem_map+((unsigned long)(((x).pte_low >> (PAGE_SHIFT+2)))))
5873 #define __mk_pte(page_nr,pgprot) __pte(((page_nr) << (PAGE_SHIFT+2)) | pgprot_val(pgprot))
5875 diff -urN linux.old/include/asm-mips/serial.h linux.dev/include/asm-mips/serial.h
5876 --- linux.old/include/asm-mips/serial.h 2005-07-10 03:00:44.799179096 +0200
5877 +++ linux.dev/include/asm-mips/serial.h 2005-07-12 02:59:26.203666856 +0200
5880 #define C_P(card,port) (((card)<<6|(port)<<3) + 1)
5883 +#include <asm/ar7/ar7.h>
5884 +#define AR7_SERIAL_PORT_DEFNS \
5885 + { 0, AR7_BASE_BAUD, AR7_UART0_REGS_BASE, LNXINTNUM(AVALANCHE_UART0_INT), STD_COM_FLAGS }, \
5886 + { 0, AR7_BASE_BAUD, AR7_UART1_REGS_BASE, LNXINTNUM(AVALANCHE_UART1_INT), STD_COM_FLAGS },
5888 +#define AR7_SERIAL_PORT_DEFNS
5891 #ifdef CONFIG_MIPS_JAZZ
5892 #define _JAZZ_SERIAL_INIT(int, base) \
5893 { .baud_base = JAZZ_BASE_BAUD, .irq = int, .flags = STD_COM_FLAGS, \
5897 #define SERIAL_PORT_DFNS \
5898 + AR7_SERIAL_PORT_DEFNS \
5899 ATLAS_SERIAL_PORT_DEFNS \
5900 AU1000_SERIAL_PORT_DEFNS \
5901 COBALT_SERIAL_PORT_DEFNS \
5902 diff -urN linux.old/Makefile linux.dev/Makefile
5903 --- linux.old/Makefile 2005-07-10 03:00:44.799179096 +0200
5904 +++ linux.dev/Makefile 2005-07-12 02:59:26.204666704 +0200
5907 CPPFLAGS := -D__KERNEL__ -I$(HPATH)
5909 -CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
5910 +CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
5911 -fno-strict-aliasing -fno-common
5912 ifndef CONFIG_FRAME_POINTER
5913 CFLAGS += -fomit-frame-pointer