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"
30 #define VREG(_name, _id) { .name = _name, .id = _id, }
32 static struct vreg vregs[] = {
66 struct vreg *vreg_get(struct device *dev, const char *id)
69 for (n = 0; n < ARRAY_SIZE(vregs); n++) {
70 if (!strcmp(vregs[n].name, id))
76 void vreg_put(struct vreg *vreg)
80 int vreg_enable(struct vreg *vreg)
82 unsigned id = vreg->id;
84 return msm_proc_comm(PCOM_VREG_SWITCH, &id, &enable);
87 void vreg_disable(struct vreg *vreg)
89 unsigned id = vreg->id;
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;
113 vreg_set_level(vreg, val);
119 static int vreg_debug_get(void *data, u64 *val)
124 DEFINE_SIMPLE_ATTRIBUTE(vreg_fops, vreg_debug_get, vreg_debug_set, "%llu\n");
126 static int __init vreg_debug_init(void)
131 dent = debugfs_create_dir("vreg", 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);
142 device_initcall(vreg_debug_init);