Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013, NVIDIA Corporation. All rights reserved. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sub license, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the |
| 12 | * next paragraph) shall be included in all copies or substantial portions |
| 13 | * of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | * DEALINGS IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | #include <linux/backlight.h> |
Alexandre Courbot | cfdf054 | 2014-03-01 14:00:58 +0900 | [diff] [blame] | 25 | #include <linux/gpio/consumer.h> |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 26 | #include <linux/module.h> |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 27 | #include <linux/of_platform.h> |
| 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/regulator/consumer.h> |
| 30 | |
| 31 | #include <drm/drmP.h> |
| 32 | #include <drm/drm_crtc.h> |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 33 | #include <drm/drm_mipi_dsi.h> |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 34 | #include <drm/drm_panel.h> |
| 35 | |
| 36 | struct panel_desc { |
| 37 | const struct drm_display_mode *modes; |
| 38 | unsigned int num_modes; |
| 39 | |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 40 | unsigned int bpc; |
| 41 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 42 | struct { |
| 43 | unsigned int width; |
| 44 | unsigned int height; |
| 45 | } size; |
Ajay Kumar | f673c37 | 2014-07-31 23:12:11 +0530 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * @prepare: the time (in milliseconds) that it takes for the panel to |
| 49 | * become ready and start receiving video data |
| 50 | * @enable: the time (in milliseconds) that it takes for the panel to |
| 51 | * display the first valid frame after starting to receive |
| 52 | * video data |
| 53 | * @disable: the time (in milliseconds) that it takes for the panel to |
| 54 | * turn the display off (no content is visible) |
| 55 | * @unprepare: the time (in milliseconds) that it takes for the panel |
| 56 | * to power itself down completely |
| 57 | */ |
| 58 | struct { |
| 59 | unsigned int prepare; |
| 60 | unsigned int enable; |
| 61 | unsigned int disable; |
| 62 | unsigned int unprepare; |
| 63 | } delay; |
Boris Brezillon | 795f7ab | 2014-07-22 13:33:59 +0200 | [diff] [blame] | 64 | |
| 65 | u32 bus_format; |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 66 | }; |
| 67 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 68 | struct panel_simple { |
| 69 | struct drm_panel base; |
Ajay Kumar | 613a633 | 2014-07-31 23:12:10 +0530 | [diff] [blame] | 70 | bool prepared; |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 71 | bool enabled; |
| 72 | |
| 73 | const struct panel_desc *desc; |
| 74 | |
| 75 | struct backlight_device *backlight; |
| 76 | struct regulator *supply; |
| 77 | struct i2c_adapter *ddc; |
| 78 | |
Alexandre Courbot | cfdf054 | 2014-03-01 14:00:58 +0900 | [diff] [blame] | 79 | struct gpio_desc *enable_gpio; |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | static inline struct panel_simple *to_panel_simple(struct drm_panel *panel) |
| 83 | { |
| 84 | return container_of(panel, struct panel_simple, base); |
| 85 | } |
| 86 | |
| 87 | static int panel_simple_get_fixed_modes(struct panel_simple *panel) |
| 88 | { |
| 89 | struct drm_connector *connector = panel->base.connector; |
| 90 | struct drm_device *drm = panel->base.drm; |
| 91 | struct drm_display_mode *mode; |
| 92 | unsigned int i, num = 0; |
| 93 | |
| 94 | if (!panel->desc) |
| 95 | return 0; |
| 96 | |
| 97 | for (i = 0; i < panel->desc->num_modes; i++) { |
| 98 | const struct drm_display_mode *m = &panel->desc->modes[i]; |
| 99 | |
| 100 | mode = drm_mode_duplicate(drm, m); |
| 101 | if (!mode) { |
| 102 | dev_err(drm->dev, "failed to add mode %ux%u@%u\n", |
| 103 | m->hdisplay, m->vdisplay, m->vrefresh); |
| 104 | continue; |
| 105 | } |
| 106 | |
| 107 | drm_mode_set_name(mode); |
| 108 | |
| 109 | drm_mode_probed_add(connector, mode); |
| 110 | num++; |
| 111 | } |
| 112 | |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 113 | connector->display_info.bpc = panel->desc->bpc; |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 114 | connector->display_info.width_mm = panel->desc->size.width; |
| 115 | connector->display_info.height_mm = panel->desc->size.height; |
Boris Brezillon | 795f7ab | 2014-07-22 13:33:59 +0200 | [diff] [blame] | 116 | if (panel->desc->bus_format) |
| 117 | drm_display_info_set_bus_formats(&connector->display_info, |
| 118 | &panel->desc->bus_format, 1); |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 119 | |
| 120 | return num; |
| 121 | } |
| 122 | |
| 123 | static int panel_simple_disable(struct drm_panel *panel) |
| 124 | { |
| 125 | struct panel_simple *p = to_panel_simple(panel); |
| 126 | |
| 127 | if (!p->enabled) |
| 128 | return 0; |
| 129 | |
| 130 | if (p->backlight) { |
| 131 | p->backlight->props.power = FB_BLANK_POWERDOWN; |
| 132 | backlight_update_status(p->backlight); |
| 133 | } |
| 134 | |
Ajay Kumar | f673c37 | 2014-07-31 23:12:11 +0530 | [diff] [blame] | 135 | if (p->desc->delay.disable) |
| 136 | msleep(p->desc->delay.disable); |
| 137 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 138 | p->enabled = false; |
| 139 | |
| 140 | return 0; |
| 141 | } |
| 142 | |
Ajay Kumar | c0e1d17 | 2014-07-31 23:12:04 +0530 | [diff] [blame] | 143 | static int panel_simple_unprepare(struct drm_panel *panel) |
| 144 | { |
Ajay Kumar | 613a633 | 2014-07-31 23:12:10 +0530 | [diff] [blame] | 145 | struct panel_simple *p = to_panel_simple(panel); |
| 146 | |
| 147 | if (!p->prepared) |
| 148 | return 0; |
| 149 | |
| 150 | if (p->enable_gpio) |
| 151 | gpiod_set_value_cansleep(p->enable_gpio, 0); |
| 152 | |
| 153 | regulator_disable(p->supply); |
| 154 | |
Ajay Kumar | f673c37 | 2014-07-31 23:12:11 +0530 | [diff] [blame] | 155 | if (p->desc->delay.unprepare) |
| 156 | msleep(p->desc->delay.unprepare); |
| 157 | |
Ajay Kumar | 613a633 | 2014-07-31 23:12:10 +0530 | [diff] [blame] | 158 | p->prepared = false; |
| 159 | |
Ajay Kumar | c0e1d17 | 2014-07-31 23:12:04 +0530 | [diff] [blame] | 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | static int panel_simple_prepare(struct drm_panel *panel) |
| 164 | { |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 165 | struct panel_simple *p = to_panel_simple(panel); |
| 166 | int err; |
| 167 | |
Ajay Kumar | 613a633 | 2014-07-31 23:12:10 +0530 | [diff] [blame] | 168 | if (p->prepared) |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 169 | return 0; |
| 170 | |
| 171 | err = regulator_enable(p->supply); |
| 172 | if (err < 0) { |
| 173 | dev_err(panel->dev, "failed to enable supply: %d\n", err); |
| 174 | return err; |
| 175 | } |
| 176 | |
Alexandre Courbot | cfdf054 | 2014-03-01 14:00:58 +0900 | [diff] [blame] | 177 | if (p->enable_gpio) |
Thierry Reding | 15c1a91 | 2014-03-14 12:03:47 +0100 | [diff] [blame] | 178 | gpiod_set_value_cansleep(p->enable_gpio, 1); |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 179 | |
Ajay Kumar | f673c37 | 2014-07-31 23:12:11 +0530 | [diff] [blame] | 180 | if (p->desc->delay.prepare) |
| 181 | msleep(p->desc->delay.prepare); |
| 182 | |
Ajay Kumar | 613a633 | 2014-07-31 23:12:10 +0530 | [diff] [blame] | 183 | p->prepared = true; |
| 184 | |
| 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | static int panel_simple_enable(struct drm_panel *panel) |
| 189 | { |
| 190 | struct panel_simple *p = to_panel_simple(panel); |
| 191 | |
| 192 | if (p->enabled) |
| 193 | return 0; |
| 194 | |
Ajay Kumar | f673c37 | 2014-07-31 23:12:11 +0530 | [diff] [blame] | 195 | if (p->desc->delay.enable) |
| 196 | msleep(p->desc->delay.enable); |
| 197 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 198 | if (p->backlight) { |
| 199 | p->backlight->props.power = FB_BLANK_UNBLANK; |
| 200 | backlight_update_status(p->backlight); |
| 201 | } |
| 202 | |
| 203 | p->enabled = true; |
| 204 | |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | static int panel_simple_get_modes(struct drm_panel *panel) |
| 209 | { |
| 210 | struct panel_simple *p = to_panel_simple(panel); |
| 211 | int num = 0; |
| 212 | |
| 213 | /* probe EDID if a DDC bus is available */ |
| 214 | if (p->ddc) { |
| 215 | struct edid *edid = drm_get_edid(panel->connector, p->ddc); |
Stephen Warren | 70bf687 | 2014-01-09 11:37:34 -0700 | [diff] [blame] | 216 | drm_mode_connector_update_edid_property(panel->connector, edid); |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 217 | if (edid) { |
| 218 | num += drm_add_edid_modes(panel->connector, edid); |
| 219 | kfree(edid); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | /* add hard-coded panel modes */ |
| 224 | num += panel_simple_get_fixed_modes(p); |
| 225 | |
| 226 | return num; |
| 227 | } |
| 228 | |
| 229 | static const struct drm_panel_funcs panel_simple_funcs = { |
| 230 | .disable = panel_simple_disable, |
Ajay Kumar | c0e1d17 | 2014-07-31 23:12:04 +0530 | [diff] [blame] | 231 | .unprepare = panel_simple_unprepare, |
| 232 | .prepare = panel_simple_prepare, |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 233 | .enable = panel_simple_enable, |
| 234 | .get_modes = panel_simple_get_modes, |
| 235 | }; |
| 236 | |
| 237 | static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) |
| 238 | { |
| 239 | struct device_node *backlight, *ddc; |
| 240 | struct panel_simple *panel; |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 241 | int err; |
| 242 | |
| 243 | panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); |
| 244 | if (!panel) |
| 245 | return -ENOMEM; |
| 246 | |
| 247 | panel->enabled = false; |
Ajay Kumar | 613a633 | 2014-07-31 23:12:10 +0530 | [diff] [blame] | 248 | panel->prepared = false; |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 249 | panel->desc = desc; |
| 250 | |
| 251 | panel->supply = devm_regulator_get(dev, "power"); |
| 252 | if (IS_ERR(panel->supply)) |
| 253 | return PTR_ERR(panel->supply); |
| 254 | |
Alexandre Courbot | a61400d | 2014-10-23 17:16:58 +0900 | [diff] [blame] | 255 | panel->enable_gpio = devm_gpiod_get_optional(dev, "enable", |
| 256 | GPIOD_OUT_LOW); |
Alexandre Courbot | cfdf054 | 2014-03-01 14:00:58 +0900 | [diff] [blame] | 257 | if (IS_ERR(panel->enable_gpio)) { |
| 258 | err = PTR_ERR(panel->enable_gpio); |
Alexandre Courbot | 9746c61 | 2014-07-25 23:47:25 +0900 | [diff] [blame] | 259 | dev_err(dev, "failed to request GPIO: %d\n", err); |
| 260 | return err; |
| 261 | } |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 262 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 263 | backlight = of_parse_phandle(dev->of_node, "backlight", 0); |
| 264 | if (backlight) { |
| 265 | panel->backlight = of_find_backlight_by_node(backlight); |
| 266 | of_node_put(backlight); |
| 267 | |
Alexandre Courbot | cfdf054 | 2014-03-01 14:00:58 +0900 | [diff] [blame] | 268 | if (!panel->backlight) |
| 269 | return -EPROBE_DEFER; |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0); |
| 273 | if (ddc) { |
| 274 | panel->ddc = of_find_i2c_adapter_by_node(ddc); |
| 275 | of_node_put(ddc); |
| 276 | |
| 277 | if (!panel->ddc) { |
| 278 | err = -EPROBE_DEFER; |
| 279 | goto free_backlight; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | drm_panel_init(&panel->base); |
| 284 | panel->base.dev = dev; |
| 285 | panel->base.funcs = &panel_simple_funcs; |
| 286 | |
| 287 | err = drm_panel_add(&panel->base); |
| 288 | if (err < 0) |
| 289 | goto free_ddc; |
| 290 | |
| 291 | dev_set_drvdata(dev, panel); |
| 292 | |
| 293 | return 0; |
| 294 | |
| 295 | free_ddc: |
| 296 | if (panel->ddc) |
| 297 | put_device(&panel->ddc->dev); |
| 298 | free_backlight: |
| 299 | if (panel->backlight) |
| 300 | put_device(&panel->backlight->dev); |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 301 | |
| 302 | return err; |
| 303 | } |
| 304 | |
| 305 | static int panel_simple_remove(struct device *dev) |
| 306 | { |
| 307 | struct panel_simple *panel = dev_get_drvdata(dev); |
| 308 | |
| 309 | drm_panel_detach(&panel->base); |
| 310 | drm_panel_remove(&panel->base); |
| 311 | |
| 312 | panel_simple_disable(&panel->base); |
| 313 | |
| 314 | if (panel->ddc) |
| 315 | put_device(&panel->ddc->dev); |
| 316 | |
| 317 | if (panel->backlight) |
| 318 | put_device(&panel->backlight->dev); |
| 319 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 320 | return 0; |
| 321 | } |
| 322 | |
Thierry Reding | d02fd93 | 2014-04-29 17:21:21 +0200 | [diff] [blame] | 323 | static void panel_simple_shutdown(struct device *dev) |
| 324 | { |
| 325 | struct panel_simple *panel = dev_get_drvdata(dev); |
| 326 | |
| 327 | panel_simple_disable(&panel->base); |
| 328 | } |
| 329 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 330 | static const struct drm_display_mode auo_b101aw03_mode = { |
| 331 | .clock = 51450, |
| 332 | .hdisplay = 1024, |
| 333 | .hsync_start = 1024 + 156, |
| 334 | .hsync_end = 1024 + 156 + 8, |
| 335 | .htotal = 1024 + 156 + 8 + 156, |
| 336 | .vdisplay = 600, |
| 337 | .vsync_start = 600 + 16, |
| 338 | .vsync_end = 600 + 16 + 6, |
| 339 | .vtotal = 600 + 16 + 6 + 16, |
| 340 | .vrefresh = 60, |
| 341 | }; |
| 342 | |
| 343 | static const struct panel_desc auo_b101aw03 = { |
| 344 | .modes = &auo_b101aw03_mode, |
| 345 | .num_modes = 1, |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 346 | .bpc = 6, |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 347 | .size = { |
| 348 | .width = 223, |
| 349 | .height = 125, |
| 350 | }, |
| 351 | }; |
| 352 | |
Rob Clark | dac746e | 2014-08-01 17:01:06 -0400 | [diff] [blame] | 353 | static const struct drm_display_mode auo_b101xtn01_mode = { |
| 354 | .clock = 72000, |
| 355 | .hdisplay = 1366, |
| 356 | .hsync_start = 1366 + 20, |
| 357 | .hsync_end = 1366 + 20 + 70, |
| 358 | .htotal = 1366 + 20 + 70, |
| 359 | .vdisplay = 768, |
| 360 | .vsync_start = 768 + 14, |
| 361 | .vsync_end = 768 + 14 + 42, |
| 362 | .vtotal = 768 + 14 + 42, |
| 363 | .vrefresh = 60, |
| 364 | .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, |
| 365 | }; |
| 366 | |
| 367 | static const struct panel_desc auo_b101xtn01 = { |
| 368 | .modes = &auo_b101xtn01_mode, |
| 369 | .num_modes = 1, |
| 370 | .bpc = 6, |
| 371 | .size = { |
| 372 | .width = 223, |
| 373 | .height = 125, |
| 374 | }, |
| 375 | }; |
| 376 | |
Ajay Kumar | e35e305 | 2014-09-01 15:40:02 +0530 | [diff] [blame] | 377 | static const struct drm_display_mode auo_b116xw03_mode = { |
| 378 | .clock = 70589, |
| 379 | .hdisplay = 1366, |
| 380 | .hsync_start = 1366 + 40, |
| 381 | .hsync_end = 1366 + 40 + 40, |
| 382 | .htotal = 1366 + 40 + 40 + 32, |
| 383 | .vdisplay = 768, |
| 384 | .vsync_start = 768 + 10, |
| 385 | .vsync_end = 768 + 10 + 12, |
| 386 | .vtotal = 768 + 10 + 12 + 6, |
| 387 | .vrefresh = 60, |
| 388 | }; |
| 389 | |
| 390 | static const struct panel_desc auo_b116xw03 = { |
| 391 | .modes = &auo_b116xw03_mode, |
| 392 | .num_modes = 1, |
| 393 | .bpc = 6, |
| 394 | .size = { |
| 395 | .width = 256, |
| 396 | .height = 144, |
| 397 | }, |
| 398 | }; |
| 399 | |
Stéphane Marchesin | a333f7a | 2014-05-23 19:27:59 -0700 | [diff] [blame] | 400 | static const struct drm_display_mode auo_b133xtn01_mode = { |
| 401 | .clock = 69500, |
| 402 | .hdisplay = 1366, |
| 403 | .hsync_start = 1366 + 48, |
| 404 | .hsync_end = 1366 + 48 + 32, |
| 405 | .htotal = 1366 + 48 + 32 + 20, |
| 406 | .vdisplay = 768, |
| 407 | .vsync_start = 768 + 3, |
| 408 | .vsync_end = 768 + 3 + 6, |
| 409 | .vtotal = 768 + 3 + 6 + 13, |
| 410 | .vrefresh = 60, |
| 411 | }; |
| 412 | |
| 413 | static const struct panel_desc auo_b133xtn01 = { |
| 414 | .modes = &auo_b133xtn01_mode, |
| 415 | .num_modes = 1, |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 416 | .bpc = 6, |
Stéphane Marchesin | a333f7a | 2014-05-23 19:27:59 -0700 | [diff] [blame] | 417 | .size = { |
| 418 | .width = 293, |
| 419 | .height = 165, |
| 420 | }, |
| 421 | }; |
| 422 | |
Ajay Kumar | 3e51d60 | 2014-07-31 23:12:12 +0530 | [diff] [blame] | 423 | static const struct drm_display_mode auo_b133htn01_mode = { |
| 424 | .clock = 150660, |
| 425 | .hdisplay = 1920, |
| 426 | .hsync_start = 1920 + 172, |
| 427 | .hsync_end = 1920 + 172 + 80, |
| 428 | .htotal = 1920 + 172 + 80 + 60, |
| 429 | .vdisplay = 1080, |
| 430 | .vsync_start = 1080 + 25, |
| 431 | .vsync_end = 1080 + 25 + 10, |
| 432 | .vtotal = 1080 + 25 + 10 + 10, |
| 433 | .vrefresh = 60, |
| 434 | }; |
| 435 | |
| 436 | static const struct panel_desc auo_b133htn01 = { |
| 437 | .modes = &auo_b133htn01_mode, |
| 438 | .num_modes = 1, |
Thierry Reding | d7a839c | 2014-11-06 10:11:01 +0100 | [diff] [blame] | 439 | .bpc = 6, |
Ajay Kumar | 3e51d60 | 2014-07-31 23:12:12 +0530 | [diff] [blame] | 440 | .size = { |
| 441 | .width = 293, |
| 442 | .height = 165, |
| 443 | }, |
| 444 | .delay = { |
| 445 | .prepare = 105, |
| 446 | .enable = 20, |
| 447 | .unprepare = 50, |
| 448 | }, |
| 449 | }; |
| 450 | |
Stephen Warren | 4c93075 | 2014-01-07 16:46:26 -0700 | [diff] [blame] | 451 | static const struct drm_display_mode chunghwa_claa101wa01a_mode = { |
| 452 | .clock = 72070, |
| 453 | .hdisplay = 1366, |
| 454 | .hsync_start = 1366 + 58, |
| 455 | .hsync_end = 1366 + 58 + 58, |
| 456 | .htotal = 1366 + 58 + 58 + 58, |
| 457 | .vdisplay = 768, |
| 458 | .vsync_start = 768 + 4, |
| 459 | .vsync_end = 768 + 4 + 4, |
| 460 | .vtotal = 768 + 4 + 4 + 4, |
| 461 | .vrefresh = 60, |
| 462 | }; |
| 463 | |
| 464 | static const struct panel_desc chunghwa_claa101wa01a = { |
| 465 | .modes = &chunghwa_claa101wa01a_mode, |
| 466 | .num_modes = 1, |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 467 | .bpc = 6, |
Stephen Warren | 4c93075 | 2014-01-07 16:46:26 -0700 | [diff] [blame] | 468 | .size = { |
| 469 | .width = 220, |
| 470 | .height = 120, |
| 471 | }, |
| 472 | }; |
| 473 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 474 | static const struct drm_display_mode chunghwa_claa101wb01_mode = { |
| 475 | .clock = 69300, |
| 476 | .hdisplay = 1366, |
| 477 | .hsync_start = 1366 + 48, |
| 478 | .hsync_end = 1366 + 48 + 32, |
| 479 | .htotal = 1366 + 48 + 32 + 20, |
| 480 | .vdisplay = 768, |
| 481 | .vsync_start = 768 + 16, |
| 482 | .vsync_end = 768 + 16 + 8, |
| 483 | .vtotal = 768 + 16 + 8 + 16, |
| 484 | .vrefresh = 60, |
| 485 | }; |
| 486 | |
| 487 | static const struct panel_desc chunghwa_claa101wb01 = { |
| 488 | .modes = &chunghwa_claa101wb01_mode, |
| 489 | .num_modes = 1, |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 490 | .bpc = 6, |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 491 | .size = { |
| 492 | .width = 223, |
| 493 | .height = 125, |
| 494 | }, |
| 495 | }; |
| 496 | |
Stefan Agner | 26ab006 | 2014-05-15 11:38:45 +0200 | [diff] [blame] | 497 | static const struct drm_display_mode edt_et057090dhu_mode = { |
| 498 | .clock = 25175, |
| 499 | .hdisplay = 640, |
| 500 | .hsync_start = 640 + 16, |
| 501 | .hsync_end = 640 + 16 + 30, |
| 502 | .htotal = 640 + 16 + 30 + 114, |
| 503 | .vdisplay = 480, |
| 504 | .vsync_start = 480 + 10, |
| 505 | .vsync_end = 480 + 10 + 3, |
| 506 | .vtotal = 480 + 10 + 3 + 32, |
| 507 | .vrefresh = 60, |
| 508 | .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, |
| 509 | }; |
| 510 | |
| 511 | static const struct panel_desc edt_et057090dhu = { |
| 512 | .modes = &edt_et057090dhu_mode, |
| 513 | .num_modes = 1, |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 514 | .bpc = 6, |
Stefan Agner | 26ab006 | 2014-05-15 11:38:45 +0200 | [diff] [blame] | 515 | .size = { |
| 516 | .width = 115, |
| 517 | .height = 86, |
| 518 | }, |
| 519 | }; |
| 520 | |
Philipp Zabel | fff5de4 | 2014-05-15 12:25:47 +0200 | [diff] [blame] | 521 | static const struct drm_display_mode edt_etm0700g0dh6_mode = { |
| 522 | .clock = 33260, |
| 523 | .hdisplay = 800, |
| 524 | .hsync_start = 800 + 40, |
| 525 | .hsync_end = 800 + 40 + 128, |
| 526 | .htotal = 800 + 40 + 128 + 88, |
| 527 | .vdisplay = 480, |
| 528 | .vsync_start = 480 + 10, |
| 529 | .vsync_end = 480 + 10 + 2, |
| 530 | .vtotal = 480 + 10 + 2 + 33, |
| 531 | .vrefresh = 60, |
| 532 | .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, |
| 533 | }; |
| 534 | |
| 535 | static const struct panel_desc edt_etm0700g0dh6 = { |
| 536 | .modes = &edt_etm0700g0dh6_mode, |
| 537 | .num_modes = 1, |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 538 | .bpc = 6, |
Philipp Zabel | fff5de4 | 2014-05-15 12:25:47 +0200 | [diff] [blame] | 539 | .size = { |
| 540 | .width = 152, |
| 541 | .height = 91, |
| 542 | }, |
| 543 | }; |
| 544 | |
Boris BREZILLON | 102932b | 2014-06-05 15:53:32 +0200 | [diff] [blame] | 545 | static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = { |
| 546 | .clock = 32260, |
| 547 | .hdisplay = 800, |
| 548 | .hsync_start = 800 + 168, |
| 549 | .hsync_end = 800 + 168 + 64, |
| 550 | .htotal = 800 + 168 + 64 + 88, |
| 551 | .vdisplay = 480, |
| 552 | .vsync_start = 480 + 37, |
| 553 | .vsync_end = 480 + 37 + 2, |
| 554 | .vtotal = 480 + 37 + 2 + 8, |
| 555 | .vrefresh = 60, |
| 556 | }; |
| 557 | |
| 558 | static const struct panel_desc foxlink_fl500wvr00_a0t = { |
| 559 | .modes = &foxlink_fl500wvr00_a0t_mode, |
| 560 | .num_modes = 1, |
Thierry Reding | d7a839c | 2014-11-06 10:11:01 +0100 | [diff] [blame] | 561 | .bpc = 8, |
Boris BREZILLON | 102932b | 2014-06-05 15:53:32 +0200 | [diff] [blame] | 562 | .size = { |
| 563 | .width = 108, |
| 564 | .height = 65, |
| 565 | }, |
Boris Brezillon | bb276cb | 2014-07-22 13:35:47 +0200 | [diff] [blame] | 566 | .bus_format = MEDIA_BUS_FMT_RGB888_1X24, |
Boris BREZILLON | 102932b | 2014-06-05 15:53:32 +0200 | [diff] [blame] | 567 | }; |
| 568 | |
Philipp Zabel | d435a2a | 2014-11-19 10:29:55 +0100 | [diff] [blame^] | 569 | static const struct drm_display_mode giantplus_gpg482739qs5_mode = { |
| 570 | .clock = 9000, |
| 571 | .hdisplay = 480, |
| 572 | .hsync_start = 480 + 5, |
| 573 | .hsync_end = 480 + 5 + 1, |
| 574 | .htotal = 480 + 5 + 1 + 40, |
| 575 | .vdisplay = 272, |
| 576 | .vsync_start = 272 + 8, |
| 577 | .vsync_end = 272 + 8 + 1, |
| 578 | .vtotal = 272 + 8 + 1 + 8, |
| 579 | .vrefresh = 60, |
| 580 | }; |
| 581 | |
| 582 | static const struct panel_desc giantplus_gpg482739qs5 = { |
| 583 | .modes = &giantplus_gpg482739qs5_mode, |
| 584 | .num_modes = 1, |
| 585 | .bpc = 8, |
| 586 | .size = { |
| 587 | .width = 95, |
| 588 | .height = 54, |
| 589 | }, |
| 590 | }; |
| 591 | |
Philipp Zabel | a853205 | 2014-10-23 16:31:06 +0200 | [diff] [blame] | 592 | static const struct drm_display_mode hannstar_hsd070pww1_mode = { |
| 593 | .clock = 71100, |
| 594 | .hdisplay = 1280, |
| 595 | .hsync_start = 1280 + 1, |
| 596 | .hsync_end = 1280 + 1 + 158, |
| 597 | .htotal = 1280 + 1 + 158 + 1, |
| 598 | .vdisplay = 800, |
| 599 | .vsync_start = 800 + 1, |
| 600 | .vsync_end = 800 + 1 + 21, |
| 601 | .vtotal = 800 + 1 + 21 + 1, |
| 602 | .vrefresh = 60, |
| 603 | }; |
| 604 | |
| 605 | static const struct panel_desc hannstar_hsd070pww1 = { |
| 606 | .modes = &hannstar_hsd070pww1_mode, |
| 607 | .num_modes = 1, |
| 608 | .bpc = 6, |
| 609 | .size = { |
| 610 | .width = 151, |
| 611 | .height = 94, |
| 612 | }, |
| 613 | }; |
| 614 | |
Lucas Stach | 61ac0bf | 2014-11-06 17:44:35 +0100 | [diff] [blame] | 615 | static const struct drm_display_mode hitachi_tx23d38vm0caa_mode = { |
| 616 | .clock = 33333, |
| 617 | .hdisplay = 800, |
| 618 | .hsync_start = 800 + 85, |
| 619 | .hsync_end = 800 + 85 + 86, |
| 620 | .htotal = 800 + 85 + 86 + 85, |
| 621 | .vdisplay = 480, |
| 622 | .vsync_start = 480 + 16, |
| 623 | .vsync_end = 480 + 16 + 13, |
| 624 | .vtotal = 480 + 16 + 13 + 16, |
| 625 | .vrefresh = 60, |
| 626 | }; |
| 627 | |
| 628 | static const struct panel_desc hitachi_tx23d38vm0caa = { |
| 629 | .modes = &hitachi_tx23d38vm0caa_mode, |
| 630 | .num_modes = 1, |
| 631 | .bpc = 6, |
| 632 | .size = { |
| 633 | .width = 195, |
| 634 | .height = 117, |
| 635 | }, |
| 636 | }; |
| 637 | |
Lucas Stach | d731f66 | 2014-11-06 17:44:33 +0100 | [diff] [blame] | 638 | static const struct drm_display_mode innolux_g121i1_l01_mode = { |
Thierry Reding | 0a2288c | 2014-07-03 14:02:59 +0200 | [diff] [blame] | 639 | .clock = 71000, |
Lucas Stach | d731f66 | 2014-11-06 17:44:33 +0100 | [diff] [blame] | 640 | .hdisplay = 1280, |
| 641 | .hsync_start = 1280 + 64, |
| 642 | .hsync_end = 1280 + 64 + 32, |
| 643 | .htotal = 1280 + 64 + 32 + 64, |
| 644 | .vdisplay = 800, |
| 645 | .vsync_start = 800 + 9, |
| 646 | .vsync_end = 800 + 9 + 6, |
| 647 | .vtotal = 800 + 9 + 6 + 9, |
| 648 | .vrefresh = 60, |
| 649 | }; |
| 650 | |
| 651 | static const struct panel_desc innolux_g121i1_l01 = { |
| 652 | .modes = &innolux_g121i1_l01_mode, |
| 653 | .num_modes = 1, |
| 654 | .bpc = 6, |
| 655 | .size = { |
| 656 | .width = 261, |
| 657 | .height = 163, |
| 658 | }, |
| 659 | }; |
| 660 | |
Thierry Reding | 0a2288c | 2014-07-03 14:02:59 +0200 | [diff] [blame] | 661 | static const struct drm_display_mode innolux_n116bge_mode = { |
Daniel Kurtz | 7fe8c77 | 2014-09-02 10:56:46 +0800 | [diff] [blame] | 662 | .clock = 76420, |
Thierry Reding | 0a2288c | 2014-07-03 14:02:59 +0200 | [diff] [blame] | 663 | .hdisplay = 1366, |
Daniel Kurtz | 7fe8c77 | 2014-09-02 10:56:46 +0800 | [diff] [blame] | 664 | .hsync_start = 1366 + 136, |
| 665 | .hsync_end = 1366 + 136 + 30, |
| 666 | .htotal = 1366 + 136 + 30 + 60, |
Thierry Reding | 0a2288c | 2014-07-03 14:02:59 +0200 | [diff] [blame] | 667 | .vdisplay = 768, |
| 668 | .vsync_start = 768 + 8, |
Daniel Kurtz | 7fe8c77 | 2014-09-02 10:56:46 +0800 | [diff] [blame] | 669 | .vsync_end = 768 + 8 + 12, |
| 670 | .vtotal = 768 + 8 + 12 + 12, |
Thierry Reding | 0a2288c | 2014-07-03 14:02:59 +0200 | [diff] [blame] | 671 | .vrefresh = 60, |
| 672 | .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, |
| 673 | }; |
| 674 | |
| 675 | static const struct panel_desc innolux_n116bge = { |
| 676 | .modes = &innolux_n116bge_mode, |
| 677 | .num_modes = 1, |
| 678 | .bpc = 6, |
| 679 | .size = { |
| 680 | .width = 256, |
| 681 | .height = 144, |
| 682 | }, |
| 683 | }; |
| 684 | |
Alban Bedel | ea44739 | 2014-07-22 08:38:55 +0200 | [diff] [blame] | 685 | static const struct drm_display_mode innolux_n156bge_l21_mode = { |
| 686 | .clock = 69300, |
| 687 | .hdisplay = 1366, |
| 688 | .hsync_start = 1366 + 16, |
| 689 | .hsync_end = 1366 + 16 + 34, |
| 690 | .htotal = 1366 + 16 + 34 + 50, |
| 691 | .vdisplay = 768, |
| 692 | .vsync_start = 768 + 2, |
| 693 | .vsync_end = 768 + 2 + 6, |
| 694 | .vtotal = 768 + 2 + 6 + 12, |
| 695 | .vrefresh = 60, |
| 696 | }; |
| 697 | |
| 698 | static const struct panel_desc innolux_n156bge_l21 = { |
| 699 | .modes = &innolux_n156bge_l21_mode, |
| 700 | .num_modes = 1, |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 701 | .bpc = 6, |
Alban Bedel | ea44739 | 2014-07-22 08:38:55 +0200 | [diff] [blame] | 702 | .size = { |
| 703 | .width = 344, |
| 704 | .height = 193, |
| 705 | }, |
| 706 | }; |
| 707 | |
Thierry Reding | ec7c565 | 2013-11-15 15:59:32 +0100 | [diff] [blame] | 708 | static const struct drm_display_mode lg_lp129qe_mode = { |
| 709 | .clock = 285250, |
| 710 | .hdisplay = 2560, |
| 711 | .hsync_start = 2560 + 48, |
| 712 | .hsync_end = 2560 + 48 + 32, |
| 713 | .htotal = 2560 + 48 + 32 + 80, |
| 714 | .vdisplay = 1700, |
| 715 | .vsync_start = 1700 + 3, |
| 716 | .vsync_end = 1700 + 3 + 10, |
| 717 | .vtotal = 1700 + 3 + 10 + 36, |
| 718 | .vrefresh = 60, |
| 719 | }; |
| 720 | |
| 721 | static const struct panel_desc lg_lp129qe = { |
| 722 | .modes = &lg_lp129qe_mode, |
| 723 | .num_modes = 1, |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 724 | .bpc = 8, |
Thierry Reding | ec7c565 | 2013-11-15 15:59:32 +0100 | [diff] [blame] | 725 | .size = { |
| 726 | .width = 272, |
| 727 | .height = 181, |
| 728 | }, |
| 729 | }; |
| 730 | |
Marc Dietrich | 6d54e3d | 2013-12-21 21:38:12 +0100 | [diff] [blame] | 731 | static const struct drm_display_mode samsung_ltn101nt05_mode = { |
| 732 | .clock = 54030, |
| 733 | .hdisplay = 1024, |
| 734 | .hsync_start = 1024 + 24, |
| 735 | .hsync_end = 1024 + 24 + 136, |
| 736 | .htotal = 1024 + 24 + 136 + 160, |
| 737 | .vdisplay = 600, |
| 738 | .vsync_start = 600 + 3, |
| 739 | .vsync_end = 600 + 3 + 6, |
| 740 | .vtotal = 600 + 3 + 6 + 61, |
| 741 | .vrefresh = 60, |
| 742 | }; |
| 743 | |
| 744 | static const struct panel_desc samsung_ltn101nt05 = { |
| 745 | .modes = &samsung_ltn101nt05_mode, |
| 746 | .num_modes = 1, |
Stéphane Marchesin | 0208d51 | 2014-06-19 18:18:28 -0700 | [diff] [blame] | 747 | .bpc = 6, |
Marc Dietrich | 6d54e3d | 2013-12-21 21:38:12 +0100 | [diff] [blame] | 748 | .size = { |
| 749 | .width = 1024, |
| 750 | .height = 600, |
| 751 | }, |
| 752 | }; |
| 753 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 754 | static const struct of_device_id platform_of_match[] = { |
| 755 | { |
| 756 | .compatible = "auo,b101aw03", |
| 757 | .data = &auo_b101aw03, |
| 758 | }, { |
Rob Clark | dac746e | 2014-08-01 17:01:06 -0400 | [diff] [blame] | 759 | .compatible = "auo,b101xtn01", |
| 760 | .data = &auo_b101xtn01, |
| 761 | }, { |
Ajay Kumar | e35e305 | 2014-09-01 15:40:02 +0530 | [diff] [blame] | 762 | .compatible = "auo,b116xw03", |
| 763 | .data = &auo_b116xw03, |
| 764 | }, { |
Ajay Kumar | 3e51d60 | 2014-07-31 23:12:12 +0530 | [diff] [blame] | 765 | .compatible = "auo,b133htn01", |
| 766 | .data = &auo_b133htn01, |
| 767 | }, { |
Stéphane Marchesin | a333f7a | 2014-05-23 19:27:59 -0700 | [diff] [blame] | 768 | .compatible = "auo,b133xtn01", |
| 769 | .data = &auo_b133xtn01, |
| 770 | }, { |
Stephen Warren | 4c93075 | 2014-01-07 16:46:26 -0700 | [diff] [blame] | 771 | .compatible = "chunghwa,claa101wa01a", |
| 772 | .data = &chunghwa_claa101wa01a |
| 773 | }, { |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 774 | .compatible = "chunghwa,claa101wb01", |
| 775 | .data = &chunghwa_claa101wb01 |
| 776 | }, { |
Stefan Agner | 26ab006 | 2014-05-15 11:38:45 +0200 | [diff] [blame] | 777 | .compatible = "edt,et057090dhu", |
| 778 | .data = &edt_et057090dhu, |
| 779 | }, { |
Philipp Zabel | fff5de4 | 2014-05-15 12:25:47 +0200 | [diff] [blame] | 780 | .compatible = "edt,et070080dh6", |
| 781 | .data = &edt_etm0700g0dh6, |
| 782 | }, { |
| 783 | .compatible = "edt,etm0700g0dh6", |
| 784 | .data = &edt_etm0700g0dh6, |
| 785 | }, { |
Boris BREZILLON | 102932b | 2014-06-05 15:53:32 +0200 | [diff] [blame] | 786 | .compatible = "foxlink,fl500wvr00-a0t", |
| 787 | .data = &foxlink_fl500wvr00_a0t, |
| 788 | }, { |
Philipp Zabel | d435a2a | 2014-11-19 10:29:55 +0100 | [diff] [blame^] | 789 | .compatible = "giantplus,gpg482739qs5", |
| 790 | .data = &giantplus_gpg482739qs5 |
| 791 | }, { |
Philipp Zabel | a853205 | 2014-10-23 16:31:06 +0200 | [diff] [blame] | 792 | .compatible = "hannstar,hsd070pww1", |
| 793 | .data = &hannstar_hsd070pww1, |
| 794 | }, { |
Lucas Stach | 61ac0bf | 2014-11-06 17:44:35 +0100 | [diff] [blame] | 795 | .compatible = "hit,tx23d38vm0caa", |
| 796 | .data = &hitachi_tx23d38vm0caa |
| 797 | }, { |
Lucas Stach | d731f66 | 2014-11-06 17:44:33 +0100 | [diff] [blame] | 798 | .compatible ="innolux,g121i1-l01", |
| 799 | .data = &innolux_g121i1_l01 |
| 800 | }, { |
Thierry Reding | 0a2288c | 2014-07-03 14:02:59 +0200 | [diff] [blame] | 801 | .compatible = "innolux,n116bge", |
| 802 | .data = &innolux_n116bge, |
| 803 | }, { |
Alban Bedel | ea44739 | 2014-07-22 08:38:55 +0200 | [diff] [blame] | 804 | .compatible = "innolux,n156bge-l21", |
| 805 | .data = &innolux_n156bge_l21, |
| 806 | }, { |
Thierry Reding | ec7c565 | 2013-11-15 15:59:32 +0100 | [diff] [blame] | 807 | .compatible = "lg,lp129qe", |
| 808 | .data = &lg_lp129qe, |
| 809 | }, { |
Marc Dietrich | 6d54e3d | 2013-12-21 21:38:12 +0100 | [diff] [blame] | 810 | .compatible = "samsung,ltn101nt05", |
| 811 | .data = &samsung_ltn101nt05, |
| 812 | }, { |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 813 | /* sentinel */ |
| 814 | } |
| 815 | }; |
| 816 | MODULE_DEVICE_TABLE(of, platform_of_match); |
| 817 | |
| 818 | static int panel_simple_platform_probe(struct platform_device *pdev) |
| 819 | { |
| 820 | const struct of_device_id *id; |
| 821 | |
| 822 | id = of_match_node(platform_of_match, pdev->dev.of_node); |
| 823 | if (!id) |
| 824 | return -ENODEV; |
| 825 | |
| 826 | return panel_simple_probe(&pdev->dev, id->data); |
| 827 | } |
| 828 | |
| 829 | static int panel_simple_platform_remove(struct platform_device *pdev) |
| 830 | { |
| 831 | return panel_simple_remove(&pdev->dev); |
| 832 | } |
| 833 | |
Thierry Reding | d02fd93 | 2014-04-29 17:21:21 +0200 | [diff] [blame] | 834 | static void panel_simple_platform_shutdown(struct platform_device *pdev) |
| 835 | { |
| 836 | panel_simple_shutdown(&pdev->dev); |
| 837 | } |
| 838 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 839 | static struct platform_driver panel_simple_platform_driver = { |
| 840 | .driver = { |
| 841 | .name = "panel-simple", |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 842 | .of_match_table = platform_of_match, |
| 843 | }, |
| 844 | .probe = panel_simple_platform_probe, |
| 845 | .remove = panel_simple_platform_remove, |
Thierry Reding | d02fd93 | 2014-04-29 17:21:21 +0200 | [diff] [blame] | 846 | .shutdown = panel_simple_platform_shutdown, |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 847 | }; |
| 848 | |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 849 | struct panel_desc_dsi { |
| 850 | struct panel_desc desc; |
| 851 | |
Thierry Reding | 462658b | 2014-03-14 11:24:57 +0100 | [diff] [blame] | 852 | unsigned long flags; |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 853 | enum mipi_dsi_pixel_format format; |
| 854 | unsigned int lanes; |
| 855 | }; |
| 856 | |
Alexandre Courbot | 712ac1b | 2014-01-21 18:57:10 +0900 | [diff] [blame] | 857 | static const struct drm_display_mode lg_ld070wx3_sl01_mode = { |
| 858 | .clock = 71000, |
| 859 | .hdisplay = 800, |
| 860 | .hsync_start = 800 + 32, |
| 861 | .hsync_end = 800 + 32 + 1, |
| 862 | .htotal = 800 + 32 + 1 + 57, |
| 863 | .vdisplay = 1280, |
| 864 | .vsync_start = 1280 + 28, |
| 865 | .vsync_end = 1280 + 28 + 1, |
| 866 | .vtotal = 1280 + 28 + 1 + 14, |
| 867 | .vrefresh = 60, |
| 868 | }; |
| 869 | |
| 870 | static const struct panel_desc_dsi lg_ld070wx3_sl01 = { |
| 871 | .desc = { |
| 872 | .modes = &lg_ld070wx3_sl01_mode, |
| 873 | .num_modes = 1, |
Thierry Reding | d7a839c | 2014-11-06 10:11:01 +0100 | [diff] [blame] | 874 | .bpc = 8, |
Alexandre Courbot | 712ac1b | 2014-01-21 18:57:10 +0900 | [diff] [blame] | 875 | .size = { |
| 876 | .width = 94, |
| 877 | .height = 151, |
| 878 | }, |
| 879 | }, |
Alexandre Courbot | 5e4cc27 | 2014-07-08 21:32:12 +0900 | [diff] [blame] | 880 | .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS, |
Alexandre Courbot | 712ac1b | 2014-01-21 18:57:10 +0900 | [diff] [blame] | 881 | .format = MIPI_DSI_FMT_RGB888, |
| 882 | .lanes = 4, |
| 883 | }; |
| 884 | |
Alexandre Courbot | 499ce85 | 2014-01-21 18:57:09 +0900 | [diff] [blame] | 885 | static const struct drm_display_mode lg_lh500wx1_sd03_mode = { |
| 886 | .clock = 67000, |
| 887 | .hdisplay = 720, |
| 888 | .hsync_start = 720 + 12, |
| 889 | .hsync_end = 720 + 12 + 4, |
| 890 | .htotal = 720 + 12 + 4 + 112, |
| 891 | .vdisplay = 1280, |
| 892 | .vsync_start = 1280 + 8, |
| 893 | .vsync_end = 1280 + 8 + 4, |
| 894 | .vtotal = 1280 + 8 + 4 + 12, |
| 895 | .vrefresh = 60, |
| 896 | }; |
| 897 | |
| 898 | static const struct panel_desc_dsi lg_lh500wx1_sd03 = { |
| 899 | .desc = { |
| 900 | .modes = &lg_lh500wx1_sd03_mode, |
| 901 | .num_modes = 1, |
Thierry Reding | d7a839c | 2014-11-06 10:11:01 +0100 | [diff] [blame] | 902 | .bpc = 8, |
Alexandre Courbot | 499ce85 | 2014-01-21 18:57:09 +0900 | [diff] [blame] | 903 | .size = { |
| 904 | .width = 62, |
| 905 | .height = 110, |
| 906 | }, |
| 907 | }, |
| 908 | .flags = MIPI_DSI_MODE_VIDEO, |
| 909 | .format = MIPI_DSI_FMT_RGB888, |
| 910 | .lanes = 4, |
| 911 | }; |
| 912 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 913 | static const struct drm_display_mode panasonic_vvx10f004b00_mode = { |
| 914 | .clock = 157200, |
| 915 | .hdisplay = 1920, |
| 916 | .hsync_start = 1920 + 154, |
| 917 | .hsync_end = 1920 + 154 + 16, |
| 918 | .htotal = 1920 + 154 + 16 + 32, |
| 919 | .vdisplay = 1200, |
| 920 | .vsync_start = 1200 + 17, |
| 921 | .vsync_end = 1200 + 17 + 2, |
| 922 | .vtotal = 1200 + 17 + 2 + 16, |
| 923 | .vrefresh = 60, |
| 924 | }; |
| 925 | |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 926 | static const struct panel_desc_dsi panasonic_vvx10f004b00 = { |
| 927 | .desc = { |
| 928 | .modes = &panasonic_vvx10f004b00_mode, |
| 929 | .num_modes = 1, |
Thierry Reding | d7a839c | 2014-11-06 10:11:01 +0100 | [diff] [blame] | 930 | .bpc = 8, |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 931 | .size = { |
| 932 | .width = 217, |
| 933 | .height = 136, |
| 934 | }, |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 935 | }, |
Alexandre Courbot | 5e4cc27 | 2014-07-08 21:32:12 +0900 | [diff] [blame] | 936 | .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | |
| 937 | MIPI_DSI_CLOCK_NON_CONTINUOUS, |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 938 | .format = MIPI_DSI_FMT_RGB888, |
| 939 | .lanes = 4, |
| 940 | }; |
| 941 | |
| 942 | static const struct of_device_id dsi_of_match[] = { |
| 943 | { |
Alexandre Courbot | 712ac1b | 2014-01-21 18:57:10 +0900 | [diff] [blame] | 944 | .compatible = "lg,ld070wx3-sl01", |
| 945 | .data = &lg_ld070wx3_sl01 |
| 946 | }, { |
Alexandre Courbot | 499ce85 | 2014-01-21 18:57:09 +0900 | [diff] [blame] | 947 | .compatible = "lg,lh500wx1-sd03", |
| 948 | .data = &lg_lh500wx1_sd03 |
| 949 | }, { |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 950 | .compatible = "panasonic,vvx10f004b00", |
| 951 | .data = &panasonic_vvx10f004b00 |
| 952 | }, { |
| 953 | /* sentinel */ |
| 954 | } |
| 955 | }; |
| 956 | MODULE_DEVICE_TABLE(of, dsi_of_match); |
| 957 | |
| 958 | static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi) |
| 959 | { |
| 960 | const struct panel_desc_dsi *desc; |
| 961 | const struct of_device_id *id; |
| 962 | int err; |
| 963 | |
| 964 | id = of_match_node(dsi_of_match, dsi->dev.of_node); |
| 965 | if (!id) |
| 966 | return -ENODEV; |
| 967 | |
| 968 | desc = id->data; |
| 969 | |
| 970 | err = panel_simple_probe(&dsi->dev, &desc->desc); |
| 971 | if (err < 0) |
| 972 | return err; |
| 973 | |
Thierry Reding | 462658b | 2014-03-14 11:24:57 +0100 | [diff] [blame] | 974 | dsi->mode_flags = desc->flags; |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 975 | dsi->format = desc->format; |
| 976 | dsi->lanes = desc->lanes; |
| 977 | |
| 978 | return mipi_dsi_attach(dsi); |
| 979 | } |
| 980 | |
| 981 | static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi) |
| 982 | { |
| 983 | int err; |
| 984 | |
| 985 | err = mipi_dsi_detach(dsi); |
| 986 | if (err < 0) |
| 987 | dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err); |
| 988 | |
| 989 | return panel_simple_remove(&dsi->dev); |
| 990 | } |
| 991 | |
Thierry Reding | d02fd93 | 2014-04-29 17:21:21 +0200 | [diff] [blame] | 992 | static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi) |
| 993 | { |
| 994 | panel_simple_shutdown(&dsi->dev); |
| 995 | } |
| 996 | |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 997 | static struct mipi_dsi_driver panel_simple_dsi_driver = { |
| 998 | .driver = { |
| 999 | .name = "panel-simple-dsi", |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 1000 | .of_match_table = dsi_of_match, |
| 1001 | }, |
| 1002 | .probe = panel_simple_dsi_probe, |
| 1003 | .remove = panel_simple_dsi_remove, |
Thierry Reding | d02fd93 | 2014-04-29 17:21:21 +0200 | [diff] [blame] | 1004 | .shutdown = panel_simple_dsi_shutdown, |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 1005 | }; |
| 1006 | |
| 1007 | static int __init panel_simple_init(void) |
| 1008 | { |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 1009 | int err; |
| 1010 | |
| 1011 | err = platform_driver_register(&panel_simple_platform_driver); |
| 1012 | if (err < 0) |
| 1013 | return err; |
| 1014 | |
| 1015 | if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) { |
| 1016 | err = mipi_dsi_driver_register(&panel_simple_dsi_driver); |
| 1017 | if (err < 0) |
| 1018 | return err; |
| 1019 | } |
| 1020 | |
| 1021 | return 0; |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 1022 | } |
| 1023 | module_init(panel_simple_init); |
| 1024 | |
| 1025 | static void __exit panel_simple_exit(void) |
| 1026 | { |
Thierry Reding | 210fcd9 | 2013-11-22 19:27:11 +0100 | [diff] [blame] | 1027 | if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) |
| 1028 | mipi_dsi_driver_unregister(&panel_simple_dsi_driver); |
| 1029 | |
Thierry Reding | 280921d | 2013-08-30 15:10:14 +0200 | [diff] [blame] | 1030 | platform_driver_unregister(&panel_simple_platform_driver); |
| 1031 | } |
| 1032 | module_exit(panel_simple_exit); |
| 1033 | |
| 1034 | MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>"); |
| 1035 | MODULE_DESCRIPTION("DRM Driver for Simple Panels"); |
| 1036 | MODULE_LICENSE("GPL and additional rights"); |