diff options
Diffstat (limited to 'arch/arm/mach-msm/vreg.c')
-rw-r--r-- | arch/arm/mach-msm/vreg.c | 143 |
1 files changed, 143 insertions, 0 deletions
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 | |||
25 | struct vreg { | ||
26 | const char *name; | ||
27 | unsigned id; | ||
28 | }; | ||
29 | |||
30 | #define VREG(_name, _id) { .name = _name, .id = _id, } | ||
31 | |||
32 | static 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 | |||
66 | struct 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 | |||
76 | void vreg_put(struct vreg *vreg) | ||
77 | { | ||
78 | } | ||
79 | |||
80 | int 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 | |||
87 | void 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 | |||
94 | int 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 | |||
102 | static 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 | |||
119 | static int vreg_debug_get(void *data, u64 *val) | ||
120 | { | ||
121 | return -ENOSYS; | ||
122 | } | ||
123 | |||
124 | DEFINE_SIMPLE_ATTRIBUTE(vreg_fops, vreg_debug_get, vreg_debug_set, "%llu\n"); | ||
125 | |||
126 | static 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 | |||
142 | device_initcall(vreg_debug_init); | ||
143 | #endif | ||