Commit 24489ba0 authored by Ondrej Jirman's avatar Ondrej Jirman Committed by Sam Ravnborg
Browse files

drm/panel: st7703: Rename functions from jh057n prefix to st7703



This is done so that code that's not specific to a particular
jh057n panel is named after the controller. Functions specific
to the panel are kept named after the panel.

Signed-off-by: default avatarOndrej Jirman <megous@megous.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Tested-by: default avatarGuido Günther <agx@sigxcpu.org>
Reviewed-by: default avatarGuido Günther <agx@sigxcpu.org>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200701162928.1638874-6-megous@megous.com
parent a74e81a5
Loading
Loading
Loading
Loading
+46 −44
Original line number Original line Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
// SPDX-License-Identifier: GPL-2.0
/*
/*
 * Rockteck jh057n00900 5.5" MIPI-DSI panel driver
 * Driver for panels based on Sitronix ST7703 controller, souch as:
 *
 * - Rocktech jh057n00900 5.5" MIPI-DSI panel
 *
 *
 * Copyright (C) Purism SPC 2019
 * Copyright (C) Purism SPC 2019
 */
 */
@@ -21,7 +23,7 @@
#include <drm/drm_panel.h>
#include <drm/drm_panel.h>
#include <drm/drm_print.h>
#include <drm/drm_print.h>


#define DRV_NAME "panel-rocktech-jh057n00900"
#define DRV_NAME "panel-sitronix-st7703"


/* Manufacturer specific Commands send via DSI */
/* Manufacturer specific Commands send via DSI */
#define ST7703_CMD_ALL_PIXEL_OFF 0x22
#define ST7703_CMD_ALL_PIXEL_OFF 0x22
@@ -45,7 +47,7 @@
#define ST7703_CMD_SETGIP1	 0xE9
#define ST7703_CMD_SETGIP1	 0xE9
#define ST7703_CMD_SETGIP2	 0xEA
#define ST7703_CMD_SETGIP2	 0xEA


struct jh057n {
struct st7703 {
	struct device *dev;
	struct device *dev;
	struct drm_panel panel;
	struct drm_panel panel;
	struct gpio_desc *reset_gpio;
	struct gpio_desc *reset_gpio;
@@ -56,9 +58,9 @@ struct jh057n {
	struct dentry *debugfs;
	struct dentry *debugfs;
};
};


static inline struct jh057n *panel_to_jh057n(struct drm_panel *panel)
static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
{
{
	return container_of(panel, struct jh057n, panel);
	return container_of(panel, struct st7703, panel);
}
}


#define dsi_generic_write_seq(dsi, seq...) do {				\
#define dsi_generic_write_seq(dsi, seq...) do {				\
@@ -69,7 +71,7 @@ static inline struct jh057n *panel_to_jh057n(struct drm_panel *panel)
			return ret;					\
			return ret;					\
	} while (0)
	} while (0)


static int jh057n_init_sequence(struct jh057n *ctx)
static int jh057n_init_sequence(struct st7703 *ctx)
{
{
	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
	struct device *dev = ctx->dev;
	struct device *dev = ctx->dev;
@@ -141,9 +143,9 @@ static int jh057n_init_sequence(struct jh057n *ctx)
	return 0;
	return 0;
}
}


static int jh057n_enable(struct drm_panel *panel)
static int st7703_enable(struct drm_panel *panel)
{
{
	struct jh057n *ctx = panel_to_jh057n(panel);
	struct st7703 *ctx = panel_to_st7703(panel);
	int ret;
	int ret;


	ret = jh057n_init_sequence(ctx);
	ret = jh057n_init_sequence(ctx);
@@ -156,17 +158,17 @@ static int jh057n_enable(struct drm_panel *panel)
	return 0;
	return 0;
}
}


static int jh057n_disable(struct drm_panel *panel)
static int st7703_disable(struct drm_panel *panel)
{
{
	struct jh057n *ctx = panel_to_jh057n(panel);
	struct st7703 *ctx = panel_to_st7703(panel);
	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);


	return mipi_dsi_dcs_set_display_off(dsi);
	return mipi_dsi_dcs_set_display_off(dsi);
}
}


static int jh057n_unprepare(struct drm_panel *panel)
static int st7703_unprepare(struct drm_panel *panel)
{
{
	struct jh057n *ctx = panel_to_jh057n(panel);
	struct st7703 *ctx = panel_to_st7703(panel);


	if (!ctx->prepared)
	if (!ctx->prepared)
		return 0;
		return 0;
@@ -178,9 +180,9 @@ static int jh057n_unprepare(struct drm_panel *panel)
	return 0;
	return 0;
}
}


static int jh057n_prepare(struct drm_panel *panel)
static int st7703_prepare(struct drm_panel *panel)
{
{
	struct jh057n *ctx = panel_to_jh057n(panel);
	struct st7703 *ctx = panel_to_st7703(panel);
	int ret;
	int ret;


	if (ctx->prepared)
	if (ctx->prepared)
@@ -229,10 +231,10 @@ static const struct drm_display_mode default_mode = {
	.height_mm   = 130,
	.height_mm   = 130,
};
};


static int jh057n_get_modes(struct drm_panel *panel,
static int st7703_get_modes(struct drm_panel *panel,
			    struct drm_connector *connector)
			    struct drm_connector *connector)
{
{
	struct jh057n *ctx = panel_to_jh057n(panel);
	struct st7703 *ctx = panel_to_st7703(panel);
	struct drm_display_mode *mode;
	struct drm_display_mode *mode;


	mode = drm_mode_duplicate(connector->dev, &default_mode);
	mode = drm_mode_duplicate(connector->dev, &default_mode);
@@ -253,17 +255,17 @@ static int jh057n_get_modes(struct drm_panel *panel,
	return 1;
	return 1;
}
}


static const struct drm_panel_funcs jh057n_drm_funcs = {
static const struct drm_panel_funcs st7703_drm_funcs = {
	.disable   = jh057n_disable,
	.disable   = st7703_disable,
	.unprepare = jh057n_unprepare,
	.unprepare = st7703_unprepare,
	.prepare   = jh057n_prepare,
	.prepare   = st7703_prepare,
	.enable	   = jh057n_enable,
	.enable	   = st7703_enable,
	.get_modes = jh057n_get_modes,
	.get_modes = st7703_get_modes,
};
};


static int allpixelson_set(void *data, u64 val)
static int allpixelson_set(void *data, u64 val)
{
{
	struct jh057n *ctx = data;
	struct st7703 *ctx = data;
	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);


	DRM_DEV_DEBUG_DRIVER(ctx->dev, "Setting all pixels on\n");
	DRM_DEV_DEBUG_DRIVER(ctx->dev, "Setting all pixels on\n");
@@ -281,7 +283,7 @@ static int allpixelson_set(void *data, u64 val)
DEFINE_SIMPLE_ATTRIBUTE(allpixelson_fops, NULL,
DEFINE_SIMPLE_ATTRIBUTE(allpixelson_fops, NULL,
			allpixelson_set, "%llu\n");
			allpixelson_set, "%llu\n");


static void jh057n_debugfs_init(struct jh057n *ctx)
static void st7703_debugfs_init(struct st7703 *ctx)
{
{
	ctx->debugfs = debugfs_create_dir(DRV_NAME, NULL);
	ctx->debugfs = debugfs_create_dir(DRV_NAME, NULL);


@@ -289,16 +291,16 @@ static void jh057n_debugfs_init(struct jh057n *ctx)
			    &allpixelson_fops);
			    &allpixelson_fops);
}
}


static void jh057n_debugfs_remove(struct jh057n *ctx)
static void st7703_debugfs_remove(struct st7703 *ctx)
{
{
	debugfs_remove_recursive(ctx->debugfs);
	debugfs_remove_recursive(ctx->debugfs);
	ctx->debugfs = NULL;
	ctx->debugfs = NULL;
}
}


static int jh057n_probe(struct mipi_dsi_device *dsi)
static int st7703_probe(struct mipi_dsi_device *dsi)
{
{
	struct device *dev = &dsi->dev;
	struct device *dev = &dsi->dev;
	struct jh057n *ctx;
	struct st7703 *ctx;
	int ret;
	int ret;


	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
@@ -339,7 +341,7 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
		return ret;
		return ret;
	}
	}


	drm_panel_init(&ctx->panel, dev, &jh057n_drm_funcs,
	drm_panel_init(&ctx->panel, dev, &st7703_drm_funcs,
		       DRM_MODE_CONNECTOR_DSI);
		       DRM_MODE_CONNECTOR_DSI);


	ret = drm_panel_of_backlight(&ctx->panel);
	ret = drm_panel_of_backlight(&ctx->panel);
@@ -362,13 +364,13 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
		     drm_mode_vrefresh(&default_mode),
		     drm_mode_vrefresh(&default_mode),
		     mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);
		     mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);


	jh057n_debugfs_init(ctx);
	st7703_debugfs_init(ctx);
	return 0;
	return 0;
}
}


static void jh057n_shutdown(struct mipi_dsi_device *dsi)
static void st7703_shutdown(struct mipi_dsi_device *dsi)
{
{
	struct jh057n *ctx = mipi_dsi_get_drvdata(dsi);
	struct st7703 *ctx = mipi_dsi_get_drvdata(dsi);
	int ret;
	int ret;


	ret = drm_panel_unprepare(&ctx->panel);
	ret = drm_panel_unprepare(&ctx->panel);
@@ -382,12 +384,12 @@ static void jh057n_shutdown(struct mipi_dsi_device *dsi)
			      ret);
			      ret);
}
}


static int jh057n_remove(struct mipi_dsi_device *dsi)
static int st7703_remove(struct mipi_dsi_device *dsi)
{
{
	struct jh057n *ctx = mipi_dsi_get_drvdata(dsi);
	struct st7703 *ctx = mipi_dsi_get_drvdata(dsi);
	int ret;
	int ret;


	jh057n_shutdown(dsi);
	st7703_shutdown(dsi);


	ret = mipi_dsi_detach(dsi);
	ret = mipi_dsi_detach(dsi);
	if (ret < 0)
	if (ret < 0)
@@ -396,28 +398,28 @@ static int jh057n_remove(struct mipi_dsi_device *dsi)


	drm_panel_remove(&ctx->panel);
	drm_panel_remove(&ctx->panel);


	jh057n_debugfs_remove(ctx);
	st7703_debugfs_remove(ctx);


	return 0;
	return 0;
}
}


static const struct of_device_id jh057n_of_match[] = {
static const struct of_device_id st7703_of_match[] = {
	{ .compatible = "rocktech,jh057n00900" },
	{ .compatible = "rocktech,jh057n00900" },
	{ /* sentinel */ }
	{ /* sentinel */ }
};
};
MODULE_DEVICE_TABLE(of, jh057n_of_match);
MODULE_DEVICE_TABLE(of, st7703_of_match);


static struct mipi_dsi_driver jh057n_driver = {
static struct mipi_dsi_driver st7703_driver = {
	.probe	= jh057n_probe,
	.probe	= st7703_probe,
	.remove = jh057n_remove,
	.remove = st7703_remove,
	.shutdown = jh057n_shutdown,
	.shutdown = st7703_shutdown,
	.driver = {
	.driver = {
		.name = DRV_NAME,
		.name = DRV_NAME,
		.of_match_table = jh057n_of_match,
		.of_match_table = st7703_of_match,
	},
	},
};
};
module_mipi_dsi_driver(jh057n_driver);
module_mipi_dsi_driver(st7703_driver);


MODULE_AUTHOR("Guido Günther <agx@sigxcpu.org>");
MODULE_AUTHOR("Guido Günther <agx@sigxcpu.org>");
MODULE_DESCRIPTION("DRM driver for Rocktech JH057N00900 MIPI DSI panel");
MODULE_DESCRIPTION("DRM driver for Sitronix ST7703 based MIPI DSI panels");
MODULE_LICENSE("GPL v2");
MODULE_LICENSE("GPL v2");