diff options
| author | Oleksandr Kozaruk <oleksandr.kozaruk@globallogic.com> | 2015-07-31 14:58:14 -0700 |
|---|---|---|
| committer | Evan Wilson <evan@oliodevices.com> | 2015-08-07 12:54:31 -0700 |
| commit | 17effd3107a92f2579d28ad8d0b39c44d401bf4b (patch) | |
| tree | 215d551a6de3bc33090ccf76ddeb963c9ab8e4bb | |
| parent | 5370cf916ba7717c002caa9e51785d07e6ef5270 (diff) | |
| download | olio-linux-3.10-17effd3107a92f2579d28ad8d0b39c44d401bf4b.tar.xz olio-linux-3.10-17effd3107a92f2579d28ad8d0b39c44d401bf4b.zip | |
olio: LM3530: backlight: Add simple enable/disable mode
New mode is similar to 'manual' but it allows to enable/disable
backlight using PWM pin.
Change-Id: I205cd716bfa56573e5efe9b78918f8742bd7c0f3
Signed-off-by: Evan Wilson <evan@oliodevices.com>
| -rw-r--r-- | drivers/leds/leds-lm3530.c | 13 | ||||
| -rw-r--r-- | include/linux/led-lm3530.h | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index e3acd8583e5..c3d4a69655f 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c @@ -22,6 +22,7 @@ #include <linux/types.h> #include <linux/regulator/consumer.h> #include <linux/module.h> +#include <linux/gpio.h> #define LM3530_LED_DEV "lcd-backlight" #define LM3530_NAME "lm3530-led" @@ -92,6 +93,7 @@ struct lm3530_mode_map { static struct lm3530_mode_map mode_map[] = { { "man", LM3530_BL_MODE_MANUAL }, + { "man", LM3530_BL_MODE_SIMPLE_MANUAL }, { "als", LM3530_BL_MODE_ALS }, { "pwm", LM3530_BL_MODE_PWM }, }; @@ -246,6 +248,11 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) case LM3530_BL_MODE_MANUAL: gen_config |= LM3530_ENABLE_I2C; break; + case LM3530_BL_MODE_SIMPLE_MANUAL: + gen_config |= LM3530_ENABLE_I2C | LM3530_ENABLE_PWM_SIMPLE | + LM3530_ENABLE_PWM | + (pdata->pwm_pol_hi << LM3530_PWM_POL_SHIFT); + break; case LM3530_BL_MODE_ALS: gen_config |= LM3530_ENABLE_I2C; lm3530_als_configure(pdata, &als); @@ -317,6 +324,7 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev, switch (drvdata->mode) { case LM3530_BL_MODE_MANUAL: + case LM3530_BL_MODE_SIMPLE_MANUAL: if (!drvdata->enable) { err = lm3530_init_registers(drvdata); @@ -471,6 +479,11 @@ static int lm3530_probe(struct i2c_client *client, goto err_create_file; } + if (gpio_request_one(drvdata->pdata->pwm_gpio, + GPIOF_DIR_OUT | GPIOF_EXPORT | GPIOF_INIT_HIGH, + "backlight gpio")) + dev_err(&client->dev, "Failed to request gpio:\n"); + return 0; err_create_file: diff --git a/include/linux/led-lm3530.h b/include/linux/led-lm3530.h index 4b133479d6e..963ecb68002 100644 --- a/include/linux/led-lm3530.h +++ b/include/linux/led-lm3530.h @@ -60,6 +60,7 @@ enum lm3530_mode { LM3530_BL_MODE_MANUAL = 0, /* "man" */ + LM3530_BL_MODE_SIMPLE_MANUAL, /* "man" simple enable/disable */ LM3530_BL_MODE_ALS, /* "als" */ LM3530_BL_MODE_PWM, /* "pwm" */ }; @@ -93,6 +94,7 @@ struct lm3530_pwm_data { * @als_vmin: als input voltage calibrated for max brightness in mV * @als_vmax: als input voltage calibrated for min brightness in mV * @brt_val: brightness value (0-127) + * @pwm_gpio: PWM control pin * @pwm_data: PWM control functions (only valid when the mode is PWM) */ struct lm3530_platform_data { @@ -115,6 +117,8 @@ struct lm3530_platform_data { u8 brt_val; + int pwm_gpio; + struct lm3530_pwm_data pwm_data; }; |