forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/video/backlight/tosa_lcd.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * LCD / Backlight control code for Sharp SL-6000x (tosa)
34 *
45 * Copyright (c) 2005 Dirk Opfer
56 * Copyright (c) 2007,2008 Dmitry Baryshkov
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
117 */
128
139 #include <linux/kernel.h>
....@@ -16,14 +12,14 @@
1612 #include <linux/spi/spi.h>
1713 #include <linux/i2c.h>
1814 #include <linux/slab.h>
19
-#include <linux/gpio.h>
15
+#include <linux/gpio/consumer.h>
2016 #include <linux/delay.h>
2117 #include <linux/lcd.h>
2218 #include <linux/fb.h>
2319
2420 #include <asm/mach/sharpsl_param.h>
2521
26
-#include <mach/tosa.h>
22
+#include "tosa_bl.h"
2723
2824 #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
2925
....@@ -32,12 +28,26 @@
3228 #define TG_REG0_UD 0x0004
3329 #define TG_REG0_LR 0x0008
3430
31
+/*
32
+ * Timing Generator
33
+ */
34
+#define TG_PNLCTL 0x00
35
+#define TG_TPOSCTL 0x01
36
+#define TG_DUTYCTL 0x02
37
+#define TG_GPOSR 0x03
38
+#define TG_GPODR1 0x04
39
+#define TG_GPODR2 0x05
40
+#define TG_PINICTL 0x06
41
+#define TG_HPOSCTL 0x07
42
+
43
+
3544 #define DAC_BASE 0x4e
3645
3746 struct tosa_lcd_data {
3847 struct spi_device *spi;
3948 struct lcd_device *lcd;
4049 struct i2c_client *i2c;
50
+ struct gpio_desc *gpiod_tg;
4151
4252 int lcd_power;
4353 bool is_vga;
....@@ -70,7 +80,7 @@
7080 static void tosa_lcd_tg_init(struct tosa_lcd_data *data)
7181 {
7282 /* TG on */
73
- gpio_set_value(TOSA_GPIO_TG_ON, 0);
83
+ gpiod_set_value(data->gpiod_tg, 0);
7484
7585 mdelay(60);
7686
....@@ -97,18 +107,19 @@
97107 /* TG LCD GVSS */
98108 tosa_tg_send(spi, TG_PINICTL, 0x0);
99109
100
- if (!data->i2c) {
110
+ if (IS_ERR_OR_NULL(data->i2c)) {
101111 /*
102112 * after the pannel is powered up the first time,
103113 * we can access the i2c bus so probe for the DAC
104114 */
105115 struct i2c_adapter *adap = i2c_get_adapter(0);
106116 struct i2c_board_info info = {
117
+ .dev_name = "tosa-bl",
107118 .type = "tosa-bl",
108119 .addr = DAC_BASE,
109120 .platform_data = data->spi,
110121 };
111
- data->i2c = i2c_new_device(adap, &info);
122
+ data->i2c = i2c_new_client_device(adap, &info);
112123 }
113124 }
114125
....@@ -125,7 +136,7 @@
125136 mdelay(50);
126137
127138 /* TG Off */
128
- gpio_set_value(TOSA_GPIO_TG_ON, 1);
139
+ gpiod_set_value(data->gpiod_tg, 1);
129140 mdelay(100);
130141 }
131142
....@@ -195,10 +206,9 @@
195206 data->spi = spi;
196207 spi_set_drvdata(spi, data);
197208
198
- ret = devm_gpio_request_one(&spi->dev, TOSA_GPIO_TG_ON,
199
- GPIOF_OUT_INIT_LOW, "tg #pwr");
200
- if (ret < 0)
201
- return ret;
209
+ data->gpiod_tg = devm_gpiod_get(&spi->dev, "tg #pwr", GPIOD_OUT_LOW);
210
+ if (IS_ERR(data->gpiod_tg))
211
+ return PTR_ERR(data->gpiod_tg);
202212
203213 mdelay(60);
204214
....@@ -226,8 +236,7 @@
226236 {
227237 struct tosa_lcd_data *data = spi_get_drvdata(spi);
228238
229
- if (data->i2c)
230
- i2c_unregister_device(data->i2c);
239
+ i2c_unregister_device(data->i2c);
231240
232241 tosa_lcd_tg_off(data);
233242