| .. | .. |
|---|
| 44 | 44 | #include <linux/delay.h> |
|---|
| 45 | 45 | #include <linux/err.h> |
|---|
| 46 | 46 | #include <linux/fb.h> |
|---|
| 47 | | -#include <linux/gpio.h> |
|---|
| 48 | | -#include <linux/gpio/consumer.h> |
|---|
| 49 | 47 | #include <linux/i2c.h> |
|---|
| 50 | 48 | #include <linux/module.h> |
|---|
| 51 | 49 | #include <linux/of.h> |
|---|
| .. | .. |
|---|
| 53 | 51 | #include <linux/of_graph.h> |
|---|
| 54 | 52 | #include <linux/pm.h> |
|---|
| 55 | 53 | |
|---|
| 56 | | -#include <drm/drm_panel.h> |
|---|
| 57 | | -#include <drm/drmP.h> |
|---|
| 58 | 54 | #include <drm/drm_crtc.h> |
|---|
| 55 | +#include <drm/drm_device.h> |
|---|
| 59 | 56 | #include <drm/drm_mipi_dsi.h> |
|---|
| 60 | 57 | #include <drm/drm_panel.h> |
|---|
| 61 | 58 | |
|---|
| .. | .. |
|---|
| 212 | 209 | .vsync_start = 480 + 7, |
|---|
| 213 | 210 | .vsync_end = 480 + 7 + 2, |
|---|
| 214 | 211 | .vtotal = 480 + 7 + 2 + 21, |
|---|
| 215 | | - .vrefresh = 60, |
|---|
| 216 | 212 | }, |
|---|
| 217 | 213 | }; |
|---|
| 218 | 214 | |
|---|
| .. | .. |
|---|
| 233 | 229 | |
|---|
| 234 | 230 | ret = i2c_smbus_write_byte_data(ts->i2c, reg, val); |
|---|
| 235 | 231 | if (ret) |
|---|
| 236 | | - dev_err(&ts->dsi->dev, "I2C write failed: %d\n", ret); |
|---|
| 232 | + dev_err(&ts->i2c->dev, "I2C write failed: %d\n", ret); |
|---|
| 237 | 233 | } |
|---|
| 238 | 234 | |
|---|
| 239 | 235 | static int rpi_touchscreen_write(struct rpi_touchscreen *ts, u16 reg, u32 val) |
|---|
| .. | .. |
|---|
| 269 | 265 | return 0; |
|---|
| 270 | 266 | } |
|---|
| 271 | 267 | |
|---|
| 272 | | -static int rpi_touchscreen_enable(struct drm_panel *panel) |
|---|
| 268 | +static int rpi_touchscreen_prepare(struct drm_panel *panel) |
|---|
| 273 | 269 | { |
|---|
| 274 | 270 | struct rpi_touchscreen *ts = panel_to_ts(panel); |
|---|
| 275 | 271 | int i; |
|---|
| .. | .. |
|---|
| 299 | 295 | rpi_touchscreen_write(ts, DSI_STARTDSI, 0x01); |
|---|
| 300 | 296 | msleep(100); |
|---|
| 301 | 297 | |
|---|
| 298 | + return 0; |
|---|
| 299 | +} |
|---|
| 300 | + |
|---|
| 301 | +static int rpi_touchscreen_enable(struct drm_panel *panel) |
|---|
| 302 | +{ |
|---|
| 303 | + struct rpi_touchscreen *ts = panel_to_ts(panel); |
|---|
| 304 | + |
|---|
| 302 | 305 | /* Turn on the backlight. */ |
|---|
| 303 | 306 | rpi_touchscreen_i2c_write(ts, REG_PWM, 255); |
|---|
| 304 | 307 | |
|---|
| .. | .. |
|---|
| 312 | 315 | return 0; |
|---|
| 313 | 316 | } |
|---|
| 314 | 317 | |
|---|
| 315 | | -static int rpi_touchscreen_get_modes(struct drm_panel *panel) |
|---|
| 318 | +static int rpi_touchscreen_get_modes(struct drm_panel *panel, |
|---|
| 319 | + struct drm_connector *connector) |
|---|
| 316 | 320 | { |
|---|
| 317 | | - struct drm_connector *connector = panel->connector; |
|---|
| 318 | | - struct drm_device *drm = panel->drm; |
|---|
| 319 | 321 | unsigned int i, num = 0; |
|---|
| 320 | 322 | static const u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24; |
|---|
| 321 | 323 | |
|---|
| .. | .. |
|---|
| 323 | 325 | const struct drm_display_mode *m = &rpi_touchscreen_modes[i]; |
|---|
| 324 | 326 | struct drm_display_mode *mode; |
|---|
| 325 | 327 | |
|---|
| 326 | | - mode = drm_mode_duplicate(drm, m); |
|---|
| 328 | + mode = drm_mode_duplicate(connector->dev, m); |
|---|
| 327 | 329 | if (!mode) { |
|---|
| 328 | | - dev_err(drm->dev, "failed to add mode %ux%u@%u\n", |
|---|
| 329 | | - m->hdisplay, m->vdisplay, m->vrefresh); |
|---|
| 330 | + dev_err(panel->dev, "failed to add mode %ux%u@%u\n", |
|---|
| 331 | + m->hdisplay, m->vdisplay, |
|---|
| 332 | + drm_mode_vrefresh(m)); |
|---|
| 330 | 333 | continue; |
|---|
| 331 | 334 | } |
|---|
| 332 | 335 | |
|---|
| .. | .. |
|---|
| 353 | 356 | static const struct drm_panel_funcs rpi_touchscreen_funcs = { |
|---|
| 354 | 357 | .disable = rpi_touchscreen_disable, |
|---|
| 355 | 358 | .unprepare = rpi_touchscreen_noop, |
|---|
| 356 | | - .prepare = rpi_touchscreen_noop, |
|---|
| 359 | + .prepare = rpi_touchscreen_prepare, |
|---|
| 357 | 360 | .enable = rpi_touchscreen_enable, |
|---|
| 358 | 361 | .get_modes = rpi_touchscreen_get_modes, |
|---|
| 359 | 362 | }; |
|---|
| .. | .. |
|---|
| 365 | 368 | struct rpi_touchscreen *ts; |
|---|
| 366 | 369 | struct device_node *endpoint, *dsi_host_node; |
|---|
| 367 | 370 | struct mipi_dsi_host *host; |
|---|
| 368 | | - int ret, ver; |
|---|
| 371 | + int ver; |
|---|
| 369 | 372 | struct mipi_dsi_device_info info = { |
|---|
| 370 | 373 | .type = RPI_DSI_DRIVER_NAME, |
|---|
| 371 | 374 | .channel = 0, |
|---|
| .. | .. |
|---|
| 427 | 430 | return PTR_ERR(ts->dsi); |
|---|
| 428 | 431 | } |
|---|
| 429 | 432 | |
|---|
| 430 | | - drm_panel_init(&ts->base); |
|---|
| 431 | | - ts->base.dev = dev; |
|---|
| 432 | | - ts->base.funcs = &rpi_touchscreen_funcs; |
|---|
| 433 | + drm_panel_init(&ts->base, dev, &rpi_touchscreen_funcs, |
|---|
| 434 | + DRM_MODE_CONNECTOR_DSI); |
|---|
| 433 | 435 | |
|---|
| 434 | 436 | /* This appears last, as it's what will unblock the DSI host |
|---|
| 435 | 437 | * driver's component bind function. |
|---|
| 436 | 438 | */ |
|---|
| 437 | | - ret = drm_panel_add(&ts->base); |
|---|
| 438 | | - if (ret) |
|---|
| 439 | | - return ret; |
|---|
| 439 | + drm_panel_add(&ts->base); |
|---|
| 440 | 440 | |
|---|
| 441 | 441 | return 0; |
|---|
| 442 | 442 | |
|---|