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). */
207 /** @override_edid_mode: Override the mode obtained by edid. */
208 const struct drm_display_mode *override_edid_mode;
212 struct drm_panel base;
218 ktime_t prepared_time;
219 ktime_t unprepared_time;
221 const struct panel_desc *desc;
223 struct regulator *supply;
224 struct i2c_adapter *ddc;
225 struct drm_dp_aux *aux;
227 struct gpio_desc *enable_gpio;
228 struct gpio_desc *hpd_gpio;
230 const struct edp_panel_entry *detected_panel;
234 struct drm_display_mode override_mode;
236 enum drm_panel_orientation orientation;
239 static inline struct panel_edp *to_panel_edp(struct drm_panel *panel)
241 return container_of(panel, struct panel_edp, base);
244 static unsigned int panel_edp_get_timings_modes(struct panel_edp *panel,
245 struct drm_connector *connector)
247 struct drm_display_mode *mode;
248 unsigned int i, num = 0;
250 for (i = 0; i < panel->desc->num_timings; i++) {
251 const struct display_timing *dt = &panel->desc->timings[i];
254 videomode_from_timing(dt, &vm);
255 mode = drm_mode_create(connector->dev);
257 dev_err(panel->base.dev, "failed to add mode %ux%u\n",
258 dt->hactive.typ, dt->vactive.typ);
262 drm_display_mode_from_videomode(&vm, mode);
264 mode->type |= DRM_MODE_TYPE_DRIVER;
266 if (panel->desc->num_timings == 1)
267 mode->type |= DRM_MODE_TYPE_PREFERRED;
269 drm_mode_probed_add(connector, mode);
276 static unsigned int panel_edp_get_display_modes(struct panel_edp *panel,
277 struct drm_connector *connector)
279 struct drm_display_mode *mode;
280 unsigned int i, num = 0;
282 for (i = 0; i < panel->desc->num_modes; i++) {
283 const struct drm_display_mode *m = &panel->desc->modes[i];
285 mode = drm_mode_duplicate(connector->dev, m);
287 dev_err(panel->base.dev, "failed to add mode %ux%u@%u\n",
288 m->hdisplay, m->vdisplay,
289 drm_mode_vrefresh(m));
293 mode->type |= DRM_MODE_TYPE_DRIVER;
295 if (panel->desc->num_modes == 1)
296 mode->type |= DRM_MODE_TYPE_PREFERRED;
298 drm_mode_set_name(mode);
300 drm_mode_probed_add(connector, mode);
307 static int panel_edp_override_edid_mode(struct panel_edp *panel,
308 struct drm_connector *connector,
309 const struct drm_display_mode *override_mode)
311 struct drm_display_mode *mode;
313 mode = drm_mode_duplicate(connector->dev, override_mode);
315 dev_err(panel->base.dev, "failed to add additional mode\n");
319 mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
320 drm_mode_set_name(mode);
321 drm_mode_probed_add(connector, mode);
325 static int panel_edp_get_non_edid_modes(struct panel_edp *panel,
326 struct drm_connector *connector)
328 struct drm_display_mode *mode;
329 bool has_override = panel->override_mode.type;
330 unsigned int num = 0;
336 mode = drm_mode_duplicate(connector->dev,
337 &panel->override_mode);
339 drm_mode_probed_add(connector, mode);
342 dev_err(panel->base.dev, "failed to add override mode\n");
346 /* Only add timings if override was not there or failed to validate */
347 if (num == 0 && panel->desc->num_timings)
348 num = panel_edp_get_timings_modes(panel, connector);
351 * Only add fixed modes if timings/override added no mode.
353 * We should only ever have either the display timings specified
354 * or a fixed mode. Anything else is rather bogus.
356 WARN_ON(panel->desc->num_timings && panel->desc->num_modes);
358 num = panel_edp_get_display_modes(panel, connector);
360 connector->display_info.bpc = panel->desc->bpc;
361 connector->display_info.width_mm = panel->desc->size.width;
362 connector->display_info.height_mm = panel->desc->size.height;
367 static void panel_edp_wait(ktime_t start_ktime, unsigned int min_ms)
369 ktime_t now_ktime, min_ktime;
374 min_ktime = ktime_add(start_ktime, ms_to_ktime(min_ms));
375 now_ktime = ktime_get_boottime();
377 if (ktime_before(now_ktime, min_ktime))
378 msleep(ktime_to_ms(ktime_sub(min_ktime, now_ktime)) + 1);
381 static int panel_edp_disable(struct drm_panel *panel)
383 struct panel_edp *p = to_panel_edp(panel);
388 if (p->desc->delay.disable)
389 msleep(p->desc->delay.disable);
396 static int panel_edp_suspend(struct device *dev)
398 struct panel_edp *p = dev_get_drvdata(dev);
400 gpiod_set_value_cansleep(p->enable_gpio, 0);
401 regulator_disable(p->supply);
402 p->unprepared_time = ktime_get_boottime();
407 static int panel_edp_unprepare(struct drm_panel *panel)
409 struct panel_edp *p = to_panel_edp(panel);
412 /* Unpreparing when already unprepared is a no-op */
416 pm_runtime_mark_last_busy(panel->dev);
417 ret = pm_runtime_put_autosuspend(panel->dev);
425 static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p)
427 p->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN);
428 if (IS_ERR(p->hpd_gpio))
429 return dev_err_probe(dev, PTR_ERR(p->hpd_gpio),
430 "failed to get 'hpd' GPIO\n");
435 static bool panel_edp_can_read_hpd(struct panel_edp *p)
437 return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted));
440 static int panel_edp_prepare_once(struct panel_edp *p)
442 struct device *dev = p->base.dev;
446 unsigned long hpd_wait_us;
448 panel_edp_wait(p->unprepared_time, p->desc->delay.unprepare);
450 err = regulator_enable(p->supply);
452 dev_err(dev, "failed to enable supply: %d\n", err);
456 gpiod_set_value_cansleep(p->enable_gpio, 1);
458 delay = p->desc->delay.hpd_reliable;
460 delay = max(delay, p->desc->delay.hpd_absent);
464 if (panel_edp_can_read_hpd(p)) {
465 if (p->desc->delay.hpd_absent)
466 hpd_wait_us = p->desc->delay.hpd_absent * 1000UL;
468 hpd_wait_us = 2000000;
471 err = readx_poll_timeout(gpiod_get_value_cansleep,
472 p->hpd_gpio, hpd_asserted,
473 hpd_asserted, 1000, hpd_wait_us);
474 if (hpd_asserted < 0)
477 err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us);
481 if (err != -ETIMEDOUT)
483 "error waiting for hpd GPIO: %d\n", err);
488 p->prepared_time = ktime_get_boottime();
493 gpiod_set_value_cansleep(p->enable_gpio, 0);
494 regulator_disable(p->supply);
495 p->unprepared_time = ktime_get_boottime();
501 * Some panels simply don't always come up and need to be power cycled to
502 * work properly. We'll allow for a handful of retries.
504 #define MAX_PANEL_PREPARE_TRIES 5
506 static int panel_edp_resume(struct device *dev)
508 struct panel_edp *p = dev_get_drvdata(dev);
512 for (try = 0; try < MAX_PANEL_PREPARE_TRIES; try++) {
513 ret = panel_edp_prepare_once(p);
514 if (ret != -ETIMEDOUT)
518 if (ret == -ETIMEDOUT)
519 dev_err(dev, "Prepare timeout after %d tries\n", try);
521 dev_warn(dev, "Prepare needed %d retries\n", try);
526 static int panel_edp_prepare(struct drm_panel *panel)
528 struct panel_edp *p = to_panel_edp(panel);
531 /* Preparing when already prepared is a no-op */
535 ret = pm_runtime_get_sync(panel->dev);
537 pm_runtime_put_autosuspend(panel->dev);
546 static int panel_edp_enable(struct drm_panel *panel)
548 struct panel_edp *p = to_panel_edp(panel);
554 delay = p->desc->delay.enable;
557 * If there is a "prepare_to_enable" delay then that's supposed to be
558 * the delay from HPD going high until we can turn the backlight on.
559 * However, we can only count this if HPD is readable by the panel
562 * If we aren't handling the HPD pin ourselves then the best we
563 * can do is assume that HPD went high immediately before we were
564 * called (and link training took zero time). Note that "no-hpd"
565 * actually counts as handling HPD ourselves since we're doing the
566 * worst case delay (in prepare) ourselves.
568 * NOTE: if we ever end up in this "if" statement then we're
569 * guaranteed that the panel_edp_wait() call below will do no delay.
570 * It already handles that case, though, so we don't need any special
573 if (p->desc->delay.prepare_to_enable &&
574 !panel_edp_can_read_hpd(p) && !p->no_hpd)
575 delay = max(delay, p->desc->delay.prepare_to_enable);
580 panel_edp_wait(p->prepared_time, p->desc->delay.prepare_to_enable);
587 static int panel_edp_get_modes(struct drm_panel *panel,
588 struct drm_connector *connector)
590 struct panel_edp *p = to_panel_edp(panel);
592 bool has_override_edid_mode = p->detected_panel &&
593 p->detected_panel != ERR_PTR(-EINVAL) &&
594 p->detected_panel->override_edid_mode;
596 /* probe EDID if a DDC bus is available */
598 pm_runtime_get_sync(panel->dev);
601 p->edid = drm_get_edid(connector, p->ddc);
603 if (has_override_edid_mode) {
605 * override_edid_mode is specified. Use
606 * override_edid_mode instead of from edid.
608 num += panel_edp_override_edid_mode(p, connector,
609 p->detected_panel->override_edid_mode);
611 num += drm_add_edid_modes(connector, p->edid);
615 pm_runtime_mark_last_busy(panel->dev);
616 pm_runtime_put_autosuspend(panel->dev);
620 * Add hard-coded panel modes. Don't call this if there are no timings
621 * and no modes (the generic edp-panel case) because it will clobber
622 * the display_info that was already set by drm_add_edid_modes().
624 if (p->desc->num_timings || p->desc->num_modes)
625 num += panel_edp_get_non_edid_modes(p, connector);
627 dev_warn(p->base.dev, "No display modes\n");
630 * TODO: Remove once all drm drivers call
631 * drm_connector_set_orientation_from_panel()
633 drm_connector_set_panel_orientation(connector, p->orientation);
638 static int panel_edp_get_timings(struct drm_panel *panel,
639 unsigned int num_timings,
640 struct display_timing *timings)
642 struct panel_edp *p = to_panel_edp(panel);
645 if (p->desc->num_timings < num_timings)
646 num_timings = p->desc->num_timings;
649 for (i = 0; i < num_timings; i++)
650 timings[i] = p->desc->timings[i];
652 return p->desc->num_timings;
655 static enum drm_panel_orientation panel_edp_get_orientation(struct drm_panel *panel)
657 struct panel_edp *p = to_panel_edp(panel);
659 return p->orientation;
662 static int detected_panel_show(struct seq_file *s, void *data)
664 struct drm_panel *panel = s->private;
665 struct panel_edp *p = to_panel_edp(panel);
667 if (IS_ERR(p->detected_panel))
668 seq_puts(s, "UNKNOWN\n");
669 else if (!p->detected_panel)
670 seq_puts(s, "HARDCODED\n");
672 seq_printf(s, "%s\n", p->detected_panel->name);
677 DEFINE_SHOW_ATTRIBUTE(detected_panel);
679 static void panel_edp_debugfs_init(struct drm_panel *panel, struct dentry *root)
681 debugfs_create_file("detected_panel", 0600, root, panel, &detected_panel_fops);
684 static const struct drm_panel_funcs panel_edp_funcs = {
685 .disable = panel_edp_disable,
686 .unprepare = panel_edp_unprepare,
687 .prepare = panel_edp_prepare,
688 .enable = panel_edp_enable,
689 .get_modes = panel_edp_get_modes,
690 .get_orientation = panel_edp_get_orientation,
691 .get_timings = panel_edp_get_timings,
692 .debugfs_init = panel_edp_debugfs_init,
695 #define PANEL_EDP_BOUNDS_CHECK(to_check, bounds, field) \
696 (to_check->field.typ >= bounds->field.min && \
697 to_check->field.typ <= bounds->field.max)
698 static void panel_edp_parse_panel_timing_node(struct device *dev,
699 struct panel_edp *panel,
700 const struct display_timing *ot)
702 const struct panel_desc *desc = panel->desc;
706 if (WARN_ON(desc->num_modes)) {
707 dev_err(dev, "Reject override mode: panel has a fixed mode\n");
710 if (WARN_ON(!desc->num_timings)) {
711 dev_err(dev, "Reject override mode: no timings specified\n");
715 for (i = 0; i < panel->desc->num_timings; i++) {
716 const struct display_timing *dt = &panel->desc->timings[i];
718 if (!PANEL_EDP_BOUNDS_CHECK(ot, dt, hactive) ||
719 !PANEL_EDP_BOUNDS_CHECK(ot, dt, hfront_porch) ||
720 !PANEL_EDP_BOUNDS_CHECK(ot, dt, hback_porch) ||
721 !PANEL_EDP_BOUNDS_CHECK(ot, dt, hsync_len) ||
722 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vactive) ||
723 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vfront_porch) ||
724 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vback_porch) ||
725 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vsync_len))
728 if (ot->flags != dt->flags)
731 videomode_from_timing(ot, &vm);
732 drm_display_mode_from_videomode(&vm, &panel->override_mode);
733 panel->override_mode.type |= DRM_MODE_TYPE_DRIVER |
734 DRM_MODE_TYPE_PREFERRED;
738 if (WARN_ON(!panel->override_mode.type))
739 dev_err(dev, "Reject override mode: No display_timing found\n");
742 static const struct edp_panel_entry *find_edp_panel(u32 panel_id);
744 static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel)
746 struct panel_desc *desc;
754 desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
760 * Read the dts properties for the initial probe. These are used by
761 * the runtime resume code which will get called by the
762 * pm_runtime_get_sync() call below.
764 of_property_read_u32(dev->of_node, "hpd-reliable-delay-ms", &reliable_ms);
765 desc->delay.hpd_reliable = reliable_ms;
766 of_property_read_u32(dev->of_node, "hpd-absent-delay-ms", &absent_ms);
767 desc->delay.hpd_absent = absent_ms;
769 /* Power the panel on so we can read the EDID */
770 ret = pm_runtime_get_sync(dev);
772 dev_err(dev, "Couldn't power on panel to read EDID: %d\n", ret);
776 panel_id = drm_edid_get_panel_id(panel->ddc);
778 dev_err(dev, "Couldn't identify panel via EDID\n");
782 drm_edid_decode_panel_id(panel_id, vend, &product_id);
784 panel->detected_panel = find_edp_panel(panel_id);
787 * We're using non-optimized timings and want it really obvious that
788 * someone needs to add an entry to the table, so we'll do a WARN_ON
791 if (WARN_ON(!panel->detected_panel)) {
793 "Unknown panel %s %#06x, using conservative timings\n",
797 * It's highly likely that the panel will work if we use very
798 * conservative timings, so let's do that. We already know that
799 * the HPD-related delays must have worked since we got this
800 * far, so we really just need the "unprepare" / "enable"
801 * delays. We don't need "prepare_to_enable" since that
802 * overlaps the "enable" delay anyway.
804 * Nearly all panels have a "unprepare" delay of 500 ms though
805 * there are a few with 1000. Let's stick 2000 in just to be
806 * super conservative.
808 * An "enable" delay of 80 ms seems the most common, but we'll
809 * throw in 200 ms to be safe.
811 desc->delay.unprepare = 2000;
812 desc->delay.enable = 200;
814 panel->detected_panel = ERR_PTR(-EINVAL);
816 dev_info(dev, "Detected %s %s (%#06x)\n",
817 vend, panel->detected_panel->name, product_id);
819 /* Update the delay; everything else comes from EDID */
820 desc->delay = *panel->detected_panel->delay;
825 pm_runtime_mark_last_busy(dev);
826 pm_runtime_put_autosuspend(dev);
831 static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,
832 struct drm_dp_aux *aux)
834 struct panel_edp *panel;
835 struct display_timing dt;
836 struct device_node *ddc;
839 panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
843 panel->enabled = false;
844 panel->prepared_time = 0;
848 panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");
849 if (!panel->no_hpd) {
850 err = panel_edp_get_hpd_gpio(dev, panel);
855 panel->supply = devm_regulator_get(dev, "power");
856 if (IS_ERR(panel->supply))
857 return PTR_ERR(panel->supply);
859 panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
861 if (IS_ERR(panel->enable_gpio))
862 return dev_err_probe(dev, PTR_ERR(panel->enable_gpio),
863 "failed to request GPIO\n");
865 err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
867 dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err);
871 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
873 panel->ddc = of_find_i2c_adapter_by_node(ddc);
877 return -EPROBE_DEFER;
879 panel->ddc = &aux->ddc;
882 if (!of_get_display_timing(dev->of_node, "panel-timing", &dt))
883 panel_edp_parse_panel_timing_node(dev, panel, &dt);
885 dev_set_drvdata(dev, panel);
887 drm_panel_init(&panel->base, dev, &panel_edp_funcs, DRM_MODE_CONNECTOR_eDP);
889 err = drm_panel_of_backlight(&panel->base);
891 goto err_finished_ddc_init;
894 * We use runtime PM for prepare / unprepare since those power the panel
895 * on and off and those can be very slow operations. This is important
896 * to optimize powering the panel on briefly to read the EDID before
897 * fully enabling the panel.
899 pm_runtime_enable(dev);
900 pm_runtime_set_autosuspend_delay(dev, 1000);
901 pm_runtime_use_autosuspend(dev);
903 if (of_device_is_compatible(dev->of_node, "edp-panel")) {
904 err = generic_edp_panel_probe(dev, panel);
906 dev_err_probe(dev, err,
907 "Couldn't detect panel nor find a fallback\n");
908 goto err_finished_pm_runtime;
910 /* generic_edp_panel_probe() replaces desc in the panel */
912 } else if (desc->bpc != 6 && desc->bpc != 8 && desc->bpc != 10) {
913 dev_warn(dev, "Expected bpc in {6,8,10} but got: %u\n", desc->bpc);
916 if (!panel->base.backlight && panel->aux) {
917 pm_runtime_get_sync(dev);
918 err = drm_panel_dp_aux_backlight(&panel->base, panel->aux);
919 pm_runtime_mark_last_busy(dev);
920 pm_runtime_put_autosuspend(dev);
922 goto err_finished_pm_runtime;
925 drm_panel_add(&panel->base);
929 err_finished_pm_runtime:
930 pm_runtime_dont_use_autosuspend(dev);
931 pm_runtime_disable(dev);
932 err_finished_ddc_init:
933 if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc))
934 put_device(&panel->ddc->dev);
939 static void panel_edp_remove(struct device *dev)
941 struct panel_edp *panel = dev_get_drvdata(dev);
943 drm_panel_remove(&panel->base);
944 drm_panel_disable(&panel->base);
945 drm_panel_unprepare(&panel->base);
947 pm_runtime_dont_use_autosuspend(dev);
948 pm_runtime_disable(dev);
949 if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc))
950 put_device(&panel->ddc->dev);
956 static void panel_edp_shutdown(struct device *dev)
958 struct panel_edp *panel = dev_get_drvdata(dev);
960 drm_panel_disable(&panel->base);
961 drm_panel_unprepare(&panel->base);
964 static const struct display_timing auo_b101ean01_timing = {
965 .pixelclock = { 65300000, 72500000, 75000000 },
966 .hactive = { 1280, 1280, 1280 },
967 .hfront_porch = { 18, 119, 119 },
968 .hback_porch = { 21, 21, 21 },
969 .hsync_len = { 32, 32, 32 },
970 .vactive = { 800, 800, 800 },
971 .vfront_porch = { 4, 4, 4 },
972 .vback_porch = { 8, 8, 8 },
973 .vsync_len = { 18, 20, 20 },
976 static const struct panel_desc auo_b101ean01 = {
977 .timings = &auo_b101ean01_timing,
986 static const struct drm_display_mode auo_b116xak01_mode = {
989 .hsync_start = 1366 + 48,
990 .hsync_end = 1366 + 48 + 32,
991 .htotal = 1366 + 48 + 32 + 10,
993 .vsync_start = 768 + 4,
994 .vsync_end = 768 + 4 + 6,
995 .vtotal = 768 + 4 + 6 + 15,
996 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
999 static const struct panel_desc auo_b116xak01 = {
1000 .modes = &auo_b116xak01_mode,
1014 static const struct drm_display_mode auo_b133han05_mode = {
1017 .hsync_start = 1920 + 58,
1018 .hsync_end = 1920 + 58 + 42,
1019 .htotal = 1920 + 58 + 42 + 60,
1021 .vsync_start = 1080 + 3,
1022 .vsync_end = 1080 + 3 + 5,
1023 .vtotal = 1080 + 3 + 5 + 54,
1026 static const struct panel_desc auo_b133han05 = {
1027 .modes = &auo_b133han05_mode,
1035 .hpd_reliable = 100,
1041 static const struct drm_display_mode auo_b133htn01_mode = {
1044 .hsync_start = 1920 + 172,
1045 .hsync_end = 1920 + 172 + 80,
1046 .htotal = 1920 + 172 + 80 + 60,
1048 .vsync_start = 1080 + 25,
1049 .vsync_end = 1080 + 25 + 10,
1050 .vtotal = 1080 + 25 + 10 + 10,
1053 static const struct panel_desc auo_b133htn01 = {
1054 .modes = &auo_b133htn01_mode,
1062 .hpd_reliable = 105,
1068 static const struct drm_display_mode auo_b133xtn01_mode = {
1071 .hsync_start = 1366 + 48,
1072 .hsync_end = 1366 + 48 + 32,
1073 .htotal = 1366 + 48 + 32 + 20,
1075 .vsync_start = 768 + 3,
1076 .vsync_end = 768 + 3 + 6,
1077 .vtotal = 768 + 3 + 6 + 13,
1080 static const struct panel_desc auo_b133xtn01 = {
1081 .modes = &auo_b133xtn01_mode,
1090 static const struct drm_display_mode auo_b140han06_mode = {
1093 .hsync_start = 1920 + 16,
1094 .hsync_end = 1920 + 16 + 16,
1095 .htotal = 1920 + 16 + 16 + 152,
1097 .vsync_start = 1080 + 3,
1098 .vsync_end = 1080 + 3 + 14,
1099 .vtotal = 1080 + 3 + 14 + 19,
1102 static const struct panel_desc auo_b140han06 = {
1103 .modes = &auo_b140han06_mode,
1111 .hpd_reliable = 100,
1117 static const struct drm_display_mode boe_nv101wxmn51_modes[] = {
1121 .hsync_start = 1280 + 48,
1122 .hsync_end = 1280 + 48 + 32,
1123 .htotal = 1280 + 48 + 32 + 80,
1125 .vsync_start = 800 + 3,
1126 .vsync_end = 800 + 3 + 5,
1127 .vtotal = 800 + 3 + 5 + 24,
1132 .hsync_start = 1280 + 48,
1133 .hsync_end = 1280 + 48 + 32,
1134 .htotal = 1280 + 48 + 32 + 80,
1136 .vsync_start = 800 + 3,
1137 .vsync_end = 800 + 3 + 5,
1138 .vtotal = 800 + 3 + 5 + 24,
1142 static const struct panel_desc boe_nv101wxmn51 = {
1143 .modes = boe_nv101wxmn51_modes,
1144 .num_modes = ARRAY_SIZE(boe_nv101wxmn51_modes),
1151 /* TODO: should be hpd-absent and no-hpd should be set? */
1152 .hpd_reliable = 210,
1158 static const struct drm_display_mode boe_nv110wtm_n61_modes[] = {
1162 .hsync_start = 2160 + 48,
1163 .hsync_end = 2160 + 48 + 32,
1164 .htotal = 2160 + 48 + 32 + 100,
1166 .vsync_start = 1440 + 3,
1167 .vsync_end = 1440 + 3 + 6,
1168 .vtotal = 1440 + 3 + 6 + 31,
1169 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
1174 .hsync_start = 2160 + 48,
1175 .hsync_end = 2160 + 48 + 32,
1176 .htotal = 2160 + 48 + 32 + 100,
1178 .vsync_start = 1440 + 3,
1179 .vsync_end = 1440 + 3 + 6,
1180 .vtotal = 1440 + 3 + 6 + 31,
1181 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
1185 static const struct panel_desc boe_nv110wtm_n61 = {
1186 .modes = boe_nv110wtm_n61_modes,
1187 .num_modes = ARRAY_SIZE(boe_nv110wtm_n61_modes),
1195 .prepare_to_enable = 80,
1201 /* Also used for boe_nv133fhm_n62 */
1202 static const struct drm_display_mode boe_nv133fhm_n61_modes = {
1205 .hsync_start = 1920 + 48,
1206 .hsync_end = 1920 + 48 + 32,
1207 .htotal = 1920 + 48 + 32 + 200,
1209 .vsync_start = 1080 + 3,
1210 .vsync_end = 1080 + 3 + 6,
1211 .vtotal = 1080 + 3 + 6 + 31,
1212 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
1215 /* Also used for boe_nv133fhm_n62 */
1216 static const struct panel_desc boe_nv133fhm_n61 = {
1217 .modes = &boe_nv133fhm_n61_modes,
1226 * When power is first given to the panel there's a short
1227 * spike on the HPD line. It was explained that this spike
1228 * was until the TCON data download was complete. On
1229 * one system this was measured at 8 ms. We'll put 15 ms
1230 * in the prepare delay just to be safe. That means:
1231 * - If HPD isn't hooked up you still have 200 ms delay.
1232 * - If HPD is hooked up we won't try to look at it for the
1242 static const struct drm_display_mode boe_nv140fhmn49_modes[] = {
1246 .hsync_start = 1920 + 48,
1247 .hsync_end = 1920 + 48 + 32,
1250 .vsync_start = 1080 + 3,
1251 .vsync_end = 1080 + 3 + 5,
1256 static const struct panel_desc boe_nv140fhmn49 = {
1257 .modes = boe_nv140fhmn49_modes,
1258 .num_modes = ARRAY_SIZE(boe_nv140fhmn49_modes),
1265 /* TODO: should be hpd-absent and no-hpd should be set? */
1266 .hpd_reliable = 210,
1272 static const struct drm_display_mode innolux_n116bca_ea1_mode = {
1275 .hsync_start = 1366 + 136,
1276 .hsync_end = 1366 + 136 + 30,
1277 .htotal = 1366 + 136 + 30 + 60,
1279 .vsync_start = 768 + 8,
1280 .vsync_end = 768 + 8 + 12,
1281 .vtotal = 768 + 8 + 12 + 12,
1282 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
1285 static const struct panel_desc innolux_n116bca_ea1 = {
1286 .modes = &innolux_n116bca_ea1_mode,
1302 * Datasheet specifies that at 60 Hz refresh rate:
1303 * - total horizontal time: { 1506, 1592, 1716 }
1304 * - total vertical time: { 788, 800, 868 }
1306 * ...but doesn't go into exactly how that should be split into a front
1307 * porch, back porch, or sync length. For now we'll leave a single setting
1308 * here which allows a bit of tweaking of the pixel clock at the expense of
1311 static const struct display_timing innolux_n116bge_timing = {
1312 .pixelclock = { 72600000, 76420000, 80240000 },
1313 .hactive = { 1366, 1366, 1366 },
1314 .hfront_porch = { 136, 136, 136 },
1315 .hback_porch = { 60, 60, 60 },
1316 .hsync_len = { 30, 30, 30 },
1317 .vactive = { 768, 768, 768 },
1318 .vfront_porch = { 8, 8, 8 },
1319 .vback_porch = { 12, 12, 12 },
1320 .vsync_len = { 12, 12, 12 },
1321 .flags = DISPLAY_FLAGS_VSYNC_LOW | DISPLAY_FLAGS_HSYNC_LOW,
1324 static const struct panel_desc innolux_n116bge = {
1325 .timings = &innolux_n116bge_timing,
1334 static const struct drm_display_mode innolux_n125hce_gn1_mode = {
1337 .hsync_start = 1920 + 40,
1338 .hsync_end = 1920 + 40 + 40,
1339 .htotal = 1920 + 40 + 40 + 80,
1341 .vsync_start = 1080 + 4,
1342 .vsync_end = 1080 + 4 + 4,
1343 .vtotal = 1080 + 4 + 4 + 24,
1346 static const struct panel_desc innolux_n125hce_gn1 = {
1347 .modes = &innolux_n125hce_gn1_mode,
1356 static const struct drm_display_mode innolux_p120zdg_bf1_mode = {
1359 .hsync_start = 2160 + 48,
1360 .hsync_end = 2160 + 48 + 32,
1361 .htotal = 2160 + 48 + 32 + 80,
1363 .vsync_start = 1440 + 3,
1364 .vsync_end = 1440 + 3 + 10,
1365 .vtotal = 1440 + 3 + 10 + 27,
1366 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
1369 static const struct panel_desc innolux_p120zdg_bf1 = {
1370 .modes = &innolux_p120zdg_bf1_mode,
1383 static const struct drm_display_mode ivo_m133nwf4_r0_mode = {
1386 .hsync_start = 1920 + 24,
1387 .hsync_end = 1920 + 24 + 48,
1388 .htotal = 1920 + 24 + 48 + 88,
1390 .vsync_start = 1080 + 3,
1391 .vsync_end = 1080 + 3 + 12,
1392 .vtotal = 1080 + 3 + 12 + 17,
1393 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
1396 static const struct panel_desc ivo_m133nwf4_r0 = {
1397 .modes = &ivo_m133nwf4_r0_mode,
1410 static const struct drm_display_mode kingdisplay_kd116n21_30nv_a010_mode = {
1413 .hsync_start = 1366 + 40,
1414 .hsync_end = 1366 + 40 + 32,
1415 .htotal = 1366 + 40 + 32 + 62,
1417 .vsync_start = 768 + 5,
1418 .vsync_end = 768 + 5 + 5,
1419 .vtotal = 768 + 5 + 5 + 122,
1420 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1423 static const struct panel_desc kingdisplay_kd116n21_30nv_a010 = {
1424 .modes = &kingdisplay_kd116n21_30nv_a010_mode,
1436 static const struct drm_display_mode lg_lp079qx1_sp0v_mode = {
1439 .hsync_start = 1536 + 12,
1440 .hsync_end = 1536 + 12 + 16,
1441 .htotal = 1536 + 12 + 16 + 48,
1443 .vsync_start = 2048 + 8,
1444 .vsync_end = 2048 + 8 + 4,
1445 .vtotal = 2048 + 8 + 4 + 8,
1446 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1449 static const struct panel_desc lg_lp079qx1_sp0v = {
1450 .modes = &lg_lp079qx1_sp0v_mode,
1458 static const struct drm_display_mode lg_lp097qx1_spa1_mode = {
1461 .hsync_start = 2048 + 150,
1462 .hsync_end = 2048 + 150 + 5,
1463 .htotal = 2048 + 150 + 5 + 5,
1465 .vsync_start = 1536 + 3,
1466 .vsync_end = 1536 + 3 + 1,
1467 .vtotal = 1536 + 3 + 1 + 9,
1470 static const struct panel_desc lg_lp097qx1_spa1 = {
1471 .modes = &lg_lp097qx1_spa1_mode,
1479 static const struct drm_display_mode lg_lp120up1_mode = {
1482 .hsync_start = 1920 + 40,
1483 .hsync_end = 1920 + 40 + 40,
1484 .htotal = 1920 + 40 + 40 + 80,
1486 .vsync_start = 1280 + 4,
1487 .vsync_end = 1280 + 4 + 4,
1488 .vtotal = 1280 + 4 + 4 + 12,
1491 static const struct panel_desc lg_lp120up1 = {
1492 .modes = &lg_lp120up1_mode,
1501 static const struct drm_display_mode lg_lp129qe_mode = {
1504 .hsync_start = 2560 + 48,
1505 .hsync_end = 2560 + 48 + 32,
1506 .htotal = 2560 + 48 + 32 + 80,
1508 .vsync_start = 1700 + 3,
1509 .vsync_end = 1700 + 3 + 10,
1510 .vtotal = 1700 + 3 + 10 + 36,
1513 static const struct panel_desc lg_lp129qe = {
1514 .modes = &lg_lp129qe_mode,
1523 static const struct drm_display_mode neweast_wjfh116008a_modes[] = {
1527 .hsync_start = 1920 + 48,
1528 .hsync_end = 1920 + 48 + 32,
1529 .htotal = 1920 + 48 + 32 + 80,
1531 .vsync_start = 1080 + 3,
1532 .vsync_end = 1080 + 3 + 5,
1533 .vtotal = 1080 + 3 + 5 + 23,
1534 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1538 .hsync_start = 1920 + 48,
1539 .hsync_end = 1920 + 48 + 32,
1540 .htotal = 1920 + 48 + 32 + 80,
1542 .vsync_start = 1080 + 3,
1543 .vsync_end = 1080 + 3 + 5,
1544 .vtotal = 1080 + 3 + 5 + 23,
1545 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1549 static const struct panel_desc neweast_wjfh116008a = {
1550 .modes = neweast_wjfh116008a_modes,
1558 .hpd_reliable = 110,
1564 static const struct drm_display_mode samsung_lsn122dl01_c01_mode = {
1567 .hsync_start = 2560 + 48,
1568 .hsync_end = 2560 + 48 + 32,
1569 .htotal = 2560 + 48 + 32 + 80,
1571 .vsync_start = 1600 + 2,
1572 .vsync_end = 1600 + 2 + 5,
1573 .vtotal = 1600 + 2 + 5 + 57,
1576 static const struct panel_desc samsung_lsn122dl01_c01 = {
1577 .modes = &samsung_lsn122dl01_c01_mode,
1585 static const struct drm_display_mode samsung_ltn140at29_301_mode = {
1588 .hsync_start = 1366 + 64,
1589 .hsync_end = 1366 + 64 + 48,
1590 .htotal = 1366 + 64 + 48 + 128,
1592 .vsync_start = 768 + 2,
1593 .vsync_end = 768 + 2 + 5,
1594 .vtotal = 768 + 2 + 5 + 17,
1597 static const struct panel_desc samsung_ltn140at29_301 = {
1598 .modes = &samsung_ltn140at29_301_mode,
1607 static const struct drm_display_mode sharp_ld_d5116z01b_mode = {
1610 .hsync_start = 1920 + 48,
1611 .hsync_end = 1920 + 48 + 32,
1612 .htotal = 1920 + 48 + 32 + 80,
1614 .vsync_start = 1280 + 3,
1615 .vsync_end = 1280 + 3 + 10,
1616 .vtotal = 1280 + 3 + 10 + 57,
1617 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
1620 static const struct panel_desc sharp_ld_d5116z01b = {
1621 .modes = &sharp_ld_d5116z01b_mode,
1630 static const struct display_timing sharp_lq123p1jx31_timing = {
1631 .pixelclock = { 252750000, 252750000, 266604720 },
1632 .hactive = { 2400, 2400, 2400 },
1633 .hfront_porch = { 48, 48, 48 },
1634 .hback_porch = { 80, 80, 84 },
1635 .hsync_len = { 32, 32, 32 },
1636 .vactive = { 1600, 1600, 1600 },
1637 .vfront_porch = { 3, 3, 3 },
1638 .vback_porch = { 33, 33, 120 },
1639 .vsync_len = { 10, 10, 10 },
1640 .flags = DISPLAY_FLAGS_VSYNC_LOW | DISPLAY_FLAGS_HSYNC_LOW,
1643 static const struct panel_desc sharp_lq123p1jx31 = {
1644 .timings = &sharp_lq123p1jx31_timing,
1652 .hpd_reliable = 110,
1658 static const struct drm_display_mode sharp_lq140m1jw46_mode[] = {
1662 .hsync_start = 1920 + 48,
1663 .hsync_end = 1920 + 48 + 32,
1664 .htotal = 1920 + 48 + 32 + 80,
1666 .vsync_start = 1080 + 3,
1667 .vsync_end = 1080 + 3 + 5,
1668 .vtotal = 1080 + 3 + 5 + 69,
1669 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1673 .hsync_start = 1920 + 48,
1674 .hsync_end = 1920 + 48 + 32,
1675 .htotal = 1920 + 48 + 32 + 80,
1677 .vsync_start = 1080 + 3,
1678 .vsync_end = 1080 + 3 + 5,
1679 .vtotal = 1080 + 3 + 5 + 69,
1680 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1684 static const struct panel_desc sharp_lq140m1jw46 = {
1685 .modes = sharp_lq140m1jw46_mode,
1686 .num_modes = ARRAY_SIZE(sharp_lq140m1jw46_mode),
1699 static const struct drm_display_mode starry_kr122ea0sra_mode = {
1702 .hsync_start = 1920 + 16,
1703 .hsync_end = 1920 + 16 + 16,
1704 .htotal = 1920 + 16 + 16 + 32,
1706 .vsync_start = 1200 + 15,
1707 .vsync_end = 1200 + 15 + 2,
1708 .vtotal = 1200 + 15 + 2 + 18,
1709 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1712 static const struct panel_desc starry_kr122ea0sra = {
1713 .modes = &starry_kr122ea0sra_mode,
1720 /* TODO: should be hpd-absent and no-hpd should be set? */
1721 .hpd_reliable = 10 + 200,
1723 .unprepare = 10 + 500,
1727 static const struct of_device_id platform_of_match[] = {
1730 .compatible = "edp-panel",
1732 .compatible = "auo,b101ean01",
1733 .data = &auo_b101ean01,
1735 .compatible = "auo,b116xa01",
1736 .data = &auo_b116xak01,
1738 .compatible = "auo,b133han05",
1739 .data = &auo_b133han05,
1741 .compatible = "auo,b133htn01",
1742 .data = &auo_b133htn01,
1744 .compatible = "auo,b133xtn01",
1745 .data = &auo_b133xtn01,
1747 .compatible = "auo,b140han06",
1748 .data = &auo_b140han06,
1750 .compatible = "boe,nv101wxmn51",
1751 .data = &boe_nv101wxmn51,
1753 .compatible = "boe,nv110wtm-n61",
1754 .data = &boe_nv110wtm_n61,
1756 .compatible = "boe,nv133fhm-n61",
1757 .data = &boe_nv133fhm_n61,
1759 .compatible = "boe,nv133fhm-n62",
1760 .data = &boe_nv133fhm_n61,
1762 .compatible = "boe,nv140fhmn49",
1763 .data = &boe_nv140fhmn49,
1765 .compatible = "innolux,n116bca-ea1",
1766 .data = &innolux_n116bca_ea1,
1768 .compatible = "innolux,n116bge",
1769 .data = &innolux_n116bge,
1771 .compatible = "innolux,n125hce-gn1",
1772 .data = &innolux_n125hce_gn1,
1774 .compatible = "innolux,p120zdg-bf1",
1775 .data = &innolux_p120zdg_bf1,
1777 .compatible = "ivo,m133nwf4-r0",
1778 .data = &ivo_m133nwf4_r0,
1780 .compatible = "kingdisplay,kd116n21-30nv-a010",
1781 .data = &kingdisplay_kd116n21_30nv_a010,
1783 .compatible = "lg,lp079qx1-sp0v",
1784 .data = &lg_lp079qx1_sp0v,
1786 .compatible = "lg,lp097qx1-spa1",
1787 .data = &lg_lp097qx1_spa1,
1789 .compatible = "lg,lp120up1",
1790 .data = &lg_lp120up1,
1792 .compatible = "lg,lp129qe",
1793 .data = &lg_lp129qe,
1795 .compatible = "neweast,wjfh116008a",
1796 .data = &neweast_wjfh116008a,
1798 .compatible = "samsung,lsn122dl01-c01",
1799 .data = &samsung_lsn122dl01_c01,
1801 .compatible = "samsung,ltn140at29-301",
1802 .data = &samsung_ltn140at29_301,
1804 .compatible = "sharp,ld-d5116z01b",
1805 .data = &sharp_ld_d5116z01b,
1807 .compatible = "sharp,lq123p1jx31",
1808 .data = &sharp_lq123p1jx31,
1810 .compatible = "sharp,lq140m1jw46",
1811 .data = &sharp_lq140m1jw46,
1813 .compatible = "starry,kr122ea0sra",
1814 .data = &starry_kr122ea0sra,
1819 MODULE_DEVICE_TABLE(of, platform_of_match);
1821 static const struct panel_delay delay_200_500_p2e80 = {
1824 .prepare_to_enable = 80,
1827 static const struct panel_delay delay_200_500_p2e100 = {
1830 .prepare_to_enable = 100,
1833 static const struct panel_delay delay_200_500_e50 = {
1839 static const struct panel_delay delay_200_500_e80_d50 = {
1846 static const struct panel_delay delay_100_500_e200 = {
1852 static const struct panel_delay delay_200_500_e200 = {
1858 #define EDP_PANEL_ENTRY(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _delay, _name) \
1861 .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \
1866 #define EDP_PANEL_ENTRY2(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _delay, _name, _mode) \
1869 .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \
1872 .override_edid_mode = _mode \
1876 * This table is used to figure out power sequencing delays for panels that
1877 * are detected by EDID. Entries here may point to entries in the
1878 * platform_of_match table (if a panel is listed in both places).
1880 * Sort first by vendor, then by product ID.
1882 static const struct edp_panel_entry edp_panels[] = {
1883 EDP_PANEL_ENTRY('A', 'U', 'O', 0x1062, &delay_200_500_e50, "B120XAN01.0"),
1884 EDP_PANEL_ENTRY('A', 'U', 'O', 0x145c, &delay_200_500_e50, "B116XAB01.4"),
1885 EDP_PANEL_ENTRY('A', 'U', 'O', 0x1e9b, &delay_200_500_e50, "B133UAN02.1"),
1886 EDP_PANEL_ENTRY('A', 'U', 'O', 0x1ea5, &delay_200_500_e50, "B116XAK01.6"),
1887 EDP_PANEL_ENTRY('A', 'U', 'O', 0x235c, &delay_200_500_e50, "B116XTN02.3"),
1888 EDP_PANEL_ENTRY('A', 'U', 'O', 0x405c, &auo_b116xak01.delay, "B116XAK01.0"),
1889 EDP_PANEL_ENTRY('A', 'U', 'O', 0x582d, &delay_200_500_e50, "B133UAN01.0"),
1890 EDP_PANEL_ENTRY('A', 'U', 'O', 0x615c, &delay_200_500_e50, "B116XAN06.1"),
1891 EDP_PANEL_ENTRY('A', 'U', 'O', 0x8594, &delay_200_500_e50, "B133UAN01.0"),
1893 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0786, &delay_200_500_p2e80, "NV116WHM-T01"),
1894 EDP_PANEL_ENTRY('B', 'O', 'E', 0x07d1, &boe_nv133fhm_n61.delay, "NV133FHM-N61"),
1895 EDP_PANEL_ENTRY('B', 'O', 'E', 0x082d, &boe_nv133fhm_n61.delay, "NV133FHM-N62"),
1896 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09c3, &delay_200_500_e50, "NT116WHM-N21,836X2"),
1897 EDP_PANEL_ENTRY('B', 'O', 'E', 0x094b, &delay_200_500_e50, "NT116WHM-N21"),
1898 EDP_PANEL_ENTRY('B', 'O', 'E', 0x095f, &delay_200_500_e50, "NE135FBM-N41 v8.1"),
1899 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0979, &delay_200_500_e50, "NV116WHM-N49 V8.0"),
1900 EDP_PANEL_ENTRY('B', 'O', 'E', 0x098d, &boe_nv110wtm_n61.delay, "NV110WTM-N61"),
1901 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09dd, &delay_200_500_e50, "NT116WHM-N21"),
1902 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0a5d, &delay_200_500_e50, "NV116WHM-N45"),
1903 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0ac5, &delay_200_500_e50, "NV116WHM-N4C"),
1905 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1139, &delay_200_500_e80_d50, "N116BGE-EA2"),
1906 EDP_PANEL_ENTRY('C', 'M', 'N', 0x114c, &innolux_n116bca_ea1.delay, "N116BCA-EA1"),
1907 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1152, &delay_200_500_e80_d50, "N116BCN-EA1"),
1908 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1153, &delay_200_500_e80_d50, "N116BGE-EA2"),
1909 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1154, &delay_200_500_e80_d50, "N116BCA-EA2"),
1910 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1247, &delay_200_500_e80_d50, "N120ACA-EA1"),
1911 EDP_PANEL_ENTRY('C', 'M', 'N', 0x14d4, &delay_200_500_e80_d50, "N140HCA-EAC"),
1913 EDP_PANEL_ENTRY('I', 'V', 'O', 0x057d, &delay_200_500_e200, "R140NWF5 RH"),
1914 EDP_PANEL_ENTRY('I', 'V', 'O', 0x854a, &delay_200_500_p2e100, "M133NW4J"),
1915 EDP_PANEL_ENTRY('I', 'V', 'O', 0x854b, &delay_200_500_p2e100, "R133NW4K-R0"),
1917 EDP_PANEL_ENTRY('K', 'D', 'B', 0x0624, &kingdisplay_kd116n21_30nv_a010.delay, "116N21-30NV-A010"),
1918 EDP_PANEL_ENTRY('K', 'D', 'B', 0x1120, &delay_200_500_e80_d50, "116N29-30NK-C007"),
1920 EDP_PANEL_ENTRY('S', 'H', 'P', 0x1511, &delay_200_500_e50, "LQ140M1JW48"),
1921 EDP_PANEL_ENTRY('S', 'H', 'P', 0x1523, &sharp_lq140m1jw46.delay, "LQ140M1JW46"),
1922 EDP_PANEL_ENTRY('S', 'H', 'P', 0x154c, &delay_200_500_p2e100, "LQ116M1JW10"),
1924 EDP_PANEL_ENTRY('S', 'T', 'A', 0x0100, &delay_100_500_e200, "2081116HHD028001-51D"),
1929 static const struct edp_panel_entry *find_edp_panel(u32 panel_id)
1931 const struct edp_panel_entry *panel;
1936 for (panel = edp_panels; panel->panel_id; panel++)
1937 if (panel->panel_id == panel_id)
1943 static int panel_edp_platform_probe(struct platform_device *pdev)
1945 const struct of_device_id *id;
1947 /* Skip one since "edp-panel" is only supported on DP AUX bus */
1948 id = of_match_node(platform_of_match + 1, pdev->dev.of_node);
1952 return panel_edp_probe(&pdev->dev, id->data, NULL);
1955 static void panel_edp_platform_remove(struct platform_device *pdev)
1957 panel_edp_remove(&pdev->dev);
1960 static void panel_edp_platform_shutdown(struct platform_device *pdev)
1962 panel_edp_shutdown(&pdev->dev);
1965 static const struct dev_pm_ops panel_edp_pm_ops = {
1966 SET_RUNTIME_PM_OPS(panel_edp_suspend, panel_edp_resume, NULL)
1967 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
1968 pm_runtime_force_resume)
1971 static struct platform_driver panel_edp_platform_driver = {
1973 .name = "panel-edp",
1974 .of_match_table = platform_of_match,
1975 .pm = &panel_edp_pm_ops,
1977 .probe = panel_edp_platform_probe,
1978 .remove_new = panel_edp_platform_remove,
1979 .shutdown = panel_edp_platform_shutdown,
1982 static int panel_edp_dp_aux_ep_probe(struct dp_aux_ep_device *aux_ep)
1984 const struct of_device_id *id;
1986 id = of_match_node(platform_of_match, aux_ep->dev.of_node);
1990 return panel_edp_probe(&aux_ep->dev, id->data, aux_ep->aux);
1993 static void panel_edp_dp_aux_ep_remove(struct dp_aux_ep_device *aux_ep)
1995 panel_edp_remove(&aux_ep->dev);
1998 static void panel_edp_dp_aux_ep_shutdown(struct dp_aux_ep_device *aux_ep)
2000 panel_edp_shutdown(&aux_ep->dev);
2003 static struct dp_aux_ep_driver panel_edp_dp_aux_ep_driver = {
2005 .name = "panel-simple-dp-aux",
2006 .of_match_table = platform_of_match, /* Same as platform one! */
2007 .pm = &panel_edp_pm_ops,
2009 .probe = panel_edp_dp_aux_ep_probe,
2010 .remove = panel_edp_dp_aux_ep_remove,
2011 .shutdown = panel_edp_dp_aux_ep_shutdown,
2014 static int __init panel_edp_init(void)
2018 err = platform_driver_register(&panel_edp_platform_driver);
2022 err = dp_aux_dp_driver_register(&panel_edp_dp_aux_ep_driver);
2024 goto err_did_platform_register;
2028 err_did_platform_register:
2029 platform_driver_unregister(&panel_edp_platform_driver);
2033 module_init(panel_edp_init);
2035 static void __exit panel_edp_exit(void)
2037 dp_aux_dp_driver_unregister(&panel_edp_dp_aux_ep_driver);
2038 platform_driver_unregister(&panel_edp_platform_driver);
2040 module_exit(panel_edp_exit);
2042 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
2043 MODULE_DESCRIPTION("DRM Driver for Simple eDP Panels");
2044 MODULE_LICENSE("GPL and additional rights");