1 From 9e0235e97ea2617beaacaa16ab5f0b9e75f4680e Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 30 Mar 2011 09:27:47 +0200
4 Subject: [PATCH 01/13] MIPS: Lantiq: Add initial support for Lantiq SoCs
6 Add initial support for Mips based SoCs made by Lantiq. This series will add
7 support for the XWAY family.
9 The series allows booting a minimal system using a initramfs or NOR. Missing
10 drivers and support for Amazon and GPON family will be provided in a later
13 [Ralf: Remove some cargo cult programming and fixed formatting.]
15 Signed-off-by: John Crispin <blogic@openwrt.org>
16 Signed-off-by: Ralph Hempel <ralph.hempel@lantiq.com>
17 Signed-off-by: David Daney <ddaney@caviumnetworks.com>
18 Cc: linux-mips@linux-mips.org
19 Patchwork: https://patchwork.linux-mips.org/patch/2252/
20 Patchwork: https://patchwork.linux-mips.org/patch/2371/
21 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
23 arch/mips/Kbuild.platforms | 1 +
24 arch/mips/Kconfig | 17 ++
25 arch/mips/include/asm/mach-lantiq/lantiq.h | 63 ++++++
26 arch/mips/include/asm/mach-lantiq/war.h | 24 ++
27 arch/mips/lantiq/Makefile | 9 +
28 arch/mips/lantiq/Platform | 7 +
29 arch/mips/lantiq/clk.c | 140 ++++++++++++
30 arch/mips/lantiq/clk.h | 18 ++
31 arch/mips/lantiq/early_printk.c | 33 +++
32 arch/mips/lantiq/irq.c | 326 ++++++++++++++++++++++++++++
33 arch/mips/lantiq/prom.c | 71 ++++++
34 arch/mips/lantiq/prom.h | 24 ++
35 arch/mips/lantiq/setup.c | 41 ++++
36 13 files changed, 774 insertions(+), 0 deletions(-)
37 create mode 100644 arch/mips/include/asm/mach-lantiq/lantiq.h
38 create mode 100644 arch/mips/include/asm/mach-lantiq/war.h
39 create mode 100644 arch/mips/lantiq/Makefile
40 create mode 100644 arch/mips/lantiq/Platform
41 create mode 100644 arch/mips/lantiq/clk.c
42 create mode 100644 arch/mips/lantiq/clk.h
43 create mode 100644 arch/mips/lantiq/early_printk.c
44 create mode 100644 arch/mips/lantiq/irq.c
45 create mode 100644 arch/mips/lantiq/prom.c
46 create mode 100644 arch/mips/lantiq/prom.h
47 create mode 100644 arch/mips/lantiq/setup.c
49 --- a/arch/mips/Kconfig
50 +++ b/arch/mips/Kconfig
51 @@ -212,6 +212,23 @@ config MACH_JZ4740
56 + bool "Lantiq based platforms"
57 + select DMA_NONCOHERENT
61 + select SYS_HAS_CPU_MIPS32_R1
62 + select SYS_HAS_CPU_MIPS32_R2
63 + select SYS_SUPPORTS_BIG_ENDIAN
64 + select SYS_SUPPORTS_32BIT_KERNEL
65 + select SYS_SUPPORTS_MULTITHREADING
66 + select SYS_HAS_EARLY_PRINTK
67 + select ARCH_REQUIRE_GPIOLIB
68 + select SWAP_IO_SPACE
73 bool "LASAT Networks platforms"
76 +++ b/arch/mips/include/asm/mach-lantiq/lantiq.h
79 + * This program is free software; you can redistribute it and/or modify it
80 + * under the terms of the GNU General Public License version 2 as published
81 + * by the Free Software Foundation.
83 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
88 +#include <linux/irq.h>
90 +/* generic reg access functions */
91 +#define ltq_r32(reg) __raw_readl(reg)
92 +#define ltq_w32(val, reg) __raw_writel(val, reg)
93 +#define ltq_w32_mask(clear, set, reg) \
94 + ltq_w32((ltq_r32(reg) & ~(clear)) | (set), reg)
95 +#define ltq_r8(reg) __raw_readb(reg)
96 +#define ltq_w8(val, reg) __raw_writeb(val, reg)
98 +/* register access macros for EBU and CGU */
99 +#define ltq_ebu_w32(x, y) ltq_w32((x), ltq_ebu_membase + (y))
100 +#define ltq_ebu_r32(x) ltq_r32(ltq_ebu_membase + (x))
101 +#define ltq_cgu_w32(x, y) ltq_w32((x), ltq_cgu_membase + (y))
102 +#define ltq_cgu_r32(x) ltq_r32(ltq_cgu_membase + (x))
104 +extern __iomem void *ltq_ebu_membase;
105 +extern __iomem void *ltq_cgu_membase;
107 +extern unsigned int ltq_get_cpu_ver(void);
108 +extern unsigned int ltq_get_soc_type(void);
111 +#define CLOCK_60M 60000000
112 +#define CLOCK_83M 83333333
113 +#define CLOCK_111M 111111111
114 +#define CLOCK_133M 133333333
115 +#define CLOCK_167M 166666667
116 +#define CLOCK_200M 200000000
117 +#define CLOCK_266M 266666666
118 +#define CLOCK_333M 333333333
119 +#define CLOCK_400M 400000000
121 +/* spinlock all ebu i/o */
122 +extern spinlock_t ebu_lock;
124 +/* some irq helpers */
125 +extern void ltq_disable_irq(struct irq_data *d);
126 +extern void ltq_mask_and_ack_irq(struct irq_data *d);
127 +extern void ltq_enable_irq(struct irq_data *d);
129 +/* find out what caused the last cpu reset */
130 +extern int ltq_reset_cause(void);
131 +#define LTQ_RST_CAUSE_WDTRST 0x20
133 +#define IOPORT_RESOURCE_START 0x10000000
134 +#define IOPORT_RESOURCE_END 0xffffffff
135 +#define IOMEM_RESOURCE_START 0x10000000
136 +#define IOMEM_RESOURCE_END 0xffffffff
137 +#define LTQ_FLASH_START 0x10000000
138 +#define LTQ_FLASH_MAX 0x04000000
142 +++ b/arch/mips/include/asm/mach-lantiq/war.h
145 + * This file is subject to the terms and conditions of the GNU General Public
146 + * License. See the file "COPYING" in the main directory of this archive
147 + * for more details.
150 +#ifndef __ASM_MIPS_MACH_LANTIQ_WAR_H
151 +#define __ASM_MIPS_MACH_LANTIQ_WAR_H
153 +#define R4600_V1_INDEX_ICACHEOP_WAR 0
154 +#define R4600_V1_HIT_CACHEOP_WAR 0
155 +#define R4600_V2_HIT_CACHEOP_WAR 0
156 +#define R5432_CP0_INTERRUPT_WAR 0
157 +#define BCM1250_M3_WAR 0
158 +#define SIBYTE_1956_WAR 0
159 +#define MIPS4K_ICACHE_REFILL_WAR 0
160 +#define MIPS_CACHE_SYNC_WAR 0
161 +#define TX49XX_ICACHE_INDEX_INV_WAR 0
162 +#define RM9000_CDEX_SMP_WAR 0
163 +#define ICACHE_REFILLS_WORKAROUND_WAR 0
164 +#define R10000_LLSC_WAR 0
165 +#define MIPS34K_MISSED_ITLB_WAR 0
169 +++ b/arch/mips/lantiq/Makefile
171 +# Copyright (C) 2010 John Crispin <blogic@openwrt.org>
173 +# This program is free software; you can redistribute it and/or modify it
174 +# under the terms of the GNU General Public License version 2 as published
175 +# by the Free Software Foundation.
177 +obj-y := irq.o setup.o clk.o prom.o
179 +obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
181 +++ b/arch/mips/lantiq/Platform
187 +platform-$(CONFIG_LANTIQ) += lantiq/
188 +cflags-$(CONFIG_LANTIQ) += -I$(srctree)/arch/mips/include/asm/mach-lantiq
189 +load-$(CONFIG_LANTIQ) = 0xffffffff80002000
191 +++ b/arch/mips/lantiq/clk.c
194 + * This program is free software; you can redistribute it and/or modify it
195 + * under the terms of the GNU General Public License version 2 as published
196 + * by the Free Software Foundation.
198 + * Copyright (C) 2010 Thomas Langer <thomas.langer@lantiq.com>
199 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
201 +#include <linux/io.h>
202 +#include <linux/module.h>
203 +#include <linux/init.h>
204 +#include <linux/kernel.h>
205 +#include <linux/types.h>
206 +#include <linux/clk.h>
207 +#include <linux/err.h>
208 +#include <linux/list.h>
210 +#include <asm/time.h>
211 +#include <asm/irq.h>
212 +#include <asm/div64.h>
214 +#include <lantiq_soc.h>
220 + unsigned long rate;
221 + unsigned long (*get_rate) (void);
224 +static struct clk *cpu_clk;
225 +static int cpu_clk_cnt;
227 +/* lantiq socs have 3 static clocks */
228 +static struct clk cpu_clk_generic[] = {
231 + .get_rate = ltq_get_cpu_hz,
234 + .get_rate = ltq_get_fpi_hz,
237 + .get_rate = ltq_get_io_region_clock,
241 +#ifdef CONFIG_SOC_TYPE_XWAY
242 +static struct resource ltq_cgu_resource = {
244 + .start = LTQ_CGU_BASE_ADDR,
245 + .end = LTQ_CGU_BASE_ADDR + LTQ_CGU_SIZE - 1,
246 + .flags = IORESOURCE_MEM,
249 +/* remapped clock register range */
250 +void __iomem *ltq_cgu_membase;
255 + cpu_clk = cpu_clk_generic;
256 + cpu_clk_cnt = ARRAY_SIZE(cpu_clk_generic);
259 +static inline int clk_good(struct clk *clk)
261 + return clk && !IS_ERR(clk);
264 +unsigned long clk_get_rate(struct clk *clk)
266 + if (unlikely(!clk_good(clk)))
269 + if (clk->rate != 0)
272 + if (clk->get_rate != NULL)
273 + return clk->get_rate();
277 +EXPORT_SYMBOL(clk_get_rate);
279 +struct clk *clk_get(struct device *dev, const char *id)
283 + for (i = 0; i < cpu_clk_cnt; i++)
284 + if (!strcmp(id, cpu_clk[i].name))
285 + return &cpu_clk[i];
287 + return ERR_PTR(-ENOENT);
289 +EXPORT_SYMBOL(clk_get);
291 +void clk_put(struct clk *clk)
295 +EXPORT_SYMBOL(clk_put);
297 +static inline u32 ltq_get_counter_resolution(void)
301 + __asm__ __volatile__(
313 +void __init plat_time_init(void)
317 +#ifdef CONFIG_SOC_TYPE_XWAY
318 + if (insert_resource(&iomem_resource, <q_cgu_resource) < 0)
319 + panic("Failed to insert cgu memory\n");
321 + if (request_mem_region(ltq_cgu_resource.start,
322 + resource_size(<q_cgu_resource), "cgu") < 0)
323 + panic("Failed to request cgu memory\n");
325 + ltq_cgu_membase = ioremap_nocache(ltq_cgu_resource.start,
326 + resource_size(<q_cgu_resource));
327 + if (!ltq_cgu_membase) {
328 + pr_err("Failed to remap cgu memory\n");
332 + clk = clk_get(0, "cpu");
333 + mips_hpt_frequency = clk_get_rate(clk) / ltq_get_counter_resolution();
334 + write_c0_compare(read_c0_count());
338 +++ b/arch/mips/lantiq/clk.h
341 + * This program is free software; you can redistribute it and/or modify it
342 + * under the terms of the GNU General Public License version 2 as published
343 + * by the Free Software Foundation.
345 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
348 +#ifndef _LTQ_CLK_H__
349 +#define _LTQ_CLK_H__
351 +extern void clk_init(void);
353 +extern unsigned long ltq_get_cpu_hz(void);
354 +extern unsigned long ltq_get_fpi_hz(void);
355 +extern unsigned long ltq_get_io_region_clock(void);
359 +++ b/arch/mips/lantiq/early_printk.c
362 + * This program is free software; you can redistribute it and/or modify it
363 + * under the terms of the GNU General Public License version 2 as published
364 + * by the Free Software Foundation.
366 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
369 +#include <linux/init.h>
370 +#include <linux/cpu.h>
373 +#include <lantiq_soc.h>
375 +/* no ioremap possible at this early stage, lets use KSEG1 instead */
376 +#ifdef CONFIG_SOC_FALCON
377 +#define LTQ_ASC_BASE KSEG1ADDR(LTQ_ASC0_BASE_ADDR)
379 +#define LTQ_ASC_BASE KSEG1ADDR(LTQ_ASC1_BASE_ADDR)
381 +#define ASC_BUF 1024
382 +#define LTQ_ASC_FSTAT ((u32 *)(LTQ_ASC_BASE + 0x0048))
383 +#define LTQ_ASC_TBUF ((u32 *)(LTQ_ASC_BASE + 0x0020))
384 +#define TXMASK 0x3F00
387 +void prom_putchar(char c)
389 + unsigned long flags;
391 + local_irq_save(flags);
392 + do { } while ((ltq_r32(LTQ_ASC_FSTAT) & TXMASK) >> TXOFFSET);
394 + ltq_w32('\r', LTQ_ASC_TBUF);
395 + ltq_w32(c, LTQ_ASC_TBUF);
396 + local_irq_restore(flags);
399 +++ b/arch/mips/lantiq/irq.c
402 + * This program is free software; you can redistribute it and/or modify it
403 + * under the terms of the GNU General Public License version 2 as published
404 + * by the Free Software Foundation.
406 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
407 + * Copyright (C) 2010 Thomas Langer <thomas.langer@lantiq.com>
410 +#include <linux/interrupt.h>
411 +#include <linux/ioport.h>
412 +#include <linux/module.h>
414 +#include <asm/bootinfo.h>
415 +#include <asm/irq_cpu.h>
417 +#include <lantiq_soc.h>
420 +/* register definitions */
421 +#define LTQ_ICU_IM0_ISR 0x0000
422 +#define LTQ_ICU_IM0_IER 0x0008
423 +#define LTQ_ICU_IM0_IOSR 0x0010
424 +#define LTQ_ICU_IM0_IRSR 0x0018
425 +#define LTQ_ICU_IM0_IMR 0x0020
426 +#define LTQ_ICU_IM1_ISR 0x0028
427 +#define LTQ_ICU_OFFSET (LTQ_ICU_IM1_ISR - LTQ_ICU_IM0_ISR)
429 +#ifdef CONFIG_SOC_TYPE_XWAY
431 +#define LTQ_EIU_EXIN_C 0x0000
432 +#define LTQ_EIU_EXIN_INIC 0x0004
433 +#define LTQ_EIU_EXIN_INEN 0x000C
435 +/* irq numbers used by the external interrupt unit (EIU) */
436 +#define LTQ_EIU_IR0 (INT_NUM_IM4_IRL0 + 30)
437 +#define LTQ_EIU_IR1 (INT_NUM_IM3_IRL0 + 31)
438 +#define LTQ_EIU_IR2 (INT_NUM_IM1_IRL0 + 26)
439 +#define LTQ_EIU_IR3 INT_NUM_IM1_IRL0
440 +#define LTQ_EIU_IR4 (INT_NUM_IM1_IRL0 + 1)
441 +#define LTQ_EIU_IR5 (INT_NUM_IM1_IRL0 + 2)
442 +#define LTQ_EIU_IR6 (INT_NUM_IM2_IRL0 + 30)
446 +/* irqs generated by device attached to the EBU need to be acked in
449 +#define LTQ_ICU_EBU_IRQ 22
451 +#define ltq_eiu_w32(x, y) ltq_w32((x), ltq_eiu_membase + (y))
452 +#define ltq_eiu_r32(x) ltq_r32(ltq_eiu_membase + (x))
454 +static unsigned short ltq_eiu_irq[MAX_EIU] = {
463 +static void __iomem *ltq_eiu_membase;
465 +static struct resource ltq_eiu_resource = {
467 + .start = LTQ_EIU_BASE_ADDR,
468 + .end = LTQ_EIU_BASE_ADDR + LTQ_ICU_SIZE - 1,
469 + .flags = IORESOURCE_MEM,
474 +static struct resource ltq_icu_resource = {
476 + .start = LTQ_ICU_BASE_ADDR,
477 + .end = LTQ_ICU_BASE_ADDR + LTQ_ICU_SIZE - 1,
478 + .flags = IORESOURCE_MEM,
481 +#define ltq_icu_w32(x, y) ltq_w32((x), ltq_icu_membase + (y))
482 +#define ltq_icu_r32(x) ltq_r32(ltq_icu_membase + (x))
484 +static void __iomem *ltq_icu_membase;
487 +void ltq_disable_irq(struct irq_data *d)
489 + u32 ier = LTQ_ICU_IM0_IER;
490 + int irq_nr = d->irq - INT_NUM_IRQ0;
492 + ier += LTQ_ICU_OFFSET * (irq_nr / INT_NUM_IM_OFFSET);
493 + irq_nr %= INT_NUM_IM_OFFSET;
494 + ltq_icu_w32(ltq_icu_r32(ier) & ~(1 << irq_nr), ier);
497 +void ltq_mask_and_ack_irq(struct irq_data *d)
499 + u32 ier = LTQ_ICU_IM0_IER;
500 + u32 isr = LTQ_ICU_IM0_ISR;
501 + int irq_nr = d->irq - INT_NUM_IRQ0;
503 + ier += LTQ_ICU_OFFSET * (irq_nr / INT_NUM_IM_OFFSET);
504 + isr += LTQ_ICU_OFFSET * (irq_nr / INT_NUM_IM_OFFSET);
505 + irq_nr %= INT_NUM_IM_OFFSET;
506 + ltq_icu_w32(ltq_icu_r32(ier) & ~(1 << irq_nr), ier);
507 + ltq_icu_w32((1 << irq_nr), isr);
509 +EXPORT_SYMBOL(ltq_mask_and_ack_irq);
511 +static void ltq_ack_irq(struct irq_data *d)
513 + u32 isr = LTQ_ICU_IM0_ISR;
514 + int irq_nr = d->irq - INT_NUM_IRQ0;
516 + isr += LTQ_ICU_OFFSET * (irq_nr / INT_NUM_IM_OFFSET);
517 + irq_nr %= INT_NUM_IM_OFFSET;
518 + ltq_icu_w32((1 << irq_nr), isr);
521 +void ltq_enable_irq(struct irq_data *d)
523 + u32 ier = LTQ_ICU_IM0_IER;
524 + int irq_nr = d->irq - INT_NUM_IRQ0;
526 + ier += LTQ_ICU_OFFSET * (irq_nr / INT_NUM_IM_OFFSET);
527 + irq_nr %= INT_NUM_IM_OFFSET;
528 + ltq_icu_w32(ltq_icu_r32(ier) | (1 << irq_nr), ier);
531 +#ifdef CONFIG_SOC_TYPE_XWAY
532 +static unsigned int ltq_startup_eiu_irq(struct irq_data *d)
535 + int irq_nr = d->irq - INT_NUM_IRQ0;
538 + for (i = 0; i < MAX_EIU; i++) {
539 + if (irq_nr == ltq_eiu_irq[i]) {
540 + /* low level - we should really handle set_type */
541 + ltq_eiu_w32(ltq_eiu_r32(LTQ_EIU_EXIN_C) |
542 + (0x6 << (i * 4)), LTQ_EIU_EXIN_C);
543 + /* clear all pending */
544 + ltq_eiu_w32(ltq_eiu_r32(LTQ_EIU_EXIN_INIC) & ~(1 << i),
545 + LTQ_EIU_EXIN_INIC);
547 + ltq_eiu_w32(ltq_eiu_r32(LTQ_EIU_EXIN_INEN) | (1 << i),
548 + LTQ_EIU_EXIN_INEN);
556 +static void ltq_shutdown_eiu_irq(struct irq_data *d)
559 + int irq_nr = d->irq - INT_NUM_IRQ0;
561 + ltq_disable_irq(d);
562 + for (i = 0; i < MAX_EIU; i++) {
563 + if (irq_nr == ltq_eiu_irq[i]) {
565 + ltq_eiu_w32(ltq_eiu_r32(LTQ_EIU_EXIN_INEN) & ~(1 << i),
566 + LTQ_EIU_EXIN_INEN);
573 +static struct irq_chip ltq_irq_type = {
575 + .irq_enable = ltq_enable_irq,
576 + .irq_disable = ltq_disable_irq,
577 + .irq_unmask = ltq_enable_irq,
578 + .irq_ack = ltq_ack_irq,
579 + .irq_mask = ltq_disable_irq,
580 + .irq_mask_ack = ltq_mask_and_ack_irq,
583 +#ifdef CONFIG_SOC_TYPE_XWAY
584 +static struct irq_chip ltq_eiu_type = {
586 + .irq_startup = ltq_startup_eiu_irq,
587 + .irq_shutdown = ltq_shutdown_eiu_irq,
588 + .irq_enable = ltq_enable_irq,
589 + .irq_disable = ltq_disable_irq,
590 + .irq_unmask = ltq_enable_irq,
591 + .irq_ack = ltq_ack_irq,
592 + .irq_mask = ltq_disable_irq,
593 + .irq_mask_ack = ltq_mask_and_ack_irq,
597 +static void ltq_hw_irqdispatch(int module)
601 + irq = ltq_icu_r32(LTQ_ICU_IM0_IOSR + (module * LTQ_ICU_OFFSET));
605 + /* silicon bug causes only the msb set to 1 to be valid. all
606 + * other bits might be bogus
609 + do_IRQ((int)irq + INT_NUM_IM0_IRL0 + (INT_NUM_IM_OFFSET * module));
611 +#ifdef CONFIG_SOC_TYPE_XWAY
612 + /* if this is a EBU irq, we need to ack it or get a deadlock */
613 + if ((irq == LTQ_ICU_EBU_IRQ) && (module == 0))
614 + ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_PCC_ISTAT) | 0x10,
615 + LTQ_EBU_PCC_ISTAT);
619 +#define DEFINE_HWx_IRQDISPATCH(x) \
620 + static void ltq_hw ## x ## _irqdispatch(void) \
622 + ltq_hw_irqdispatch(x); \
624 +DEFINE_HWx_IRQDISPATCH(0)
625 +DEFINE_HWx_IRQDISPATCH(1)
626 +DEFINE_HWx_IRQDISPATCH(2)
627 +DEFINE_HWx_IRQDISPATCH(3)
628 +DEFINE_HWx_IRQDISPATCH(4)
630 +static void ltq_hw5_irqdispatch(void)
632 + do_IRQ(MIPS_CPU_TIMER_IRQ);
635 +asmlinkage void plat_irq_dispatch(void)
637 + unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
640 + if (pending & CAUSEF_IP7) {
641 + do_IRQ(MIPS_CPU_TIMER_IRQ);
644 + for (i = 0; i < 5; i++) {
645 + if (pending & (CAUSEF_IP2 << i)) {
646 + ltq_hw_irqdispatch(i);
651 + pr_alert("Spurious IRQ: CAUSE=0x%08x\n", read_c0_status());
657 +static struct irqaction cascade = {
658 + .handler = no_action,
659 + .flags = IRQF_DISABLED,
663 +void __init arch_init_irq(void)
667 + if (insert_resource(&iomem_resource, <q_icu_resource) < 0)
668 + panic("Failed to insert icu memory\n");
670 + if (request_mem_region(ltq_icu_resource.start,
671 + resource_size(<q_icu_resource), "icu") < 0)
672 + panic("Failed to request icu memory\n");
674 + ltq_icu_membase = ioremap_nocache(ltq_icu_resource.start,
675 + resource_size(<q_icu_resource));
676 + if (!ltq_icu_membase)
677 + panic("Failed to remap icu memory\n");
679 +#ifdef CONFIG_SOC_TYPE_XWAY
680 + if (insert_resource(&iomem_resource, <q_eiu_resource) < 0)
681 + panic("Failed to insert eiu memory\n");
683 + if (request_mem_region(ltq_eiu_resource.start,
684 + resource_size(<q_eiu_resource), "eiu") < 0)
685 + panic("Failed to request eiu memory\n");
687 + ltq_eiu_membase = ioremap_nocache(ltq_eiu_resource.start,
688 + resource_size(<q_eiu_resource));
689 + if (!ltq_eiu_membase)
690 + panic("Failed to remap eiu memory\n");
692 + /* make sure all irqs are turned off by default */
693 + for (i = 0; i < 5; i++)
694 + ltq_icu_w32(0, LTQ_ICU_IM0_IER + (i * LTQ_ICU_OFFSET));
696 + /* clear all possibly pending interrupts */
697 + ltq_icu_w32(~0, LTQ_ICU_IM0_ISR + (i * LTQ_ICU_OFFSET));
699 + mips_cpu_irq_init();
701 + for (i = 2; i <= 6; i++)
702 + setup_irq(i, &cascade);
704 + if (cpu_has_vint) {
705 + pr_info("Setting up vectored interrupts\n");
706 + set_vi_handler(2, ltq_hw0_irqdispatch);
707 + set_vi_handler(3, ltq_hw1_irqdispatch);
708 + set_vi_handler(4, ltq_hw2_irqdispatch);
709 + set_vi_handler(5, ltq_hw3_irqdispatch);
710 + set_vi_handler(6, ltq_hw4_irqdispatch);
711 + set_vi_handler(7, ltq_hw5_irqdispatch);
714 + for (i = INT_NUM_IRQ0;
715 + i <= (INT_NUM_IRQ0 + (5 * INT_NUM_IM_OFFSET)); i++)
716 +#ifdef CONFIG_SOC_TYPE_XWAY
717 + if ((i == LTQ_EIU_IR0) || (i == LTQ_EIU_IR1) || (i == LTQ_EIU_IR2))
718 + irq_set_chip_and_handler(i, <q_eiu_type, handle_level_irq);
719 + /* EIU3-5 only exist on ar9 and vr9 */
720 + else if (((i == LTQ_EIU_IR3) || (i == LTQ_EIU_IR4) ||
721 + (i == LTQ_EIU_IR5)) && (ltq_is_ar9() || ltq_is_vr9()))
722 + irq_set_chip_and_handler(i, <q_eiu_type, handle_level_irq);
725 + irq_set_chip_and_handler(i, <q_irq_type, handle_level_irq);
727 +#if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC)
728 + set_c0_status(IE_IRQ0 | IE_IRQ1 | IE_IRQ2 |
729 + IE_IRQ3 | IE_IRQ4 | IE_IRQ5);
731 + set_c0_status(IE_SW0 | IE_SW1 | IE_IRQ0 | IE_IRQ1 |
732 + IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5);
736 +unsigned int __cpuinit get_c0_compare_int(void)
738 + return CP0_LEGACY_COMPARE_IRQ;
741 +++ b/arch/mips/lantiq/prom.c
744 + * This program is free software; you can redistribute it and/or modify it
745 + * under the terms of the GNU General Public License version 2 as published
746 + * by the Free Software Foundation.
748 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
751 +#include <linux/module.h>
752 +#include <linux/clk.h>
753 +#include <asm/bootinfo.h>
754 +#include <asm/time.h>
761 +static struct ltq_soc_info soc_info;
763 +unsigned int ltq_get_cpu_ver(void)
765 + return soc_info.rev;
767 +EXPORT_SYMBOL(ltq_get_cpu_ver);
769 +unsigned int ltq_get_soc_type(void)
771 + return soc_info.type;
773 +EXPORT_SYMBOL(ltq_get_soc_type);
775 +const char *get_system_type(void)
777 + return soc_info.sys_type;
780 +void prom_free_prom_memory(void)
784 +static void __init prom_init_cmdline(void)
786 + int argc = fw_arg0;
787 + char **argv = (char **) KSEG1ADDR(fw_arg1);
790 + for (i = 0; i < argc; i++) {
791 + char *p = (char *) KSEG1ADDR(argv[i]);
794 + strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
795 + strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
800 +void __init prom_init(void)
804 + ltq_soc_detect(&soc_info);
806 + clk = clk_get(0, "cpu");
807 + snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev1.%d",
808 + soc_info.name, soc_info.rev);
810 + soc_info.sys_type[LTQ_SYS_TYPE_LEN - 1] = '\0';
811 + pr_info("SoC: %s\n", soc_info.sys_type);
812 + prom_init_cmdline();
815 +++ b/arch/mips/lantiq/prom.h
818 + * This program is free software; you can redistribute it and/or modify it
819 + * under the terms of the GNU General Public License version 2 as published
820 + * by the Free Software Foundation.
822 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
825 +#ifndef _LTQ_PROM_H__
826 +#define _LTQ_PROM_H__
828 +#define LTQ_SYS_TYPE_LEN 0x100
830 +struct ltq_soc_info {
831 + unsigned char *name;
833 + unsigned int partnum;
835 + unsigned char sys_type[LTQ_SYS_TYPE_LEN];
838 +extern void ltq_soc_detect(struct ltq_soc_info *i);
842 +++ b/arch/mips/lantiq/setup.c
845 + * This program is free software; you can redistribute it and/or modify it
846 + * under the terms of the GNU General Public License version 2 as published
847 + * by the Free Software Foundation.
849 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
852 +#include <linux/kernel.h>
853 +#include <linux/module.h>
854 +#include <linux/io.h>
855 +#include <linux/ioport.h>
856 +#include <asm/bootinfo.h>
858 +#include <lantiq_soc.h>
860 +void __init plat_mem_setup(void)
862 + /* assume 16M as default incase uboot fails to pass proper ramsize */
863 + unsigned long memsize = 16;
864 + char **envp = (char **) KSEG1ADDR(fw_arg2);
866 + ioport_resource.start = IOPORT_RESOURCE_START;
867 + ioport_resource.end = IOPORT_RESOURCE_END;
868 + iomem_resource.start = IOMEM_RESOURCE_START;
869 + iomem_resource.end = IOMEM_RESOURCE_END;
871 + set_io_port_base((unsigned long) KSEG1);
874 + char *e = (char *)KSEG1ADDR(*envp);
875 + if (!strncmp(e, "memsize=", 8)) {
877 + if (strict_strtoul(e, 0, &memsize))
878 + pr_warn("bad memsize specified\n");
882 + memsize *= 1024 * 1024;
883 + add_memory_region(0x00000000, memsize, BOOT_MEM_RAM);
885 --- a/arch/mips/Kbuild.platforms
886 +++ b/arch/mips/Kbuild.platforms
887 @@ -11,6 +11,7 @@ platforms += dec
893 platforms += loongson