forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
....@@ -1,21 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2013 Red Hat
34 * Author: Rob Clark <robdclark@gmail.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License version 2 as published by
7
- * the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program. If not, see <http://www.gnu.org/licenses/>.
165 */
176
18
-#include <linux/gpio.h>
7
+#include <linux/delay.h>
8
+#include <linux/gpio/consumer.h>
199 #include <linux/pinctrl/consumer.h>
2010
2111 #include "msm_kms.h"
....@@ -79,30 +69,21 @@
7969
8070 static int gpio_config(struct hdmi *hdmi, bool on)
8171 {
82
- struct device *dev = &hdmi->pdev->dev;
8372 const struct hdmi_platform_config *config = hdmi->config;
84
- int ret, i;
73
+ int i;
8574
8675 if (on) {
8776 for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
8877 struct hdmi_gpio_data gpio = config->gpios[i];
8978
90
- if (gpio.num != -1) {
91
- ret = gpio_request(gpio.num, gpio.label);
92
- if (ret) {
93
- dev_err(dev,
94
- "'%s'(%d) gpio_request failed: %d\n",
95
- gpio.label, gpio.num, ret);
96
- goto err;
97
- }
98
-
79
+ if (gpio.gpiod) {
9980 if (gpio.output) {
100
- gpio_direction_output(gpio.num,
101
- gpio.value);
81
+ gpiod_direction_output(gpio.gpiod,
82
+ gpio.value);
10283 } else {
103
- gpio_direction_input(gpio.num);
104
- gpio_set_value_cansleep(gpio.num,
105
- gpio.value);
84
+ gpiod_direction_input(gpio.gpiod);
85
+ gpiod_set_value_cansleep(gpio.gpiod,
86
+ gpio.value);
10687 }
10788 }
10889 }
....@@ -112,29 +93,20 @@
11293 for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
11394 struct hdmi_gpio_data gpio = config->gpios[i];
11495
115
- if (gpio.num == -1)
96
+ if (!gpio.gpiod)
11697 continue;
11798
11899 if (gpio.output) {
119100 int value = gpio.value ? 0 : 1;
120101
121
- gpio_set_value_cansleep(gpio.num, value);
102
+ gpiod_set_value_cansleep(gpio.gpiod, value);
122103 }
123
-
124
- gpio_free(gpio.num);
125
- };
104
+ }
126105
127106 DBG("gpio off");
128107 }
129108
130109 return 0;
131
-err:
132
- while (i--) {
133
- if (config->gpios[i].num != -1)
134
- gpio_free(config->gpios[i].num);
135
- }
136
-
137
- return ret;
138110 }
139111
140112 static void enable_hpd_clocks(struct hdmi *hdmi, bool enable)
....@@ -156,7 +128,7 @@
156128
157129 ret = clk_prepare_enable(hdmi->hpd_clks[i]);
158130 if (ret) {
159
- dev_err(dev,
131
+ DRM_DEV_ERROR(dev,
160132 "failed to enable hpd clk: %s (%d)\n",
161133 config->hpd_clk_names[i], ret);
162134 }
....@@ -180,7 +152,7 @@
180152 for (i = 0; i < config->hpd_reg_cnt; i++) {
181153 ret = regulator_enable(hdmi->hpd_regs[i]);
182154 if (ret) {
183
- dev_err(dev, "failed to enable hpd regulator: %s (%d)\n",
155
+ DRM_DEV_ERROR(dev, "failed to enable hpd regulator: %s (%d)\n",
184156 config->hpd_reg_names[i], ret);
185157 goto fail;
186158 }
....@@ -188,13 +160,13 @@
188160
189161 ret = pinctrl_pm_select_default_state(dev);
190162 if (ret) {
191
- dev_err(dev, "pinctrl state chg failed: %d\n", ret);
163
+ DRM_DEV_ERROR(dev, "pinctrl state chg failed: %d\n", ret);
192164 goto fail;
193165 }
194166
195167 ret = gpio_config(hdmi, true);
196168 if (ret) {
197
- dev_err(dev, "failed to configure GPIOs: %d\n", ret);
169
+ DRM_DEV_ERROR(dev, "failed to configure GPIOs: %d\n", ret);
198170 goto fail;
199171 }
200172
....@@ -322,7 +294,7 @@
322294 const struct hdmi_platform_config *config = hdmi->config;
323295 struct hdmi_gpio_data hpd_gpio = config->gpios[HPD_GPIO_INDEX];
324296
325
- return gpio_get_value(hpd_gpio.num) ?
297
+ return gpiod_get_value(hpd_gpio.gpiod) ?
326298 connector_status_connected :
327299 connector_status_disconnected;
328300 }
....@@ -341,7 +313,7 @@
341313 * some platforms may not have hpd gpio. Rely only on the status
342314 * provided by REG_HDMI_HPD_INT_STATUS in this case.
343315 */
344
- if (hpd_gpio.num == -1)
316
+ if (!hpd_gpio.gpiod)
345317 return detect_reg(hdmi);
346318
347319 do {
....@@ -461,8 +433,10 @@
461433
462434 connector = &hdmi_connector->base;
463435
464
- drm_connector_init(hdmi->dev, connector, &hdmi_connector_funcs,
465
- DRM_MODE_CONNECTOR_HDMIA);
436
+ drm_connector_init_with_ddc(hdmi->dev, connector,
437
+ &hdmi_connector_funcs,
438
+ DRM_MODE_CONNECTOR_HDMIA,
439
+ hdmi->i2c);
466440 drm_connector_helper_add(connector, &msm_hdmi_connector_helper_funcs);
467441
468442 connector->polled = DRM_CONNECTOR_POLL_CONNECT |