forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/video/backlight/bd6107.c
....@@ -1,20 +1,17 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ROHM Semiconductor BD6107 LED Driver
34 *
45 * Copyright (C) 2013 Ideas on board SPRL
56 *
67 * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
118 */
129
1310 #include <linux/backlight.h>
1411 #include <linux/delay.h>
1512 #include <linux/err.h>
1613 #include <linux/fb.h>
17
-#include <linux/gpio.h>
14
+#include <linux/gpio/consumer.h>
1815 #include <linux/i2c.h>
1916 #include <linux/module.h>
2017 #include <linux/platform_data/bd6107.h>
....@@ -74,6 +71,7 @@
7471 struct i2c_client *client;
7572 struct backlight_device *backlight;
7673 struct bd6107_platform_data *pdata;
74
+ struct gpio_desc *reset;
7775 };
7876
7977 static int bd6107_write(struct bd6107 *bd, u8 reg, u8 data)
....@@ -84,12 +82,7 @@
8482 static int bd6107_backlight_update_status(struct backlight_device *backlight)
8583 {
8684 struct bd6107 *bd = bl_get_data(backlight);
87
- int brightness = backlight->props.brightness;
88
-
89
- if (backlight->props.power != FB_BLANK_UNBLANK ||
90
- backlight->props.fb_blank != FB_BLANK_UNBLANK ||
91
- backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
92
- brightness = 0;
85
+ int brightness = backlight_get_brightness(backlight);
9386
9487 if (brightness) {
9588 bd6107_write(bd, BD6107_PORTSEL, BD6107_PORTSEL_LEDM(2) |
....@@ -97,9 +90,10 @@
9790 bd6107_write(bd, BD6107_MAINCNT1, brightness);
9891 bd6107_write(bd, BD6107_LEDCNT1, BD6107_LEDCNT1_LEDONOFF1);
9992 } else {
100
- gpio_set_value(bd->pdata->reset, 0);
93
+ /* Assert the reset line (gpiolib will handle active low) */
94
+ gpiod_set_value(bd->reset, 1);
10195 msleep(24);
102
- gpio_set_value(bd->pdata->reset, 1);
96
+ gpiod_set_value(bd->reset, 0);
10397 }
10498
10599 return 0;
....@@ -110,7 +104,7 @@
110104 {
111105 struct bd6107 *bd = bl_get_data(backlight);
112106
113
- return bd->pdata->fbdev == NULL || bd->pdata->fbdev == info->dev;
107
+ return bd->pdata->fbdev == NULL || bd->pdata->fbdev == info->device;
114108 }
115109
116110 static const struct backlight_ops bd6107_backlight_ops = {
....@@ -128,8 +122,8 @@
128122 struct bd6107 *bd;
129123 int ret;
130124
131
- if (pdata == NULL || !pdata->reset) {
132
- dev_err(&client->dev, "No reset GPIO in platform data\n");
125
+ if (pdata == NULL) {
126
+ dev_err(&client->dev, "No platform data\n");
133127 return -EINVAL;
134128 }
135129
....@@ -147,10 +141,16 @@
147141 bd->client = client;
148142 bd->pdata = pdata;
149143
150
- ret = devm_gpio_request_one(&client->dev, pdata->reset,
151
- GPIOF_DIR_OUT | GPIOF_INIT_LOW, "reset");
152
- if (ret < 0) {
144
+ /*
145
+ * Request the reset GPIO line with GPIOD_OUT_HIGH meaning asserted,
146
+ * so in the machine descriptor table (or other hardware description),
147
+ * the line should be flagged as active low so this will assert
148
+ * the reset.
149
+ */
150
+ bd->reset = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
151
+ if (IS_ERR(bd->reset)) {
153152 dev_err(&client->dev, "unable to request reset GPIO\n");
153
+ ret = PTR_ERR(bd->reset);
154154 return ret;
155155 }
156156