* [PATCH v1 0/2] Add support for Tianma TL121BVMS07-00 panel @ 2025-09-30 7:50 Langyan Ye 2025-09-30 7:50 ` [PATCH v1 1/2] dt-bindings: display: panel: Add " Langyan Ye 2025-09-30 7:50 ` [PATCH v1 2/2] drm/panel: Add driver for " Langyan Ye 0 siblings, 2 replies; 5+ messages in thread From: Langyan Ye @ 2025-09-30 7:50 UTC (permalink / raw) To: neil.armstrong, jessica.zhang, airlied, simona, maarten.lankhorst, mripard, tzimmermann, robh, krzk+dt, conor+dt, dianders Cc: dri-devel, devicetree, linux-kernel, Langyan Ye This patch series adds device tree bindings and a DRM panel driver for the Tianma TL121BVMS07-00 12.1" MIPI-DSI TFT LCD panel. The panel requires multiple power supplies (AVDD, AVEE, and 1.8V logic), an enable GPIO, and a backlight device. It is based on the Ilitek IL79900A controller. Tested on a MediaTek platform. Langyan Ye (2): dt-bindings: display: panel: Add Tianma TL121BVMS07-00 panel drm/panel: Add driver for Tianma TL121BVMS07-00 panel .../display/panel/tianma,tl121bvms07-00.yaml | 85 ++++ .../drm/panel/panel-tianma-tl121bvms07-00.c | 419 ++++++++++++++++++ 2 files changed, 504 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/tianma,tl121bvms07-00.yaml create mode 100644 drivers/gpu/drm/panel/panel-tianma-tl121bvms07-00.c -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 1/2] dt-bindings: display: panel: Add Tianma TL121BVMS07-00 panel 2025-09-30 7:50 [PATCH v1 0/2] Add support for Tianma TL121BVMS07-00 panel Langyan Ye @ 2025-09-30 7:50 ` Langyan Ye 2025-10-07 1:16 ` Rob Herring 2025-09-30 7:50 ` [PATCH v1 2/2] drm/panel: Add driver for " Langyan Ye 1 sibling, 1 reply; 5+ messages in thread From: Langyan Ye @ 2025-09-30 7:50 UTC (permalink / raw) To: neil.armstrong, jessica.zhang, airlied, simona, maarten.lankhorst, mripard, tzimmermann, robh, krzk+dt, conor+dt, dianders Cc: dri-devel, devicetree, linux-kernel, Langyan Ye Add device tree bindings for the Tianma TL121BVMS07-00 12.1" MIPI-DSI TFT LCD panel. Signed-off-by: Langyan Ye <yelangyan@huaqin.corp-partner.google.com> --- .../display/panel/tianma,tl121bvms07-00.yaml | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/tianma,tl121bvms07-00.yaml diff --git a/Documentation/devicetree/bindings/display/panel/tianma,tl121bvms07-00.yaml b/Documentation/devicetree/bindings/display/panel/tianma,tl121bvms07-00.yaml new file mode 100644 index 000000000000..e654b86782e6 --- /dev/null +++ b/Documentation/devicetree/bindings/display/panel/tianma,tl121bvms07-00.yaml @@ -0,0 +1,85 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/tianma,tl121bvms07-00.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Tianma TL121BVMS07-00 12.1" MIPI-DSI TFT LCD Panel + +maintainers: + - Langyan Ye <yelangyan@huaqin.corp-partner.google.com> + +description: | + The Tianma TL121BVMS07-00 is a 12.1-inch MIPI-DSI TFT LCD panel. + It requires multiple regulators (AVDD, AVEE, and 1.8V logic) + and an enable GPIO. Optional properties such as backlight and + rotation are inherited from panel-common.yaml. + +allOf: + - $ref: panel-common.yaml# + +properties: + compatible: + const: tianma,tl121bvms07-00 + + reg: + description: DSI virtual channel number + minimum: 0 + maximum: 3 + + enable-gpios: + maxItems: 1 + description: GPIO specifier for the enable pin + + avdd-supply: + description: phandle of the regulator that provides positive voltage + + avee-supply: + description: phandle of the regulator that provides negative voltage + + pp1800-supply: + description: core voltage supply + + backlight: + $ref: /schemas/types.yaml#/definitions/phandle + description: Phandle to the backlight device. + + port: + $ref: /schemas/graph.yaml#/properties/port + description: Input port of the panel, connected to the DSI host. + +required: + - compatible + - reg + - enable-gpios + - avdd-supply + - avee-supply + - pp1800-supply + - port + +additionalProperties: false + +examples: + - | + dsi0 { + #address-cells = <1>; + #size-cells = <0>; + + mipi_panel: panel@0 { + compatible = "tianma,tl121bvms07-00"; + reg = <0>; + enable-gpios = <&pio 25 0>; + avdd-supply = <&en_pp5800_mipi_disp>; + avee-supply = <&en_pp5800_mipi_disp>; + pp1800-supply = <&mt6359_vcn18_ldo_reg>; + backlight = <&backlight>; + + port { + panel_in: endpoint { + remote-endpoint = <&dsi_out>; + }; + }; + }; + }; + +... -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/2] dt-bindings: display: panel: Add Tianma TL121BVMS07-00 panel 2025-09-30 7:50 ` [PATCH v1 1/2] dt-bindings: display: panel: Add " Langyan Ye @ 2025-10-07 1:16 ` Rob Herring 0 siblings, 0 replies; 5+ messages in thread From: Rob Herring @ 2025-10-07 1:16 UTC (permalink / raw) To: Langyan Ye Cc: neil.armstrong, jessica.zhang, airlied, simona, maarten.lankhorst, mripard, tzimmermann, krzk+dt, conor+dt, dianders, dri-devel, devicetree, linux-kernel On Tue, Sep 30, 2025 at 03:50:43PM +0800, Langyan Ye wrote: > Add device tree bindings for the Tianma TL121BVMS07-00 12.1" > MIPI-DSI TFT LCD panel. > > Signed-off-by: Langyan Ye <yelangyan@huaqin.corp-partner.google.com> > --- > .../display/panel/tianma,tl121bvms07-00.yaml | 85 +++++++++++++++++++ > 1 file changed, 85 insertions(+) > create mode 100644 Documentation/devicetree/bindings/display/panel/tianma,tl121bvms07-00.yaml > > diff --git a/Documentation/devicetree/bindings/display/panel/tianma,tl121bvms07-00.yaml b/Documentation/devicetree/bindings/display/panel/tianma,tl121bvms07-00.yaml > new file mode 100644 > index 000000000000..e654b86782e6 > --- /dev/null > +++ b/Documentation/devicetree/bindings/display/panel/tianma,tl121bvms07-00.yaml > @@ -0,0 +1,85 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/display/panel/tianma,tl121bvms07-00.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Tianma TL121BVMS07-00 12.1" MIPI-DSI TFT LCD Panel > + > +maintainers: > + - Langyan Ye <yelangyan@huaqin.corp-partner.google.com> > + > +description: | Don't need '|' if no formatting to preserve. > + The Tianma TL121BVMS07-00 is a 12.1-inch MIPI-DSI TFT LCD panel. > + It requires multiple regulators (AVDD, AVEE, and 1.8V logic) > + and an enable GPIO. Optional properties such as backlight and > + rotation are inherited from panel-common.yaml. Wrap lines at 80 char. The last sentence can be dropped as it says what the schema do. > + > +allOf: > + - $ref: panel-common.yaml# > + > +properties: > + compatible: > + const: tianma,tl121bvms07-00 > + > + reg: > + description: DSI virtual channel number > + minimum: 0 > + maximum: 3 Just 'reg: true'. dsi-controller.yaml already has these constraints. > + > + enable-gpios: > + maxItems: 1 > + description: GPIO specifier for the enable pin > + > + avdd-supply: > + description: phandle of the regulator that provides positive voltage > + > + avee-supply: > + description: phandle of the regulator that provides negative voltage > + > + pp1800-supply: > + description: core voltage supply > + > + backlight: > + $ref: /schemas/types.yaml#/definitions/phandle Already has a type in panel-common.yaml. Drop. > + description: Phandle to the backlight device. > + > + port: > + $ref: /schemas/graph.yaml#/properties/port > + description: Input port of the panel, connected to the DSI host. Already in panel-common.yaml. Either just 'true' for both of these or drop and use 'unevaluatedProperties' instead of 'additionalProperties'. > + > +required: > + - compatible > + - reg > + - enable-gpios > + - avdd-supply > + - avee-supply > + - pp1800-supply > + - port > + > +additionalProperties: false > + > +examples: > + - | > + dsi0 { dsi { > + #address-cells = <1>; > + #size-cells = <0>; > + > + mipi_panel: panel@0 { drop unused labels. > + compatible = "tianma,tl121bvms07-00"; > + reg = <0>; > + enable-gpios = <&pio 25 0>; > + avdd-supply = <&en_pp5800_mipi_disp>; > + avee-supply = <&en_pp5800_mipi_disp>; > + pp1800-supply = <&mt6359_vcn18_ldo_reg>; > + backlight = <&backlight>; > + > + port { > + panel_in: endpoint { > + remote-endpoint = <&dsi_out>; > + }; > + }; > + }; > + }; > + > +... > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 2/2] drm/panel: Add driver for Tianma TL121BVMS07-00 panel 2025-09-30 7:50 [PATCH v1 0/2] Add support for Tianma TL121BVMS07-00 panel Langyan Ye 2025-09-30 7:50 ` [PATCH v1 1/2] dt-bindings: display: panel: Add " Langyan Ye @ 2025-09-30 7:50 ` Langyan Ye 2025-10-05 23:21 ` Dmitry Baryshkov 1 sibling, 1 reply; 5+ messages in thread From: Langyan Ye @ 2025-09-30 7:50 UTC (permalink / raw) To: neil.armstrong, jessica.zhang, airlied, simona, maarten.lankhorst, mripard, tzimmermann, robh, krzk+dt, conor+dt, dianders Cc: dri-devel, devicetree, linux-kernel, Langyan Ye Add a DRM panel driver for the Tianma TL121BVMS07-00 12.1" MIPI-DSI TFT LCD panel. The panel requires multiple power supplies (AVDD, AVEE, 1.8V logic), an enable GPIO, and a backlight device. The panel is based on the Ilitek IL79900A controller. Signed-off-by: Langyan Ye <yelangyan@huaqin.corp-partner.google.com> --- .../drm/panel/panel-tianma-tl121bvms07-00.c | 419 ++++++++++++++++++ 1 file changed, 419 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-tianma-tl121bvms07-00.c diff --git a/drivers/gpu/drm/panel/panel-tianma-tl121bvms07-00.c b/drivers/gpu/drm/panel/panel-tianma-tl121bvms07-00.c new file mode 100644 index 000000000000..5facffeda864 --- /dev/null +++ b/drivers/gpu/drm/panel/panel-tianma-tl121bvms07-00.c @@ -0,0 +1,419 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * DRM panel driver for Tianma TL121BVMS07-00 12.1" MIPI-DSI TFT LCD panel + * + * Based on drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c + */ + + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/regulator/consumer.h> + +#include <drm/drm_connector.h> +#include <drm/drm_crtc.h> +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_panel.h> + +#include <video/mipi_display.h> + +struct tm_panel; + +struct panel_desc { + const struct drm_display_mode *modes; + unsigned int bpc; + + /** + * @width_mm: width of the panel's active display area + * @height_mm: height of the panel's active display area + */ + struct { + unsigned int width_mm; + unsigned int height_mm; + } size; + + unsigned long mode_flags; + enum mipi_dsi_pixel_format format; + int (*init)(struct tm_panel *tm); + unsigned int lanes; + bool discharge_on_disable; + bool lp11_before_reset; +}; + +struct tm_panel { + struct drm_panel base; + struct mipi_dsi_device *dsi; + + const struct panel_desc *desc; + + enum drm_panel_orientation orientation; + struct regulator *pp1800; + struct regulator *avee; + struct regulator *avdd; + struct gpio_desc *enable_gpio; + + bool prepared; +}; + +static int tm_tl121bvms07_00_init(struct tm_panel *tm) +{ + struct mipi_dsi_multi_context ctx = { .dsi = tm->dsi }; + struct mipi_dsi_device *dsi = ctx.dsi; + + mipi_dsi_dcs_write_seq_multi(&ctx, 0xff, 0x5a, 0xa5, 0x06); + mipi_dsi_dcs_write_seq_multi(&ctx, 0x3e, 0x62); + + + mipi_dsi_generic_write_seq(dsi, 0xff, 0x5a, 0xa5, 0x02); + mipi_dsi_dcs_write_seq_multi(&ctx, 0x1b, 0x20); + mipi_dsi_dcs_write_seq_multi(&ctx, 0x5d, 0x00); + mipi_dsi_dcs_write_seq_multi(&ctx, 0x5e, 0x40); + + mipi_dsi_dcs_write_seq_multi(&ctx, 0xff, 0x5a, 0xa5, 0x07); + mipi_dsi_dcs_write_seq_multi(&ctx, 0X29, 0x00); + + mipi_dsi_generic_write_seq(dsi, 0xff, 0x5a, 0xa5, 0x00); + + mipi_dsi_dcs_write_seq_multi(&ctx, 0X11); + + if (ctx.accum_err) + return ctx.accum_err; + + msleep(120); + + mipi_dsi_dcs_write_seq_multi(&ctx, 0X29); + + if (ctx.accum_err) + return ctx.accum_err; + + msleep(80); + + return 0; +}; + +static inline struct tm_panel *to_tm_panel(struct drm_panel *panel) +{ + return container_of(panel, struct tm_panel, base); +} + +static int tm_panel_enter_sleep_mode(struct tm_panel *tm) +{ + struct mipi_dsi_device *dsi = tm->dsi; + int ret; + + dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; + + ret = mipi_dsi_dcs_set_display_off(dsi); + if (ret < 0) + return ret; + + ret = mipi_dsi_dcs_enter_sleep_mode(dsi); + if (ret < 0) + return ret; + + return 0; +} + +static int tm_panel_disable(struct drm_panel *panel) +{ + struct tm_panel *tm = to_tm_panel(panel); + int ret; + + ret = tm_panel_enter_sleep_mode(tm); + if (ret < 0) { + dev_err(panel->dev, "failed to set panel off: %d\n", ret); + return ret; + } + + msleep(150); + + return 0; +} + +static int tm_panel_unprepare(struct drm_panel *panel) +{ + struct tm_panel *tm = to_tm_panel(panel); + + if (!tm->prepared) + return 0; + + if (tm->desc->discharge_on_disable) { + regulator_disable(tm->avee); + regulator_disable(tm->avdd); + usleep_range(5000, 7000); + gpiod_set_value(tm->enable_gpio, 0); + usleep_range(5000, 7000); + regulator_disable(tm->pp1800); + } else { + gpiod_set_value(tm->enable_gpio, 0); + usleep_range(1000, 2000); + regulator_disable(tm->avee); + regulator_disable(tm->avdd); + usleep_range(5000, 7000); + regulator_disable(tm->pp1800); + } + + tm->prepared = false; + + return 0; +} + +static int tm_panel_prepare(struct drm_panel *panel) +{ + struct tm_panel *tm = to_tm_panel(panel); + int ret; + + if (tm->prepared) + return 0; + + ret = regulator_enable(tm->pp1800); + if (ret < 0) + return ret; + + usleep_range(6000, 8000); + + ret = regulator_enable(tm->avdd); + if (ret < 0) + goto poweroff1v8; + ret = regulator_enable(tm->avee); + if (ret < 0) + goto poweroffavdd; + + usleep_range(11000, 12000); + + gpiod_set_value(tm->enable_gpio, 1); + + if (tm->desc->lp11_before_reset) { + ret = mipi_dsi_dcs_nop(tm->dsi); + if (ret < 0) { + dev_err(&tm->dsi->dev, "Failed to send NOP: %d\n", ret); + goto poweroff; + } + usleep_range(1000, 2000); + } + gpiod_set_value(tm->enable_gpio, 0); + usleep_range(1000, 2000); + gpiod_set_value(tm->enable_gpio, 1); + usleep_range(20000, 21000); + + ret = tm->desc->init(tm); + if (ret < 0) + goto poweroff; + + tm->prepared = true; + return 0; + +poweroff: + gpiod_set_value(tm->enable_gpio, 0); + regulator_disable(tm->avee); +poweroffavdd: + regulator_disable(tm->avdd); +poweroff1v8: + usleep_range(5000, 7000); + regulator_disable(tm->pp1800); + + return ret; +} + +static int tm_panel_enable(struct drm_panel *panel) +{ + msleep(130); + return 0; +} + +static const struct drm_display_mode tm_tl121bvms07_00_default_mode = { + .clock = 264355, + .hdisplay = 1600, + .hsync_start = 1600 + 20, + .hsync_end = 1600 + 20 + 4, + .htotal = 1600 + 20 + 4 + 20, + .vdisplay = 2560, + .vsync_start = 2560 + 82, + .vsync_end = 2560 + 82 + 2, + .vtotal = 2560 + 82 + 2 + 36, +}; + +static const struct panel_desc tm_tl121bvms07_00_desc = { + .modes = &tm_tl121bvms07_00_default_mode, + .bpc = 8, + .size = { + .width_mm = 163, + .height_mm = 260, + }, + .lanes = 3, + .format = MIPI_DSI_FMT_RGB888, + .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | + MIPI_DSI_MODE_LPM, + .init = tm_tl121bvms07_00_init, + .lp11_before_reset = true, +}; + +static int tm_panel_get_modes(struct drm_panel *panel, + struct drm_connector *connector) +{ + struct tm_panel *tm = to_tm_panel(panel); + const struct drm_display_mode *m = tm->desc->modes; + struct drm_display_mode *mode; + + mode = drm_mode_duplicate(connector->dev, m); + if (!mode) { + dev_err(panel->dev, "failed to add mode %ux%u@%u\n", + m->hdisplay, m->vdisplay, drm_mode_vrefresh(m)); + return -ENOMEM; + } + + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; + drm_mode_set_name(mode); + drm_mode_probed_add(connector, mode); + + connector->display_info.width_mm = tm->desc->size.width_mm; + connector->display_info.height_mm = tm->desc->size.height_mm; + connector->display_info.bpc = tm->desc->bpc; + /* + * TODO: Remove once all drm drivers call + * drm_connector_set_orientation_from_panel() + */ + drm_connector_set_panel_orientation(connector, tm->orientation); + + return 1; +} + +static enum drm_panel_orientation tm_panel_get_orientation(struct drm_panel *panel) +{ + struct tm_panel *tm = to_tm_panel(panel); + + return tm->orientation; +} + +static const struct drm_panel_funcs tm_panel_funcs = { + .disable = tm_panel_disable, + .unprepare = tm_panel_unprepare, + .prepare = tm_panel_prepare, + .enable = tm_panel_enable, + .get_modes = tm_panel_get_modes, + .get_orientation = tm_panel_get_orientation, +}; + +static int tm_panel_add(struct tm_panel *tm) +{ + struct device *dev = &tm->dsi->dev; + int err; + + tm->avdd = devm_regulator_get(dev, "avdd"); + if (IS_ERR(tm->avdd)) + return PTR_ERR(tm->avdd); + + tm->avee = devm_regulator_get(dev, "avee"); + if (IS_ERR(tm->avee)) + return PTR_ERR(tm->avee); + + tm->pp1800 = devm_regulator_get(dev, "pp1800"); + if (IS_ERR(tm->pp1800)) + return PTR_ERR(tm->pp1800); + + tm->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); + if (IS_ERR(tm->enable_gpio)) { + dev_err(dev, "cannot get reset-gpios %ld\n", + PTR_ERR(tm->enable_gpio)); + return PTR_ERR(tm->enable_gpio); + } + + gpiod_set_value(tm->enable_gpio, 0); + + tm->base.prepare_prev_first = true; + + drm_panel_init(&tm->base, dev, &tm_panel_funcs, + DRM_MODE_CONNECTOR_DSI); + err = of_drm_get_panel_orientation(dev->of_node, &tm->orientation); + if (err < 0) { + dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err); + return err; + } + + err = drm_panel_of_backlight(&tm->base); + if (err) + return err; + + tm->base.funcs = &tm_panel_funcs; + tm->base.dev = &tm->dsi->dev; + + drm_panel_add(&tm->base); + + return 0; +} + +static int tm_panel_probe(struct mipi_dsi_device *dsi) +{ + struct tm_panel *tm; + int ret; + const struct panel_desc *desc; + + tm = devm_kzalloc(&dsi->dev, sizeof(*tm), GFP_KERNEL); + if (!tm) + return -ENOMEM; + + desc = of_device_get_match_data(&dsi->dev); + dsi->lanes = desc->lanes; + dsi->format = desc->format; + dsi->mode_flags = desc->mode_flags; + tm->desc = desc; + tm->dsi = dsi; + ret = tm_panel_add(tm); + if (ret < 0) + return ret; + + mipi_dsi_set_drvdata(dsi, tm); + + ret = mipi_dsi_attach(dsi); + if (ret) + drm_panel_remove(&tm->base); + return ret; +} + +static void tm_panel_shutdown(struct mipi_dsi_device *dsi) +{ + struct tm_panel *tm = mipi_dsi_get_drvdata(dsi); + + drm_panel_disable(&tm->base); + drm_panel_unprepare(&tm->base); +} + +static void tm_panel_remove(struct mipi_dsi_device *dsi) +{ + struct tm_panel *tm = mipi_dsi_get_drvdata(dsi); + int ret; + + tm_panel_shutdown(dsi); + + ret = mipi_dsi_detach(dsi); + if (ret < 0) + dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", ret); + + if (tm->base.dev) + drm_panel_remove(&tm->base); +} + +static const struct of_device_id tm_of_match[] = { + { .compatible = "tianma,tl121bvms07-00", + .data = &tm_tl121bvms07_00_desc + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, tm_of_match); + +static struct mipi_dsi_driver tm_panel_driver = { + .driver = { + .name = "panel-tianma-tl121bvms07-00", + .of_match_table = tm_of_match, + }, + .probe = tm_panel_probe, + .remove = tm_panel_remove, + .shutdown = tm_panel_shutdown, +}; +module_mipi_dsi_driver(tm_panel_driver); + +MODULE_AUTHOR("Langyan Ye <yelangyan@huaqin.corp-partner.google.com>"); +MODULE_DESCRIPTION("TM tl121bvms07-00 1600x2560 video mode panel driver"); +MODULE_LICENSE("GPL"); -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/2] drm/panel: Add driver for Tianma TL121BVMS07-00 panel 2025-09-30 7:50 ` [PATCH v1 2/2] drm/panel: Add driver for " Langyan Ye @ 2025-10-05 23:21 ` Dmitry Baryshkov 0 siblings, 0 replies; 5+ messages in thread From: Dmitry Baryshkov @ 2025-10-05 23:21 UTC (permalink / raw) To: Langyan Ye Cc: neil.armstrong, jessica.zhang, airlied, simona, maarten.lankhorst, mripard, tzimmermann, robh, krzk+dt, conor+dt, dianders, dri-devel, devicetree, linux-kernel On Tue, Sep 30, 2025 at 03:50:44PM +0800, Langyan Ye wrote: > Add a DRM panel driver for the Tianma TL121BVMS07-00 12.1" > MIPI-DSI TFT LCD panel. The panel requires multiple power > supplies (AVDD, AVEE, 1.8V logic), an enable GPIO, and a > backlight device. The panel is based on the Ilitek IL79900A > controller. The rest of panels based on Ilitek controllers are handled by panel-ilitek-iliNNNN.c drivers (which might or might not be shared by several panels). Is there a reason to deviate from that custom? > > Signed-off-by: Langyan Ye <yelangyan@huaqin.corp-partner.google.com> > --- > .../drm/panel/panel-tianma-tl121bvms07-00.c | 419 ++++++++++++++++++ > 1 file changed, 419 insertions(+) > create mode 100644 drivers/gpu/drm/panel/panel-tianma-tl121bvms07-00.c > > diff --git a/drivers/gpu/drm/panel/panel-tianma-tl121bvms07-00.c b/drivers/gpu/drm/panel/panel-tianma-tl121bvms07-00.c > new file mode 100644 > index 000000000000..5facffeda864 > --- /dev/null > +++ b/drivers/gpu/drm/panel/panel-tianma-tl121bvms07-00.c > @@ -0,0 +1,419 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * DRM panel driver for Tianma TL121BVMS07-00 12.1" MIPI-DSI TFT LCD panel > + * > + * Based on drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c > + */ > + > + > +#include <linux/delay.h> > +#include <linux/gpio/consumer.h> > +#include <linux/module.h> > +#include <linux/of.h> > +#include <linux/regulator/consumer.h> > + > +#include <drm/drm_connector.h> > +#include <drm/drm_crtc.h> Unnecessary > +#include <drm/drm_mipi_dsi.h> > +#include <drm/drm_panel.h> > + > +#include <video/mipi_display.h> > + > +struct tm_panel; > + > +struct panel_desc { > + const struct drm_display_mode *modes; > + unsigned int bpc; > + > + /** > + * @width_mm: width of the panel's active display area > + * @height_mm: height of the panel's active display area > + */ > + struct { > + unsigned int width_mm; > + unsigned int height_mm; > + } size; > + > + unsigned long mode_flags; > + enum mipi_dsi_pixel_format format; > + int (*init)(struct tm_panel *tm); > + unsigned int lanes; > + bool discharge_on_disable; > + bool lp11_before_reset; > +}; > + > +struct tm_panel { > + struct drm_panel base; > + struct mipi_dsi_device *dsi; > + > + const struct panel_desc *desc; > + > + enum drm_panel_orientation orientation; > + struct regulator *pp1800; > + struct regulator *avee; > + struct regulator *avdd; > + struct gpio_desc *enable_gpio; > + > + bool prepared; > +}; > + > +static int tm_tl121bvms07_00_init(struct tm_panel *tm) > +{ > + struct mipi_dsi_multi_context ctx = { .dsi = tm->dsi }; > + struct mipi_dsi_device *dsi = ctx.dsi; > + > + mipi_dsi_dcs_write_seq_multi(&ctx, 0xff, 0x5a, 0xa5, 0x06); > + mipi_dsi_dcs_write_seq_multi(&ctx, 0x3e, 0x62); > + > + > + mipi_dsi_generic_write_seq(dsi, 0xff, 0x5a, 0xa5, 0x02); > + mipi_dsi_dcs_write_seq_multi(&ctx, 0x1b, 0x20); > + mipi_dsi_dcs_write_seq_multi(&ctx, 0x5d, 0x00); > + mipi_dsi_dcs_write_seq_multi(&ctx, 0x5e, 0x40); > + > + mipi_dsi_dcs_write_seq_multi(&ctx, 0xff, 0x5a, 0xa5, 0x07); > + mipi_dsi_dcs_write_seq_multi(&ctx, 0X29, 0x00); > + > + mipi_dsi_generic_write_seq(dsi, 0xff, 0x5a, 0xa5, 0x00); > + > + mipi_dsi_dcs_write_seq_multi(&ctx, 0X11); > + > + if (ctx.accum_err) > + return ctx.accum_err; > + > + msleep(120); > + > + mipi_dsi_dcs_write_seq_multi(&ctx, 0X29); > + > + if (ctx.accum_err) > + return ctx.accum_err; > + > + msleep(80); > + > + return 0; > +}; > + > +static inline struct tm_panel *to_tm_panel(struct drm_panel *panel) > +{ > + return container_of(panel, struct tm_panel, base); > +} I'd expect this function to be present right after struct tm_panel definition. > + > +static int tm_panel_enter_sleep_mode(struct tm_panel *tm) > +{ > + struct mipi_dsi_device *dsi = tm->dsi; > + int ret; > + > + dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; > + > + ret = mipi_dsi_dcs_set_display_off(dsi); Use _multi. > + if (ret < 0) > + return ret; > + > + ret = mipi_dsi_dcs_enter_sleep_mode(dsi); > + if (ret < 0) > + return ret; > + > + return 0; > +} > + > +static int tm_panel_disable(struct drm_panel *panel) > +{ > + struct tm_panel *tm = to_tm_panel(panel); > + int ret; > + > + ret = tm_panel_enter_sleep_mode(tm); Inline > + if (ret < 0) { > + dev_err(panel->dev, "failed to set panel off: %d\n", ret); > + return ret; > + } > + > + msleep(150); And here use DSI-specific wrapper. > + > + return 0; > +} > + > +static int tm_panel_unprepare(struct drm_panel *panel) > +{ > + struct tm_panel *tm = to_tm_panel(panel); > + > + if (!tm->prepared) > + return 0; > + > + if (tm->desc->discharge_on_disable) { > + regulator_disable(tm->avee); > + regulator_disable(tm->avdd); > + usleep_range(5000, 7000); > + gpiod_set_value(tm->enable_gpio, 0); > + usleep_range(5000, 7000); > + regulator_disable(tm->pp1800); > + } else { > + gpiod_set_value(tm->enable_gpio, 0); > + usleep_range(1000, 2000); > + regulator_disable(tm->avee); > + regulator_disable(tm->avdd); > + usleep_range(5000, 7000); > + regulator_disable(tm->pp1800); > + } > + > + tm->prepared = false; > + > + return 0; > +} > + > +static int tm_panel_prepare(struct drm_panel *panel) > +{ > + struct tm_panel *tm = to_tm_panel(panel); > + int ret; > + > + if (tm->prepared) > + return 0; > + > + ret = regulator_enable(tm->pp1800); > + if (ret < 0) > + return ret; > + > + usleep_range(6000, 8000); > + > + ret = regulator_enable(tm->avdd); > + if (ret < 0) > + goto poweroff1v8; > + ret = regulator_enable(tm->avee); > + if (ret < 0) > + goto poweroffavdd; > + > + usleep_range(11000, 12000); > + > + gpiod_set_value(tm->enable_gpio, 1); > + > + if (tm->desc->lp11_before_reset) { > + ret = mipi_dsi_dcs_nop(tm->dsi); > + if (ret < 0) { > + dev_err(&tm->dsi->dev, "Failed to send NOP: %d\n", ret); > + goto poweroff; > + } > + usleep_range(1000, 2000); > + } > + gpiod_set_value(tm->enable_gpio, 0); > + usleep_range(1000, 2000); > + gpiod_set_value(tm->enable_gpio, 1); > + usleep_range(20000, 21000); > + > + ret = tm->desc->init(tm); > + if (ret < 0) > + goto poweroff; > + > + tm->prepared = true; > + return 0; > + > +poweroff: > + gpiod_set_value(tm->enable_gpio, 0); > + regulator_disable(tm->avee); > +poweroffavdd: > + regulator_disable(tm->avdd); > +poweroff1v8: > + usleep_range(5000, 7000); > + regulator_disable(tm->pp1800); > + > + return ret; > +} > + > +static int tm_panel_enable(struct drm_panel *panel) > +{ > + msleep(130); > + return 0; > +} > + > +static const struct drm_display_mode tm_tl121bvms07_00_default_mode = { > + .clock = 264355, > + .hdisplay = 1600, > + .hsync_start = 1600 + 20, > + .hsync_end = 1600 + 20 + 4, > + .htotal = 1600 + 20 + 4 + 20, > + .vdisplay = 2560, > + .vsync_start = 2560 + 82, > + .vsync_end = 2560 + 82 + 2, > + .vtotal = 2560 + 82 + 2 + 36, > +}; > + > +static const struct panel_desc tm_tl121bvms07_00_desc = { > + .modes = &tm_tl121bvms07_00_default_mode, > + .bpc = 8, > + .size = { > + .width_mm = 163, > + .height_mm = 260, > + }, > + .lanes = 3, > + .format = MIPI_DSI_FMT_RGB888, > + .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | > + MIPI_DSI_MODE_LPM, > + .init = tm_tl121bvms07_00_init, > + .lp11_before_reset = true, > +}; > + > +static int tm_panel_get_modes(struct drm_panel *panel, > + struct drm_connector *connector) > +{ > + struct tm_panel *tm = to_tm_panel(panel); > + const struct drm_display_mode *m = tm->desc->modes; > + struct drm_display_mode *mode; > + > + mode = drm_mode_duplicate(connector->dev, m); > + if (!mode) { > + dev_err(panel->dev, "failed to add mode %ux%u@%u\n", > + m->hdisplay, m->vdisplay, drm_mode_vrefresh(m)); > + return -ENOMEM; > + } See drm_connector_helper_get_modes_fixed() > + > + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; > + drm_mode_set_name(mode); > + drm_mode_probed_add(connector, mode); > + > + connector->display_info.width_mm = tm->desc->size.width_mm; > + connector->display_info.height_mm = tm->desc->size.height_mm; > + connector->display_info.bpc = tm->desc->bpc; > + /* > + * TODO: Remove once all drm drivers call > + * drm_connector_set_orientation_from_panel() > + */ > + drm_connector_set_panel_orientation(connector, tm->orientation); > + > + return 1; > +} > + -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-07 1:16 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-09-30 7:50 [PATCH v1 0/2] Add support for Tianma TL121BVMS07-00 panel Langyan Ye 2025-09-30 7:50 ` [PATCH v1 1/2] dt-bindings: display: panel: Add " Langyan Ye 2025-10-07 1:16 ` Rob Herring 2025-09-30 7:50 ` [PATCH v1 2/2] drm/panel: Add driver for " Langyan Ye 2025-10-05 23:21 ` Dmitry Baryshkov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).