| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2012 Texas Instruments |
|---|
| 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/pinctrl/pinmux.h> |
|---|
| 19 | | -#include <linux/pinctrl/consumer.h> |
|---|
| 20 | | -#include <linux/backlight.h> |
|---|
| 21 | 7 | #include <linux/gpio/consumer.h> |
|---|
| 8 | +#include <linux/pinctrl/consumer.h> |
|---|
| 9 | +#include <linux/platform_device.h> |
|---|
| 10 | + |
|---|
| 22 | 11 | #include <video/display_timing.h> |
|---|
| 23 | 12 | #include <video/of_display_timing.h> |
|---|
| 24 | 13 | #include <video/videomode.h> |
|---|
| 25 | | -#include <drm/drm_atomic_helper.h> |
|---|
| 14 | + |
|---|
| 15 | +#include <drm/drm_atomic_state_helper.h> |
|---|
| 16 | +#include <drm/drm_connector.h> |
|---|
| 17 | +#include <drm/drm_modeset_helper_vtables.h> |
|---|
| 18 | +#include <drm/drm_probe_helper.h> |
|---|
| 19 | +#include <drm/drm_simple_kms_helper.h> |
|---|
| 26 | 20 | |
|---|
| 27 | 21 | #include "tilcdc_drv.h" |
|---|
| 28 | 22 | #include "tilcdc_panel.h" |
|---|
| .. | .. |
|---|
| 81 | 75 | /* nothing needed */ |
|---|
| 82 | 76 | } |
|---|
| 83 | 77 | |
|---|
| 84 | | -static const struct drm_encoder_funcs panel_encoder_funcs = { |
|---|
| 85 | | - .destroy = drm_encoder_cleanup, |
|---|
| 86 | | -}; |
|---|
| 87 | | - |
|---|
| 88 | 78 | static const struct drm_encoder_helper_funcs panel_encoder_helper_funcs = { |
|---|
| 89 | 79 | .dpms = panel_encoder_dpms, |
|---|
| 90 | 80 | .prepare = panel_encoder_prepare, |
|---|
| .. | .. |
|---|
| 109 | 99 | encoder = &panel_encoder->base; |
|---|
| 110 | 100 | encoder->possible_crtcs = 1; |
|---|
| 111 | 101 | |
|---|
| 112 | | - ret = drm_encoder_init(dev, encoder, &panel_encoder_funcs, |
|---|
| 113 | | - DRM_MODE_ENCODER_LVDS, NULL); |
|---|
| 102 | + ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_LVDS); |
|---|
| 114 | 103 | if (ret < 0) |
|---|
| 115 | 104 | goto fail; |
|---|
| 116 | 105 | |
|---|
| .. | .. |
|---|
| 174 | 163 | return i; |
|---|
| 175 | 164 | } |
|---|
| 176 | 165 | |
|---|
| 177 | | -static int panel_connector_mode_valid(struct drm_connector *connector, |
|---|
| 178 | | - struct drm_display_mode *mode) |
|---|
| 179 | | -{ |
|---|
| 180 | | - struct tilcdc_drm_private *priv = connector->dev->dev_private; |
|---|
| 181 | | - /* our only constraints are what the crtc can generate: */ |
|---|
| 182 | | - return tilcdc_crtc_mode_valid(priv->crtc, mode); |
|---|
| 183 | | -} |
|---|
| 184 | | - |
|---|
| 185 | 166 | static struct drm_encoder *panel_connector_best_encoder( |
|---|
| 186 | 167 | struct drm_connector *connector) |
|---|
| 187 | 168 | { |
|---|
| .. | .. |
|---|
| 199 | 180 | |
|---|
| 200 | 181 | static const struct drm_connector_helper_funcs panel_connector_helper_funcs = { |
|---|
| 201 | 182 | .get_modes = panel_connector_get_modes, |
|---|
| 202 | | - .mode_valid = panel_connector_mode_valid, |
|---|
| 203 | 183 | .best_encoder = panel_connector_best_encoder, |
|---|
| 204 | 184 | }; |
|---|
| 205 | 185 | |
|---|
| .. | .. |
|---|
| 323 | 303 | |
|---|
| 324 | 304 | static int panel_probe(struct platform_device *pdev) |
|---|
| 325 | 305 | { |
|---|
| 326 | | - struct device_node *bl_node, *node = pdev->dev.of_node; |
|---|
| 306 | + struct device_node *node = pdev->dev.of_node; |
|---|
| 307 | + struct backlight_device *backlight; |
|---|
| 327 | 308 | struct panel_module *panel_mod; |
|---|
| 328 | 309 | struct tilcdc_module *mod; |
|---|
| 329 | 310 | struct pinctrl *pinctrl; |
|---|
| .. | .. |
|---|
| 339 | 320 | if (!panel_mod) |
|---|
| 340 | 321 | return -ENOMEM; |
|---|
| 341 | 322 | |
|---|
| 342 | | - bl_node = of_parse_phandle(node, "backlight", 0); |
|---|
| 343 | | - if (bl_node) { |
|---|
| 344 | | - panel_mod->backlight = of_find_backlight_by_node(bl_node); |
|---|
| 345 | | - of_node_put(bl_node); |
|---|
| 346 | | - |
|---|
| 347 | | - if (!panel_mod->backlight) |
|---|
| 348 | | - return -EPROBE_DEFER; |
|---|
| 349 | | - |
|---|
| 350 | | - dev_info(&pdev->dev, "found backlight\n"); |
|---|
| 351 | | - } |
|---|
| 323 | + backlight = devm_of_find_backlight(&pdev->dev); |
|---|
| 324 | + if (IS_ERR(backlight)) |
|---|
| 325 | + return PTR_ERR(backlight); |
|---|
| 326 | + panel_mod->backlight = backlight; |
|---|
| 352 | 327 | |
|---|
| 353 | 328 | panel_mod->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", |
|---|
| 354 | 329 | GPIOD_OUT_LOW); |
|---|
| .. | .. |
|---|
| 420 | 395 | { }, |
|---|
| 421 | 396 | }; |
|---|
| 422 | 397 | |
|---|
| 423 | | -struct platform_driver panel_driver = { |
|---|
| 398 | +static struct platform_driver panel_driver = { |
|---|
| 424 | 399 | .probe = panel_probe, |
|---|
| 425 | 400 | .remove = panel_remove, |
|---|
| 426 | 401 | .driver = { |
|---|