1 From d90739a8962b541969b4c5f7ef1df8fec9c7f153 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 10 Aug 2011 14:57:04 +0200
4 Subject: [PATCH 04/24] MIPS: lantiq: reorganize xway code
6 Inside the folder arch/mips/lantiq/xway, there were alot of small files with
7 lots of duplicated code. This patch adds a wrapper function for inserting and
8 requesting resources and unifies the small files into one bigger file.
10 This patch makes the xway code consistent with the falcon support added later
13 Signed-off-by: John Crispin <blogic@openwrt.org>
14 Signed-off-by: Thomas Langer <thomas.langer@lantiq.com>
15 Cc: linux-mips@linux-mips.org
17 arch/mips/include/asm/mach-lantiq/lantiq.h | 14 +---
18 .../mips/include/asm/mach-lantiq/xway/lantiq_soc.h | 14 ++++
19 arch/mips/lantiq/clk.c | 25 +------
20 arch/mips/lantiq/devices.c | 30 ++------
21 arch/mips/lantiq/devices.h | 4 +
22 arch/mips/lantiq/prom.c | 50 +++++++++++--
23 arch/mips/lantiq/prom.h | 4 +
24 arch/mips/lantiq/xway/Makefile | 6 +-
25 arch/mips/lantiq/xway/devices.c | 42 ++---------
26 arch/mips/lantiq/xway/dma.c | 21 ++----
27 arch/mips/lantiq/xway/ebu.c | 53 --------------
28 arch/mips/lantiq/xway/pmu.c | 70 ------------------
29 arch/mips/lantiq/xway/prom-ase.c | 9 +++
30 arch/mips/lantiq/xway/prom-xway.c | 10 +++
31 arch/mips/lantiq/xway/reset.c | 21 ++----
32 arch/mips/lantiq/xway/setup-ase.c | 19 -----
33 arch/mips/lantiq/xway/setup-xway.c | 20 -----
34 arch/mips/lantiq/xway/sysctrl.c | 77 ++++++++++++++++++++
35 drivers/watchdog/lantiq_wdt.c | 2 +-
36 19 files changed, 197 insertions(+), 294 deletions(-)
37 delete mode 100644 arch/mips/lantiq/xway/ebu.c
38 delete mode 100644 arch/mips/lantiq/xway/pmu.c
39 delete mode 100644 arch/mips/lantiq/xway/setup-ase.c
40 delete mode 100644 arch/mips/lantiq/xway/setup-xway.c
41 create mode 100644 arch/mips/lantiq/xway/sysctrl.c
43 --- a/arch/mips/include/asm/mach-lantiq/lantiq.h
44 +++ b/arch/mips/include/asm/mach-lantiq/lantiq.h
48 #include <linux/irq.h>
49 +#include <linux/ioport.h>
51 /* generic reg access functions */
52 #define ltq_r32(reg) __raw_readl(reg)
54 #define ltq_r8(reg) __raw_readb(reg)
55 #define ltq_w8(val, reg) __raw_writeb(val, reg)
57 -/* register access macros for EBU and CGU */
58 -#define ltq_ebu_w32(x, y) ltq_w32((x), ltq_ebu_membase + (y))
59 -#define ltq_ebu_r32(x) ltq_r32(ltq_ebu_membase + (x))
60 -#define ltq_cgu_w32(x, y) ltq_w32((x), ltq_cgu_membase + (y))
61 -#define ltq_cgu_r32(x) ltq_r32(ltq_cgu_membase + (x))
63 -extern __iomem void *ltq_ebu_membase;
64 -extern __iomem void *ltq_cgu_membase;
66 extern unsigned int ltq_get_cpu_ver(void);
67 extern unsigned int ltq_get_soc_type(void);
69 @@ -51,7 +43,9 @@ extern void ltq_enable_irq(struct irq_da
71 /* find out what caused the last cpu reset */
72 extern int ltq_reset_cause(void);
73 -#define LTQ_RST_CAUSE_WDTRST 0x20
75 +/* helper for requesting and remapping resources */
76 +extern void __iomem *ltq_remap_resource(struct resource *res);
78 #define IOPORT_RESOURCE_START 0x10000000
79 #define IOPORT_RESOURCE_END 0xffffffff
80 --- a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
81 +++ b/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
83 #define LTQ_CGU_BASE_ADDR 0x1F103000
84 #define LTQ_CGU_SIZE 0x1000
86 +#define CGU_EPHY 0x10
88 /* ICU - interrupt control unit */
89 #define LTQ_ICU_BASE_ADDR 0x1F880200
90 #define LTQ_ICU_SIZE 0x100
92 #define LTQ_WDT_BASE_ADDR 0x1F8803F0
93 #define LTQ_WDT_SIZE 0x10
95 +#define LTQ_RST_CAUSE_WDTRST 0x20
97 /* STP - serial to parallel conversion unit */
98 #define LTQ_STP_BASE_ADDR 0x1E100BB0
99 #define LTQ_STP_SIZE 0x40
100 @@ -125,11 +129,21 @@
101 #define LTQ_MPS_BASE_ADDR (KSEG1 + 0x1F107000)
102 #define LTQ_MPS_CHIPID ((u32 *)(LTQ_MPS_BASE_ADDR + 0x0344))
104 +/* register access macros for EBU and CGU */
105 +#define ltq_ebu_w32(x, y) ltq_w32((x), ltq_ebu_membase + (y))
106 +#define ltq_ebu_r32(x) ltq_r32(ltq_ebu_membase + (x))
107 +#define ltq_cgu_w32(x, y) ltq_w32((x), ltq_cgu_membase + (y))
108 +#define ltq_cgu_r32(x) ltq_r32(ltq_cgu_membase + (x))
110 +extern __iomem void *ltq_ebu_membase;
111 +extern __iomem void *ltq_cgu_membase;
113 /* request a non-gpio and set the PIO config */
114 extern int ltq_gpio_request(unsigned int pin, unsigned int alt0,
115 unsigned int alt1, unsigned int dir, const char *name);
116 extern void ltq_pmu_enable(unsigned int module);
117 extern void ltq_pmu_disable(unsigned int module);
118 +extern void ltq_cgu_enable(unsigned int clk);
120 static inline int ltq_is_ar9(void)
122 --- a/arch/mips/lantiq/clk.c
123 +++ b/arch/mips/lantiq/clk.c
125 #include <lantiq_soc.h>
132 @@ -46,16 +47,6 @@ static struct clk cpu_clk_generic[] = {
136 -static struct resource ltq_cgu_resource = {
138 - .start = LTQ_CGU_BASE_ADDR,
139 - .end = LTQ_CGU_BASE_ADDR + LTQ_CGU_SIZE - 1,
140 - .flags = IORESOURCE_MEM,
143 -/* remapped clock register range */
144 -void __iomem *ltq_cgu_membase;
148 cpu_clk = cpu_clk_generic;
149 @@ -133,21 +124,11 @@ void __init plat_time_init(void)
153 - if (insert_resource(&iomem_resource, <q_cgu_resource) < 0)
154 - panic("Failed to insert cgu memory\n");
157 - if (request_mem_region(ltq_cgu_resource.start,
158 - resource_size(<q_cgu_resource), "cgu") < 0)
159 - panic("Failed to request cgu memory\n");
161 - ltq_cgu_membase = ioremap_nocache(ltq_cgu_resource.start,
162 - resource_size(<q_cgu_resource));
163 - if (!ltq_cgu_membase) {
164 - pr_err("Failed to remap cgu memory\n");
167 clk = clk_get(0, "cpu");
168 mips_hpt_frequency = clk_get_rate(clk) / ltq_get_counter_resolution();
169 write_c0_compare(read_c0_count());
170 + pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000);
173 --- a/arch/mips/lantiq/devices.c
174 +++ b/arch/mips/lantiq/devices.c
179 -static struct resource ltq_nor_resource = {
181 - .start = LTQ_FLASH_START,
182 - .end = LTQ_FLASH_START + LTQ_FLASH_MAX - 1,
183 - .flags = IORESOURCE_MEM,
185 +static struct resource ltq_nor_resource =
186 + MEM_RES("nor", LTQ_FLASH_START, LTQ_FLASH_MAX);
188 static struct platform_device ltq_nor = {
190 @@ -47,12 +43,8 @@ void __init ltq_register_nor(struct phys
194 -static struct resource ltq_wdt_resource = {
195 - .name = "watchdog",
196 - .start = LTQ_WDT_BASE_ADDR,
197 - .end = LTQ_WDT_BASE_ADDR + LTQ_WDT_SIZE - 1,
198 - .flags = IORESOURCE_MEM,
200 +static struct resource ltq_wdt_resource =
201 + MEM_RES("watchdog", LTQ_WDT_BASE_ADDR, LTQ_WDT_SIZE);
203 void __init ltq_register_wdt(void)
205 @@ -61,24 +53,14 @@ void __init ltq_register_wdt(void)
208 static struct resource ltq_asc0_resources[] = {
211 - .start = LTQ_ASC0_BASE_ADDR,
212 - .end = LTQ_ASC0_BASE_ADDR + LTQ_ASC_SIZE - 1,
213 - .flags = IORESOURCE_MEM,
215 + MEM_RES("asc0", LTQ_ASC0_BASE_ADDR, LTQ_ASC_SIZE),
216 IRQ_RES(tx, LTQ_ASC_TIR(0)),
217 IRQ_RES(rx, LTQ_ASC_RIR(0)),
218 IRQ_RES(err, LTQ_ASC_EIR(0)),
221 static struct resource ltq_asc1_resources[] = {
224 - .start = LTQ_ASC1_BASE_ADDR,
225 - .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
226 - .flags = IORESOURCE_MEM,
228 + MEM_RES("asc1", LTQ_ASC1_BASE_ADDR, LTQ_ASC_SIZE),
229 IRQ_RES(tx, LTQ_ASC_TIR(1)),
230 IRQ_RES(rx, LTQ_ASC_RIR(1)),
231 IRQ_RES(err, LTQ_ASC_EIR(1)),
232 --- a/arch/mips/lantiq/devices.h
233 +++ b/arch/mips/lantiq/devices.h
236 #define IRQ_RES(resname, irq) \
237 {.name = #resname, .start = (irq), .flags = IORESOURCE_IRQ}
238 +#define MEM_RES(resname, adr_start, adr_size) \
239 + { .name = resname, .flags = IORESOURCE_MEM, \
240 + .start = ((adr_start) & ~KSEG1), \
241 + .end = ((adr_start + adr_size - 1) & ~KSEG1) }
243 extern void ltq_register_nor(struct physmap_flash_data *data);
244 extern void ltq_register_wdt(void);
245 --- a/arch/mips/lantiq/prom.c
246 +++ b/arch/mips/lantiq/prom.c
251 +/* access to the ebu needs to be locked between different drivers */
252 +DEFINE_SPINLOCK(ebu_lock);
253 +EXPORT_SYMBOL_GPL(ebu_lock);
255 static struct ltq_soc_info soc_info;
257 unsigned int ltq_get_cpu_ver(void)
258 @@ -57,16 +61,50 @@ static void __init prom_init_cmdline(voi
262 -void __init prom_init(void)
263 +void __iomem *ltq_remap_resource(struct resource *res)
266 + __iomem void *ret = NULL;
267 + struct resource *lookup = lookup_resource(&iomem_resource, res->start);
269 + if (lookup && strcmp(lookup->name, res->name)) {
270 + panic("conflicting memory range %s\n", res->name);
274 + if (insert_resource(&iomem_resource, res) < 0) {
275 + panic("Failed to insert %s memory\n", res->name);
279 + if (request_mem_region(res->start,
280 + resource_size(res), res->name) < 0) {
281 + panic("Failed to request %s memory\n", res->name);
285 + ret = ioremap_nocache(res->start, resource_size(res));
289 + pr_debug("remap: 0x%08X-0x%08X : \"%s\"\n",
290 + res->start, res->end, res->name);
294 + panic("Failed to remap %s memory\n", res->name);
295 + release_mem_region(res->start, resource_size(res));
298 + release_resource(res);
302 +void __init prom_init(void)
304 ltq_soc_detect(&soc_info);
306 - clk = clk_get(0, "cpu");
307 - snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev1.%d",
308 - soc_info.name, soc_info.rev);
310 + snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev %s",
311 + soc_info.name, soc_info.rev_type);
312 soc_info.sys_type[LTQ_SYS_TYPE_LEN - 1] = '\0';
313 pr_info("SoC: %s\n", soc_info.sys_type);
315 --- a/arch/mips/lantiq/prom.h
316 +++ b/arch/mips/lantiq/prom.h
318 #ifndef _LTQ_PROM_H__
319 #define _LTQ_PROM_H__
321 +#define LTQ_SYS_REV_LEN 0x10
322 #define LTQ_SYS_TYPE_LEN 0x100
324 struct ltq_soc_info {
327 + unsigned char rev_type[LTQ_SYS_REV_LEN];
329 unsigned int partnum;
331 unsigned char sys_type[LTQ_SYS_TYPE_LEN];
334 extern void ltq_soc_detect(struct ltq_soc_info *i);
335 +extern void ltq_soc_init(void);
336 extern void ltq_soc_setup(void);
339 --- a/arch/mips/lantiq/xway/Makefile
340 +++ b/arch/mips/lantiq/xway/Makefile
342 -obj-y := pmu.o ebu.o reset.o gpio.o gpio_stp.o gpio_ebu.o devices.o dma.o
343 +obj-y := sysctrl.o reset.o gpio.o gpio_stp.o gpio_ebu.o devices.o dma.o
345 -obj-$(CONFIG_SOC_XWAY) += clk-xway.o prom-xway.o setup-xway.o
346 -obj-$(CONFIG_SOC_AMAZON_SE) += clk-ase.o prom-ase.o setup-ase.o
347 +obj-$(CONFIG_SOC_XWAY) += clk-xway.o prom-xway.o
348 +obj-$(CONFIG_SOC_AMAZON_SE) += clk-ase.o prom-ase.o
350 obj-$(CONFIG_LANTIQ_MACH_EASY50712) += mach-easy50712.o
351 obj-$(CONFIG_LANTIQ_MACH_EASY50601) += mach-easy50601.o
352 --- a/arch/mips/lantiq/xway/devices.c
353 +++ b/arch/mips/lantiq/xway/devices.c
357 static struct resource ltq_gpio_resource[] = {
360 - .start = LTQ_GPIO0_BASE_ADDR,
361 - .end = LTQ_GPIO0_BASE_ADDR + LTQ_GPIO_SIZE - 1,
362 - .flags = IORESOURCE_MEM,
365 - .start = LTQ_GPIO1_BASE_ADDR,
366 - .end = LTQ_GPIO1_BASE_ADDR + LTQ_GPIO_SIZE - 1,
367 - .flags = IORESOURCE_MEM,
370 - .start = LTQ_GPIO2_BASE_ADDR,
371 - .end = LTQ_GPIO2_BASE_ADDR + LTQ_GPIO_SIZE - 1,
372 - .flags = IORESOURCE_MEM,
374 + MEM_RES("gpio0", LTQ_GPIO0_BASE_ADDR, LTQ_GPIO_SIZE),
375 + MEM_RES("gpio1", LTQ_GPIO1_BASE_ADDR, LTQ_GPIO_SIZE),
376 + MEM_RES("gpio2", LTQ_GPIO2_BASE_ADDR, LTQ_GPIO_SIZE),
379 void __init ltq_register_gpio(void)
380 @@ -64,12 +51,8 @@ void __init ltq_register_gpio(void)
383 /* serial to parallel conversion */
384 -static struct resource ltq_stp_resource = {
386 - .start = LTQ_STP_BASE_ADDR,
387 - .end = LTQ_STP_BASE_ADDR + LTQ_STP_SIZE - 1,
388 - .flags = IORESOURCE_MEM,
390 +static struct resource ltq_stp_resource =
391 + MEM_RES("stp", LTQ_STP_BASE_ADDR, LTQ_STP_SIZE);
393 void __init ltq_register_gpio_stp(void)
395 @@ -78,12 +61,7 @@ void __init ltq_register_gpio_stp(void)
397 /* asc ports - amazon se has its own serial mapping */
398 static struct resource ltq_ase_asc_resources[] = {
401 - .start = LTQ_ASC1_BASE_ADDR,
402 - .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
403 - .flags = IORESOURCE_MEM,
405 + MEM_RES("asc0", LTQ_ASC1_BASE_ADDR, LTQ_ASC_SIZE),
406 IRQ_RES(tx, LTQ_ASC_ASE_TIR),
407 IRQ_RES(rx, LTQ_ASC_ASE_RIR),
408 IRQ_RES(err, LTQ_ASC_ASE_EIR),
409 @@ -96,12 +74,8 @@ void __init ltq_register_ase_asc(void)
413 -static struct resource ltq_etop_resources = {
415 - .start = LTQ_ETOP_BASE_ADDR,
416 - .end = LTQ_ETOP_BASE_ADDR + LTQ_ETOP_SIZE - 1,
417 - .flags = IORESOURCE_MEM,
419 +static struct resource ltq_etop_resources =
420 + MEM_RES("etop", LTQ_ETOP_BASE_ADDR, LTQ_ETOP_SIZE);
422 static struct platform_device ltq_etop = {
424 --- a/arch/mips/lantiq/xway/dma.c
425 +++ b/arch/mips/lantiq/xway/dma.c
427 #include <lantiq_soc.h>
428 #include <xway_dma.h>
430 +#include "../devices.h"
432 #define LTQ_DMA_CTRL 0x10
433 #define LTQ_DMA_CPOLL 0x14
434 #define LTQ_DMA_CS 0x18
436 #define ltq_dma_w32_mask(x, y, z) ltq_w32_mask(x, y, \
437 ltq_dma_membase + (z))
439 -static struct resource ltq_dma_resource = {
441 - .start = LTQ_DMA_BASE_ADDR,
442 - .end = LTQ_DMA_BASE_ADDR + LTQ_DMA_SIZE - 1,
443 - .flags = IORESOURCE_MEM,
445 +static struct resource ltq_dma_resource =
446 + MEM_RES("dma", LTQ_DMA_BASE_ADDR, LTQ_DMA_SIZE);
448 static void __iomem *ltq_dma_membase;
450 @@ -219,17 +217,8 @@ ltq_dma_init(void)
454 - /* insert and request the memory region */
455 - if (insert_resource(&iomem_resource, <q_dma_resource) < 0)
456 - panic("Failed to insert dma memory\n");
458 - if (request_mem_region(ltq_dma_resource.start,
459 - resource_size(<q_dma_resource), "dma") < 0)
460 - panic("Failed to request dma memory\n");
462 /* remap dma register range */
463 - ltq_dma_membase = ioremap_nocache(ltq_dma_resource.start,
464 - resource_size(<q_dma_resource));
465 + ltq_dma_membase = ltq_remap_resource(<q_dma_resource);
466 if (!ltq_dma_membase)
467 panic("Failed to remap dma memory\n");
469 --- a/arch/mips/lantiq/xway/ebu.c
473 - * This program is free software; you can redistribute it and/or modify it
474 - * under the terms of the GNU General Public License version 2 as published
475 - * by the Free Software Foundation.
477 - * EBU - the external bus unit attaches PCI, NOR and NAND
479 - * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
482 -#include <linux/kernel.h>
483 -#include <linux/module.h>
484 -#include <linux/ioport.h>
486 -#include <lantiq_soc.h>
488 -/* all access to the ebu must be locked */
489 -DEFINE_SPINLOCK(ebu_lock);
490 -EXPORT_SYMBOL_GPL(ebu_lock);
492 -static struct resource ltq_ebu_resource = {
494 - .start = LTQ_EBU_BASE_ADDR,
495 - .end = LTQ_EBU_BASE_ADDR + LTQ_EBU_SIZE - 1,
496 - .flags = IORESOURCE_MEM,
499 -/* remapped base addr of the clock unit and external bus unit */
500 -void __iomem *ltq_ebu_membase;
502 -static int __init lantiq_ebu_init(void)
504 - /* insert and request the memory region */
505 - if (insert_resource(&iomem_resource, <q_ebu_resource) < 0)
506 - panic("Failed to insert ebu memory\n");
508 - if (request_mem_region(ltq_ebu_resource.start,
509 - resource_size(<q_ebu_resource), "ebu") < 0)
510 - panic("Failed to request ebu memory\n");
512 - /* remap ebu register range */
513 - ltq_ebu_membase = ioremap_nocache(ltq_ebu_resource.start,
514 - resource_size(<q_ebu_resource));
515 - if (!ltq_ebu_membase)
516 - panic("Failed to remap ebu memory\n");
518 - /* make sure to unprotect the memory region where flash is located */
519 - ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_BUSCON0) & ~EBU_WRDIS, LTQ_EBU_BUSCON0);
523 -postcore_initcall(lantiq_ebu_init);
524 --- a/arch/mips/lantiq/xway/pmu.c
528 - * This program is free software; you can redistribute it and/or modify it
529 - * under the terms of the GNU General Public License version 2 as published
530 - * by the Free Software Foundation.
532 - * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
535 -#include <linux/kernel.h>
536 -#include <linux/module.h>
537 -#include <linux/ioport.h>
539 -#include <lantiq_soc.h>
541 -/* PMU - the power management unit allows us to turn part of the core
545 -/* the enable / disable registers */
546 -#define LTQ_PMU_PWDCR 0x1C
547 -#define LTQ_PMU_PWDSR 0x20
549 -#define ltq_pmu_w32(x, y) ltq_w32((x), ltq_pmu_membase + (y))
550 -#define ltq_pmu_r32(x) ltq_r32(ltq_pmu_membase + (x))
552 -static struct resource ltq_pmu_resource = {
554 - .start = LTQ_PMU_BASE_ADDR,
555 - .end = LTQ_PMU_BASE_ADDR + LTQ_PMU_SIZE - 1,
556 - .flags = IORESOURCE_MEM,
559 -static void __iomem *ltq_pmu_membase;
561 -void ltq_pmu_enable(unsigned int module)
565 - ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) & ~module, LTQ_PMU_PWDCR);
566 - do {} while (--err && (ltq_pmu_r32(LTQ_PMU_PWDSR) & module));
569 - panic("activating PMU module failed!\n");
571 -EXPORT_SYMBOL(ltq_pmu_enable);
573 -void ltq_pmu_disable(unsigned int module)
575 - ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) | module, LTQ_PMU_PWDCR);
577 -EXPORT_SYMBOL(ltq_pmu_disable);
579 -int __init ltq_pmu_init(void)
581 - if (insert_resource(&iomem_resource, <q_pmu_resource) < 0)
582 - panic("Failed to insert pmu memory\n");
584 - if (request_mem_region(ltq_pmu_resource.start,
585 - resource_size(<q_pmu_resource), "pmu") < 0)
586 - panic("Failed to request pmu memory\n");
588 - ltq_pmu_membase = ioremap_nocache(ltq_pmu_resource.start,
589 - resource_size(<q_pmu_resource));
590 - if (!ltq_pmu_membase)
591 - panic("Failed to remap pmu memory\n");
595 -core_initcall(ltq_pmu_init);
596 --- a/arch/mips/lantiq/xway/prom-ase.c
597 +++ b/arch/mips/lantiq/xway/prom-ase.c
600 #include <lantiq_soc.h>
602 +#include "devices.h"
605 #define SOC_AMAZON_SE "Amazon_SE"
606 @@ -26,6 +27,7 @@ void __init ltq_soc_detect(struct ltq_so
608 i->partnum = (ltq_r32(LTQ_MPS_CHIPID) & PART_MASK) >> PART_SHIFT;
609 i->rev = (ltq_r32(LTQ_MPS_CHIPID) & REV_MASK) >> REV_SHIFT;
610 + sprintf(i->rev_type, "1.%d", i->rev);
611 switch (i->partnum) {
612 case SOC_ID_AMAZON_SE:
613 i->name = SOC_AMAZON_SE;
614 @@ -37,3 +39,10 @@ void __init ltq_soc_detect(struct ltq_so
619 +void __init ltq_soc_setup(void)
621 + ltq_register_ase_asc();
622 + ltq_register_gpio();
623 + ltq_register_wdt();
625 --- a/arch/mips/lantiq/xway/prom-xway.c
626 +++ b/arch/mips/lantiq/xway/prom-xway.c
629 #include <lantiq_soc.h>
631 +#include "devices.h"
634 #define SOC_DANUBE "Danube"
635 @@ -28,6 +29,7 @@ void __init ltq_soc_detect(struct ltq_so
637 i->partnum = (ltq_r32(LTQ_MPS_CHIPID) & PART_MASK) >> PART_SHIFT;
638 i->rev = (ltq_r32(LTQ_MPS_CHIPID) & REV_MASK) >> REV_SHIFT;
639 + sprintf(i->rev_type, "1.%d", i->rev);
640 switch (i->partnum) {
643 @@ -52,3 +54,11 @@ void __init ltq_soc_detect(struct ltq_so
648 +void __init ltq_soc_setup(void)
650 + ltq_register_asc(0);
651 + ltq_register_asc(1);
652 + ltq_register_gpio();
653 + ltq_register_wdt();
655 --- a/arch/mips/lantiq/xway/reset.c
656 +++ b/arch/mips/lantiq/xway/reset.c
659 #include <lantiq_soc.h>
661 +#include "../devices.h"
663 #define ltq_rcu_w32(x, y) ltq_w32((x), ltq_rcu_membase + (y))
664 #define ltq_rcu_r32(x) ltq_r32(ltq_rcu_membase + (x))
667 #define LTQ_RCU_RST_STAT 0x0014
668 #define LTQ_RCU_STAT_SHIFT 26
670 -static struct resource ltq_rcu_resource = {
672 - .start = LTQ_RCU_BASE_ADDR,
673 - .end = LTQ_RCU_BASE_ADDR + LTQ_RCU_SIZE - 1,
674 - .flags = IORESOURCE_MEM,
676 +static struct resource ltq_rcu_resource =
677 + MEM_RES("rcu", LTQ_RCU_BASE_ADDR, LTQ_RCU_SIZE);
679 /* remapped base addr of the reset control unit */
680 static void __iomem *ltq_rcu_membase;
681 @@ -67,17 +65,8 @@ static void ltq_machine_power_off(void)
683 static int __init mips_reboot_setup(void)
685 - /* insert and request the memory region */
686 - if (insert_resource(&iomem_resource, <q_rcu_resource) < 0)
687 - panic("Failed to insert rcu memory\n");
689 - if (request_mem_region(ltq_rcu_resource.start,
690 - resource_size(<q_rcu_resource), "rcu") < 0)
691 - panic("Failed to request rcu memory\n");
693 /* remap rcu register range */
694 - ltq_rcu_membase = ioremap_nocache(ltq_rcu_resource.start,
695 - resource_size(<q_rcu_resource));
696 + ltq_rcu_membase = ltq_remap_resource(<q_rcu_resource);
697 if (!ltq_rcu_membase)
698 panic("Failed to remap rcu memory\n");
700 --- a/arch/mips/lantiq/xway/setup-ase.c
704 - * This program is free software; you can redistribute it and/or modify it
705 - * under the terms of the GNU General Public License version 2 as published
706 - * by the Free Software Foundation.
708 - * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
711 -#include <lantiq_soc.h>
713 -#include "../prom.h"
714 -#include "devices.h"
716 -void __init ltq_soc_setup(void)
718 - ltq_register_ase_asc();
719 - ltq_register_gpio();
720 - ltq_register_wdt();
722 --- a/arch/mips/lantiq/xway/setup-xway.c
726 - * This program is free software; you can redistribute it and/or modify it
727 - * under the terms of the GNU General Public License version 2 as published
728 - * by the Free Software Foundation.
730 - * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
733 -#include <lantiq_soc.h>
735 -#include "../prom.h"
736 -#include "devices.h"
738 -void __init ltq_soc_setup(void)
740 - ltq_register_asc(0);
741 - ltq_register_asc(1);
742 - ltq_register_gpio();
743 - ltq_register_wdt();
746 +++ b/arch/mips/lantiq/xway/sysctrl.c
749 + * This program is free software; you can redistribute it and/or modify it
750 + * under the terms of the GNU General Public License version 2 as published
751 + * by the Free Software Foundation.
753 + * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
756 +#include <linux/ioport.h>
758 +#include <lantiq_soc.h>
760 +#include "../devices.h"
762 +/* clock control register */
763 +#define LTQ_CGU_IFCCR 0x0018
765 +/* the enable / disable registers */
766 +#define LTQ_PMU_PWDCR 0x1C
767 +#define LTQ_PMU_PWDSR 0x20
769 +#define ltq_pmu_w32(x, y) ltq_w32((x), ltq_pmu_membase + (y))
770 +#define ltq_pmu_r32(x) ltq_r32(ltq_pmu_membase + (x))
772 +static struct resource ltq_cgu_resource =
773 + MEM_RES("cgu", LTQ_CGU_BASE_ADDR, LTQ_CGU_SIZE);
775 +static struct resource ltq_pmu_resource =
776 + MEM_RES("pmu", LTQ_PMU_BASE_ADDR, LTQ_PMU_SIZE);
778 +static struct resource ltq_ebu_resource =
779 + MEM_RES("ebu", LTQ_EBU_BASE_ADDR, LTQ_EBU_SIZE);
781 +void __iomem *ltq_cgu_membase;
782 +void __iomem *ltq_ebu_membase;
783 +static void __iomem *ltq_pmu_membase;
785 +void ltq_cgu_enable(unsigned int clk)
787 + ltq_cgu_w32(ltq_cgu_r32(LTQ_CGU_IFCCR) | clk, LTQ_CGU_IFCCR);
790 +void ltq_pmu_enable(unsigned int module)
794 + ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) & ~module, LTQ_PMU_PWDCR);
795 + do {} while (--err && (ltq_pmu_r32(LTQ_PMU_PWDSR) & module));
798 + panic("activating PMU module failed!\n");
800 +EXPORT_SYMBOL(ltq_pmu_enable);
802 +void ltq_pmu_disable(unsigned int module)
804 + ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) | module, LTQ_PMU_PWDCR);
806 +EXPORT_SYMBOL(ltq_pmu_disable);
808 +void __init ltq_soc_init(void)
810 + ltq_pmu_membase = ltq_remap_resource(<q_pmu_resource);
811 + if (!ltq_pmu_membase)
812 + panic("Failed to remap pmu memory\n");
814 + ltq_cgu_membase = ltq_remap_resource(<q_cgu_resource);
815 + if (!ltq_cgu_membase)
816 + panic("Failed to remap cgu memory\n");
818 + ltq_ebu_membase = ltq_remap_resource(<q_ebu_resource);
819 + if (!ltq_ebu_membase)
820 + panic("Failed to remap ebu memory\n");
822 + /* make sure to unprotect the memory region where flash is located */
823 + ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_BUSCON0) & ~EBU_WRDIS, LTQ_EBU_BUSCON0);
825 --- a/drivers/watchdog/lantiq_wdt.c
826 +++ b/drivers/watchdog/lantiq_wdt.c
828 #include <linux/clk.h>
829 #include <linux/io.h>
832 +#include <lantiq_soc.h>
834 /* Section 3.4 of the datasheet
835 * The password sequence protects the WDT control register from unintended