Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm/hdmi: drop unused GPIO support

The HDMI driver has code to configure extra GPIOs, which predates
pinctrl support. Nowadays all platforms should use pinctrl instead.
Neither of upstreamed Qualcomm platforms uses these properties, so it's
safe to drop them.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Patchwork: https://patchwork.freedesktop.org/patch/488858/
Link: https://lore.kernel.org/r/20220609122350.3157529-7-dmitry.baryshkov@linaro.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

+21 -120
+15 -51
drivers/gpu/drm/msm/hdmi/hdmi.c
··· 233 233 hdmi->pwr_clks[i] = clk; 234 234 } 235 235 236 + hdmi->hpd_gpiod = devm_gpiod_get_optional(&pdev->dev, "hpd", GPIOD_IN); 237 + /* This will catch e.g. -EPROBE_DEFER */ 238 + if (IS_ERR(hdmi->hpd_gpiod)) { 239 + ret = PTR_ERR(hdmi->hpd_gpiod); 240 + DRM_DEV_ERROR(&pdev->dev, "failed to get hpd gpio: (%d)\n", ret); 241 + goto fail; 242 + } 243 + 244 + if (!hdmi->hpd_gpiod) 245 + DBG("failed to get HPD gpio"); 246 + 247 + if (hdmi->hpd_gpiod) 248 + gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); 249 + 236 250 pm_runtime_enable(&pdev->dev); 237 251 238 252 hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0); ··· 423 409 .hpd_freq = hpd_clk_freq_8x74, 424 410 }; 425 411 426 - static const struct { 427 - const char *name; 428 - const bool output; 429 - const int value; 430 - const char *label; 431 - } msm_hdmi_gpio_pdata[] = { 432 - { "qcom,hdmi-tx-ddc-clk", true, 1, "HDMI_DDC_CLK" }, 433 - { "qcom,hdmi-tx-ddc-data", true, 1, "HDMI_DDC_DATA" }, 434 - { "qcom,hdmi-tx-hpd", false, 1, "HDMI_HPD" }, 435 - { "qcom,hdmi-tx-mux-en", true, 1, "HDMI_MUX_EN" }, 436 - { "qcom,hdmi-tx-mux-sel", true, 0, "HDMI_MUX_SEL" }, 437 - { "qcom,hdmi-tx-mux-lpm", true, 1, "HDMI_MUX_LPM" }, 438 - }; 439 - 440 412 /* 441 413 * HDMI audio codec callbacks 442 414 */ ··· 534 534 struct hdmi_platform_config *hdmi_cfg; 535 535 struct hdmi *hdmi; 536 536 struct device_node *of_node = dev->of_node; 537 - int i, err; 537 + int err; 538 538 539 539 hdmi_cfg = (struct hdmi_platform_config *) 540 540 of_device_get_match_data(dev); ··· 545 545 546 546 hdmi_cfg->mmio_name = "core_physical"; 547 547 hdmi_cfg->qfprom_mmio_name = "qfprom_physical"; 548 - 549 - for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) { 550 - const char *name = msm_hdmi_gpio_pdata[i].name; 551 - struct gpio_desc *gpiod; 552 - 553 - /* 554 - * We are fetching the GPIO lines "as is" since the connector 555 - * code is enabling and disabling the lines. Until that point 556 - * the power-on default value will be kept. 557 - */ 558 - gpiod = devm_gpiod_get_optional(dev, name, GPIOD_ASIS); 559 - /* This will catch e.g. -PROBE_DEFER */ 560 - if (IS_ERR(gpiod)) 561 - return PTR_ERR(gpiod); 562 - if (!gpiod) { 563 - /* Try a second time, stripping down the name */ 564 - char name3[32]; 565 - 566 - /* 567 - * Try again after stripping out the "qcom,hdmi-tx" 568 - * prefix. This is mainly to match "hpd-gpios" used 569 - * in the upstream bindings. 570 - */ 571 - if (sscanf(name, "qcom,hdmi-tx-%s", name3)) 572 - gpiod = devm_gpiod_get_optional(dev, name3, GPIOD_ASIS); 573 - if (IS_ERR(gpiod)) 574 - return PTR_ERR(gpiod); 575 - if (!gpiod) 576 - DBG("failed to get gpio: %s", name); 577 - } 578 - hdmi_cfg->gpios[i].gpiod = gpiod; 579 - if (gpiod) 580 - gpiod_set_consumer_name(gpiod, msm_hdmi_gpio_pdata[i].label); 581 - hdmi_cfg->gpios[i].output = msm_hdmi_gpio_pdata[i].output; 582 - hdmi_cfg->gpios[i].value = msm_hdmi_gpio_pdata[i].value; 583 - } 584 548 585 549 dev->platform_data = hdmi_cfg; 586 550
+2 -11
drivers/gpu/drm/msm/hdmi/hdmi.h
··· 19 19 #include "msm_drv.h" 20 20 #include "hdmi.xml.h" 21 21 22 - #define HDMI_MAX_NUM_GPIO 6 23 - 24 22 struct hdmi_phy; 25 23 struct hdmi_platform_config; 26 - 27 - struct hdmi_gpio_data { 28 - struct gpio_desc *gpiod; 29 - bool output; 30 - int value; 31 - }; 32 24 33 25 struct hdmi_audio { 34 26 bool enabled; ··· 52 60 struct regulator_bulk_data *pwr_regs; 53 61 struct clk **hpd_clks; 54 62 struct clk **pwr_clks; 63 + 64 + struct gpio_desc *hpd_gpiod; 55 65 56 66 struct hdmi_phy *phy; 57 67 struct device *phy_dev; ··· 103 109 /* clks that need to be on for screen pwr (ie pixel clk): */ 104 110 const char **pwr_clk_names; 105 111 int pwr_clk_cnt; 106 - 107 - /* gpio's: */ 108 - struct hdmi_gpio_data gpios[HDMI_MAX_NUM_GPIO]; 109 112 }; 110 113 111 114 struct hdmi_bridge {
+4 -58
drivers/gpu/drm/msm/hdmi/hdmi_hpd.c
··· 60 60 } 61 61 } 62 62 63 - static int gpio_config(struct hdmi *hdmi, bool on) 64 - { 65 - const struct hdmi_platform_config *config = hdmi->config; 66 - int i; 67 - 68 - if (on) { 69 - for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) { 70 - struct hdmi_gpio_data gpio = config->gpios[i]; 71 - 72 - if (gpio.gpiod) { 73 - if (gpio.output) { 74 - gpiod_direction_output(gpio.gpiod, 75 - gpio.value); 76 - } else { 77 - gpiod_direction_input(gpio.gpiod); 78 - gpiod_set_value_cansleep(gpio.gpiod, 79 - gpio.value); 80 - } 81 - } 82 - } 83 - 84 - DBG("gpio on"); 85 - } else { 86 - for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) { 87 - struct hdmi_gpio_data gpio = config->gpios[i]; 88 - 89 - if (!gpio.gpiod) 90 - continue; 91 - 92 - if (gpio.output) { 93 - int value = gpio.value ? 0 : 1; 94 - 95 - gpiod_set_value_cansleep(gpio.gpiod, value); 96 - } 97 - } 98 - 99 - DBG("gpio off"); 100 - } 101 - 102 - return 0; 103 - } 104 - 105 63 static void enable_hpd_clocks(struct hdmi *hdmi, bool enable) 106 64 { 107 65 const struct hdmi_platform_config *config = hdmi->config; ··· 112 154 goto fail; 113 155 } 114 156 115 - ret = gpio_config(hdmi, true); 116 - if (ret) { 117 - DRM_DEV_ERROR(dev, "failed to configure GPIOs: %d\n", ret); 118 - goto fail; 119 - } 157 + if (hdmi->hpd_gpiod) 158 + gpiod_set_value_cansleep(hdmi->hpd_gpiod, 1); 120 159 121 160 pm_runtime_get_sync(dev); 122 161 enable_hpd_clocks(hdmi, true); ··· 161 206 162 207 enable_hpd_clocks(hdmi, false); 163 208 pm_runtime_put(dev); 164 - 165 - ret = gpio_config(hdmi, false); 166 - if (ret) 167 - dev_warn(dev, "failed to unconfigure GPIOs: %d\n", ret); 168 209 169 210 ret = pinctrl_pm_select_sleep_state(dev); 170 211 if (ret) ··· 220 269 #define HPD_GPIO_INDEX 2 221 270 static enum drm_connector_status detect_gpio(struct hdmi *hdmi) 222 271 { 223 - const struct hdmi_platform_config *config = hdmi->config; 224 - struct hdmi_gpio_data hpd_gpio = config->gpios[HPD_GPIO_INDEX]; 225 - 226 - return gpiod_get_value(hpd_gpio.gpiod) ? 272 + return gpiod_get_value(hdmi->hpd_gpiod) ? 227 273 connector_status_connected : 228 274 connector_status_disconnected; 229 275 } ··· 230 282 { 231 283 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); 232 284 struct hdmi *hdmi = hdmi_bridge->hdmi; 233 - const struct hdmi_platform_config *config = hdmi->config; 234 - struct hdmi_gpio_data hpd_gpio = config->gpios[HPD_GPIO_INDEX]; 235 285 enum drm_connector_status stat_gpio, stat_reg; 236 286 int retry = 20; 237 287 ··· 237 291 * some platforms may not have hpd gpio. Rely only on the status 238 292 * provided by REG_HDMI_HPD_INT_STATUS in this case. 239 293 */ 240 - if (!hpd_gpio.gpiod) 294 + if (!hdmi->hpd_gpiod) 241 295 return detect_reg(hdmi); 242 296 243 297 do {