Skip to content

Commit ae53db0

Browse files
committed
arm64: dts: qcom: samsung-gtelwifiue: Add RT8555 backlight driver
This adds the RT8555 backlight driver to the device tree. Using i2c-gpio here is necessary, as the backlight ic is not on any i2c pins. Signed-off-by: Michael Abood <[email protected]>
1 parent 15da270 commit ae53db0

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

Diff for: arch/arm64/boot/dts/qcom/apq8016-samsung-gtelwifiue.dts

+36
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@
4747
};
4848
};
4949

50+
i2c-bl {
51+
status = "okay";
52+
compatible = "i2c-gpio";
53+
sda-gpios = <&msmgpio 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
54+
scl-gpios = <&msmgpio 25 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
55+
56+
pinctrl-names = "default";
57+
pinctrl-0 = <&bl_i2c_default>;
58+
59+
#address-cells = <1>;
60+
#size-cells = <0>;
61+
62+
backlight@31 {
63+
status = "okay";
64+
compatible = "richtek,rt8555-backlight";
65+
gpio = <&msmgpio 69 GPIO_ACTIVE_HIGH>;
66+
reg = <0x31>;
67+
};
68+
};
69+
5070
reg_vdd_tsp: regulator-vdd-tsp {
5171
compatible = "regulator-fixed";
5272
regulator-name = "vdd_tsp";
@@ -315,6 +335,22 @@
315335
bias-disable;
316336
};
317337

338+
bl_en_default: reg-lcd-en-default {
339+
pins = "gpio69";
340+
function = "gpio";
341+
342+
drive-strength = <2>;
343+
bias-disable;
344+
};
345+
346+
bl_i2c_default: muic-i2c-default {
347+
pins = "gpio24", "gpio25";
348+
function = "gpio";
349+
350+
drive-strength = <2>;
351+
bias-disable;
352+
};
353+
318354
gpio_keys_default: gpio-keys-default {
319355
pins = "gpio107", "gpio109";
320356
function = "gpio";

Diff for: drivers/video/backlight/rt8555-backlight.c

+12-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ struct rt8555_priv {
2929
static int rt8555_bl_update_status(struct backlight_device *bl_dev)
3030
{
3131
struct rt8555_priv *priv = bl_get_data(bl_dev);
32-
unsigned int brightness = min(backlight_get_brightness(bl_dev), RT8555_MAX_BRIGHTNESS);
32+
unsigned int brightness = min(backlight_get_brightness(bl_dev), priv->bl->props.max_brightness);
3333
int ret;
3434

3535
/* Enable the IC before setting the brightness */
3636
if (brightness)
37-
if (!IS_ERR(priv->enable))
37+
if (!IS_ERR_OR_NULL(priv->enable))
3838
gpiod_set_value(priv->enable, 1);
3939

4040

@@ -48,7 +48,7 @@ static int rt8555_bl_update_status(struct backlight_device *bl_dev)
4848

4949
/* Disable the IC after setting it to 0 */
5050
if (brightness == 0)
51-
if (!IS_ERR(priv->enable))
51+
if (!IS_ERR_OR_NULL(priv->enable))
5252
gpiod_set_value(priv->enable, 0);
5353

5454
return 0;
@@ -61,7 +61,7 @@ static int rt8555_bl_get_brightness(struct backlight_device *bl_dev)
6161

6262
/* If the RT8555 is disabled, there's no reason to turn it on just to read
6363
* it back */
64-
if (!IS_ERR(priv->enable))
64+
if (!IS_ERR_OR_NULL(priv->enable))
6565
if (gpiod_get_value(priv->enable) == 0)
6666
return 0;
6767

@@ -103,9 +103,15 @@ static int rt8555_bl_probe(struct i2c_client *client)
103103
priv->dev = &client->dev;
104104

105105
priv->enable = devm_gpiod_get_optional(&client->dev, NULL, GPIOD_OUT_HIGH);
106-
if (!IS_ERR(priv->enable))
106+
if (!IS_ERR_OR_NULL(priv->enable))
107107
gpiod_set_value(priv->enable, 1);
108108

109+
priv->regmap = devm_regmap_init_i2c(client, &rt8555_regmap_config);
110+
if (!priv->regmap) {
111+
dev_err(&client->dev, "Failed to init regmap\n");
112+
return -ENODEV;
113+
}
114+
109115
ret = device_property_read_u32(&client->dev, "max-brightness", &brightness);
110116
if (ret)
111117
brightness = RT8555_MAX_BRIGHTNESS;
@@ -144,7 +150,7 @@ static void rt8555_bl_remove(struct i2c_client *client)
144150
bl_dev->props.brightness = 0;
145151
backlight_update_status(priv->bl);
146152

147-
if (!IS_ERR(priv->enable))
153+
if (!IS_ERR_OR_NULL(priv->enable))
148154
gpiod_set_value(priv->enable, 0);
149155
}
150156

0 commit comments

Comments
 (0)