2 * drivers/misc/max1749.c
4 * Driver for MAX1749, vibrator motor driver.
6 * Copyright (c) 2011, NVIDIA Corporation.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include <linux/module.h>
24 #include <linux/regulator/consumer.h>
25 #include <linux/kernel.h>
26 #include <linux/platform_device.h>
27 #include <linux/err.h>
28 #include <linux/hrtimer.h>
29 #include <linux/delay.h>
31 #include "../staging/android/timed_output.h"
33 static struct regulator *regulator;
36 static void vibrator_start(void)
38 regulator_enable(regulator);
41 static void vibrator_stop(void)
45 ret = regulator_is_enabled(regulator);
47 regulator_disable(regulator);
51 * Timeout value can be changed from sysfs entry
52 * created by timed_output_dev.
53 * echo 100 > /sys/class/timed_output/vibrator/enable
55 static void vibrator_enable(struct timed_output_dev *dev, int value)
71 * Timeout value can be read from sysfs entry
72 * created by timed_output_dev.
73 * cat /sys/class/timed_output/vibrator/enable
75 static int vibrator_get_time(struct timed_output_dev *dev)
80 static struct timed_output_dev vibrator_dev = {
82 .get_time = vibrator_get_time,
83 .enable = vibrator_enable,
86 static int __init vibrator_init(void)
90 regulator = regulator_get(NULL, "vdd_vbrtr");
91 if (IS_ERR_OR_NULL(regulator)) {
92 pr_err("vibrator_init:Couldn't get regulator vdd_vbrtr\n");
94 return PTR_ERR(regulator);
97 status = timed_output_dev_register(&vibrator_dev);
100 regulator_put(regulator);
106 static void __exit vibrator_exit(void)
109 timed_output_dev_unregister(&vibrator_dev);
110 regulator_put(regulator);
115 MODULE_DESCRIPTION("timed output vibrator device");
116 MODULE_AUTHOR("GPL");
118 module_init(vibrator_init);
119 module_exit(vibrator_exit);