3 @@ -179,6 +179,11 @@ config ARM_L1_CACHE_SHIFT_6
5 Setting ARM L1 cache line size to 64 Bytes.
7 +config ARM_L1_CACHE_SHIFT_4
10 + Setting ARM L1 cache line size to 16 bytes.
14 default 0xffff0000 if MMU || CPU_HIGH_VECTOR
15 @@ -286,6 +291,15 @@ config ARCH_BCMRING
17 Support for Broadcom's BCMRing platform.
20 + bool "Cavium Networks CNS21xx family"
24 + select ARM_L1_CACHE_SHIFT_4
26 + Support for Cavium Networks CNS21xx family.
29 bool "Cirrus Logic CLPS711x/EP721x-based"
31 @@ -864,6 +878,8 @@ source "arch/arm/mach-davinci/Kconfig"
33 source "arch/arm/mach-dove/Kconfig"
35 +source "arch/arm/mach-cns21xx/Kconfig"
37 source "arch/arm/mach-ep93xx/Kconfig"
39 source "arch/arm/mach-footbridge/Kconfig"
41 +++ b/arch/arm/mach-cns21xx/Kconfig
45 +menu "Cavium Networks CNS21xx based machines"
50 +++ b/arch/arm/mach-cns21xx/Makefile
53 +# Makefile for the linux kernel.
58 +obj-y := core.o irq.o mm.o time.o
60 +# machine specific files
63 +++ b/arch/arm/mach-cns21xx/Makefile.boot
65 + zreladdr-y := 0x00008000
66 +params_phys-y := 0x00000100
67 +initrd_phys-y := 0x00C00000
68 --- a/arch/arm/Makefile
69 +++ b/arch/arm/Makefile
70 @@ -129,6 +129,7 @@ endif
71 machine-$(CONFIG_ARCH_AAEC2000) := aaec2000
72 machine-$(CONFIG_ARCH_AT91) := at91
73 machine-$(CONFIG_ARCH_BCMRING) := bcmring
74 +machine-$(CONFIG_ARCH_CNS21XX) := cns21xx
75 machine-$(CONFIG_ARCH_CLPS711X) := clps711x
76 machine-$(CONFIG_ARCH_CNS3XXX) := cns3xxx
77 machine-$(CONFIG_ARCH_DAVINCI) := davinci
79 +++ b/arch/arm/mach-cns21xx/common.h
82 + * Copyright (c) 2008 Cavium Networks
83 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
85 + * This file is free software; you can redistribute it and/or modify
86 + * it under the terms of the GNU General Public License, Version 2, as
87 + * published by the Free Software Foundation.
90 +#ifndef _MACH_CNS21XX_COMMON_H
91 +#define _MACH_CNS21XX_COMMON_H
93 +void __init cns21xx_map_io(void);
94 +void __init cns21xx_init_irq(void);
96 +extern struct sys_timer cns21xx_timer;
98 +#endif /* _MACH_CNS21XX_COMMON_H */
100 +++ b/arch/arm/mach-cns21xx/mm.c
103 + * Copyright (c) 2008 Cavium Networks
104 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
106 + * This file is free software; you can redistribute it and/or modify
107 + * it under the terms of the GNU General Public License, Version 2, as
108 + * published by the Free Software Foundation.
111 +#include <linux/mm.h>
112 +#include <linux/init.h>
114 +#include <asm/mach/map.h>
116 +#include <mach/hardware.h>
117 +#include <mach/cns21xx.h>
122 + * Standard IO mapping
124 +static struct map_desc cns21xx_io_desc[] __initdata = {
126 + .virtual = CNS21XX_FLASH_BANK0_BASE_VIRT,
127 + .pfn = __phys_to_pfn(CNS21XX_FLASH_BANK0_BASE),
131 + .virtual = CNS21XX_IDE_DEVICE_BASE_VIRT,
132 + .pfn = __phys_to_pfn(CNS21XX_IDE_DEVICE_BASE),
136 + .virtual = CNS21XX_GDMAC_BASE_VIRT,
137 + .pfn = __phys_to_pfn(CNS21XX_GDMAC_BASE),
141 + .virtual = CNS21XX_NIC_BASE_VIRT,
142 + .pfn = __phys_to_pfn(CNS21XX_NIC_BASE),
146 + .virtual = CNS21XX_SPI_BASE_VIRT,
147 + .pfn = __phys_to_pfn(CNS21XX_SPI_BASE),
151 + .virtual = CNS21XX_PCM_BASE_VIRT,
152 + .pfn = __phys_to_pfn(CNS21XX_PCM_BASE),
156 + .virtual = CNS21XX_I2C_BASE_VIRT,
157 + .pfn = __phys_to_pfn(CNS21XX_I2C_BASE),
161 + .virtual = CNS21XX_I2S_BASE_VIRT,
162 + .pfn = __phys_to_pfn(CNS21XX_I2S_BASE),
166 + .virtual = CNS21XX_DDRC_BASE_VIRT,
167 + .pfn = __phys_to_pfn(CNS21XX_DDRC_BASE),
171 + .virtual = CNS21XX_SMC_BASE_VIRT,
172 + .pfn = __phys_to_pfn(CNS21XX_SMC_BASE),
176 + .virtual = CNS21XX_IDE_CTRL_BASE_VIRT,
177 + .pfn = __phys_to_pfn(CNS21XX_IDE_CTRL_BASE),
181 + .virtual = CNS21XX_MISC_BASE_VIRT,
182 + .pfn = __phys_to_pfn(CNS21XX_MISC_BASE),
186 + .virtual = CNS21XX_CPM_BASE_VIRT,
187 + .pfn = __phys_to_pfn(CNS21XX_CPM_BASE),
191 + .virtual = CNS21XX_UART0_BASE_VIRT,
192 + .pfn = __phys_to_pfn(CNS21XX_UART0_BASE),
196 + .virtual = CNS21XX_UART1_BASE_VIRT,
197 + .pfn = __phys_to_pfn(CNS21XX_UART1_BASE),
201 + .virtual = CNS21XX_TIMER_BASE_VIRT,
202 + .pfn = __phys_to_pfn(CNS21XX_TIMER_BASE),
206 + .virtual = CNS21XX_WDT_BASE_VIRT,
207 + .pfn = __phys_to_pfn(CNS21XX_WDT_BASE),
211 + .virtual = CNS21XX_RTC_BASE_VIRT,
212 + .pfn = __phys_to_pfn(CNS21XX_RTC_BASE),
216 + .virtual = CNS21XX_GPIOA_BASE_VIRT,
217 + .pfn = __phys_to_pfn(CNS21XX_GPIOA_BASE),
221 + .virtual = CNS21XX_GPIOB_BASE_VIRT,
222 + .pfn = __phys_to_pfn(CNS21XX_GPIOB_BASE),
226 + .virtual = CNS21XX_PCI_CFGDATA_BASE_VIRT,
227 + .pfn = __phys_to_pfn(CNS21XX_PCI_CFGDATA_BASE),
231 + .virtual = CNS21XX_PCI_CFGADDR_BASE_VIRT,
232 + .pfn = __phys_to_pfn(CNS21XX_PCI_CFGADDR_BASE),
236 + .virtual = CNS21XX_OHCI_CONFIG_BASE_VIRT,
237 + .pfn = __phys_to_pfn(CNS21XX_OHCI_CONFIG_BASE),
241 + .virtual = CNS21XX_OHCI_CTRL_BASE_VIRT,
242 + .pfn = __phys_to_pfn(CNS21XX_OHCI_CTRL_BASE),
246 + .virtual = CNS21XX_EHCI_CONFIG_BASE_VIRT,
247 + .pfn = __phys_to_pfn(CNS21XX_EHCI_CONFIG_BASE),
251 + .virtual = CNS21XX_EHCI_CTRL_BASE_VIRT,
252 + .pfn = __phys_to_pfn(CNS21XX_EHCI_CTRL_BASE),
256 + .virtual = CNS21XX_USB_DEVICE_BASE_VIRT,
257 + .pfn = __phys_to_pfn(CNS21XX_USB_DEVICE_BASE),
261 + .virtual = CNS21XX_INTC_BASE_VIRT,
262 + .pfn = __phys_to_pfn(CNS21XX_INTC_BASE),
268 +void __init cns21xx_map_io(void)
270 + iotable_init(cns21xx_io_desc, ARRAY_SIZE(cns21xx_io_desc));
273 +++ b/arch/arm/mach-cns21xx/include/mach/hardware.h
276 + * Copyright (c) 2008 Cavium Networks
277 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
279 + * This file is free software; you can redistribute it and/or modify
280 + * it under the terms of the GNU General Public License, Version 2, as
281 + * published by the Free Software Foundation.
284 +#ifndef _CNS21XX_HARDWARE_H
285 +#define _CNS21XX_HARDWARE_H
287 +#define PCIBIOS_MIN_IO 0x00000000
288 +#define PCIBIOS_MIN_MEM 0x00000000
290 +#ifndef __ASSEMBLY__
291 +extern unsigned long cns21xx_get_pll_freq(void);
292 +extern unsigned long cns21xx_get_cpu_freq(void);
293 +extern unsigned long cns21xx_get_ahb_freq(void);
294 +extern unsigned long cns21xx_get_apb_freq(void);
297 +#endif /* _CNS21XX_HARDWARE_H */
299 +++ b/arch/arm/mach-cns21xx/include/mach/vmalloc.h
302 + * Copyright (c) 2008 Cavium Networks
303 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
305 + * This file is free software; you can redistribute it and/or modify
306 + * it under the terms of the GNU General Public License, Version 2, as
307 + * published by the Free Software Foundation.
310 +#ifndef _CNS21XX_VMALLOC_H
311 +#define _CNS21XX_VMALLOC_H
313 +#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
315 +#endif /* _CNS21XX_VMALLOC_H */
317 +++ b/arch/arm/mach-cns21xx/include/mach/debug-macro.S
320 + * Copyright (c) 2008 Cavium Networks
321 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
323 + * This file is free software; you can redistribute it and/or modify
324 + * it under the terms of the GNU General Public License, Version 2, as
325 + * published by the Free Software Foundation.
328 +#include <mach/cns21xx.h>
330 +/* TODO: make it configurable */
331 +#define CNS21XX_DEBUG_UART_BASE CNS21XX_UART0_BASE
332 +#define CNS21XX_DEBUG_UART_BASE_VIRT CNS21XX_UART0_BASE_VIRT
334 + .macro addruart, rp, rv
335 + mov \rp, #(CNS21XX_DEBUG_UART_BASE) @ physical
336 + mov \rv, #(CNS21XX_DEBUG_UART_BASE_VIRT & 0xff000000) @virtual
337 + orr \rv, \rv, #(CNS21XX_DEBUG_UART_BASE_VIRT & 0x00ff0000)
338 + orr \rv, \rv, #(CNS21XX_DEBUG_UART_BASE_VIRT & 0x0000ff00)
339 + orr \rv, \rv, #(CNS21XX_DEBUG_UART_BASE_VIRT & 0x000000ff)
342 +#define UART_SHIFT 2
343 +#include <asm/hardware/debug-8250.S>
345 +++ b/arch/arm/mach-cns21xx/include/mach/entry-macro.S
348 + * Copyright (c) 2008 Cavium Networks
349 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
351 + * This file is free software; you can redistribute it and/or modify
352 + * it under the terms of the GNU General Public License, Version 2, as
353 + * published by the Free Software Foundation.
356 +#include <mach/cns21xx.h>
357 +#include <mach/irqs.h>
359 +#define INTC_IRQ_STATUS 0x1c
364 + .macro get_irqnr_preamble, base, tmp
367 + .macro arch_ret_to_user, tmp1, tmp2
370 + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
371 + ldr \base, =(CNS21XX_INTC_BASE_VIRT + INTC_IRQ_STATUS)
372 + ldr \irqstat, [\base]
377 + add \irqnr, \irqnr, #1
378 + mov \irqstat, \irqstat, lsr #1
379 + cmp \irqnr, #CNS21XX_NR_INTC_IRQS
384 + .macro irq_prio_table
387 +++ b/arch/arm/mach-cns21xx/include/mach/io.h
390 + * Copyright (c) 2008 Cavium Networks
391 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
393 + * This file is free software; you can redistribute it and/or modify
394 + * it under the terms of the GNU General Public License, Version 2, as
395 + * published by the Free Software Foundation.
398 +#ifndef _CNS21XX_IO_H
399 +#define _CNS21XX_IO_H
401 +#define IO_SPACE_LIMIT 0xffffffff
403 +#define __io(p) __typesafe_io(p)
404 +#define __mem_pci(a) (a)
406 +#endif /* _CNS21XX_IO_H */
408 +++ b/arch/arm/mach-cns21xx/include/mach/irqs.h
411 + * Copyright (c) 2008 Cavium Networks
412 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
414 + * This file is free software; you can redistribute it and/or modify
415 + * it under the terms of the GNU General Public License, Version 2, as
416 + * published by the Free Software Foundation.
419 +#ifndef _CNS21XX_IRQS_H
420 +#define _CNS21XX_IRQS_H
422 +#define CNS21XX_IRQ_TIMER1 0
423 +#define CNS21XX_IRQ_TIMER2 1
424 +#define CNS21XX_IRQ_CPM 2
425 +#define CNS21XX_IRQ_WDT 3
426 +#define CNS21XX_IRQ_GPIO 4
427 +#define CNS21XX_IRQ_PCI_INTA 5
428 +#define CNS21XX_IRQ_PCI_INTB 6
429 +#define CNS21XX_IRQ_PCI_BROKEN 7
430 +#define CNS21XX_IRQ_AHB2PCI 8
431 +#define CNS21XX_IRQ_UART0 9
432 +#define CNS21XX_IRQ_UART1 10
433 +#define CNS21XX_IRQ_GDMAC_TC 11
434 +#define CNS21XX_IRQ_GDMAC_ERR 12
435 +#define CNS21XX_IRQ_PCMCIA 13
436 +#define CNS21XX_IRQ_RTC 14
437 +#define CNS21XX_IRQ_PCM 15
438 +#define CNS21XX_IRQ_USB_DEVICE 16
439 +#define CNS21XX_IRQ_IDE 17
440 +#define CNS21XX_IRQ_NIC_STATUS 18
441 +#define CNS21XX_IRQ_NIC_TXTC 19
442 +#define CNS21XX_IRQ_NIC_RXRC 20
443 +#define CNS21XX_IRQ_NIC_TXQE 21
444 +#define CNS21XX_IRQ_NIC_RXQF 22
445 +#define CNS21XX_IRQ_OHCI 23
446 +#define CNS21XX_IRQ_EHCI 24
447 +#define CNS21XX_IRQ_I2S 25
448 +#define CNS21XX_IRQ_SPI 26
449 +#define CNS21XX_IRQ_I2C 27
450 +#define CNS21XX_IRQ_USB_VBUS 28
451 +#define CNS21XX_IRQ_EXT_29 29
452 +#define CNS21XX_IRQ_EXT_30 30
453 +#define CNS21XX_IRQ_HSDMAC 31
455 +#define CNS21XX_GPIO_IRQ_BASE 32
457 +#define CNS21XX_NR_INTC_IRQS 32
458 +#define CNS21XX_NR_GPIO_IRQS 64
462 +#endif /* _CNS21XX_IRQS_H */
464 +++ b/arch/arm/mach-cns21xx/include/mach/timex.h
467 + * Copyright (c) 2008 Cavium Networks
468 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
470 + * This file is free software; you can redistribute it and/or modify
471 + * it under the terms of the GNU General Public License, Version 2, as
472 + * published by the Free Software Foundation.
475 +#ifndef _CNS21XX_TIMEX_H
476 +#define _CNS21XX_TIMEX_H
478 +#define CLOCK_TICK_RATE 43750000
480 +#endif /* _CNS21XX_TIMEX_H */
482 +++ b/arch/arm/mach-cns21xx/include/mach/uncompress.h
485 + * Copyright (c) 2008 Cavium Networks
486 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
488 + * This file is free software; you can redistribute it and/or modify
489 + * it under the terms of the GNU General Public License, Version 2, as
490 + * published by the Free Software Foundation.
493 +#ifndef _CNS21XX_UNCOMPRESS_H
494 +#define _CNS21XX_UNCOMPRESS_H
496 +#define UART_BASE 0x78000000
498 +#define UART_REG(offs) (*((volatile unsigned int *)(UART_BASE + offs)))
500 +#define UART_THR UART_REG(0x00)
501 +#define UART_LSR UART_REG(0x14)
502 +#define THR_EMPTY (1 << 5)
504 +#define UART_THR_EMPTY() (((UART_LSR) & THR_EMPTY) == (THR_EMPTY))
506 +static void putc(int c)
509 + while (!UART_THR_EMPTY())
512 + UART_THR = (int)(c & 0xFF);
516 +static inline void flush(void)
520 +#define arch_decomp_setup()
521 +#define arch_decomp_wdog()
523 +#endif /* _CNS21XX_UNCOMPRESS_H */
525 +++ b/arch/arm/mach-cns21xx/include/mach/memory.h
528 + * Copyright (c) 2008 Cavium Networks
529 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
531 + * This file is free software; you can redistribute it and/or modify
532 + * it under the terms of the GNU General Public License, Version 2, as
533 + * published by the Free Software Foundation.
536 +#ifndef _CNS21XX_MEMORY_H
537 +#define _CNS21XX_MEMORY_H
539 +#define PHYS_OFFSET UL(0x00000000)
541 +#endif /* _CNS21XX_MEMORY_H */
543 +++ b/arch/arm/mach-cns21xx/include/mach/system.h
546 + * Copyright (c) 2008 Cavium Networks
547 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
549 + * This file is free software; you can redistribute it and/or modify
550 + * it under the terms of the GNU General Public License, Version 2, as
551 + * published by the Free Software Foundation.
554 +#ifndef _CNS21XX_SYSTEM_H
555 +#define _CNS21XX_SYSTEM_H
557 +#include <mach/cns21xx.h>
558 +#include <mach/cns21xx_powermgmt.h>
560 +static inline void arch_idle(void)
563 + * Because of broken hardware we have to enable interrupts or the CPU
564 + * will never wakeup... Acctualy it is not very good to enable
565 + * interrupts here since scheduler can miss a tick, but there is
566 + * no other way around this. Platforms that needs it for power saving
567 + * should call enable_hlt() in init code, since by default it is
570 + local_irq_enable();
574 +static inline void arch_reset(char mode, const char *cmd)
576 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |=
577 + (1UL << PWRMGT_GLOBAL_SOFTWARE_RESET_MASK_BIT_INDEX);
578 + PWRMGT_SOFTWARE_RESET_CONTROL_REG &=
579 + ~(1UL << PWRMGT_GLOBAL_SOFTWARE_RESET_MASK_BIT_INDEX);
582 +#endif /* _CNS21XX_SYSTEM_H */
584 +++ b/arch/arm/mach-cns21xx/irq.c
587 + * Copyright (c) 2008 Cavium Networks
588 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
590 + * This file is free software; you can redistribute it and/or modify
591 + * it under the terms of the GNU General Public License, Version 2, as
592 + * published by the Free Software Foundation.
595 +#include <linux/init.h>
596 +#include <linux/interrupt.h>
597 +#include <linux/irq.h>
598 +#include <linux/io.h>
599 +#include <linux/ioport.h>
601 +#include <mach/cns21xx.h>
603 +#define INTC_INTERRUPT_RAW_STATUS_REG 0x000
604 +#define INTC_EDGE_INTERRUPT_SOURCE_CLEAR_REG 0x004
605 +#define INTC_INTERRUPT_MASK_REG 0x008
606 +#define INTC_INTERRUPT_MASK_CLEAR_REG 0x00c
607 +#define INTC_INTERRUPT_TRIGGER_MODE_REG 0x010
608 +#define INTC_INTERRUPT_TRIGGER_LEVEL_REG 0x014
609 +#define INTC_FIQ_SELECT_REG 0x018
610 +#define INTC_IRQ_STATUS_REG 0x01c
611 +#define INTC_FIQ_STATUS_REG 0x020
612 +#define INTC_SOFTWARE_INTERRUPT_REG 0x024
613 +#define INTC_SOFTWARE_INTERRUPT_CLEAR_REG 0x028
614 +#define INTC_SOFTWARE_PRIORITY_MASK_REG 0x02c
615 +#define INTC_POWER_MANAGEMENT_INTERRUPT_REG 0x034
617 +#define INTC_VECTOR_ADDRESS_REG(_x) ((_x) + 0x040)
618 +#define INTC_PRIORITY_REG(_x) ((_x) + 0x0c0)
619 +#define INTC_IRQ_VECTOR_ADDRESS_REG 0x140
620 +#define INTC_VECTOR_INTERRUPT_ENABLE_REG 0x144
622 +#define INTC_SIZE 0x148
624 +static unsigned int cns21xx_irq_types[CNS21XX_NR_INTC_IRQS] = {
625 + [CNS21XX_IRQ_TIMER1] = IRQ_TYPE_EDGE_RISING,
626 + [CNS21XX_IRQ_TIMER2] = IRQ_TYPE_EDGE_RISING,
627 + [CNS21XX_IRQ_CPM] = IRQ_TYPE_EDGE_FALLING,
628 + [CNS21XX_IRQ_WDT] = IRQ_TYPE_EDGE_RISING,
629 + [CNS21XX_IRQ_GPIO] = IRQ_TYPE_NONE,
630 + [CNS21XX_IRQ_PCI_INTA] = IRQ_TYPE_LEVEL_LOW,
631 + [CNS21XX_IRQ_PCI_INTB] = IRQ_TYPE_LEVEL_LOW,
632 + [CNS21XX_IRQ_PCI_BROKEN] = IRQ_TYPE_LEVEL_HIGH,
633 + [CNS21XX_IRQ_AHB2PCI] = IRQ_TYPE_LEVEL_HIGH,
634 + [CNS21XX_IRQ_UART0] = IRQ_TYPE_LEVEL_HIGH,
635 + [CNS21XX_IRQ_UART1] = IRQ_TYPE_LEVEL_HIGH,
636 + [CNS21XX_IRQ_GDMAC_TC] = IRQ_TYPE_LEVEL_HIGH,
637 + [CNS21XX_IRQ_GDMAC_ERR] = IRQ_TYPE_LEVEL_HIGH,
638 + [CNS21XX_IRQ_PCMCIA] = IRQ_TYPE_NONE,
639 + [CNS21XX_IRQ_RTC] = IRQ_TYPE_LEVEL_HIGH,
640 + [CNS21XX_IRQ_PCM] = IRQ_TYPE_LEVEL_LOW,
641 + [CNS21XX_IRQ_USB_DEVICE] = IRQ_TYPE_LEVEL_LOW,
642 + [CNS21XX_IRQ_IDE] = IRQ_TYPE_LEVEL_HIGH,
643 + [CNS21XX_IRQ_NIC_STATUS] = IRQ_TYPE_LEVEL_HIGH,
644 + [CNS21XX_IRQ_NIC_TXTC] = IRQ_TYPE_EDGE_RISING,
645 + [CNS21XX_IRQ_NIC_RXRC] = IRQ_TYPE_EDGE_RISING,
646 + [CNS21XX_IRQ_NIC_TXQE] = IRQ_TYPE_EDGE_RISING,
647 + [CNS21XX_IRQ_NIC_RXQF] = IRQ_TYPE_EDGE_RISING,
648 + [CNS21XX_IRQ_OHCI] = IRQ_TYPE_LEVEL_LOW,
649 + [CNS21XX_IRQ_EHCI] = IRQ_TYPE_LEVEL_LOW,
650 + [CNS21XX_IRQ_I2S] = IRQ_TYPE_LEVEL_LOW,
651 + [CNS21XX_IRQ_SPI] = IRQ_TYPE_LEVEL_LOW,
652 + [CNS21XX_IRQ_I2C] = IRQ_TYPE_LEVEL_LOW,
653 + [CNS21XX_IRQ_USB_VBUS] = IRQ_TYPE_EDGE_RISING,
654 + [CNS21XX_IRQ_EXT_29] = IRQ_TYPE_NONE,
655 + [CNS21XX_IRQ_EXT_30] = IRQ_TYPE_NONE,
656 + [CNS21XX_IRQ_HSDMAC] = IRQ_TYPE_EDGE_RISING,
659 +static void __iomem *cns21xx_intc_base;
661 +static inline void cns21xx_intc_writel(u32 val, unsigned int reg)
663 + __raw_writel(val, cns21xx_intc_base + reg);
666 +static inline u32 cns21xx_intc_readl(unsigned int reg)
668 + return __raw_readl(cns21xx_intc_base + reg);
671 +static void cns21xx_irq_ack(unsigned int irq)
673 + cns21xx_intc_writel(1 << irq, INTC_EDGE_INTERRUPT_SOURCE_CLEAR_REG);
676 +static void cns21xx_irq_mask(unsigned int irq)
678 + cns21xx_intc_writel(1 << irq, INTC_INTERRUPT_MASK_REG);
681 +static void cns21xx_irq_unmask(unsigned int irq)
683 + cns21xx_intc_writel(1 << irq, INTC_INTERRUPT_MASK_CLEAR_REG);
686 +static struct irq_chip cns21xx_irq_chip = {
688 + .ack = cns21xx_irq_ack,
689 + .mask = cns21xx_irq_mask,
690 + .unmask = cns21xx_irq_unmask,
693 +static struct resource cns21xx_intc_resource = {
695 + .flags = IORESOURCE_MEM,
696 + .start = CNS21XX_INTC_BASE,
697 + .end = CNS21XX_INTC_BASE + INTC_SIZE - 1,
700 +void __init cns21xx_init_irq(void)
702 + unsigned int mode = 0;
703 + unsigned int level = 0;
707 + * Disable arch_idle() by default since it is buggy
708 + * For more info see arch/arm/mach-cns21xx/include/mach/system.h
712 + request_resource(&iomem_resource, &cns21xx_intc_resource);
713 + cns21xx_intc_base = ioremap(cns21xx_intc_resource.start, INTC_SIZE);
715 + cns21xx_intc_writel(0xffffffff, INTC_INTERRUPT_MASK_REG);
716 + cns21xx_intc_writel(0xffffffff, INTC_EDGE_INTERRUPT_SOURCE_CLEAR_REG);
717 + cns21xx_intc_writel(0xffffffff, INTC_SOFTWARE_INTERRUPT_CLEAR_REG);
718 + cns21xx_intc_writel(0, INTC_SOFTWARE_PRIORITY_MASK_REG);
719 + cns21xx_intc_writel(0, INTC_FIQ_SELECT_REG);
720 + cns21xx_intc_writel(0, INTC_VECTOR_INTERRUPT_ENABLE_REG);
722 + for (i = 0; i < ARRAY_SIZE(cns21xx_irq_types); i++) {
723 + irq_flow_handler_t handler;
725 + switch (cns21xx_irq_types[i]) {
726 + case IRQ_TYPE_EDGE_RISING:
727 + handler = handle_edge_irq;
731 + case IRQ_TYPE_EDGE_FALLING:
732 + handler = handle_edge_irq;
737 + case IRQ_TYPE_LEVEL_LOW:
738 + handler = handle_level_irq;
742 + case IRQ_TYPE_LEVEL_HIGH:
743 + case IRQ_TYPE_NONE:
744 + handler = handle_level_irq;
752 + set_irq_chip(i, &cns21xx_irq_chip);
753 + set_irq_handler(i, handler);
754 + set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
757 + cns21xx_intc_writel(mode, INTC_INTERRUPT_TRIGGER_MODE_REG);
758 + cns21xx_intc_writel(level, INTC_INTERRUPT_TRIGGER_LEVEL_REG);
761 +++ b/arch/arm/mach-cns21xx/time.c
764 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
766 + * This file is free software; you can redistribute it and/or modify
767 + * it under the terms of the GNU General Public License, Version 2, as
768 + * published by the Free Software Foundation.
771 +#include <linux/init.h>
772 +#include <linux/irq.h>
774 +#include <asm/mach/time.h>
776 +#include <plat/time.h>
777 +#include <mach/hardware.h>
778 +#include <mach/cns21xx.h>
782 +static void __init cns21xx_timer_init(void)
784 + fa_timer_init(CNS21XX_TIMER_BASE, CNS21XX_IRQ_TIMER1, FA_TIMER1,
785 + cns21xx_get_apb_freq());
788 +struct sys_timer cns21xx_timer = {
789 + .init = cns21xx_timer_init,
792 +++ b/arch/arm/mach-cns21xx/include/mach/cns21xx_powermgmt.h
795 + * Copyright (c) 2008 Cavium Networks
796 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
798 + * This file is free software; you can redistribute it and/or modify
799 + * it under the terms of the GNU General Public License, Version 2, as
800 + * published by the Free Software Foundation.
803 +#ifndef _CNS21XX_POWERMGMT_H
804 +#define _CNS21XX_POWERMGMT_H
806 +#define PWRMGT_MEM_MAP_VALUE(reg_offset) \
807 + (*((u32 volatile *)(CNS21XX_CPM_BASE_VIRT + reg_offset)))
810 + * define access macros
812 +#define PWRMGT_CLOCK_GATE_CONTROL0_REG PWRMGT_MEM_MAP_VALUE(0x00)
813 +#define PWRMGT_CLOCK_GATE_CONTROL1_REG PWRMGT_MEM_MAP_VALUE(0x04)
814 +#define PWRMGT_SOFTWARE_RESET_CONTROL_REG PWRMGT_MEM_MAP_VALUE(0x08)
815 +#define PWRMGT_SYSTEM_CLOCK_CONTROL_REG PWRMGT_MEM_MAP_VALUE(0x0C)
816 +#define PWRMGT_PLL_POWER_DOWN_CONTROL_REG PWRMGT_MEM_MAP_VALUE(0x10)
817 +#define PWRMGT_CPU_INITIALIZATION_REG PWRMGT_MEM_MAP_VALUE(0x14)
818 +#define PWRMGT_PAD_DRIVE_STRENGTH_CONTROL_REG PWRMGT_MEM_MAP_VALUE(0x1C)
819 +#define PWRMGT_USB_DEVICE_POWERMGT_REG PWRMGT_MEM_MAP_VALUE(0x20)
820 +#define PWRMGT_REGULATOR_CONTROL_REG PWRMGT_MEM_MAP_VALUE(0x24)
821 +#define PWRMGT_RTC_XTAL_CONTROL_REG PWRMGT_MEM_MAP_VALUE(0x28)
822 +#define PWRMGT_PLL250_CONTROL_REG PWRMGT_MEM_MAP_VALUE(0x2C)
826 + * define constants macros
828 +#define PWRMGT_GLOBAL_SOFTWARE_RESET_MASK_BIT_INDEX 0
829 +#define PWRMGT_PCMCIA_SOFTWARE_RESET_BIT_INDEX 1
830 +#define PWRMGT_IDE_SOFTWARE_RESET_BIT_INDEX 2
831 +#define PWRMGT_VIC_SOFTWARE_RESET_BIT_INDEX 3
832 +#define PWRMGT_DMA_SOFTWARE_RESET_BIT_INDEX 4
833 +#define PWRMGT_NIC_SOFTWARE_RESET_BIT_INDEX 5
834 +#define PWRMGT_USB_HOST_SOFTWARE_RESET_BIT_INDEX 6
835 +#define PWRMGT_PCI_BRIDGE_SOFTWARE_RESET_BIT_INDEX 7
836 +#define PWRMGT_P2S_SOFTWARE_RESET_BIT_INDEX 8
837 +#define PWRMGT_UART0_SOFTWARE_RESET_BIT_INDEX 9
838 +#define PWRMGT_UART1_SOFTWARE_RESET_BIT_INDEX 10
839 +#define PWRMGT_TIMER_SOFTWARE_RESET_BIT_INDEX 11
840 +#define PWRMGT_WDTIMER_SOFTWARE_RESET_BIT_INDEX 12
841 +#define PWRMGT_GPIO_SOFTWARE_RESET_BIT_INDEX 13
842 +#define PWRMGT_USB_DEVICE_SOFTWARE_RESET_BIT_INDEX 14
843 +#define PWRMGT_FAST_ETHERNET_PHY_SOFTWARE_RESET_BIT_INDEX 15
844 +#define PWRMGT_HSDMA_SOFTWARE_RESET_BIT_INDEX 16
846 +#define PWRMGT_PLL_FREQUENCY_175MHZ (0 << 0)
847 +#define PWRMGT_PLL_FREQUENCY_200MHZ (1 << 0)
848 +#define PWRMGT_PLL_FREQUENCY_225MHZ (2 << 0)
849 +#define PWRMGT_PLL_FREQUENCY_250MHZ (3 << 0)
851 +#define PWRMGT_CPUCLK_DIVIDER_BY_1 (0 << 2)
852 +#define PWRMGT_CPUCLK_DIVIDER_BY_2 (1 << 2)
853 +#define PWRMGT_CPUCLK_DIVIDER_BY_3 (2 << 2)
854 +#define PWRMGT_CPUCLK_DIVIDER_BY_4 (3 << 2)
856 +#define PWRMGT_HCLK_DIVIDER_BY_1 (0 << 4)
857 +#define PWRMGT_HCLK_DIVIDER_BY_2 (1 << 4)
858 +#define PWRMGT_HCLK_DIVIDER_BY_3 (2 << 4)
859 +#define PWRMGT_HCLK_DIVIDER_BY_4 (3 << 4)
861 +#define PWRMGT_HCLK_SOURCE_FCLK (0 << 6)
862 +#define PWRMGT_HCLK_SOURCE_125MHZ (1 << 6)
864 +#define PWRMGT_PCLK_DIVIDER_BY_1 (0 << 8)
865 +#define PWRMGT_PCLK_DIVIDER_BY_2 (1 << 8)
866 +#define PWRMGT_PCLK_DIVIDER_BY_3 (2 << 8)
867 +#define PWRMGT_PCLK_DIVIDER_BY_4 (3 << 8)
869 +#define PWRMGT_PCICLK_DIVIDER_BY_1 (0 << 10)
870 +#define PWRMGT_PCICLK_DIVIDER_BY_2 (1 << 10)
871 +#define PWRMGT_PCICLK_DIVIDER_BY_3 (2 << 10)
872 +#define PWRMGT_PCICLK_DIVIDER_BY_4 (3 << 10)
875 +#define PWRMGT_PLLCLK_TO_CPUCLK_RATIO_BY_1 1
876 +#define PWRMGT_PLLCLK_TO_CPUCLK_RATIO_BY_2 2
877 +#define PWRMGT_PLLCLK_TO_CPUCLK_RATIO_BY_3 3
878 +#define PWRMGT_PLLCLK_TO_CPUCLK_RATIO_BY_4 4
880 +#define PWRMGT_CPUCLK_TO_HCLK_RATIO_BY_1 1
881 +#define PWRMGT_CPUCLK_TO_HCLK_RATIO_BY_2 2
882 +#define PWRMGT_CPUCLK_TO_HCLK_RATIO_BY_3 3
883 +#define PWRMGT_CPUCLK_TO_HCLK_RATIO_BY_4 4
885 +#define PWRMGT_HCLK_TO_PCLK_RATIO_BY_1 1
886 +#define PWRMGT_HCLK_TO_PCLK_RATIO_BY_2 2
887 +#define PWRMGT_HCLK_TO_PCLK_RATIO_BY_3 3
888 +#define PWRMGT_HCLK_TO_PCLK_RATIO_BY_4 4
891 + * Macro defines for Clock Gate Control
893 +#define HAL_PWRMGT_DISABLE_DRAMC_CLOCK() \
895 + PWRMGT_CLOCK_GATE_CONTROL0_REG &= ~(0x1); \
899 +#define HAL_PWRMGT_ENABLE_NIC_CLOCK() \
901 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 0); \
902 + PWRMGT_CLOCK_GATE_CONTROL0_REG |= (0x0F << 20); \
903 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 5); \
906 +#define HAL_PWRMGT_DISABLE_NIC_CLOCK() \
908 + PWRMGT_CLOCK_GATE_CONTROL0_REG &= ~(0x0F << 20); \
912 +#define HAL_PWRMGT_ENABLE_PCI_BRIDGE_33M_CLOCK() \
914 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 1); \
915 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3 << 10); \
916 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (0x1 << 10); \
917 + PWRMGT_CLOCK_GATE_CONTROL0_REG |= (0x1 << 28) | (0x1 << 30); \
918 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 7); \
921 +#define HAL_PWRMGT_ENABLE_PCI_BRIDGE_66M_CLOCK() \
923 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 1); \
924 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3 << 10); \
925 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (0x0 << 10); \
926 + PWRMGT_CLOCK_GATE_CONTROL0_REG |= (0x1 << 28) | (0x1 << 30); \
927 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 7); \
930 +#define HAL_PWRMGT_DISABLE_PCI_CLOCK() \
932 + PWRMGT_CLOCK_GATE_CONTROL0_REG &= ~((0x1 << 28) | (0x1 << 30)); \
936 +#define HAL_PWRMGT_ENABLE_USB_CLOCK() \
938 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0xF << 1); \
939 + PWRMGT_CLOCK_GATE_CONTROL0_REG |= (0x1 << 24); \
940 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 28); \
941 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 6) | (0x1 << 14); \
944 +#define HAL_PWRMGT_DISABLE_USB_CLOCK() \
946 + PWRMGT_CLOCK_GATE_CONTROL0_REG &= ~(0x1 << 24); \
947 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~(0x1 << 28); \
951 +#define HAL_PWRMGT_ENABLE_DMA_CLOCK() \
953 + PWRMGT_CLOCK_GATE_CONTROL0_REG |= (0x1 << 16); \
954 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 4); \
957 +#define HAL_PWRMGT_DISABLE_DMA_CLOCK() \
959 + PWRMGT_CLOCK_GATE_CONTROL0_REG &= ~(0x1 << 16); \
963 +#define HAL_PWRMGT_ENABLE_IDE_CLOCK() \
965 + PWRMGT_CLOCK_GATE_CONTROL0_REG |= (0x1 << 8) | (0x1 << 9); \
966 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 2); \
969 +#define HAL_PWRMGT_DISABLE_IDE_CLOCK() \
971 + PWRMGT_CLOCK_GATE_CONTROL0_REG &= ~((0x1 << 8) | (0x1 << 9)); \
975 +#define HAL_PWRMGT_ENABLE_UART0_CLOCK() \
977 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~((0x1 << 1) | (0x1 << 2) | (0x1 << 5)); \
978 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 12); \
979 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 9); \
982 +#define HAL_PWRMGT_DISABLE_UART0_CLOCK() \
984 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~(0x1 << 12); \
988 +#define HAL_PWRMGT_ENABLE_UART1_CLOCK() \
990 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~((0x1 << 1) | (0x1 << 2) | (0x1 << 5)); \
991 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 13); \
992 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 10); \
995 +#define HAL_PWRMGT_DISABLE_UART1_CLOCK() \
997 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~(0x1 << 13); \
1001 +#define HAL_PWRMGT_ENABLE_PCMCIA_CLOCK() \
1003 + PWRMGT_CLOCK_GATE_CONTROL0_REG |= (0x1 << 4) | (0x1 << 5); \
1006 +#define HAL_PWRMGT_DISABLE_PCMCIA_CLOCK() \
1008 + PWRMGT_CLOCK_GATE_CONTROL0_REG &= ~((0x1 << 4) | (0x1 << 5)); \
1012 +#define HAL_PWRMGT_ENABLE_GPIO_CLOCK() \
1014 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 25); \
1017 +#define HAL_PWRMGT_DISABLE_GPIO_CLOCK() \
1019 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~(0x1 << 25); \
1023 +#define HAL_PWRMGT_ENABLE_WDTIMER_CLOCK() \
1025 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 21) | (0x1 << 22); \
1028 +#define HAL_PWRMGT_DISABLE_WDTIMER_CLOCK() \
1030 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~((0x1 << 21) | (0x1 << 22)); \
1034 +#define HAL_PWRMGT_ENABLE_RTC_CLOCK() \
1036 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 23); \
1039 +#define HAL_PWRMGT_DISABLE_RTC_CLOCK() \
1041 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~(0x1 << 23); \
1045 +#define HAL_PWRMGT_ENABLE_TIMER_CLOCK() \
1047 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 17) | (0x1 << 18) | (0x1 << 19); \
1050 +#define HAL_PWRMGT_DISABLE_TIMER_CLOCK() \
1052 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~((0x1 << 17) | (0x1 << 18) | (0x1 << 19)); \
1056 +#define HAL_PWRMGT_ENABLE_I2C_CLOCK() \
1058 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 1); \
1061 +#define HAL_PWRMGT_DISABLE_I2C_CLOCK() \
1063 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~(0x1 << 1); \
1067 +#define HAL_PWRMGT_ENABLE_I2S_CLOCK() \
1069 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~((0x1 << 5) | (0x1 << 6)); \
1070 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 1) | (0x1 << 10); \
1071 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 8); \
1074 +#define HAL_PWRMGT_DISABLE_I2S_CLOCK() \
1076 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~((0x1 << 1) | (0x1 << 10)); \
1080 +#define HAL_PWRMGT_ENABLE_PCM_CLOCK() \
1082 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 5); \
1083 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 1) | (0x1 << 6); \
1084 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 8); \
1087 +#define HAL_PWRMGT_DISABLE_PCM_CLOCK() \
1089 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~((0x1 << 1) | (0x1 << 6)); \
1093 +#define HAL_PWRMGT_ENABLE_SPI_CLOCK() \
1095 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 0) | (0x1 << 1); \
1098 +#define HAL_PWRMGT_DISABLE_SPI_CLOCK() \
1100 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~((0x1 << 0) | (0x1 << 1)); \
1104 +#define HAL_PWRMGT_ENABLE_VIC_CLOCK() \
1106 + PWRMGT_CLOCK_GATE_CONTROL0_REG |= (0x1 << 12); \
1109 +#define HAL_PWRMGT_DISABLE_VIC_CLOCK() \
1111 + PWRMGT_CLOCK_GATE_CONTROL0_REG &= ~(0x1 << 12); \
1115 +#define HAL_PWRMGT_ENABLE_SMC_CLOCK() \
1117 + PWRMGT_CLOCK_GATE_CONTROL0_REG |= (0x1 << 4) | (0x1 << 5); \
1120 +#define HAL_PWRMGT_DISABLE_SMC_CLOCK() \
1122 + PWRMGT_CLOCK_GATE_CONTROL0_REG &= ~((0x1 << 4) | (0x1 << 5)); \
1126 +#define HAL_PWRMGT_ENABLE_HSDMA_CLOCK() \
1128 + PWRMGT_CLOCK_GATE_CONTROL1_REG |= (0x1 << 29); \
1129 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1 << 16); \
1132 +#define HAL_PWRMGT_DISABLE_HSDMA_CLOCK() \
1134 + PWRMGT_CLOCK_GATE_CONTROL1_REG &= ~(0x1 << 29); \
1140 + * Macro defines for Reset Control
1142 +#define HAL_PWRMGT_GLOBAL_SOFTWARE_RESET() \
1144 + PWRMGT_SOFTWARE_RESET_CONTROL_REG |= (0x1); \
1145 + PWRMGT_SOFTWARE_RESET_CONTROL_REG &= ~(0x1); \
1150 + * Macro defines for System Clock Control
1152 +#define HAL_PWRMGT_SET_PLL_FREQUENCY_175MHZ() \
1154 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~0x3; \
1158 +#define HAL_PWRMGT_SET_PLL_FREQUENCY_200MHZ() \
1160 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~0x3; \
1161 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= 0x1; \
1165 +#define HAL_PWRMGT_SET_PLL_FREQUENCY_225MHZ() \
1167 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~0x3; \
1168 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= 0x2; \
1172 +#define HAL_PWRMGT_SET_PLL_FREQUENCY_250MHZ() \
1174 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~0x3; \
1175 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= 0x3; \
1179 +#define HAL_PWRMGT_CONFIG_PLLCLK_TO_CPUCLK_RATIO(ratio) \
1181 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3 << 2); \
1182 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (((ratio - 1) & 0x3) << 2); \
1186 +#define HAL_PWRMGT_CONFIG_CPUCLK_TO_HCLK_RATIO(ratio) \
1188 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3 << 4); \
1189 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (((ratio - 1) & 0x3) << 4); \
1193 +#define HAL_PWRMGT_HCLK_SOURCE_FCLK() \
1195 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x1 << 6); \
1199 +#define HAL_PWRMGT_HCLK_SOURCE_125MHZ() \
1201 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (0x1 << 6); \
1205 +#define HAL_PWRMGT_GIGA_NIC_CLOCK_SOURCE_HCLK() \
1207 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x1 << 7); \
1211 +#define HAL_PWRMGT_GIGA_NIC_CLOCK_SOURCE_62_5MHZ() \
1213 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (0x1 << 7); \
1217 +#define HAL_PWRMGT_CONFIG_HCLK_TO_PCLK_RATIO(ratio) \
1219 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3 << 8); \
1220 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (((ratio - 1) & 0x3) << 8); \
1224 +#define HAL_PWRMGT_I2S_CLOCK_SOURCE_8192000HZ() \
1226 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3 << 12); \
1227 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (0x0 << 12); \
1231 +#define HAL_PWRMGT_I2S_CLOCK_SOURCE_11289600HZ() \
1233 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3 << 12); \
1234 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (0x1 << 12); \
1238 +#define HAL_PWRMGT_I2S_CLOCK_SOURCE_12288000HZ() \
1240 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3 << 12); \
1241 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= (0x2 << 12); \
1245 +#define HAL_PWRMGT_CONFIGURE_MDC_CLOCK_DIVIDER(divided_value) \
1247 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3 << 14); \
1248 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= ((divided_value & 0x3) << 14); \
1252 +#define HAL_PWRMGT_CONFIGURE_CLOCK_OUT_PIN(pin_source_select, divided_value) \
1254 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG &= ~(0x3F << 16); \
1255 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= ((pin_source_select & 0xF) << 16); \
1256 + PWRMGT_SYSTEM_CLOCK_CONTROL_REG |= ((divided_value & 0x3) << 20); \
1261 + * Macro defines for PLL Power Down Control
1263 +#define HAL_PWRMGT_POWER_DOWN_SYSTEM_XTAL_PAD() \
1264 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG |= (0x1 << 7)
1266 +#define HAL_PWRMGT_POWER_ON_SYSTEM_XTAL_PAD() \
1267 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 7)
1270 +#define HAL_PWRMGT_POWER_DOWN_PLL_X5() \
1271 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG |= (0x1 << 0)
1273 +#define HAL_PWRMGT_POWER_ON_PLL_X5() \
1274 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 0)
1277 +#define HAL_PWRMGT_POWER_DOWN_PLL_X8() \
1278 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG |= (0x1 << 1)
1280 +#define HAL_PWRMGT_POWER_ON_PLL_X8() \
1281 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 1)
1284 +#define HAL_PWRMGT_POWER_DOWN_PLL_X3() \
1285 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG |= (0x1 << 2)
1287 +#define HAL_PWRMGT_POWER_ON_PLL_X3() \
1288 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 2)
1291 +#define HAL_PWRMGT_POWER_DOWN_USBH_PHY_PLL() \
1292 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG |= (0x1 << 3)
1294 +#define HAL_PWRMGT_POWER_ON_USBH_PHY_PLL() \
1295 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 3)
1298 +#define HAL_PWRMGT_POWER_DOWN_USBD_PHY_PLL() \
1299 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG |= (0x1 << 4)
1301 +#define HAL_PWRMGT_POWER_ON_USBD_PHY_PLL() \
1302 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 4)
1305 +#define HAL_PWRMGT_POWER_DOWN_PLL_X2250() \
1306 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG |= (0x1 << 5)
1308 +#define HAL_PWRMGT_POWER_ON_PLL_X2250() \
1309 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 5)
1312 +#define HAL_PWRMGT_POWER_DOWN_PLL_X7() \
1313 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG |= (0x1 << 6)
1315 +#define HAL_PWRMGT_POWER_ON_PLL_X7() \
1316 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG &= ~(0x1 << 6)
1319 +#define HAL_PWRMGT_POWER_DOWN_ALL_PLL() \
1320 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG = 0x7F;
1322 +#define HAL_PWRMGT_POWER_ON_ALL_PLL() \
1323 + PWRMGT_PLL_POWER_DOWN_CONTROL_REG = 0;
1327 + * Macro defines for Pad Drive Strength Control
1329 +#define HAL_PWRMGT_SELECT_PAD_DRIVE_STRENGTH_PCMCIA_CARDBUS_MODE() \
1331 + PWRMGT_PAD_DRIVE_STRENGTH_CONTROL_REG &= ~(0x3 << 0); \
1334 +#define HAL_PWRMGT_SELECT_PAD_DRIVE_STRENGTH_PCI_MODE() \
1336 + PWRMGT_PAD_DRIVE_STRENGTH_CONTROL_REG &= ~(0x3 << 0); \
1337 + PWRMGT_PAD_DRIVE_STRENGTH_CONTROL_REG |= (0x1 << 0); \
1340 +#define HAL_PWRMGT_SELECT_PAD_DRIVE_STRENGTH_MII_MODE() \
1342 + PWRMGT_PAD_DRIVE_STRENGTH_CONTROL_REG |= (0x1 << 2); \
1345 +#define HAL_PWRMGT_SELECT_PAD_DRIVE_STRENGTH_RGMII_MODE() \
1347 + PWRMGT_PAD_DRIVE_STRENGTH_CONTROL_REG &= ~(0x1 << 2); \
1350 +#define HAL_PWRMGT_ENABLE_MII_PAD_SIGNAL_NOT_BOUNDED() \
1352 + PWRMGT_PAD_DRIVE_STRENGTH_CONTROL_REG |= (0x1 << 3); \
1355 +#define HAL_PWRMGT_DISABLE_MII_PAD_SIGNAL_NOT_BOUNDED() \
1357 + PWRMGT_PAD_DRIVE_STRENGTH_CONTROL_REG &= ~(0x1 << 3); \
1362 + * Macro defines for USB Device Power Management
1364 +#define HAL_PWRMGT_REMOTE_WAKEUP_USB_HOST() \
1366 + PWRMGT_USB_DEVICE_POWERMGT_REG |= (0x1 << 4); \
1369 +#define HAL_PWRMGT_USB_DEVICE_PHY_CLOCK_SOURCE_EXTERNAL_12MHZ() \
1371 + PWRMGT_USB_DEVICE_POWERMGT_REG &= ~(0x1 << 5); \
1374 +#define HAL_PWRMGT_USB_DEVICE_PHY_CLOCK_SOURCE_INTERNAL_12MHZ() \
1376 + PWRMGT_USB_DEVICE_POWERMGT_REG |= (0x1 << 5); \
1381 + * Macro defines for Regulator Control
1384 +#endif /* _CNS21XX_POWERMGMT_H */
1386 +++ b/arch/arm/mach-cns21xx/include/mach/cns21xx.h
1389 + * Copyright (c) 2008 Cavium Networks
1390 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
1392 + * This file is free software; you can redistribute it and/or modify
1393 + * it under the terms of the GNU General Public License, Version 2, as
1394 + * published by the Free Software Foundation.
1400 +#define CNS21XX_FLASH_BANK0_BASE 0x10000000
1401 +#define CNS21XX_FLASH_BANK1_BASE 0x11000000
1402 +#define CNS21XX_FLASH_BANK2_BASE 0x12000000
1403 +#define CNS21XX_FLASH_BANK3_BASE 0x13000000
1404 +#define CNS21XX_PCMCIA_ATTR_BASE 0x14000000
1405 +#define CNS21XX_PCMCIA_MEM_BASE 0x15000000
1406 +#define CNS21XX_PCMCIA_IO_BASE 0x16000000
1407 +#define CNS21XX_IDE_DEVICE_BASE 0x18000000
1408 +#define CNS21XX_SDRAM_MEMORY_BASE 0x20000000
1409 +#define CNS21XX_GDMAC_BASE 0x60000000
1410 +#define CNS21XX_NIC_BASE 0x70000000
1411 +#define CNS21XX_SPI_BASE 0x71000000
1412 +#define CNS21XX_PCM_BASE 0x71000000
1413 +#define CNS21XX_I2C_BASE 0x71000000
1414 +#define CNS21XX_I2S_BASE 0x71000000
1415 +#define CNS21XX_DDRC_BASE 0x72000000
1416 +#define CNS21XX_SMC_BASE 0x73000000
1417 +#define CNS21XX_PCMCIA_CTRL_BASE 0x73000000
1418 +#define CNS21XX_IDE_CTRL_BASE 0x74000000
1419 +#define CNS21XX_MISC_BASE 0x76000000
1420 +#define CNS21XX_CPM_BASE 0x77000000
1421 +#define CNS21XX_UART0_BASE 0x78000000
1422 +#define CNS21XX_UART1_BASE 0x78800000
1423 +#define CNS21XX_TIMER_BASE 0x79000000
1424 +#define CNS21XX_WDT_BASE 0x7a000000
1425 +#define CNS21XX_RTC_BASE 0x7b000000
1426 +#define CNS21XX_GPIOA_BASE 0x7c000000
1427 +#define CNS21XX_GPIOB_BASE 0x7c800000
1428 +#define CNS21XX_PCI_CFGDATA_BASE 0xa0000000
1429 +#define CNS21XX_PCI_CFGADDR_BASE 0xa4000000
1430 +#define CNS21XX_PCI_IO_BASE 0xa8000000
1431 +#define CNS21XX_PCI_MEMORY_BASE 0xb0000000
1432 +#define CNS21XX_OHCI_CONFIG_BASE 0xc0000000
1433 +#define CNS21XX_OHCI_CTRL_BASE 0xc4000000
1434 +#define CNS21XX_EHCI_CONFIG_BASE 0xc8000000
1435 +#define CNS21XX_EHCI_CTRL_BASE 0xcc000000
1436 +#define CNS21XX_USB_DEVICE_BASE 0xd0000000
1437 +#define CNS21XX_INTC_BASE 0xfffff000
1439 +#define CNS21XX_FLASH_BANK0_BASE_VIRT 0xe0000000
1440 +#define CNS21XX_FLASH_BANK1_BASE_VIRT 0xe2000000
1441 +#define CNS21XX_FLASH_BANK2_BASE_VIRT 0xe4000000
1442 +#define CNS21XX_FLASH_BANK3_BASE_VIRT 0xe8000000
1443 +#define CNS21XX_IDE_DEVICE_BASE_VIRT 0xfff00000
1444 +#define CNS21XX_GDMAC_BASE_VIRT 0xfff01000
1445 +#define CNS21XX_NIC_BASE_VIRT 0xfff02000
1446 +#define CNS21XX_SPI_BASE_VIRT 0xfff03000
1447 +#define CNS21XX_PCM_BASE_VIRT 0xfff04000
1448 +#define CNS21XX_I2C_BASE_VIRT 0xfff05000
1449 +#define CNS21XX_I2S_BASE_VIRT 0xfff06000
1450 +#define CNS21XX_DDRC_BASE_VIRT 0xfff07000
1451 +#define CNS21XX_SMC_BASE_VIRT 0xfff08000
1452 +#define CNS21XX_PCMCIA_CTRL_BASE_VIRT 0xfff09000
1453 +#define CNS21XX_IDE_CTRL_BASE_VIRT 0xfff0A000
1454 +#define CNS21XX_MISC_BASE_VIRT 0xfff0B000
1455 +#define CNS21XX_CPM_BASE_VIRT 0xfff0C000
1456 +#define CNS21XX_UART0_BASE_VIRT 0xfff0D000
1457 +#define CNS21XX_UART1_BASE_VIRT 0xfff0E000
1458 +#define CNS21XX_TIMER_BASE_VIRT 0xfff0F000
1459 +#define CNS21XX_WDT_BASE_VIRT 0xfff10000
1460 +#define CNS21XX_RTC_BASE_VIRT 0xfff11000
1461 +#define CNS21XX_GPIOA_BASE_VIRT 0xfff12000
1462 +#define CNS21XX_GPIOB_BASE_VIRT 0xfff13000
1463 +#define CNS21XX_PCI_CFGDATA_BASE_VIRT 0xfff14000
1464 +#define CNS21XX_PCI_CFGADDR_BASE_VIRT 0xfff15000
1465 +#define CNS21XX_OHCI_CONFIG_BASE_VIRT 0xfff16000
1466 +#define CNS21XX_OHCI_CTRL_BASE_VIRT 0xfff17000
1467 +#define CNS21XX_EHCI_CONFIG_BASE_VIRT 0xfff18000
1468 +#define CNS21XX_EHCI_CTRL_BASE_VIRT 0xfff19000
1469 +#define CNS21XX_USB_DEVICE_BASE_VIRT 0xfff1a000
1470 +#define CNS21XX_INTC_BASE_VIRT 0xfff1b000
1472 +#define CNS21XX_PHYS_IO CNS21XX_UART0_BASE
1473 +#define CNS21XX_IO_PAGE_OFFSET ((CNS21XX_UART0_BASE_VIRT) >> 18) & 0xfffc
1475 +#endif /* _CNS21XX_H */
1477 +++ b/arch/arm/mach-cns21xx/core.c
1480 + * Copyright (c) 2008 Cavium Networks
1481 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
1483 + * This file is free software; you can redistribute it and/or modify
1484 + * it under the terms of the GNU General Public License, Version 2, as
1485 + * published by the Free Software Foundation.
1488 +#include <linux/kernel.h>
1490 +#include <mach/hardware.h>
1491 +#include <mach/cns21xx.h>
1492 +#include <mach/cns21xx_powermgmt.h>
1494 +static unsigned long cns21xx_pll_freq;
1495 +static unsigned long cns21xx_cpu_freq;
1496 +static unsigned long cns21xx_ahb_freq;
1497 +static unsigned long cns21xx_apb_freq;
1499 +static void cns21xx_init_freq(void)
1501 + static int freq_init_done;
1504 + if (freq_init_done)
1507 + t = PWRMGT_SYSTEM_CLOCK_CONTROL_REG;
1508 + switch (t & 0x3) {
1510 + cns21xx_pll_freq = 175000000;
1514 + cns21xx_pll_freq = 200000000;
1518 + cns21xx_pll_freq = 225000000;
1522 + cns21xx_pll_freq = 250000000;
1526 + cns21xx_cpu_freq = cns21xx_pll_freq / (((t >> 2) & 0x3) + 1);
1527 + cns21xx_ahb_freq = cns21xx_cpu_freq / (((t >> 4) & 0x3) + 1);
1528 + cns21xx_apb_freq = cns21xx_ahb_freq / (((t >> 8) & 0x3) + 1);
1530 + freq_init_done = 1;
1533 +unsigned long cns21xx_get_pll_freq(void)
1535 + cns21xx_init_freq();
1536 + return cns21xx_pll_freq;
1539 +unsigned long cns21xx_get_cpu_freq(void)
1541 + cns21xx_init_freq();
1542 + return cns21xx_cpu_freq;
1545 +unsigned long cns21xx_get_ahb_freq(void)
1547 + cns21xx_init_freq();
1548 + return cns21xx_ahb_freq;
1551 +unsigned long cns21xx_get_apb_freq(void)
1553 + cns21xx_init_freq();
1554 + return cns21xx_apb_freq;
1556 --- a/arch/arm/mm/Kconfig
1557 +++ b/arch/arm/mm/Kconfig
1558 @@ -807,6 +807,7 @@ config CACHE_XSC3L2
1559 config ARM_L1_CACHE_SHIFT
1561 default 6 if ARM_L1_CACHE_SHIFT_6
1562 + default 4 if ARM_L1_CACHE_SHIFT_4
1565 config ARM_DMA_MEM_BUFFERABLE
1566 --- a/arch/arm/mm/cache-fa.S
1567 +++ b/arch/arm/mm/cache-fa.S
1570 * The total size of the data cache.
1572 -#ifdef CONFIG_ARCH_GEMINI
1573 +#if (defined(CONFIG_ARCH_GEMINI) || defined(CONFIG_ARCH_CNS21XX))
1574 #define CACHE_DSIZE 8192
1576 #define CACHE_DSIZE 16384
1578 +++ b/arch/arm/mach-cns21xx/include/mach/cns21xx_misc.h
1580 +/*******************************************************************************
1582 + * Copyright (c) 2008 Cavium Networks
1584 + * This file is free software; you can redistribute it and/or modify
1585 + * it under the terms of the GNU General Public License, Version 2, as
1586 + * published by the Free Software Foundation.
1588 + * This file is distributed in the hope that it will be useful,
1589 + * but AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty of
1590 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
1591 + * NONINFRINGEMENT. See the GNU General Public License for more details.
1593 + * You should have received a copy of the GNU General Public License
1594 + * along with this file; if not, write to the Free Software
1595 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA or
1596 + * visit http://www.gnu.org/licenses/.
1598 + * This file may also be available under a different license from Cavium.
1599 + * Contact Cavium Networks for more information
1601 + ******************************************************************************/
1603 +#ifndef _STAR_MISC_H_
1604 +#define _STAR_MISC_H_
1606 +#include <mach/cns21xx.h>
1608 +#define MISC_MEM_MAP_VALUE(reg_offset) \
1609 + (*((u32 volatile *)(CNS21XX_MISC_BASE_VIRT + reg_offset)))
1612 + * define access macros
1614 +#define MISC_MEMORY_REMAP_REG MISC_MEM_MAP_VALUE(0x00)
1615 +#define MISC_CHIP_CONFIG_REG MISC_MEM_MAP_VALUE(0x04)
1616 +#define MISC_DEBUG_PROBE_DATA_REG MISC_MEM_MAP_VALUE(0x08)
1617 +#define MISC_DEBUG_PROBE_SELECTION_REG MISC_MEM_MAP_VALUE(0x0C)
1618 +#define MISC_PCI_CONTROL_BROKEN_MASK_REG MISC_MEM_MAP_VALUE(0x10)
1619 +#define MISC_PCI_BROKEN_STATUS_REG MISC_MEM_MAP_VALUE(0x14)
1620 +#define MISC_PCI_DEVICE_VENDOR_ID_REG MISC_MEM_MAP_VALUE(0x18)
1621 +#define MISC_USB_HOST_PHY_CONTROL_TEST_REG MISC_MEM_MAP_VALUE(0x1C)
1622 +#define MISC_GPIOA_PIN_ENABLE_REG MISC_MEM_MAP_VALUE(0x20)
1623 +#define MISC_GPIOB_PIN_ENABLE_REG MISC_MEM_MAP_VALUE(0x24)
1624 +#define MISC_GPIOA_RESISTOR_CONFIG_REG MISC_MEM_MAP_VALUE(0x28)
1625 +#define MISC_GPIOA_DRIVE_STRENGTH_CONFIG_REG MISC_MEM_MAP_VALUE(0x2C)
1626 +#define MISC_FAST_ETHERNET_PHY_CONFIG_REG MISC_MEM_MAP_VALUE(0x30)
1627 +#define MISC_SOFTWARE_TEST_1_REG MISC_MEM_MAP_VALUE(0x38)
1628 +#define MISC_SOFTWARE_TEST_2_REG MISC_MEM_MAP_VALUE(0x3C)
1630 +#define MISC_E_FUSE_0_REG MISC_MEM_MAP_VALUE(0x60)
1631 +#define MISC_E_FUSE_1_REG MISC_MEM_MAP_VALUE(0x64)
1635 + * define constants macros
1637 +#define MISC_PARALLEL_FLASH_BOOT 0
1638 +#define MISC_SPI_SERIAL_FLASH_BOOT 1
1640 +#define MISC_LITTLE_ENDIAN 0
1641 +#define MISC_BIG_ENDIAN 1
1643 +#define MISC_FARADAY_ICE 0
1644 +#define MISC_ARM_ICE 1
1646 +#define MISC_EXT_INT29_PINS ((0x1 << 0))
1647 +#define MISC_EXT_INT30_PINS ((0x1 << 1))
1648 +#define MISC_EXT_INT31_PINS ((0x1 << 2))
1649 +#define MISC_I2C_PINS ((0x1 << 13) | (0x1 << 14))
1650 +#define MISC_I2S_PINS ((0x1 << 15) | (0x1 << 16) | (0x1 << 17))
1651 +#define MISC_I2SSD_PINS (1 << 15)
1652 +#define MISC_I2SWS_PINS (1 << 16)
1653 +#define MISC_I2SCLK_PINS (1 << 17)
1654 +#define MISC_PCM_PINS ((0x1 << 18) | (0x1 << 19) | (0x1 << 20) | (0x1 << 21))
1655 +#define MISC_PCMDR_PINS (1 << 18)
1656 +#define MISC_PCMDT_PINS (1 << 19)
1657 +#define MISC_PCMFS_PINS (1 << 20)
1658 +#define MISC_PCMCLK_PINS (1 << 21)
1659 +#define MISC_LED0_PINS ((0x1 << 22))
1660 +#define MISC_LED1_PINS ((0x1 << 23))
1661 +#define MISC_LED2_PINS ((0x1 << 24))
1662 +#define MISC_LED012_PINS ((0x1 << 22) | (0x1 << 23) | (0x1 << 24))
1663 +#define MISC_WDTIMER_RESET_PINS ((0x1 << 25))
1664 +#define MISC_SPIDR_PINS (0x1 << 26)
1665 +#define MISC_SPICLK_PINS (0x1 << 27)
1666 +#define MISC_SPICSN0_PINS (0x1 << 28)
1667 +#define MISC_SPICSN1_PINS (0x1 << 29)
1668 +#define MISC_SPICSN2_PINS (0x1 << 30)
1669 +#define MISC_SPICSN3_PINS (0x1 << 31)
1670 +#define MISC_SPI_PINS ((0x1 << 26) | (0x1 << 27) | (0x1 << 28) | (0x1 << 29) | (0x1 << 30) | (0x1 << 31))
1671 +#define MISC_MDC_MDIO_PINS ((0x1 << 0) | (0x1 << 1))
1672 +#define MISC_NIC_COL_PINS ((0x1 << 2))
1673 +#define MISC_IDE_PINS ((0xFF << 3))
1674 +#define MISC_SRAM_BANK1_PINS ((0x1 << 11) | (0x1 << 14))
1675 +#define MISC_SRAM_BANK2_PINS ((0x1 << 12) | (0x1 << 15))
1676 +#define MISC_SRAM_BANK3_PINS ((0x1 << 13) | (0x1 << 16))
1677 +#define MISC_PCMCIA_PINS ((0x1 << 17) | (0x1 << 18) | (0x1 << 19) | (0x1 << 20))
1678 +#define MISC_UART1_PINS ((0x1 << 21) | (0x1 << 22))
1679 +#define MISC_PCI_PINS (((u32)0x1FF << 23))
1681 +#define MISC_UART0_ACT0_Pin (0x1 << 2)
1682 +#define MISC_UART1_ACT1_Pin (0x1 << 3)
1684 +#define MISC_GPIOA_PIN_0 0
1685 +#define MISC_GPIOA_PIN_1 1
1686 +#define MISC_GPIOA_PIN_2 2
1687 +#define MISC_GPIOA_PIN_3 3
1688 +#define MISC_GPIOA_PIN_4 4
1689 +#define MISC_GPIOA_PIN_5 5
1690 +#define MISC_GPIOA_PIN_6 6
1691 +#define MISC_GPIOA_PIN_7 7
1692 +#define MISC_GPIOA_PIN_8 8
1693 +#define MISC_GPIOA_PIN_9 9
1694 +#define MISC_GPIOA_PIN_10 10
1696 +#define MISC_GPIOA_75K_RESISTOR_PULL_DOWN 1
1697 +#define MISC_GPIOA_75K_RESISTOR_PULL_UP 2
1698 +#define MISC_GPIOA_75K_RESISTOR_PULL_KEEPER 3
1700 +#define MISC_GPIOA_DRIVE_STRENGTH_4MA 0
1701 +#define MISC_GPIOA_DRIVE_STRENGTH_8MA 1
1705 + * macro declarations
1707 +#define HAL_MISC_ENABLE_SPI_SERIAL_FLASH_BANK_ACCESS() \
1709 + (MISC_CHIP_CONFIG_REG) |= (0x1 << 4); \
1712 +#define HAL_MISC_DISABLE_SPI_SERIAL_FLASH_BANK_ACCESS() \
1714 + (MISC_CHIP_CONFIG_REG) &= ~(0x1 << 4); \
1719 + * Macro defines for GPIOA and GPIOB Pin Enable Register
1721 +#define HAL_MISC_ENABLE_EXT_INT29_PINS() \
1723 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_EXT_INT29_PINS); \
1726 +#define HAL_MISC_DISABLE_EXT_INT29_PINS() \
1728 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_EXT_INT29_PINS); \
1731 +#define HAL_MISC_ENABLE_EXT_INT30_PINS() \
1733 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_EXT_INT30_PINS); \
1736 +#define HAL_MISC_DISABLE_EXT_INT30_PINS() \
1738 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_EXT_INT30_PINS); \
1741 +#define HAL_MISC_ENABLE_I2C_PINS() \
1743 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_I2C_PINS); \
1746 +#define HAL_MISC_DISABLE_I2C_PINS() \
1748 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_I2C_PINS); \
1751 +#define HAL_MISC_ENABLE_I2S_PINS() \
1753 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_I2S_PINS); \
1756 +#define HAL_MISC_DISABLE_I2S_PINS() \
1758 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_I2S_PINS); \
1761 +#define HAL_MISC_DISABLE_I2SSD_PINS() \
1763 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_I2SSD_PINS); \
1766 +#define HAL_MISC_DISABLE_I2SWS_PINS() \
1768 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_I2SWS_PINS); \
1771 +#define HAL_MISC_DISABLE_I2SCLK_PINS() \
1773 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_I2SCLK_PINS); \
1776 +#define HAL_MISC_ENABLE_PCM_PINS() \
1778 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_PCM_PINS); \
1781 +#define HAL_MISC_DISABLE_PCM_PINS() \
1783 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_PCM_PINS); \
1786 +#define HAL_MISC_DISABLE_PCMDR_PINS() \
1788 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_PCMDR_PINS); \
1791 +#define HAL_MISC_DISABLE_PCMDT_PINS() \
1793 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_PCMDT_PINS); \
1796 +#define HAL_MISC_DISABLE_PCMFS_PINS() \
1798 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_PCMFS_PINS); \
1801 +#define HAL_MISC_DISABLE_PCMCLK_PINS() \
1803 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_PCMCLK_PINS); \
1806 +#define HAL_MISC_ENABLE_LED0_PINS() \
1808 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_LED0_PINS); \
1811 +#define HAL_MISC_DISABLE_LED0_PINS() \
1813 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_LED0_PINS); \
1816 +#define HAL_MISC_ENABLE_LED1_PINS() \
1818 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_LED1_PINS); \
1821 +#define HAL_MISC_DISABLE_LED1_PINS() \
1823 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_LED1_PINS); \
1826 +#define HAL_MISC_ENABLE_LED2_PINS() \
1828 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_LED2_PINS); \
1831 +#define HAL_MISC_DISABLE_LED2_PINS() \
1833 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_LED2_PINS); \
1836 +#define HAL_MISC_ENABLE_LED012_PINS() \
1838 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_LED012_PINS); \
1841 +#define HAL_MISC_DISABLE_LED012_PINS() \
1843 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_LED012_PINS); \
1846 +#define HAL_MISC_ENABLE_WDTIMER_RESET_PINS() \
1848 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_WDTIMER_RESET_PINS); \
1851 +#define HAL_MISC_DISABLE_WDTIMER_RESET_PINS() \
1853 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_WDTIMER_RESET_PINS); \
1856 +#define HAL_MISC_ENABLE_SPI_PINS() \
1858 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_SPI_PINS); \
1861 +#define HAL_MISC_ENABLE_SPIDR_PINS() \
1863 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_SPIDR_PINS); \
1866 +#define HAL_MISC_ENABLE_SPICLK_PINS() \
1868 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_SPICLK_PINS); \
1871 +#define HAL_MISC_ENABLE_SPICSN0_PINS() \
1873 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_SPICSN0_PINS); \
1876 +#define HAL_MISC_ENABLE_SPICSN0_PINS() \
1878 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_SPICSN0_PINS); \
1881 +#define HAL_MISC_ENABLE_SPICSN1_PINS() \
1883 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_SPICSN1_PINS); \
1886 +#define HAL_MISC_ENABLE_SPICSN2_PINS() \
1888 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_SPICSN2_PINS); \
1891 +#define HAL_MISC_ENABLE_SPICSN3_PINS() \
1893 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_SPICSN3_PINS); \
1896 +#define HAL_MISC_DISABLE_SPI_PINS() \
1898 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_SPI_PINS); \
1901 +#define HAL_MISC_DISABLE_SPIDR_PINS() \
1903 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_SPIDR_PINS); \
1906 +#define HAL_MISC_DISABLE_SPICLK_PINS() \
1908 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_SPICLK_PINS); \
1911 +#define HAL_MISC_DISABLE_SPICSN0_PINS() \
1913 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_SPICSN0_PINS); \
1916 +#define HAL_MISC_DISABLE_SPICSN1_PINS() \
1918 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_SPICSN1_PINS); \
1921 +#define HAL_MISC_DISABLE_SPICSN2_PINS() \
1923 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_SPICSN2_PINS); \
1926 +#define HAL_MISC_DISABLE_SPICSN3_PINS() \
1928 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_SPICSN3_PINS); \
1931 +#define HAL_MISC_ENABLE_UART0_ACT0_PIN() \
1933 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_UART0_ACT0_Pin); \
1936 +#define HAL_MISC_DISABLE_UART0_ACT0_PIN() \
1938 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_UART0_ACT0_Pin); \
1941 +#define HAL_MISC_ENABLE_UART1_ACT1_PIN() \
1943 + (MISC_GPIOA_PIN_ENABLE_REG) |= (MISC_UART1_ACT1_Pin); \
1946 +#define HAL_MISC_DISABLE_UART1_ACT1_PIN() \
1948 + (MISC_GPIOA_PIN_ENABLE_REG) &= ~(MISC_UART1_ACT1_Pin); \
1951 +#define HAL_MISC_ENABLE_MDC_MDIO_PINS() \
1953 + (MISC_GPIOB_PIN_ENABLE_REG) |= (MISC_MDC_MDIO_PINS); \
1956 +#define HAL_MISC_DISABLE_MDC_MDIO_PINS() \
1958 + (MISC_GPIOB_PIN_ENABLE_REG) &= ~(MISC_MDC_MDIO_PINS); \
1961 +#define HAL_MISC_ENABLE_NIC_COL_PINS() \
1963 + (MISC_GPIOB_PIN_ENABLE_REG) |= (MISC_NIC_COL_PINS); \
1966 +#define HAL_MISC_DISABLE_NIC_COL_PINS() \
1968 + (MISC_GPIOB_PIN_ENABLE_REG) &= ~(MISC_NIC_COL_PINS); \
1971 +#define HAL_MISC_ENABLE_IDE_PINS() \
1973 + (MISC_GPIOB_PIN_ENABLE_REG) |= (MISC_IDE_PINS); \
1976 +#define HAL_MISC_DISABLE_IDE_PINS() \
1978 + (MISC_GPIOB_PIN_ENABLE_REG) &= ~(MISC_IDE_PINS); \
1981 +#define HAL_MISC_ENABLE_SRAM_BANK1_PINS() \
1983 + (MISC_GPIOB_PIN_ENABLE_REG) |= (MISC_SRAM_BANK1_PINS); \
1986 +#define HAL_MISC_DISABLE_SRAM_BANK1_PINS() \
1988 + (MISC_GPIOB_PIN_ENABLE_REG) &= ~(MISC_SRAM_BANK1_PINS); \
1991 +#define HAL_MISC_ENABLE_SRAM_BANK2_PINS() \
1993 + (MISC_GPIOB_PIN_ENABLE_REG) |= (MISC_SRAM_BANK2_PINS); \
1996 +#define HAL_MISC_DISABLE_SRAM_BANK2_PINS() \
1998 + (MISC_GPIOB_PIN_ENABLE_REG) &= ~(MISC_SRAM_BANK2_PINS); \
2001 +#define HAL_MISC_ENABLE_SRAM_BANK3_PINS() \
2003 + (MISC_GPIOB_PIN_ENABLE_REG) |= (MISC_SRAM_BANK3_PINS); \
2006 +#define HAL_MISC_DISABLE_SRAM_BANK3_PINS() \
2008 + (MISC_GPIOB_PIN_ENABLE_REG) &= ~(MISC_SRAM_BANK3_PINS); \
2011 +#define HAL_MISC_ENABLE_PCMCIA_PINS() \
2013 + (MISC_GPIOB_PIN_ENABLE_REG) |= (MISC_PCMCIA_PINS); \
2016 +#define HAL_MISC_DISABLE_PCMCIA_PINS() \
2018 + (MISC_GPIOB_PIN_ENABLE_REG) &= ~(MISC_PCMCIA_PINS); \
2021 +#define HAL_MISC_ENABLE_UART1_PINS() \
2023 + (MISC_GPIOB_PIN_ENABLE_REG) |= (MISC_UART1_PINS); \
2026 +#define HAL_MISC_DISABLE_UART1_PINS() \
2028 + (MISC_GPIOB_PIN_ENABLE_REG) &= ~(MISC_UART1_PINS); \
2031 +#define HAL_MISC_ENABLE_PCI_PINS() \
2033 + (MISC_GPIOB_PIN_ENABLE_REG) |= (MISC_PCI_PINS); \
2036 +#define HAL_MISC_DISABLE_PCI_PINS() \
2038 + (MISC_GPIOB_PIN_ENABLE_REG) &= ~(MISC_PCI_PINS); \
2041 +#define HAL_MISC_ENABLE_ALL_SHARED_GPIO_PINS() \
2043 + (MISC_GPIOA_PIN_ENABLE_REG) = (0x0); \
2044 + (MISC_GPIOB_PIN_ENABLE_REG) = (0x0); \
2047 +#define HAL_MISC_DISABLE_ALL_SHARED_GPIO_PINS() \
2049 + (MISC_GPIOA_PIN_ENABLE_REG) = (0xFFFFFFFF); \
2050 + (MISC_GPIOB_PIN_ENABLE_REG) = (0xFFFFFFFF); \
2053 +#define HAL_MISC_CONFIGURE_GPIOA_RESISTOR(pin_index, value) \
2055 + (MISC_GPIOA_RESISTOR_CONFIG_REG) &= ~(0x3 << (2 * pin_index)); \
2056 + (MISC_GPIOA_RESISTOR_CONFIG_REG) |= ((value & 0x3) << (2 * pin_index)); \
2059 +#define HAL_MISC_CONFIGURE_GPIOA_DRIVE_STRENGTH(pin_index, value) \
2061 + (MISC_GPIOA_DRIVE_STRENGTH_CONFIG_REG) &= ~(0x1 << pin_index); \
2062 + (MISC_GPIOA_DRIVE_STRENGTH_CONFIG_REG) |= (value << pin_index); \
2065 +#define HAL_MISC_SELECT_FAST_ETHERNET_PHY_LED_MODE0() \
2067 + (MISC_FAST_ETHERNET_PHY_CONFIG_REG) = (0x0); \
2070 +#define HAL_MISC_SELECT_FAST_ETHERNET_PHY_LED_MODE1() \
2072 + (MISC_FAST_ETHERNET_PHY_CONFIG_REG) = (0x1); \
2075 +#define HAL_MISC_SELECT_FAST_ETHERNET_PHY_LED_MODE2() \
2077 + (MISC_FAST_ETHERNET_PHY_CONFIG_REG) = (0x2); \
2080 +#define HAL_MISC_SELECT_FAST_ETHERNET_PHY_LED_MODE3() \
2082 + (MISC_FAST_ETHERNET_PHY_CONFIG_REG) = (0x3); \
2086 +#endif // end of #ifndef _STAR_MISC_H_