1 --- a/arch/mips/Kconfig
2 +++ b/arch/mips/Kconfig
3 @@ -139,6 +139,9 @@ config MACH_DECSTATION
5 otherwise choose R3000.
11 bool "Jazz family of machines"
13 @@ -693,6 +696,7 @@ source "arch/mips/txx9/Kconfig"
14 source "arch/mips/vr41xx/Kconfig"
15 source "arch/mips/cavium-octeon/Kconfig"
16 source "arch/mips/loongson/Kconfig"
17 +source "arch/mips/lantiq/Kconfig"
21 --- a/arch/mips/Makefile
22 +++ b/arch/mips/Makefile
23 @@ -317,6 +317,17 @@ cflags-$(CONFIG_MIPS_COBALT) += -I$(srct
24 load-$(CONFIG_MIPS_COBALT) += 0xffffffff80080000
29 +load-$(CONFIG_LANTIQ) += 0xffffffff80002000
30 +core-$(CONFIG_LANTIQ) += arch/mips/lantiq/
31 +cflags-$(CONFIG_LANTIQ) += -I$(srctree)/arch/mips/include/asm/mach-lantiq
32 +core-$(CONFIG_SOC_LANTIQ_FALCON) += arch/mips/lantiq/falcon/
33 +cflags-$(CONFIG_SOC_LANTIQ_FALCON) += -I$(srctree)/arch/mips/include/asm/mach-lantiq/falcon
34 +core-$(CONFIG_SOC_LANTIQ_XWAY) += arch/mips/lantiq/xway/
35 +cflags-$(CONFIG_SOC_LANTIQ_XWAY) += -I$(srctree)/arch/mips/include/asm/mach-lantiq/xway
40 core-$(CONFIG_MACH_DECSTATION) += arch/mips/dec/
42 +++ b/arch/mips/lantiq/Kconfig
48 + select DMA_NONCOHERENT
52 + select SYS_HAS_CPU_MIPS32_R1
53 + select SYS_HAS_CPU_MIPS32_R2
54 + select SYS_SUPPORTS_BIG_ENDIAN
55 + select SYS_SUPPORTS_32BIT_KERNEL
56 + select SYS_SUPPORTS_MULTITHREADING
57 + select SYS_HAS_EARLY_PRINTK
59 + select ARCH_REQUIRE_GPIOLIB
60 + select SWAP_IO_SPACE
65 + default SOC_LANTIQ_XWAY
67 +#config SOC_LANTIQ_FALCON
71 +config SOC_LANTIQ_XWAY
76 +#source "arch/mips/lantiq/falcon/Kconfig"
77 +source "arch/mips/lantiq/xway/Kconfig"
81 +++ b/arch/mips/lantiq/Makefile
83 +obj-y := irq.o setup.o clk.o prom.o
84 +obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
86 +++ b/arch/mips/lantiq/setup.c
89 + * This program is free software; you can redistribute it and/or modify it
90 + * under the terms of the GNU General Public License version 2 as published
91 + * by the Free Software Foundation.
93 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
96 +#include <linux/kernel.h>
97 +#include <linux/module.h>
98 +#include <linux/io.h>
99 +#include <linux/ioport.h>
102 +#include <lantiq_regs.h>
105 +plat_mem_setup(void)
107 + /* assume 16M as default */
109 + char **envp = (char **) KSEG1ADDR(fw_arg2);
112 + /* make sure to have no "reverse endian" for user mode! */
113 + status = read_c0_status();
114 + status &= (~(1<<25));
115 + write_c0_status(status);
117 + ioport_resource.start = IOPORT_RESOURCE_START;
118 + ioport_resource.end = IOPORT_RESOURCE_END;
119 + iomem_resource.start = IOMEM_RESOURCE_START;
120 + iomem_resource.end = IOMEM_RESOURCE_END;
124 + char *e = (char *)KSEG1ADDR(*envp);
125 + if (!strncmp(e, "memsize=", 8))
128 + memsize = simple_strtoul(e, NULL, 10);
132 + memsize *= 1024 * 1024;
133 + add_memory_region(0x00000000, memsize, BOOT_MEM_RAM);
136 +++ b/arch/mips/lantiq/clk.c
139 + * This program is free software; you can redistribute it and/or modify it
140 + * under the terms of the GNU General Public License version 2 as published
141 + * by the Free Software Foundation.
143 + * Copyright (C) 2010 Thomas Langer, Lantiq Deutschland
144 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
147 +#include <linux/io.h>
148 +#include <linux/module.h>
149 +#include <linux/init.h>
150 +#include <linux/kernel.h>
151 +#include <linux/types.h>
152 +#include <linux/clk.h>
153 +#include <linux/err.h>
154 +#include <linux/list.h>
156 +#include <asm/time.h>
157 +#include <asm/irq.h>
158 +#include <asm/div64.h>
161 +#ifdef CONFIG_SOC_LANTIQ_XWAY
165 +extern unsigned long lq_get_cpu_hz(void);
166 +extern unsigned long lq_get_fpi_hz(void);
167 +extern unsigned long lq_get_io_region_clock(void);
171 + unsigned long rate;
172 + unsigned long (*get_rate) (void);
175 +static struct clk *cpu_clk = 0;
176 +static int cpu_clk_cnt = 0;
178 +static unsigned int r4k_offset;
179 +static unsigned int r4k_cur;
181 +static struct clk cpu_clk_generic[] = {
184 + .get_rate = lq_get_cpu_hz,
187 + .get_rate = lq_get_fpi_hz,
190 + .get_rate = lq_get_io_region_clock,
198 + cpu_clk = cpu_clk_generic;
199 + cpu_clk_cnt = ARRAY_SIZE(cpu_clk_generic);
200 + for(i = 0; i < cpu_clk_cnt; i++)
201 + printk("%s: %ld\n", cpu_clk[i].name, clk_get_rate(&cpu_clk[i]));
205 +clk_good(struct clk *clk)
207 + return clk && !IS_ERR(clk);
211 +clk_get_rate(struct clk *clk)
213 + if (unlikely(!clk_good(clk)))
216 + if (clk->rate != 0)
219 + if (clk->get_rate != NULL)
220 + return clk->get_rate();
224 +EXPORT_SYMBOL(clk_get_rate);
227 +clk_get(struct device *dev, const char *id)
230 + for(i = 0; i < cpu_clk_cnt; i++)
231 + if (!strcmp(id, cpu_clk[i].name))
232 + return &cpu_clk[i];
234 + return ERR_PTR(-ENOENT);
236 +EXPORT_SYMBOL(clk_get);
239 +clk_put(struct clk *clk)
243 +EXPORT_SYMBOL(clk_put);
246 +lq_get_counter_resolution(void)
249 + __asm__ __volatile__(
259 + instruction_hazard();
264 +plat_time_init(void)
266 + struct clk *clk = clk_get(0, "cpu");
267 + mips_hpt_frequency = clk_get_rate(clk) / lq_get_counter_resolution();
268 + r4k_cur = (read_c0_count() + r4k_offset);
269 + write_c0_compare(r4k_cur);
271 +#ifdef CONFIG_SOC_LANTIQ_XWAY
272 +#define LQ_GPTU_GPT_CLC ((u32 *)(LQ_GPTU_BASE_ADDR + 0x0000))
273 + lq_pmu_enable(PMU_GPT);
274 + lq_pmu_enable(PMU_FPI);
276 + lq_w32(0x100, LQ_GPTU_GPT_CLC);
280 +++ b/arch/mips/lantiq/prom.c
283 + * This program is free software; you can redistribute it and/or modify it
284 + * under the terms of the GNU General Public License version 2 as published
285 + * by the Free Software Foundation.
287 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
290 +#include <linux/module.h>
291 +#include <linux/clk.h>
292 +#include <asm/bootinfo.h>
293 +#include <asm/time.h>
299 +static struct lq_soc_info soc_info;
301 +/* for Multithreading (APRP) on MIPS34K */
302 +unsigned long physical_memsize;
304 +/* all access to the ebu must be locked */
305 +DEFINE_SPINLOCK(ebu_lock);
306 +EXPORT_SYMBOL_GPL(ebu_lock);
308 +extern void clk_init(void);
311 +lq_get_cpu_ver(void)
313 + return soc_info.rev;
315 +EXPORT_SYMBOL(lq_get_cpu_ver);
318 +lq_get_soc_type(void)
320 + return soc_info.type;
322 +EXPORT_SYMBOL(lq_get_soc_type);
325 +get_system_type(void)
327 + return soc_info.sys_type;
331 +prom_free_prom_memory(void)
335 +#ifdef CONFIG_IMAGE_CMDLINE_HACK
336 +extern char __image_cmdline[];
339 +prom_init_image_cmdline(void)
341 + char *p = __image_cmdline;
353 + strlcpy(arcs_cmdline, p, sizeof(arcs_cmdline));
355 + strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
356 + strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
360 +static void __init prom_init_image_cmdline(void) { return; }
364 +prom_init_cmdline(void)
366 + int argc = fw_arg0;
367 + char **argv = (char**)KSEG1ADDR(fw_arg1);
370 + arcs_cmdline[0] = '\0';
372 + for (i = 1; i < argc; i++)
374 + strlcat(arcs_cmdline, (char*)KSEG1ADDR(argv[i]), COMMAND_LINE_SIZE);
376 + strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
379 + if (!*arcs_cmdline)
380 + strcpy(&(arcs_cmdline[0]),
381 + "console=ttyS1,115200 rootfstype=squashfs,jffs2");
382 + prom_init_image_cmdline();
389 + lq_soc_detect(&soc_info);
392 + clk = clk_get(0, "cpu");
393 + snprintf(soc_info.sys_type, LQ_SYS_TYPE_LEN - 1, "%s rev1.%d %ldMhz",
394 + soc_info.name, soc_info.rev, clk_get_rate(clk) / 1000000);
395 + soc_info.sys_type[LQ_SYS_TYPE_LEN - 1] = '\0';
396 + printk("SoC: %s\n", soc_info.sys_type);
398 + prom_init_cmdline();
401 +++ b/arch/mips/lantiq/prom.h
404 + * This program is free software; you can redistribute it and/or modify it
405 + * under the terms of the GNU General Public License version 2 as published
406 + * by the Free Software Foundation.
408 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
411 +#ifndef _LQ_PROM_H__
412 +#define _LQ_PROM_H__
414 +#define LQ_SYS_TYPE_LEN 0x100
416 +struct lq_soc_info {
417 + unsigned char *name;
419 + unsigned int partnum;
421 + unsigned char sys_type[LQ_SYS_TYPE_LEN];
424 +void lq_soc_detect(struct lq_soc_info *i);