| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2013 Red Hat |
|---|
| 3 | 4 | * 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/>. |
|---|
| 16 | 5 | */ |
|---|
| 17 | 6 | |
|---|
| 18 | | -#include <linux/gpio.h> |
|---|
| 7 | +#include <linux/delay.h> |
|---|
| 8 | +#include <linux/gpio/consumer.h> |
|---|
| 19 | 9 | #include <linux/pinctrl/consumer.h> |
|---|
| 20 | 10 | |
|---|
| 21 | 11 | #include "msm_kms.h" |
|---|
| .. | .. |
|---|
| 79 | 69 | |
|---|
| 80 | 70 | static int gpio_config(struct hdmi *hdmi, bool on) |
|---|
| 81 | 71 | { |
|---|
| 82 | | - struct device *dev = &hdmi->pdev->dev; |
|---|
| 83 | 72 | const struct hdmi_platform_config *config = hdmi->config; |
|---|
| 84 | | - int ret, i; |
|---|
| 73 | + int i; |
|---|
| 85 | 74 | |
|---|
| 86 | 75 | if (on) { |
|---|
| 87 | 76 | for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) { |
|---|
| 88 | 77 | struct hdmi_gpio_data gpio = config->gpios[i]; |
|---|
| 89 | 78 | |
|---|
| 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) { |
|---|
| 99 | 80 | if (gpio.output) { |
|---|
| 100 | | - gpio_direction_output(gpio.num, |
|---|
| 101 | | - gpio.value); |
|---|
| 81 | + gpiod_direction_output(gpio.gpiod, |
|---|
| 82 | + gpio.value); |
|---|
| 102 | 83 | } 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); |
|---|
| 106 | 87 | } |
|---|
| 107 | 88 | } |
|---|
| 108 | 89 | } |
|---|
| .. | .. |
|---|
| 112 | 93 | for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) { |
|---|
| 113 | 94 | struct hdmi_gpio_data gpio = config->gpios[i]; |
|---|
| 114 | 95 | |
|---|
| 115 | | - if (gpio.num == -1) |
|---|
| 96 | + if (!gpio.gpiod) |
|---|
| 116 | 97 | continue; |
|---|
| 117 | 98 | |
|---|
| 118 | 99 | if (gpio.output) { |
|---|
| 119 | 100 | int value = gpio.value ? 0 : 1; |
|---|
| 120 | 101 | |
|---|
| 121 | | - gpio_set_value_cansleep(gpio.num, value); |
|---|
| 102 | + gpiod_set_value_cansleep(gpio.gpiod, value); |
|---|
| 122 | 103 | } |
|---|
| 123 | | - |
|---|
| 124 | | - gpio_free(gpio.num); |
|---|
| 125 | | - }; |
|---|
| 104 | + } |
|---|
| 126 | 105 | |
|---|
| 127 | 106 | DBG("gpio off"); |
|---|
| 128 | 107 | } |
|---|
| 129 | 108 | |
|---|
| 130 | 109 | 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; |
|---|
| 138 | 110 | } |
|---|
| 139 | 111 | |
|---|
| 140 | 112 | static void enable_hpd_clocks(struct hdmi *hdmi, bool enable) |
|---|
| .. | .. |
|---|
| 156 | 128 | |
|---|
| 157 | 129 | ret = clk_prepare_enable(hdmi->hpd_clks[i]); |
|---|
| 158 | 130 | if (ret) { |
|---|
| 159 | | - dev_err(dev, |
|---|
| 131 | + DRM_DEV_ERROR(dev, |
|---|
| 160 | 132 | "failed to enable hpd clk: %s (%d)\n", |
|---|
| 161 | 133 | config->hpd_clk_names[i], ret); |
|---|
| 162 | 134 | } |
|---|
| .. | .. |
|---|
| 180 | 152 | for (i = 0; i < config->hpd_reg_cnt; i++) { |
|---|
| 181 | 153 | ret = regulator_enable(hdmi->hpd_regs[i]); |
|---|
| 182 | 154 | 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", |
|---|
| 184 | 156 | config->hpd_reg_names[i], ret); |
|---|
| 185 | 157 | goto fail; |
|---|
| 186 | 158 | } |
|---|
| .. | .. |
|---|
| 188 | 160 | |
|---|
| 189 | 161 | ret = pinctrl_pm_select_default_state(dev); |
|---|
| 190 | 162 | 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); |
|---|
| 192 | 164 | goto fail; |
|---|
| 193 | 165 | } |
|---|
| 194 | 166 | |
|---|
| 195 | 167 | ret = gpio_config(hdmi, true); |
|---|
| 196 | 168 | 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); |
|---|
| 198 | 170 | goto fail; |
|---|
| 199 | 171 | } |
|---|
| 200 | 172 | |
|---|
| .. | .. |
|---|
| 322 | 294 | const struct hdmi_platform_config *config = hdmi->config; |
|---|
| 323 | 295 | struct hdmi_gpio_data hpd_gpio = config->gpios[HPD_GPIO_INDEX]; |
|---|
| 324 | 296 | |
|---|
| 325 | | - return gpio_get_value(hpd_gpio.num) ? |
|---|
| 297 | + return gpiod_get_value(hpd_gpio.gpiod) ? |
|---|
| 326 | 298 | connector_status_connected : |
|---|
| 327 | 299 | connector_status_disconnected; |
|---|
| 328 | 300 | } |
|---|
| .. | .. |
|---|
| 341 | 313 | * some platforms may not have hpd gpio. Rely only on the status |
|---|
| 342 | 314 | * provided by REG_HDMI_HPD_INT_STATUS in this case. |
|---|
| 343 | 315 | */ |
|---|
| 344 | | - if (hpd_gpio.num == -1) |
|---|
| 316 | + if (!hpd_gpio.gpiod) |
|---|
| 345 | 317 | return detect_reg(hdmi); |
|---|
| 346 | 318 | |
|---|
| 347 | 319 | do { |
|---|
| .. | .. |
|---|
| 461 | 433 | |
|---|
| 462 | 434 | connector = &hdmi_connector->base; |
|---|
| 463 | 435 | |
|---|
| 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); |
|---|
| 466 | 440 | drm_connector_helper_add(connector, &msm_hdmi_connector_helper_funcs); |
|---|
| 467 | 441 | |
|---|
| 468 | 442 | connector->polled = DRM_CONNECTOR_POLL_CONNECT | |
|---|