nilfs2: fix oopses with doubly mounted snapshots
[linux-2.6/mini2440.git] / arch / arm / mach-msm / vreg.c
blobfcb0b9f256841a291616d85cd1099a09bd8bc088
1 /* arch/arm/mach-msm/vreg.c
3 * Copyright (C) 2008 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
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.
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.
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>
23 #include "proc_comm.h"
25 struct vreg {
26 const char *name;
27 unsigned id;
30 #define VREG(_name, _id) { .name = _name, .id = _id, }
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),
66 struct vreg *vreg_get(struct device *dev, const char *id)
68 int n;
69 for (n = 0; n < ARRAY_SIZE(vregs); n++) {
70 if (!strcmp(vregs[n].name, id))
71 return vregs + n;
73 return 0;
76 void vreg_put(struct vreg *vreg)
80 int vreg_enable(struct vreg *vreg)
82 unsigned id = vreg->id;
83 unsigned enable = 1;
84 return msm_proc_comm(PCOM_VREG_SWITCH, &id, &enable);
87 void vreg_disable(struct vreg *vreg)
89 unsigned id = vreg->id;
90 unsigned enable = 0;
91 msm_proc_comm(PCOM_VREG_SWITCH, &id, &enable);
94 int vreg_set_level(struct vreg *vreg, unsigned mv)
96 unsigned id = vreg->id;
97 return msm_proc_comm(PCOM_VREG_SET_LEVEL, &id, &mv);
100 #if defined(CONFIG_DEBUG_FS)
102 static int vreg_debug_set(void *data, u64 val)
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;
116 return 0;
119 static int vreg_debug_get(void *data, u64 *val)
121 return -ENOSYS;
124 DEFINE_SIMPLE_ATTRIBUTE(vreg_fops, vreg_debug_get, vreg_debug_set, "%llu\n");
126 static int __init vreg_debug_init(void)
128 struct dentry *dent;
129 int n;
131 dent = debugfs_create_dir("vreg", 0);
132 if (IS_ERR(dent))
133 return 0;
135 for (n = 0; n < ARRAY_SIZE(vregs); n++)
136 (void) debugfs_create_file(vregs[n].name, 0644,
137 dent, vregs + n, &vreg_fops);
139 return 0;
142 device_initcall(vreg_debug_init);
143 #endif