aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-msm/Makefile1
-rw-r--r--arch/arm/mach-msm/include/mach/vreg.h29
-rw-r--r--arch/arm/mach-msm/vreg.c143
3 files changed, 173 insertions, 0 deletions
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index bfcb2518ba53..1aa47001aa3b 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -1,6 +1,7 @@
1obj-y += io.o idle.o irq.o timer.o dma.o 1obj-y += io.o idle.o irq.o timer.o dma.o
2obj-y += devices.o 2obj-y += devices.o
3obj-y += proc_comm.o 3obj-y += proc_comm.o
4obj-y += vreg.o
4obj-y += clock.o clock-7x01a.o 5obj-y += clock.o clock-7x01a.o
5 6
6obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o 7obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o
diff --git a/arch/arm/mach-msm/include/mach/vreg.h b/arch/arm/mach-msm/include/mach/vreg.h
new file mode 100644
index 000000000000..9f9e25cb718e
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/vreg.h
@@ -0,0 +1,29 @@
1/* linux/include/asm-arm/arch-msm/vreg.h
2 *
3 * Copyright (C) 2008 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#ifndef __ARCH_ARM_MACH_MSM_VREG_H
18#define __ARCH_ARM_MACH_MSM_VREG_H
19
20struct vreg;
21
22struct vreg *vreg_get(struct device *dev, const char *id);
23void vreg_put(struct vreg *vreg);
24
25int vreg_enable(struct vreg *vreg);
26void vreg_disable(struct vreg *vreg);
27int vreg_set_level(struct vreg *vreg, unsigned mv);
28
29#endif
diff --git a/arch/arm/mach-msm/vreg.c b/arch/arm/mach-msm/vreg.c
new file mode 100644
index 000000000000..fcb0b9f25684
--- /dev/null
+++ b/arch/arm/mach-msm/vreg.c
@@ -0,0 +1,143 @@
1/* arch/arm/mach-msm/vreg.c
2 *
3 * Copyright (C) 2008 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/device.h>
19#include <linux/init.h>
20#include <linux/debugfs.h>
21#include <mach/vreg.h>
22
23#include "proc_comm.h"
24
25struct vreg {
26 const char *name;
27 unsigned id;
28};
29
30#define VREG(_name, _id) { .name = _name, .id = _id, }
31
32static struct vreg vregs[] = {
33 VREG("msma", 0),
34 VREG("msmp", 1),
35 VREG("msme1", 2),
36 VREG("msmc1", 3),
37 VREG("msmc2", 4),
38 VREG("gp3", 5),
39 VREG("msme2", 6),
40 VREG("gp4", 7),
41 VREG("gp1", 8),
42 VREG("tcxo", 9),
43 VREG("pa", 10),
44 VREG("rftx", 11),
45 VREG("rfrx1", 12),
46 VREG("rfrx2", 13),
47 VREG("synt", 14),
48 VREG("wlan", 15),
49 VREG("usb", 16),
50 VREG("boost", 17),
51 VREG("mmc", 18),
52 VREG("ruim", 19),
53 VREG("msmc0", 20),
54 VREG("gp2", 21),
55 VREG("gp5", 22),
56 VREG("gp6", 23),
57 VREG("rf", 24),
58 VREG("rf_vco", 26),
59 VREG("mpll", 27),
60 VREG("s2", 28),
61 VREG("s3", 29),
62 VREG("rfubm", 30),
63 VREG("ncp", 31),
64};
65
66struct vreg *vreg_get(struct device *dev, const char *id)
67{
68 int n;
69 for (n = 0; n < ARRAY_SIZE(vregs); n++) {
70 if (!strcmp(vregs[n].name, id))
71 return vregs + n;
72 }
73 return 0;
74}
75
76void vreg_put(struct vreg *vreg)
77{
78}
79
80int vreg_enable(struct vreg *vreg)
81{
82 unsigned id = vreg->id;
83 unsigned enable = 1;
84 return msm_proc_comm(PCOM_VREG_SWITCH, &id, &enable);
85}
86
87void vreg_disable(struct vreg *vreg)
88{
89 unsigned id = vreg->id;
90 unsigned enable = 0;
91 msm_proc_comm(PCOM_VREG_SWITCH, &id, &enable);
92}
93
94int vreg_set_level(struct vreg *vreg, unsigned mv)
95{
96 unsigned id = vreg->id;
97 return msm_proc_comm(PCOM_VREG_SET_LEVEL, &id, &mv);
98}
99
100#if defined(CONFIG_DEBUG_FS)
101
102static int vreg_debug_set(void *data, u64 val)
103{
104 struct vreg *vreg = data;
105 switch (val) {
106 case 0:
107 vreg_disable(vreg);
108 break;
109 case 1:
110 vreg_enable(vreg);
111 break;
112 default:
113 vreg_set_level(vreg, val);
114 break;
115 }
116 return 0;
117}
118
119static int vreg_debug_get(void *data, u64 *val)
120{
121 return -ENOSYS;
122}
123
124DEFINE_SIMPLE_ATTRIBUTE(vreg_fops, vreg_debug_get, vreg_debug_set, "%llu\n");
125
126static int __init vreg_debug_init(void)
127{
128 struct dentry *dent;
129 int n;
130
131 dent = debugfs_create_dir("vreg", 0);
132 if (IS_ERR(dent))
133 return 0;
134
135 for (n = 0; n < ARRAY_SIZE(vregs); n++)
136 (void) debugfs_create_file(vregs[n].name, 0644,
137 dent, vregs + n, &vreg_fops);
138
139 return 0;
140}
141
142device_initcall(vreg_debug_init);
143#endif