diff options
author | Simon Shields <keepcalm444@gmail.com> | 2016-08-01 20:27:36 +1000 |
---|---|---|
committer | Simon Shields <keepcalm444@gmail.com> | 2016-08-02 17:20:14 +1000 |
commit | 9271694bc414bfacdc0854164b08d9686dc50b9b (patch) | |
tree | 59958028826717c0bbdfff73a8e490acf01e0d17 | |
parent | 98bce590f5d092d1436a80b43f6dbedd174cd9e0 (diff) | |
download | kernel_samsung_smdk4412-9271694bc414bfacdc0854164b08d9686dc50b9b.tar.gz kernel_samsung_smdk4412-9271694bc414bfacdc0854164b08d9686dc50b9b.tar.bz2 kernel_samsung_smdk4412-9271694bc414bfacdc0854164b08d9686dc50b9b.zip |
motor: max77693: expose min/max/default/threshold in sysfs
based off a similar patch for klte by Kevin Haggerty
Change-Id: If2b4f1f2c0310fc0a6c3fe49fd680973dce28ef5
-rw-r--r-- | drivers/motor/max77693_haptic.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/drivers/motor/max77693_haptic.c b/drivers/motor/max77693_haptic.c index beb7f2a5c8e..9c83c2597ab 100644 --- a/drivers/motor/max77693_haptic.c +++ b/drivers/motor/max77693_haptic.c @@ -24,6 +24,11 @@ #include <linux/mfd/max77693.h> #include <linux/mfd/max77693-private.h> +#define PWM_MIN 0 +#define PWM_DEFAULT 50 +#define PWM_THRESH 75 +#define PWM_MAX 100 + static unsigned long pwm_val = 50; /* duty in percent */ static int pwm_duty = 27787; /* duty value, 37050=100%, 27787=50%, 18525=0% */ @@ -301,6 +306,42 @@ ssize_t pwm_value_store(struct device *dev, static DEVICE_ATTR(pwm_value, S_IRUGO | S_IWUSR, pwm_value_show, pwm_value_store); +static ssize_t pwm_default_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%u\n", PWM_DEFAULT); +} + +static DEVICE_ATTR(pwm_default, S_IRUGO, + pwm_default_show, NULL); + +static ssize_t pwm_max_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%u\n", PWM_MAX); +} + +static DEVICE_ATTR(pwm_max, S_IRUGO, + pwm_max_show, NULL); + +static ssize_t pwm_min_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%u\n", PWM_MIN); +} + +static DEVICE_ATTR(pwm_min, S_IRUGO, + pwm_min_show, NULL); + +static ssize_t pwm_threshold_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%u\n", PWM_THRESH); +} + +static DEVICE_ATTR(pwm_threshold, S_IRUGO, + pwm_threshold_show, NULL); + static int max77693_haptic_probe(struct platform_device *pdev) { int error = 0; @@ -378,6 +419,23 @@ static int max77693_haptic_probe(struct platform_device *pdev) if (error < 0) { pr_err("[VIB] create sysfs fail: pwm_value\n"); } + error = device_create_file(hap_data->tout_dev.dev, &dev_attr_pwm_max); + if (error < 0) { + pr_err("[VIB] create sysfs fail: pwm_max\n"); + } + error = device_create_file(hap_data->tout_dev.dev, &dev_attr_pwm_min); + if (error < 0) { + pr_err("[VIB] create sysfs fail: pwm_min\n"); + } + error = device_create_file(hap_data->tout_dev.dev, &dev_attr_pwm_default); + if (error < 0) { + pr_err("[VIB] create sysfs fail: pwm_default\n"); + } + error = device_create_file(hap_data->tout_dev.dev, &dev_attr_pwm_threshold); + if (error < 0) { + pr_err("[VIB] create sysfs fail: pwm_threshold\n"); + } + #endif pr_debug("[VIB] -- %s\n", __func__); |