Skip to content

Commit

Permalink
max8997_vibrator: remove hardcoded pwm_duty
Browse files Browse the repository at this point in the history
the px boards have larger duty values, so with the hardcoded u1
values vibration is weak

patch set 2: replace pwm_duty_* macros with global variables

Change-Id: I8914095d329e2fddbe1ef4e1439b43a4b7dfc8cd
  • Loading branch information
ohanar authored and Gokhan Moral committed Sep 11, 2012
1 parent f40f906 commit 051fff5
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions drivers/motor/max8997_vibrator.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
#include "mach/gpio.h"
#endif

static int pwm_duty_max;
static int pwm_duty_min;

static unsigned long pwm_val = 50; /* duty in percent */
static int pwm_duty = 28230; /* duty value, 37640=100% 28230=50%, 18820=0% */
static int pwm_duty; /* duty value */

struct vibrator_drvdata {
struct max8997_motor_data *pdata;
Expand All @@ -44,7 +47,7 @@ struct vibrator_drvdata {
};

#ifdef CONFIG_VIBETONZ
struct vibrator_drvdata *g_data;
static struct vibrator_drvdata *g_data;
#endif

static int vibetonz_clk_on(struct device *dev, bool en)
Expand Down Expand Up @@ -228,14 +231,13 @@ SAMSUNGROM pwm_duty = pwm_period/2 + ((pwm_period/2 - 2) * nForce)/127;
}
}
EXPORT_SYMBOL(vibtonz_pwm);
#endif

static ssize_t pwm_val_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int count;

pwm_val = ((pwm_duty - 18820) * 100) / 18820;
pwm_val = ((pwm_duty - pwm_duty_min) * 100) / pwm_duty_min;

count = sprintf(buf, "%lu\n", pwm_val);
pr_debug("[VIB] pwm_val: %lu\n", pwm_val);
Expand All @@ -252,14 +254,14 @@ ssize_t pwm_val_store(struct device *dev,

pr_info("[VIB] %s: pwm_val=%lu\n", __func__, pwm_val);

pwm_duty = (pwm_val * 18820) / 100 + 18820;
pwm_duty = (pwm_val * pwm_duty_min) / 100 + pwm_duty_min;

/* make sure new pwm duty is in range */
if(pwm_duty > 37640) {
pwm_duty = 37640;
if(pwm_duty > pwm_duty_max) {
pwm_duty = pwm_duty_max;
}
else if (pwm_duty < 18820) {
pwm_duty = 18820;
else if (pwm_duty < pwm_duty_min) {
pwm_duty = pwm_duty_min;
}

pr_info("[VIB] %s: pwm_duty=%d\n", __func__, pwm_duty);
Expand All @@ -268,6 +270,7 @@ ssize_t pwm_val_store(struct device *dev,
}
static DEVICE_ATTR(pwm_val, S_IRUGO | S_IWUSR,
pwm_val_show, pwm_val_store);
#endif

static int create_vibrator_sysfs(void)
{
Expand Down Expand Up @@ -349,6 +352,9 @@ static int __devinit vibrator_probe(struct platform_device *pdev)

#ifdef CONFIG_VIBETONZ
g_data = ddata;
pwm_duty_max = g_data->pdata->duty;
pwm_duty_min = pwm_duty_max/2;
pwm_duty = (pwm_duty_min + pwm_duty_max)/2;
#endif

return 0;
Expand Down

0 comments on commit 051fff5

Please sign in to comment.