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 diff --git a/arch/mips/include/asm/mach-lantiq/lantiq.h b/arch/mips/include/asm/mach-lantiq/lantiq.h
44 index ce2f029..66d7300 100644
45 --- a/arch/mips/include/asm/mach-lantiq/lantiq.h
46 +++ b/arch/mips/include/asm/mach-lantiq/lantiq.h
50 #include <linux/irq.h>
51 +#include <linux/ioport.h>
53 /* generic reg access functions */
54 #define ltq_r32(reg) __raw_readl(reg)
56 #define ltq_r8(reg) __raw_readb(reg)
57 #define ltq_w8(val, reg) __raw_writeb(val, reg)
59 -/* register access macros for EBU and CGU */
60 -#define ltq_ebu_w32(x, y) ltq_w32((x), ltq_ebu_membase + (y))
61 -#define ltq_ebu_r32(x) ltq_r32(ltq_ebu_membase + (x))
62 -#define ltq_cgu_w32(x, y) ltq_w32((x), ltq_cgu_membase + (y))
63 -#define ltq_cgu_r32(x) ltq_r32(ltq_cgu_membase + (x))
65 -extern __iomem void *ltq_ebu_membase;
66 -extern __iomem void *ltq_cgu_membase;
68 extern unsigned int ltq_get_cpu_ver(void);
69 extern unsigned int ltq_get_soc_type(void);
71 @@ -51,7 +43,9 @@ extern void ltq_enable_irq(struct irq_data *data);
73 /* find out what caused the last cpu reset */
74 extern int ltq_reset_cause(void);
75 -#define LTQ_RST_CAUSE_WDTRST 0x20
77 +/* helper for requesting and remapping resources */
78 +extern void __iomem *ltq_remap_resource(struct resource *res);
80 #define IOPORT_RESOURCE_START 0x10000000
81 #define IOPORT_RESOURCE_END 0xffffffff
82 diff --git a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h b/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
83 index e6d1ca0..da8ff95 100644
84 --- a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
85 +++ b/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
87 #define LTQ_CGU_BASE_ADDR 0x1F103000
88 #define LTQ_CGU_SIZE 0x1000
90 +#define CGU_EPHY 0x10
92 /* ICU - interrupt control unit */
93 #define LTQ_ICU_BASE_ADDR 0x1F880200
94 #define LTQ_ICU_SIZE 0x100
96 #define LTQ_WDT_BASE_ADDR 0x1F8803F0
97 #define LTQ_WDT_SIZE 0x10
99 +#define LTQ_RST_CAUSE_WDTRST 0x20
101 /* STP - serial to parallel conversion unit */
102 #define LTQ_STP_BASE_ADDR 0x1E100BB0
103 #define LTQ_STP_SIZE 0x40
104 @@ -125,11 +129,21 @@
105 #define LTQ_MPS_BASE_ADDR (KSEG1 + 0x1F107000)
106 #define LTQ_MPS_CHIPID ((u32 *)(LTQ_MPS_BASE_ADDR + 0x0344))
108 +/* register access macros for EBU and CGU */
109 +#define ltq_ebu_w32(x, y) ltq_w32((x), ltq_ebu_membase + (y))
110 +#define ltq_ebu_r32(x) ltq_r32(ltq_ebu_membase + (x))
111 +#define ltq_cgu_w32(x, y) ltq_w32((x), ltq_cgu_membase + (y))
112 +#define ltq_cgu_r32(x) ltq_r32(ltq_cgu_membase + (x))
114 +extern __iomem void *ltq_ebu_membase;
115 +extern __iomem void *ltq_cgu_membase;
117 /* request a non-gpio and set the PIO config */
118 extern int ltq_gpio_request(unsigned int pin, unsigned int alt0,
119 unsigned int alt1, unsigned int dir, const char *name);
120 extern void ltq_pmu_enable(unsigned int module);
121 extern void ltq_pmu_disable(unsigned int module);
122 +extern void ltq_cgu_enable(unsigned int clk);
124 static inline int ltq_is_ar9(void)
126 diff --git a/arch/mips/lantiq/clk.c b/arch/mips/lantiq/clk.c
127 index 7e9c0ff..4254f08 100644
128 --- a/arch/mips/lantiq/clk.c
129 +++ b/arch/mips/lantiq/clk.c
131 #include <lantiq_soc.h>
138 @@ -46,16 +47,6 @@ static struct clk cpu_clk_generic[] = {
142 -static struct resource ltq_cgu_resource = {
144 - .start = LTQ_CGU_BASE_ADDR,
145 - .end = LTQ_CGU_BASE_ADDR + LTQ_CGU_SIZE - 1,
146 - .flags = IORESOURCE_MEM,
149 -/* remapped clock register range */
150 -void __iomem *ltq_cgu_membase;
154 cpu_clk = cpu_clk_generic;
155 @@ -133,21 +124,11 @@ void __init plat_time_init(void)
159 - if (insert_resource(&iomem_resource, <q_cgu_resource) < 0)
160 - panic("Failed to insert cgu memory\n");
162 - if (request_mem_region(ltq_cgu_resource.start,
163 - resource_size(<q_cgu_resource), "cgu") < 0)
164 - panic("Failed to request cgu memory\n");
167 - ltq_cgu_membase = ioremap_nocache(ltq_cgu_resource.start,
168 - resource_size(<q_cgu_resource));
169 - if (!ltq_cgu_membase) {
170 - pr_err("Failed to remap cgu memory\n");
173 clk = clk_get(0, "cpu");
174 mips_hpt_frequency = clk_get_rate(clk) / ltq_get_counter_resolution();
175 write_c0_compare(read_c0_count());
176 + pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000);
179 diff --git a/arch/mips/lantiq/devices.c b/arch/mips/lantiq/devices.c
180 index 44a3677..81c7aab 100644
181 --- a/arch/mips/lantiq/devices.c
182 +++ b/arch/mips/lantiq/devices.c
187 -static struct resource ltq_nor_resource = {
189 - .start = LTQ_FLASH_START,
190 - .end = LTQ_FLASH_START + LTQ_FLASH_MAX - 1,
191 - .flags = IORESOURCE_MEM,
193 +static struct resource ltq_nor_resource =
194 + MEM_RES("nor", LTQ_FLASH_START, LTQ_FLASH_MAX);
196 static struct platform_device ltq_nor = {
198 @@ -47,12 +43,8 @@ void __init ltq_register_nor(struct physmap_flash_data *data)
202 -static struct resource ltq_wdt_resource = {
203 - .name = "watchdog",
204 - .start = LTQ_WDT_BASE_ADDR,
205 - .end = LTQ_WDT_BASE_ADDR + LTQ_WDT_SIZE - 1,
206 - .flags = IORESOURCE_MEM,
208 +static struct resource ltq_wdt_resource =
209 + MEM_RES("watchdog", LTQ_WDT_BASE_ADDR, LTQ_WDT_SIZE);
211 void __init ltq_register_wdt(void)
213 @@ -61,24 +53,14 @@ void __init ltq_register_wdt(void)
216 static struct resource ltq_asc0_resources[] = {
219 - .start = LTQ_ASC0_BASE_ADDR,
220 - .end = LTQ_ASC0_BASE_ADDR + LTQ_ASC_SIZE - 1,
221 - .flags = IORESOURCE_MEM,
223 + MEM_RES("asc0", LTQ_ASC0_BASE_ADDR, LTQ_ASC_SIZE),
224 IRQ_RES(tx, LTQ_ASC_TIR(0)),
225 IRQ_RES(rx, LTQ_ASC_RIR(0)),
226 IRQ_RES(err, LTQ_ASC_EIR(0)),
229 static struct resource ltq_asc1_resources[] = {
232 - .start = LTQ_ASC1_BASE_ADDR,
233 - .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
234 - .flags = IORESOURCE_MEM,
236 + MEM_RES("asc1", LTQ_ASC1_BASE_ADDR, LTQ_ASC_SIZE),
237 IRQ_RES(tx, LTQ_ASC_TIR(1)),
238 IRQ_RES(rx, LTQ_ASC_RIR(1)),
239 IRQ_RES(err, LTQ_ASC_EIR(1)),
240 diff --git a/arch/mips/lantiq/devices.h b/arch/mips/lantiq/devices.h
241 index 2947bb1..a03c23f 100644
242 --- a/arch/mips/lantiq/devices.h
243 +++ b/arch/mips/lantiq/devices.h
246 #define IRQ_RES(resname, irq) \
247 {.name = #resname, .start = (irq), .flags = IORESOURCE_IRQ}
248 +#define MEM_RES(resname, adr_start, adr_size) \
249 + { .name = resname, .flags = IORESOURCE_MEM, \
250 + .start = ((adr_start) & ~KSEG1), \
251 + .end = ((adr_start + adr_size - 1) & ~KSEG1) }
253 extern void ltq_register_nor(struct physmap_flash_data *data);
254 extern void ltq_register_wdt(void);
255 diff --git a/arch/mips/lantiq/prom.c b/arch/mips/lantiq/prom.c
256 index 5035c10..fead2cc 100644
257 --- a/arch/mips/lantiq/prom.c
258 +++ b/arch/mips/lantiq/prom.c
263 +/* access to the ebu needs to be locked between different drivers */
264 +DEFINE_SPINLOCK(ebu_lock);
265 +EXPORT_SYMBOL_GPL(ebu_lock);
267 static struct ltq_soc_info soc_info;
269 unsigned int ltq_get_cpu_ver(void)
270 @@ -57,16 +61,50 @@ static void __init prom_init_cmdline(void)
274 -void __init prom_init(void)
275 +void __iomem *ltq_remap_resource(struct resource *res)
278 + __iomem void *ret = NULL;
279 + struct resource *lookup = lookup_resource(&iomem_resource, res->start);
281 + if (lookup && strcmp(lookup->name, res->name)) {
282 + panic("conflicting memory range %s\n", res->name);
286 + if (insert_resource(&iomem_resource, res) < 0) {
287 + panic("Failed to insert %s memory\n", res->name);
291 + if (request_mem_region(res->start,
292 + resource_size(res), res->name) < 0) {
293 + panic("Failed to request %s memory\n", res->name);
297 + ret = ioremap_nocache(res->start, resource_size(res));
301 + pr_debug("remap: 0x%08X-0x%08X : \"%s\"\n",
302 + res->start, res->end, res->name);
306 + panic("Failed to remap %s memory\n", res->name);
307 + release_mem_region(res->start, resource_size(res));
310 + release_resource(res);
314 +void __init prom_init(void)
316 ltq_soc_detect(&soc_info);
318 - clk = clk_get(0, "cpu");
319 - snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev1.%d",
320 - soc_info.name, soc_info.rev);
322 + snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev %s",
323 + soc_info.name, soc_info.rev_type);
324 soc_info.sys_type[LTQ_SYS_TYPE_LEN - 1] = '\0';
325 pr_info("SoC: %s\n", soc_info.sys_type);
327 diff --git a/arch/mips/lantiq/prom.h b/arch/mips/lantiq/prom.h
328 index b4229d9..51dba1b 100644
329 --- a/arch/mips/lantiq/prom.h
330 +++ b/arch/mips/lantiq/prom.h
332 #ifndef _LTQ_PROM_H__
333 #define _LTQ_PROM_H__
335 +#define LTQ_SYS_REV_LEN 0x10
336 #define LTQ_SYS_TYPE_LEN 0x100
338 struct ltq_soc_info {
341 + unsigned char rev_type[LTQ_SYS_REV_LEN];
343 unsigned int partnum;
345 unsigned char sys_type[LTQ_SYS_TYPE_LEN];
348 extern void ltq_soc_detect(struct ltq_soc_info *i);
349 +extern void ltq_soc_init(void);
350 extern void ltq_soc_setup(void);
353 diff --git a/arch/mips/lantiq/xway/Makefile b/arch/mips/lantiq/xway/Makefile
354 index c517f2e..6678402 100644
355 --- a/arch/mips/lantiq/xway/Makefile
356 +++ b/arch/mips/lantiq/xway/Makefile
358 -obj-y := pmu.o ebu.o reset.o gpio.o gpio_stp.o gpio_ebu.o devices.o dma.o
359 +obj-y := sysctrl.o reset.o gpio.o gpio_stp.o gpio_ebu.o devices.o dma.o
361 -obj-$(CONFIG_SOC_XWAY) += clk-xway.o prom-xway.o setup-xway.o
362 -obj-$(CONFIG_SOC_AMAZON_SE) += clk-ase.o prom-ase.o setup-ase.o
363 +obj-$(CONFIG_SOC_XWAY) += clk-xway.o prom-xway.o
364 +obj-$(CONFIG_SOC_AMAZON_SE) += clk-ase.o prom-ase.o
366 obj-$(CONFIG_LANTIQ_MACH_EASY50712) += mach-easy50712.o
367 obj-$(CONFIG_LANTIQ_MACH_EASY50601) += mach-easy50601.o
368 diff --git a/arch/mips/lantiq/xway/devices.c b/arch/mips/lantiq/xway/devices.c
369 index d0e32ab..9bacaa8 100644
370 --- a/arch/mips/lantiq/xway/devices.c
371 +++ b/arch/mips/lantiq/xway/devices.c
375 static struct resource ltq_gpio_resource[] = {
378 - .start = LTQ_GPIO0_BASE_ADDR,
379 - .end = LTQ_GPIO0_BASE_ADDR + LTQ_GPIO_SIZE - 1,
380 - .flags = IORESOURCE_MEM,
383 - .start = LTQ_GPIO1_BASE_ADDR,
384 - .end = LTQ_GPIO1_BASE_ADDR + LTQ_GPIO_SIZE - 1,
385 - .flags = IORESOURCE_MEM,
388 - .start = LTQ_GPIO2_BASE_ADDR,
389 - .end = LTQ_GPIO2_BASE_ADDR + LTQ_GPIO_SIZE - 1,
390 - .flags = IORESOURCE_MEM,
392 + MEM_RES("gpio0", LTQ_GPIO0_BASE_ADDR, LTQ_GPIO_SIZE),
393 + MEM_RES("gpio1", LTQ_GPIO1_BASE_ADDR, LTQ_GPIO_SIZE),
394 + MEM_RES("gpio2", LTQ_GPIO2_BASE_ADDR, LTQ_GPIO_SIZE),
397 void __init ltq_register_gpio(void)
398 @@ -64,12 +51,8 @@ void __init ltq_register_gpio(void)
401 /* serial to parallel conversion */
402 -static struct resource ltq_stp_resource = {
404 - .start = LTQ_STP_BASE_ADDR,
405 - .end = LTQ_STP_BASE_ADDR + LTQ_STP_SIZE - 1,
406 - .flags = IORESOURCE_MEM,
408 +static struct resource ltq_stp_resource =
409 + MEM_RES("stp", LTQ_STP_BASE_ADDR, LTQ_STP_SIZE);
411 void __init ltq_register_gpio_stp(void)
413 @@ -78,12 +61,7 @@ void __init ltq_register_gpio_stp(void)
415 /* asc ports - amazon se has its own serial mapping */
416 static struct resource ltq_ase_asc_resources[] = {
419 - .start = LTQ_ASC1_BASE_ADDR,
420 - .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
421 - .flags = IORESOURCE_MEM,
423 + MEM_RES("asc0", LTQ_ASC1_BASE_ADDR, LTQ_ASC_SIZE),
424 IRQ_RES(tx, LTQ_ASC_ASE_TIR),
425 IRQ_RES(rx, LTQ_ASC_ASE_RIR),
426 IRQ_RES(err, LTQ_ASC_ASE_EIR),
427 @@ -96,12 +74,8 @@ void __init ltq_register_ase_asc(void)
431 -static struct resource ltq_etop_resources = {
433 - .start = LTQ_ETOP_BASE_ADDR,
434 - .end = LTQ_ETOP_BASE_ADDR + LTQ_ETOP_SIZE - 1,
435 - .flags = IORESOURCE_MEM,
437 +static struct resource ltq_etop_resources =
438 + MEM_RES("etop", LTQ_ETOP_BASE_ADDR, LTQ_ETOP_SIZE);
440 static struct platform_device ltq_etop = {
442 diff --git a/arch/mips/lantiq/xway/dma.c b/arch/mips/lantiq/xway/dma.c
443 index 4278a45..af35e62 100644
444 --- a/arch/mips/lantiq/xway/dma.c
445 +++ b/arch/mips/lantiq/xway/dma.c
447 #include <lantiq_soc.h>
448 #include <xway_dma.h>
450 +#include "../devices.h"
452 #define LTQ_DMA_CTRL 0x10
453 #define LTQ_DMA_CPOLL 0x14
454 #define LTQ_DMA_CS 0x18
456 #define ltq_dma_w32_mask(x, y, z) ltq_w32_mask(x, y, \
457 ltq_dma_membase + (z))
459 -static struct resource ltq_dma_resource = {
461 - .start = LTQ_DMA_BASE_ADDR,
462 - .end = LTQ_DMA_BASE_ADDR + LTQ_DMA_SIZE - 1,
463 - .flags = IORESOURCE_MEM,
465 +static struct resource ltq_dma_resource =
466 + MEM_RES("dma", LTQ_DMA_BASE_ADDR, LTQ_DMA_SIZE);
468 static void __iomem *ltq_dma_membase;
470 @@ -219,17 +217,8 @@ ltq_dma_init(void)
474 - /* insert and request the memory region */
475 - if (insert_resource(&iomem_resource, <q_dma_resource) < 0)
476 - panic("Failed to insert dma memory\n");
478 - if (request_mem_region(ltq_dma_resource.start,
479 - resource_size(<q_dma_resource), "dma") < 0)
480 - panic("Failed to request dma memory\n");
482 /* remap dma register range */
483 - ltq_dma_membase = ioremap_nocache(ltq_dma_resource.start,
484 - resource_size(<q_dma_resource));
485 + ltq_dma_membase = ltq_remap_resource(<q_dma_resource);
486 if (!ltq_dma_membase)
487 panic("Failed to remap dma memory\n");
489 diff --git a/arch/mips/lantiq/xway/ebu.c b/arch/mips/lantiq/xway/ebu.c
490 deleted file mode 100644
491 index 66eb52f..0000000
492 --- a/arch/mips/lantiq/xway/ebu.c
496 - * This program is free software; you can redistribute it and/or modify it
497 - * under the terms of the GNU General Public License version 2 as published
498 - * by the Free Software Foundation.
500 - * EBU - the external bus unit attaches PCI, NOR and NAND
502 - * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
505 -#include <linux/kernel.h>
506 -#include <linux/module.h>
507 -#include <linux/version.h>
508 -#include <linux/ioport.h>
510 -#include <lantiq_soc.h>
512 -/* all access to the ebu must be locked */
513 -DEFINE_SPINLOCK(ebu_lock);
514 -EXPORT_SYMBOL_GPL(ebu_lock);
516 -static struct resource ltq_ebu_resource = {
518 - .start = LTQ_EBU_BASE_ADDR,
519 - .end = LTQ_EBU_BASE_ADDR + LTQ_EBU_SIZE - 1,
520 - .flags = IORESOURCE_MEM,
523 -/* remapped base addr of the clock unit and external bus unit */
524 -void __iomem *ltq_ebu_membase;
526 -static int __init lantiq_ebu_init(void)
528 - /* insert and request the memory region */
529 - if (insert_resource(&iomem_resource, <q_ebu_resource) < 0)
530 - panic("Failed to insert ebu memory\n");
532 - if (request_mem_region(ltq_ebu_resource.start,
533 - resource_size(<q_ebu_resource), "ebu") < 0)
534 - panic("Failed to request ebu memory\n");
536 - /* remap ebu register range */
537 - ltq_ebu_membase = ioremap_nocache(ltq_ebu_resource.start,
538 - resource_size(<q_ebu_resource));
539 - if (!ltq_ebu_membase)
540 - panic("Failed to remap ebu memory\n");
542 - /* make sure to unprotect the memory region where flash is located */
543 - ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_BUSCON0) & ~EBU_WRDIS, LTQ_EBU_BUSCON0);
547 -postcore_initcall(lantiq_ebu_init);
548 diff --git a/arch/mips/lantiq/xway/pmu.c b/arch/mips/lantiq/xway/pmu.c
549 deleted file mode 100644
550 index 9d69f01e..0000000
551 --- a/arch/mips/lantiq/xway/pmu.c
555 - * This program is free software; you can redistribute it and/or modify it
556 - * under the terms of the GNU General Public License version 2 as published
557 - * by the Free Software Foundation.
559 - * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
562 -#include <linux/kernel.h>
563 -#include <linux/module.h>
564 -#include <linux/version.h>
565 -#include <linux/ioport.h>
567 -#include <lantiq_soc.h>
569 -/* PMU - the power management unit allows us to turn part of the core
573 -/* the enable / disable registers */
574 -#define LTQ_PMU_PWDCR 0x1C
575 -#define LTQ_PMU_PWDSR 0x20
577 -#define ltq_pmu_w32(x, y) ltq_w32((x), ltq_pmu_membase + (y))
578 -#define ltq_pmu_r32(x) ltq_r32(ltq_pmu_membase + (x))
580 -static struct resource ltq_pmu_resource = {
582 - .start = LTQ_PMU_BASE_ADDR,
583 - .end = LTQ_PMU_BASE_ADDR + LTQ_PMU_SIZE - 1,
584 - .flags = IORESOURCE_MEM,
587 -static void __iomem *ltq_pmu_membase;
589 -void ltq_pmu_enable(unsigned int module)
593 - ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) & ~module, LTQ_PMU_PWDCR);
594 - do {} while (--err && (ltq_pmu_r32(LTQ_PMU_PWDSR) & module));
597 - panic("activating PMU module failed!\n");
599 -EXPORT_SYMBOL(ltq_pmu_enable);
601 -void ltq_pmu_disable(unsigned int module)
603 - ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) | module, LTQ_PMU_PWDCR);
605 -EXPORT_SYMBOL(ltq_pmu_disable);
607 -int __init ltq_pmu_init(void)
609 - if (insert_resource(&iomem_resource, <q_pmu_resource) < 0)
610 - panic("Failed to insert pmu memory\n");
612 - if (request_mem_region(ltq_pmu_resource.start,
613 - resource_size(<q_pmu_resource), "pmu") < 0)
614 - panic("Failed to request pmu memory\n");
616 - ltq_pmu_membase = ioremap_nocache(ltq_pmu_resource.start,
617 - resource_size(<q_pmu_resource));
618 - if (!ltq_pmu_membase)
619 - panic("Failed to remap pmu memory\n");
623 -core_initcall(ltq_pmu_init);
624 diff --git a/arch/mips/lantiq/xway/prom-ase.c b/arch/mips/lantiq/xway/prom-ase.c
625 index abe49f4..aaccdcb 100644
626 --- a/arch/mips/lantiq/xway/prom-ase.c
627 +++ b/arch/mips/lantiq/xway/prom-ase.c
630 #include <lantiq_soc.h>
632 +#include "devices.h"
635 #define SOC_AMAZON_SE "Amazon_SE"
636 @@ -26,6 +27,7 @@ void __init ltq_soc_detect(struct ltq_soc_info *i)
638 i->partnum = (ltq_r32(LTQ_MPS_CHIPID) & PART_MASK) >> PART_SHIFT;
639 i->rev = (ltq_r32(LTQ_MPS_CHIPID) & REV_MASK) >> REV_SHIFT;
640 + sprintf(i->rev_type, "1.%d", i->rev);
641 switch (i->partnum) {
642 case SOC_ID_AMAZON_SE:
643 i->name = SOC_AMAZON_SE;
644 @@ -37,3 +39,10 @@ void __init ltq_soc_detect(struct ltq_soc_info *i)
649 +void __init ltq_soc_setup(void)
651 + ltq_register_ase_asc();
652 + ltq_register_gpio();
653 + ltq_register_wdt();
655 diff --git a/arch/mips/lantiq/xway/prom-xway.c b/arch/mips/lantiq/xway/prom-xway.c
656 index 1686692a..f3d1228 100644
657 --- a/arch/mips/lantiq/xway/prom-xway.c
658 +++ b/arch/mips/lantiq/xway/prom-xway.c
661 #include <lantiq_soc.h>
663 +#include "devices.h"
666 #define SOC_DANUBE "Danube"
667 @@ -28,6 +29,7 @@ void __init ltq_soc_detect(struct ltq_soc_info *i)
669 i->partnum = (ltq_r32(LTQ_MPS_CHIPID) & PART_MASK) >> PART_SHIFT;
670 i->rev = (ltq_r32(LTQ_MPS_CHIPID) & REV_MASK) >> REV_SHIFT;
671 + sprintf(i->rev_type, "1.%d", i->rev);
672 switch (i->partnum) {
675 @@ -52,3 +54,11 @@ void __init ltq_soc_detect(struct ltq_soc_info *i)
680 +void __init ltq_soc_setup(void)
682 + ltq_register_asc(0);
683 + ltq_register_asc(1);
684 + ltq_register_gpio();
685 + ltq_register_wdt();
687 diff --git a/arch/mips/lantiq/xway/reset.c b/arch/mips/lantiq/xway/reset.c
688 index a1be36d..e701a48 100644
689 --- a/arch/mips/lantiq/xway/reset.c
690 +++ b/arch/mips/lantiq/xway/reset.c
693 #include <lantiq_soc.h>
695 +#include "../devices.h"
697 #define ltq_rcu_w32(x, y) ltq_w32((x), ltq_rcu_membase + (y))
698 #define ltq_rcu_r32(x) ltq_r32(ltq_rcu_membase + (x))
701 #define LTQ_RCU_RST_STAT 0x0014
702 #define LTQ_RCU_STAT_SHIFT 26
704 -static struct resource ltq_rcu_resource = {
706 - .start = LTQ_RCU_BASE_ADDR,
707 - .end = LTQ_RCU_BASE_ADDR + LTQ_RCU_SIZE - 1,
708 - .flags = IORESOURCE_MEM,
710 +static struct resource ltq_rcu_resource =
711 + MEM_RES("rcu", LTQ_RCU_BASE_ADDR, LTQ_RCU_SIZE);
713 /* remapped base addr of the reset control unit */
714 static void __iomem *ltq_rcu_membase;
715 @@ -67,17 +65,8 @@ static void ltq_machine_power_off(void)
717 static int __init mips_reboot_setup(void)
719 - /* insert and request the memory region */
720 - if (insert_resource(&iomem_resource, <q_rcu_resource) < 0)
721 - panic("Failed to insert rcu memory\n");
723 - if (request_mem_region(ltq_rcu_resource.start,
724 - resource_size(<q_rcu_resource), "rcu") < 0)
725 - panic("Failed to request rcu memory\n");
727 /* remap rcu register range */
728 - ltq_rcu_membase = ioremap_nocache(ltq_rcu_resource.start,
729 - resource_size(<q_rcu_resource));
730 + ltq_rcu_membase = ltq_remap_resource(<q_rcu_resource);
731 if (!ltq_rcu_membase)
732 panic("Failed to remap rcu memory\n");
734 diff --git a/arch/mips/lantiq/xway/setup-ase.c b/arch/mips/lantiq/xway/setup-ase.c
735 deleted file mode 100644
736 index f6f3267..0000000
737 --- a/arch/mips/lantiq/xway/setup-ase.c
741 - * This program is free software; you can redistribute it and/or modify it
742 - * under the terms of the GNU General Public License version 2 as published
743 - * by the Free Software Foundation.
745 - * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
748 -#include <lantiq_soc.h>
750 -#include "../prom.h"
751 -#include "devices.h"
753 -void __init ltq_soc_setup(void)
755 - ltq_register_ase_asc();
756 - ltq_register_gpio();
757 - ltq_register_wdt();
759 diff --git a/arch/mips/lantiq/xway/setup-xway.c b/arch/mips/lantiq/xway/setup-xway.c
760 deleted file mode 100644
761 index c292f64..0000000
762 --- a/arch/mips/lantiq/xway/setup-xway.c
766 - * This program is free software; you can redistribute it and/or modify it
767 - * under the terms of the GNU General Public License version 2 as published
768 - * by the Free Software Foundation.
770 - * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
773 -#include <lantiq_soc.h>
775 -#include "../prom.h"
776 -#include "devices.h"
778 -void __init ltq_soc_setup(void)
780 - ltq_register_asc(0);
781 - ltq_register_asc(1);
782 - ltq_register_gpio();
783 - ltq_register_wdt();
785 diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c
787 index 0000000..a29944f
789 +++ b/arch/mips/lantiq/xway/sysctrl.c
792 + * This program is free software; you can redistribute it and/or modify it
793 + * under the terms of the GNU General Public License version 2 as published
794 + * by the Free Software Foundation.
796 + * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
799 +#include <linux/ioport.h>
801 +#include <lantiq_soc.h>
803 +#include "../devices.h"
805 +/* clock control register */
806 +#define LTQ_CGU_IFCCR 0x0018
808 +/* the enable / disable registers */
809 +#define LTQ_PMU_PWDCR 0x1C
810 +#define LTQ_PMU_PWDSR 0x20
812 +#define ltq_pmu_w32(x, y) ltq_w32((x), ltq_pmu_membase + (y))
813 +#define ltq_pmu_r32(x) ltq_r32(ltq_pmu_membase + (x))
815 +static struct resource ltq_cgu_resource =
816 + MEM_RES("cgu", LTQ_CGU_BASE_ADDR, LTQ_CGU_SIZE);
818 +static struct resource ltq_pmu_resource =
819 + MEM_RES("pmu", LTQ_PMU_BASE_ADDR, LTQ_PMU_SIZE);
821 +static struct resource ltq_ebu_resource =
822 + MEM_RES("ebu", LTQ_EBU_BASE_ADDR, LTQ_EBU_SIZE);
824 +void __iomem *ltq_cgu_membase;
825 +void __iomem *ltq_ebu_membase;
826 +static void __iomem *ltq_pmu_membase;
828 +void ltq_cgu_enable(unsigned int clk)
830 + ltq_cgu_w32(ltq_cgu_r32(LTQ_CGU_IFCCR) | clk, LTQ_CGU_IFCCR);
833 +void ltq_pmu_enable(unsigned int module)
837 + ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) & ~module, LTQ_PMU_PWDCR);
838 + do {} while (--err && (ltq_pmu_r32(LTQ_PMU_PWDSR) & module));
841 + panic("activating PMU module failed!\n");
843 +EXPORT_SYMBOL(ltq_pmu_enable);
845 +void ltq_pmu_disable(unsigned int module)
847 + ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) | module, LTQ_PMU_PWDCR);
849 +EXPORT_SYMBOL(ltq_pmu_disable);
851 +void __init ltq_soc_init(void)
853 + ltq_pmu_membase = ltq_remap_resource(<q_pmu_resource);
854 + if (!ltq_pmu_membase)
855 + panic("Failed to remap pmu memory\n");
857 + ltq_cgu_membase = ltq_remap_resource(<q_cgu_resource);
858 + if (!ltq_cgu_membase)
859 + panic("Failed to remap cgu memory\n");
861 + ltq_ebu_membase = ltq_remap_resource(<q_ebu_resource);
862 + if (!ltq_ebu_membase)
863 + panic("Failed to remap ebu memory\n");
865 + /* make sure to unprotect the memory region where flash is located */
866 + ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_BUSCON0) & ~EBU_WRDIS, LTQ_EBU_BUSCON0);
868 diff --git a/drivers/watchdog/lantiq_wdt.c b/drivers/watchdog/lantiq_wdt.c
869 index 102aed0..179bf98 100644
870 --- a/drivers/watchdog/lantiq_wdt.c
871 +++ b/drivers/watchdog/lantiq_wdt.c
873 #include <linux/clk.h>
874 #include <linux/io.h>
877 +#include <lantiq_soc.h>
879 /* Section 3.4 of the datasheet
880 * The password sequence protects the WDT control register from unintended