* [PATCH v11 0/2] Add support for rm69299 Visionox panel driver and add devicetree bindings for visionox panel @ 2020-04-21 4:55 Harigovindan P 2020-04-21 4:55 ` [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver Harigovindan P ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Harigovindan P @ 2020-04-21 4:55 UTC (permalink / raw) To: dri-devel, linux-arm-msm, freedreno, devicetree Cc: sean, seanpaul, Harigovindan P Adding support for visionox rm69299 panel driver and adding bindings for the same panel. https://patchwork.kernel.org/patch/11461943/ has already been added to drm-misc-next. Harigovindan P (2): drm/panel: add support for rm69299 visionox panel driver dt-bindings: documenting compatible string vendor "visionox" .../devicetree/bindings/vendor-prefixes.yaml | 2 + drivers/gpu/drm/panel/Kconfig | 8 + drivers/gpu/drm/panel/Makefile | 1 + .../gpu/drm/panel/panel-visionox-rm69299.c | 304 ++++++++++++++++++ 4 files changed, 315 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-visionox-rm69299.c -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver 2020-04-21 4:55 [PATCH v11 0/2] Add support for rm69299 Visionox panel driver and add devicetree bindings for visionox panel Harigovindan P @ 2020-04-21 4:55 ` Harigovindan P 2020-04-21 20:00 ` Matthias Kaehlcke ` (2 more replies) 2020-04-21 4:55 ` [PATCH v11 2/2] dt-bindings: documenting compatible string vendor "visionox" Harigovindan P 2020-04-29 5:45 ` [PATCH v12 " Harigovindan P 2 siblings, 3 replies; 13+ messages in thread From: Harigovindan P @ 2020-04-21 4:55 UTC (permalink / raw) To: dri-devel, linux-arm-msm, freedreno, devicetree Cc: sean, seanpaul, Harigovindan P Add support for Visionox panel driver. Signed-off-by: Harigovindan P <harigovi@codeaurora.org> --- Changes in v2: - Dropping redundant space in Kconfig(Sam Ravnborg). - Changing structure for include files(Sam Ravnborg). - Removing backlight related code and functions(Sam Ravnborg). - Removing repeated printing of error message(Sam Ravnborg). - Adding drm_connector as an argument for get_modes function. Changes in v3: - Adding arguments for drm_panel_init to support against mainline. Changes in v4: - Removing error messages from regulator_set_load. - Removing dev struct entry. - Removing checks. - Dropping empty comment lines. Changes in v5: - Removing unused struct member variables. - Removing blank lines. - Fixed indentation. - Invoking dsi_detach and panel_remove while early exiting from probe. Changes in v6: - Changed "35597" to "rm69299" for power_on function. - Removing rm69299_config since it supports single type of panel for now. - Fixed alignment. - Using goto statements when regulator_set_load fails. Changes in v7: - Added new goto statement when regulator_set_load fails. Changes in v8,v9,v10: - Had changes in first patch, did not make any change in panel driver. Changes in v11: - Fixing checkpatch script errors. - Updated assignment of panel.dev property in probe. drivers/gpu/drm/panel/Kconfig | 8 + drivers/gpu/drm/panel/Makefile | 1 + .../gpu/drm/panel/panel-visionox-rm69299.c | 304 ++++++++++++++++++ 3 files changed, 313 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-visionox-rm69299.c diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index d56258b9fcaf..4b6131f5893d 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -444,6 +444,14 @@ config DRM_PANEL_TRULY_NT35597_WQXGA Say Y here if you want to enable support for Truly NT35597 WQXGA Dual DSI Video Mode panel +config DRM_PANEL_VISIONOX_RM69299 + tristate "Visionox RM69299" + depends on OF + depends on DRM_MIPI_DSI + help + Say Y here if you want to enable support for Visionox + RM69299 DSI Video Mode panel. + config DRM_PANEL_XINPENG_XPP055C272 tristate "Xinpeng XPP055C272 panel driver" depends on OF diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index 2335a1e32ae0..8eac3e6fa82c 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -47,4 +47,5 @@ obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o +obj-$(CONFIG_DRM_PANEL_VISIONOX_RM69299) += panel-visionox-rm69299.o obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c new file mode 100644 index 000000000000..3ef4cc80044a --- /dev/null +++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c @@ -0,0 +1,304 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#include <linux/delay.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/gpio/consumer.h> +#include <linux/regulator/consumer.h> + +#include <video/mipi_display.h> + +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_modes.h> +#include <drm/drm_panel.h> +#include <drm/drm_print.h> + +struct visionox_rm69299 { + struct drm_panel panel; + struct regulator_bulk_data supplies[2]; + struct gpio_desc *reset_gpio; + struct mipi_dsi_device *dsi; + bool prepared; + bool enabled; +}; + +static inline struct visionox_rm69299 *panel_to_ctx(struct drm_panel *panel) +{ + return container_of(panel, struct visionox_rm69299, panel); +} + +static int visionox_rm69299_power_on(struct visionox_rm69299 *ctx) +{ + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); + if (ret < 0) + return ret; + + /* + * Reset sequence of visionox panel requires the panel to be + * out of reset for 10ms, followed by being held in reset + * for 10ms and then out again + */ + gpiod_set_value(ctx->reset_gpio, 1); + usleep_range(10000, 20000); + gpiod_set_value(ctx->reset_gpio, 0); + usleep_range(10000, 20000); + gpiod_set_value(ctx->reset_gpio, 1); + usleep_range(10000, 20000); + + return 0; +} + +static int visionox_rm69299_power_off(struct visionox_rm69299 *ctx) +{ + gpiod_set_value(ctx->reset_gpio, 0); + + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); +} + +static int visionox_rm69299_unprepare(struct drm_panel *panel) +{ + struct visionox_rm69299 *ctx = panel_to_ctx(panel); + int ret; + + ctx->dsi->mode_flags = 0; + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); + if (ret < 0) + DRM_DEV_ERROR(ctx->panel.dev, + "set_display_off cmd failed ret = %d\n", ret); + + /* 120ms delay required here as per DCS spec */ + msleep(120); + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "enter_sleep cmd failed ret = %d\n", ret); + } + + ret = visionox_rm69299_power_off(ctx); + + ctx->prepared = false; + return ret; +} + +static int visionox_rm69299_prepare(struct drm_panel *panel) +{ + struct visionox_rm69299 *ctx = panel_to_ctx(panel); + int ret; + + if (ctx->prepared) + return 0; + + ret = visionox_rm69299_power_on(ctx); + if (ret < 0) + return ret; + + ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM; + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xfe, 0x00 }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 0 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xc2, 0x08 }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 1 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x35, 0x00 }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 2 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x51, 0xff }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 3 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "exit_sleep_mode cmd failed ret = %d\n", ret); + goto power_off; + } + + /* Per DSI spec wait 120ms after sending exit sleep DCS command */ + msleep(120); + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "set_display_on cmd failed ret = %d\n", ret); + goto power_off; + } + + /* Per DSI spec wait 120ms after sending set_display_on DCS command */ + msleep(120); + + ctx->prepared = true; + + return 0; + +power_off: + return ret; +} + +static const struct drm_display_mode visionox_rm69299_1080x2248_60hz = { + .name = "1080x2248", + .clock = 158695, + .hdisplay = 1080, + .hsync_start = 1080 + 26, + .hsync_end = 1080 + 26 + 2, + .htotal = 1080 + 26 + 2 + 36, + .vdisplay = 2248, + .vsync_start = 2248 + 56, + .vsync_end = 2248 + 56 + 4, + .vtotal = 2248 + 56 + 4 + 4, + .vrefresh = 60, + .flags = 0, +}; + +static int visionox_rm69299_get_modes(struct drm_panel *panel, + struct drm_connector *connector) +{ + struct visionox_rm69299 *ctx = panel_to_ctx(panel); + struct drm_display_mode *mode; + + mode = drm_mode_create(connector->dev); + if (!mode) { + DRM_DEV_ERROR(ctx->panel.dev, + "failed to create a new display mode\n"); + return 0; + } + + connector->display_info.width_mm = 74; + connector->display_info.height_mm = 131; + drm_mode_copy(mode, &visionox_rm69299_1080x2248_60hz); + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; + drm_mode_probed_add(connector, mode); + + return 1; +} + +static const struct drm_panel_funcs visionox_rm69299_drm_funcs = { + .unprepare = visionox_rm69299_unprepare, + .prepare = visionox_rm69299_prepare, + .get_modes = visionox_rm69299_get_modes, +}; + +static int visionox_rm69299_probe(struct mipi_dsi_device *dsi) +{ + struct device *dev = &dsi->dev; + struct visionox_rm69299 *ctx; + int ret; + + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + mipi_dsi_set_drvdata(dsi, ctx); + + ctx->panel.dev = dev; + ctx->dsi = dsi; + + ctx->supplies[0].supply = "vdda"; + ctx->supplies[1].supply = "vdd3p3"; + + ret = devm_regulator_bulk_get(ctx->panel.dev, ARRAY_SIZE(ctx->supplies), + ctx->supplies); + if (ret < 0) + return ret; + + ctx->reset_gpio = devm_gpiod_get(ctx->panel.dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(ctx->reset_gpio)) { + DRM_DEV_ERROR(dev, "cannot get reset gpio %ld\n", + PTR_ERR(ctx->reset_gpio)); + return PTR_ERR(ctx->reset_gpio); + } + + drm_panel_init(&ctx->panel, dev, &visionox_rm69299_drm_funcs, + DRM_MODE_CONNECTOR_DSI); + ctx->panel.dev = dev; + ctx->panel.funcs = &visionox_rm69299_drm_funcs; + drm_panel_add(&ctx->panel); + + dsi->lanes = 4; + dsi->format = MIPI_DSI_FMT_RGB888; + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM | + MIPI_DSI_CLOCK_NON_CONTINUOUS; + ret = mipi_dsi_attach(dsi); + if (ret < 0) { + DRM_DEV_ERROR(dev, "dsi attach failed ret = %d\n", ret); + goto err_dsi_attach; + } + + ret = regulator_set_load(ctx->supplies[0].consumer, 32000); + if (ret) { + DRM_DEV_ERROR(dev, + "regulator set load failed for vdda supply ret = %d\n", + ret); + goto err_set_load; + } + + ret = regulator_set_load(ctx->supplies[1].consumer, 13200); + if (ret) { + DRM_DEV_ERROR(dev, + "regulator set load failed for vdd3p3 supply ret = %d\n", + ret); + goto err_set_load; + } + + return 0; + +err_set_load: + mipi_dsi_detach(dsi); +err_dsi_attach: + drm_panel_remove(&ctx->panel); + return ret; +} + +static int visionox_rm69299_remove(struct mipi_dsi_device *dsi) +{ + struct visionox_rm69299 *ctx = mipi_dsi_get_drvdata(dsi); + + mipi_dsi_detach(ctx->dsi); + mipi_dsi_device_unregister(ctx->dsi); + + drm_panel_remove(&ctx->panel); + return 0; +} + +static const struct of_device_id visionox_rm69299_of_match[] = { + { + .compatible = "visionox,rm69299-1080p-display", + } +}; +MODULE_DEVICE_TABLE(of, visionox_rm69299_of_match); + +static struct mipi_dsi_driver visionox_rm69299_driver = { + .driver = { + .name = "panel-visionox-rm69299", + .of_match_table = visionox_rm69299_of_match, + }, + .probe = visionox_rm69299_probe, + .remove = visionox_rm69299_remove, +}; +module_mipi_dsi_driver(visionox_rm69299_driver); + +MODULE_DESCRIPTION("Visionox RM69299 DSI Panel Driver"); -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver 2020-04-21 4:55 ` [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver Harigovindan P @ 2020-04-21 20:00 ` Matthias Kaehlcke 2020-04-29 5:45 ` Harigovindan P 2020-05-06 18:57 ` Sam Ravnborg 2 siblings, 0 replies; 13+ messages in thread From: Matthias Kaehlcke @ 2020-04-21 20:00 UTC (permalink / raw) To: Harigovindan P Cc: sean, devicetree, linux-arm-msm, dri-devel, seanpaul, freedreno Hi, On Tue, Apr 21, 2020 at 10:25:07AM +0530, Harigovindan P wrote: > Add support for Visionox panel driver. > > Signed-off-by: Harigovindan P <harigovi@codeaurora.org> Please keep tags from previous versions (like my Reviewed-by from v7) when making minimal changes. Also there is no need to keep sending the bindings patch, it already landed in drm-misc. > diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c > new file mode 100644 > index 000000000000..3ef4cc80044a > --- /dev/null > +++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c ... > +MODULE_DESCRIPTION("Visionox RM69299 DSI Panel Driver"); > -- > 2.25.1 The last two lines break the patch: git am /tmp/v11-1-2-drm-panel-add-support-for-rm69299-visionox-panel-driver.patch Applying: drm/panel: add support for rm69299 visionox panel driver error: corrupt patch at line 379 Patch failed at 0001 drm/panel: add support for rm69299 visionox panel driver Besides the broken format: Reviewed-by: Matthias Kaehlcke <mka@chromium.org> _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver 2020-04-21 4:55 ` [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver Harigovindan P 2020-04-21 20:00 ` Matthias Kaehlcke @ 2020-04-29 5:45 ` Harigovindan P 2020-05-06 18:57 ` Sam Ravnborg 2 siblings, 0 replies; 13+ messages in thread From: Harigovindan P @ 2020-04-29 5:45 UTC (permalink / raw) To: dri-devel, linux-arm-msm, freedreno, devicetree Cc: sean, Matthias Kaehlcke, seanpaul, Harigovindan P Add support for Visionox panel driver. Signed-off-by: Harigovindan P <harigovi@codeaurora.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> --- Changes in v2: - Dropping redundant space in Kconfig(Sam Ravnborg). - Changing structure for include files(Sam Ravnborg). - Removing backlight related code and functions(Sam Ravnborg). - Removing repeated printing of error message(Sam Ravnborg). - Adding drm_connector as an argument for get_modes function. Changes in v3: - Adding arguments for drm_panel_init to support against mainline. Changes in v4: - Removing error messages from regulator_set_load. - Removing dev struct entry. - Removing checks. - Dropping empty comment lines. Changes in v5: - Removing unused struct member variables. - Removing blank lines. - Fixed indentation. - Invoking dsi_detach and panel_remove while early exiting from probe. Changes in v6: - Changed "35597" to "rm69299" for power_on function. - Removing rm69299_config since it supports single type of panel for now. - Fixed alignment. - Using goto statements when regulator_set_load fails. Changes in v7: - Added new goto statement when regulator_set_load fails. Changes in v8,v9,v10: - Had changes in first patch, did not make any change in panel driver. Changes in v11: - Fixing checkpatch script errors. - Updated assignment of panel.dev property in probe. drivers/gpu/drm/panel/Kconfig | 8 + drivers/gpu/drm/panel/Makefile | 1 + .../gpu/drm/panel/panel-visionox-rm69299.c | 304 ++++++++++++++++++ 3 files changed, 313 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-visionox-rm69299.c diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index d56258b9fcaf..4b6131f5893d 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -444,6 +444,14 @@ config DRM_PANEL_TRULY_NT35597_WQXGA Say Y here if you want to enable support for Truly NT35597 WQXGA Dual DSI Video Mode panel +config DRM_PANEL_VISIONOX_RM69299 + tristate "Visionox RM69299" + depends on OF + depends on DRM_MIPI_DSI + help + Say Y here if you want to enable support for Visionox + RM69299 DSI Video Mode panel. + config DRM_PANEL_XINPENG_XPP055C272 tristate "Xinpeng XPP055C272 panel driver" depends on OF diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index 2335a1e32ae0..8eac3e6fa82c 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -47,4 +47,5 @@ obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o +obj-$(CONFIG_DRM_PANEL_VISIONOX_RM69299) += panel-visionox-rm69299.o obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c new file mode 100644 index 000000000000..3ef4cc80044a --- /dev/null +++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c @@ -0,0 +1,304 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#include <linux/delay.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/gpio/consumer.h> +#include <linux/regulator/consumer.h> + +#include <video/mipi_display.h> + +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_modes.h> +#include <drm/drm_panel.h> +#include <drm/drm_print.h> + +struct visionox_rm69299 { + struct drm_panel panel; + struct regulator_bulk_data supplies[2]; + struct gpio_desc *reset_gpio; + struct mipi_dsi_device *dsi; + bool prepared; + bool enabled; +}; + +static inline struct visionox_rm69299 *panel_to_ctx(struct drm_panel *panel) +{ + return container_of(panel, struct visionox_rm69299, panel); +} + +static int visionox_rm69299_power_on(struct visionox_rm69299 *ctx) +{ + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); + if (ret < 0) + return ret; + + /* + * Reset sequence of visionox panel requires the panel to be + * out of reset for 10ms, followed by being held in reset + * for 10ms and then out again + */ + gpiod_set_value(ctx->reset_gpio, 1); + usleep_range(10000, 20000); + gpiod_set_value(ctx->reset_gpio, 0); + usleep_range(10000, 20000); + gpiod_set_value(ctx->reset_gpio, 1); + usleep_range(10000, 20000); + + return 0; +} + +static int visionox_rm69299_power_off(struct visionox_rm69299 *ctx) +{ + gpiod_set_value(ctx->reset_gpio, 0); + + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); +} + +static int visionox_rm69299_unprepare(struct drm_panel *panel) +{ + struct visionox_rm69299 *ctx = panel_to_ctx(panel); + int ret; + + ctx->dsi->mode_flags = 0; + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); + if (ret < 0) + DRM_DEV_ERROR(ctx->panel.dev, + "set_display_off cmd failed ret = %d\n", ret); + + /* 120ms delay required here as per DCS spec */ + msleep(120); + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "enter_sleep cmd failed ret = %d\n", ret); + } + + ret = visionox_rm69299_power_off(ctx); + + ctx->prepared = false; + return ret; +} + +static int visionox_rm69299_prepare(struct drm_panel *panel) +{ + struct visionox_rm69299 *ctx = panel_to_ctx(panel); + int ret; + + if (ctx->prepared) + return 0; + + ret = visionox_rm69299_power_on(ctx); + if (ret < 0) + return ret; + + ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM; + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xfe, 0x00 }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 0 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xc2, 0x08 }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 1 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x35, 0x00 }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 2 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x51, 0xff }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 3 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "exit_sleep_mode cmd failed ret = %d\n", ret); + goto power_off; + } + + /* Per DSI spec wait 120ms after sending exit sleep DCS command */ + msleep(120); + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "set_display_on cmd failed ret = %d\n", ret); + goto power_off; + } + + /* Per DSI spec wait 120ms after sending set_display_on DCS command */ + msleep(120); + + ctx->prepared = true; + + return 0; + +power_off: + return ret; +} + +static const struct drm_display_mode visionox_rm69299_1080x2248_60hz = { + .name = "1080x2248", + .clock = 158695, + .hdisplay = 1080, + .hsync_start = 1080 + 26, + .hsync_end = 1080 + 26 + 2, + .htotal = 1080 + 26 + 2 + 36, + .vdisplay = 2248, + .vsync_start = 2248 + 56, + .vsync_end = 2248 + 56 + 4, + .vtotal = 2248 + 56 + 4 + 4, + .vrefresh = 60, + .flags = 0, +}; + +static int visionox_rm69299_get_modes(struct drm_panel *panel, + struct drm_connector *connector) +{ + struct visionox_rm69299 *ctx = panel_to_ctx(panel); + struct drm_display_mode *mode; + + mode = drm_mode_create(connector->dev); + if (!mode) { + DRM_DEV_ERROR(ctx->panel.dev, + "failed to create a new display mode\n"); + return 0; + } + + connector->display_info.width_mm = 74; + connector->display_info.height_mm = 131; + drm_mode_copy(mode, &visionox_rm69299_1080x2248_60hz); + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; + drm_mode_probed_add(connector, mode); + + return 1; +} + +static const struct drm_panel_funcs visionox_rm69299_drm_funcs = { + .unprepare = visionox_rm69299_unprepare, + .prepare = visionox_rm69299_prepare, + .get_modes = visionox_rm69299_get_modes, +}; + +static int visionox_rm69299_probe(struct mipi_dsi_device *dsi) +{ + struct device *dev = &dsi->dev; + struct visionox_rm69299 *ctx; + int ret; + + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + mipi_dsi_set_drvdata(dsi, ctx); + + ctx->panel.dev = dev; + ctx->dsi = dsi; + + ctx->supplies[0].supply = "vdda"; + ctx->supplies[1].supply = "vdd3p3"; + + ret = devm_regulator_bulk_get(ctx->panel.dev, ARRAY_SIZE(ctx->supplies), + ctx->supplies); + if (ret < 0) + return ret; + + ctx->reset_gpio = devm_gpiod_get(ctx->panel.dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(ctx->reset_gpio)) { + DRM_DEV_ERROR(dev, "cannot get reset gpio %ld\n", + PTR_ERR(ctx->reset_gpio)); + return PTR_ERR(ctx->reset_gpio); + } + + drm_panel_init(&ctx->panel, dev, &visionox_rm69299_drm_funcs, + DRM_MODE_CONNECTOR_DSI); + ctx->panel.dev = dev; + ctx->panel.funcs = &visionox_rm69299_drm_funcs; + drm_panel_add(&ctx->panel); + + dsi->lanes = 4; + dsi->format = MIPI_DSI_FMT_RGB888; + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM | + MIPI_DSI_CLOCK_NON_CONTINUOUS; + ret = mipi_dsi_attach(dsi); + if (ret < 0) { + DRM_DEV_ERROR(dev, "dsi attach failed ret = %d\n", ret); + goto err_dsi_attach; + } + + ret = regulator_set_load(ctx->supplies[0].consumer, 32000); + if (ret) { + DRM_DEV_ERROR(dev, + "regulator set load failed for vdda supply ret = %d\n", + ret); + goto err_set_load; + } + + ret = regulator_set_load(ctx->supplies[1].consumer, 13200); + if (ret) { + DRM_DEV_ERROR(dev, + "regulator set load failed for vdd3p3 supply ret = %d\n", + ret); + goto err_set_load; + } + + return 0; + +err_set_load: + mipi_dsi_detach(dsi); +err_dsi_attach: + drm_panel_remove(&ctx->panel); + return ret; +} + +static int visionox_rm69299_remove(struct mipi_dsi_device *dsi) +{ + struct visionox_rm69299 *ctx = mipi_dsi_get_drvdata(dsi); + + mipi_dsi_detach(ctx->dsi); + mipi_dsi_device_unregister(ctx->dsi); + + drm_panel_remove(&ctx->panel); + return 0; +} + +static const struct of_device_id visionox_rm69299_of_match[] = { + { + .compatible = "visionox,rm69299-1080p-display", + } +}; +MODULE_DEVICE_TABLE(of, visionox_rm69299_of_match); + +static struct mipi_dsi_driver visionox_rm69299_driver = { + .driver = { + .name = "panel-visionox-rm69299", + .of_match_table = visionox_rm69299_of_match, + }, + .probe = visionox_rm69299_probe, + .remove = visionox_rm69299_remove, +}; +module_mipi_dsi_driver(visionox_rm69299_driver); + +MODULE_DESCRIPTION("Visionox RM69299 DSI Panel Driver"); + -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver 2020-04-21 4:55 ` [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver Harigovindan P 2020-04-21 20:00 ` Matthias Kaehlcke 2020-04-29 5:45 ` Harigovindan P @ 2020-05-06 18:57 ` Sam Ravnborg 2020-05-14 3:35 ` Dave Airlie 2 siblings, 1 reply; 13+ messages in thread From: Sam Ravnborg @ 2020-05-06 18:57 UTC (permalink / raw) To: Harigovindan P Cc: freedreno, devicetree, linux-arm-msm, dri-devel, Matthias Kaehlcke, seanpaul, sean Hi Harigovindan On Wed, Apr 29, 2020 at 11:15:14AM +0530, Harigovindan P wrote: > Add support for Visionox panel driver. > > Signed-off-by: Harigovindan P <harigovi@codeaurora.org> > Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Thanks for your persistence on this. Patch applied. I fixed a few lingering --strict releated checkpatch warnings when I applied. Sam > --- > > Changes in v2: > - Dropping redundant space in Kconfig(Sam Ravnborg). > - Changing structure for include files(Sam Ravnborg). > - Removing backlight related code and functions(Sam Ravnborg). > - Removing repeated printing of error message(Sam Ravnborg). > - Adding drm_connector as an argument for get_modes function. > Changes in v3: > - Adding arguments for drm_panel_init to support against mainline. > Changes in v4: > - Removing error messages from regulator_set_load. > - Removing dev struct entry. > - Removing checks. > - Dropping empty comment lines. > Changes in v5: > - Removing unused struct member variables. > - Removing blank lines. > - Fixed indentation. > - Invoking dsi_detach and panel_remove while early exiting from probe. > Changes in v6: > - Changed "35597" to "rm69299" for power_on function. > - Removing rm69299_config since it supports single type of panel for now. > - Fixed alignment. > - Using goto statements when regulator_set_load fails. > Changes in v7: > - Added new goto statement when regulator_set_load fails. > Changes in v8,v9,v10: > - Had changes in first patch, did not make any change in panel driver. > Changes in v11: > - Fixing checkpatch script errors. > - Updated assignment of panel.dev property in probe. > > drivers/gpu/drm/panel/Kconfig | 8 + > drivers/gpu/drm/panel/Makefile | 1 + > .../gpu/drm/panel/panel-visionox-rm69299.c | 304 ++++++++++++++++++ > 3 files changed, 313 insertions(+) > create mode 100644 drivers/gpu/drm/panel/panel-visionox-rm69299.c > > diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig > index d56258b9fcaf..4b6131f5893d 100644 > --- a/drivers/gpu/drm/panel/Kconfig > +++ b/drivers/gpu/drm/panel/Kconfig > @@ -444,6 +444,14 @@ config DRM_PANEL_TRULY_NT35597_WQXGA > Say Y here if you want to enable support for Truly NT35597 WQXGA Dual DSI > Video Mode panel > > +config DRM_PANEL_VISIONOX_RM69299 > + tristate "Visionox RM69299" > + depends on OF > + depends on DRM_MIPI_DSI > + help > + Say Y here if you want to enable support for Visionox > + RM69299 DSI Video Mode panel. > + > config DRM_PANEL_XINPENG_XPP055C272 > tristate "Xinpeng XPP055C272 panel driver" > depends on OF > diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile > index 2335a1e32ae0..8eac3e6fa82c 100644 > --- a/drivers/gpu/drm/panel/Makefile > +++ b/drivers/gpu/drm/panel/Makefile > @@ -47,4 +47,5 @@ obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o > obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o > obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o > obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o > +obj-$(CONFIG_DRM_PANEL_VISIONOX_RM69299) += panel-visionox-rm69299.o > obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o > diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c > new file mode 100644 > index 000000000000..3ef4cc80044a > --- /dev/null > +++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c > @@ -0,0 +1,304 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2019, The Linux Foundation. All rights reserved. > + */ > + > +#include <linux/delay.h> > +#include <linux/module.h> > +#include <linux/of_device.h> > +#include <linux/gpio/consumer.h> > +#include <linux/regulator/consumer.h> > + > +#include <video/mipi_display.h> > + > +#include <drm/drm_mipi_dsi.h> > +#include <drm/drm_modes.h> > +#include <drm/drm_panel.h> > +#include <drm/drm_print.h> > + > +struct visionox_rm69299 { > + struct drm_panel panel; > + struct regulator_bulk_data supplies[2]; > + struct gpio_desc *reset_gpio; > + struct mipi_dsi_device *dsi; > + bool prepared; > + bool enabled; > +}; > + > +static inline struct visionox_rm69299 *panel_to_ctx(struct drm_panel *panel) > +{ > + return container_of(panel, struct visionox_rm69299, panel); > +} > + > +static int visionox_rm69299_power_on(struct visionox_rm69299 *ctx) > +{ > + int ret; > + > + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); > + if (ret < 0) > + return ret; > + > + /* > + * Reset sequence of visionox panel requires the panel to be > + * out of reset for 10ms, followed by being held in reset > + * for 10ms and then out again > + */ > + gpiod_set_value(ctx->reset_gpio, 1); > + usleep_range(10000, 20000); > + gpiod_set_value(ctx->reset_gpio, 0); > + usleep_range(10000, 20000); > + gpiod_set_value(ctx->reset_gpio, 1); > + usleep_range(10000, 20000); > + > + return 0; > +} > + > +static int visionox_rm69299_power_off(struct visionox_rm69299 *ctx) > +{ > + gpiod_set_value(ctx->reset_gpio, 0); > + > + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); > +} > + > +static int visionox_rm69299_unprepare(struct drm_panel *panel) > +{ > + struct visionox_rm69299 *ctx = panel_to_ctx(panel); > + int ret; > + > + ctx->dsi->mode_flags = 0; > + > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); > + if (ret < 0) > + DRM_DEV_ERROR(ctx->panel.dev, > + "set_display_off cmd failed ret = %d\n", ret); > + > + /* 120ms delay required here as per DCS spec */ > + msleep(120); > + > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); > + if (ret < 0) { > + DRM_DEV_ERROR(ctx->panel.dev, > + "enter_sleep cmd failed ret = %d\n", ret); > + } > + > + ret = visionox_rm69299_power_off(ctx); > + > + ctx->prepared = false; > + return ret; > +} > + > +static int visionox_rm69299_prepare(struct drm_panel *panel) > +{ > + struct visionox_rm69299 *ctx = panel_to_ctx(panel); > + int ret; > + > + if (ctx->prepared) > + return 0; > + > + ret = visionox_rm69299_power_on(ctx); > + if (ret < 0) > + return ret; > + > + ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM; > + > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xfe, 0x00 }, 2); > + if (ret < 0) { > + DRM_DEV_ERROR(ctx->panel.dev, > + "cmd set tx 0 failed, ret = %d\n", ret); > + goto power_off; > + } > + > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xc2, 0x08 }, 2); > + if (ret < 0) { > + DRM_DEV_ERROR(ctx->panel.dev, > + "cmd set tx 1 failed, ret = %d\n", ret); > + goto power_off; > + } > + > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x35, 0x00 }, 2); > + if (ret < 0) { > + DRM_DEV_ERROR(ctx->panel.dev, > + "cmd set tx 2 failed, ret = %d\n", ret); > + goto power_off; > + } > + > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x51, 0xff }, 2); > + if (ret < 0) { > + DRM_DEV_ERROR(ctx->panel.dev, > + "cmd set tx 3 failed, ret = %d\n", ret); > + goto power_off; > + } > + > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); > + if (ret < 0) { > + DRM_DEV_ERROR(ctx->panel.dev, > + "exit_sleep_mode cmd failed ret = %d\n", ret); > + goto power_off; > + } > + > + /* Per DSI spec wait 120ms after sending exit sleep DCS command */ > + msleep(120); > + > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); > + if (ret < 0) { > + DRM_DEV_ERROR(ctx->panel.dev, > + "set_display_on cmd failed ret = %d\n", ret); > + goto power_off; > + } > + > + /* Per DSI spec wait 120ms after sending set_display_on DCS command */ > + msleep(120); > + > + ctx->prepared = true; > + > + return 0; > + > +power_off: > + return ret; > +} > + > +static const struct drm_display_mode visionox_rm69299_1080x2248_60hz = { > + .name = "1080x2248", > + .clock = 158695, > + .hdisplay = 1080, > + .hsync_start = 1080 + 26, > + .hsync_end = 1080 + 26 + 2, > + .htotal = 1080 + 26 + 2 + 36, > + .vdisplay = 2248, > + .vsync_start = 2248 + 56, > + .vsync_end = 2248 + 56 + 4, > + .vtotal = 2248 + 56 + 4 + 4, > + .vrefresh = 60, > + .flags = 0, > +}; > + > +static int visionox_rm69299_get_modes(struct drm_panel *panel, > + struct drm_connector *connector) > +{ > + struct visionox_rm69299 *ctx = panel_to_ctx(panel); > + struct drm_display_mode *mode; > + > + mode = drm_mode_create(connector->dev); > + if (!mode) { > + DRM_DEV_ERROR(ctx->panel.dev, > + "failed to create a new display mode\n"); > + return 0; > + } > + > + connector->display_info.width_mm = 74; > + connector->display_info.height_mm = 131; > + drm_mode_copy(mode, &visionox_rm69299_1080x2248_60hz); > + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; > + drm_mode_probed_add(connector, mode); > + > + return 1; > +} > + > +static const struct drm_panel_funcs visionox_rm69299_drm_funcs = { > + .unprepare = visionox_rm69299_unprepare, > + .prepare = visionox_rm69299_prepare, > + .get_modes = visionox_rm69299_get_modes, > +}; > + > +static int visionox_rm69299_probe(struct mipi_dsi_device *dsi) > +{ > + struct device *dev = &dsi->dev; > + struct visionox_rm69299 *ctx; > + int ret; > + > + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); > + if (!ctx) > + return -ENOMEM; > + > + mipi_dsi_set_drvdata(dsi, ctx); > + > + ctx->panel.dev = dev; > + ctx->dsi = dsi; > + > + ctx->supplies[0].supply = "vdda"; > + ctx->supplies[1].supply = "vdd3p3"; > + > + ret = devm_regulator_bulk_get(ctx->panel.dev, ARRAY_SIZE(ctx->supplies), > + ctx->supplies); > + if (ret < 0) > + return ret; > + > + ctx->reset_gpio = devm_gpiod_get(ctx->panel.dev, > + "reset", GPIOD_OUT_LOW); > + if (IS_ERR(ctx->reset_gpio)) { > + DRM_DEV_ERROR(dev, "cannot get reset gpio %ld\n", > + PTR_ERR(ctx->reset_gpio)); > + return PTR_ERR(ctx->reset_gpio); > + } > + > + drm_panel_init(&ctx->panel, dev, &visionox_rm69299_drm_funcs, > + DRM_MODE_CONNECTOR_DSI); > + ctx->panel.dev = dev; > + ctx->panel.funcs = &visionox_rm69299_drm_funcs; > + drm_panel_add(&ctx->panel); > + > + dsi->lanes = 4; > + dsi->format = MIPI_DSI_FMT_RGB888; > + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM | > + MIPI_DSI_CLOCK_NON_CONTINUOUS; > + ret = mipi_dsi_attach(dsi); > + if (ret < 0) { > + DRM_DEV_ERROR(dev, "dsi attach failed ret = %d\n", ret); > + goto err_dsi_attach; > + } > + > + ret = regulator_set_load(ctx->supplies[0].consumer, 32000); > + if (ret) { > + DRM_DEV_ERROR(dev, > + "regulator set load failed for vdda supply ret = %d\n", > + ret); > + goto err_set_load; > + } > + > + ret = regulator_set_load(ctx->supplies[1].consumer, 13200); > + if (ret) { > + DRM_DEV_ERROR(dev, > + "regulator set load failed for vdd3p3 supply ret = %d\n", > + ret); > + goto err_set_load; > + } > + > + return 0; > + > +err_set_load: > + mipi_dsi_detach(dsi); > +err_dsi_attach: > + drm_panel_remove(&ctx->panel); > + return ret; > +} > + > +static int visionox_rm69299_remove(struct mipi_dsi_device *dsi) > +{ > + struct visionox_rm69299 *ctx = mipi_dsi_get_drvdata(dsi); > + > + mipi_dsi_detach(ctx->dsi); > + mipi_dsi_device_unregister(ctx->dsi); > + > + drm_panel_remove(&ctx->panel); > + return 0; > +} > + > +static const struct of_device_id visionox_rm69299_of_match[] = { > + { > + .compatible = "visionox,rm69299-1080p-display", > + } > +}; > +MODULE_DEVICE_TABLE(of, visionox_rm69299_of_match); > + > +static struct mipi_dsi_driver visionox_rm69299_driver = { > + .driver = { > + .name = "panel-visionox-rm69299", > + .of_match_table = visionox_rm69299_of_match, > + }, > + .probe = visionox_rm69299_probe, > + .remove = visionox_rm69299_remove, > +}; > +module_mipi_dsi_driver(visionox_rm69299_driver); > + > +MODULE_DESCRIPTION("Visionox RM69299 DSI Panel Driver"); > + > -- > 2.25.1 > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver 2020-05-06 18:57 ` Sam Ravnborg @ 2020-05-14 3:35 ` Dave Airlie 2020-05-14 4:43 ` Sam Ravnborg 0 siblings, 1 reply; 13+ messages in thread From: Dave Airlie @ 2020-05-14 3:35 UTC (permalink / raw) To: Sam Ravnborg Cc: Sean Paul, devicetree, linux-arm-msm, Harigovindan P, dri-devel, Matthias Kaehlcke, Sean Paul, freedreno On Thu, 7 May 2020 at 04:57, Sam Ravnborg <sam@ravnborg.org> wrote: > > Hi Harigovindan > > On Wed, Apr 29, 2020 at 11:15:14AM +0530, Harigovindan P wrote: > > Add support for Visionox panel driver. > > > > Signed-off-by: Harigovindan P <harigovi@codeaurora.org> > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org> > > Thanks for your persistence on this. > Patch applied. > > I fixed a few lingering --strict releated checkpatch warnings > when I applied. > > Sam I'm seeing WARNING: modpost: missing MODULE_LICENSE() in drivers/gpu/drm/panel/panel-visionox-rm69299.o Can we fix that up? Dave. > > > --- > > > > Changes in v2: > > - Dropping redundant space in Kconfig(Sam Ravnborg). > > - Changing structure for include files(Sam Ravnborg). > > - Removing backlight related code and functions(Sam Ravnborg). > > - Removing repeated printing of error message(Sam Ravnborg). > > - Adding drm_connector as an argument for get_modes function. > > Changes in v3: > > - Adding arguments for drm_panel_init to support against mainline. > > Changes in v4: > > - Removing error messages from regulator_set_load. > > - Removing dev struct entry. > > - Removing checks. > > - Dropping empty comment lines. > > Changes in v5: > > - Removing unused struct member variables. > > - Removing blank lines. > > - Fixed indentation. > > - Invoking dsi_detach and panel_remove while early exiting from probe. > > Changes in v6: > > - Changed "35597" to "rm69299" for power_on function. > > - Removing rm69299_config since it supports single type of panel for now. > > - Fixed alignment. > > - Using goto statements when regulator_set_load fails. > > Changes in v7: > > - Added new goto statement when regulator_set_load fails. > > Changes in v8,v9,v10: > > - Had changes in first patch, did not make any change in panel driver. > > Changes in v11: > > - Fixing checkpatch script errors. > > - Updated assignment of panel.dev property in probe. > > > > drivers/gpu/drm/panel/Kconfig | 8 + > > drivers/gpu/drm/panel/Makefile | 1 + > > .../gpu/drm/panel/panel-visionox-rm69299.c | 304 ++++++++++++++++++ > > 3 files changed, 313 insertions(+) > > create mode 100644 drivers/gpu/drm/panel/panel-visionox-rm69299.c > > > > diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig > > index d56258b9fcaf..4b6131f5893d 100644 > > --- a/drivers/gpu/drm/panel/Kconfig > > +++ b/drivers/gpu/drm/panel/Kconfig > > @@ -444,6 +444,14 @@ config DRM_PANEL_TRULY_NT35597_WQXGA > > Say Y here if you want to enable support for Truly NT35597 WQXGA Dual DSI > > Video Mode panel > > > > +config DRM_PANEL_VISIONOX_RM69299 > > + tristate "Visionox RM69299" > > + depends on OF > > + depends on DRM_MIPI_DSI > > + help > > + Say Y here if you want to enable support for Visionox > > + RM69299 DSI Video Mode panel. > > + > > config DRM_PANEL_XINPENG_XPP055C272 > > tristate "Xinpeng XPP055C272 panel driver" > > depends on OF > > diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile > > index 2335a1e32ae0..8eac3e6fa82c 100644 > > --- a/drivers/gpu/drm/panel/Makefile > > +++ b/drivers/gpu/drm/panel/Makefile > > @@ -47,4 +47,5 @@ obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o > > obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o > > obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o > > obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o > > +obj-$(CONFIG_DRM_PANEL_VISIONOX_RM69299) += panel-visionox-rm69299.o > > obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o > > diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c > > new file mode 100644 > > index 000000000000..3ef4cc80044a > > --- /dev/null > > +++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c > > @@ -0,0 +1,304 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (c) 2019, The Linux Foundation. All rights reserved. > > + */ > > + > > +#include <linux/delay.h> > > +#include <linux/module.h> > > +#include <linux/of_device.h> > > +#include <linux/gpio/consumer.h> > > +#include <linux/regulator/consumer.h> > > + > > +#include <video/mipi_display.h> > > + > > +#include <drm/drm_mipi_dsi.h> > > +#include <drm/drm_modes.h> > > +#include <drm/drm_panel.h> > > +#include <drm/drm_print.h> > > + > > +struct visionox_rm69299 { > > + struct drm_panel panel; > > + struct regulator_bulk_data supplies[2]; > > + struct gpio_desc *reset_gpio; > > + struct mipi_dsi_device *dsi; > > + bool prepared; > > + bool enabled; > > +}; > > + > > +static inline struct visionox_rm69299 *panel_to_ctx(struct drm_panel *panel) > > +{ > > + return container_of(panel, struct visionox_rm69299, panel); > > +} > > + > > +static int visionox_rm69299_power_on(struct visionox_rm69299 *ctx) > > +{ > > + int ret; > > + > > + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); > > + if (ret < 0) > > + return ret; > > + > > + /* > > + * Reset sequence of visionox panel requires the panel to be > > + * out of reset for 10ms, followed by being held in reset > > + * for 10ms and then out again > > + */ > > + gpiod_set_value(ctx->reset_gpio, 1); > > + usleep_range(10000, 20000); > > + gpiod_set_value(ctx->reset_gpio, 0); > > + usleep_range(10000, 20000); > > + gpiod_set_value(ctx->reset_gpio, 1); > > + usleep_range(10000, 20000); > > + > > + return 0; > > +} > > + > > +static int visionox_rm69299_power_off(struct visionox_rm69299 *ctx) > > +{ > > + gpiod_set_value(ctx->reset_gpio, 0); > > + > > + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); > > +} > > + > > +static int visionox_rm69299_unprepare(struct drm_panel *panel) > > +{ > > + struct visionox_rm69299 *ctx = panel_to_ctx(panel); > > + int ret; > > + > > + ctx->dsi->mode_flags = 0; > > + > > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); > > + if (ret < 0) > > + DRM_DEV_ERROR(ctx->panel.dev, > > + "set_display_off cmd failed ret = %d\n", ret); > > + > > + /* 120ms delay required here as per DCS spec */ > > + msleep(120); > > + > > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); > > + if (ret < 0) { > > + DRM_DEV_ERROR(ctx->panel.dev, > > + "enter_sleep cmd failed ret = %d\n", ret); > > + } > > + > > + ret = visionox_rm69299_power_off(ctx); > > + > > + ctx->prepared = false; > > + return ret; > > +} > > + > > +static int visionox_rm69299_prepare(struct drm_panel *panel) > > +{ > > + struct visionox_rm69299 *ctx = panel_to_ctx(panel); > > + int ret; > > + > > + if (ctx->prepared) > > + return 0; > > + > > + ret = visionox_rm69299_power_on(ctx); > > + if (ret < 0) > > + return ret; > > + > > + ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM; > > + > > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xfe, 0x00 }, 2); > > + if (ret < 0) { > > + DRM_DEV_ERROR(ctx->panel.dev, > > + "cmd set tx 0 failed, ret = %d\n", ret); > > + goto power_off; > > + } > > + > > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xc2, 0x08 }, 2); > > + if (ret < 0) { > > + DRM_DEV_ERROR(ctx->panel.dev, > > + "cmd set tx 1 failed, ret = %d\n", ret); > > + goto power_off; > > + } > > + > > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x35, 0x00 }, 2); > > + if (ret < 0) { > > + DRM_DEV_ERROR(ctx->panel.dev, > > + "cmd set tx 2 failed, ret = %d\n", ret); > > + goto power_off; > > + } > > + > > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x51, 0xff }, 2); > > + if (ret < 0) { > > + DRM_DEV_ERROR(ctx->panel.dev, > > + "cmd set tx 3 failed, ret = %d\n", ret); > > + goto power_off; > > + } > > + > > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); > > + if (ret < 0) { > > + DRM_DEV_ERROR(ctx->panel.dev, > > + "exit_sleep_mode cmd failed ret = %d\n", ret); > > + goto power_off; > > + } > > + > > + /* Per DSI spec wait 120ms after sending exit sleep DCS command */ > > + msleep(120); > > + > > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); > > + if (ret < 0) { > > + DRM_DEV_ERROR(ctx->panel.dev, > > + "set_display_on cmd failed ret = %d\n", ret); > > + goto power_off; > > + } > > + > > + /* Per DSI spec wait 120ms after sending set_display_on DCS command */ > > + msleep(120); > > + > > + ctx->prepared = true; > > + > > + return 0; > > + > > +power_off: > > + return ret; > > +} > > + > > +static const struct drm_display_mode visionox_rm69299_1080x2248_60hz = { > > + .name = "1080x2248", > > + .clock = 158695, > > + .hdisplay = 1080, > > + .hsync_start = 1080 + 26, > > + .hsync_end = 1080 + 26 + 2, > > + .htotal = 1080 + 26 + 2 + 36, > > + .vdisplay = 2248, > > + .vsync_start = 2248 + 56, > > + .vsync_end = 2248 + 56 + 4, > > + .vtotal = 2248 + 56 + 4 + 4, > > + .vrefresh = 60, > > + .flags = 0, > > +}; > > + > > +static int visionox_rm69299_get_modes(struct drm_panel *panel, > > + struct drm_connector *connector) > > +{ > > + struct visionox_rm69299 *ctx = panel_to_ctx(panel); > > + struct drm_display_mode *mode; > > + > > + mode = drm_mode_create(connector->dev); > > + if (!mode) { > > + DRM_DEV_ERROR(ctx->panel.dev, > > + "failed to create a new display mode\n"); > > + return 0; > > + } > > + > > + connector->display_info.width_mm = 74; > > + connector->display_info.height_mm = 131; > > + drm_mode_copy(mode, &visionox_rm69299_1080x2248_60hz); > > + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; > > + drm_mode_probed_add(connector, mode); > > + > > + return 1; > > +} > > + > > +static const struct drm_panel_funcs visionox_rm69299_drm_funcs = { > > + .unprepare = visionox_rm69299_unprepare, > > + .prepare = visionox_rm69299_prepare, > > + .get_modes = visionox_rm69299_get_modes, > > +}; > > + > > +static int visionox_rm69299_probe(struct mipi_dsi_device *dsi) > > +{ > > + struct device *dev = &dsi->dev; > > + struct visionox_rm69299 *ctx; > > + int ret; > > + > > + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); > > + if (!ctx) > > + return -ENOMEM; > > + > > + mipi_dsi_set_drvdata(dsi, ctx); > > + > > + ctx->panel.dev = dev; > > + ctx->dsi = dsi; > > + > > + ctx->supplies[0].supply = "vdda"; > > + ctx->supplies[1].supply = "vdd3p3"; > > + > > + ret = devm_regulator_bulk_get(ctx->panel.dev, ARRAY_SIZE(ctx->supplies), > > + ctx->supplies); > > + if (ret < 0) > > + return ret; > > + > > + ctx->reset_gpio = devm_gpiod_get(ctx->panel.dev, > > + "reset", GPIOD_OUT_LOW); > > + if (IS_ERR(ctx->reset_gpio)) { > > + DRM_DEV_ERROR(dev, "cannot get reset gpio %ld\n", > > + PTR_ERR(ctx->reset_gpio)); > > + return PTR_ERR(ctx->reset_gpio); > > + } > > + > > + drm_panel_init(&ctx->panel, dev, &visionox_rm69299_drm_funcs, > > + DRM_MODE_CONNECTOR_DSI); > > + ctx->panel.dev = dev; > > + ctx->panel.funcs = &visionox_rm69299_drm_funcs; > > + drm_panel_add(&ctx->panel); > > + > > + dsi->lanes = 4; > > + dsi->format = MIPI_DSI_FMT_RGB888; > > + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM | > > + MIPI_DSI_CLOCK_NON_CONTINUOUS; > > + ret = mipi_dsi_attach(dsi); > > + if (ret < 0) { > > + DRM_DEV_ERROR(dev, "dsi attach failed ret = %d\n", ret); > > + goto err_dsi_attach; > > + } > > + > > + ret = regulator_set_load(ctx->supplies[0].consumer, 32000); > > + if (ret) { > > + DRM_DEV_ERROR(dev, > > + "regulator set load failed for vdda supply ret = %d\n", > > + ret); > > + goto err_set_load; > > + } > > + > > + ret = regulator_set_load(ctx->supplies[1].consumer, 13200); > > + if (ret) { > > + DRM_DEV_ERROR(dev, > > + "regulator set load failed for vdd3p3 supply ret = %d\n", > > + ret); > > + goto err_set_load; > > + } > > + > > + return 0; > > + > > +err_set_load: > > + mipi_dsi_detach(dsi); > > +err_dsi_attach: > > + drm_panel_remove(&ctx->panel); > > + return ret; > > +} > > + > > +static int visionox_rm69299_remove(struct mipi_dsi_device *dsi) > > +{ > > + struct visionox_rm69299 *ctx = mipi_dsi_get_drvdata(dsi); > > + > > + mipi_dsi_detach(ctx->dsi); > > + mipi_dsi_device_unregister(ctx->dsi); > > + > > + drm_panel_remove(&ctx->panel); > > + return 0; > > +} > > + > > +static const struct of_device_id visionox_rm69299_of_match[] = { > > + { > > + .compatible = "visionox,rm69299-1080p-display", > > + } > > +}; > > +MODULE_DEVICE_TABLE(of, visionox_rm69299_of_match); > > + > > +static struct mipi_dsi_driver visionox_rm69299_driver = { > > + .driver = { > > + .name = "panel-visionox-rm69299", > > + .of_match_table = visionox_rm69299_of_match, > > + }, > > + .probe = visionox_rm69299_probe, > > + .remove = visionox_rm69299_remove, > > +}; > > +module_mipi_dsi_driver(visionox_rm69299_driver); > > + > > +MODULE_DESCRIPTION("Visionox RM69299 DSI Panel Driver"); > > + > > -- > > 2.25.1 > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver 2020-05-14 3:35 ` Dave Airlie @ 2020-05-14 4:43 ` Sam Ravnborg 0 siblings, 0 replies; 13+ messages in thread From: Sam Ravnborg @ 2020-05-14 4:43 UTC (permalink / raw) To: Dave Airlie Cc: Sean Paul, devicetree, linux-arm-msm, Harigovindan P, dri-devel, Matthias Kaehlcke, Sean Paul, freedreno Hi Dave. On Thu, May 14, 2020 at 01:35:22PM +1000, Dave Airlie wrote: > On Thu, 7 May 2020 at 04:57, Sam Ravnborg <sam@ravnborg.org> wrote: > > > > Hi Harigovindan > > > > On Wed, Apr 29, 2020 at 11:15:14AM +0530, Harigovindan P wrote: > > > Add support for Visionox panel driver. > > > > > > Signed-off-by: Harigovindan P <harigovi@codeaurora.org> > > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org> > > > > Thanks for your persistence on this. > > Patch applied. > > > > I fixed a few lingering --strict releated checkpatch warnings > > when I applied. > > > > Sam > > I'm seeing > > WARNING: modpost: missing MODULE_LICENSE() in > drivers/gpu/drm/panel/panel-visionox-rm69299.o > > Can we fix that up? The patch is in drm-misc-next: e41b49b7e4d4ad9755af4813a57b5f6a09e357d7 "drm: panel: add MODULE_LICENSE to panel-visionox-rm69299.c" Holler if this does not fix it or we need to expedit it somehow. Sam > > Dave. > > > > > > --- > > > > > > Changes in v2: > > > - Dropping redundant space in Kconfig(Sam Ravnborg). > > > - Changing structure for include files(Sam Ravnborg). > > > - Removing backlight related code and functions(Sam Ravnborg). > > > - Removing repeated printing of error message(Sam Ravnborg). > > > - Adding drm_connector as an argument for get_modes function. > > > Changes in v3: > > > - Adding arguments for drm_panel_init to support against mainline. > > > Changes in v4: > > > - Removing error messages from regulator_set_load. > > > - Removing dev struct entry. > > > - Removing checks. > > > - Dropping empty comment lines. > > > Changes in v5: > > > - Removing unused struct member variables. > > > - Removing blank lines. > > > - Fixed indentation. > > > - Invoking dsi_detach and panel_remove while early exiting from probe. > > > Changes in v6: > > > - Changed "35597" to "rm69299" for power_on function. > > > - Removing rm69299_config since it supports single type of panel for now. > > > - Fixed alignment. > > > - Using goto statements when regulator_set_load fails. > > > Changes in v7: > > > - Added new goto statement when regulator_set_load fails. > > > Changes in v8,v9,v10: > > > - Had changes in first patch, did not make any change in panel driver. > > > Changes in v11: > > > - Fixing checkpatch script errors. > > > - Updated assignment of panel.dev property in probe. > > > > > > drivers/gpu/drm/panel/Kconfig | 8 + > > > drivers/gpu/drm/panel/Makefile | 1 + > > > .../gpu/drm/panel/panel-visionox-rm69299.c | 304 ++++++++++++++++++ > > > 3 files changed, 313 insertions(+) > > > create mode 100644 drivers/gpu/drm/panel/panel-visionox-rm69299.c > > > > > > diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig > > > index d56258b9fcaf..4b6131f5893d 100644 > > > --- a/drivers/gpu/drm/panel/Kconfig > > > +++ b/drivers/gpu/drm/panel/Kconfig > > > @@ -444,6 +444,14 @@ config DRM_PANEL_TRULY_NT35597_WQXGA > > > Say Y here if you want to enable support for Truly NT35597 WQXGA Dual DSI > > > Video Mode panel > > > > > > +config DRM_PANEL_VISIONOX_RM69299 > > > + tristate "Visionox RM69299" > > > + depends on OF > > > + depends on DRM_MIPI_DSI > > > + help > > > + Say Y here if you want to enable support for Visionox > > > + RM69299 DSI Video Mode panel. > > > + > > > config DRM_PANEL_XINPENG_XPP055C272 > > > tristate "Xinpeng XPP055C272 panel driver" > > > depends on OF > > > diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile > > > index 2335a1e32ae0..8eac3e6fa82c 100644 > > > --- a/drivers/gpu/drm/panel/Makefile > > > +++ b/drivers/gpu/drm/panel/Makefile > > > @@ -47,4 +47,5 @@ obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o > > > obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o > > > obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o > > > obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o > > > +obj-$(CONFIG_DRM_PANEL_VISIONOX_RM69299) += panel-visionox-rm69299.o > > > obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o > > > diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c > > > new file mode 100644 > > > index 000000000000..3ef4cc80044a > > > --- /dev/null > > > +++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c > > > @@ -0,0 +1,304 @@ > > > +// SPDX-License-Identifier: GPL-2.0 > > > +/* > > > + * Copyright (c) 2019, The Linux Foundation. All rights reserved. > > > + */ > > > + > > > +#include <linux/delay.h> > > > +#include <linux/module.h> > > > +#include <linux/of_device.h> > > > +#include <linux/gpio/consumer.h> > > > +#include <linux/regulator/consumer.h> > > > + > > > +#include <video/mipi_display.h> > > > + > > > +#include <drm/drm_mipi_dsi.h> > > > +#include <drm/drm_modes.h> > > > +#include <drm/drm_panel.h> > > > +#include <drm/drm_print.h> > > > + > > > +struct visionox_rm69299 { > > > + struct drm_panel panel; > > > + struct regulator_bulk_data supplies[2]; > > > + struct gpio_desc *reset_gpio; > > > + struct mipi_dsi_device *dsi; > > > + bool prepared; > > > + bool enabled; > > > +}; > > > + > > > +static inline struct visionox_rm69299 *panel_to_ctx(struct drm_panel *panel) > > > +{ > > > + return container_of(panel, struct visionox_rm69299, panel); > > > +} > > > + > > > +static int visionox_rm69299_power_on(struct visionox_rm69299 *ctx) > > > +{ > > > + int ret; > > > + > > > + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); > > > + if (ret < 0) > > > + return ret; > > > + > > > + /* > > > + * Reset sequence of visionox panel requires the panel to be > > > + * out of reset for 10ms, followed by being held in reset > > > + * for 10ms and then out again > > > + */ > > > + gpiod_set_value(ctx->reset_gpio, 1); > > > + usleep_range(10000, 20000); > > > + gpiod_set_value(ctx->reset_gpio, 0); > > > + usleep_range(10000, 20000); > > > + gpiod_set_value(ctx->reset_gpio, 1); > > > + usleep_range(10000, 20000); > > > + > > > + return 0; > > > +} > > > + > > > +static int visionox_rm69299_power_off(struct visionox_rm69299 *ctx) > > > +{ > > > + gpiod_set_value(ctx->reset_gpio, 0); > > > + > > > + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); > > > +} > > > + > > > +static int visionox_rm69299_unprepare(struct drm_panel *panel) > > > +{ > > > + struct visionox_rm69299 *ctx = panel_to_ctx(panel); > > > + int ret; > > > + > > > + ctx->dsi->mode_flags = 0; > > > + > > > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); > > > + if (ret < 0) > > > + DRM_DEV_ERROR(ctx->panel.dev, > > > + "set_display_off cmd failed ret = %d\n", ret); > > > + > > > + /* 120ms delay required here as per DCS spec */ > > > + msleep(120); > > > + > > > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); > > > + if (ret < 0) { > > > + DRM_DEV_ERROR(ctx->panel.dev, > > > + "enter_sleep cmd failed ret = %d\n", ret); > > > + } > > > + > > > + ret = visionox_rm69299_power_off(ctx); > > > + > > > + ctx->prepared = false; > > > + return ret; > > > +} > > > + > > > +static int visionox_rm69299_prepare(struct drm_panel *panel) > > > +{ > > > + struct visionox_rm69299 *ctx = panel_to_ctx(panel); > > > + int ret; > > > + > > > + if (ctx->prepared) > > > + return 0; > > > + > > > + ret = visionox_rm69299_power_on(ctx); > > > + if (ret < 0) > > > + return ret; > > > + > > > + ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM; > > > + > > > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xfe, 0x00 }, 2); > > > + if (ret < 0) { > > > + DRM_DEV_ERROR(ctx->panel.dev, > > > + "cmd set tx 0 failed, ret = %d\n", ret); > > > + goto power_off; > > > + } > > > + > > > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xc2, 0x08 }, 2); > > > + if (ret < 0) { > > > + DRM_DEV_ERROR(ctx->panel.dev, > > > + "cmd set tx 1 failed, ret = %d\n", ret); > > > + goto power_off; > > > + } > > > + > > > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x35, 0x00 }, 2); > > > + if (ret < 0) { > > > + DRM_DEV_ERROR(ctx->panel.dev, > > > + "cmd set tx 2 failed, ret = %d\n", ret); > > > + goto power_off; > > > + } > > > + > > > + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x51, 0xff }, 2); > > > + if (ret < 0) { > > > + DRM_DEV_ERROR(ctx->panel.dev, > > > + "cmd set tx 3 failed, ret = %d\n", ret); > > > + goto power_off; > > > + } > > > + > > > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); > > > + if (ret < 0) { > > > + DRM_DEV_ERROR(ctx->panel.dev, > > > + "exit_sleep_mode cmd failed ret = %d\n", ret); > > > + goto power_off; > > > + } > > > + > > > + /* Per DSI spec wait 120ms after sending exit sleep DCS command */ > > > + msleep(120); > > > + > > > + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); > > > + if (ret < 0) { > > > + DRM_DEV_ERROR(ctx->panel.dev, > > > + "set_display_on cmd failed ret = %d\n", ret); > > > + goto power_off; > > > + } > > > + > > > + /* Per DSI spec wait 120ms after sending set_display_on DCS command */ > > > + msleep(120); > > > + > > > + ctx->prepared = true; > > > + > > > + return 0; > > > + > > > +power_off: > > > + return ret; > > > +} > > > + > > > +static const struct drm_display_mode visionox_rm69299_1080x2248_60hz = { > > > + .name = "1080x2248", > > > + .clock = 158695, > > > + .hdisplay = 1080, > > > + .hsync_start = 1080 + 26, > > > + .hsync_end = 1080 + 26 + 2, > > > + .htotal = 1080 + 26 + 2 + 36, > > > + .vdisplay = 2248, > > > + .vsync_start = 2248 + 56, > > > + .vsync_end = 2248 + 56 + 4, > > > + .vtotal = 2248 + 56 + 4 + 4, > > > + .vrefresh = 60, > > > + .flags = 0, > > > +}; > > > + > > > +static int visionox_rm69299_get_modes(struct drm_panel *panel, > > > + struct drm_connector *connector) > > > +{ > > > + struct visionox_rm69299 *ctx = panel_to_ctx(panel); > > > + struct drm_display_mode *mode; > > > + > > > + mode = drm_mode_create(connector->dev); > > > + if (!mode) { > > > + DRM_DEV_ERROR(ctx->panel.dev, > > > + "failed to create a new display mode\n"); > > > + return 0; > > > + } > > > + > > > + connector->display_info.width_mm = 74; > > > + connector->display_info.height_mm = 131; > > > + drm_mode_copy(mode, &visionox_rm69299_1080x2248_60hz); > > > + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; > > > + drm_mode_probed_add(connector, mode); > > > + > > > + return 1; > > > +} > > > + > > > +static const struct drm_panel_funcs visionox_rm69299_drm_funcs = { > > > + .unprepare = visionox_rm69299_unprepare, > > > + .prepare = visionox_rm69299_prepare, > > > + .get_modes = visionox_rm69299_get_modes, > > > +}; > > > + > > > +static int visionox_rm69299_probe(struct mipi_dsi_device *dsi) > > > +{ > > > + struct device *dev = &dsi->dev; > > > + struct visionox_rm69299 *ctx; > > > + int ret; > > > + > > > + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); > > > + if (!ctx) > > > + return -ENOMEM; > > > + > > > + mipi_dsi_set_drvdata(dsi, ctx); > > > + > > > + ctx->panel.dev = dev; > > > + ctx->dsi = dsi; > > > + > > > + ctx->supplies[0].supply = "vdda"; > > > + ctx->supplies[1].supply = "vdd3p3"; > > > + > > > + ret = devm_regulator_bulk_get(ctx->panel.dev, ARRAY_SIZE(ctx->supplies), > > > + ctx->supplies); > > > + if (ret < 0) > > > + return ret; > > > + > > > + ctx->reset_gpio = devm_gpiod_get(ctx->panel.dev, > > > + "reset", GPIOD_OUT_LOW); > > > + if (IS_ERR(ctx->reset_gpio)) { > > > + DRM_DEV_ERROR(dev, "cannot get reset gpio %ld\n", > > > + PTR_ERR(ctx->reset_gpio)); > > > + return PTR_ERR(ctx->reset_gpio); > > > + } > > > + > > > + drm_panel_init(&ctx->panel, dev, &visionox_rm69299_drm_funcs, > > > + DRM_MODE_CONNECTOR_DSI); > > > + ctx->panel.dev = dev; > > > + ctx->panel.funcs = &visionox_rm69299_drm_funcs; > > > + drm_panel_add(&ctx->panel); > > > + > > > + dsi->lanes = 4; > > > + dsi->format = MIPI_DSI_FMT_RGB888; > > > + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM | > > > + MIPI_DSI_CLOCK_NON_CONTINUOUS; > > > + ret = mipi_dsi_attach(dsi); > > > + if (ret < 0) { > > > + DRM_DEV_ERROR(dev, "dsi attach failed ret = %d\n", ret); > > > + goto err_dsi_attach; > > > + } > > > + > > > + ret = regulator_set_load(ctx->supplies[0].consumer, 32000); > > > + if (ret) { > > > + DRM_DEV_ERROR(dev, > > > + "regulator set load failed for vdda supply ret = %d\n", > > > + ret); > > > + goto err_set_load; > > > + } > > > + > > > + ret = regulator_set_load(ctx->supplies[1].consumer, 13200); > > > + if (ret) { > > > + DRM_DEV_ERROR(dev, > > > + "regulator set load failed for vdd3p3 supply ret = %d\n", > > > + ret); > > > + goto err_set_load; > > > + } > > > + > > > + return 0; > > > + > > > +err_set_load: > > > + mipi_dsi_detach(dsi); > > > +err_dsi_attach: > > > + drm_panel_remove(&ctx->panel); > > > + return ret; > > > +} > > > + > > > +static int visionox_rm69299_remove(struct mipi_dsi_device *dsi) > > > +{ > > > + struct visionox_rm69299 *ctx = mipi_dsi_get_drvdata(dsi); > > > + > > > + mipi_dsi_detach(ctx->dsi); > > > + mipi_dsi_device_unregister(ctx->dsi); > > > + > > > + drm_panel_remove(&ctx->panel); > > > + return 0; > > > +} > > > + > > > +static const struct of_device_id visionox_rm69299_of_match[] = { > > > + { > > > + .compatible = "visionox,rm69299-1080p-display", > > > + } > > > +}; > > > +MODULE_DEVICE_TABLE(of, visionox_rm69299_of_match); > > > + > > > +static struct mipi_dsi_driver visionox_rm69299_driver = { > > > + .driver = { > > > + .name = "panel-visionox-rm69299", > > > + .of_match_table = visionox_rm69299_of_match, > > > + }, > > > + .probe = visionox_rm69299_probe, > > > + .remove = visionox_rm69299_remove, > > > +}; > > > +module_mipi_dsi_driver(visionox_rm69299_driver); > > > + > > > +MODULE_DESCRIPTION("Visionox RM69299 DSI Panel Driver"); > > > + > > > -- > > > 2.25.1 > > > _______________________________________________ > > > dri-devel mailing list > > > dri-devel@lists.freedesktop.org > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v11 2/2] dt-bindings: documenting compatible string vendor "visionox" 2020-04-21 4:55 [PATCH v11 0/2] Add support for rm69299 Visionox panel driver and add devicetree bindings for visionox panel Harigovindan P 2020-04-21 4:55 ` [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver Harigovindan P @ 2020-04-21 4:55 ` Harigovindan P 2020-04-22 19:40 ` Rob Herring 2020-04-29 5:45 ` [PATCH v12 " Harigovindan P 2 siblings, 1 reply; 13+ messages in thread From: Harigovindan P @ 2020-04-21 4:55 UTC (permalink / raw) To: dri-devel, linux-arm-msm, freedreno, devicetree Cc: sean, seanpaul, Harigovindan P Documenting compatible string vendor "visionox" in vendor-prefix yaml file. Signed-off-by: Harigovindan P <harigovi@codeaurora.org> --- Changes in v11: - Added visionox compatible string in vendor-prefixes.yaml - Added as a part of checkpatch script error for panel driver. Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 66a7382add95..b2b8de90b87a 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -1047,6 +1047,8 @@ patternProperties: description: Tronsmart "^truly,.*": description: Truly Semiconductors Limited + "visionox,.*": + description: Visionox "^tsd,.*": description: Theobroma Systems Design und Consulting GmbH "^tyan,.*": -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v11 2/2] dt-bindings: documenting compatible string vendor "visionox" 2020-04-21 4:55 ` [PATCH v11 2/2] dt-bindings: documenting compatible string vendor "visionox" Harigovindan P @ 2020-04-22 19:40 ` Rob Herring 0 siblings, 0 replies; 13+ messages in thread From: Rob Herring @ 2020-04-22 19:40 UTC (permalink / raw) To: Harigovindan P Cc: sean, devicetree, linux-arm-msm, Harigovindan P, dri-devel, seanpaul, freedreno On Tue, 21 Apr 2020 10:25:08 +0530, Harigovindan P wrote: > Documenting compatible string vendor "visionox" in vendor-prefix yaml file. > > Signed-off-by: Harigovindan P <harigovi@codeaurora.org> > --- > Changes in v11: > - Added visionox compatible string in vendor-prefixes.yaml > - Added as a part of checkpatch script error for panel driver. > > Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ > 1 file changed, 2 insertions(+) > My bot found errors running 'make dt_binding_check' on your patch: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/vendor-prefixes.yaml: patternProperties:visionox,.*: {'description': 'Visionox'} is not valid under any of the given schemas (Possible causes of the failure): /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/vendor-prefixes.yaml: patternProperties:visionox,.*: 'not' is a required property Documentation/devicetree/bindings/Makefile:11: recipe for target 'Documentation/devicetree/bindings/vendor-prefixes.example.dts' failed make[1]: *** [Documentation/devicetree/bindings/vendor-prefixes.example.dts] Error 1 make[1]: *** Waiting for unfinished jobs.... warning: no schema found in file: Documentation/devicetree/bindings/vendor-prefixes.yaml /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/vendor-prefixes.yaml: ignoring, error in schema: patternProperties: visionox,.* warning: no schema found in file: Documentation/devicetree/bindings/vendor-prefixes.yaml /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/vendor-prefixes.yaml: ignoring, error in schema: patternProperties: visionox,.* Makefile:1300: recipe for target 'dt_binding_check' failed make: *** [dt_binding_check] Error 2 See https://patchwork.ozlabs.org/patch/1273941 If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date: pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade Please check and re-submit. _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v12 2/2] dt-bindings: documenting compatible string vendor "visionox" 2020-04-21 4:55 [PATCH v11 0/2] Add support for rm69299 Visionox panel driver and add devicetree bindings for visionox panel Harigovindan P 2020-04-21 4:55 ` [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver Harigovindan P 2020-04-21 4:55 ` [PATCH v11 2/2] dt-bindings: documenting compatible string vendor "visionox" Harigovindan P @ 2020-04-29 5:45 ` Harigovindan P 2020-05-05 15:40 ` Rob Herring 2020-05-06 18:56 ` Sam Ravnborg 2 siblings, 2 replies; 13+ messages in thread From: Harigovindan P @ 2020-04-29 5:45 UTC (permalink / raw) To: dri-devel, linux-arm-msm, freedreno, devicetree Cc: sean, seanpaul, Harigovindan P Documenting compatible string vendor "visionox" in vendor-prefix yaml file. Signed-off-by: Harigovindan P <harigovi@codeaurora.org> --- Changes in v11: - Added compatible string in vendor-prefix yaml file Changes in v12: - Fixed the string to clear dt_binding_check errors. Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 66a7382add95..1c86ebbeae20 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -1047,6 +1047,8 @@ patternProperties: description: Tronsmart "^truly,.*": description: Truly Semiconductors Limited + "^visionox,.*": + description: Visionox "^tsd,.*": description: Theobroma Systems Design und Consulting GmbH "^tyan,.*": -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v12 2/2] dt-bindings: documenting compatible string vendor "visionox" 2020-04-29 5:45 ` [PATCH v12 " Harigovindan P @ 2020-05-05 15:40 ` Rob Herring 2020-05-06 18:56 ` Sam Ravnborg 1 sibling, 0 replies; 13+ messages in thread From: Rob Herring @ 2020-05-05 15:40 UTC (permalink / raw) To: Harigovindan P Cc: freedreno, devicetree, linux-arm-msm, Harigovindan P, dri-devel, seanpaul, sean On Wed, 29 Apr 2020 11:15:15 +0530, Harigovindan P wrote: > Documenting compatible string vendor "visionox" in vendor-prefix yaml file. > > Signed-off-by: Harigovindan P <harigovi@codeaurora.org> > --- > Changes in v11: > - Added compatible string in vendor-prefix yaml file > > Changes in v12: > - Fixed the string to clear dt_binding_check errors. > > Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ > 1 file changed, 2 insertions(+) > Acked-by: Rob Herring <robh@kernel.org> _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v12 2/2] dt-bindings: documenting compatible string vendor "visionox" 2020-04-29 5:45 ` [PATCH v12 " Harigovindan P 2020-05-05 15:40 ` Rob Herring @ 2020-05-06 18:56 ` Sam Ravnborg 1 sibling, 0 replies; 13+ messages in thread From: Sam Ravnborg @ 2020-05-06 18:56 UTC (permalink / raw) To: Harigovindan P Cc: freedreno, devicetree, linux-arm-msm, dri-devel, seanpaul, sean On Wed, Apr 29, 2020 at 11:15:15AM +0530, Harigovindan P wrote: > Documenting compatible string vendor "visionox" in vendor-prefix yaml file. > > Signed-off-by: Harigovindan P <harigovi@codeaurora.org> Thanks, applied. Sam > --- > Changes in v11: > - Added compatible string in vendor-prefix yaml file > > Changes in v12: > - Fixed the string to clear dt_binding_check errors. > > Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml > index 66a7382add95..1c86ebbeae20 100644 > --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml > +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml > @@ -1047,6 +1047,8 @@ patternProperties: > description: Tronsmart > "^truly,.*": > description: Truly Semiconductors Limited > + "^visionox,.*": > + description: Visionox > "^tsd,.*": > description: Theobroma Systems Design und Consulting GmbH > "^tyan,.*": > -- > 2.25.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v11 0/2] Add support for rm69299 Visionox panel driver and add devicetree bindings for visionox panel @ 2020-04-21 4:51 Harigovindan P 2020-04-21 4:51 ` [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver Harigovindan P 0 siblings, 1 reply; 13+ messages in thread From: Harigovindan P @ 2020-04-21 4:51 UTC (permalink / raw) To: dri-devel, linux-arm-msm, freedreno, devicetree Cc: sean, seanpaul, Harigovindan P Adding support for visionox rm69299 panel driver and adding bindings for the same panel. https://patchwork.kernel.org/patch/11461943/ has already been added to drm-misc-next. Harigovindan P (2): drm/panel: add support for rm69299 visionox panel driver dt-bindings: documenting compatible string vendor "visionox" .../devicetree/bindings/vendor-prefixes.yaml | 2 + drivers/gpu/drm/panel/Kconfig | 8 + drivers/gpu/drm/panel/Makefile | 1 + .../gpu/drm/panel/panel-visionox-rm69299.c | 304 ++++++++++++++++++ 4 files changed, 315 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-visionox-rm69299.c -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver 2020-04-21 4:51 [PATCH v11 0/2] Add support for rm69299 Visionox panel driver and add devicetree bindings for visionox panel Harigovindan P @ 2020-04-21 4:51 ` Harigovindan P 0 siblings, 0 replies; 13+ messages in thread From: Harigovindan P @ 2020-04-21 4:51 UTC (permalink / raw) To: dri-devel, linux-arm-msm, freedreno, devicetree Cc: sean, seanpaul, Harigovindan P Add support for Visionox panel driver. Signed-off-by: Harigovindan P <harigovi@codeaurora.org> --- Changes in v2: - Dropping redundant space in Kconfig(Sam Ravnborg). - Changing structure for include files(Sam Ravnborg). - Removing backlight related code and functions(Sam Ravnborg). - Removing repeated printing of error message(Sam Ravnborg). - Adding drm_connector as an argument for get_modes function. Changes in v3: - Adding arguments for drm_panel_init to support against mainline. Changes in v4: - Removing error messages from regulator_set_load. - Removing dev struct entry. - Removing checks. - Dropping empty comment lines. Changes in v5: - Removing unused struct member variables. - Removing blank lines. - Fixed indentation. - Invoking dsi_detach and panel_remove while early exiting from probe. Changes in v6: - Changed "35597" to "rm69299" for power_on function. - Removing rm69299_config since it supports single type of panel for now. - Fixed alignment. - Using goto statements when regulator_set_load fails. Changes in v7: - Added new goto statement when regulator_set_load fails. Changes in v8,v9,v10: - Had changes in first patch, did not make any change in panel driver. Changes in v11: - Fixing checkpatch script errors. - Updated assignment of panel.dev property in probe. drivers/gpu/drm/panel/Kconfig | 8 + drivers/gpu/drm/panel/Makefile | 1 + .../gpu/drm/panel/panel-visionox-rm69299.c | 304 ++++++++++++++++++ 3 files changed, 313 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-visionox-rm69299.c diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index d56258b9fcaf..4b6131f5893d 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -444,6 +444,14 @@ config DRM_PANEL_TRULY_NT35597_WQXGA Say Y here if you want to enable support for Truly NT35597 WQXGA Dual DSI Video Mode panel +config DRM_PANEL_VISIONOX_RM69299 + tristate "Visionox RM69299" + depends on OF + depends on DRM_MIPI_DSI + help + Say Y here if you want to enable support for Visionox + RM69299 DSI Video Mode panel. + config DRM_PANEL_XINPENG_XPP055C272 tristate "Xinpeng XPP055C272 panel driver" depends on OF diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index 2335a1e32ae0..8eac3e6fa82c 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -47,4 +47,5 @@ obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o +obj-$(CONFIG_DRM_PANEL_VISIONOX_RM69299) += panel-visionox-rm69299.o obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c new file mode 100644 index 000000000000..3ef4cc80044a --- /dev/null +++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c @@ -0,0 +1,304 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#include <linux/delay.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/gpio/consumer.h> +#include <linux/regulator/consumer.h> + +#include <video/mipi_display.h> + +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_modes.h> +#include <drm/drm_panel.h> +#include <drm/drm_print.h> + +struct visionox_rm69299 { + struct drm_panel panel; + struct regulator_bulk_data supplies[2]; + struct gpio_desc *reset_gpio; + struct mipi_dsi_device *dsi; + bool prepared; + bool enabled; +}; + +static inline struct visionox_rm69299 *panel_to_ctx(struct drm_panel *panel) +{ + return container_of(panel, struct visionox_rm69299, panel); +} + +static int visionox_rm69299_power_on(struct visionox_rm69299 *ctx) +{ + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); + if (ret < 0) + return ret; + + /* + * Reset sequence of visionox panel requires the panel to be + * out of reset for 10ms, followed by being held in reset + * for 10ms and then out again + */ + gpiod_set_value(ctx->reset_gpio, 1); + usleep_range(10000, 20000); + gpiod_set_value(ctx->reset_gpio, 0); + usleep_range(10000, 20000); + gpiod_set_value(ctx->reset_gpio, 1); + usleep_range(10000, 20000); + + return 0; +} + +static int visionox_rm69299_power_off(struct visionox_rm69299 *ctx) +{ + gpiod_set_value(ctx->reset_gpio, 0); + + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); +} + +static int visionox_rm69299_unprepare(struct drm_panel *panel) +{ + struct visionox_rm69299 *ctx = panel_to_ctx(panel); + int ret; + + ctx->dsi->mode_flags = 0; + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); + if (ret < 0) + DRM_DEV_ERROR(ctx->panel.dev, + "set_display_off cmd failed ret = %d\n", ret); + + /* 120ms delay required here as per DCS spec */ + msleep(120); + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "enter_sleep cmd failed ret = %d\n", ret); + } + + ret = visionox_rm69299_power_off(ctx); + + ctx->prepared = false; + return ret; +} + +static int visionox_rm69299_prepare(struct drm_panel *panel) +{ + struct visionox_rm69299 *ctx = panel_to_ctx(panel); + int ret; + + if (ctx->prepared) + return 0; + + ret = visionox_rm69299_power_on(ctx); + if (ret < 0) + return ret; + + ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM; + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xfe, 0x00 }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 0 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0xc2, 0x08 }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 1 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x35, 0x00 }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 2 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]){ 0x51, 0xff }, 2); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "cmd set tx 3 failed, ret = %d\n", ret); + goto power_off; + } + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "exit_sleep_mode cmd failed ret = %d\n", ret); + goto power_off; + } + + /* Per DSI spec wait 120ms after sending exit sleep DCS command */ + msleep(120); + + ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); + if (ret < 0) { + DRM_DEV_ERROR(ctx->panel.dev, + "set_display_on cmd failed ret = %d\n", ret); + goto power_off; + } + + /* Per DSI spec wait 120ms after sending set_display_on DCS command */ + msleep(120); + + ctx->prepared = true; + + return 0; + +power_off: + return ret; +} + +static const struct drm_display_mode visionox_rm69299_1080x2248_60hz = { + .name = "1080x2248", + .clock = 158695, + .hdisplay = 1080, + .hsync_start = 1080 + 26, + .hsync_end = 1080 + 26 + 2, + .htotal = 1080 + 26 + 2 + 36, + .vdisplay = 2248, + .vsync_start = 2248 + 56, + .vsync_end = 2248 + 56 + 4, + .vtotal = 2248 + 56 + 4 + 4, + .vrefresh = 60, + .flags = 0, +}; + +static int visionox_rm69299_get_modes(struct drm_panel *panel, + struct drm_connector *connector) +{ + struct drm_connector *connector = panel->connector; + struct visionox_rm69299 *ctx = panel_to_ctx(panel); + struct drm_display_mode *mode; + + mode = drm_mode_create(connector->dev); + if (!mode) { + DRM_DEV_ERROR(ctx->panel.dev, + "failed to create a new display mode\n"); + return 0; + } + + connector->display_info.width_mm = 74; + connector->display_info.height_mm = 131; + drm_mode_copy(mode, &visionox_rm69299_1080x2248_60hz); + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; + drm_mode_probed_add(connector, mode); + + return 1; +} + +static const struct drm_panel_funcs visionox_rm69299_drm_funcs = { + .unprepare = visionox_rm69299_unprepare, + .prepare = visionox_rm69299_prepare, + .get_modes = visionox_rm69299_get_modes, +}; + +static int visionox_rm69299_probe(struct mipi_dsi_device *dsi) +{ + struct device *dev = &dsi->dev; + struct visionox_rm69299 *ctx; + int ret; + + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + mipi_dsi_set_drvdata(dsi, ctx); + + ctx->panel.dev = dev; + ctx->dsi = dsi; + + ctx->supplies[0].supply = "vdda"; + ctx->supplies[1].supply = "vdd3p3"; + + ret = devm_regulator_bulk_get(ctx->panel.dev, ARRAY_SIZE(ctx->supplies), + ctx->supplies); + if (ret < 0) + return ret; + + ctx->reset_gpio = devm_gpiod_get(ctx->panel.dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(ctx->reset_gpio)) { + DRM_DEV_ERROR(dev, "cannot get reset gpio %ld\n", + PTR_ERR(ctx->reset_gpio)); + return PTR_ERR(ctx->reset_gpio); + } + + drm_panel_init(&ctx->panel, dev, &visionox_rm69299_drm_funcs, + DRM_MODE_CONNECTOR_DSI); + ctx->panel.dev = dev; + ctx->panel.funcs = &visionox_rm69299_drm_funcs; + drm_panel_add(&ctx->panel); + + dsi->lanes = 4; + dsi->format = MIPI_DSI_FMT_RGB888; + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM | + MIPI_DSI_CLOCK_NON_CONTINUOUS; + ret = mipi_dsi_attach(dsi); + if (ret < 0) { + DRM_DEV_ERROR(dev, "dsi attach failed ret = %d\n", ret); + goto err_dsi_attach; + } + + ret = regulator_set_load(ctx->supplies[0].consumer, 32000); + if (ret) { + DRM_DEV_ERROR(dev, + "regulator set load failed for vdda supply ret = %d\n", + ret); + goto err_set_load; + } + + ret = regulator_set_load(ctx->supplies[1].consumer, 13200); + if (ret) { + DRM_DEV_ERROR(dev, + "regulator set load failed for vdd3p3 supply ret = %d\n", + ret); + goto err_set_load; + } + + return 0; + +err_set_load: + mipi_dsi_detach(dsi); +err_dsi_attach: + drm_panel_remove(&ctx->panel); + return ret; +} + +static int visionox_rm69299_remove(struct mipi_dsi_device *dsi) +{ + struct visionox_rm69299 *ctx = mipi_dsi_get_drvdata(dsi); + + mipi_dsi_detach(ctx->dsi); + mipi_dsi_device_unregister(ctx->dsi); + + drm_panel_remove(&ctx->panel); + return 0; +} + +static const struct of_device_id visionox_rm69299_of_match[] = { + { + .compatible = "visionox,rm69299-1080p-display", + } +}; +MODULE_DEVICE_TABLE(of, visionox_rm69299_of_match); + +static struct mipi_dsi_driver visionox_rm69299_driver = { + .driver = { + .name = "panel-visionox-rm69299", + .of_match_table = visionox_rm69299_of_match, + }, + .probe = visionox_rm69299_probe, + .remove = visionox_rm69299_remove, +}; +module_mipi_dsi_driver(visionox_rm69299_driver); + +MODULE_DESCRIPTION("Visionox RM69299 DSI Panel Driver"); -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2020-05-14 4:43 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-21 4:55 [PATCH v11 0/2] Add support for rm69299 Visionox panel driver and add devicetree bindings for visionox panel Harigovindan P 2020-04-21 4:55 ` [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver Harigovindan P 2020-04-21 20:00 ` Matthias Kaehlcke 2020-04-29 5:45 ` Harigovindan P 2020-05-06 18:57 ` Sam Ravnborg 2020-05-14 3:35 ` Dave Airlie 2020-05-14 4:43 ` Sam Ravnborg 2020-04-21 4:55 ` [PATCH v11 2/2] dt-bindings: documenting compatible string vendor "visionox" Harigovindan P 2020-04-22 19:40 ` Rob Herring 2020-04-29 5:45 ` [PATCH v12 " Harigovindan P 2020-05-05 15:40 ` Rob Herring 2020-05-06 18:56 ` Sam Ravnborg -- strict thread matches above, loose matches on Subject: below -- 2020-04-21 4:51 [PATCH v11 0/2] Add support for rm69299 Visionox panel driver and add devicetree bindings for visionox panel Harigovindan P 2020-04-21 4:51 ` [PATCH v11 1/2] drm/panel: add support for rm69299 visionox panel driver Harigovindan P
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).