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 * @powered_on_to_enable: Time between panel powered on and enable.
76 * The minimum time, in milliseconds, that needs to have passed
77 * between when panel powered on and enable may begin.
79 * This is (T3+T4+T5+T6+T8)-min on eDP timing diagrams or after the
80 * power supply enabled until we can turn the backlight on and see
83 * This doesn't normally need to be set if timings are already met by
84 * prepare_to_enable or enable.
86 unsigned int powered_on_to_enable;
89 * @prepare_to_enable: Time between prepare and enable.
91 * The minimum time, in milliseconds, that needs to have passed
92 * between when prepare finished and enable may begin. If at
93 * enable time less time has passed since prepare finished,
94 * the driver waits for the remaining time.
96 * If a fixed enable delay is also specified, we'll start
97 * counting before delaying for the fixed delay.
99 * If a fixed prepare delay is also specified, we won't start
100 * counting until after the fixed delay. We can't overlap this
101 * fixed delay with the min time because the fixed delay
102 * doesn't happen at the end of the function if a HPD GPIO was
108 * // do fixed prepare delay
109 * // wait for HPD GPIO if applicable
110 * // start counting for prepare_to_enable
113 * // do fixed enable delay
114 * // enforce prepare_to_enable min time
116 * This is not specified in a standard way on eDP timing diagrams.
117 * It is effectively the time from HPD going high till you can
118 * turn on the backlight.
120 unsigned int prepare_to_enable;
123 * @enable: Time for the panel to display a valid frame.
125 * The time (in milliseconds) that it takes for the panel to
126 * display the first valid frame after starting to receive
129 * This is (T6-min + max(T7-max, T8-min)) on eDP timing diagrams or
130 * the delay after link training finishes until we can turn the
131 * backlight on and see valid data.
136 * @disable: Time for the panel to turn the display off.
138 * The time (in milliseconds) that it takes for the panel to
139 * turn the display off (no content is visible).
141 * This is T9-min (delay from backlight off to end of valid video
142 * data) on eDP timing diagrams. It is not common to set.
144 unsigned int disable;
147 * @unprepare: Time to power down completely.
149 * The time (in milliseconds) that it takes for the panel
150 * to power itself down completely.
152 * This time is used to prevent a future "prepare" from
153 * starting until at least this many milliseconds has passed.
154 * If at prepare time less time has passed since unprepare
155 * finished, the driver waits for the remaining time.
157 * This is T12-min on eDP timing diagrams.
159 unsigned int unprepare;
163 * struct panel_desc - Describes a simple panel.
167 * @modes: Pointer to array of fixed modes appropriate for this panel.
169 * If only one mode then this can just be the address of the mode.
170 * NOTE: cannot be used with "timings" and also if this is specified
171 * then you cannot override the mode in the device tree.
173 const struct drm_display_mode *modes;
175 /** @num_modes: Number of elements in modes array. */
176 unsigned int num_modes;
179 * @timings: Pointer to array of display timings
181 * NOTE: cannot be used with "modes" and also these will be used to
182 * validate a device tree override if one is present.
184 const struct display_timing *timings;
186 /** @num_timings: Number of elements in timings array. */
187 unsigned int num_timings;
189 /** @bpc: Bits per color. */
192 /** @size: Structure containing the physical size of this panel. */
195 * @size.width: Width (in mm) of the active display area.
200 * @size.height: Height (in mm) of the active display area.
205 /** @delay: Structure containing various delay values for this panel. */
206 struct panel_delay delay;
210 * struct edp_panel_entry - Maps panel ID to delay / panel name.
212 struct edp_panel_entry {
213 /** @panel_id: 32-bit ID for panel, encoded with drm_edid_encode_panel_id(). */
216 /** @delay: The power sequencing delays needed for this panel. */
217 const struct panel_delay *delay;
219 /** @name: Name of this panel (for printing to logs). */
222 /** @override_edid_mode: Override the mode obtained by edid. */
223 const struct drm_display_mode *override_edid_mode;
227 struct drm_panel base;
233 ktime_t prepared_time;
234 ktime_t powered_on_time;
235 ktime_t unprepared_time;
237 const struct panel_desc *desc;
239 struct regulator *supply;
240 struct i2c_adapter *ddc;
241 struct drm_dp_aux *aux;
243 struct gpio_desc *enable_gpio;
244 struct gpio_desc *hpd_gpio;
246 const struct edp_panel_entry *detected_panel;
250 struct drm_display_mode override_mode;
252 enum drm_panel_orientation orientation;
255 static inline struct panel_edp *to_panel_edp(struct drm_panel *panel)
257 return container_of(panel, struct panel_edp, base);
260 static unsigned int panel_edp_get_timings_modes(struct panel_edp *panel,
261 struct drm_connector *connector)
263 struct drm_display_mode *mode;
264 unsigned int i, num = 0;
266 for (i = 0; i < panel->desc->num_timings; i++) {
267 const struct display_timing *dt = &panel->desc->timings[i];
270 videomode_from_timing(dt, &vm);
271 mode = drm_mode_create(connector->dev);
273 dev_err(panel->base.dev, "failed to add mode %ux%u\n",
274 dt->hactive.typ, dt->vactive.typ);
278 drm_display_mode_from_videomode(&vm, mode);
280 mode->type |= DRM_MODE_TYPE_DRIVER;
282 if (panel->desc->num_timings == 1)
283 mode->type |= DRM_MODE_TYPE_PREFERRED;
285 drm_mode_probed_add(connector, mode);
292 static unsigned int panel_edp_get_display_modes(struct panel_edp *panel,
293 struct drm_connector *connector)
295 struct drm_display_mode *mode;
296 unsigned int i, num = 0;
298 for (i = 0; i < panel->desc->num_modes; i++) {
299 const struct drm_display_mode *m = &panel->desc->modes[i];
301 mode = drm_mode_duplicate(connector->dev, m);
303 dev_err(panel->base.dev, "failed to add mode %ux%u@%u\n",
304 m->hdisplay, m->vdisplay,
305 drm_mode_vrefresh(m));
309 mode->type |= DRM_MODE_TYPE_DRIVER;
311 if (panel->desc->num_modes == 1)
312 mode->type |= DRM_MODE_TYPE_PREFERRED;
314 drm_mode_set_name(mode);
316 drm_mode_probed_add(connector, mode);
323 static int panel_edp_override_edid_mode(struct panel_edp *panel,
324 struct drm_connector *connector,
325 const struct drm_display_mode *override_mode)
327 struct drm_display_mode *mode;
329 mode = drm_mode_duplicate(connector->dev, override_mode);
331 dev_err(panel->base.dev, "failed to add additional mode\n");
335 mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
336 drm_mode_set_name(mode);
337 drm_mode_probed_add(connector, mode);
341 static int panel_edp_get_non_edid_modes(struct panel_edp *panel,
342 struct drm_connector *connector)
344 struct drm_display_mode *mode;
345 bool has_override = panel->override_mode.type;
346 unsigned int num = 0;
352 mode = drm_mode_duplicate(connector->dev,
353 &panel->override_mode);
355 drm_mode_probed_add(connector, mode);
358 dev_err(panel->base.dev, "failed to add override mode\n");
362 /* Only add timings if override was not there or failed to validate */
363 if (num == 0 && panel->desc->num_timings)
364 num = panel_edp_get_timings_modes(panel, connector);
367 * Only add fixed modes if timings/override added no mode.
369 * We should only ever have either the display timings specified
370 * or a fixed mode. Anything else is rather bogus.
372 WARN_ON(panel->desc->num_timings && panel->desc->num_modes);
374 num = panel_edp_get_display_modes(panel, connector);
376 connector->display_info.bpc = panel->desc->bpc;
377 connector->display_info.width_mm = panel->desc->size.width;
378 connector->display_info.height_mm = panel->desc->size.height;
383 static void panel_edp_wait(ktime_t start_ktime, unsigned int min_ms)
385 ktime_t now_ktime, min_ktime;
390 min_ktime = ktime_add(start_ktime, ms_to_ktime(min_ms));
391 now_ktime = ktime_get_boottime();
393 if (ktime_before(now_ktime, min_ktime))
394 msleep(ktime_to_ms(ktime_sub(min_ktime, now_ktime)) + 1);
397 static int panel_edp_disable(struct drm_panel *panel)
399 struct panel_edp *p = to_panel_edp(panel);
404 if (p->desc->delay.disable)
405 msleep(p->desc->delay.disable);
412 static int panel_edp_suspend(struct device *dev)
414 struct panel_edp *p = dev_get_drvdata(dev);
416 drm_dp_dpcd_set_powered(p->aux, false);
417 gpiod_set_value_cansleep(p->enable_gpio, 0);
418 regulator_disable(p->supply);
419 p->unprepared_time = ktime_get_boottime();
424 static int panel_edp_unprepare(struct drm_panel *panel)
426 struct panel_edp *p = to_panel_edp(panel);
429 /* Unpreparing when already unprepared is a no-op */
433 ret = pm_runtime_put_sync_suspend(panel->dev);
441 static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p)
443 p->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN);
444 if (IS_ERR(p->hpd_gpio))
445 return dev_err_probe(dev, PTR_ERR(p->hpd_gpio),
446 "failed to get 'hpd' GPIO\n");
451 static bool panel_edp_can_read_hpd(struct panel_edp *p)
453 return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted));
456 static int panel_edp_prepare_once(struct panel_edp *p)
458 struct device *dev = p->base.dev;
462 unsigned long hpd_wait_us;
464 panel_edp_wait(p->unprepared_time, p->desc->delay.unprepare);
466 err = regulator_enable(p->supply);
468 dev_err(dev, "failed to enable supply: %d\n", err);
472 gpiod_set_value_cansleep(p->enable_gpio, 1);
473 drm_dp_dpcd_set_powered(p->aux, true);
475 p->powered_on_time = ktime_get_boottime();
477 delay = p->desc->delay.hpd_reliable;
479 delay = max(delay, p->desc->delay.hpd_absent);
483 if (panel_edp_can_read_hpd(p)) {
484 if (p->desc->delay.hpd_absent)
485 hpd_wait_us = p->desc->delay.hpd_absent * 1000UL;
487 hpd_wait_us = 2000000;
490 err = readx_poll_timeout(gpiod_get_value_cansleep,
491 p->hpd_gpio, hpd_asserted,
492 hpd_asserted, 1000, hpd_wait_us);
493 if (hpd_asserted < 0)
496 err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us);
500 if (err != -ETIMEDOUT)
502 "error waiting for hpd GPIO: %d\n", err);
507 p->prepared_time = ktime_get_boottime();
512 drm_dp_dpcd_set_powered(p->aux, false);
513 gpiod_set_value_cansleep(p->enable_gpio, 0);
514 regulator_disable(p->supply);
515 p->unprepared_time = ktime_get_boottime();
521 * Some panels simply don't always come up and need to be power cycled to
522 * work properly. We'll allow for a handful of retries.
524 #define MAX_PANEL_PREPARE_TRIES 5
526 static int panel_edp_resume(struct device *dev)
528 struct panel_edp *p = dev_get_drvdata(dev);
532 for (try = 0; try < MAX_PANEL_PREPARE_TRIES; try++) {
533 ret = panel_edp_prepare_once(p);
534 if (ret != -ETIMEDOUT)
538 if (ret == -ETIMEDOUT)
539 dev_err(dev, "Prepare timeout after %d tries\n", try);
541 dev_warn(dev, "Prepare needed %d retries\n", try);
546 static int panel_edp_prepare(struct drm_panel *panel)
548 struct panel_edp *p = to_panel_edp(panel);
551 /* Preparing when already prepared is a no-op */
555 ret = pm_runtime_get_sync(panel->dev);
557 pm_runtime_put_autosuspend(panel->dev);
566 static int panel_edp_enable(struct drm_panel *panel)
568 struct panel_edp *p = to_panel_edp(panel);
574 delay = p->desc->delay.enable;
577 * If there is a "prepare_to_enable" delay then that's supposed to be
578 * the delay from HPD going high until we can turn the backlight on.
579 * However, we can only count this if HPD is readable by the panel
582 * If we aren't handling the HPD pin ourselves then the best we
583 * can do is assume that HPD went high immediately before we were
584 * called (and link training took zero time). Note that "no-hpd"
585 * actually counts as handling HPD ourselves since we're doing the
586 * worst case delay (in prepare) ourselves.
588 * NOTE: if we ever end up in this "if" statement then we're
589 * guaranteed that the panel_edp_wait() call below will do no delay.
590 * It already handles that case, though, so we don't need any special
593 if (p->desc->delay.prepare_to_enable &&
594 !panel_edp_can_read_hpd(p) && !p->no_hpd)
595 delay = max(delay, p->desc->delay.prepare_to_enable);
600 panel_edp_wait(p->prepared_time, p->desc->delay.prepare_to_enable);
602 panel_edp_wait(p->powered_on_time, p->desc->delay.powered_on_to_enable);
609 static int panel_edp_get_modes(struct drm_panel *panel,
610 struct drm_connector *connector)
612 struct panel_edp *p = to_panel_edp(panel);
614 bool has_hard_coded_modes = p->desc->num_timings || p->desc->num_modes;
615 bool has_override_edid_mode = p->detected_panel &&
616 p->detected_panel != ERR_PTR(-EINVAL) &&
617 p->detected_panel->override_edid_mode;
619 /* probe EDID if a DDC bus is available */
621 pm_runtime_get_sync(panel->dev);
624 p->edid = drm_get_edid(connector, p->ddc);
626 * If both edid and hard-coded modes exists, skip edid modes to
627 * avoid multiple preferred modes.
629 if (p->edid && !has_hard_coded_modes) {
630 if (has_override_edid_mode) {
632 * override_edid_mode is specified. Use
633 * override_edid_mode instead of from edid.
635 num += panel_edp_override_edid_mode(p, connector,
636 p->detected_panel->override_edid_mode);
638 num += drm_add_edid_modes(connector, p->edid);
642 pm_runtime_mark_last_busy(panel->dev);
643 pm_runtime_put_autosuspend(panel->dev);
646 if (has_hard_coded_modes)
647 num += panel_edp_get_non_edid_modes(p, connector);
649 dev_warn(p->base.dev, "No display modes\n");
652 * TODO: Remove once all drm drivers call
653 * drm_connector_set_orientation_from_panel()
655 drm_connector_set_panel_orientation(connector, p->orientation);
660 static int panel_edp_get_timings(struct drm_panel *panel,
661 unsigned int num_timings,
662 struct display_timing *timings)
664 struct panel_edp *p = to_panel_edp(panel);
667 if (p->desc->num_timings < num_timings)
668 num_timings = p->desc->num_timings;
671 for (i = 0; i < num_timings; i++)
672 timings[i] = p->desc->timings[i];
674 return p->desc->num_timings;
677 static enum drm_panel_orientation panel_edp_get_orientation(struct drm_panel *panel)
679 struct panel_edp *p = to_panel_edp(panel);
681 return p->orientation;
684 static int detected_panel_show(struct seq_file *s, void *data)
686 struct drm_panel *panel = s->private;
687 struct panel_edp *p = to_panel_edp(panel);
689 if (IS_ERR(p->detected_panel))
690 seq_puts(s, "UNKNOWN\n");
691 else if (!p->detected_panel)
692 seq_puts(s, "HARDCODED\n");
694 seq_printf(s, "%s\n", p->detected_panel->name);
699 DEFINE_SHOW_ATTRIBUTE(detected_panel);
701 static void panel_edp_debugfs_init(struct drm_panel *panel, struct dentry *root)
703 debugfs_create_file("detected_panel", 0600, root, panel, &detected_panel_fops);
706 static const struct drm_panel_funcs panel_edp_funcs = {
707 .disable = panel_edp_disable,
708 .unprepare = panel_edp_unprepare,
709 .prepare = panel_edp_prepare,
710 .enable = panel_edp_enable,
711 .get_modes = panel_edp_get_modes,
712 .get_orientation = panel_edp_get_orientation,
713 .get_timings = panel_edp_get_timings,
714 .debugfs_init = panel_edp_debugfs_init,
717 #define PANEL_EDP_BOUNDS_CHECK(to_check, bounds, field) \
718 (to_check->field.typ >= bounds->field.min && \
719 to_check->field.typ <= bounds->field.max)
720 static void panel_edp_parse_panel_timing_node(struct device *dev,
721 struct panel_edp *panel,
722 const struct display_timing *ot)
724 const struct panel_desc *desc = panel->desc;
728 if (WARN_ON(desc->num_modes)) {
729 dev_err(dev, "Reject override mode: panel has a fixed mode\n");
732 if (WARN_ON(!desc->num_timings)) {
733 dev_err(dev, "Reject override mode: no timings specified\n");
737 for (i = 0; i < panel->desc->num_timings; i++) {
738 const struct display_timing *dt = &panel->desc->timings[i];
740 if (!PANEL_EDP_BOUNDS_CHECK(ot, dt, hactive) ||
741 !PANEL_EDP_BOUNDS_CHECK(ot, dt, hfront_porch) ||
742 !PANEL_EDP_BOUNDS_CHECK(ot, dt, hback_porch) ||
743 !PANEL_EDP_BOUNDS_CHECK(ot, dt, hsync_len) ||
744 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vactive) ||
745 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vfront_porch) ||
746 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vback_porch) ||
747 !PANEL_EDP_BOUNDS_CHECK(ot, dt, vsync_len))
750 if (ot->flags != dt->flags)
753 videomode_from_timing(ot, &vm);
754 drm_display_mode_from_videomode(&vm, &panel->override_mode);
755 panel->override_mode.type |= DRM_MODE_TYPE_DRIVER |
756 DRM_MODE_TYPE_PREFERRED;
760 if (WARN_ON(!panel->override_mode.type))
761 dev_err(dev, "Reject override mode: No display_timing found\n");
764 static const struct edp_panel_entry *find_edp_panel(u32 panel_id);
766 static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel)
768 struct panel_desc *desc;
776 desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
782 * Read the dts properties for the initial probe. These are used by
783 * the runtime resume code which will get called by the
784 * pm_runtime_get_sync() call below.
786 of_property_read_u32(dev->of_node, "hpd-reliable-delay-ms", &reliable_ms);
787 desc->delay.hpd_reliable = reliable_ms;
788 of_property_read_u32(dev->of_node, "hpd-absent-delay-ms", &absent_ms);
789 desc->delay.hpd_absent = absent_ms;
791 /* Power the panel on so we can read the EDID */
792 ret = pm_runtime_get_sync(dev);
794 dev_err(dev, "Couldn't power on panel to read EDID: %d\n", ret);
798 panel_id = drm_edid_get_panel_id(panel->ddc);
800 dev_err(dev, "Couldn't identify panel via EDID\n");
804 drm_edid_decode_panel_id(panel_id, vend, &product_id);
806 panel->detected_panel = find_edp_panel(panel_id);
809 * We're using non-optimized timings and want it really obvious that
810 * someone needs to add an entry to the table, so we'll do a WARN_ON
813 if (WARN_ON(!panel->detected_panel)) {
815 "Unknown panel %s %#06x, using conservative timings\n",
819 * It's highly likely that the panel will work if we use very
820 * conservative timings, so let's do that. We already know that
821 * the HPD-related delays must have worked since we got this
822 * far, so we really just need the "unprepare" / "enable"
823 * delays. We don't need "prepare_to_enable" since that
824 * overlaps the "enable" delay anyway.
826 * Nearly all panels have a "unprepare" delay of 500 ms though
827 * there are a few with 1000. Let's stick 2000 in just to be
828 * super conservative.
830 * An "enable" delay of 80 ms seems the most common, but we'll
831 * throw in 200 ms to be safe.
833 desc->delay.unprepare = 2000;
834 desc->delay.enable = 200;
836 panel->detected_panel = ERR_PTR(-EINVAL);
838 dev_info(dev, "Detected %s %s (%#06x)\n",
839 vend, panel->detected_panel->name, product_id);
841 /* Update the delay; everything else comes from EDID */
842 desc->delay = *panel->detected_panel->delay;
847 pm_runtime_mark_last_busy(dev);
848 pm_runtime_put_autosuspend(dev);
853 static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,
854 struct drm_dp_aux *aux)
856 struct panel_edp *panel;
857 struct display_timing dt;
858 struct device_node *ddc;
861 panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
865 panel->enabled = false;
866 panel->prepared_time = 0;
870 panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");
871 if (!panel->no_hpd) {
872 err = panel_edp_get_hpd_gpio(dev, panel);
877 panel->supply = devm_regulator_get(dev, "power");
878 if (IS_ERR(panel->supply))
879 return PTR_ERR(panel->supply);
881 panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
883 if (IS_ERR(panel->enable_gpio))
884 return dev_err_probe(dev, PTR_ERR(panel->enable_gpio),
885 "failed to request GPIO\n");
887 err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
889 dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err);
893 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
895 panel->ddc = of_find_i2c_adapter_by_node(ddc);
899 return -EPROBE_DEFER;
901 panel->ddc = &aux->ddc;
904 if (!of_get_display_timing(dev->of_node, "panel-timing", &dt))
905 panel_edp_parse_panel_timing_node(dev, panel, &dt);
907 dev_set_drvdata(dev, panel);
909 drm_panel_init(&panel->base, dev, &panel_edp_funcs, DRM_MODE_CONNECTOR_eDP);
911 err = drm_panel_of_backlight(&panel->base);
913 goto err_finished_ddc_init;
916 * We use runtime PM for prepare / unprepare since those power the panel
917 * on and off and those can be very slow operations. This is important
918 * to optimize powering the panel on briefly to read the EDID before
919 * fully enabling the panel.
921 pm_runtime_enable(dev);
922 pm_runtime_set_autosuspend_delay(dev, 1000);
923 pm_runtime_use_autosuspend(dev);
925 if (of_device_is_compatible(dev->of_node, "edp-panel")) {
926 err = generic_edp_panel_probe(dev, panel);
928 dev_err_probe(dev, err,
929 "Couldn't detect panel nor find a fallback\n");
930 goto err_finished_pm_runtime;
932 /* generic_edp_panel_probe() replaces desc in the panel */
934 } else if (desc->bpc != 6 && desc->bpc != 8 && desc->bpc != 10) {
935 dev_warn(dev, "Expected bpc in {6,8,10} but got: %u\n", desc->bpc);
938 if (!panel->base.backlight && panel->aux) {
939 pm_runtime_get_sync(dev);
940 err = drm_panel_dp_aux_backlight(&panel->base, panel->aux);
941 pm_runtime_mark_last_busy(dev);
942 pm_runtime_put_autosuspend(dev);
944 goto err_finished_pm_runtime;
947 drm_panel_add(&panel->base);
951 err_finished_pm_runtime:
952 pm_runtime_dont_use_autosuspend(dev);
953 pm_runtime_disable(dev);
954 err_finished_ddc_init:
955 if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc))
956 put_device(&panel->ddc->dev);
961 static void panel_edp_remove(struct device *dev)
963 struct panel_edp *panel = dev_get_drvdata(dev);
965 drm_panel_remove(&panel->base);
966 drm_panel_disable(&panel->base);
967 drm_panel_unprepare(&panel->base);
969 pm_runtime_dont_use_autosuspend(dev);
970 pm_runtime_disable(dev);
971 if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc))
972 put_device(&panel->ddc->dev);
978 static void panel_edp_shutdown(struct device *dev)
980 struct panel_edp *panel = dev_get_drvdata(dev);
982 drm_panel_disable(&panel->base);
983 drm_panel_unprepare(&panel->base);
986 static const struct display_timing auo_b101ean01_timing = {
987 .pixelclock = { 65300000, 72500000, 75000000 },
988 .hactive = { 1280, 1280, 1280 },
989 .hfront_porch = { 18, 119, 119 },
990 .hback_porch = { 21, 21, 21 },
991 .hsync_len = { 32, 32, 32 },
992 .vactive = { 800, 800, 800 },
993 .vfront_porch = { 4, 4, 4 },
994 .vback_porch = { 8, 8, 8 },
995 .vsync_len = { 18, 20, 20 },
998 static const struct panel_desc auo_b101ean01 = {
999 .timings = &auo_b101ean01_timing,
1008 static const struct drm_display_mode auo_b116xak01_mode = {
1011 .hsync_start = 1366 + 48,
1012 .hsync_end = 1366 + 48 + 32,
1013 .htotal = 1366 + 48 + 32 + 10,
1015 .vsync_start = 768 + 4,
1016 .vsync_end = 768 + 4 + 6,
1017 .vtotal = 768 + 4 + 6 + 15,
1018 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1021 static const struct panel_desc auo_b116xak01 = {
1022 .modes = &auo_b116xak01_mode,
1036 static const struct drm_display_mode auo_b133han05_mode = {
1039 .hsync_start = 1920 + 58,
1040 .hsync_end = 1920 + 58 + 42,
1041 .htotal = 1920 + 58 + 42 + 60,
1043 .vsync_start = 1080 + 3,
1044 .vsync_end = 1080 + 3 + 5,
1045 .vtotal = 1080 + 3 + 5 + 54,
1048 static const struct panel_desc auo_b133han05 = {
1049 .modes = &auo_b133han05_mode,
1057 .hpd_reliable = 100,
1063 static const struct drm_display_mode auo_b133htn01_mode = {
1066 .hsync_start = 1920 + 172,
1067 .hsync_end = 1920 + 172 + 80,
1068 .htotal = 1920 + 172 + 80 + 60,
1070 .vsync_start = 1080 + 25,
1071 .vsync_end = 1080 + 25 + 10,
1072 .vtotal = 1080 + 25 + 10 + 10,
1075 static const struct panel_desc auo_b133htn01 = {
1076 .modes = &auo_b133htn01_mode,
1084 .hpd_reliable = 105,
1090 static const struct drm_display_mode auo_b133xtn01_mode = {
1093 .hsync_start = 1366 + 48,
1094 .hsync_end = 1366 + 48 + 32,
1095 .htotal = 1366 + 48 + 32 + 20,
1097 .vsync_start = 768 + 3,
1098 .vsync_end = 768 + 3 + 6,
1099 .vtotal = 768 + 3 + 6 + 13,
1102 static const struct panel_desc auo_b133xtn01 = {
1103 .modes = &auo_b133xtn01_mode,
1112 static const struct drm_display_mode auo_b140han06_mode = {
1115 .hsync_start = 1920 + 16,
1116 .hsync_end = 1920 + 16 + 16,
1117 .htotal = 1920 + 16 + 16 + 152,
1119 .vsync_start = 1080 + 3,
1120 .vsync_end = 1080 + 3 + 14,
1121 .vtotal = 1080 + 3 + 14 + 19,
1124 static const struct panel_desc auo_b140han06 = {
1125 .modes = &auo_b140han06_mode,
1133 .hpd_reliable = 100,
1139 static const struct drm_display_mode boe_nv101wxmn51_modes[] = {
1143 .hsync_start = 1280 + 48,
1144 .hsync_end = 1280 + 48 + 32,
1145 .htotal = 1280 + 48 + 32 + 80,
1147 .vsync_start = 800 + 3,
1148 .vsync_end = 800 + 3 + 5,
1149 .vtotal = 800 + 3 + 5 + 24,
1154 .hsync_start = 1280 + 48,
1155 .hsync_end = 1280 + 48 + 32,
1156 .htotal = 1280 + 48 + 32 + 80,
1158 .vsync_start = 800 + 3,
1159 .vsync_end = 800 + 3 + 5,
1160 .vtotal = 800 + 3 + 5 + 24,
1164 static const struct panel_desc boe_nv101wxmn51 = {
1165 .modes = boe_nv101wxmn51_modes,
1166 .num_modes = ARRAY_SIZE(boe_nv101wxmn51_modes),
1173 /* TODO: should be hpd-absent and no-hpd should be set? */
1174 .hpd_reliable = 210,
1180 static const struct drm_display_mode boe_nv110wtm_n61_modes[] = {
1184 .hsync_start = 2160 + 48,
1185 .hsync_end = 2160 + 48 + 32,
1186 .htotal = 2160 + 48 + 32 + 100,
1188 .vsync_start = 1440 + 3,
1189 .vsync_end = 1440 + 3 + 6,
1190 .vtotal = 1440 + 3 + 6 + 31,
1191 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
1196 .hsync_start = 2160 + 48,
1197 .hsync_end = 2160 + 48 + 32,
1198 .htotal = 2160 + 48 + 32 + 100,
1200 .vsync_start = 1440 + 3,
1201 .vsync_end = 1440 + 3 + 6,
1202 .vtotal = 1440 + 3 + 6 + 31,
1203 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
1207 static const struct panel_desc boe_nv110wtm_n61 = {
1208 .modes = boe_nv110wtm_n61_modes,
1209 .num_modes = ARRAY_SIZE(boe_nv110wtm_n61_modes),
1217 .prepare_to_enable = 80,
1223 /* Also used for boe_nv133fhm_n62 */
1224 static const struct drm_display_mode boe_nv133fhm_n61_modes = {
1227 .hsync_start = 1920 + 48,
1228 .hsync_end = 1920 + 48 + 32,
1229 .htotal = 1920 + 48 + 32 + 200,
1231 .vsync_start = 1080 + 3,
1232 .vsync_end = 1080 + 3 + 6,
1233 .vtotal = 1080 + 3 + 6 + 31,
1234 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
1237 /* Also used for boe_nv133fhm_n62 */
1238 static const struct panel_desc boe_nv133fhm_n61 = {
1239 .modes = &boe_nv133fhm_n61_modes,
1248 * When power is first given to the panel there's a short
1249 * spike on the HPD line. It was explained that this spike
1250 * was until the TCON data download was complete. On
1251 * one system this was measured at 8 ms. We'll put 15 ms
1252 * in the prepare delay just to be safe. That means:
1253 * - If HPD isn't hooked up you still have 200 ms delay.
1254 * - If HPD is hooked up we won't try to look at it for the
1264 static const struct drm_display_mode boe_nv140fhmn49_modes[] = {
1268 .hsync_start = 1920 + 48,
1269 .hsync_end = 1920 + 48 + 32,
1272 .vsync_start = 1080 + 3,
1273 .vsync_end = 1080 + 3 + 5,
1278 static const struct panel_desc boe_nv140fhmn49 = {
1279 .modes = boe_nv140fhmn49_modes,
1280 .num_modes = ARRAY_SIZE(boe_nv140fhmn49_modes),
1287 /* TODO: should be hpd-absent and no-hpd should be set? */
1288 .hpd_reliable = 210,
1294 static const struct drm_display_mode innolux_n116bca_ea1_mode = {
1297 .hsync_start = 1366 + 136,
1298 .hsync_end = 1366 + 136 + 30,
1299 .htotal = 1366 + 136 + 30 + 60,
1301 .vsync_start = 768 + 8,
1302 .vsync_end = 768 + 8 + 12,
1303 .vtotal = 768 + 8 + 12 + 12,
1304 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
1307 static const struct panel_desc innolux_n116bca_ea1 = {
1308 .modes = &innolux_n116bca_ea1_mode,
1324 * Datasheet specifies that at 60 Hz refresh rate:
1325 * - total horizontal time: { 1506, 1592, 1716 }
1326 * - total vertical time: { 788, 800, 868 }
1328 * ...but doesn't go into exactly how that should be split into a front
1329 * porch, back porch, or sync length. For now we'll leave a single setting
1330 * here which allows a bit of tweaking of the pixel clock at the expense of
1333 static const struct display_timing innolux_n116bge_timing = {
1334 .pixelclock = { 72600000, 76420000, 80240000 },
1335 .hactive = { 1366, 1366, 1366 },
1336 .hfront_porch = { 136, 136, 136 },
1337 .hback_porch = { 60, 60, 60 },
1338 .hsync_len = { 30, 30, 30 },
1339 .vactive = { 768, 768, 768 },
1340 .vfront_porch = { 8, 8, 8 },
1341 .vback_porch = { 12, 12, 12 },
1342 .vsync_len = { 12, 12, 12 },
1343 .flags = DISPLAY_FLAGS_VSYNC_LOW | DISPLAY_FLAGS_HSYNC_LOW,
1346 static const struct panel_desc innolux_n116bge = {
1347 .timings = &innolux_n116bge_timing,
1356 static const struct drm_display_mode innolux_n125hce_gn1_mode = {
1359 .hsync_start = 1920 + 40,
1360 .hsync_end = 1920 + 40 + 40,
1361 .htotal = 1920 + 40 + 40 + 80,
1363 .vsync_start = 1080 + 4,
1364 .vsync_end = 1080 + 4 + 4,
1365 .vtotal = 1080 + 4 + 4 + 24,
1368 static const struct panel_desc innolux_n125hce_gn1 = {
1369 .modes = &innolux_n125hce_gn1_mode,
1378 static const struct drm_display_mode innolux_p120zdg_bf1_mode = {
1381 .hsync_start = 2160 + 48,
1382 .hsync_end = 2160 + 48 + 32,
1383 .htotal = 2160 + 48 + 32 + 80,
1385 .vsync_start = 1440 + 3,
1386 .vsync_end = 1440 + 3 + 10,
1387 .vtotal = 1440 + 3 + 10 + 27,
1388 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
1391 static const struct panel_desc innolux_p120zdg_bf1 = {
1392 .modes = &innolux_p120zdg_bf1_mode,
1405 static const struct drm_display_mode ivo_m133nwf4_r0_mode = {
1408 .hsync_start = 1920 + 24,
1409 .hsync_end = 1920 + 24 + 48,
1410 .htotal = 1920 + 24 + 48 + 88,
1412 .vsync_start = 1080 + 3,
1413 .vsync_end = 1080 + 3 + 12,
1414 .vtotal = 1080 + 3 + 12 + 17,
1415 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
1418 static const struct panel_desc ivo_m133nwf4_r0 = {
1419 .modes = &ivo_m133nwf4_r0_mode,
1432 static const struct drm_display_mode kingdisplay_kd116n21_30nv_a010_mode = {
1435 .hsync_start = 1366 + 40,
1436 .hsync_end = 1366 + 40 + 32,
1437 .htotal = 1366 + 40 + 32 + 62,
1439 .vsync_start = 768 + 5,
1440 .vsync_end = 768 + 5 + 5,
1441 .vtotal = 768 + 5 + 5 + 122,
1442 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1445 static const struct panel_desc kingdisplay_kd116n21_30nv_a010 = {
1446 .modes = &kingdisplay_kd116n21_30nv_a010_mode,
1458 static const struct drm_display_mode lg_lp079qx1_sp0v_mode = {
1461 .hsync_start = 1536 + 12,
1462 .hsync_end = 1536 + 12 + 16,
1463 .htotal = 1536 + 12 + 16 + 48,
1465 .vsync_start = 2048 + 8,
1466 .vsync_end = 2048 + 8 + 4,
1467 .vtotal = 2048 + 8 + 4 + 8,
1468 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1471 static const struct panel_desc lg_lp079qx1_sp0v = {
1472 .modes = &lg_lp079qx1_sp0v_mode,
1480 static const struct drm_display_mode lg_lp097qx1_spa1_mode = {
1483 .hsync_start = 2048 + 150,
1484 .hsync_end = 2048 + 150 + 5,
1485 .htotal = 2048 + 150 + 5 + 5,
1487 .vsync_start = 1536 + 3,
1488 .vsync_end = 1536 + 3 + 1,
1489 .vtotal = 1536 + 3 + 1 + 9,
1492 static const struct panel_desc lg_lp097qx1_spa1 = {
1493 .modes = &lg_lp097qx1_spa1_mode,
1501 static const struct drm_display_mode lg_lp120up1_mode = {
1504 .hsync_start = 1920 + 40,
1505 .hsync_end = 1920 + 40 + 40,
1506 .htotal = 1920 + 40 + 40 + 80,
1508 .vsync_start = 1280 + 4,
1509 .vsync_end = 1280 + 4 + 4,
1510 .vtotal = 1280 + 4 + 4 + 12,
1513 static const struct panel_desc lg_lp120up1 = {
1514 .modes = &lg_lp120up1_mode,
1523 static const struct drm_display_mode lg_lp129qe_mode = {
1526 .hsync_start = 2560 + 48,
1527 .hsync_end = 2560 + 48 + 32,
1528 .htotal = 2560 + 48 + 32 + 80,
1530 .vsync_start = 1700 + 3,
1531 .vsync_end = 1700 + 3 + 10,
1532 .vtotal = 1700 + 3 + 10 + 36,
1535 static const struct panel_desc lg_lp129qe = {
1536 .modes = &lg_lp129qe_mode,
1545 static const struct drm_display_mode neweast_wjfh116008a_modes[] = {
1549 .hsync_start = 1920 + 48,
1550 .hsync_end = 1920 + 48 + 32,
1551 .htotal = 1920 + 48 + 32 + 80,
1553 .vsync_start = 1080 + 3,
1554 .vsync_end = 1080 + 3 + 5,
1555 .vtotal = 1080 + 3 + 5 + 23,
1556 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1560 .hsync_start = 1920 + 48,
1561 .hsync_end = 1920 + 48 + 32,
1562 .htotal = 1920 + 48 + 32 + 80,
1564 .vsync_start = 1080 + 3,
1565 .vsync_end = 1080 + 3 + 5,
1566 .vtotal = 1080 + 3 + 5 + 23,
1567 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1571 static const struct panel_desc neweast_wjfh116008a = {
1572 .modes = neweast_wjfh116008a_modes,
1580 .hpd_reliable = 110,
1586 static const struct drm_display_mode samsung_lsn122dl01_c01_mode = {
1589 .hsync_start = 2560 + 48,
1590 .hsync_end = 2560 + 48 + 32,
1591 .htotal = 2560 + 48 + 32 + 80,
1593 .vsync_start = 1600 + 2,
1594 .vsync_end = 1600 + 2 + 5,
1595 .vtotal = 1600 + 2 + 5 + 57,
1598 static const struct panel_desc samsung_lsn122dl01_c01 = {
1599 .modes = &samsung_lsn122dl01_c01_mode,
1607 static const struct drm_display_mode samsung_ltn140at29_301_mode = {
1610 .hsync_start = 1366 + 64,
1611 .hsync_end = 1366 + 64 + 48,
1612 .htotal = 1366 + 64 + 48 + 128,
1614 .vsync_start = 768 + 2,
1615 .vsync_end = 768 + 2 + 5,
1616 .vtotal = 768 + 2 + 5 + 17,
1619 static const struct panel_desc samsung_ltn140at29_301 = {
1620 .modes = &samsung_ltn140at29_301_mode,
1629 static const struct drm_display_mode sharp_ld_d5116z01b_mode = {
1632 .hsync_start = 1920 + 48,
1633 .hsync_end = 1920 + 48 + 32,
1634 .htotal = 1920 + 48 + 32 + 80,
1636 .vsync_start = 1280 + 3,
1637 .vsync_end = 1280 + 3 + 10,
1638 .vtotal = 1280 + 3 + 10 + 57,
1639 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
1642 static const struct panel_desc sharp_ld_d5116z01b = {
1643 .modes = &sharp_ld_d5116z01b_mode,
1652 static const struct display_timing sharp_lq123p1jx31_timing = {
1653 .pixelclock = { 252750000, 252750000, 266604720 },
1654 .hactive = { 2400, 2400, 2400 },
1655 .hfront_porch = { 48, 48, 48 },
1656 .hback_porch = { 80, 80, 84 },
1657 .hsync_len = { 32, 32, 32 },
1658 .vactive = { 1600, 1600, 1600 },
1659 .vfront_porch = { 3, 3, 3 },
1660 .vback_porch = { 33, 33, 120 },
1661 .vsync_len = { 10, 10, 10 },
1662 .flags = DISPLAY_FLAGS_VSYNC_LOW | DISPLAY_FLAGS_HSYNC_LOW,
1665 static const struct panel_desc sharp_lq123p1jx31 = {
1666 .timings = &sharp_lq123p1jx31_timing,
1674 .hpd_reliable = 110,
1680 static const struct drm_display_mode sharp_lq140m1jw46_mode[] = {
1684 .hsync_start = 1920 + 48,
1685 .hsync_end = 1920 + 48 + 32,
1686 .htotal = 1920 + 48 + 32 + 80,
1688 .vsync_start = 1080 + 3,
1689 .vsync_end = 1080 + 3 + 5,
1690 .vtotal = 1080 + 3 + 5 + 69,
1691 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1695 .hsync_start = 1920 + 48,
1696 .hsync_end = 1920 + 48 + 32,
1697 .htotal = 1920 + 48 + 32 + 80,
1699 .vsync_start = 1080 + 3,
1700 .vsync_end = 1080 + 3 + 5,
1701 .vtotal = 1080 + 3 + 5 + 69,
1702 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1706 static const struct panel_desc sharp_lq140m1jw46 = {
1707 .modes = sharp_lq140m1jw46_mode,
1708 .num_modes = ARRAY_SIZE(sharp_lq140m1jw46_mode),
1721 static const struct drm_display_mode starry_kr122ea0sra_mode = {
1724 .hsync_start = 1920 + 16,
1725 .hsync_end = 1920 + 16 + 16,
1726 .htotal = 1920 + 16 + 16 + 32,
1728 .vsync_start = 1200 + 15,
1729 .vsync_end = 1200 + 15 + 2,
1730 .vtotal = 1200 + 15 + 2 + 18,
1731 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1734 static const struct panel_desc starry_kr122ea0sra = {
1735 .modes = &starry_kr122ea0sra_mode,
1742 /* TODO: should be hpd-absent and no-hpd should be set? */
1743 .hpd_reliable = 10 + 200,
1745 .unprepare = 10 + 500,
1749 static const struct of_device_id platform_of_match[] = {
1752 .compatible = "edp-panel",
1754 .compatible = "auo,b101ean01",
1755 .data = &auo_b101ean01,
1757 .compatible = "auo,b116xa01",
1758 .data = &auo_b116xak01,
1760 .compatible = "auo,b133han05",
1761 .data = &auo_b133han05,
1763 .compatible = "auo,b133htn01",
1764 .data = &auo_b133htn01,
1766 .compatible = "auo,b133xtn01",
1767 .data = &auo_b133xtn01,
1769 .compatible = "auo,b140han06",
1770 .data = &auo_b140han06,
1772 .compatible = "boe,nv101wxmn51",
1773 .data = &boe_nv101wxmn51,
1775 .compatible = "boe,nv110wtm-n61",
1776 .data = &boe_nv110wtm_n61,
1778 .compatible = "boe,nv133fhm-n61",
1779 .data = &boe_nv133fhm_n61,
1781 .compatible = "boe,nv133fhm-n62",
1782 .data = &boe_nv133fhm_n61,
1784 .compatible = "boe,nv140fhmn49",
1785 .data = &boe_nv140fhmn49,
1787 .compatible = "innolux,n116bca-ea1",
1788 .data = &innolux_n116bca_ea1,
1790 .compatible = "innolux,n116bge",
1791 .data = &innolux_n116bge,
1793 .compatible = "innolux,n125hce-gn1",
1794 .data = &innolux_n125hce_gn1,
1796 .compatible = "innolux,p120zdg-bf1",
1797 .data = &innolux_p120zdg_bf1,
1799 .compatible = "ivo,m133nwf4-r0",
1800 .data = &ivo_m133nwf4_r0,
1802 .compatible = "kingdisplay,kd116n21-30nv-a010",
1803 .data = &kingdisplay_kd116n21_30nv_a010,
1805 .compatible = "lg,lp079qx1-sp0v",
1806 .data = &lg_lp079qx1_sp0v,
1808 .compatible = "lg,lp097qx1-spa1",
1809 .data = &lg_lp097qx1_spa1,
1811 .compatible = "lg,lp120up1",
1812 .data = &lg_lp120up1,
1814 .compatible = "lg,lp129qe",
1815 .data = &lg_lp129qe,
1817 .compatible = "neweast,wjfh116008a",
1818 .data = &neweast_wjfh116008a,
1820 .compatible = "samsung,lsn122dl01-c01",
1821 .data = &samsung_lsn122dl01_c01,
1823 .compatible = "samsung,ltn140at29-301",
1824 .data = &samsung_ltn140at29_301,
1826 .compatible = "sharp,ld-d5116z01b",
1827 .data = &sharp_ld_d5116z01b,
1829 .compatible = "sharp,lq123p1jx31",
1830 .data = &sharp_lq123p1jx31,
1832 .compatible = "sharp,lq140m1jw46",
1833 .data = &sharp_lq140m1jw46,
1835 .compatible = "starry,kr122ea0sra",
1836 .data = &starry_kr122ea0sra,
1841 MODULE_DEVICE_TABLE(of, platform_of_match);
1843 static const struct panel_delay delay_200_500_p2e80 = {
1846 .prepare_to_enable = 80,
1849 static const struct panel_delay delay_200_500_e50_p2e80 = {
1853 .prepare_to_enable = 80,
1856 static const struct panel_delay delay_200_500_p2e100 = {
1859 .prepare_to_enable = 100,
1862 static const struct panel_delay delay_200_500_e50 = {
1868 static const struct panel_delay delay_200_500_e80 = {
1874 static const struct panel_delay delay_200_500_e80_d50 = {
1881 static const struct panel_delay delay_100_500_e200 = {
1887 static const struct panel_delay delay_200_500_e200 = {
1893 static const struct panel_delay delay_200_500_e200_d200 = {
1900 static const struct panel_delay delay_200_500_e200_d10 = {
1907 static const struct panel_delay delay_200_150_e200 = {
1913 static const struct panel_delay delay_200_500_e50_po2e200 = {
1917 .powered_on_to_enable = 200,
1920 #define EDP_PANEL_ENTRY(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _delay, _name) \
1923 .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \
1928 #define EDP_PANEL_ENTRY2(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _delay, _name, _mode) \
1931 .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \
1934 .override_edid_mode = _mode \
1938 * This table is used to figure out power sequencing delays for panels that
1939 * are detected by EDID. Entries here may point to entries in the
1940 * platform_of_match table (if a panel is listed in both places).
1942 * Sort first by vendor, then by product ID.
1944 static const struct edp_panel_entry edp_panels[] = {
1945 EDP_PANEL_ENTRY('A', 'U', 'O', 0x105c, &delay_200_500_e50, "B116XTN01.0"),
1946 EDP_PANEL_ENTRY('A', 'U', 'O', 0x1062, &delay_200_500_e50, "B120XAN01.0"),
1947 EDP_PANEL_ENTRY('A', 'U', 'O', 0x125c, &delay_200_500_e50, "Unknown"),
1948 EDP_PANEL_ENTRY('A', 'U', 'O', 0x145c, &delay_200_500_e50, "B116XAB01.4"),
1949 EDP_PANEL_ENTRY('A', 'U', 'O', 0x1e9b, &delay_200_500_e50, "B133UAN02.1"),
1950 EDP_PANEL_ENTRY('A', 'U', 'O', 0x1ea5, &delay_200_500_e50, "B116XAK01.6"),
1951 EDP_PANEL_ENTRY('A', 'U', 'O', 0x208d, &delay_200_500_e50, "B140HTN02.1"),
1952 EDP_PANEL_ENTRY('A', 'U', 'O', 0x235c, &delay_200_500_e50, "B116XTN02.3"),
1953 EDP_PANEL_ENTRY('A', 'U', 'O', 0x239b, &delay_200_500_e50, "B116XAN06.1"),
1954 EDP_PANEL_ENTRY('A', 'U', 'O', 0x255c, &delay_200_500_e50, "B116XTN02.5"),
1955 EDP_PANEL_ENTRY('A', 'U', 'O', 0x403d, &delay_200_500_e50, "B140HAN04.0"),
1956 EDP_PANEL_ENTRY('A', 'U', 'O', 0x405c, &auo_b116xak01.delay, "B116XAK01.0"),
1957 EDP_PANEL_ENTRY('A', 'U', 'O', 0x435c, &delay_200_500_e50, "Unknown"),
1958 EDP_PANEL_ENTRY('A', 'U', 'O', 0x582d, &delay_200_500_e50, "B133UAN01.0"),
1959 EDP_PANEL_ENTRY('A', 'U', 'O', 0x615c, &delay_200_500_e50, "B116XAN06.1"),
1960 EDP_PANEL_ENTRY('A', 'U', 'O', 0x635c, &delay_200_500_e50, "B116XAN06.3"),
1961 EDP_PANEL_ENTRY('A', 'U', 'O', 0x639c, &delay_200_500_e50, "B140HAK02.7"),
1962 EDP_PANEL_ENTRY('A', 'U', 'O', 0x723c, &delay_200_500_e50, "B140XTN07.2"),
1963 EDP_PANEL_ENTRY('A', 'U', 'O', 0x8594, &delay_200_500_e50, "B133UAN01.0"),
1964 EDP_PANEL_ENTRY('A', 'U', 'O', 0xf390, &delay_200_500_e50, "B140XTN07.7"),
1966 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0607, &delay_200_500_e200, "Unknown"),
1967 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0608, &delay_200_500_e50, "NT116WHM-N11"),
1968 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0668, &delay_200_500_e200, "Unknown"),
1969 EDP_PANEL_ENTRY('B', 'O', 'E', 0x068f, &delay_200_500_e200, "Unknown"),
1970 EDP_PANEL_ENTRY('B', 'O', 'E', 0x06e5, &delay_200_500_e200, "Unknown"),
1971 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0705, &delay_200_500_e200, "Unknown"),
1972 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0715, &delay_200_150_e200, "NT116WHM-N21"),
1973 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0717, &delay_200_500_e50_po2e200, "NV133FHM-N42"),
1974 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0731, &delay_200_500_e80, "NT116WHM-N42"),
1975 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0741, &delay_200_500_e200, "NT116WHM-N44"),
1976 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0744, &delay_200_500_e200, "Unknown"),
1977 EDP_PANEL_ENTRY('B', 'O', 'E', 0x074c, &delay_200_500_e200, "Unknown"),
1978 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0751, &delay_200_500_e200, "Unknown"),
1979 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0754, &delay_200_500_e50_po2e200, "NV116WHM-N45"),
1980 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0771, &delay_200_500_e200, "Unknown"),
1981 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0786, &delay_200_500_p2e80, "NV116WHM-T01"),
1982 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0797, &delay_200_500_e200, "Unknown"),
1983 EDP_PANEL_ENTRY('B', 'O', 'E', 0x07d1, &boe_nv133fhm_n61.delay, "NV133FHM-N61"),
1984 EDP_PANEL_ENTRY('B', 'O', 'E', 0x07d3, &delay_200_500_e200, "Unknown"),
1985 EDP_PANEL_ENTRY('B', 'O', 'E', 0x07f6, &delay_200_500_e200, "NT140FHM-N44"),
1986 EDP_PANEL_ENTRY('B', 'O', 'E', 0x07f8, &delay_200_500_e200, "Unknown"),
1987 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0813, &delay_200_500_e200, "Unknown"),
1988 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0827, &delay_200_500_e50_p2e80, "NT140WHM-N44 V8.0"),
1989 EDP_PANEL_ENTRY('B', 'O', 'E', 0x082d, &boe_nv133fhm_n61.delay, "NV133FHM-N62"),
1990 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0843, &delay_200_500_e200, "Unknown"),
1991 EDP_PANEL_ENTRY('B', 'O', 'E', 0x08b2, &delay_200_500_e200, "NT140WHM-N49"),
1992 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0848, &delay_200_500_e200, "Unknown"),
1993 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0849, &delay_200_500_e200, "Unknown"),
1994 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09c3, &delay_200_500_e50, "NT116WHM-N21,836X2"),
1995 EDP_PANEL_ENTRY('B', 'O', 'E', 0x094b, &delay_200_500_e50, "NT116WHM-N21"),
1996 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0951, &delay_200_500_e80, "NV116WHM-N47"),
1997 EDP_PANEL_ENTRY('B', 'O', 'E', 0x095f, &delay_200_500_e50, "NE135FBM-N41 v8.1"),
1998 EDP_PANEL_ENTRY('B', 'O', 'E', 0x096e, &delay_200_500_e50_po2e200, "NV116WHM-T07 V8.0"),
1999 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0979, &delay_200_500_e50, "NV116WHM-N49 V8.0"),
2000 EDP_PANEL_ENTRY('B', 'O', 'E', 0x098d, &boe_nv110wtm_n61.delay, "NV110WTM-N61"),
2001 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0993, &delay_200_500_e80, "NV116WHM-T14 V8.0"),
2002 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09ad, &delay_200_500_e80, "NV116WHM-N47"),
2003 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09ae, &delay_200_500_e200, "NT140FHM-N45"),
2004 EDP_PANEL_ENTRY('B', 'O', 'E', 0x09dd, &delay_200_500_e50, "NT116WHM-N21"),
2005 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0a36, &delay_200_500_e200, "Unknown"),
2006 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0a3e, &delay_200_500_e80, "NV116WHM-N49"),
2007 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0a5d, &delay_200_500_e50, "NV116WHM-N45"),
2008 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0ac5, &delay_200_500_e50, "NV116WHM-N4C"),
2009 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0b34, &delay_200_500_e80, "NV122WUM-N41"),
2010 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0b43, &delay_200_500_e200, "NV140FHM-T09"),
2011 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0b56, &delay_200_500_e80, "NT140FHM-N47"),
2012 EDP_PANEL_ENTRY('B', 'O', 'E', 0x0c20, &delay_200_500_e80, "NT140FHM-N47"),
2014 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1130, &delay_200_500_e50, "N116BGE-EB2"),
2015 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1132, &delay_200_500_e80_d50, "N116BGE-EA2"),
2016 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1138, &innolux_n116bca_ea1.delay, "N116BCA-EA1-RC4"),
2017 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1139, &delay_200_500_e80_d50, "N116BGE-EA2"),
2018 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1141, &delay_200_500_e80_d50, "Unknown"),
2019 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1145, &delay_200_500_e80_d50, "N116BCN-EB1"),
2020 EDP_PANEL_ENTRY('C', 'M', 'N', 0x114a, &delay_200_500_e80_d50, "Unknown"),
2021 EDP_PANEL_ENTRY('C', 'M', 'N', 0x114c, &innolux_n116bca_ea1.delay, "N116BCA-EA1"),
2022 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1152, &delay_200_500_e80_d50, "N116BCN-EA1"),
2023 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1153, &delay_200_500_e80_d50, "N116BGE-EA2"),
2024 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1154, &delay_200_500_e80_d50, "N116BCA-EA2"),
2025 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1156, &delay_200_500_e80_d50, "Unknown"),
2026 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1157, &delay_200_500_e80_d50, "N116BGE-EA2"),
2027 EDP_PANEL_ENTRY('C', 'M', 'N', 0x115b, &delay_200_500_e80_d50, "N116BCN-EB1"),
2028 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1247, &delay_200_500_e80_d50, "N120ACA-EA1"),
2029 EDP_PANEL_ENTRY('C', 'M', 'N', 0x142b, &delay_200_500_e80_d50, "N140HCA-EAC"),
2030 EDP_PANEL_ENTRY('C', 'M', 'N', 0x142e, &delay_200_500_e80_d50, "N140BGA-EA4"),
2031 EDP_PANEL_ENTRY('C', 'M', 'N', 0x144f, &delay_200_500_e80_d50, "N140HGA-EA1"),
2032 EDP_PANEL_ENTRY('C', 'M', 'N', 0x1468, &delay_200_500_e80, "N140HGA-EA1"),
2033 EDP_PANEL_ENTRY('C', 'M', 'N', 0x14d4, &delay_200_500_e80_d50, "N140HCA-EAC"),
2034 EDP_PANEL_ENTRY('C', 'M', 'N', 0x14d6, &delay_200_500_e80_d50, "N140BGA-EA4"),
2035 EDP_PANEL_ENTRY('C', 'M', 'N', 0x14e5, &delay_200_500_e80_d50, "N140HGA-EA1"),
2037 EDP_PANEL_ENTRY('C', 'S', 'O', 0x1200, &delay_200_500_e50, "MNC207QS1-1"),
2039 EDP_PANEL_ENTRY('H', 'K', 'C', 0x2d51, &delay_200_500_e200, "Unknown"),
2040 EDP_PANEL_ENTRY('H', 'K', 'C', 0x2d5b, &delay_200_500_e200, "Unknown"),
2041 EDP_PANEL_ENTRY('H', 'K', 'C', 0x2d5c, &delay_200_500_e200, "MB116AN01-2"),
2043 EDP_PANEL_ENTRY('I', 'V', 'O', 0x048e, &delay_200_500_e200_d10, "M116NWR6 R5"),
2044 EDP_PANEL_ENTRY('I', 'V', 'O', 0x057d, &delay_200_500_e200, "R140NWF5 RH"),
2045 EDP_PANEL_ENTRY('I', 'V', 'O', 0x854a, &delay_200_500_p2e100, "M133NW4J"),
2046 EDP_PANEL_ENTRY('I', 'V', 'O', 0x854b, &delay_200_500_p2e100, "R133NW4K-R0"),
2047 EDP_PANEL_ENTRY('I', 'V', 'O', 0x8c4d, &delay_200_150_e200, "R140NWFM R1"),
2049 EDP_PANEL_ENTRY('K', 'D', 'B', 0x044f, &delay_200_500_e80_d50, "Unknown"),
2050 EDP_PANEL_ENTRY('K', 'D', 'B', 0x0624, &kingdisplay_kd116n21_30nv_a010.delay, "116N21-30NV-A010"),
2051 EDP_PANEL_ENTRY('K', 'D', 'B', 0x1118, &delay_200_500_e50, "KD116N29-30NK-A005"),
2052 EDP_PANEL_ENTRY('K', 'D', 'B', 0x1120, &delay_200_500_e80_d50, "116N29-30NK-C007"),
2054 EDP_PANEL_ENTRY('K', 'D', 'C', 0x044f, &delay_200_500_e50, "KD116N9-30NH-F3"),
2055 EDP_PANEL_ENTRY('K', 'D', 'C', 0x05f1, &delay_200_500_e80_d50, "KD116N5-30NV-G7"),
2056 EDP_PANEL_ENTRY('K', 'D', 'C', 0x0809, &delay_200_500_e50, "KD116N2930A15"),
2058 EDP_PANEL_ENTRY('L', 'G', 'D', 0x0000, &delay_200_500_e200_d200, "Unknown"),
2059 EDP_PANEL_ENTRY('L', 'G', 'D', 0x048d, &delay_200_500_e200_d200, "Unknown"),
2060 EDP_PANEL_ENTRY('L', 'G', 'D', 0x0497, &delay_200_500_e200_d200, "LP116WH7-SPB1"),
2061 EDP_PANEL_ENTRY('L', 'G', 'D', 0x052c, &delay_200_500_e200_d200, "LP133WF2-SPL7"),
2062 EDP_PANEL_ENTRY('L', 'G', 'D', 0x0537, &delay_200_500_e200_d200, "Unknown"),
2063 EDP_PANEL_ENTRY('L', 'G', 'D', 0x054a, &delay_200_500_e200_d200, "LP116WH8-SPC1"),
2064 EDP_PANEL_ENTRY('L', 'G', 'D', 0x0567, &delay_200_500_e200_d200, "Unknown"),
2065 EDP_PANEL_ENTRY('L', 'G', 'D', 0x05af, &delay_200_500_e200_d200, "Unknown"),
2066 EDP_PANEL_ENTRY('L', 'G', 'D', 0x05f1, &delay_200_500_e200_d200, "Unknown"),
2068 EDP_PANEL_ENTRY('S', 'D', 'C', 0x416d, &delay_100_500_e200, "ATNA45AF01"),
2070 EDP_PANEL_ENTRY('S', 'H', 'P', 0x1511, &delay_200_500_e50, "LQ140M1JW48"),
2071 EDP_PANEL_ENTRY('S', 'H', 'P', 0x1523, &sharp_lq140m1jw46.delay, "LQ140M1JW46"),
2072 EDP_PANEL_ENTRY('S', 'H', 'P', 0x154c, &delay_200_500_p2e100, "LQ116M1JW10"),
2074 EDP_PANEL_ENTRY('S', 'T', 'A', 0x0100, &delay_100_500_e200, "2081116HHD028001-51D"),
2079 static const struct edp_panel_entry *find_edp_panel(u32 panel_id)
2081 const struct edp_panel_entry *panel;
2086 for (panel = edp_panels; panel->panel_id; panel++)
2087 if (panel->panel_id == panel_id)
2093 static int panel_edp_platform_probe(struct platform_device *pdev)
2095 const struct of_device_id *id;
2097 /* Skip one since "edp-panel" is only supported on DP AUX bus */
2098 id = of_match_node(platform_of_match + 1, pdev->dev.of_node);
2102 return panel_edp_probe(&pdev->dev, id->data, NULL);
2105 static void panel_edp_platform_remove(struct platform_device *pdev)
2107 panel_edp_remove(&pdev->dev);
2110 static void panel_edp_platform_shutdown(struct platform_device *pdev)
2112 panel_edp_shutdown(&pdev->dev);
2115 static const struct dev_pm_ops panel_edp_pm_ops = {
2116 SET_RUNTIME_PM_OPS(panel_edp_suspend, panel_edp_resume, NULL)
2117 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
2118 pm_runtime_force_resume)
2121 static struct platform_driver panel_edp_platform_driver = {
2123 .name = "panel-edp",
2124 .of_match_table = platform_of_match,
2125 .pm = &panel_edp_pm_ops,
2127 .probe = panel_edp_platform_probe,
2128 .remove_new = panel_edp_platform_remove,
2129 .shutdown = panel_edp_platform_shutdown,
2132 static int panel_edp_dp_aux_ep_probe(struct dp_aux_ep_device *aux_ep)
2134 const struct of_device_id *id;
2136 id = of_match_node(platform_of_match, aux_ep->dev.of_node);
2140 return panel_edp_probe(&aux_ep->dev, id->data, aux_ep->aux);
2143 static void panel_edp_dp_aux_ep_remove(struct dp_aux_ep_device *aux_ep)
2145 panel_edp_remove(&aux_ep->dev);
2148 static void panel_edp_dp_aux_ep_shutdown(struct dp_aux_ep_device *aux_ep)
2150 panel_edp_shutdown(&aux_ep->dev);
2153 static struct dp_aux_ep_driver panel_edp_dp_aux_ep_driver = {
2155 .name = "panel-simple-dp-aux",
2156 .of_match_table = platform_of_match, /* Same as platform one! */
2157 .pm = &panel_edp_pm_ops,
2159 .probe = panel_edp_dp_aux_ep_probe,
2160 .remove = panel_edp_dp_aux_ep_remove,
2161 .shutdown = panel_edp_dp_aux_ep_shutdown,
2164 static int __init panel_edp_init(void)
2168 err = platform_driver_register(&panel_edp_platform_driver);
2172 err = dp_aux_dp_driver_register(&panel_edp_dp_aux_ep_driver);
2174 goto err_did_platform_register;
2178 err_did_platform_register:
2179 platform_driver_unregister(&panel_edp_platform_driver);
2183 module_init(panel_edp_init);
2185 static void __exit panel_edp_exit(void)
2187 dp_aux_dp_driver_unregister(&panel_edp_dp_aux_ep_driver);
2188 platform_driver_unregister(&panel_edp_platform_driver);
2190 module_exit(panel_edp_exit);
2193 MODULE_DESCRIPTION("DRM Driver for Simple eDP Panels");
2194 MODULE_LICENSE("GPL and additional rights");