diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/mips/lantiq/xway/pmu.c | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'arch/mips/lantiq/xway/pmu.c')
-rw-r--r-- | arch/mips/lantiq/xway/pmu.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/arch/mips/lantiq/xway/pmu.c b/arch/mips/lantiq/xway/pmu.c new file mode 100644 index 00000000000..39f0d2641cb --- /dev/null +++ b/arch/mips/lantiq/xway/pmu.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify it | ||
3 | * under the terms of the GNU General Public License version 2 as published | ||
4 | * by the Free Software Foundation. | ||
5 | * | ||
6 | * Copyright (C) 2010 John Crispin <blogic@openwrt.org> | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/ioport.h> | ||
12 | |||
13 | #include <lantiq_soc.h> | ||
14 | |||
15 | /* PMU - the power management unit allows us to turn part of the core | ||
16 | * on and off | ||
17 | */ | ||
18 | |||
19 | /* the enable / disable registers */ | ||
20 | #define LTQ_PMU_PWDCR 0x1C | ||
21 | #define LTQ_PMU_PWDSR 0x20 | ||
22 | |||
23 | #define ltq_pmu_w32(x, y) ltq_w32((x), ltq_pmu_membase + (y)) | ||
24 | #define ltq_pmu_r32(x) ltq_r32(ltq_pmu_membase + (x)) | ||
25 | |||
26 | static struct resource ltq_pmu_resource = { | ||
27 | .name = "pmu", | ||
28 | .start = LTQ_PMU_BASE_ADDR, | ||
29 | .end = LTQ_PMU_BASE_ADDR + LTQ_PMU_SIZE - 1, | ||
30 | .flags = IORESOURCE_MEM, | ||
31 | }; | ||
32 | |||
33 | static void __iomem *ltq_pmu_membase; | ||
34 | |||
35 | void ltq_pmu_enable(unsigned int module) | ||
36 | { | ||
37 | int err = 1000000; | ||
38 | |||
39 | ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) & ~module, LTQ_PMU_PWDCR); | ||
40 | do {} while (--err && (ltq_pmu_r32(LTQ_PMU_PWDSR) & module)); | ||
41 | |||
42 | if (!err) | ||
43 | panic("activating PMU module failed!\n"); | ||
44 | } | ||
45 | EXPORT_SYMBOL(ltq_pmu_enable); | ||
46 | |||
47 | void ltq_pmu_disable(unsigned int module) | ||
48 | { | ||
49 | ltq_pmu_w32(ltq_pmu_r32(LTQ_PMU_PWDCR) | module, LTQ_PMU_PWDCR); | ||
50 | } | ||
51 | EXPORT_SYMBOL(ltq_pmu_disable); | ||
52 | |||
53 | int __init ltq_pmu_init(void) | ||
54 | { | ||
55 | if (insert_resource(&iomem_resource, <q_pmu_resource) < 0) | ||
56 | panic("Failed to insert pmu memory\n"); | ||
57 | |||
58 | if (request_mem_region(ltq_pmu_resource.start, | ||
59 | resource_size(<q_pmu_resource), "pmu") < 0) | ||
60 | panic("Failed to request pmu memory\n"); | ||
61 | |||
62 | ltq_pmu_membase = ioremap_nocache(ltq_pmu_resource.start, | ||
63 | resource_size(<q_pmu_resource)); | ||
64 | if (!ltq_pmu_membase) | ||
65 | panic("Failed to remap pmu memory\n"); | ||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | core_initcall(ltq_pmu_init); | ||