blob: 82e0f34250e431061c8d91e2049f6d20ee9cab82 [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14/* Qualcomm PMIC Multi-Purpose Pin Configurations */
15
16#include <linux/kernel.h>
17#include <linux/device.h>
18#include <linux/init.h>
19#include <linux/debugfs.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070020#include <linux/module.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021
22#include <mach/mpp.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070023#include <mach/proc_comm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024
25int mpp_config_digital_out(unsigned mpp, unsigned config)
26{
27 int err;
28 err = msm_proc_comm(PCOM_PM_MPP_CONFIG, &mpp, &config);
29 if (err)
30 pr_err("%s: msm_proc_comm(PCOM_PM_MPP_CONFIG) failed\n",
31 __func__);
32 return err;
33}
34EXPORT_SYMBOL(mpp_config_digital_out);
35
36int mpp_config_digital_in(unsigned mpp, unsigned config)
37{
38 int err;
39 err = msm_proc_comm(PCOM_PM_MPP_CONFIG_DIGITAL_INPUT, &mpp, &config);
40 if (err)
41 pr_err("%s: msm_proc_comm(PCOM_PM_MPP_CONFIG) failed\n",
42 __func__);
43 return err;
44}
45EXPORT_SYMBOL(mpp_config_digital_in);
46
47#if defined(CONFIG_DEBUG_FS)
48static int test_result;
49
50static int mpp_debug_set(void *data, u64 val)
51{
52 unsigned mpp = (unsigned) data;
53
54 test_result = mpp_config_digital_out(mpp, (unsigned)val);
55 if (test_result) {
56 printk(KERN_ERR
57 "%s: mpp_config_digital_out \
58 [mpp(%d) = 0x%x] failed (err=%d)\n",
59 __func__, mpp, (unsigned)val, test_result);
60 }
61 return 0;
62}
63
64static int mpp_debug_get(void *data, u64 *val)
65{
66 if (!test_result)
67 *val = 0;
68 else
69 *val = 1;
70 return 0;
71}
72
73DEFINE_SIMPLE_ATTRIBUTE(mpp_fops, mpp_debug_get, mpp_debug_set, "%llu\n");
74
75static int __init mpp_debug_init(void)
76{
77 struct dentry *dent;
78 int n;
79 char file_name[16];
80
81 dent = debugfs_create_dir("mpp", 0);
82 if (IS_ERR(dent))
83 return 0;
84
85 for (n = 0; n < MPPS; n++) {
86 snprintf(file_name, sizeof(file_name), "mpp%d", n + 1);
87 debugfs_create_file(file_name, 0644, dent,
88 (void *)n, &mpp_fops);
89 }
90
91 return 0;
92}
93
94device_initcall(mpp_debug_init);
95#endif
96