2 * Copyright (C) 2013, NVIDIA Corporation. All rights reserved.
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:
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
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.
24 #include <linux/debugfs.h>
25 #include <linux/delay.h>
26 #include <linux/gpio/consumer.h>
27 #include <linux/iopoll.h>
28 #include <linux/module.h>
29 #include <linux/of_platform.h>
30 #include <linux/platform_device.h>
31 #include <linux/pm_runtime.h>
32 #include <linux/regulator/consumer.h>
34 #include <video/display_timing.h>
35 #include <video/of_display_timing.h>
36 #include <video/videomode.h>
38 #include <drm/display/drm_dp_aux_bus.h>
39 #include <drm/display/drm_dp_helper.h>
40 #include <drm/drm_crtc.h>
41 #include <drm/drm_device.h>
42 #include <drm/drm_edid.h>
43 #include <drm/drm_panel.h>
46 * struct panel_delay - Describes delays for a simple panel.
50 * @hpd_reliable: Time for HPD to be reliable
52 * The time (in milliseconds) that it takes after powering the panel
53 * before the HPD signal is reliable. Ideally this is 0 but some panels,
54 * board designs, or bad pulldown configs can cause a glitch here.
56 * NOTE: on some old panel data this number appears to be much too big.
57 * Presumably some old panels simply didn't have HPD hooked up and put
58 * the hpd_absent here because this field predates the
59 * hpd_absent. While that works, it's non-ideal.
61 unsigned int hpd_reliable;
64 * @hpd_absent: Time to wait if HPD isn't hooked up.
66 * Add this to the prepare delay if we know Hot Plug Detect isn't used.
68 * This is T3-max on eDP timing diagrams or the delay from power on
69 * until HPD is guaranteed to be asserted.
71 unsigned int hpd_absent;
74 * @prepare_to_enable: Time between prepare and enable.
76 * The minimum time, in milliseconds, that needs to have passed
77 * between when prepare finished and enable may begin. If at
78 * enable time less time has passed since prepare finished,
79 * the driver waits for the remaining time.
81 * If a fixed enable delay is also specified, we'll start
82 * counting before delaying for the fixed delay.
84 * If a fixed prepare delay is also specified, we won't start
85 * counting until after the fixed delay. We can't overlap this
86 * fixed delay with the min time because the fixed delay
87 * doesn't happen at the end of the function if a HPD GPIO was
93 * // do fixed prepare delay
94 * // wait for HPD GPIO if applicable
95 * // start counting for prepare_to_enable
98 * // do fixed enable delay
99 * // enforce prepare_to_enable min time
101 * This is not specified in a standard way on eDP timing diagrams.
102 * It is effectively the time from HPD going high till you can
103 * turn on the backlight.
105 unsigned int prepare_to_enable;
108 * @enable: Time for the panel to display a valid frame.
110 * The time (in milliseconds) that it takes for the panel to
111 * display the first valid frame after starting to receive
114 * This is (T6-min + max(T7-max, T8-min)) on eDP timing diagrams or
115 * the delay after link training finishes until we can turn the
116 * backlight on and see valid data.
121 * @disable: Time for the panel to turn the display off.
123 * The time (in milliseconds) that it takes for the panel to
124 * turn the display off (no content is visible).
126 * This is T9-min (delay from backlight off to end of valid video
127 * data) on eDP timing diagrams. It is not common to set.
129 unsigned int disable;
132 * @unprepare: Time to power down completely.
134 * The time (in milliseconds) that it takes for the panel
135 * to power itself down completely.
137 * This time is used to prevent a future "prepare" from
138 * starting until at least this many milliseconds has passed.
139 * If at prepare time less time has passed since unprepare
140 * finished, the driver waits for the remaining time.
142 * This is T12-min on eDP timing diagrams.
144 unsigned int unprepare;
148 * struct panel_desc - Describes a simple panel.
152 * @modes: Pointer to array of fixed modes appropriate for this panel.
154 * If only one mode then this can just be the address of the mode.
155 * NOTE: cannot be used with "timings" and also if this is specified
156 * then you cannot override the mode in the device tree.
158 const struct drm_display_mode *modes;
160 /** @num_modes: Number of elements in modes array. */
161 unsigned int num_modes;
164 * @timings: Pointer to array of display timings
166 * NOTE: cannot be used with "modes" and also these will be used to
167 * validate a device tree override if one is present.
169 const struct display_timing *timings;
171 /** @num_timings: Number of elements in timings array. */
172 unsigned int num_timings;
174 /** @bpc: Bits per color. */
177 /** @size: Structure containing the physical size of this panel. */
180 * @size.width: Width (in mm) of the active display area.
185 * @size.height: Height (in mm) of the active display area.
190 /** @delay: Structure containing various delay values for this panel. */
191 struct panel_delay delay;
195 * struct edp_panel_entry - Maps panel ID to delay / panel name.
197 struct edp_panel_entry {
198 /** @panel_id: 32-bit ID for panel, encoded with drm_edid_encode_panel_id(). */
201 /** @delay: The power sequencing delays needed for this panel. */
202 const struct panel_delay *delay;
204 /** @name: Name of this panel (for printing to logs). */
209 struct drm_panel base;
215 ktime_t prepared_time;
216 ktime_t unprepared_time;
218 const struct panel_desc *desc;
220 struct regulator *supply;
221 struct i2c_adapter *ddc;
222 struct drm_dp_aux *aux;
224 struct gpio_desc *enable_gpio;
225 struct gpio_desc *hpd_gpio;
227 const struct edp_panel_entry *detected_panel;
231 struct drm_display_mode override_mode;
233 enum drm_panel_orientation orientation;
236 static inline struct panel_edp *to_panel_edp(struct drm_panel *panel)
238 return container_of(panel, struct panel_edp, base);
241 static unsigned int panel_edp_get_timings_modes(struct panel_edp *panel,
242 struct drm_connector *connector)
244 struct drm_display_mode *mode;
245 unsigned int i, num = 0;
247 for (i = 0; i < panel->desc->num_timings; i++) {
248 const struct display_timing *dt = &panel->desc->timings[i];
251 videomode_from_timing(dt, &vm);
252 mode = drm_mode_create(connector->dev);
254 dev_err(panel->base.dev, "failed to add mode %ux%u\n",
255 dt->hactive.typ, dt->vactive.typ);
259 drm_display_mode_from_videomode(&vm, mode);
261 mode->type |= DRM_MODE_TYPE_DRIVER;
263 if (panel->desc->num_timings == 1)
264 mode->type |= DRM_MODE_TYPE_PREFERRED;
266 drm_mode_probed_add(connector, mode);
273 static unsigned int panel_edp_get_display_modes(struct panel_edp *panel,
274 struct drm_connector *connector)
276 struct drm_display_mode *mode;
277 unsigned int i, num = 0;
279 for (i = 0; i < panel->desc->num_modes; i++) {
280 const struct drm_display_mode *m = &panel->desc->modes[i];
282 mode = drm_mode_duplicate(connector->dev, m);
284 dev_err(panel->base.dev, "failed to add mode %ux%u@%u\n",
285 m->hdisplay, m->vdisplay,
286 drm_mode_vrefresh(m));
290 mode->type |= DRM_MODE_TYPE_DRIVER;
292 if (panel->desc->num_modes == 1)
293 mode->type |= DRM_MODE_TYPE_PREFERRED;
295 drm_mode_set_name(mode);
297 drm_mode_probed_add(connector, mode);
304 static int panel_edp_get_non_edid_modes(struct panel_edp *panel,
305 struct drm_connector *connector)
307 struct drm_display_mode *mode;
308 bool has_override = panel->override_mode.type;
309 unsigned int num = 0;
315 mode = drm_mode_duplicate(connector->dev,
316 &panel->override_mode);
318 drm_mode_probed_add(connector, mode);
321 dev_err(panel->base.dev, "failed to add override mode\n");
325 /* Only add timings if override was not there or failed to validate */
326 if (num == 0 && panel->desc->num_timings)
327 num = panel_edp_get_timings_modes(panel, connector);
330 * Only add fixed modes if timings/override added no mode.
332 * We should only ever have either the display timings specified
333 * or a fixed mode. Anything else is rather bogus.
335 WARN_ON(panel->desc->num_timings && panel->desc->num_modes);
337 num = panel_edp_get_display_modes(panel, connector);
339 connector->display_info.bpc = panel->desc->bpc;
340 connector->display_info.width_mm = panel->desc->size.width;
341 connector->display_info.height_mm = panel->desc->size.height;
346 static void panel_edp_wait(ktime_t start_ktime, unsigned int min_ms)
348 ktime_t now_ktime, min_ktime;
353 min_ktime = ktime_add(start_ktime, ms_to_ktime(min_ms));
354 now_ktime = ktime_get_boottime();
356 if (ktime_before(now_ktime, min_ktime))
357 msleep(ktime_to_ms(ktime_sub(min_ktime, now_ktime)) + 1);
360 static int panel_edp_disable(struct drm_panel *panel)
362 struct panel_edp *p = to_panel_edp(panel);
367 if (p->desc->delay.disable)
368 msleep(p->desc->delay.disable);
375 static int panel_edp_suspend(struct device *dev)
377 struct panel_edp *p = dev_get_drvdata(dev);
379 gpiod_set_value_cansleep(p->enable_gpio, 0);
380 regulator_disable(p->supply);
381 p->unprepared_time = ktime_get_boottime();
386 static int panel_edp_unprepare(struct drm_panel *panel)
388 struct panel_edp *p = to_panel_edp(panel);
391 /* Unpreparing when already unprepared is a no-op */
395 pm_runtime_mark_last_busy(panel->dev);
396 ret = pm_runtime_put_autosuspend(panel->dev);
404 static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p)
406 p->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN);
407 if (IS_ERR(p->hpd_gpio))
408 return dev_err_probe(dev, PTR_ERR(p->hpd_gpio),
409 "failed to get 'hpd' GPIO\n");
414 static bool panel_edp_can_read_hpd(struct panel_edp *p)
416 return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted));
419 static int panel_edp_prepare_once(struct panel_edp *p)
421 struct device *dev = p->base.dev;
425 unsigned long hpd_wait_us;
427 panel_edp_wait(p->unprepared_time, p->desc->delay.unprepare);
429 err = regulator_enable(p->supply);
431 dev_err(dev, "failed to enable supply: %d\n", err);
435 gpiod_set_value_cansleep(p->enable_gpio, 1);
437 delay = p->desc->delay.hpd_reliable;
439 delay = max(delay, p->desc->delay.hpd_absent);
443 if (panel_edp_can_read_hpd(p)) {
444 if (p->desc->delay.hpd_absent)
445 hpd_wait_us = p->desc->delay.hpd_absent * 1000UL;
447 hpd_wait_us = 2000000;
450 err = readx_poll_timeout(gpiod_get_value_cansleep,
451 p->hpd_gpio, hpd_asserted,
452 hpd_asserted, 1000, hpd_wait_us);
453 if (hpd_asserted < 0)
456 err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us);
460 if (err != -ETIMEDOUT)
462 "error waiting for hpd GPIO: %d\n", err);
467 p->prepared_time = ktime_get_boottime();
472 gpiod_set_value_cansleep(p->enable_gpio, 0);
473 regulator_disable(p->supply);
474 p->unprepared_time = ktime_get_boottime();
480 * Some panels simply don't always come up and need to be power cycled to
481 * work properly. We'll allow for a handful of retries.
483 #define MAX_PANEL_PREPARE_TRIES 5
485 static int panel_edp_resume(struct device *dev)
487 struct panel_edp *p = dev_get_drvdata(dev);
491 for (try = 0; try < MAX_PANEL_PREPARE_TRIES; try++) {
492 ret = panel_edp_prepare_once(p);
493 if (ret != -ETIMEDOUT)
497 if (ret == -ETIMEDOUT)
498 dev_err(dev, "Prepare timeout after %d tries\n", try);
500 dev_warn(dev, "Prepare needed %d retries\n", try);
505 static int panel_edp_prepare(struct drm_panel *panel)
507 struct panel_edp *p = to_panel_edp(panel);
510 /* Preparing when already prepared is a no-op */
514 ret = pm_runtime_get_sync(panel->dev);
516 pm_runtime_put_autosuspend(panel->dev);
525 static int panel_edp_enable(struct drm_panel *panel)
527 struct panel_edp *p = to_panel_edp(panel);
533 delay = p->desc->delay.enable;
536 * If there is a "prepare_to_enable" delay then that's supposed to be
537 * the delay from HPD going high until we can turn the backlight on.
538 * However, we can only count this if HPD is readable by the panel
541 * If we aren't handling the HPD pin ourselves then the best we
542 * can do is assume that HPD went high immediately before we were
543 * called (and link training took zero time). Note that "no-hpd"
544 * actually counts as handling HPD ourselves since we're doing the
545 * worst case delay (in prepare) ourselves.
547 * NOTE: if we ever end up in this "if" statement then we're
548 * guaranteed that the panel_edp_wait() call below will do no delay.
549 * It already handles that case, though, so we don't need any special
552 if (p->desc->delay.prepare_to_enable &&
553 !panel_edp_can_read_hpd(p) && !p->no_hpd)
554 delay = max(delay, p->desc->delay.prepare_to_enable);
559 panel_edp_wait(p->prepared_time, p->desc->delay.prepare_to_enable);
566 static int panel_edp_get_modes(struct drm_panel *panel,
567 struct drm_connector *connector)
569 struct panel_edp *p = to_panel_edp(panel);
572 /* probe EDID if a DDC bus is available */
574 pm_runtime_get_sync(panel->dev);
577 p->edid = drm_get_edid(connector, p->ddc);
580 num += drm_add_edid_modes(connector, p->edid);
582 pm_runtime_mark_last_busy(panel->dev);
583 pm_runtime_put_autosuspend(panel->dev);
587 * Add hard-coded panel modes. Don't call this if there are no timings
588 * and no modes (the generic edp-panel case) because it will clobber
589 * the display_info that was already set by drm_add_edid_modes().
591 if (p->desc->num_timings || p->desc->num_modes)
592 num += panel_edp_get_non_edid_modes(p, connector);
594 dev_warn(p->base.dev, "No display modes\n");
597 * TODO: Remove once all drm drivers call
598 * drm_connector_set_orientation_from_panel()
600 drm_connector_set_panel_orientation(connector, p->orientation);
605 static int panel_edp_get_timings(struct drm_panel *panel,
606 unsigned int num_timings,
607 struct display_timing *timings)
609 struct panel_edp *p = to_panel_edp(panel);
612 if (p->desc->num_timings < num_timings)
613 num_timings = p->desc->num_timings;
616 for (i = 0; i < num_timings; i++)
617 timings[i] = p->desc->timings[i];
619 return p->desc->num_timings;
622 static enum drm_panel_orientation panel_edp_get_orientation(struct drm_panel *panel)
624 struct panel_edp *p = to_panel_edp(panel);
626 return p->orientation;
629 static int detected_panel_show(struct seq_file *s, void *data)
631 struct drm_panel *panel = s->private;
632 struct panel_edp *p = to_panel_edp(panel);
634 if (IS_ERR(p->detected_panel))
635 seq_puts(s, "UNKNOWN\n");
636 else if (!p->detected_panel)
637 seq_puts(s, "HARDCODED\n");
639 seq_printf(s, "%s\n", p->detected_panel->name);
644 DEFINE_SHOW_ATTRIBUTE(detected_panel);
646 static void panel_edp_debugfs_init(struct drm_panel *panel, struct dentry *root)
648 debugfs_create_file("detected_panel", 0600, root, panel, &detected_panel_fops);
651 static const struct drm_panel_funcs panel_edp_funcs = {
652 .disable = panel_edp_disable,
653 .unprepare = panel_edp_unprepare,
654 .prepare = panel_edp_prepare,
655 .enable = panel_edp_enable,
656 .get_modes = panel_edp_get_modes,
657 .get_orientation = panel_edp_get_orientation,
658 .get_timings = panel_edp_get_timings,
659 .debugfs_init = panel_edp_debugfs_init,
662 #define PANEL_EDP_BOUNDS_CHECK(to_check, bounds, field) \
663 (to_check->field.typ >= bounds->field.min && \
664 to_check->field.typ <= bounds->field.max)
665 static void panel_edp_parse_panel_timing_node(struct device *dev,
666 struct panel_edp *panel,
667 const struct display_timing *ot)
669 const struct panel_desc *desc = panel->desc;
673 if (WARN_ON(desc->num_modes)) {
674 dev_err(dev, "Reject override mode: panel has a fixed mode\n");
677 if (WARN_ON(!desc->num_timings)) {
678 dev_err(dev, "Reject override mode: no timings specified\n");
682 for (i = 0; i < panel->desc->num_timings; i++) {
683 const struct display_timing *dt = &panel->desc->timings[i];
685 if (!PANEL_EDP_BOUNDS_CHECK(ot, dt, hactive) ||
686 !PANEL_EDP_BOUNDS_CHECK(ot, dt, hfront_porch) ||
687 !PANEL_EDP_BOUNDS_CHECK(ot, dt, hback_porch) ||
688 !PANEL_EDP_BOUNDS_CHECK(ot, dt, hsync_len) ||
689 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vactive) ||
690 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vfront_porch) ||
691 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vback_porch) ||
692 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vsync_len))
695 if (ot->flags != dt->flags)
698 videomode_from_timing(ot, &vm);
699 drm_display_mode_from_videomode(&vm, &panel->override_mode);
700 panel->override_mode.type |= DRM_MODE_TYPE_DRIVER |
701 DRM_MODE_TYPE_PREFERRED;
705 if (WARN_ON(!panel->override_mode.type))
706 dev_err(dev, "Reject override mode: No display_timing found\n");
709 static const struct edp_panel_entry *find_edp_panel(u32 panel_id);
711 static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel)
713 struct panel_desc *desc;
721 desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
727 * Read the dts properties for the initial probe. These are used by
728 * the runtime resume code which will get called by the
729 * pm_runtime_get_sync() call below.
731 of_property_read_u32(dev->of_node, "hpd-reliable-delay-ms", &reliable_ms);
732 desc->delay.hpd_reliable = reliable_ms;
733 of_property_read_u32(dev->of_node, "hpd-absent-delay-ms", &absent_ms);
734 desc->delay.hpd_absent = absent_ms;
736 /* Power the panel on so we can read the EDID */
737 ret = pm_runtime_get_sync(dev);
739 dev_err(dev, "Couldn't power on panel to read EDID: %d\n", ret);
743 panel_id = drm_edid_get_panel_id(panel->ddc);
745 dev_err(dev, "Couldn't identify panel via EDID\n");
749 drm_edid_decode_panel_id(panel_id, vend, &product_id);
751 panel->detected_panel = find_edp_panel(panel_id);
754 * We're using non-optimized timings and want it really obvious that
755 * someone needs to add an entry to the table, so we'll do a WARN_ON
758 if (WARN_ON(!panel->detected_panel)) {
760 "Unknown panel %s %#06x, using conservative timings\n",
764 * It's highly likely that the panel will work if we use very
765 * conservative timings, so let's do that. We already know that
766 * the HPD-related delays must have worked since we got this
767 * far, so we really just need the "unprepare" / "enable"
768 * delays. We don't need "prepare_to_enable" since that
769 * overlaps the "enable" delay anyway.
771 * Nearly all panels have a "unprepare" delay of 500 ms though
772 * there are a few with 1000. Let's stick 2000 in just to be
773 * super conservative.
775 * An "enable" delay of 80 ms seems the most common, but we'll
776 * throw in 200 ms to be safe.
778 desc->delay.unprepare = 2000;
779 desc->delay.enable = 200;
781 panel->detected_panel = ERR_PTR(-EINVAL);
783 dev_info(dev, "Detected %s %s (%#06x)\n",
784 vend, panel->detected_panel->name, product_id);
786 /* Update the delay; everything else comes from EDID */
787 desc->delay = *panel->detected_panel->delay;
792 pm_runtime_mark_last_busy(dev);
793 pm_runtime_put_autosuspend(dev);
798 static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,
799 struct drm_dp_aux *aux)
801 struct panel_edp *panel;
802 struct display_timing dt;
803 struct device_node *ddc;
806 panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
810 panel->enabled = false;
811 panel->prepared_time = 0;
815 panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");
816 if (!panel->no_hpd) {
817 err = panel_edp_get_hpd_gpio(dev, panel);
822 panel->supply = devm_regulator_get(dev, "power");
823 if (IS_ERR(panel->supply))
824 return PTR_ERR(panel->supply);
826 panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
828 if (IS_ERR(panel->enable_gpio))
829 return dev_err_probe(dev, PTR_ERR(panel->enable_gpio),
830 "failed to request GPIO\n");
832 err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
834 dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err);
838 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
840 panel->ddc = of_find_i2c_adapter_by_node(ddc);
844 return -EPROBE_DEFER;
846 panel->ddc = &aux->ddc;
849 if (!of_get_display_timing(dev->of_node, "panel-timing", &dt))
850 panel_edp_parse_panel_timing_node(dev, panel, &dt);
852 dev_set_drvdata(dev, panel);
854 drm_panel_init(&panel->base, dev, &panel_edp_funcs, DRM_MODE_CONNECTOR_eDP);
856 err = drm_panel_of_backlight(&panel->base);
858 goto err_finished_ddc_init;
861 * We use runtime PM for prepare / unprepare since those power the panel
862 * on and off and those can be very slow operations. This is important
863 * to optimize powering the panel on briefly to read the EDID before
864 * fully enabling the panel.
866 pm_runtime_enable(dev);
867 pm_runtime_set_autosuspend_delay(dev, 1000);
868 pm_runtime_use_autosuspend(dev);
870 if (of_device_is_compatible(dev->of_node, "edp-panel")) {
871 err = generic_edp_panel_probe(dev, panel);
873 dev_err_probe(dev, err,
874 "Couldn't detect panel nor find a fallback\n");
875 goto err_finished_pm_runtime;
877 /* generic_edp_panel_probe() replaces desc in the panel */
879 } else if (desc->bpc != 6 && desc->bpc != 8 && desc->bpc != 10) {
880 dev_warn(dev, "Expected bpc in {6,8,10} but got: %u\n", desc->bpc);
883 if (!panel->base.backlight && panel->aux) {
884 pm_runtime_get_sync(dev);
885 err = drm_panel_dp_aux_backlight(&panel->base, panel->aux);
886 pm_runtime_mark_last_busy(dev);
887 pm_runtime_put_autosuspend(dev);
889 goto err_finished_pm_runtime;
892 drm_panel_add(&panel->base);
896 err_finished_pm_runtime:
897 pm_runtime_dont_use_autosuspend(dev);
898 pm_runtime_disable(dev);
899 err_finished_ddc_init:
900 if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc))
901 put_device(&panel->ddc->dev);
906 static void panel_edp_remove(struct device *dev)
908 struct panel_edp *panel = dev_get_drvdata(dev);
910 drm_panel_remove(&panel->base);
911 drm_panel_disable(&panel->base);
912 drm_panel_unprepare(&panel->base);
914 pm_runtime_dont_use_autosuspend(dev);
915 pm_runtime_disable(dev);
916 if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc))
917 put_device(&panel->ddc->dev);
923 static void panel_edp_shutdown(struct device *dev)
925 struct panel_edp *panel = dev_get_drvdata(dev);
927 drm_panel_disable(&panel->base);
928 drm_panel_unprepare(&panel->base);
931 static const struct display_timing auo_b101ean01_timing = {
932 .pixelclock = { 65300000, 72500000, 75000000 },
933 .hactive = { 1280, 1280, 1280 },
934 .hfront_porch = { 18, 119, 119 },
935 .hback_porch = { 21, 21, 21 },
936 .hsync_len = { 32, 32, 32 },
937 .vactive = { 800, 800, 800 },
938 .vfront_porch = { 4, 4, 4 },
939 .vback_porch = { 8, 8, 8 },
940 .vsync_len = { 18, 20, 20 },
943 static const struct panel_desc auo_b101ean01 = {
944 .timings = &auo_b101ean01_timing,
953 static const struct drm_display_mode auo_b116xak01_mode = {
956 .hsync_start = 1366 + 48,
957 .hsync_end = 1366 + 48 + 32,
958 .htotal = 1366 + 48 + 32 + 10,
960 .vsync_start = 768 + 4,
961 .vsync_end = 768 + 4 + 6,
962 .vtotal = 768 + 4 + 6 + 15,
963 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
966 static const struct panel_desc auo_b116xak01 = {
967 .modes = &auo_b116xak01_mode,
981 static const struct drm_display_mode auo_b133han05_mode = {
984 .hsync_start = 1920 + 58,
985 .hsync_end = 1920 + 58 + 42,
986 .htotal = 1920 + 58 + 42 + 60,
988 .vsync_start = 1080 + 3,
989 .vsync_end = 1080 + 3 + 5,
990 .vtotal = 1080 + 3 + 5 + 54,
993 static const struct panel_desc auo_b133han05 = {
994 .modes = &auo_b133han05_mode,
1002 .hpd_reliable = 100,
1008 static const struct drm_display_mode auo_b133htn01_mode = {
1011 .hsync_start = 1920 + 172,
1012 .hsync_end = 1920 + 172 + 80,
1013 .htotal = 1920 + 172 + 80 + 60,
1015 .vsync_start = 1080 + 25,
1016 .vsync_end = 1080 + 25 + 10,
1017 .vtotal = 1080 + 25 + 10 + 10,
1020 static const struct panel_desc auo_b133htn01 = {
1021 .modes = &auo_b133htn01_mode,
1029 .hpd_reliable = 105,
1035 static const struct drm_display_mode auo_b133xtn01_mode = {
1038 .hsync_start = 1366 + 48,
1039 .hsync_end = 1366 + 48 + 32,
1040 .htotal = 1366 + 48 + 32 + 20,
1042 .vsync_start = 768 + 3,
1043 .vsync_end = 768 + 3 + 6,
1044 .vtotal = 768 + 3 + 6 + 13,
1047 static const struct panel_desc auo_b133xtn01 = {
1048 .modes = &auo_b133xtn01_mode,
1057 static const struct drm_display_mode auo_b140han06_mode = {
1060 .hsync_start = 1920 + 16,
1061 .hsync_end = 1920 + 16 + 16,
1062 .htotal = 1920 + 16 + 16 + 152,
1064 .vsync_start = 1080 + 3,
1065 .vsync_end = 1080 + 3 + 14,
1066 .vtotal = 1080 + 3 + 14 + 19,
1069 static const struct panel_desc auo_b140han06 = {
1070 .modes = &auo_b140han06_mode,
1078 .hpd_reliable = 100,
1084 static const struct drm_display_mode boe_nv101wxmn51_modes[] = {
1088 .hsync_start = 1280 + 48,
1089 .hsync_end = 1280 + 48 + 32,
1090 .htotal = 1280 + 48 + 32 + 80,
1092 .vsync_start = 800 + 3,
1093 .vsync_end = 800 + 3 + 5,
1094 .vtotal = 800 + 3 + 5 + 24,
1099 .hsync_start = 1280 + 48,
1100 .hsync_end = 1280 + 48 + 32,
1101 .htotal = 1280 + 48 + 32 + 80,
1103 .vsync_start = 800 + 3,
1104 .vsync_end = 800 + 3 + 5,
1105 .vtotal = 800 + 3 + 5 + 24,
1109 static const struct panel_desc boe_nv101wxmn51 = {
1110 .modes = boe_nv101wxmn51_modes,
1111 .num_modes = ARRAY_SIZE(boe_nv101wxmn51_modes),
1118 /* TODO: should be hpd-absent and no-hpd should be set? */
1119 .hpd_reliable = 210,
1125 static const struct drm_display_mode boe_nv110wtm_n61_modes[] = {
1129 .hsync_start = 2160 + 48,
1130 .hsync_end = 2160 + 48 + 32,
1131 .htotal = 2160 + 48 + 32 + 100,
1133 .vsync_start = 1440 + 3,
1134 .vsync_end = 1440 + 3 + 6,
1135 .vtotal = 1440 + 3 + 6 + 31,
1136 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
1141 .hsync_start = 2160 + 48,
1142 .hsync_end = 2160 + 48 + 32,
1143 .htotal = 2160 + 48 + 32 + 100,
1145 .vsync_start = 1440 + 3,
1146 .vsync_end = 1440 + 3 + 6,
1147 .vtotal = 1440 + 3 + 6 + 31,
1148 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
1152 static const struct panel_desc boe_nv110wtm_n61 = {
1153 .modes = boe_nv110wtm_n61_modes,
1154 .num_modes = ARRAY_SIZE(boe_nv110wtm_n61_modes),
1162 .prepare_to_enable = 80,
1168 /* Also used for boe_nv133fhm_n62 */
1169 static const struct drm_display_mode boe_nv133fhm_n61_modes = {
1172 .hsync_start = 1920 + 48,
1173 .hsync_end = 1920 + 48 + 32,
1174 .htotal = 1920 + 48 + 32 + 200,
1176 .vsync_start = 1080 + 3,
1177 .vsync_end = 1080 + 3 + 6,
1178 .vtotal = 1080 + 3 + 6 + 31,
1179 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
1182 /* Also used for boe_nv133fhm_n62 */
1183 static const struct panel_desc boe_nv133fhm_n61 = {
1184 .modes = &boe_nv133fhm_n61_modes,
1193 * When power is first given to the panel there's a short
1194 * spike on the HPD line. It was explained that this spike
1195 * was until the TCON data download was complete. On
1196 * one system this was measured at 8 ms. We'll put 15 ms
1197 * in the prepare delay just to be safe. That means:
1198 * - If HPD isn't hooked up you still have 200 ms delay.
1199 * - If HPD is hooked up we won't try to look at it for the
1209 static const struct drm_display_mode boe_nv140fhmn49_modes[] = {
1213 .hsync_start = 1920 + 48,
1214 .hsync_end = 1920 + 48 + 32,
1217 .vsync_start = 1080 + 3,
1218 .vsync_end = 1080 + 3 + 5,
1223 static const struct panel_desc boe_nv140fhmn49 = {
1224 .modes = boe_nv140fhmn49_modes,
1225 .num_modes = ARRAY_SIZE(boe_nv140fhmn49_modes),
1232 /* TODO: should be hpd-absent and no-hpd should be set? */
1233 .hpd_reliable = 210,
1239 static const struct drm_display_mode innolux_n116bca_ea1_mode = {
1242 .hsync_start = 1366 + 136,
1243 .hsync_end = 1366 + 136 + 30,
1244 .htotal = 1366 + 136 + 30 + 60,
1246 .vsync_start = 768 + 8,
1247 .vsync_end = 768 + 8 + 12,
1248 .vtotal = 768 + 8 + 12 + 12,
1249 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
1252 static const struct panel_desc innolux_n116bca_ea1 = {
1253 .modes = &innolux_n116bca_ea1_mode,
1269 * Datasheet specifies that at 60 Hz refresh rate:
1270 * - total horizontal time: { 1506, 1592, 1716 }
1271 * - total vertical time: { 788, 800, 868 }
1273 * ...but doesn't go into exactly how that should be split into a front
1274 * porch, back porch, or sync length. For now we'll leave a single setting
1275 * here which allows a bit of tweaking of the pixel clock at the expense of
1278 static const struct display_timing innolux_n116bge_timing = {
1279 .pixelclock = { 72600000, 76420000, 80240000 },
1280 .hactive = { 1366, 1366, 1366 },
1281 .hfront_porch = { 136, 136, 136 },
1282 .hback_porch = { 60, 60, 60 },
1283 .hsync_len = { 30, 30, 30 },
1284 .vactive = { 768, 768, 768 },
1285 .vfront_porch = { 8, 8, 8 },
1286 .vback_porch = { 12, 12, 12 },
1287 .vsync_len = { 12, 12, 12 },
1288 .flags = DISPLAY_FLAGS_VSYNC_LOW | DISPLAY_FLAGS_HSYNC_LOW,
1291 static const struct panel_desc innolux_n116bge = {
1292 .timings = &innolux_n116bge_timing,
1301 static const struct drm_display_mode innolux_n125hce_gn1_mode = {
1304 .hsync_start = 1920 + 40,
1305 .hsync_end = 1920 + 40 + 40,
1306 .htotal = 1920 + 40 + 40 + 80,
1308 .vsync_start = 1080 + 4,
1309 .vsync_end = 1080 + 4 + 4,
1310 .vtotal = 1080 + 4 + 4 + 24,
1313 static const struct panel_desc innolux_n125hce_gn1 = {
1314 .modes = &innolux_n125hce_gn1_mode,
1323 static const struct drm_display_mode innolux_p120zdg_bf1_mode = {
1326 .hsync_start = 2160 + 48,
1327 .hsync_end = 2160 + 48 + 32,
1328 .htotal = 2160 + 48 + 32 + 80,
1330 .vsync_start = 1440 + 3,
1331 .vsync_end = 1440 + 3 + 10,
1332 .vtotal = 1440 + 3 + 10 + 27,
1333 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
1336 static const struct panel_desc innolux_p120zdg_bf1 = {
1337 .modes = &innolux_p120zdg_bf1_mode,
1350 static const struct drm_display_mode ivo_m133nwf4_r0_mode = {
1353 .hsync_start = 1920 + 24,
1354 .hsync_end = 1920 + 24 + 48,
1355 .htotal = 1920 + 24 + 48 + 88,
1357 .vsync_start = 1080 + 3,
1358 .vsync_end = 1080 + 3 + 12,
1359 .vtotal = 1080 + 3 + 12 + 17,
1360 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
1363 static const struct panel_desc ivo_m133nwf4_r0 = {
1364 .modes = &ivo_m133nwf4_r0_mode,
1377 static const struct drm_display_mode kingdisplay_kd116n21_30nv_a010_mode = {
1380 .hsync_start = 1366 + 40,
1381 .hsync_end = 1366 + 40 + 32,
1382 .htotal = 1366 + 40 + 32 + 62,
1384 .vsync_start = 768 + 5,
1385 .vsync_end = 768 + 5 + 5,
1386 .vtotal = 768 + 5 + 5 + 122,
1387 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1390 static const struct panel_desc kingdisplay_kd116n21_30nv_a010 = {
1391 .modes = &kingdisplay_kd116n21_30nv_a010_mode,
1403 static const struct drm_display_mode lg_lp079qx1_sp0v_mode = {
1406 .hsync_start = 1536 + 12,
1407 .hsync_end = 1536 + 12 + 16,
1408 .htotal = 1536 + 12 + 16 + 48,
1410 .vsync_start = 2048 + 8,
1411 .vsync_end = 2048 + 8 + 4,
1412 .vtotal = 2048 + 8 + 4 + 8,
1413 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1416 static const struct panel_desc lg_lp079qx1_sp0v = {
1417 .modes = &lg_lp079qx1_sp0v_mode,
1425 static const struct drm_display_mode lg_lp097qx1_spa1_mode = {
1428 .hsync_start = 2048 + 150,
1429 .hsync_end = 2048 + 150 + 5,
1430 .htotal = 2048 + 150 + 5 + 5,
1432 .vsync_start = 1536 + 3,
1433 .vsync_end = 1536 + 3 + 1,
1434 .vtotal = 1536 + 3 + 1 + 9,
1437 static const struct panel_desc lg_lp097qx1_spa1 = {
1438 .modes = &lg_lp097qx1_spa1_mode,
1446 static const struct drm_display_mode lg_lp120up1_mode = {
1449 .hsync_start = 1920 + 40,
1450 .hsync_end = 1920 + 40 + 40,
1451 .htotal = 1920 + 40 + 40 + 80,
1453 .vsync_start = 1280 + 4,
1454 .vsync_end = 1280 + 4 + 4,
1455 .vtotal = 1280 + 4 + 4 + 12,
1458 static const struct panel_desc lg_lp120up1 = {
1459 .modes = &lg_lp120up1_mode,
1468 static const struct drm_display_mode lg_lp129qe_mode = {
1471 .hsync_start = 2560 + 48,
1472 .hsync_end = 2560 + 48 + 32,
1473 .htotal = 2560 + 48 + 32 + 80,
1475 .vsync_start = 1700 + 3,
1476 .vsync_end = 1700 + 3 + 10,
1477 .vtotal = 1700 + 3 + 10 + 36,
1480 static const struct panel_desc lg_lp129qe = {
1481 .modes = &lg_lp129qe_mode,
1490 static const struct drm_display_mode neweast_wjfh116008a_modes[] = {
1494 .hsync_start = 1920 + 48,
1495 .hsync_end = 1920 + 48 + 32,
1496 .htotal = 1920 + 48 + 32 + 80,
1498 .vsync_start = 1080 + 3,
1499 .vsync_end = 1080 + 3 + 5,
1500 .vtotal = 1080 + 3 + 5 + 23,
1501 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1505 .hsync_start = 1920 + 48,
1506 .hsync_end = 1920 + 48 + 32,
1507 .htotal = 1920 + 48 + 32 + 80,
1509 .vsync_start = 1080 + 3,
1510 .vsync_end = 1080 + 3 + 5,
1511 .vtotal = 1080 + 3 + 5 + 23,
1512 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1516 static const struct panel_desc neweast_wjfh116008a = {
1517 .modes = neweast_wjfh116008a_modes,
1525 .hpd_reliable = 110,
1531 static const struct drm_display_mode samsung_lsn122dl01_c01_mode = {
1534 .hsync_start = 2560 + 48,
1535 .hsync_end = 2560 + 48 + 32,
1536 .htotal = 2560 + 48 + 32 + 80,
1538 .vsync_start = 1600 + 2,
1539 .vsync_end = 1600 + 2 + 5,
1540 .vtotal = 1600 + 2 + 5 + 57,
1543 static const struct panel_desc samsung_lsn122dl01_c01 = {
1544 .modes = &samsung_lsn122dl01_c01_mode,
1552 static const struct drm_display_mode samsung_ltn140at29_301_mode = {
1555 .hsync_start = 1366 + 64,
1556 .hsync_end = 1366 + 64 + 48,
1557 .htotal = 1366 + 64 + 48 + 128,
1559 .vsync_start = 768 + 2,
1560 .vsync_end = 768 + 2 + 5,
1561 .vtotal = 768 + 2 + 5 + 17,
1564 static const struct panel_desc samsung_ltn140at29_301 = {
1565 .modes = &samsung_ltn140at29_301_mode,
1574 static const struct drm_display_mode sharp_ld_d5116z01b_mode = {
1577 .hsync_start = 1920 + 48,
1578 .hsync_end = 1920 + 48 + 32,
1579 .htotal = 1920 + 48 + 32 + 80,
1581 .vsync_start = 1280 + 3,
1582 .vsync_end = 1280 + 3 + 10,
1583 .vtotal = 1280 + 3 + 10 + 57,
1584 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
1587 static const struct panel_desc sharp_ld_d5116z01b = {
1588 .modes = &sharp_ld_d5116z01b_mode,
1597 static const struct display_timing sharp_lq123p1jx31_timing = {
1598 .pixelclock = { 252750000, 252750000, 266604720 },
1599 .hactive = { 2400, 2400, 2400 },
1600 .hfront_porch = { 48, 48, 48 },
1601 .hback_porch = { 80, 80, 84 },
1602 .hsync_len = { 32, 32, 32 },
1603 .vactive = { 1600, 1600, 1600 },
1604 .vfront_porch = { 3, 3, 3 },
1605 .vback_porch = { 33, 33, 120 },
1606 .vsync_len = { 10, 10, 10 },
1607 .flags = DISPLAY_FLAGS_VSYNC_LOW | DISPLAY_FLAGS_HSYNC_LOW,
1610 static const struct panel_desc sharp_lq123p1jx31 = {
1611 .timings = &sharp_lq123p1jx31_timing,
1619 .hpd_reliable = 110,
1625 static const struct drm_display_mode sharp_lq140m1jw46_mode[] = {
1629 .hsync_start = 1920 + 48,
1630 .hsync_end = 1920 + 48 + 32,
1631 .htotal = 1920 + 48 + 32 + 80,
1633 .vsync_start = 1080 + 3,
1634 .vsync_end = 1080 + 3 + 5,
1635 .vtotal = 1080 + 3 + 5 + 69,
1636 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1640 .hsync_start = 1920 + 48,
1641 .hsync_end = 1920 + 48 + 32,
1642 .htotal = 1920 + 48 + 32 + 80,
1644 .vsync_start = 1080 + 3,
1645 .vsync_end = 1080 + 3 + 5,
1646 .vtotal = 1080 + 3 + 5 + 69,
1647 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1651 static const struct panel_desc sharp_lq140m1jw46 = {
1652 .modes = sharp_lq140m1jw46_mode,
1653 .num_modes = ARRAY_SIZE(sharp_lq140m1jw46_mode),
1666 static const struct drm_display_mode starry_kr122ea0sra_mode = {
1669 .hsync_start = 1920 + 16,
1670 .hsync_end = 1920 + 16 + 16,
1671 .htotal = 1920 + 16 + 16 + 32,
1673 .vsync_start = 1200 + 15,
1674 .vsync_end = 1200 + 15 + 2,
1675 .vtotal = 1200 + 15 + 2 + 18,
1676 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1679 static const struct panel_desc starry_kr122ea0sra = {
1680 .modes = &starry_kr122ea0sra_mode,
1687 /* TODO: should be hpd-absent and no-hpd should be set? */
1688 .hpd_reliable = 10 + 200,
1690 .unprepare = 10 + 500,
1694 static const struct of_device_id platform_of_match[] = {
1697 .compatible = "edp-panel",
1699 .compatible = "auo,b101ean01",
1700 .data = &auo_b101ean01,
1702 .compatible = "auo,b116xa01",
1703 .data = &auo_b116xak01,
1705 .compatible = "auo,b133han05",
1706 .data = &auo_b133han05,
1708 .compatible = "auo,b133htn01",
1709 .data = &auo_b133htn01,
1711 .compatible = "auo,b133xtn01",
1712 .data = &auo_b133xtn01,
1714 .compatible = "auo,b140han06",
1715 .data = &auo_b140han06,
1717 .compatible = "boe,nv101wxmn51",
1718 .data = &boe_nv101wxmn51,
1720 .compatible = "boe,nv110wtm-n61",
1721 .data = &boe_nv110wtm_n61,
1723 .compatible = "boe,nv133fhm-n61",
1724 .data = &boe_nv133fhm_n61,
1726 .compatible = "boe,nv133fhm-n62",
1727 .data = &boe_nv133fhm_n61,
1729 .compatible = "boe,nv140fhmn49",
1730 .data = &boe_nv140fhmn49,
1732 .compatible = "innolux,n116bca-ea1",
1733 .data = &innolux_n116bca_ea1,
1735 .compatible = "innolux,n116bge",
1736 .data = &innolux_n116bge,
1738 .compatible = "innolux,n125hce-gn1",
1739 .data = &innolux_n125hce_gn1,
1741 .compatible = "innolux,p120zdg-bf1",
1742 .data = &innolux_p120zdg_bf1,
1744 .compatible = "ivo,m133nwf4-r0",
1745 .data = &ivo_m133nwf4_r0,
1747 .compatible = "kingdisplay,kd116n21-30nv-a010",
1748 .data = &kingdisplay_kd116n21_30nv_a010,
1750 .compatible = "lg,lp079qx1-sp0v",
1751 .data = &lg_lp079qx1_sp0v,
1753 .compatible = "lg,lp097qx1-spa1",
1754 .data = &lg_lp097qx1_spa1,
1756 .compatible = "lg,lp120up1",
1757 .data = &lg_lp120up1,
1759 .compatible = "lg,lp129qe",
1760 .data = &lg_lp129qe,
1762 .compatible = "neweast,wjfh116008a",
1763 .data = &neweast_wjfh116008a,
1765 .compatible = "samsung,lsn122dl01-c01",
1766 .data = &samsung_lsn122dl01_c01,
1768 .compatible = "samsung,ltn140at29-301",
1769 .data = &samsung_ltn140at29_301,
1771 .compatible = "sharp,ld-d5116z01b",
1772 .data = &sharp_ld_d5116z01b,
1774 .compatible = "sharp,lq123p1jx31",
1775 .data = &sharp_lq123p1jx31,
1777 .compatible = "sharp,lq140m1jw46",
1778 .data = &sharp_lq140m1jw46,
1780 .compatible = "starry,kr122ea0sra",
1781 .data = &starry_kr122ea0sra,
1786 MODULE_DEVICE_TABLE(of, platform_of_match);
1788 static const struct panel_delay delay_200_500_p2e80 = {
1791 .prepare_to_enable = 80,
1794 static const struct panel_delay delay_200_500_p2e100 = {
1797 .prepare_to_enable = 100,
1800 static const struct panel_delay delay_200_500_e50 = {
1806 static const struct panel_delay delay_200_500_e80 = {
1812 static const struct panel_delay delay_200_500_e80_d50 = {
1819 static const struct panel_delay delay_100_500_e200 = {
1825 static const struct panel_delay delay_200_500_e200 = {
1831 static const struct panel_delay delay_200_500_e200_d10 = {
1838 static const struct panel_delay delay_200_150_e200 = {
1844 #define EDP_PANEL_ENTRY(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _delay, _name) \
1847 .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \
1853 * This table is used to figure out power sequencing delays for panels that
1854 * are detected by EDID. Entries here may point to entries in the
1855 * platform_of_match table (if a panel is listed in both places).
1857 * Sort first by vendor, then by product ID.
1859 static const struct edp_panel_entry edp_panels[] = {
1860 EDP_PANEL_ENTRY('A', 'U', 'O', 0x1062, &delay_200_500_e50, "B120XAN01.0"),
1861 EDP_PANEL_ENTRY('A', 'U', 'O', 0x145c, &delay_200_500_e50, "B116XAB01.4"),
1862 EDP_PANEL_ENTRY('A', 'U', 'O', 0x1e9b, &delay_200_500_e50, "B133UAN02.1"),
1863 EDP_PANEL_ENTRY('A', 'U', 'O', 0x1ea5, &delay_200_500_e50, "B116XAK01.6"),
1864 EDP_PANEL_ENTRY('A', 'U', 'O', 0x208d, &delay_200_500_e50, "B140HTN02.1"),
1865 EDP_PANEL_ENTRY('A', 'U', 'O', 0x235c, &delay_200_500_e50, "B116XTN02.3"),
1866 EDP_PANEL_ENTRY('A', 'U', 'O', 0x239b, &delay_200_500_e50, "B116XAN06.1"),
1867 EDP_PANEL_ENTRY('A', 'U', 'O', 0x255c, &delay_200_500_e50, "B116XTN02.5"),
1868 EDP_PANEL_ENTRY('A', 'U', 'O', 0x403d, &delay_200_500_e50, "B140HAN04.0"),
1869 EDP_PANEL_ENTRY('A', 'U', 'O', 0x405c, &auo_b116xak01.delay, "B116XAK01.0"),
1870 EDP_PANEL_ENTRY('A', 'U', 'O', 0x582d, &delay_200_500_e50, "B133UAN01.0"),
1871 EDP_PANEL_ENTRY('A', 'U', 'O', 0x615c, &delay_200_500_e50, "B116XAN06.1"),
1872 EDP_PANEL_ENTRY('A', 'U', 'O', 0x635c, &delay_200_500_e50, "B116XAN06.3"),
1873 EDP_PANEL_ENTRY('A', 'U', 'O', 0x639c, &delay_200_500_e50, "B140HAK02.7"),
1874 EDP_PANEL_ENTRY('A', 'U', 'O', 0x8594, &delay_200_500_e50, "B133UAN01.0"),
1875 EDP_PANEL_ENTRY('A', 'U', 'O', 0xf390, &delay_200_500_e50, "B140XTN07.7"),
1877 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0715, &delay_200_150_e200, "NT116WHM-N21"),
1878 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0731, &delay_200_500_e80, "NT116WHM-N42"),
1879 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0741, &delay_200_500_e200, "NT116WHM-N44"),
1880 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0786, &delay_200_500_p2e80, "NV116WHM-T01"),
1881 EDP_PANEL_ENTRY('B', 'O', 'E', 0x07d1, &boe_nv133fhm_n61.delay, "NV133FHM-N61"),
1882 EDP_PANEL_ENTRY('B', 'O', 'E', 0x07f6, &delay_200_500_e200, "NT140FHM-N44"),
1883 EDP_PANEL_ENTRY('B', 'O', 'E', 0x082d, &boe_nv133fhm_n61.delay, "NV133FHM-N62"),
1884 EDP_PANEL_ENTRY('B', 'O', 'E', 0x08b2, &delay_200_500_e200, "NT140WHM-N49"),
1885 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09c3, &delay_200_500_e50, "NT116WHM-N21,836X2"),
1886 EDP_PANEL_ENTRY('B', 'O', 'E', 0x094b, &delay_200_500_e50, "NT116WHM-N21"),
1887 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0951, &delay_200_500_e80, "NV116WHM-N47"),
1888 EDP_PANEL_ENTRY('B', 'O', 'E', 0x095f, &delay_200_500_e50, "NE135FBM-N41 v8.1"),
1889 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0979, &delay_200_500_e50, "NV116WHM-N49 V8.0"),
1890 EDP_PANEL_ENTRY('B', 'O', 'E', 0x098d, &boe_nv110wtm_n61.delay, "NV110WTM-N61"),
1891 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09ae, &delay_200_500_e200, "NT140FHM-N45"),
1892 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09dd, &delay_200_500_e50, "NT116WHM-N21"),
1893 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0a5d, &delay_200_500_e50, "NV116WHM-N45"),
1894 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0ac5, &delay_200_500_e50, "NV116WHM-N4C"),
1895 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0b43, &delay_200_500_e200, "NV140FHM-T09"),
1896 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0b56, &delay_200_500_e80, "NT140FHM-N47"),
1897 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0c20, &delay_200_500_e80, "NT140FHM-N47"),
1899 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1132, &delay_200_500_e80_d50, "N116BGE-EA2"),
1900 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1138, &innolux_n116bca_ea1.delay, "N116BCA-EA1-RC4"),
1901 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1139, &delay_200_500_e80_d50, "N116BGE-EA2"),
1902 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1145, &delay_200_500_e80_d50, "N116BCN-EB1"),
1903 EDP_PANEL_ENTRY('C', 'M', 'N', 0x114c, &innolux_n116bca_ea1.delay, "N116BCA-EA1"),
1904 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1152, &delay_200_500_e80_d50, "N116BCN-EA1"),
1905 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1153, &delay_200_500_e80_d50, "N116BGE-EA2"),
1906 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1154, &delay_200_500_e80_d50, "N116BCA-EA2"),
1907 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1157, &delay_200_500_e80_d50, "N116BGE-EA2"),
1908 EDP_PANEL_ENTRY('C', 'M', 'N', 0x115b, &delay_200_500_e80_d50, "N116BCN-EB1"),
1909 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1247, &delay_200_500_e80_d50, "N120ACA-EA1"),
1910 EDP_PANEL_ENTRY('C', 'M', 'N', 0x142b, &delay_200_500_e80_d50, "N140HCA-EAC"),
1911 EDP_PANEL_ENTRY('C', 'M', 'N', 0x144f, &delay_200_500_e80_d50, "N140HGA-EA1"),
1912 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1468, &delay_200_500_e80, "N140HGA-EA1"),
1913 EDP_PANEL_ENTRY('C', 'M', 'N', 0x14e5, &delay_200_500_e80_d50, "N140HGA-EA1"),
1914 EDP_PANEL_ENTRY('C', 'M', 'N', 0x14d4, &delay_200_500_e80_d50, "N140HCA-EAC"),
1915 EDP_PANEL_ENTRY('C', 'M', 'N', 0x14d6, &delay_200_500_e80_d50, "N140BGA-EA4"),
1917 EDP_PANEL_ENTRY('H', 'K', 'C', 0x2d5c, &delay_200_500_e200, "MB116AN01-2"),
1919 EDP_PANEL_ENTRY('I', 'V', 'O', 0x048e, &delay_200_500_e200_d10, "M116NWR6 R5"),
1920 EDP_PANEL_ENTRY('I', 'V', 'O', 0x057d, &delay_200_500_e200, "R140NWF5 RH"),
1921 EDP_PANEL_ENTRY('I', 'V', 'O', 0x854a, &delay_200_500_p2e100, "M133NW4J"),
1922 EDP_PANEL_ENTRY('I', 'V', 'O', 0x854b, &delay_200_500_p2e100, "R133NW4K-R0"),
1923 EDP_PANEL_ENTRY('I', 'V', 'O', 0x8c4d, &delay_200_150_e200, "R140NWFM R1"),
1925 EDP_PANEL_ENTRY('K', 'D', 'B', 0x0624, &kingdisplay_kd116n21_30nv_a010.delay, "116N21-30NV-A010"),
1926 EDP_PANEL_ENTRY('K', 'D', 'C', 0x0809, &delay_200_500_e50, "KD116N2930A15"),
1927 EDP_PANEL_ENTRY('K', 'D', 'B', 0x1120, &delay_200_500_e80_d50, "116N29-30NK-C007"),
1929 EDP_PANEL_ENTRY('S', 'H', 'P', 0x1511, &delay_200_500_e50, "LQ140M1JW48"),
1930 EDP_PANEL_ENTRY('S', 'H', 'P', 0x1523, &sharp_lq140m1jw46.delay, "LQ140M1JW46"),
1931 EDP_PANEL_ENTRY('S', 'H', 'P', 0x154c, &delay_200_500_p2e100, "LQ116M1JW10"),
1933 EDP_PANEL_ENTRY('S', 'T', 'A', 0x0100, &delay_100_500_e200, "2081116HHD028001-51D"),
1938 static const struct edp_panel_entry *find_edp_panel(u32 panel_id)
1940 const struct edp_panel_entry *panel;
1945 for (panel = edp_panels; panel->panel_id; panel++)
1946 if (panel->panel_id == panel_id)
1952 static int panel_edp_platform_probe(struct platform_device *pdev)
1954 const struct of_device_id *id;
1956 /* Skip one since "edp-panel" is only supported on DP AUX bus */
1957 id = of_match_node(platform_of_match + 1, pdev->dev.of_node);
1961 return panel_edp_probe(&pdev->dev, id->data, NULL);
1964 static void panel_edp_platform_remove(struct platform_device *pdev)
1966 panel_edp_remove(&pdev->dev);
1969 static void panel_edp_platform_shutdown(struct platform_device *pdev)
1971 panel_edp_shutdown(&pdev->dev);
1974 static const struct dev_pm_ops panel_edp_pm_ops = {
1975 SET_RUNTIME_PM_OPS(panel_edp_suspend, panel_edp_resume, NULL)
1976 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
1977 pm_runtime_force_resume)
1980 static struct platform_driver panel_edp_platform_driver = {
1982 .name = "panel-edp",
1983 .of_match_table = platform_of_match,
1984 .pm = &panel_edp_pm_ops,
1986 .probe = panel_edp_platform_probe,
1987 .remove_new = panel_edp_platform_remove,
1988 .shutdown = panel_edp_platform_shutdown,
1991 static int panel_edp_dp_aux_ep_probe(struct dp_aux_ep_device *aux_ep)
1993 const struct of_device_id *id;
1995 id = of_match_node(platform_of_match, aux_ep->dev.of_node);
1999 return panel_edp_probe(&aux_ep->dev, id->data, aux_ep->aux);
2002 static void panel_edp_dp_aux_ep_remove(struct dp_aux_ep_device *aux_ep)
2004 panel_edp_remove(&aux_ep->dev);
2007 static void panel_edp_dp_aux_ep_shutdown(struct dp_aux_ep_device *aux_ep)
2009 panel_edp_shutdown(&aux_ep->dev);
2012 static struct dp_aux_ep_driver panel_edp_dp_aux_ep_driver = {
2014 .name = "panel-simple-dp-aux",
2015 .of_match_table = platform_of_match, /* Same as platform one! */
2016 .pm = &panel_edp_pm_ops,
2018 .probe = panel_edp_dp_aux_ep_probe,
2019 .remove = panel_edp_dp_aux_ep_remove,
2020 .shutdown = panel_edp_dp_aux_ep_shutdown,
2023 static int __init panel_edp_init(void)
2027 err = platform_driver_register(&panel_edp_platform_driver);
2031 err = dp_aux_dp_driver_register(&panel_edp_dp_aux_ep_driver);
2033 goto err_did_platform_register;
2037 err_did_platform_register:
2038 platform_driver_unregister(&panel_edp_platform_driver);
2042 module_init(panel_edp_init);
2044 static void __exit panel_edp_exit(void)
2046 dp_aux_dp_driver_unregister(&panel_edp_dp_aux_ep_driver);
2047 platform_driver_unregister(&panel_edp_platform_driver);
2049 module_exit(panel_edp_exit);
2051 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
2052 MODULE_DESCRIPTION("DRM Driver for Simple eDP Panels");
2053 MODULE_LICENSE("GPL and additional rights");