Add timing data for tfc_s9700rtwv43tr_01b from Linux to the simple-panel driver. To support hardcoded timing data as Linux does, add a new struct simple_panel_drv_data which holds a struct display_timing pointer as well. The hardcoded timing data is preferred over DT parsing.
Reviewed-by: Fabio Estevam <[email protected]> Signed-off-by: Markus Schneider-Pargmann (TI.com) <[email protected]> --- drivers/video/simple_panel.c | 62 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c index 0f23df701bc3c40ea49380bbfa3743ee592d8bd3..987ad29995c9b0e30ec59fd56e52590b516fae52 100644 --- a/drivers/video/simple_panel.c +++ b/drivers/video/simple_panel.c @@ -22,6 +22,12 @@ struct simple_panel_priv { struct gpio_desc enable; }; +struct simple_panel_drv_data { + const struct drm_display_mode *modes; + unsigned int num_modes; + const struct mipi_dsi_panel_plat *mipi_dsi; +}; + static int simple_panel_enable_backlight(struct udevice *dev) { struct simple_panel_priv *priv = dev_get_priv(dev); @@ -104,13 +110,32 @@ static int simple_panel_get_edid_timing(struct udevice *dev, } #endif +static int simple_panel_get_modes(struct udevice *dev, + const struct drm_display_mode **modes) +{ + const struct simple_panel_drv_data *data = + (const struct simple_panel_drv_data *)dev_get_driver_data(dev); + + if (!data || !data->modes || data->num_modes == 0) + return -ENODEV; + + *modes = data->modes; + return data->num_modes; +} + static int simple_panel_get_display_timing(struct udevice *dev, struct display_timing *timings) { + const struct simple_panel_drv_data *data = + (const struct simple_panel_drv_data *)dev_get_driver_data(dev); const void *blob = gd->fdt_blob; int ret; - /* Check for timing subnode if panel node first */ + /* Prefer the use of drm_display_mode if available */ + if (data && data->modes && data->num_modes > 0) + return -ENODEV; + + /* Check for timing subnode in panel node */ ret = fdtdec_decode_display_timing(blob, dev_of_offset(dev), 0, timings); if (!ret) @@ -158,9 +183,9 @@ static int simple_panel_of_to_plat(struct udevice *dev) static int simple_panel_probe(struct udevice *dev) { struct simple_panel_priv *priv = dev_get_priv(dev); + const struct simple_panel_drv_data *data = + (const struct simple_panel_drv_data *)dev_get_driver_data(dev); struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); - struct mipi_dsi_panel_plat *dsi_data = - (struct mipi_dsi_panel_plat *)dev_get_driver_data(dev); int ret; ret = regulator_set_enable_if_allowed(priv->reg, true); @@ -170,8 +195,8 @@ static int simple_panel_probe(struct udevice *dev) return ret; } - if (dsi_data) - memcpy(plat, dsi_data, sizeof(struct mipi_dsi_panel_plat)); + if (data->mipi_dsi) + memcpy(plat, data->mipi_dsi, sizeof(struct mipi_dsi_panel_plat)); return 0; } @@ -180,6 +205,7 @@ static const struct panel_ops simple_panel_ops = { .enable_backlight = simple_panel_enable_backlight, .set_backlight = simple_panel_set_backlight, .get_display_timing = simple_panel_get_display_timing, + .get_modes = simple_panel_get_modes, }; static const struct mipi_dsi_panel_plat panasonic_vvx10f004b00 = { @@ -189,6 +215,28 @@ static const struct mipi_dsi_panel_plat panasonic_vvx10f004b00 = { .lanes = 4, }; +static const struct simple_panel_drv_data panasonic_vvx10f004b00_data = { + .mipi_dsi = &panasonic_vvx10f004b00, +}; + +static const struct drm_display_mode tfc_s9700rtwv43tr_01b_mode = { + .clock = 30000, + .hdisplay = 800, + .hsync_start = 800 + 39, + .hsync_end = 800 + 39 + 47, + .htotal = 800 + 39 + 47 + 39, + .vdisplay = 480, + .vsync_start = 480 + 13, + .vsync_end = 480 + 13 + 2, + .vtotal = 480 + 13 + 2 + 29, + .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC, +}; + +static const struct simple_panel_drv_data tfc_s9700rtwv43tr_01b_data = { + .modes = &tfc_s9700rtwv43tr_01b_mode, + .num_modes = 1, +}; + static const struct udevice_id simple_panel_ids[] = { { .compatible = "simple-panel" }, { .compatible = "panel-lvds" }, @@ -200,7 +248,9 @@ static const struct udevice_id simple_panel_ids[] = { { .compatible = "sharp,lq123p1jx31" }, { .compatible = "boe,nv101wxmn51" }, { .compatible = "panasonic,vvx10f004b00", - .data = (ulong)&panasonic_vvx10f004b00 }, + .data = (ulong)&panasonic_vvx10f004b00_data }, + { .compatible = "tfc,s9700rtwv43tr-01b", + .data = (ulong)&tfc_s9700rtwv43tr_01b_data }, { } }; -- 2.51.0

