···11+/* linux/include/asm-arm/arch-msm/vreg.h22+ *33+ * Copyright (C) 2008 Google, Inc.44+ * Author: Brian Swetland <swetland@google.com>55+ *66+ * This software is licensed under the terms of the GNU General Public77+ * License version 2, as published by the Free Software Foundation, and88+ * may be copied, distributed, and modified under those terms.99+ *1010+ * This program is distributed in the hope that it will be useful,1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313+ * GNU General Public License for more details.1414+ *1515+ */1616+1717+#ifndef __ARCH_ARM_MACH_MSM_VREG_H1818+#define __ARCH_ARM_MACH_MSM_VREG_H1919+2020+struct vreg;2121+2222+struct vreg *vreg_get(struct device *dev, const char *id);2323+void vreg_put(struct vreg *vreg);2424+2525+int vreg_enable(struct vreg *vreg);2626+void vreg_disable(struct vreg *vreg);2727+int vreg_set_level(struct vreg *vreg, unsigned mv);2828+2929+#endif
+143
arch/arm/mach-msm/vreg.c
···11+/* arch/arm/mach-msm/vreg.c22+ *33+ * Copyright (C) 2008 Google, Inc.44+ * Author: Brian Swetland <swetland@google.com>55+ *66+ * This software is licensed under the terms of the GNU General Public77+ * License version 2, as published by the Free Software Foundation, and88+ * may be copied, distributed, and modified under those terms.99+ *1010+ * This program is distributed in the hope that it will be useful,1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313+ * GNU General Public License for more details.1414+ *1515+ */1616+1717+#include <linux/kernel.h>1818+#include <linux/device.h>1919+#include <linux/init.h>2020+#include <linux/debugfs.h>2121+#include <mach/vreg.h>2222+2323+#include "proc_comm.h"2424+2525+struct vreg {2626+ const char *name;2727+ unsigned id;2828+};2929+3030+#define VREG(_name, _id) { .name = _name, .id = _id, }3131+3232+static struct vreg vregs[] = {3333+ VREG("msma", 0),3434+ VREG("msmp", 1),3535+ VREG("msme1", 2),3636+ VREG("msmc1", 3),3737+ VREG("msmc2", 4),3838+ VREG("gp3", 5),3939+ VREG("msme2", 6),4040+ VREG("gp4", 7),4141+ VREG("gp1", 8),4242+ VREG("tcxo", 9),4343+ VREG("pa", 10),4444+ VREG("rftx", 11),4545+ VREG("rfrx1", 12),4646+ VREG("rfrx2", 13),4747+ VREG("synt", 14),4848+ VREG("wlan", 15),4949+ VREG("usb", 16),5050+ VREG("boost", 17),5151+ VREG("mmc", 18),5252+ VREG("ruim", 19),5353+ VREG("msmc0", 20),5454+ VREG("gp2", 21),5555+ VREG("gp5", 22),5656+ VREG("gp6", 23),5757+ VREG("rf", 24),5858+ VREG("rf_vco", 26),5959+ VREG("mpll", 27),6060+ VREG("s2", 28),6161+ VREG("s3", 29),6262+ VREG("rfubm", 30),6363+ VREG("ncp", 31),6464+};6565+6666+struct vreg *vreg_get(struct device *dev, const char *id)6767+{6868+ int n;6969+ for (n = 0; n < ARRAY_SIZE(vregs); n++) {7070+ if (!strcmp(vregs[n].name, id))7171+ return vregs + n;7272+ }7373+ return 0;7474+}7575+7676+void vreg_put(struct vreg *vreg)7777+{7878+}7979+8080+int vreg_enable(struct vreg *vreg)8181+{8282+ unsigned id = vreg->id;8383+ unsigned enable = 1;8484+ return msm_proc_comm(PCOM_VREG_SWITCH, &id, &enable);8585+}8686+8787+void vreg_disable(struct vreg *vreg)8888+{8989+ unsigned id = vreg->id;9090+ unsigned enable = 0;9191+ msm_proc_comm(PCOM_VREG_SWITCH, &id, &enable);9292+}9393+9494+int vreg_set_level(struct vreg *vreg, unsigned mv)9595+{9696+ unsigned id = vreg->id;9797+ return msm_proc_comm(PCOM_VREG_SET_LEVEL, &id, &mv);9898+}9999+100100+#if defined(CONFIG_DEBUG_FS)101101+102102+static int vreg_debug_set(void *data, u64 val)103103+{104104+ struct vreg *vreg = data;105105+ switch (val) {106106+ case 0:107107+ vreg_disable(vreg);108108+ break;109109+ case 1:110110+ vreg_enable(vreg);111111+ break;112112+ default:113113+ vreg_set_level(vreg, val);114114+ break;115115+ }116116+ return 0;117117+}118118+119119+static int vreg_debug_get(void *data, u64 *val)120120+{121121+ return -ENOSYS;122122+}123123+124124+DEFINE_SIMPLE_ATTRIBUTE(vreg_fops, vreg_debug_get, vreg_debug_set, "%llu\n");125125+126126+static int __init vreg_debug_init(void)127127+{128128+ struct dentry *dent;129129+ int n;130130+131131+ dent = debugfs_create_dir("vreg", 0);132132+ if (IS_ERR(dent))133133+ return 0;134134+135135+ for (n = 0; n < ARRAY_SIZE(vregs); n++)136136+ (void) debugfs_create_file(vregs[n].name, 0644,137137+ dent, vregs + n, &vreg_fops);138138+139139+ return 0;140140+}141141+142142+device_initcall(vreg_debug_init);143143+#endif