Commit 0efa7924 authored by Dario Binacchi's avatar Dario Binacchi Committed by Neil Armstrong
Browse files

drm/panel: ilitek-ili9806e: split core and DSI logic



Split the driver to support multiple transport buses. The core logic
(power, GPIO, backlight) is moved to a dedicated core module, while
DSI-specific code is restricted to the DSI module.

Introduce DRM_PANEL_ILITEK_ILI9806E_CORE as a hidden Kconfig symbol
selected by the bus-specific configuration.

Signed-off-by: default avatarDario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20260318073346.18041-3-dario.binacchi@amarulasolutions.com
parent 3bdd847a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8028,7 +8028,7 @@ F: drivers/gpu/drm/panel/panel-ilitek-ili9805.c
DRM DRIVER FOR ILITEK ILI9806E PANELS
M:	Michael Walle <mwalle@kernel.org>
S:	Maintained
F:	drivers/gpu/drm/panel/panel-ilitek-ili9806e-dsi.c
F:	drivers/gpu/drm/panel/panel-ilitek-ili9806e-*
DRM DRIVER FOR JADARD JD9365DA-H3 MIPI-DSI LCD PANELS
M:	Jagan Teki <jagan@edgeble.ai>
+4 −0
Original line number Diff line number Diff line
@@ -268,11 +268,15 @@ config DRM_PANEL_ILITEK_ILI9805
	  Say Y if you want to enable support for panels based on the
	  Ilitek ILI9805 controller.

config DRM_PANEL_ILITEK_ILI9806E_CORE
	tristate

config DRM_PANEL_ILITEK_ILI9806E_DSI
	tristate "Ilitek ILI9806E-based DSI panels"
	depends on OF
	depends on DRM_MIPI_DSI
	depends on BACKLIGHT_CLASS_DEVICE
	select DRM_PANEL_ILITEK_ILI9806E_CORE
	help
	  Say Y if you want to enable support for panels based on the
	  Ilitek ILI9806E controller using DSI.
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ obj-$(CONFIG_DRM_PANEL_HYDIS_HV101HD1) += panel-hydis-hv101hd1.o
obj-$(CONFIG_DRM_PANEL_ILITEK_IL9322) += panel-ilitek-ili9322.o
obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9341) += panel-ilitek-ili9341.o
obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9805) += panel-ilitek-ili9805.o
obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9806E_CORE) += panel-ilitek-ili9806e-core.o
obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9806E_DSI) += panel-ilitek-ili9806e-dsi.o
obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9881C) += panel-ilitek-ili9881c.o
obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9882T) += panel-ilitek-ili9882t.o
+129 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Ilitek ILI9806E core driver.
 *
 * Copyright (c) 2026 Amarula Solutions, Dario Binacchi <dario.binacchi@amarulasolutions.com>
 */

#include <drm/drm_panel.h>

#include <linux/delay.h>
#include <linux/export.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>

#include "panel-ilitek-ili9806e-core.h"

struct ili9806e {
	void *transport;
	struct drm_panel panel;

	struct regulator_bulk_data supplies[2];
	struct gpio_desc *reset_gpio;
};

static const char * const regulator_names[] = {
	"vdd",
	"vccio",
};

void *ili9806e_get_transport(struct drm_panel *panel)
{
	struct ili9806e *ctx = container_of(panel, struct ili9806e, panel);

	return ctx->transport;
}
EXPORT_SYMBOL_GPL(ili9806e_get_transport);

int ili9806e_power_on(struct device *dev)
{
	struct ili9806e *ctx = dev_get_drvdata(dev);
	int ret;

	gpiod_set_value(ctx->reset_gpio, 1);

	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
	if (ret) {
		dev_err(dev, "regulator bulk enable failed: %d\n", ret);
		return ret;
	}

	usleep_range(10000, 20000);
	gpiod_set_value(ctx->reset_gpio, 0);
	usleep_range(10000, 20000);

	return 0;
}
EXPORT_SYMBOL_GPL(ili9806e_power_on);

int ili9806e_power_off(struct device *dev)
{
	struct ili9806e *ctx = dev_get_drvdata(dev);
	int ret;

	gpiod_set_value(ctx->reset_gpio, 1);

	ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
	if (ret)
		dev_err(dev, "regulator bulk disable failed: %d\n", ret);

	return ret;
}
EXPORT_SYMBOL_GPL(ili9806e_power_off);

int ili9806e_probe(struct device *dev, void *transport,
		  const struct drm_panel_funcs *funcs,
		  int connector_type)
{
	struct ili9806e *ctx;
	int i, ret;

	ctx = devm_kzalloc(dev, sizeof(struct ili9806e), GFP_KERNEL);
	if (!ctx)
		return -ENOMEM;

	dev_set_drvdata(dev, ctx);
	ctx->transport = transport;

	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++)
		ctx->supplies[i].supply = regulator_names[i];

	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
				      ctx->supplies);
	if (ret)
		return dev_err_probe(dev, ret, "failed to get regulators\n");

	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
	if (IS_ERR(ctx->reset_gpio))
		return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
				     "Failed to get reset-gpios\n");

	drm_panel_init(&ctx->panel, dev, funcs, connector_type);

	ret = drm_panel_of_backlight(&ctx->panel);
	if (ret)
		return dev_err_probe(dev, ret, "Failed to get backlight\n");

	ctx->panel.prepare_prev_first = true;
	drm_panel_add(&ctx->panel);

	return 0;

}
EXPORT_SYMBOL_GPL(ili9806e_probe);

void ili9806e_remove(struct device *dev)
{
	struct ili9806e *ctx = dev_get_drvdata(dev);

	drm_panel_remove(&ctx->panel);
}
EXPORT_SYMBOL_GPL(ili9806e_remove);

MODULE_AUTHOR("Dario Binacchi <dario.binacchi@amarulasolutions.com>");
MODULE_AUTHOR("Gunnar Dibbern <gunnar.dibbern@lht.dlh.de>");
MODULE_AUTHOR("Michael Walle <mwalle@kernel.org>");
MODULE_DESCRIPTION("Ilitek ILI9806E Controller Driver");
MODULE_LICENSE("GPL");
+15 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef _PANEL_ILITEK_ILI9806E_CORE_H
#define _PANEL_ILITEK_ILI9806E_CORE_H

void *ili9806e_get_transport(struct drm_panel *panel);
int ili9806e_power_off(struct device *dev);
int ili9806e_power_on(struct device *dev);

int ili9806e_probe(struct device *dev, void *transport,
		   const struct drm_panel_funcs *funcs,
		   int connector_type);
void ili9806e_remove(struct device *dev);

#endif /* _PANEL_ILITEK_ILI9806E_CORE_H */
Loading