]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
backlight: LP88XX: add optional device tree props
authorDaniel Solomon <daniels@nvidia.com>
Thu, 8 Dec 2016 02:11:24 +0000 (18:11 -0800)
committermobile promotions <svcmobile_promotions@nvidia.com>
Tue, 17 Jan 2017 22:24:44 +0000 (14:24 -0800)
Add ability to pass a backlight device names via device
tree. The list of backlight driver names are applied, in order,
to LED groupings. If the list doesn't exist or if it contains
fewer names than LED groupings, default backlight device names are used.

Add ability to set initial backlight brightness. If this property
isn't specified, brightness is initialized to 0 (off).

TDS-1403

Change-Id: I47174e418b90f8d1f0973ab0cc08a5be3f743388
Signed-off-by: Daniel Solomon <daniels@nvidia.com>
Reviewed-on: http://git-master/r/1269631
(cherry picked from commit afe01956da3e9c5fba9a34024c18da6d2085e967)
Reviewed-on: http://git-master/r/1267858
GVS: Gerrit_Virtual_Submit
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Tested-by: Ishwarya Balaji Gururajan <igururajan@nvidia.com>
Reviewed-by: Mitch Luban <mluban@nvidia.com>
Documentation/devicetree/bindings/leds/backlight/lp88xx.txt
drivers/video/backlight/lp88xx.h
drivers/video/backlight/lp88xx_core.c

index 37afaa2802933a11a7df0524fcab8be054710d8c..a9cc50ef327391d82206f2ff3d68e52c853e892b 100644 (file)
@@ -12,6 +12,12 @@ Optional properties:
   - irq-gpios: GPIO specifiers for fault interrupt pin.
   - pwms: PWM specifiers for backlight control.
   - slope-time-ms: Lighting effect. Slope time from 0 to 500.
+  - names: Array of backlight driver name strings, in order, for each LED group.
+  - max-input-brt: Maximum expected brightness value passed to the driver.
+    This value is used to scale requested brightness values to the device's
+    actual maximum brightness.
+  - init-brt: Initial backlight brightness (applied to all LED groups). Must be
+    scaled to max-input-brt, if provided, or otherwise max device brightness.
 
 Example 1)
 I2C for device configuration, map region 0 to all LEDs and PWM input for
index 9f71f10028ebb72ad14aec340e1bd105a24c83a0..e1a0355883d414551def138109a2203dfe0b18d3 100644 (file)
@@ -26,6 +26,7 @@ struct lp88xx {
        struct pwm_device *pwm;
        unsigned int period;
        u16 max_dev_brt;
+       u32 max_input_brt;
 };
 
 extern int lp88xx_common_probe(struct device *dev, struct lp88xx *lp);
index 4fa3cc95303a670cb518a904b2f3f6db2e5311cb..9c409ffd43b92e6d02a88ffd7369a6f665486414 100644 (file)
@@ -189,10 +189,12 @@ static int lp88xx_bl_update_status(struct backlight_device *bldev)
 {
        struct lp88xx_bl *bl = bl_get_data(bldev);
        struct lp88xx *lp = bl->lp;
-       u16 val = bldev->props.brightness;
+       u32 val = bldev->props.brightness;
        int duty;
        int ret;
 
+       val = val * lp->max_dev_brt / lp->max_input_brt;
+
        if (val > 0)
                lp88xx_bl_on(lp, 1);
        else
@@ -234,6 +236,7 @@ static int lp88xx_add_bl_device(struct lp88xx *lp, int id)
        struct device *dev = lp->dev;
        struct backlight_properties props;
        char name[64];
+       const char *pname;
        unsigned int reg_brt[] = {
                [LP88XX_REGION_BASE] = LP88XX_REG_BRT_BASE,
                [LP88XX_REGION_LED1] = LP88XX_REG_BRT_LED1,
@@ -252,10 +255,16 @@ static int lp88xx_add_bl_device(struct lp88xx *lp, int id)
        bl->is_db_used = lp88xx_is_db_used(id);
 
        memset(name, 0, sizeof(name));
-       snprintf(name, sizeof(name), "%s:%d", DEFAULT_BL_NAME, id);
+       if (!of_property_read_string_index(dev->of_node, "names",
+               id, &pname))
+               snprintf(name, sizeof(name), "%s", pname);
+       else
+               snprintf(name, sizeof(name), "%s:%d", DEFAULT_BL_NAME, id);
+
        props.type = BACKLIGHT_PLATFORM;
-       props.max_brightness = lp->max_dev_brt;
+       props.max_brightness = lp->max_input_brt;
        props.brightness = 0;
+       of_property_read_s32(dev->of_node, "init-brt", &props.brightness);
 
        bl->bldev = devm_backlight_device_register(dev, name, dev, bl,
                                                   &lp88xx_bl_ops, &props);
@@ -398,6 +407,10 @@ int lp88xx_common_probe(struct device *dev, struct lp88xx *lp)
                lp->max_dev_brt = (1U << val) - 1;
        }
 
+       if (of_property_read_u32(dev->of_node, "max-input-brt",
+               &lp->max_input_brt))
+               lp->max_input_brt = lp->max_dev_brt;
+
        for (i = 0; i < size; i++) {
                if (!lp88xx_is_valid_region(region[i])) {
                        dev_err(dev, "Invalid region ID: %d\n", region[i]);