hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/video/backlight/sky81452-backlight.c
....@@ -1,33 +1,20 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * sky81452-backlight.c SKY81452 backlight driver
34 *
45 * Copyright 2014 Skyworks Solutions Inc.
56 * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License version 2
9
- * as published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful, but
12
- * WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- * General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License along
17
- * with this program; if not, see <http://www.gnu.org/licenses/>.
187 */
198
209 #include <linux/backlight.h>
2110 #include <linux/err.h>
22
-#include <linux/gpio.h>
11
+#include <linux/gpio/consumer.h>
2312 #include <linux/init.h>
2413 #include <linux/kernel.h>
2514 #include <linux/module.h>
2615 #include <linux/of.h>
27
-#include <linux/of_gpio.h>
2816 #include <linux/platform_device.h>
2917 #include <linux/regmap.h>
30
-#include <linux/platform_data/sky81452-backlight.h>
3118 #include <linux/slab.h>
3219
3320 /* registers */
....@@ -52,6 +39,29 @@
5239
5340 #define SKY81452_DEFAULT_NAME "lcd-backlight"
5441 #define SKY81452_MAX_BRIGHTNESS (SKY81452_CS + 1)
42
+
43
+/**
44
+ * struct sky81452_platform_data
45
+ * @name: backlight driver name.
46
+ * If it is not defined, default name is lcd-backlight.
47
+ * @gpiod_enable:GPIO descriptor which control EN pin
48
+ * @enable: Enable mask for current sink channel 1, 2, 3, 4, 5 and 6.
49
+ * @ignore_pwm: true if DPWMI should be ignored.
50
+ * @dpwm_mode: true is DPWM dimming mode, otherwise Analog dimming mode.
51
+ * @phase_shift:true is phase shift mode.
52
+ * @short_detection_threshold: It should be one of 4, 5, 6 and 7V.
53
+ * @boost_current_limit: It should be one of 2300, 2750mA.
54
+ */
55
+struct sky81452_bl_platform_data {
56
+ const char *name;
57
+ struct gpio_desc *gpiod_enable;
58
+ unsigned int enable;
59
+ bool ignore_pwm;
60
+ bool dpwm_mode;
61
+ bool phase_shift;
62
+ unsigned int short_detection_threshold;
63
+ unsigned int boost_current_limit;
64
+};
5565
5666 #define CTZ(b) __builtin_ctz(b)
5767
....@@ -193,7 +203,7 @@
193203 pdata->ignore_pwm = of_property_read_bool(np, "skyworks,ignore-pwm");
194204 pdata->dpwm_mode = of_property_read_bool(np, "skyworks,dpwm-mode");
195205 pdata->phase_shift = of_property_read_bool(np, "skyworks,phase-shift");
196
- pdata->gpio_enable = of_get_gpio(np, 0);
206
+ pdata->gpiod_enable = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH);
197207
198208 ret = of_property_count_u32_elems(np, "led-sources");
199209 if (ret < 0) {
....@@ -264,26 +274,15 @@
264274 {
265275 struct device *dev = &pdev->dev;
266276 struct regmap *regmap = dev_get_drvdata(dev->parent);
267
- struct sky81452_bl_platform_data *pdata = dev_get_platdata(dev);
277
+ struct sky81452_bl_platform_data *pdata;
268278 struct backlight_device *bd;
269279 struct backlight_properties props;
270280 const char *name;
271281 int ret;
272282
273
- if (!pdata) {
274
- pdata = sky81452_bl_parse_dt(dev);
275
- if (IS_ERR(pdata))
276
- return PTR_ERR(pdata);
277
- }
278
-
279
- if (gpio_is_valid(pdata->gpio_enable)) {
280
- ret = devm_gpio_request_one(dev, pdata->gpio_enable,
281
- GPIOF_OUT_INIT_HIGH, "sky81452-en");
282
- if (ret < 0) {
283
- dev_err(dev, "failed to request GPIO. err=%d\n", ret);
284
- return ret;
285
- }
286
- }
283
+ pdata = sky81452_bl_parse_dt(dev);
284
+ if (IS_ERR(pdata))
285
+ return PTR_ERR(pdata);
287286
288287 ret = sky81452_bl_init_device(regmap, pdata);
289288 if (ret < 0) {
....@@ -324,8 +323,8 @@
324323 bd->props.brightness = 0;
325324 backlight_update_status(bd);
326325
327
- if (gpio_is_valid(pdata->gpio_enable))
328
- gpio_set_value_cansleep(pdata->gpio_enable, 0);
326
+ if (pdata->gpiod_enable)
327
+ gpiod_set_value_cansleep(pdata->gpiod_enable, 0);
329328
330329 return 0;
331330 }