|
@@ -199,6 +199,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
|
|
struct backlight_properties props;
|
|
struct backlight_properties props;
|
|
struct backlight_device *bl;
|
|
struct backlight_device *bl;
|
|
struct pwm_bl_data *pb;
|
|
struct pwm_bl_data *pb;
|
|
|
|
+ phandle phandle = pdev->dev.of_node->phandle;
|
|
|
|
+ int initial_blank = FB_BLANK_UNBLANK;
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
if (!data) {
|
|
if (!data) {
|
|
@@ -242,7 +244,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
|
|
pb->enabled = false;
|
|
pb->enabled = false;
|
|
|
|
|
|
pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
|
|
pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
|
|
- GPIOD_OUT_HIGH);
|
|
|
|
|
|
+ GPIOD_ASIS);
|
|
if (IS_ERR(pb->enable_gpio)) {
|
|
if (IS_ERR(pb->enable_gpio)) {
|
|
ret = PTR_ERR(pb->enable_gpio);
|
|
ret = PTR_ERR(pb->enable_gpio);
|
|
goto err_alloc;
|
|
goto err_alloc;
|
|
@@ -264,12 +266,30 @@ static int pwm_backlight_probe(struct platform_device *pdev)
|
|
pb->enable_gpio = gpio_to_desc(data->enable_gpio);
|
|
pb->enable_gpio = gpio_to_desc(data->enable_gpio);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (pb->enable_gpio) {
|
|
|
|
+ /*
|
|
|
|
+ * If the driver is probed from the device tree and there is a
|
|
|
|
+ * phandle link pointing to the backlight node, it is safe to
|
|
|
|
+ * assume that another driver will enable the backlight at the
|
|
|
|
+ * appropriate time. Therefore, if it is disabled, keep it so.
|
|
|
|
+ */
|
|
|
|
+ if (phandle &&
|
|
|
|
+ gpiod_get_direction(pb->enable_gpio) == GPIOF_DIR_OUT &&
|
|
|
|
+ gpiod_get_value(pb->enable_gpio) == 0)
|
|
|
|
+ initial_blank = FB_BLANK_POWERDOWN;
|
|
|
|
+ else
|
|
|
|
+ gpiod_direction_output(pb->enable_gpio, 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
pb->power_supply = devm_regulator_get(&pdev->dev, "power");
|
|
pb->power_supply = devm_regulator_get(&pdev->dev, "power");
|
|
if (IS_ERR(pb->power_supply)) {
|
|
if (IS_ERR(pb->power_supply)) {
|
|
ret = PTR_ERR(pb->power_supply);
|
|
ret = PTR_ERR(pb->power_supply);
|
|
goto err_alloc;
|
|
goto err_alloc;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (phandle && !regulator_is_enabled(pb->power_supply))
|
|
|
|
+ initial_blank = FB_BLANK_POWERDOWN;
|
|
|
|
+
|
|
pb->pwm = devm_pwm_get(&pdev->dev, NULL);
|
|
pb->pwm = devm_pwm_get(&pdev->dev, NULL);
|
|
if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER
|
|
if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER
|
|
&& !pdev->dev.of_node) {
|
|
&& !pdev->dev.of_node) {
|
|
@@ -320,6 +340,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
|
|
}
|
|
}
|
|
|
|
|
|
bl->props.brightness = data->dft_brightness;
|
|
bl->props.brightness = data->dft_brightness;
|
|
|
|
+ bl->props.power = initial_blank;
|
|
backlight_update_status(bl);
|
|
backlight_update_status(bl);
|
|
|
|
|
|
platform_set_drvdata(pdev, bl);
|
|
platform_set_drvdata(pdev, bl);
|