1 /* arch/arm/mach-msm/vreg.c
3 * Copyright (C) 2008 Google, Inc.
4 * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
5 * Author: Brian Swetland <swetland@google.com>
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #include <linux/kernel.h>
19 #include <linux/device.h>
20 #include <linux/init.h>
21 #include <linux/debugfs.h>
22 #include <mach/vreg.h>
24 #include "proc_comm.h"
32 #define VREG(_name, _id, _status) \
33 { .name = _name, .id = _id, .status = _status }
35 static struct vreg vregs[] = {
61 VREG("rf_vco", 26, 0),
69 struct vreg *vreg_get(struct device *dev, const char *id)
72 for (n = 0; n < ARRAY_SIZE(vregs); n++) {
73 if (!strcmp(vregs[n].name, id))
76 return ERR_PTR(-ENOENT);
79 void vreg_put(struct vreg *vreg)
83 int vreg_enable(struct vreg *vreg)
85 unsigned id = vreg->id;
88 vreg->status = msm_proc_comm(PCOM_VREG_SWITCH, &id, &enable);
92 int vreg_disable(struct vreg *vreg)
94 unsigned id = vreg->id;
97 vreg->status = msm_proc_comm(PCOM_VREG_SWITCH, &id, &enable);
101 int vreg_set_level(struct vreg *vreg, unsigned mv)
103 unsigned id = vreg->id;
105 vreg->status = msm_proc_comm(PCOM_VREG_SET_LEVEL, &id, &mv);
109 #if defined(CONFIG_DEBUG_FS)
111 static int vreg_debug_set(void *data, u64 val)
113 struct vreg *vreg = data;
122 vreg_set_level(vreg, val);
128 static int vreg_debug_get(void *data, u64 *val)
130 struct vreg *vreg = data;
140 DEFINE_SIMPLE_ATTRIBUTE(vreg_fops, vreg_debug_get, vreg_debug_set, "%llu\n");
142 static int __init vreg_debug_init(void)
147 dent = debugfs_create_dir("vreg", 0);
151 for (n = 0; n < ARRAY_SIZE(vregs); n++)
152 (void) debugfs_create_file(vregs[n].name, 0644,
153 dent, vregs + n, &vreg_fops);
158 device_initcall(vreg_debug_init);