| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2015 Heiko Schocher <hs@denx.de> |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 9 | 10 | * Derived from drivers/video/backlight/ld9040.c |
|---|
| 10 | 11 | * |
|---|
| 11 | 12 | * Andrzej Hajda <a.hajda@samsung.com> |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 14 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 15 | | - * published by the Free Software Foundation. |
|---|
| 16 | 13 | */ |
|---|
| 17 | 14 | |
|---|
| 18 | | -#include <drm/drmP.h> |
|---|
| 19 | | -#include <drm/drm_panel.h> |
|---|
| 20 | | - |
|---|
| 15 | +#include <linux/delay.h> |
|---|
| 21 | 16 | #include <linux/gpio/consumer.h> |
|---|
| 17 | +#include <linux/module.h> |
|---|
| 22 | 18 | #include <linux/regulator/consumer.h> |
|---|
| 23 | 19 | #include <linux/spi/spi.h> |
|---|
| 24 | 20 | |
|---|
| 25 | 21 | #include <video/mipi_display.h> |
|---|
| 26 | 22 | #include <video/of_videomode.h> |
|---|
| 27 | 23 | #include <video/videomode.h> |
|---|
| 24 | + |
|---|
| 25 | +#include <drm/drm_device.h> |
|---|
| 26 | +#include <drm/drm_modes.h> |
|---|
| 27 | +#include <drm/drm_panel.h> |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | struct lg4573 { |
|---|
| 30 | 30 | struct drm_panel panel; |
|---|
| .. | .. |
|---|
| 42 | 42 | struct spi_transfer xfer = { |
|---|
| 43 | 43 | .len = 2, |
|---|
| 44 | 44 | }; |
|---|
| 45 | | - u16 temp = cpu_to_be16(data); |
|---|
| 45 | + __be16 temp = cpu_to_be16(data); |
|---|
| 46 | 46 | struct spi_message msg; |
|---|
| 47 | 47 | |
|---|
| 48 | 48 | dev_dbg(ctx->panel.dev, "writing data: %x\n", data); |
|---|
| .. | .. |
|---|
| 197 | 197 | } |
|---|
| 198 | 198 | |
|---|
| 199 | 199 | static const struct drm_display_mode default_mode = { |
|---|
| 200 | | - .clock = 27000, |
|---|
| 200 | + .clock = 28341, |
|---|
| 201 | 201 | .hdisplay = 480, |
|---|
| 202 | 202 | .hsync_start = 480 + 10, |
|---|
| 203 | 203 | .hsync_end = 480 + 10 + 59, |
|---|
| .. | .. |
|---|
| 206 | 206 | .vsync_start = 800 + 15, |
|---|
| 207 | 207 | .vsync_end = 800 + 15 + 15, |
|---|
| 208 | 208 | .vtotal = 800 + 15 + 15 + 15, |
|---|
| 209 | | - .vrefresh = 60, |
|---|
| 210 | 209 | }; |
|---|
| 211 | 210 | |
|---|
| 212 | | -static int lg4573_get_modes(struct drm_panel *panel) |
|---|
| 211 | +static int lg4573_get_modes(struct drm_panel *panel, |
|---|
| 212 | + struct drm_connector *connector) |
|---|
| 213 | 213 | { |
|---|
| 214 | | - struct drm_connector *connector = panel->connector; |
|---|
| 215 | 214 | struct drm_display_mode *mode; |
|---|
| 216 | 215 | |
|---|
| 217 | | - mode = drm_mode_duplicate(panel->drm, &default_mode); |
|---|
| 216 | + mode = drm_mode_duplicate(connector->dev, &default_mode); |
|---|
| 218 | 217 | if (!mode) { |
|---|
| 219 | | - dev_err(panel->drm->dev, "failed to add mode %ux%ux@%u\n", |
|---|
| 218 | + dev_err(panel->dev, "failed to add mode %ux%ux@%u\n", |
|---|
| 220 | 219 | default_mode.hdisplay, default_mode.vdisplay, |
|---|
| 221 | | - default_mode.vrefresh); |
|---|
| 220 | + drm_mode_vrefresh(&default_mode)); |
|---|
| 222 | 221 | return -ENOMEM; |
|---|
| 223 | 222 | } |
|---|
| 224 | 223 | |
|---|
| .. | .. |
|---|
| 227 | 226 | mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; |
|---|
| 228 | 227 | drm_mode_probed_add(connector, mode); |
|---|
| 229 | 228 | |
|---|
| 230 | | - panel->connector->display_info.width_mm = 61; |
|---|
| 231 | | - panel->connector->display_info.height_mm = 103; |
|---|
| 229 | + connector->display_info.width_mm = 61; |
|---|
| 230 | + connector->display_info.height_mm = 103; |
|---|
| 232 | 231 | |
|---|
| 233 | 232 | return 1; |
|---|
| 234 | 233 | } |
|---|
| .. | .. |
|---|
| 259 | 258 | return ret; |
|---|
| 260 | 259 | } |
|---|
| 261 | 260 | |
|---|
| 262 | | - drm_panel_init(&ctx->panel); |
|---|
| 263 | | - ctx->panel.dev = &spi->dev; |
|---|
| 264 | | - ctx->panel.funcs = &lg4573_drm_funcs; |
|---|
| 261 | + drm_panel_init(&ctx->panel, &spi->dev, &lg4573_drm_funcs, |
|---|
| 262 | + DRM_MODE_CONNECTOR_DPI); |
|---|
| 265 | 263 | |
|---|
| 266 | | - return drm_panel_add(&ctx->panel); |
|---|
| 264 | + drm_panel_add(&ctx->panel); |
|---|
| 265 | + |
|---|
| 266 | + return 0; |
|---|
| 267 | 267 | } |
|---|
| 268 | 268 | |
|---|
| 269 | 269 | static int lg4573_remove(struct spi_device *spi) |
|---|