* [PATCH v8 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-27 4:16 ` Mikko Perttunen
2026-11-22 8:18 ` [PATCH v8 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus Svyatoslav Ryhel
` (10 subsequent siblings)
11 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
The MIPI DBI bus allows modeling DBI hosts and peripherals using the Linux
driver model. DBI hosts are registered by their respective drivers. During
registration, DBI peripherals are created from the device tree nodes
provided by the host.
DBI hosts expose operations that can be used by peripheral drivers to
access associated devices.
This implementation adds support for MIPI DBI Type A and Type B only.
Type C support existing in drm_mipi_dbi.c was not altered. The framework
is modeled to closely resemble the existing MIPI DSI setup for seamless
integration.
Suggested-by: Mikko Perttunen <mperttunen@nvidia.com> # preliminary sketch
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/gpu/drm/Makefile | 2 +-
drivers/gpu/drm/drm_mipi_dbi_bus.c | 287 +++++++++++++++++++++++++++++
include/drm/drm_mipi_dbi_bus.h | 148 +++++++++++++++
3 files changed, 436 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpu/drm/drm_mipi_dbi_bus.c
create mode 100644 include/drm/drm_mipi_dbi_bus.h
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 2c6bc093a923a..880f0dc930b85 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -166,7 +166,7 @@ obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
obj-y += tests/
-obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o
+obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o drm_mipi_dbi_bus.o
obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
obj-y += arm/
obj-y += clients/
diff --git a/drivers/gpu/drm/drm_mipi_dbi_bus.c b/drivers/gpu/drm/drm_mipi_dbi_bus.c
new file mode 100644
index 0000000000000..4b51de5bdf0b5
--- /dev/null
+++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c
@@ -0,0 +1,287 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * MIPI DBI devices with command transport through parallel interface
+ *
+ * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
+ * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/slab.h>
+
+#include <drm/drm_mipi_dbi.h>
+#include <drm/drm_mipi_dbi_bus.h>
+
+/**
+ * DOC: overview
+ *
+ * There are three MIPI DBI implementation types:
+ *
+ * A. Motorola 6800-type parallel bus
+ *
+ * B. Intel 8080-type parallel bus
+ *
+ * C. SPI-type with three options:
+ *
+ * 1. 9-bit with the Data/Command signal as the ninth bit
+ * 2. Same as above, except it is sent as 16 bits
+ * 3. 8-bit with the Data/Command signal as a separate D/CX pin
+ *
+ * This library provides a framework for MIPI Display Bus Interface (DBI)
+ * compatible display controllers using Type A and Type B. This
+ * implementation closely matches existing DSI framework behavior to
+ * allow seamless integration.
+ *
+ * Type C options 1 and 3 are covered by drm_mipi_dbi.c with
+ * mipi_dbi_spi_init().
+ */
+
+static int mipi_dbi_match(struct device *dev, const struct device_driver *driver)
+{
+ return of_driver_match_device(dev, driver);
+}
+
+static int mipi_dbi_uevent(const struct device *dev, struct kobj_uevent_env *env)
+{
+ return of_device_uevent_modalias(dev, env);
+}
+
+static const struct dev_pm_ops mipi_dbi_device_pm_ops = {
+ .runtime_suspend = pm_generic_runtime_suspend,
+ .runtime_resume = pm_generic_runtime_resume,
+ .suspend = pm_generic_suspend,
+ .resume = pm_generic_resume,
+ .freeze = pm_generic_freeze,
+ .thaw = pm_generic_thaw,
+ .poweroff = pm_generic_poweroff,
+ .restore = pm_generic_restore,
+};
+
+static const struct bus_type mipi_dbi_bus_type = {
+ .name = "mipi-dbi",
+ .match = mipi_dbi_match,
+ .uevent = mipi_dbi_uevent,
+ .pm = &mipi_dbi_device_pm_ops,
+};
+
+static void mipi_dbi_device_release(struct device *dev)
+{
+ of_node_put(dev->of_node);
+ kfree(to_mipi_dbi_device(dev));
+}
+
+static void mipi_dbi_device_unregister(void *data)
+{
+ struct device *dev = data;
+
+ of_node_clear_flag(dev->of_node, OF_POPULATED);
+ device_unregister(dev);
+}
+
+/**
+ * devm_mipi_dbi_device_register() - create a managed peripheral MIPI DBI
+ * Type A or B device.
+ * @dev: device to tie the MIPI-DBI device lifetime to
+ * @host: DBI host to which this device is connected
+ * @np: device tree node associated with the panel MIPI DBI device
+ *
+ * This function is called by DBI host driver to create panel device.
+ * It automatically calls mipi_dbi_device_unregister() when @dev is
+ * unbound. It does not automatically free passed device node pointer,
+ * it must be put manually.
+ *
+ * Returns:
+ * A pointer to the newly created MIPI DBI device, or, a pointer encoded
+ * with an error.
+ */
+struct mipi_dbi_device *
+devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
+ struct device_node *np)
+{
+ struct mipi_dbi_device *dbidev;
+ int ret;
+
+ if (!host || !host->dev || !host->dbi || !host->dbi->command ||
+ !host->ops || !host->ops->attach || !host->ops->detach || !np)
+ return ERR_PTR(-EINVAL);
+
+ if (!of_device_is_available(np))
+ return ERR_PTR(-ENODEV);
+
+ dbidev = kzalloc_obj(*dbidev);
+ if (!dbidev)
+ return ERR_PTR(-ENOMEM);
+
+ if (of_node_test_and_set_flag(np, OF_POPULATED)) {
+ kfree(dbidev);
+ return ERR_PTR(-EBUSY);
+ }
+
+ dbidev->host = host;
+ dbidev->dbi = host->dbi;
+ device_initialize(&dbidev->dev);
+ dbidev->dev.parent = host->dev;
+ dbidev->dev.bus = &mipi_dbi_bus_type;
+ dbidev->dev.release = mipi_dbi_device_release;
+ device_set_node(&dbidev->dev, of_fwnode_handle(of_node_get(np)));
+
+ ret = dev_set_name(&dbidev->dev, "%s:%s", dev_name(host->dev), np->full_name);
+ if (ret)
+ goto put_device;
+
+ ret = device_add(&dbidev->dev);
+ if (ret)
+ goto put_device;
+
+ ret = devm_add_action_or_reset(dev, mipi_dbi_device_unregister,
+ &dbidev->dev);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return dbidev;
+
+put_device:
+ of_node_clear_flag(np, OF_POPULATED);
+ put_device(&dbidev->dev);
+ return ERR_PTR(ret);
+}
+EXPORT_SYMBOL_GPL(devm_mipi_dbi_device_register);
+
+static void mipi_dbi_detach(void *data)
+{
+ struct mipi_dbi_device *dbidev = data;
+
+ dbidev->host->ops->detach(dbidev->host, dbidev);
+ dbidev->attached = false;
+}
+
+/**
+ * devm_mipi_dbi_attach() - managed attach of peripheral DBI device to its MIPI
+ * DBI Type A or B devices.
+ * @dev: device to tie the MIPI-DBI device lifetime to
+ * @dbidev: DBI peripheral
+ */
+int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev)
+{
+ int ret;
+
+ if (dbidev->attached)
+ return -EBUSY;
+
+ ret = dbidev->host->ops->attach(dbidev->host, dbidev);
+ if (ret)
+ return ret;
+
+ dbidev->attached = true;
+ return devm_add_action_or_reset(dev, mipi_dbi_detach, dbidev);
+}
+EXPORT_SYMBOL_GPL(devm_mipi_dbi_attach);
+
+/**
+ * mipi_dbi_write_buffer_multi() - mipi_dbi_command() w/ accum_err but for
+ * MIPI DBI Type A and B
+ * @ctx: context for multiple DBI transactions
+ * @cmd: command to be sent
+ * @data: buffer containing data to be transmitted
+ * @len: size of transmission buffer
+ *
+ * Acts like mipi_dbi_command() for MIPI DBI Type C but for Types A and B
+ * and deals with errors in a way that makes it convenient to make several
+ * calls in a row.
+ */
+void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
+ u8 cmd, const u8 *data, size_t len)
+{
+ struct mipi_dbi_device *dbidev = ctx->dbidev;
+ struct device *dev = &dbidev->dev;
+ ssize_t ret;
+
+ if (ctx->accum_err)
+ return;
+
+ ret = mipi_dbi_command_stackbuf(dbidev->dbi, cmd, data, len);
+ if (ret < 0) {
+ ctx->accum_err = ret;
+ dev_err(dev, "sending dcs data %*ph failed: %d\n",
+ (int)len, data, ctx->accum_err);
+ }
+}
+EXPORT_SYMBOL(mipi_dbi_write_buffer_multi);
+
+static int mipi_dbi_drv_probe(struct device *dev)
+{
+ struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
+ struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
+
+ return drv->probe(dbidev);
+}
+
+static int mipi_dbi_drv_remove(struct device *dev)
+{
+ struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
+ struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
+
+ drv->remove(dbidev);
+
+ return 0;
+}
+
+static void mipi_dbi_drv_shutdown(struct device *dev)
+{
+ struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
+ struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
+
+ drv->shutdown(dbidev);
+}
+
+/**
+ * __mipi_dbi_driver_register() - register a driver for MIPI DBI Type A or B devices.
+ * @drv: DBI driver structure
+ * @owner: owner module
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner)
+{
+ drv->driver.bus = &mipi_dbi_bus_type;
+ drv->driver.owner = owner;
+
+ if (drv->probe)
+ drv->driver.probe = mipi_dbi_drv_probe;
+ if (drv->remove)
+ drv->driver.remove = mipi_dbi_drv_remove;
+ if (drv->shutdown)
+ drv->driver.shutdown = mipi_dbi_drv_shutdown;
+
+ return driver_register(&drv->driver);
+}
+EXPORT_SYMBOL_GPL(__mipi_dbi_driver_register);
+
+/**
+ * mipi_dbi_driver_unregister() - unregister a driver for MIPI DBI Type A or B devices.
+ * @drv: DBI driver structure
+ */
+void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv)
+{
+ driver_unregister(&drv->driver);
+}
+EXPORT_SYMBOL_GPL(mipi_dbi_driver_unregister);
+
+static int __init mipi_dbi_bus_init(void)
+{
+ return bus_register(&mipi_dbi_bus_type);
+}
+subsys_initcall(mipi_dbi_bus_init);
+
+static void __exit mipi_dbi_bus_exit(void)
+{
+ bus_unregister(&mipi_dbi_bus_type);
+}
+module_exit(mipi_dbi_bus_exit);
+
+MODULE_DESCRIPTION("MIPI DBI devices with command transport through parallel interface");
+MODULE_LICENSE("GPL");
diff --git a/include/drm/drm_mipi_dbi_bus.h b/include/drm/drm_mipi_dbi_bus.h
new file mode 100644
index 0000000000000..6f00a8eef9c67
--- /dev/null
+++ b/include/drm/drm_mipi_dbi_bus.h
@@ -0,0 +1,148 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * MIPI DBI devices with command transport through parallel interface
+ *
+ * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
+ * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#ifndef __DRM_MIPI_DBI_BUS_H__
+#define __DRM_MIPI_DBI_BUS_H__
+
+#include <linux/device.h>
+#include <linux/module.h>
+
+struct device_node;
+struct mipi_dbi;
+struct mipi_dbi_device;
+struct mipi_dbi_host;
+
+/**
+ * struct mipi_dbi_host_ops - DBI bus operations for MIPI DBI Type A and B.
+ * @attach: attach DBI device to DBI host
+ * @detach: detach DBI device from DBI host
+ */
+struct mipi_dbi_host_ops {
+ int (*attach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
+ void (*detach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
+};
+
+/**
+ * struct mipi_dbi_host - DBI host device for MIPI DBI Type A and B.
+ * @dev: driver model device node for this DBI host
+ * @dbi: MIPI DBI interface
+ * @ops: DBI host operations
+ */
+struct mipi_dbi_host {
+ struct device *dev;
+ struct mipi_dbi *dbi;
+ const struct mipi_dbi_host_ops *ops;
+};
+
+/**
+ * struct mipi_dbi_device - DBI peripheral device for MIPI DBI Type A and B.
+ * This structure describes a peripheral DBI device,
+ * an endpoint for DSC commands and video data, and must
+ * be paired with a DBI host device for MIPI DBI Type A
+ * and B. This layout is built to closely resemble
+ * the DSI framework.
+ *
+ * If your device is MIPI DBI Type C (with an SPI
+ * control bus) and incorporates DBI within, you
+ * should use the mipi_dbi_dev structure and Type C
+ * framework from drm_mipi_dbi.c.
+ * @dev: driver model device node for this peripheral
+ * @dbi: MIPI DBI interface
+ * @host: DBI host for this peripheral
+ * @attached: the DBI device has been successfully attached
+ */
+struct mipi_dbi_device {
+ struct device dev;
+ struct mipi_dbi *dbi;
+ struct mipi_dbi_host *host;
+ bool attached;
+};
+
+/**
+ * struct mipi_dbi_multi_context - Context to call multiple MIPI DBI funcs in a row
+ * @dbidev: Pointer to the peripheral MIPI DBI Type A and B device
+ * @accum_err: Storage for the accumulated error over the multiple calls
+ * Init to 0. If a function encounters an error then the error code
+ * will be stored here. If you call a function and this points to a
+ * non-zero value then the function will be a noop. This allows calling
+ * a function many times in a row and just checking the error at the
+ * end to see if any of them failed.
+ */
+
+struct mipi_dbi_multi_context {
+ struct mipi_dbi_device *dbidev;
+ int accum_err;
+};
+
+#define to_mipi_dbi_device(__dev) container_of_const(__dev, struct mipi_dbi_device, dev)
+
+void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
+ u8 cmd, const u8 *data, size_t len);
+
+/**
+ * mipi_dbi_write_seq_multi() - transmit a command with payload
+ *
+ * This macro will print errors for you and error handling is optimized for
+ * callers that call this multiple times in a row.
+ *
+ * @ctx: context for multiple DBI transactions
+ * @cmd: command to be sent
+ * @seq: buffer containing data to be transmitted
+ */
+#define mipi_dbi_write_seq_multi(ctx, cmd, seq...) \
+ do { \
+ static const u8 d[] = { seq }; \
+ mipi_dbi_write_buffer_multi(ctx, cmd, d, ARRAY_SIZE(d)); \
+ } while (0)
+
+struct mipi_dbi_device *
+devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
+ struct device_node *np);
+int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev);
+
+/**
+ * struct mipi_dbi_driver - DBI driver for MIPI DBI Type A and B.
+ * @driver: device driver model driver
+ * @probe: callback for device binding
+ * @remove: callback for device unbinding
+ * @shutdown: called at shutdown time to quiesce the device
+ */
+struct mipi_dbi_driver {
+ struct device_driver driver;
+ int (*probe)(struct mipi_dbi_device *dbi);
+ void (*remove)(struct mipi_dbi_device *dbi);
+ void (*shutdown)(struct mipi_dbi_device *dbi);
+};
+
+static inline struct mipi_dbi_driver *
+to_mipi_dbi_driver(struct device_driver *driver)
+{
+ return container_of(driver, struct mipi_dbi_driver, driver);
+}
+
+static inline void *mipi_dbi_get_drvdata(const struct mipi_dbi_device *dbi)
+{
+ return dev_get_drvdata(&dbi->dev);
+}
+
+static inline void mipi_dbi_set_drvdata(struct mipi_dbi_device *dbi, void *data)
+{
+ dev_set_drvdata(&dbi->dev, data);
+}
+
+int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner);
+void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv);
+
+#define mipi_dbi_driver_register(driver) \
+ __mipi_dbi_driver_register(driver, THIS_MODULE)
+
+#define module_mipi_dbi_driver(__mipi_dbi_driver) \
+ module_driver(__mipi_dbi_driver, mipi_dbi_driver_register, \
+ mipi_dbi_driver_unregister)
+
+#endif /* __DRM_MIPI_DBI_BUS__ */
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* Re: [PATCH v8 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B
2026-11-22 8:18 ` [PATCH v8 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
@ 2026-11-27 4:16 ` Mikko Perttunen
2026-11-27 9:06 ` Svyatoslav Ryhel
0 siblings, 1 reply; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 4:16 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Svyatoslav Ryhel, devicetree
Cc: dri-devel, devicetree, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> The MIPI DBI bus allows modeling DBI hosts and peripherals using the Linux
> driver model. DBI hosts are registered by their respective drivers. During
> registration, DBI peripherals are created from the device tree nodes
> provided by the host.
>
> DBI hosts expose operations that can be used by peripheral drivers to
> access associated devices.
>
> This implementation adds support for MIPI DBI Type A and Type B only.
> Type C support existing in drm_mipi_dbi.c was not altered. The framework
> is modeled to closely resemble the existing MIPI DSI setup for seamless
> integration.
>
> Suggested-by: Mikko Perttunen <mperttunen@nvidia.com> # preliminary sketch
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> drivers/gpu/drm/Makefile | 2 +-
> drivers/gpu/drm/drm_mipi_dbi_bus.c | 287 +++++++++++++++++++++++++++++
> include/drm/drm_mipi_dbi_bus.h | 148 +++++++++++++++
> 3 files changed, 436 insertions(+), 1 deletion(-)
> create mode 100644 drivers/gpu/drm/drm_mipi_dbi_bus.c
> create mode 100644 include/drm/drm_mipi_dbi_bus.h
>
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 2c6bc093a923a..880f0dc930b85 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -166,7 +166,7 @@ obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
>
> obj-y += tests/
>
> -obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o
> +obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o drm_mipi_dbi_bus.o
> obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
> obj-y += arm/
> obj-y += clients/
> diff --git a/drivers/gpu/drm/drm_mipi_dbi_bus.c b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> new file mode 100644
> index 0000000000000..4b51de5bdf0b5
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> @@ -0,0 +1,287 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * MIPI DBI devices with command transport through parallel interface
> + *
> + * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
> + * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
> + */
> +
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/slab.h>
> +
> +#include <drm/drm_mipi_dbi.h>
> +#include <drm/drm_mipi_dbi_bus.h>
> +
> +/**
> + * DOC: overview
> + *
> + * There are three MIPI DBI implementation types:
> + *
> + * A. Motorola 6800-type parallel bus
> + *
> + * B. Intel 8080-type parallel bus
> + *
> + * C. SPI-type with three options:
> + *
> + * 1. 9-bit with the Data/Command signal as the ninth bit
> + * 2. Same as above, except it is sent as 16 bits
> + * 3. 8-bit with the Data/Command signal as a separate D/CX pin
> + *
> + * This library provides a framework for MIPI Display Bus Interface (DBI)
> + * compatible display controllers using Type A and Type B. This
> + * implementation closely matches existing DSI framework behavior to
> + * allow seamless integration.
> + *
> + * Type C options 1 and 3 are covered by drm_mipi_dbi.c with
> + * mipi_dbi_spi_init().
> + */
> +
> +static int mipi_dbi_match(struct device *dev, const struct device_driver *driver)
> +{
> + return of_driver_match_device(dev, driver);
> +}
> +
> +static int mipi_dbi_uevent(const struct device *dev, struct kobj_uevent_env *env)
> +{
> + return of_device_uevent_modalias(dev, env);
> +}
> +
> +static const struct dev_pm_ops mipi_dbi_device_pm_ops = {
> + .runtime_suspend = pm_generic_runtime_suspend,
> + .runtime_resume = pm_generic_runtime_resume,
> + .suspend = pm_generic_suspend,
> + .resume = pm_generic_resume,
> + .freeze = pm_generic_freeze,
> + .thaw = pm_generic_thaw,
> + .poweroff = pm_generic_poweroff,
> + .restore = pm_generic_restore,
> +};
> +
> +static const struct bus_type mipi_dbi_bus_type = {
> + .name = "mipi-dbi",
> + .match = mipi_dbi_match,
> + .uevent = mipi_dbi_uevent,
These two callbacks are just direct wrappers so I believe we should be
able to set them to of_driver_match_device / of_device_uevent_modalias
directly.
> + .pm = &mipi_dbi_device_pm_ops,
I think we can drop setting .pm as well. These callbacks will fall back
to the same code (driver callbacks) if we don't set the bus PM ops.
> +};
> +
> +static void mipi_dbi_device_release(struct device *dev)
> +{
> + of_node_put(dev->of_node);
> + kfree(to_mipi_dbi_device(dev));
> +}
> +
> +static void mipi_dbi_device_unregister(void *data)
> +{
> + struct device *dev = data;
> +
> + of_node_clear_flag(dev->of_node, OF_POPULATED);
> + device_unregister(dev);
> +}
> +
> +/**
> + * devm_mipi_dbi_device_register() - create a managed peripheral MIPI DBI
> + * Type A or B device.
> + * @dev: device to tie the MIPI-DBI device lifetime to
> + * @host: DBI host to which this device is connected
> + * @np: device tree node associated with the panel MIPI DBI device
> + *
> + * This function is called by DBI host driver to create panel device.
> + * It automatically calls mipi_dbi_device_unregister() when @dev is
> + * unbound. It does not automatically free passed device node pointer,
> + * it must be put manually.
> + *
> + * Returns:
> + * A pointer to the newly created MIPI DBI device, or, a pointer encoded
> + * with an error.
For brevity, I would just use 'an error pointer'.
> + */
> +struct mipi_dbi_device *
> +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
> + struct device_node *np)
> +{
> + struct mipi_dbi_device *dbidev;
> + int ret;
> +
> + if (!host || !host->dev || !host->dbi || !host->dbi->command ||
> + !host->ops || !host->ops->attach || !host->ops->detach || !np)
> + return ERR_PTR(-EINVAL);
> +
> + if (!of_device_is_available(np))
> + return ERR_PTR(-ENODEV);
> +
> + dbidev = kzalloc_obj(*dbidev);
> + if (!dbidev)
> + return ERR_PTR(-ENOMEM);
> +
> + if (of_node_test_and_set_flag(np, OF_POPULATED)) {
> + kfree(dbidev);
> + return ERR_PTR(-EBUSY);
> + }
> +
> + dbidev->host = host;
> + dbidev->dbi = host->dbi;
> + device_initialize(&dbidev->dev);
> + dbidev->dev.parent = host->dev;
> + dbidev->dev.bus = &mipi_dbi_bus_type;
> + dbidev->dev.release = mipi_dbi_device_release;
> + device_set_node(&dbidev->dev, of_fwnode_handle(of_node_get(np)));
> +
> + ret = dev_set_name(&dbidev->dev, "%s:%s", dev_name(host->dev), np->full_name);
> + if (ret)
> + goto put_device;
> +
> + ret = device_add(&dbidev->dev);
> + if (ret)
> + goto put_device;
> +
> + ret = devm_add_action_or_reset(dev, mipi_dbi_device_unregister,
> + &dbidev->dev);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + return dbidev;
> +
> +put_device:
> + of_node_clear_flag(np, OF_POPULATED);
> + put_device(&dbidev->dev);
> + return ERR_PTR(ret);
> +}
> +EXPORT_SYMBOL_GPL(devm_mipi_dbi_device_register);
> +
> +static void mipi_dbi_detach(void *data)
> +{
> + struct mipi_dbi_device *dbidev = data;
> +
> + dbidev->host->ops->detach(dbidev->host, dbidev);
> + dbidev->attached = false;
> +}
> +
> +/**
> + * devm_mipi_dbi_attach() - managed attach of peripheral DBI device to its MIPI
> + * DBI Type A or B devices.
> + * @dev: device to tie the MIPI-DBI device lifetime to
> + * @dbidev: DBI peripheral
Add a return value description. Otherwise inevitably someone will send
an autogenerated oneline fix to add it.
> + */
> +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev)
> +{
> + int ret;
> +
> + if (dbidev->attached)
> + return -EBUSY;
> +
> + ret = dbidev->host->ops->attach(dbidev->host, dbidev);
> + if (ret)
> + return ret;
> +
> + dbidev->attached = true;
> + return devm_add_action_or_reset(dev, mipi_dbi_detach, dbidev);
> +}
> +EXPORT_SYMBOL_GPL(devm_mipi_dbi_attach);
> +
> +/**
> + * mipi_dbi_write_buffer_multi() - mipi_dbi_command() w/ accum_err but for
> + * MIPI DBI Type A and B
> + * @ctx: context for multiple DBI transactions
> + * @cmd: command to be sent
> + * @data: buffer containing data to be transmitted
> + * @len: size of transmission buffer
> + *
> + * Acts like mipi_dbi_command() for MIPI DBI Type C but for Types A and B
> + * and deals with errors in a way that makes it convenient to make several
> + * calls in a row.
> + */
> +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
> + u8 cmd, const u8 *data, size_t len)
> +{
> + struct mipi_dbi_device *dbidev = ctx->dbidev;
> + struct device *dev = &dbidev->dev;
> + ssize_t ret;
mipi_dbi_command_stackbuf returns an int, so this can be an int as well.
> +
> + if (ctx->accum_err)
> + return;
> +
> + ret = mipi_dbi_command_stackbuf(dbidev->dbi, cmd, data, len);
> + if (ret < 0) {
> + ctx->accum_err = ret;
> + dev_err(dev, "sending dcs data %*ph failed: %d\n",
> + (int)len, data, ctx->accum_err);
> + }
> +}
> +EXPORT_SYMBOL(mipi_dbi_write_buffer_multi);
> +
> +static int mipi_dbi_drv_probe(struct device *dev)
> +{
> + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> +
> + return drv->probe(dbidev);
> +}
> +
> +static int mipi_dbi_drv_remove(struct device *dev)
> +{
> + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> +
> + drv->remove(dbidev);
> +
> + return 0;
> +}
> +
> +static void mipi_dbi_drv_shutdown(struct device *dev)
> +{
> + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> +
> + drv->shutdown(dbidev);
> +}
This could be simplified slightly by making these (probe, remove,
shutdown) bus-level callbacks (set on mipi_dbi_bus_type). Then the
callback assignments in __mipi_dbi_driver_register are not needed. The
'if's do have to move into the bus-level callbacks. This also cleans up
the remove callback return type.
> +
> +/**
> + * __mipi_dbi_driver_register() - register a driver for MIPI DBI Type A or B devices.
> + * @drv: DBI driver structure
> + * @owner: owner module
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner)
> +{
> + drv->driver.bus = &mipi_dbi_bus_type;
> + drv->driver.owner = owner;
> +
> + if (drv->probe)
> + drv->driver.probe = mipi_dbi_drv_probe;
> + if (drv->remove)
> + drv->driver.remove = mipi_dbi_drv_remove;
> + if (drv->shutdown)
> + drv->driver.shutdown = mipi_dbi_drv_shutdown;
> +
> + return driver_register(&drv->driver);
> +}
> +EXPORT_SYMBOL_GPL(__mipi_dbi_driver_register);
> +
> +/**
> + * mipi_dbi_driver_unregister() - unregister a driver for MIPI DBI Type A or B devices.
> + * @drv: DBI driver structure
> + */
> +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv)
> +{
> + driver_unregister(&drv->driver);
> +}
> +EXPORT_SYMBOL_GPL(mipi_dbi_driver_unregister);
> +
> +static int __init mipi_dbi_bus_init(void)
> +{
> + return bus_register(&mipi_dbi_bus_type);
> +}
> +subsys_initcall(mipi_dbi_bus_init);
> +
> +static void __exit mipi_dbi_bus_exit(void)
> +{
> + bus_unregister(&mipi_dbi_bus_type);
> +}
> +module_exit(mipi_dbi_bus_exit);
> +
> +MODULE_DESCRIPTION("MIPI DBI devices with command transport through parallel interface");
> +MODULE_LICENSE("GPL");
> diff --git a/include/drm/drm_mipi_dbi_bus.h b/include/drm/drm_mipi_dbi_bus.h
> new file mode 100644
> index 0000000000000..6f00a8eef9c67
> --- /dev/null
> +++ b/include/drm/drm_mipi_dbi_bus.h
> @@ -0,0 +1,148 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * MIPI DBI devices with command transport through parallel interface
> + *
> + * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
> + * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
> + */
> +
> +#ifndef __DRM_MIPI_DBI_BUS_H__
> +#define __DRM_MIPI_DBI_BUS_H__
> +
> +#include <linux/device.h>
> +#include <linux/module.h>
> +
> +struct device_node;
> +struct mipi_dbi;
> +struct mipi_dbi_device;
> +struct mipi_dbi_host;
> +
> +/**
> + * struct mipi_dbi_host_ops - DBI bus operations for MIPI DBI Type A and B.
> + * @attach: attach DBI device to DBI host
> + * @detach: detach DBI device from DBI host
> + */
> +struct mipi_dbi_host_ops {
> + int (*attach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
> + void (*detach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
> +};
> +
> +/**
> + * struct mipi_dbi_host - DBI host device for MIPI DBI Type A and B.
> + * @dev: driver model device node for this DBI host
> + * @dbi: MIPI DBI interface
> + * @ops: DBI host operations
> + */
> +struct mipi_dbi_host {
> + struct device *dev;
> + struct mipi_dbi *dbi;
> + const struct mipi_dbi_host_ops *ops;
> +};
> +
> +/**
> + * struct mipi_dbi_device - DBI peripheral device for MIPI DBI Type A and B.
> + * This structure describes a peripheral DBI device,
> + * an endpoint for DSC commands and video data, and must
DCS commands
> + * be paired with a DBI host device for MIPI DBI Type A
> + * and B. This layout is built to closely resemble
> + * the DSI framework.
> + *
> + * If your device is MIPI DBI Type C (with an SPI
> + * control bus) and incorporates DBI within, you
> + * should use the mipi_dbi_dev structure and Type C
> + * framework from drm_mipi_dbi.c.
I don't think we need to talk about the DSI or Type C frameworks here.
drm_mipi_dbi.c already mentions it's for Type C.
> + * @dev: driver model device node for this peripheral
> + * @dbi: MIPI DBI interface
> + * @host: DBI host for this peripheral
> + * @attached: the DBI device has been successfully attached
> + */
> +struct mipi_dbi_device {
> + struct device dev;
> + struct mipi_dbi *dbi;
> + struct mipi_dbi_host *host;
> + bool attached;
> +};
> +
> +/**
> + * struct mipi_dbi_multi_context - Context to call multiple MIPI DBI funcs in a row
> + * @dbidev: Pointer to the peripheral MIPI DBI Type A and B device
> + * @accum_err: Storage for the accumulated error over the multiple calls
> + * Init to 0. If a function encounters an error then the error code
> + * will be stored here. If you call a function and this points to a
> + * non-zero value then the function will be a noop. This allows calling
> + * a function many times in a row and just checking the error at the
> + * end to see if any of them failed.
> + */
> +
> +struct mipi_dbi_multi_context {
> + struct mipi_dbi_device *dbidev;
> + int accum_err;
> +};
> +
> +#define to_mipi_dbi_device(__dev) container_of_const(__dev, struct mipi_dbi_device, dev)
> +
> +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
> + u8 cmd, const u8 *data, size_t len);
> +
> +/**
> + * mipi_dbi_write_seq_multi() - transmit a command with payload
> + *
> + * This macro will print errors for you and error handling is optimized for
> + * callers that call this multiple times in a row.
> + *
> + * @ctx: context for multiple DBI transactions
> + * @cmd: command to be sent
> + * @seq: buffer containing data to be transmitted
> + */
> +#define mipi_dbi_write_seq_multi(ctx, cmd, seq...) \
> + do { \
> + static const u8 d[] = { seq }; \
> + mipi_dbi_write_buffer_multi(ctx, cmd, d, ARRAY_SIZE(d)); \
> + } while (0)
> +
> +struct mipi_dbi_device *
> +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
> + struct device_node *np);
> +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev);
> +
> +/**
> + * struct mipi_dbi_driver - DBI driver for MIPI DBI Type A and B.
> + * @driver: device driver model driver
> + * @probe: callback for device binding
> + * @remove: callback for device unbinding
> + * @shutdown: called at shutdown time to quiesce the device
> + */
> +struct mipi_dbi_driver {
> + struct device_driver driver;
> + int (*probe)(struct mipi_dbi_device *dbi);
> + void (*remove)(struct mipi_dbi_device *dbi);
> + void (*shutdown)(struct mipi_dbi_device *dbi);
> +};
> +
> +static inline struct mipi_dbi_driver *
> +to_mipi_dbi_driver(struct device_driver *driver)
> +{
> + return container_of(driver, struct mipi_dbi_driver, driver);
> +}
> +
> +static inline void *mipi_dbi_get_drvdata(const struct mipi_dbi_device *dbi)
> +{
> + return dev_get_drvdata(&dbi->dev);
> +}
> +
> +static inline void mipi_dbi_set_drvdata(struct mipi_dbi_device *dbi, void *data)
> +{
> + dev_set_drvdata(&dbi->dev, data);
> +}
> +
> +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner);
> +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv);
> +
> +#define mipi_dbi_driver_register(driver) \
> + __mipi_dbi_driver_register(driver, THIS_MODULE)
> +
> +#define module_mipi_dbi_driver(__mipi_dbi_driver) \
> + module_driver(__mipi_dbi_driver, mipi_dbi_driver_register, \
> + mipi_dbi_driver_unregister)
> +
> +#endif /* __DRM_MIPI_DBI_BUS__ */
__DRM_MIPI_DBI_BUS_H__
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B
2026-11-27 4:16 ` Mikko Perttunen
@ 2026-11-27 9:06 ` Svyatoslav Ryhel
2026-11-27 12:14 ` Mikko Perttunen
0 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-27 9:06 UTC (permalink / raw)
To: Mikko Perttunen
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel
пт, 27 лист. 2026 р. о 06:16 Mikko Perttunen <mperttunen@nvidia.com> пише:
>
> On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > The MIPI DBI bus allows modeling DBI hosts and peripherals using the Linux
> > driver model. DBI hosts are registered by their respective drivers. During
> > registration, DBI peripherals are created from the device tree nodes
> > provided by the host.
> >
> > DBI hosts expose operations that can be used by peripheral drivers to
> > access associated devices.
> >
> > This implementation adds support for MIPI DBI Type A and Type B only.
> > Type C support existing in drm_mipi_dbi.c was not altered. The framework
> > is modeled to closely resemble the existing MIPI DSI setup for seamless
> > integration.
> >
> > Suggested-by: Mikko Perttunen <mperttunen@nvidia.com> # preliminary sketch
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > ---
> > drivers/gpu/drm/Makefile | 2 +-
> > drivers/gpu/drm/drm_mipi_dbi_bus.c | 287 +++++++++++++++++++++++++++++
> > include/drm/drm_mipi_dbi_bus.h | 148 +++++++++++++++
> > 3 files changed, 436 insertions(+), 1 deletion(-)
> > create mode 100644 drivers/gpu/drm/drm_mipi_dbi_bus.c
> > create mode 100644 include/drm/drm_mipi_dbi_bus.h
> >
> > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > index 2c6bc093a923a..880f0dc930b85 100644
> > --- a/drivers/gpu/drm/Makefile
> > +++ b/drivers/gpu/drm/Makefile
> > @@ -166,7 +166,7 @@ obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
> >
> > obj-y += tests/
> >
> > -obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o
> > +obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o drm_mipi_dbi_bus.o
> > obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
> > obj-y += arm/
> > obj-y += clients/
> > diff --git a/drivers/gpu/drm/drm_mipi_dbi_bus.c b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> > new file mode 100644
> > index 0000000000000..4b51de5bdf0b5
> > --- /dev/null
> > +++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> > @@ -0,0 +1,287 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * MIPI DBI devices with command transport through parallel interface
> > + *
> > + * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
> > + * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
> > + */
> > +
> > +#include <linux/err.h>
> > +#include <linux/init.h>
> > +#include <linux/of.h>
> > +#include <linux/of_device.h>
> > +#include <linux/pm_runtime.h>
> > +#include <linux/slab.h>
> > +
> > +#include <drm/drm_mipi_dbi.h>
> > +#include <drm/drm_mipi_dbi_bus.h>
> > +
> > +/**
> > + * DOC: overview
> > + *
> > + * There are three MIPI DBI implementation types:
> > + *
> > + * A. Motorola 6800-type parallel bus
> > + *
> > + * B. Intel 8080-type parallel bus
> > + *
> > + * C. SPI-type with three options:
> > + *
> > + * 1. 9-bit with the Data/Command signal as the ninth bit
> > + * 2. Same as above, except it is sent as 16 bits
> > + * 3. 8-bit with the Data/Command signal as a separate D/CX pin
> > + *
> > + * This library provides a framework for MIPI Display Bus Interface (DBI)
> > + * compatible display controllers using Type A and Type B. This
> > + * implementation closely matches existing DSI framework behavior to
> > + * allow seamless integration.
> > + *
> > + * Type C options 1 and 3 are covered by drm_mipi_dbi.c with
> > + * mipi_dbi_spi_init().
> > + */
> > +
> > +static int mipi_dbi_match(struct device *dev, const struct device_driver *driver)
> > +{
> > + return of_driver_match_device(dev, driver);
> > +}
> > +
> > +static int mipi_dbi_uevent(const struct device *dev, struct kobj_uevent_env *env)
> > +{
> > + return of_device_uevent_modalias(dev, env);
> > +}
> > +
> > +static const struct dev_pm_ops mipi_dbi_device_pm_ops = {
> > + .runtime_suspend = pm_generic_runtime_suspend,
> > + .runtime_resume = pm_generic_runtime_resume,
> > + .suspend = pm_generic_suspend,
> > + .resume = pm_generic_resume,
> > + .freeze = pm_generic_freeze,
> > + .thaw = pm_generic_thaw,
> > + .poweroff = pm_generic_poweroff,
> > + .restore = pm_generic_restore,
> > +};
> > +
> > +static const struct bus_type mipi_dbi_bus_type = {
> > + .name = "mipi-dbi",
> > + .match = mipi_dbi_match,
> > + .uevent = mipi_dbi_uevent,
>
> These two callbacks are just direct wrappers so I believe we should be
> able to set them to of_driver_match_device / of_device_uevent_modalias
> directly.
>
May you specify a bit more please?
> > + .pm = &mipi_dbi_device_pm_ops,
>
> I think we can drop setting .pm as well. These callbacks will fall back
> to the same code (driver callbacks) if we don't set the bus PM ops.
>
Noted.
> > +};
> > +
> > +static void mipi_dbi_device_release(struct device *dev)
> > +{
> > + of_node_put(dev->of_node);
> > + kfree(to_mipi_dbi_device(dev));
> > +}
> > +
> > +static void mipi_dbi_device_unregister(void *data)
> > +{
> > + struct device *dev = data;
> > +
> > + of_node_clear_flag(dev->of_node, OF_POPULATED);
> > + device_unregister(dev);
> > +}
> > +
> > +/**
> > + * devm_mipi_dbi_device_register() - create a managed peripheral MIPI DBI
> > + * Type A or B device.
> > + * @dev: device to tie the MIPI-DBI device lifetime to
> > + * @host: DBI host to which this device is connected
> > + * @np: device tree node associated with the panel MIPI DBI device
> > + *
> > + * This function is called by DBI host driver to create panel device.
> > + * It automatically calls mipi_dbi_device_unregister() when @dev is
> > + * unbound. It does not automatically free passed device node pointer,
> > + * it must be put manually.
> > + *
> > + * Returns:
> > + * A pointer to the newly created MIPI DBI device, or, a pointer encoded
> > + * with an error.
>
> For brevity, I would just use 'an error pointer'.
>
Noted
> > + */
> > +struct mipi_dbi_device *
> > +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
> > + struct device_node *np)
> > +{
> > + struct mipi_dbi_device *dbidev;
> > + int ret;
> > +
> > + if (!host || !host->dev || !host->dbi || !host->dbi->command ||
> > + !host->ops || !host->ops->attach || !host->ops->detach || !np)
> > + return ERR_PTR(-EINVAL);
> > +
> > + if (!of_device_is_available(np))
> > + return ERR_PTR(-ENODEV);
> > +
> > + dbidev = kzalloc_obj(*dbidev);
> > + if (!dbidev)
> > + return ERR_PTR(-ENOMEM);
> > +
> > + if (of_node_test_and_set_flag(np, OF_POPULATED)) {
> > + kfree(dbidev);
> > + return ERR_PTR(-EBUSY);
> > + }
> > +
> > + dbidev->host = host;
> > + dbidev->dbi = host->dbi;
> > + device_initialize(&dbidev->dev);
> > + dbidev->dev.parent = host->dev;
> > + dbidev->dev.bus = &mipi_dbi_bus_type;
> > + dbidev->dev.release = mipi_dbi_device_release;
> > + device_set_node(&dbidev->dev, of_fwnode_handle(of_node_get(np)));
> > +
> > + ret = dev_set_name(&dbidev->dev, "%s:%s", dev_name(host->dev), np->full_name);
> > + if (ret)
> > + goto put_device;
> > +
> > + ret = device_add(&dbidev->dev);
> > + if (ret)
> > + goto put_device;
> > +
> > + ret = devm_add_action_or_reset(dev, mipi_dbi_device_unregister,
> > + &dbidev->dev);
> > + if (ret)
> > + return ERR_PTR(ret);
> > +
> > + return dbidev;
> > +
> > +put_device:
> > + of_node_clear_flag(np, OF_POPULATED);
> > + put_device(&dbidev->dev);
> > + return ERR_PTR(ret);
> > +}
> > +EXPORT_SYMBOL_GPL(devm_mipi_dbi_device_register);
> > +
> > +static void mipi_dbi_detach(void *data)
> > +{
> > + struct mipi_dbi_device *dbidev = data;
> > +
> > + dbidev->host->ops->detach(dbidev->host, dbidev);
> > + dbidev->attached = false;
> > +}
> > +
> > +/**
> > + * devm_mipi_dbi_attach() - managed attach of peripheral DBI device to its MIPI
> > + * DBI Type A or B devices.
> > + * @dev: device to tie the MIPI-DBI device lifetime to
> > + * @dbidev: DBI peripheral
>
> Add a return value description. Otherwise inevitably someone will send
> an autogenerated oneline fix to add it.
>
Noted
> > + */
> > +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev)
> > +{
> > + int ret;
> > +
> > + if (dbidev->attached)
> > + return -EBUSY;
> > +
> > + ret = dbidev->host->ops->attach(dbidev->host, dbidev);
> > + if (ret)
> > + return ret;
> > +
> > + dbidev->attached = true;
> > + return devm_add_action_or_reset(dev, mipi_dbi_detach, dbidev);
> > +}
> > +EXPORT_SYMBOL_GPL(devm_mipi_dbi_attach);
> > +
> > +/**
> > + * mipi_dbi_write_buffer_multi() - mipi_dbi_command() w/ accum_err but for
> > + * MIPI DBI Type A and B
> > + * @ctx: context for multiple DBI transactions
> > + * @cmd: command to be sent
> > + * @data: buffer containing data to be transmitted
> > + * @len: size of transmission buffer
> > + *
> > + * Acts like mipi_dbi_command() for MIPI DBI Type C but for Types A and B
> > + * and deals with errors in a way that makes it convenient to make several
> > + * calls in a row.
> > + */
> > +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
> > + u8 cmd, const u8 *data, size_t len)
> > +{
> > + struct mipi_dbi_device *dbidev = ctx->dbidev;
> > + struct device *dev = &dbidev->dev;
> > + ssize_t ret;
>
> mipi_dbi_command_stackbuf returns an int, so this can be an int as well.
>
This is deliberately void, errors are accumulated in context. This
repeats DSI approach.
> > +
> > + if (ctx->accum_err)
> > + return;
> > +
> > + ret = mipi_dbi_command_stackbuf(dbidev->dbi, cmd, data, len);
> > + if (ret < 0) {
> > + ctx->accum_err = ret;
> > + dev_err(dev, "sending dcs data %*ph failed: %d\n",
> > + (int)len, data, ctx->accum_err);
> > + }
> > +}
> > +EXPORT_SYMBOL(mipi_dbi_write_buffer_multi);
> > +
> > +static int mipi_dbi_drv_probe(struct device *dev)
> > +{
> > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> > +
> > + return drv->probe(dbidev);
> > +}
> > +
> > +static int mipi_dbi_drv_remove(struct device *dev)
> > +{
> > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> > +
> > + drv->remove(dbidev);
> > +
> > + return 0;
> > +}
> > +
> > +static void mipi_dbi_drv_shutdown(struct device *dev)
> > +{
> > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> > +
> > + drv->shutdown(dbidev);
> > +}
>
> This could be simplified slightly by making these (probe, remove,
> shutdown) bus-level callbacks (set on mipi_dbi_bus_type). Then the
> callback assignments in __mipi_dbi_driver_register are not needed. The
> 'if's do have to move into the bus-level callbacks. This also cleans up
> the remove callback return type.
>
I have added these to match DSI behavior as more established framework.
> > +
> > +/**
> > + * __mipi_dbi_driver_register() - register a driver for MIPI DBI Type A or B devices.
> > + * @drv: DBI driver structure
> > + * @owner: owner module
> > + *
> > + * Return: 0 on success or a negative error code on failure.
> > + */
> > +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner)
> > +{
> > + drv->driver.bus = &mipi_dbi_bus_type;
> > + drv->driver.owner = owner;
> > +
> > + if (drv->probe)
> > + drv->driver.probe = mipi_dbi_drv_probe;
> > + if (drv->remove)
> > + drv->driver.remove = mipi_dbi_drv_remove;
> > + if (drv->shutdown)
> > + drv->driver.shutdown = mipi_dbi_drv_shutdown;
> > +
> > + return driver_register(&drv->driver);
> > +}
> > +EXPORT_SYMBOL_GPL(__mipi_dbi_driver_register);
> > +
> > +/**
> > + * mipi_dbi_driver_unregister() - unregister a driver for MIPI DBI Type A or B devices.
> > + * @drv: DBI driver structure
> > + */
> > +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv)
> > +{
> > + driver_unregister(&drv->driver);
> > +}
> > +EXPORT_SYMBOL_GPL(mipi_dbi_driver_unregister);
> > +
> > +static int __init mipi_dbi_bus_init(void)
> > +{
> > + return bus_register(&mipi_dbi_bus_type);
> > +}
> > +subsys_initcall(mipi_dbi_bus_init);
> > +
> > +static void __exit mipi_dbi_bus_exit(void)
> > +{
> > + bus_unregister(&mipi_dbi_bus_type);
> > +}
> > +module_exit(mipi_dbi_bus_exit);
> > +
> > +MODULE_DESCRIPTION("MIPI DBI devices with command transport through parallel interface");
> > +MODULE_LICENSE("GPL");
> > diff --git a/include/drm/drm_mipi_dbi_bus.h b/include/drm/drm_mipi_dbi_bus.h
> > new file mode 100644
> > index 0000000000000..6f00a8eef9c67
> > --- /dev/null
> > +++ b/include/drm/drm_mipi_dbi_bus.h
> > @@ -0,0 +1,148 @@
> > +/* SPDX-License-Identifier: GPL-2.0-or-later */
> > +/*
> > + * MIPI DBI devices with command transport through parallel interface
> > + *
> > + * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
> > + * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
> > + */
> > +
> > +#ifndef __DRM_MIPI_DBI_BUS_H__
> > +#define __DRM_MIPI_DBI_BUS_H__
> > +
> > +#include <linux/device.h>
> > +#include <linux/module.h>
> > +
> > +struct device_node;
> > +struct mipi_dbi;
> > +struct mipi_dbi_device;
> > +struct mipi_dbi_host;
> > +
> > +/**
> > + * struct mipi_dbi_host_ops - DBI bus operations for MIPI DBI Type A and B.
> > + * @attach: attach DBI device to DBI host
> > + * @detach: detach DBI device from DBI host
> > + */
> > +struct mipi_dbi_host_ops {
> > + int (*attach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
> > + void (*detach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
> > +};
> > +
> > +/**
> > + * struct mipi_dbi_host - DBI host device for MIPI DBI Type A and B.
> > + * @dev: driver model device node for this DBI host
> > + * @dbi: MIPI DBI interface
> > + * @ops: DBI host operations
> > + */
> > +struct mipi_dbi_host {
> > + struct device *dev;
> > + struct mipi_dbi *dbi;
> > + const struct mipi_dbi_host_ops *ops;
> > +};
> > +
> > +/**
> > + * struct mipi_dbi_device - DBI peripheral device for MIPI DBI Type A and B.
> > + * This structure describes a peripheral DBI device,
> > + * an endpoint for DSC commands and video data, and must
>
> DCS commands
>
Nodes
> > + * be paired with a DBI host device for MIPI DBI Type A
> > + * and B. This layout is built to closely resemble
> > + * the DSI framework.
> > + *
> > + * If your device is MIPI DBI Type C (with an SPI
> > + * control bus) and incorporates DBI within, you
> > + * should use the mipi_dbi_dev structure and Type C
> > + * framework from drm_mipi_dbi.c.
>
> I don't think we need to talk about the DSI or Type C frameworks here.
> drm_mipi_dbi.c already mentions it's for Type C.
>
I was explicit since Thierry and Maxime were very clear that
differences are not described enough.
> > + * @dev: driver model device node for this peripheral
> > + * @dbi: MIPI DBI interface
> > + * @host: DBI host for this peripheral
> > + * @attached: the DBI device has been successfully attached
> > + */
> > +struct mipi_dbi_device {
> > + struct device dev;
> > + struct mipi_dbi *dbi;
> > + struct mipi_dbi_host *host;
> > + bool attached;
> > +};
> > +
> > +/**
> > + * struct mipi_dbi_multi_context - Context to call multiple MIPI DBI funcs in a row
> > + * @dbidev: Pointer to the peripheral MIPI DBI Type A and B device
> > + * @accum_err: Storage for the accumulated error over the multiple calls
> > + * Init to 0. If a function encounters an error then the error code
> > + * will be stored here. If you call a function and this points to a
> > + * non-zero value then the function will be a noop. This allows calling
> > + * a function many times in a row and just checking the error at the
> > + * end to see if any of them failed.
> > + */
> > +
> > +struct mipi_dbi_multi_context {
> > + struct mipi_dbi_device *dbidev;
> > + int accum_err;
> > +};
> > +
> > +#define to_mipi_dbi_device(__dev) container_of_const(__dev, struct mipi_dbi_device, dev)
> > +
> > +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
> > + u8 cmd, const u8 *data, size_t len);
> > +
> > +/**
> > + * mipi_dbi_write_seq_multi() - transmit a command with payload
> > + *
> > + * This macro will print errors for you and error handling is optimized for
> > + * callers that call this multiple times in a row.
> > + *
> > + * @ctx: context for multiple DBI transactions
> > + * @cmd: command to be sent
> > + * @seq: buffer containing data to be transmitted
> > + */
> > +#define mipi_dbi_write_seq_multi(ctx, cmd, seq...) \
> > + do { \
> > + static const u8 d[] = { seq }; \
> > + mipi_dbi_write_buffer_multi(ctx, cmd, d, ARRAY_SIZE(d)); \
> > + } while (0)
> > +
> > +struct mipi_dbi_device *
> > +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
> > + struct device_node *np);
> > +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev);
> > +
> > +/**
> > + * struct mipi_dbi_driver - DBI driver for MIPI DBI Type A and B.
> > + * @driver: device driver model driver
> > + * @probe: callback for device binding
> > + * @remove: callback for device unbinding
> > + * @shutdown: called at shutdown time to quiesce the device
> > + */
> > +struct mipi_dbi_driver {
> > + struct device_driver driver;
> > + int (*probe)(struct mipi_dbi_device *dbi);
> > + void (*remove)(struct mipi_dbi_device *dbi);
> > + void (*shutdown)(struct mipi_dbi_device *dbi);
> > +};
> > +
> > +static inline struct mipi_dbi_driver *
> > +to_mipi_dbi_driver(struct device_driver *driver)
> > +{
> > + return container_of(driver, struct mipi_dbi_driver, driver);
> > +}
> > +
> > +static inline void *mipi_dbi_get_drvdata(const struct mipi_dbi_device *dbi)
> > +{
> > + return dev_get_drvdata(&dbi->dev);
> > +}
> > +
> > +static inline void mipi_dbi_set_drvdata(struct mipi_dbi_device *dbi, void *data)
> > +{
> > + dev_set_drvdata(&dbi->dev, data);
> > +}
> > +
> > +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner);
> > +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv);
> > +
> > +#define mipi_dbi_driver_register(driver) \
> > + __mipi_dbi_driver_register(driver, THIS_MODULE)
> > +
> > +#define module_mipi_dbi_driver(__mipi_dbi_driver) \
> > + module_driver(__mipi_dbi_driver, mipi_dbi_driver_register, \
> > + mipi_dbi_driver_unregister)
> > +
> > +#endif /* __DRM_MIPI_DBI_BUS__ */
>
> __DRM_MIPI_DBI_BUS_H__
>
Noted
> > --
> > 2.53.0
> >
> >
>
>
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B
2026-11-27 9:06 ` Svyatoslav Ryhel
@ 2026-11-27 12:14 ` Mikko Perttunen
2026-11-27 13:05 ` Svyatoslav Ryhel
0 siblings, 1 reply; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 12:14 UTC (permalink / raw)
To: devicetree
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Friday, November 27, 2026 6:06 PM Svyatoslav Ryhel wrote:
> пт, 27 лист. 2026 р. о 06:16 Mikko Perttunen <mperttunen@nvidia.com> пише:
> >
> > On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > > The MIPI DBI bus allows modeling DBI hosts and peripherals using the Linux
> > > driver model. DBI hosts are registered by their respective drivers. During
> > > registration, DBI peripherals are created from the device tree nodes
> > > provided by the host.
> > >
> > > DBI hosts expose operations that can be used by peripheral drivers to
> > > access associated devices.
> > >
> > > This implementation adds support for MIPI DBI Type A and Type B only.
> > > Type C support existing in drm_mipi_dbi.c was not altered. The framework
> > > is modeled to closely resemble the existing MIPI DSI setup for seamless
> > > integration.
> > >
> > > Suggested-by: Mikko Perttunen <mperttunen@nvidia.com> # preliminary sketch
> > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > ---
> > > drivers/gpu/drm/Makefile | 2 +-
> > > drivers/gpu/drm/drm_mipi_dbi_bus.c | 287 +++++++++++++++++++++++++++++
> > > include/drm/drm_mipi_dbi_bus.h | 148 +++++++++++++++
> > > 3 files changed, 436 insertions(+), 1 deletion(-)
> > > create mode 100644 drivers/gpu/drm/drm_mipi_dbi_bus.c
> > > create mode 100644 include/drm/drm_mipi_dbi_bus.h
> > >
> > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > > index 2c6bc093a923a..880f0dc930b85 100644
> > > --- a/drivers/gpu/drm/Makefile
> > > +++ b/drivers/gpu/drm/Makefile
> > > @@ -166,7 +166,7 @@ obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
> > >
> > > obj-y += tests/
> > >
> > > -obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o
> > > +obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o drm_mipi_dbi_bus.o
> > > obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
> > > obj-y += arm/
> > > obj-y += clients/
> > > diff --git a/drivers/gpu/drm/drm_mipi_dbi_bus.c b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> > > new file mode 100644
> > > index 0000000000000..4b51de5bdf0b5
> > > --- /dev/null
> > > +++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> > > @@ -0,0 +1,287 @@
> > > +// SPDX-License-Identifier: GPL-2.0-or-later
> > > +/*
> > > + * MIPI DBI devices with command transport through parallel interface
> > > + *
> > > + * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
> > > + * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
> > > + */
> > > +
> > > +#include <linux/err.h>
> > > +#include <linux/init.h>
> > > +#include <linux/of.h>
> > > +#include <linux/of_device.h>
> > > +#include <linux/pm_runtime.h>
> > > +#include <linux/slab.h>
> > > +
> > > +#include <drm/drm_mipi_dbi.h>
> > > +#include <drm/drm_mipi_dbi_bus.h>
> > > +
> > > +/**
> > > + * DOC: overview
> > > + *
> > > + * There are three MIPI DBI implementation types:
> > > + *
> > > + * A. Motorola 6800-type parallel bus
> > > + *
> > > + * B. Intel 8080-type parallel bus
> > > + *
> > > + * C. SPI-type with three options:
> > > + *
> > > + * 1. 9-bit with the Data/Command signal as the ninth bit
> > > + * 2. Same as above, except it is sent as 16 bits
> > > + * 3. 8-bit with the Data/Command signal as a separate D/CX pin
> > > + *
> > > + * This library provides a framework for MIPI Display Bus Interface (DBI)
> > > + * compatible display controllers using Type A and Type B. This
> > > + * implementation closely matches existing DSI framework behavior to
> > > + * allow seamless integration.
> > > + *
> > > + * Type C options 1 and 3 are covered by drm_mipi_dbi.c with
> > > + * mipi_dbi_spi_init().
> > > + */
> > > +
> > > +static int mipi_dbi_match(struct device *dev, const struct device_driver *driver)
> > > +{
> > > + return of_driver_match_device(dev, driver);
> > > +}
> > > +
> > > +static int mipi_dbi_uevent(const struct device *dev, struct kobj_uevent_env *env)
> > > +{
> > > + return of_device_uevent_modalias(dev, env);
> > > +}
> > > +
> > > +static const struct dev_pm_ops mipi_dbi_device_pm_ops = {
> > > + .runtime_suspend = pm_generic_runtime_suspend,
> > > + .runtime_resume = pm_generic_runtime_resume,
> > > + .suspend = pm_generic_suspend,
> > > + .resume = pm_generic_resume,
> > > + .freeze = pm_generic_freeze,
> > > + .thaw = pm_generic_thaw,
> > > + .poweroff = pm_generic_poweroff,
> > > + .restore = pm_generic_restore,
> > > +};
> > > +
> > > +static const struct bus_type mipi_dbi_bus_type = {
> > > + .name = "mipi-dbi",
> > > + .match = mipi_dbi_match,
> > > + .uevent = mipi_dbi_uevent,
> >
> > These two callbacks are just direct wrappers so I believe we should be
> > able to set them to of_driver_match_device / of_device_uevent_modalias
> > directly.
> >
>
> May you specify a bit more please?
mipi_dbi_match just calls of_driver_match_device and mipi_dbi_uevent
just calls of_device_uevent_modalias. So rather than having the
mipi_dbi_* functions, we should be able to assign the of_* functions
here directly.
>
> > > + .pm = &mipi_dbi_device_pm_ops,
> >
> > I think we can drop setting .pm as well. These callbacks will fall back
> > to the same code (driver callbacks) if we don't set the bus PM ops.
> >
>
> Noted.
>
> > > +};
> > > +
> > > +static void mipi_dbi_device_release(struct device *dev)
> > > +{
> > > + of_node_put(dev->of_node);
> > > + kfree(to_mipi_dbi_device(dev));
> > > +}
> > > +
> > > +static void mipi_dbi_device_unregister(void *data)
> > > +{
> > > + struct device *dev = data;
> > > +
> > > + of_node_clear_flag(dev->of_node, OF_POPULATED);
> > > + device_unregister(dev);
> > > +}
> > > +
> > > +/**
> > > + * devm_mipi_dbi_device_register() - create a managed peripheral MIPI DBI
> > > + * Type A or B device.
> > > + * @dev: device to tie the MIPI-DBI device lifetime to
> > > + * @host: DBI host to which this device is connected
> > > + * @np: device tree node associated with the panel MIPI DBI device
> > > + *
> > > + * This function is called by DBI host driver to create panel device.
> > > + * It automatically calls mipi_dbi_device_unregister() when @dev is
> > > + * unbound. It does not automatically free passed device node pointer,
> > > + * it must be put manually.
> > > + *
> > > + * Returns:
> > > + * A pointer to the newly created MIPI DBI device, or, a pointer encoded
> > > + * with an error.
> >
> > For brevity, I would just use 'an error pointer'.
> >
>
> Noted
>
> > > + */
> > > +struct mipi_dbi_device *
> > > +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
> > > + struct device_node *np)
> > > +{
> > > + struct mipi_dbi_device *dbidev;
> > > + int ret;
> > > +
> > > + if (!host || !host->dev || !host->dbi || !host->dbi->command ||
> > > + !host->ops || !host->ops->attach || !host->ops->detach || !np)
> > > + return ERR_PTR(-EINVAL);
> > > +
> > > + if (!of_device_is_available(np))
> > > + return ERR_PTR(-ENODEV);
> > > +
> > > + dbidev = kzalloc_obj(*dbidev);
> > > + if (!dbidev)
> > > + return ERR_PTR(-ENOMEM);
> > > +
> > > + if (of_node_test_and_set_flag(np, OF_POPULATED)) {
> > > + kfree(dbidev);
> > > + return ERR_PTR(-EBUSY);
> > > + }
> > > +
> > > + dbidev->host = host;
> > > + dbidev->dbi = host->dbi;
> > > + device_initialize(&dbidev->dev);
> > > + dbidev->dev.parent = host->dev;
> > > + dbidev->dev.bus = &mipi_dbi_bus_type;
> > > + dbidev->dev.release = mipi_dbi_device_release;
> > > + device_set_node(&dbidev->dev, of_fwnode_handle(of_node_get(np)));
> > > +
> > > + ret = dev_set_name(&dbidev->dev, "%s:%s", dev_name(host->dev), np->full_name);
> > > + if (ret)
> > > + goto put_device;
> > > +
> > > + ret = device_add(&dbidev->dev);
> > > + if (ret)
> > > + goto put_device;
> > > +
> > > + ret = devm_add_action_or_reset(dev, mipi_dbi_device_unregister,
> > > + &dbidev->dev);
> > > + if (ret)
> > > + return ERR_PTR(ret);
> > > +
> > > + return dbidev;
> > > +
> > > +put_device:
> > > + of_node_clear_flag(np, OF_POPULATED);
> > > + put_device(&dbidev->dev);
> > > + return ERR_PTR(ret);
> > > +}
> > > +EXPORT_SYMBOL_GPL(devm_mipi_dbi_device_register);
> > > +
> > > +static void mipi_dbi_detach(void *data)
> > > +{
> > > + struct mipi_dbi_device *dbidev = data;
> > > +
> > > + dbidev->host->ops->detach(dbidev->host, dbidev);
> > > + dbidev->attached = false;
> > > +}
> > > +
> > > +/**
> > > + * devm_mipi_dbi_attach() - managed attach of peripheral DBI device to its MIPI
> > > + * DBI Type A or B devices.
> > > + * @dev: device to tie the MIPI-DBI device lifetime to
> > > + * @dbidev: DBI peripheral
> >
> > Add a return value description. Otherwise inevitably someone will send
> > an autogenerated oneline fix to add it.
> >
>
> Noted
>
> > > + */
> > > +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev)
> > > +{
> > > + int ret;
> > > +
> > > + if (dbidev->attached)
> > > + return -EBUSY;
> > > +
> > > + ret = dbidev->host->ops->attach(dbidev->host, dbidev);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + dbidev->attached = true;
> > > + return devm_add_action_or_reset(dev, mipi_dbi_detach, dbidev);
> > > +}
> > > +EXPORT_SYMBOL_GPL(devm_mipi_dbi_attach);
> > > +
> > > +/**
> > > + * mipi_dbi_write_buffer_multi() - mipi_dbi_command() w/ accum_err but for
> > > + * MIPI DBI Type A and B
> > > + * @ctx: context for multiple DBI transactions
> > > + * @cmd: command to be sent
> > > + * @data: buffer containing data to be transmitted
> > > + * @len: size of transmission buffer
> > > + *
> > > + * Acts like mipi_dbi_command() for MIPI DBI Type C but for Types A and B
> > > + * and deals with errors in a way that makes it convenient to make several
> > > + * calls in a row.
> > > + */
> > > +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
> > > + u8 cmd, const u8 *data, size_t len)
> > > +{
> > > + struct mipi_dbi_device *dbidev = ctx->dbidev;
> > > + struct device *dev = &dbidev->dev;
> > > + ssize_t ret;
> >
> > mipi_dbi_command_stackbuf returns an int, so this can be an int as well.
> >
>
> This is deliberately void, errors are accumulated in context. This
> repeats DSI approach.
I mean the type of the 'ret' variable.
>
> > > +
> > > + if (ctx->accum_err)
> > > + return;
> > > +
> > > + ret = mipi_dbi_command_stackbuf(dbidev->dbi, cmd, data, len);
> > > + if (ret < 0) {
> > > + ctx->accum_err = ret;
> > > + dev_err(dev, "sending dcs data %*ph failed: %d\n",
> > > + (int)len, data, ctx->accum_err);
> > > + }
> > > +}
> > > +EXPORT_SYMBOL(mipi_dbi_write_buffer_multi);
> > > +
> > > +static int mipi_dbi_drv_probe(struct device *dev)
> > > +{
> > > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> > > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> > > +
> > > + return drv->probe(dbidev);
> > > +}
> > > +
> > > +static int mipi_dbi_drv_remove(struct device *dev)
> > > +{
> > > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> > > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> > > +
> > > + drv->remove(dbidev);
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +static void mipi_dbi_drv_shutdown(struct device *dev)
> > > +{
> > > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> > > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> > > +
> > > + drv->shutdown(dbidev);
> > > +}
> >
> > This could be simplified slightly by making these (probe, remove,
> > shutdown) bus-level callbacks (set on mipi_dbi_bus_type). Then the
> > callback assignments in __mipi_dbi_driver_register are not needed. The
> > 'if's do have to move into the bus-level callbacks. This also cleans up
> > the remove callback return type.
> >
>
> I have added these to match DSI behavior as more established framework.
Well, there are other established frameworks that have the bus-level
functions. But both approaches are pretty much equal in complexity so
either one is fine.
>
> > > +
> > > +/**
> > > + * __mipi_dbi_driver_register() - register a driver for MIPI DBI Type A or B devices.
> > > + * @drv: DBI driver structure
> > > + * @owner: owner module
> > > + *
> > > + * Return: 0 on success or a negative error code on failure.
> > > + */
> > > +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner)
> > > +{
> > > + drv->driver.bus = &mipi_dbi_bus_type;
> > > + drv->driver.owner = owner;
> > > +
> > > + if (drv->probe)
> > > + drv->driver.probe = mipi_dbi_drv_probe;
> > > + if (drv->remove)
> > > + drv->driver.remove = mipi_dbi_drv_remove;
> > > + if (drv->shutdown)
> > > + drv->driver.shutdown = mipi_dbi_drv_shutdown;
> > > +
> > > + return driver_register(&drv->driver);
> > > +}
> > > +EXPORT_SYMBOL_GPL(__mipi_dbi_driver_register);
> > > +
> > > +/**
> > > + * mipi_dbi_driver_unregister() - unregister a driver for MIPI DBI Type A or B devices.
> > > + * @drv: DBI driver structure
> > > + */
> > > +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv)
> > > +{
> > > + driver_unregister(&drv->driver);
> > > +}
> > > +EXPORT_SYMBOL_GPL(mipi_dbi_driver_unregister);
> > > +
> > > +static int __init mipi_dbi_bus_init(void)
> > > +{
> > > + return bus_register(&mipi_dbi_bus_type);
> > > +}
> > > +subsys_initcall(mipi_dbi_bus_init);
> > > +
> > > +static void __exit mipi_dbi_bus_exit(void)
> > > +{
> > > + bus_unregister(&mipi_dbi_bus_type);
> > > +}
> > > +module_exit(mipi_dbi_bus_exit);
> > > +
> > > +MODULE_DESCRIPTION("MIPI DBI devices with command transport through parallel interface");
> > > +MODULE_LICENSE("GPL");
> > > diff --git a/include/drm/drm_mipi_dbi_bus.h b/include/drm/drm_mipi_dbi_bus.h
> > > new file mode 100644
> > > index 0000000000000..6f00a8eef9c67
> > > --- /dev/null
> > > +++ b/include/drm/drm_mipi_dbi_bus.h
> > > @@ -0,0 +1,148 @@
> > > +/* SPDX-License-Identifier: GPL-2.0-or-later */
> > > +/*
> > > + * MIPI DBI devices with command transport through parallel interface
> > > + *
> > > + * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
> > > + * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
> > > + */
> > > +
> > > +#ifndef __DRM_MIPI_DBI_BUS_H__
> > > +#define __DRM_MIPI_DBI_BUS_H__
> > > +
> > > +#include <linux/device.h>
> > > +#include <linux/module.h>
> > > +
> > > +struct device_node;
> > > +struct mipi_dbi;
> > > +struct mipi_dbi_device;
> > > +struct mipi_dbi_host;
> > > +
> > > +/**
> > > + * struct mipi_dbi_host_ops - DBI bus operations for MIPI DBI Type A and B.
> > > + * @attach: attach DBI device to DBI host
> > > + * @detach: detach DBI device from DBI host
> > > + */
> > > +struct mipi_dbi_host_ops {
> > > + int (*attach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
> > > + void (*detach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
> > > +};
> > > +
> > > +/**
> > > + * struct mipi_dbi_host - DBI host device for MIPI DBI Type A and B.
> > > + * @dev: driver model device node for this DBI host
> > > + * @dbi: MIPI DBI interface
> > > + * @ops: DBI host operations
> > > + */
> > > +struct mipi_dbi_host {
> > > + struct device *dev;
> > > + struct mipi_dbi *dbi;
> > > + const struct mipi_dbi_host_ops *ops;
> > > +};
> > > +
> > > +/**
> > > + * struct mipi_dbi_device - DBI peripheral device for MIPI DBI Type A and B.
> > > + * This structure describes a peripheral DBI device,
> > > + * an endpoint for DSC commands and video data, and must
> >
> > DCS commands
> >
>
> Nodes
>
> > > + * be paired with a DBI host device for MIPI DBI Type A
> > > + * and B. This layout is built to closely resemble
> > > + * the DSI framework.
> > > + *
> > > + * If your device is MIPI DBI Type C (with an SPI
> > > + * control bus) and incorporates DBI within, you
> > > + * should use the mipi_dbi_dev structure and Type C
> > > + * framework from drm_mipi_dbi.c.
> >
> > I don't think we need to talk about the DSI or Type C frameworks here.
> > drm_mipi_dbi.c already mentions it's for Type C.
> >
>
> I was explicit since Thierry and Maxime were very clear that
> differences are not described enough.
>
> > > + * @dev: driver model device node for this peripheral
> > > + * @dbi: MIPI DBI interface
> > > + * @host: DBI host for this peripheral
> > > + * @attached: the DBI device has been successfully attached
> > > + */
> > > +struct mipi_dbi_device {
> > > + struct device dev;
> > > + struct mipi_dbi *dbi;
> > > + struct mipi_dbi_host *host;
> > > + bool attached;
> > > +};
> > > +
> > > +/**
> > > + * struct mipi_dbi_multi_context - Context to call multiple MIPI DBI funcs in a row
> > > + * @dbidev: Pointer to the peripheral MIPI DBI Type A and B device
> > > + * @accum_err: Storage for the accumulated error over the multiple calls
> > > + * Init to 0. If a function encounters an error then the error code
> > > + * will be stored here. If you call a function and this points to a
> > > + * non-zero value then the function will be a noop. This allows calling
> > > + * a function many times in a row and just checking the error at the
> > > + * end to see if any of them failed.
> > > + */
> > > +
> > > +struct mipi_dbi_multi_context {
> > > + struct mipi_dbi_device *dbidev;
> > > + int accum_err;
> > > +};
> > > +
> > > +#define to_mipi_dbi_device(__dev) container_of_const(__dev, struct mipi_dbi_device, dev)
> > > +
> > > +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
> > > + u8 cmd, const u8 *data, size_t len);
> > > +
> > > +/**
> > > + * mipi_dbi_write_seq_multi() - transmit a command with payload
> > > + *
> > > + * This macro will print errors for you and error handling is optimized for
> > > + * callers that call this multiple times in a row.
> > > + *
> > > + * @ctx: context for multiple DBI transactions
> > > + * @cmd: command to be sent
> > > + * @seq: buffer containing data to be transmitted
> > > + */
> > > +#define mipi_dbi_write_seq_multi(ctx, cmd, seq...) \
> > > + do { \
> > > + static const u8 d[] = { seq }; \
> > > + mipi_dbi_write_buffer_multi(ctx, cmd, d, ARRAY_SIZE(d)); \
> > > + } while (0)
> > > +
> > > +struct mipi_dbi_device *
> > > +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
> > > + struct device_node *np);
> > > +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev);
> > > +
> > > +/**
> > > + * struct mipi_dbi_driver - DBI driver for MIPI DBI Type A and B.
> > > + * @driver: device driver model driver
> > > + * @probe: callback for device binding
> > > + * @remove: callback for device unbinding
> > > + * @shutdown: called at shutdown time to quiesce the device
> > > + */
> > > +struct mipi_dbi_driver {
> > > + struct device_driver driver;
> > > + int (*probe)(struct mipi_dbi_device *dbi);
> > > + void (*remove)(struct mipi_dbi_device *dbi);
> > > + void (*shutdown)(struct mipi_dbi_device *dbi);
> > > +};
> > > +
> > > +static inline struct mipi_dbi_driver *
> > > +to_mipi_dbi_driver(struct device_driver *driver)
> > > +{
> > > + return container_of(driver, struct mipi_dbi_driver, driver);
> > > +}
> > > +
> > > +static inline void *mipi_dbi_get_drvdata(const struct mipi_dbi_device *dbi)
> > > +{
> > > + return dev_get_drvdata(&dbi->dev);
> > > +}
> > > +
> > > +static inline void mipi_dbi_set_drvdata(struct mipi_dbi_device *dbi, void *data)
> > > +{
> > > + dev_set_drvdata(&dbi->dev, data);
> > > +}
> > > +
> > > +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner);
> > > +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv);
> > > +
> > > +#define mipi_dbi_driver_register(driver) \
> > > + __mipi_dbi_driver_register(driver, THIS_MODULE)
> > > +
> > > +#define module_mipi_dbi_driver(__mipi_dbi_driver) \
> > > + module_driver(__mipi_dbi_driver, mipi_dbi_driver_register, \
> > > + mipi_dbi_driver_unregister)
> > > +
> > > +#endif /* __DRM_MIPI_DBI_BUS__ */
> >
> > __DRM_MIPI_DBI_BUS_H__
> >
>
> Noted
>
> > > --
> > > 2.53.0
> > >
> > >
> >
> >
> >
> >
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B
2026-11-27 12:14 ` Mikko Perttunen
@ 2026-11-27 13:05 ` Svyatoslav Ryhel
0 siblings, 0 replies; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-27 13:05 UTC (permalink / raw)
To: Mikko Perttunen
Cc: devicetree, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Jonathan Hunter, Neil Armstrong,
Jessica Zhang, dri-devel, linux-tegra, linux-kernel
пт, 27 лист. 2026 р. о 14:20 Mikko Perttunen <mperttunen@nvidia.com> пише:
>
> On Friday, November 27, 2026 6:06 PM Svyatoslav Ryhel wrote:
> > пт, 27 лист. 2026 р. о 06:16 Mikko Perttunen <mperttunen@nvidia.com> пише:
> > >
> > > On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > > > The MIPI DBI bus allows modeling DBI hosts and peripherals using the Linux
> > > > driver model. DBI hosts are registered by their respective drivers. During
> > > > registration, DBI peripherals are created from the device tree nodes
> > > > provided by the host.
> > > >
> > > > DBI hosts expose operations that can be used by peripheral drivers to
> > > > access associated devices.
> > > >
> > > > This implementation adds support for MIPI DBI Type A and Type B only.
> > > > Type C support existing in drm_mipi_dbi.c was not altered. The framework
> > > > is modeled to closely resemble the existing MIPI DSI setup for seamless
> > > > integration.
> > > >
> > > > Suggested-by: Mikko Perttunen <mperttunen@nvidia.com> # preliminary sketch
> > > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > ---
> > > > drivers/gpu/drm/Makefile | 2 +-
> > > > drivers/gpu/drm/drm_mipi_dbi_bus.c | 287 +++++++++++++++++++++++++++++
> > > > include/drm/drm_mipi_dbi_bus.h | 148 +++++++++++++++
> > > > 3 files changed, 436 insertions(+), 1 deletion(-)
> > > > create mode 100644 drivers/gpu/drm/drm_mipi_dbi_bus.c
> > > > create mode 100644 include/drm/drm_mipi_dbi_bus.h
> > > >
> > > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > > > index 2c6bc093a923a..880f0dc930b85 100644
> > > > --- a/drivers/gpu/drm/Makefile
> > > > +++ b/drivers/gpu/drm/Makefile
> > > > @@ -166,7 +166,7 @@ obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
> > > >
> > > > obj-y += tests/
> > > >
> > > > -obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o
> > > > +obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o drm_mipi_dbi_bus.o
> > > > obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
> > > > obj-y += arm/
> > > > obj-y += clients/
> > > > diff --git a/drivers/gpu/drm/drm_mipi_dbi_bus.c b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> > > > new file mode 100644
> > > > index 0000000000000..4b51de5bdf0b5
> > > > --- /dev/null
> > > > +++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> > > > @@ -0,0 +1,287 @@
> > > > +// SPDX-License-Identifier: GPL-2.0-or-later
> > > > +/*
> > > > + * MIPI DBI devices with command transport through parallel interface
> > > > + *
> > > > + * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
> > > > + * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
> > > > + */
> > > > +
> > > > +#include <linux/err.h>
> > > > +#include <linux/init.h>
> > > > +#include <linux/of.h>
> > > > +#include <linux/of_device.h>
> > > > +#include <linux/pm_runtime.h>
> > > > +#include <linux/slab.h>
> > > > +
> > > > +#include <drm/drm_mipi_dbi.h>
> > > > +#include <drm/drm_mipi_dbi_bus.h>
> > > > +
> > > > +/**
> > > > + * DOC: overview
> > > > + *
> > > > + * There are three MIPI DBI implementation types:
> > > > + *
> > > > + * A. Motorola 6800-type parallel bus
> > > > + *
> > > > + * B. Intel 8080-type parallel bus
> > > > + *
> > > > + * C. SPI-type with three options:
> > > > + *
> > > > + * 1. 9-bit with the Data/Command signal as the ninth bit
> > > > + * 2. Same as above, except it is sent as 16 bits
> > > > + * 3. 8-bit with the Data/Command signal as a separate D/CX pin
> > > > + *
> > > > + * This library provides a framework for MIPI Display Bus Interface (DBI)
> > > > + * compatible display controllers using Type A and Type B. This
> > > > + * implementation closely matches existing DSI framework behavior to
> > > > + * allow seamless integration.
> > > > + *
> > > > + * Type C options 1 and 3 are covered by drm_mipi_dbi.c with
> > > > + * mipi_dbi_spi_init().
> > > > + */
> > > > +
> > > > +static int mipi_dbi_match(struct device *dev, const struct device_driver *driver)
> > > > +{
> > > > + return of_driver_match_device(dev, driver);
> > > > +}
> > > > +
> > > > +static int mipi_dbi_uevent(const struct device *dev, struct kobj_uevent_env *env)
> > > > +{
> > > > + return of_device_uevent_modalias(dev, env);
> > > > +}
> > > > +
> > > > +static const struct dev_pm_ops mipi_dbi_device_pm_ops = {
> > > > + .runtime_suspend = pm_generic_runtime_suspend,
> > > > + .runtime_resume = pm_generic_runtime_resume,
> > > > + .suspend = pm_generic_suspend,
> > > > + .resume = pm_generic_resume,
> > > > + .freeze = pm_generic_freeze,
> > > > + .thaw = pm_generic_thaw,
> > > > + .poweroff = pm_generic_poweroff,
> > > > + .restore = pm_generic_restore,
> > > > +};
> > > > +
> > > > +static const struct bus_type mipi_dbi_bus_type = {
> > > > + .name = "mipi-dbi",
> > > > + .match = mipi_dbi_match,
> > > > + .uevent = mipi_dbi_uevent,
> > >
> > > These two callbacks are just direct wrappers so I believe we should be
> > > able to set them to of_driver_match_device / of_device_uevent_modalias
> > > directly.
> > >
> >
> > May you specify a bit more please?
>
> mipi_dbi_match just calls of_driver_match_device and mipi_dbi_uevent
> just calls of_device_uevent_modalias. So rather than having the
> mipi_dbi_* functions, we should be able to assign the of_* functions
> here directly.
>
Noted
> >
> > > > + .pm = &mipi_dbi_device_pm_ops,
> > >
> > > I think we can drop setting .pm as well. These callbacks will fall back
> > > to the same code (driver callbacks) if we don't set the bus PM ops.
> > >
> >
> > Noted.
> >
> > > > +};
> > > > +
> > > > +static void mipi_dbi_device_release(struct device *dev)
> > > > +{
> > > > + of_node_put(dev->of_node);
> > > > + kfree(to_mipi_dbi_device(dev));
> > > > +}
> > > > +
> > > > +static void mipi_dbi_device_unregister(void *data)
> > > > +{
> > > > + struct device *dev = data;
> > > > +
> > > > + of_node_clear_flag(dev->of_node, OF_POPULATED);
> > > > + device_unregister(dev);
> > > > +}
> > > > +
> > > > +/**
> > > > + * devm_mipi_dbi_device_register() - create a managed peripheral MIPI DBI
> > > > + * Type A or B device.
> > > > + * @dev: device to tie the MIPI-DBI device lifetime to
> > > > + * @host: DBI host to which this device is connected
> > > > + * @np: device tree node associated with the panel MIPI DBI device
> > > > + *
> > > > + * This function is called by DBI host driver to create panel device.
> > > > + * It automatically calls mipi_dbi_device_unregister() when @dev is
> > > > + * unbound. It does not automatically free passed device node pointer,
> > > > + * it must be put manually.
> > > > + *
> > > > + * Returns:
> > > > + * A pointer to the newly created MIPI DBI device, or, a pointer encoded
> > > > + * with an error.
> > >
> > > For brevity, I would just use 'an error pointer'.
> > >
> >
> > Noted
> >
> > > > + */
> > > > +struct mipi_dbi_device *
> > > > +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
> > > > + struct device_node *np)
> > > > +{
> > > > + struct mipi_dbi_device *dbidev;
> > > > + int ret;
> > > > +
> > > > + if (!host || !host->dev || !host->dbi || !host->dbi->command ||
> > > > + !host->ops || !host->ops->attach || !host->ops->detach || !np)
> > > > + return ERR_PTR(-EINVAL);
> > > > +
> > > > + if (!of_device_is_available(np))
> > > > + return ERR_PTR(-ENODEV);
> > > > +
> > > > + dbidev = kzalloc_obj(*dbidev);
> > > > + if (!dbidev)
> > > > + return ERR_PTR(-ENOMEM);
> > > > +
> > > > + if (of_node_test_and_set_flag(np, OF_POPULATED)) {
> > > > + kfree(dbidev);
> > > > + return ERR_PTR(-EBUSY);
> > > > + }
> > > > +
> > > > + dbidev->host = host;
> > > > + dbidev->dbi = host->dbi;
> > > > + device_initialize(&dbidev->dev);
> > > > + dbidev->dev.parent = host->dev;
> > > > + dbidev->dev.bus = &mipi_dbi_bus_type;
> > > > + dbidev->dev.release = mipi_dbi_device_release;
> > > > + device_set_node(&dbidev->dev, of_fwnode_handle(of_node_get(np)));
> > > > +
> > > > + ret = dev_set_name(&dbidev->dev, "%s:%s", dev_name(host->dev), np->full_name);
> > > > + if (ret)
> > > > + goto put_device;
> > > > +
> > > > + ret = device_add(&dbidev->dev);
> > > > + if (ret)
> > > > + goto put_device;
> > > > +
> > > > + ret = devm_add_action_or_reset(dev, mipi_dbi_device_unregister,
> > > > + &dbidev->dev);
> > > > + if (ret)
> > > > + return ERR_PTR(ret);
> > > > +
> > > > + return dbidev;
> > > > +
> > > > +put_device:
> > > > + of_node_clear_flag(np, OF_POPULATED);
> > > > + put_device(&dbidev->dev);
> > > > + return ERR_PTR(ret);
> > > > +}
> > > > +EXPORT_SYMBOL_GPL(devm_mipi_dbi_device_register);
> > > > +
> > > > +static void mipi_dbi_detach(void *data)
> > > > +{
> > > > + struct mipi_dbi_device *dbidev = data;
> > > > +
> > > > + dbidev->host->ops->detach(dbidev->host, dbidev);
> > > > + dbidev->attached = false;
> > > > +}
> > > > +
> > > > +/**
> > > > + * devm_mipi_dbi_attach() - managed attach of peripheral DBI device to its MIPI
> > > > + * DBI Type A or B devices.
> > > > + * @dev: device to tie the MIPI-DBI device lifetime to
> > > > + * @dbidev: DBI peripheral
> > >
> > > Add a return value description. Otherwise inevitably someone will send
> > > an autogenerated oneline fix to add it.
> > >
> >
> > Noted
> >
> > > > + */
> > > > +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev)
> > > > +{
> > > > + int ret;
> > > > +
> > > > + if (dbidev->attached)
> > > > + return -EBUSY;
> > > > +
> > > > + ret = dbidev->host->ops->attach(dbidev->host, dbidev);
> > > > + if (ret)
> > > > + return ret;
> > > > +
> > > > + dbidev->attached = true;
> > > > + return devm_add_action_or_reset(dev, mipi_dbi_detach, dbidev);
> > > > +}
> > > > +EXPORT_SYMBOL_GPL(devm_mipi_dbi_attach);
> > > > +
> > > > +/**
> > > > + * mipi_dbi_write_buffer_multi() - mipi_dbi_command() w/ accum_err but for
> > > > + * MIPI DBI Type A and B
> > > > + * @ctx: context for multiple DBI transactions
> > > > + * @cmd: command to be sent
> > > > + * @data: buffer containing data to be transmitted
> > > > + * @len: size of transmission buffer
> > > > + *
> > > > + * Acts like mipi_dbi_command() for MIPI DBI Type C but for Types A and B
> > > > + * and deals with errors in a way that makes it convenient to make several
> > > > + * calls in a row.
> > > > + */
> > > > +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
> > > > + u8 cmd, const u8 *data, size_t len)
> > > > +{
> > > > + struct mipi_dbi_device *dbidev = ctx->dbidev;
> > > > + struct device *dev = &dbidev->dev;
> > > > + ssize_t ret;
> > >
> > > mipi_dbi_command_stackbuf returns an int, so this can be an int as well.
> > >
> >
> > This is deliberately void, errors are accumulated in context. This
> > repeats DSI approach.
>
> I mean the type of the 'ret' variable.
>
oh, yes, good find.
> >
> > > > +
> > > > + if (ctx->accum_err)
> > > > + return;
> > > > +
> > > > + ret = mipi_dbi_command_stackbuf(dbidev->dbi, cmd, data, len);
> > > > + if (ret < 0) {
> > > > + ctx->accum_err = ret;
> > > > + dev_err(dev, "sending dcs data %*ph failed: %d\n",
> > > > + (int)len, data, ctx->accum_err);
> > > > + }
> > > > +}
> > > > +EXPORT_SYMBOL(mipi_dbi_write_buffer_multi);
> > > > +
> > > > +static int mipi_dbi_drv_probe(struct device *dev)
> > > > +{
> > > > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> > > > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> > > > +
> > > > + return drv->probe(dbidev);
> > > > +}
> > > > +
> > > > +static int mipi_dbi_drv_remove(struct device *dev)
> > > > +{
> > > > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> > > > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> > > > +
> > > > + drv->remove(dbidev);
> > > > +
> > > > + return 0;
> > > > +}
> > > > +
> > > > +static void mipi_dbi_drv_shutdown(struct device *dev)
> > > > +{
> > > > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver);
> > > > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev);
> > > > +
> > > > + drv->shutdown(dbidev);
> > > > +}
> > >
> > > This could be simplified slightly by making these (probe, remove,
> > > shutdown) bus-level callbacks (set on mipi_dbi_bus_type). Then the
> > > callback assignments in __mipi_dbi_driver_register are not needed. The
> > > 'if's do have to move into the bus-level callbacks. This also cleans up
> > > the remove callback return type.
> > >
> >
> > I have added these to match DSI behavior as more established framework.
>
> Well, there are other established frameworks that have the bus-level
> functions. But both approaches are pretty much equal in complexity so
> either one is fine.
>
I will test with bus level calls.
> >
> > > > +
> > > > +/**
> > > > + * __mipi_dbi_driver_register() - register a driver for MIPI DBI Type A or B devices.
> > > > + * @drv: DBI driver structure
> > > > + * @owner: owner module
> > > > + *
> > > > + * Return: 0 on success or a negative error code on failure.
> > > > + */
> > > > +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner)
> > > > +{
> > > > + drv->driver.bus = &mipi_dbi_bus_type;
> > > > + drv->driver.owner = owner;
> > > > +
> > > > + if (drv->probe)
> > > > + drv->driver.probe = mipi_dbi_drv_probe;
> > > > + if (drv->remove)
> > > > + drv->driver.remove = mipi_dbi_drv_remove;
> > > > + if (drv->shutdown)
> > > > + drv->driver.shutdown = mipi_dbi_drv_shutdown;
> > > > +
> > > > + return driver_register(&drv->driver);
> > > > +}
> > > > +EXPORT_SYMBOL_GPL(__mipi_dbi_driver_register);
> > > > +
> > > > +/**
> > > > + * mipi_dbi_driver_unregister() - unregister a driver for MIPI DBI Type A or B devices.
> > > > + * @drv: DBI driver structure
> > > > + */
> > > > +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv)
> > > > +{
> > > > + driver_unregister(&drv->driver);
> > > > +}
> > > > +EXPORT_SYMBOL_GPL(mipi_dbi_driver_unregister);
> > > > +
> > > > +static int __init mipi_dbi_bus_init(void)
> > > > +{
> > > > + return bus_register(&mipi_dbi_bus_type);
> > > > +}
> > > > +subsys_initcall(mipi_dbi_bus_init);
> > > > +
> > > > +static void __exit mipi_dbi_bus_exit(void)
> > > > +{
> > > > + bus_unregister(&mipi_dbi_bus_type);
> > > > +}
> > > > +module_exit(mipi_dbi_bus_exit);
> > > > +
> > > > +MODULE_DESCRIPTION("MIPI DBI devices with command transport through parallel interface");
> > > > +MODULE_LICENSE("GPL");
> > > > diff --git a/include/drm/drm_mipi_dbi_bus.h b/include/drm/drm_mipi_dbi_bus.h
> > > > new file mode 100644
> > > > index 0000000000000..6f00a8eef9c67
> > > > --- /dev/null
> > > > +++ b/include/drm/drm_mipi_dbi_bus.h
> > > > @@ -0,0 +1,148 @@
> > > > +/* SPDX-License-Identifier: GPL-2.0-or-later */
> > > > +/*
> > > > + * MIPI DBI devices with command transport through parallel interface
> > > > + *
> > > > + * Copyright 2026 Mikko Perttunen <mperttunen@nvidia.com>
> > > > + * Copyright 2026 Svyatoslav Ryhel <clamor95@gmail.com>
> > > > + */
> > > > +
> > > > +#ifndef __DRM_MIPI_DBI_BUS_H__
> > > > +#define __DRM_MIPI_DBI_BUS_H__
> > > > +
> > > > +#include <linux/device.h>
> > > > +#include <linux/module.h>
> > > > +
> > > > +struct device_node;
> > > > +struct mipi_dbi;
> > > > +struct mipi_dbi_device;
> > > > +struct mipi_dbi_host;
> > > > +
> > > > +/**
> > > > + * struct mipi_dbi_host_ops - DBI bus operations for MIPI DBI Type A and B.
> > > > + * @attach: attach DBI device to DBI host
> > > > + * @detach: detach DBI device from DBI host
> > > > + */
> > > > +struct mipi_dbi_host_ops {
> > > > + int (*attach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
> > > > + void (*detach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev);
> > > > +};
> > > > +
> > > > +/**
> > > > + * struct mipi_dbi_host - DBI host device for MIPI DBI Type A and B.
> > > > + * @dev: driver model device node for this DBI host
> > > > + * @dbi: MIPI DBI interface
> > > > + * @ops: DBI host operations
> > > > + */
> > > > +struct mipi_dbi_host {
> > > > + struct device *dev;
> > > > + struct mipi_dbi *dbi;
> > > > + const struct mipi_dbi_host_ops *ops;
> > > > +};
> > > > +
> > > > +/**
> > > > + * struct mipi_dbi_device - DBI peripheral device for MIPI DBI Type A and B.
> > > > + * This structure describes a peripheral DBI device,
> > > > + * an endpoint for DSC commands and video data, and must
> > >
> > > DCS commands
> > >
> >
> > Nodes
> >
> > > > + * be paired with a DBI host device for MIPI DBI Type A
> > > > + * and B. This layout is built to closely resemble
> > > > + * the DSI framework.
> > > > + *
> > > > + * If your device is MIPI DBI Type C (with an SPI
> > > > + * control bus) and incorporates DBI within, you
> > > > + * should use the mipi_dbi_dev structure and Type C
> > > > + * framework from drm_mipi_dbi.c.
> > >
> > > I don't think we need to talk about the DSI or Type C frameworks here.
> > > drm_mipi_dbi.c already mentions it's for Type C.
> > >
> >
> > I was explicit since Thierry and Maxime were very clear that
> > differences are not described enough.
> >
> > > > + * @dev: driver model device node for this peripheral
> > > > + * @dbi: MIPI DBI interface
> > > > + * @host: DBI host for this peripheral
> > > > + * @attached: the DBI device has been successfully attached
> > > > + */
> > > > +struct mipi_dbi_device {
> > > > + struct device dev;
> > > > + struct mipi_dbi *dbi;
> > > > + struct mipi_dbi_host *host;
> > > > + bool attached;
> > > > +};
> > > > +
> > > > +/**
> > > > + * struct mipi_dbi_multi_context - Context to call multiple MIPI DBI funcs in a row
> > > > + * @dbidev: Pointer to the peripheral MIPI DBI Type A and B device
> > > > + * @accum_err: Storage for the accumulated error over the multiple calls
> > > > + * Init to 0. If a function encounters an error then the error code
> > > > + * will be stored here. If you call a function and this points to a
> > > > + * non-zero value then the function will be a noop. This allows calling
> > > > + * a function many times in a row and just checking the error at the
> > > > + * end to see if any of them failed.
> > > > + */
> > > > +
> > > > +struct mipi_dbi_multi_context {
> > > > + struct mipi_dbi_device *dbidev;
> > > > + int accum_err;
> > > > +};
> > > > +
> > > > +#define to_mipi_dbi_device(__dev) container_of_const(__dev, struct mipi_dbi_device, dev)
> > > > +
> > > > +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx,
> > > > + u8 cmd, const u8 *data, size_t len);
> > > > +
> > > > +/**
> > > > + * mipi_dbi_write_seq_multi() - transmit a command with payload
> > > > + *
> > > > + * This macro will print errors for you and error handling is optimized for
> > > > + * callers that call this multiple times in a row.
> > > > + *
> > > > + * @ctx: context for multiple DBI transactions
> > > > + * @cmd: command to be sent
> > > > + * @seq: buffer containing data to be transmitted
> > > > + */
> > > > +#define mipi_dbi_write_seq_multi(ctx, cmd, seq...) \
> > > > + do { \
> > > > + static const u8 d[] = { seq }; \
> > > > + mipi_dbi_write_buffer_multi(ctx, cmd, d, ARRAY_SIZE(d)); \
> > > > + } while (0)
> > > > +
> > > > +struct mipi_dbi_device *
> > > > +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
> > > > + struct device_node *np);
> > > > +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev);
> > > > +
> > > > +/**
> > > > + * struct mipi_dbi_driver - DBI driver for MIPI DBI Type A and B.
> > > > + * @driver: device driver model driver
> > > > + * @probe: callback for device binding
> > > > + * @remove: callback for device unbinding
> > > > + * @shutdown: called at shutdown time to quiesce the device
> > > > + */
> > > > +struct mipi_dbi_driver {
> > > > + struct device_driver driver;
> > > > + int (*probe)(struct mipi_dbi_device *dbi);
> > > > + void (*remove)(struct mipi_dbi_device *dbi);
> > > > + void (*shutdown)(struct mipi_dbi_device *dbi);
> > > > +};
> > > > +
> > > > +static inline struct mipi_dbi_driver *
> > > > +to_mipi_dbi_driver(struct device_driver *driver)
> > > > +{
> > > > + return container_of(driver, struct mipi_dbi_driver, driver);
> > > > +}
> > > > +
> > > > +static inline void *mipi_dbi_get_drvdata(const struct mipi_dbi_device *dbi)
> > > > +{
> > > > + return dev_get_drvdata(&dbi->dev);
> > > > +}
> > > > +
> > > > +static inline void mipi_dbi_set_drvdata(struct mipi_dbi_device *dbi, void *data)
> > > > +{
> > > > + dev_set_drvdata(&dbi->dev, data);
> > > > +}
> > > > +
> > > > +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner);
> > > > +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv);
> > > > +
> > > > +#define mipi_dbi_driver_register(driver) \
> > > > + __mipi_dbi_driver_register(driver, THIS_MODULE)
> > > > +
> > > > +#define module_mipi_dbi_driver(__mipi_dbi_driver) \
> > > > + module_driver(__mipi_dbi_driver, mipi_dbi_driver_register, \
> > > > + mipi_dbi_driver_unregister)
> > > > +
> > > > +#endif /* __DRM_MIPI_DBI_BUS__ */
> > >
> > > __DRM_MIPI_DBI_BUS_H__
> > >
> >
> > Noted
> >
> > > > --
> > > > 2.53.0
> > > >
> > > >
> > >
> > >
> > >
> > >
>
>
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
2026-11-22 8:18 ` [PATCH v8 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-27 4:23 ` Mikko Perttunen
2026-11-22 8:18 ` [PATCH v8 03/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
` (9 subsequent siblings)
11 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
Switch from a generic platform driver to a dedicated MIPI DBI Type B
driver.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
.../drm/panel/panel-hitachi-tx10d07vm0baa.c | 25 +++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
index 83c2af1be9755..318ece68b7806 100644
--- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
+++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
@@ -14,6 +14,7 @@
#include <video/mipi_display.h>
#include <drm/drm_mipi_dbi.h>
+#include <drm/drm_mipi_dbi_bus.h>
#include <drm/drm_modes.h>
#include <drm/drm_of.h>
#include <drm/drm_panel.h>
@@ -25,7 +26,7 @@ static const struct regulator_bulk_data hitachi_tx10d07vm0baa_supplies[] = {
struct hitachi_tx10d07vm0baa {
struct drm_panel panel;
- struct mipi_dbi *dbi;
+ struct mipi_dbi_device *dbidev;
struct regulator_bulk_data *supplies;
struct gpio_desc *reset_gpio;
@@ -40,9 +41,10 @@ static inline struct hitachi_tx10d07vm0baa *to_hitachi_tx10d07vm0baa(struct drm_
({ \
const u8 d[] = { seq }; \
struct drm_panel *panel = &(priv)->panel; \
+ struct mipi_dbi_device *dbidev = (priv)->dbidev; \
struct device *dev = panel->dev; \
int ret; \
- ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); \
+ ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
if (ret) \
dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
ret; \
@@ -54,10 +56,6 @@ static int hitachi_tx10d07vm0baa_prepare(struct drm_panel *panel)
struct device *dev = panel->dev;
int ret;
- priv->dbi = dev_get_drvdata(dev->parent);
- if (!priv->dbi)
- return -ENODEV;
-
gpiod_set_value_cansleep(priv->reset_gpio, 1);
ret = regulator_bulk_enable(ARRAY_SIZE(hitachi_tx10d07vm0baa_supplies), priv->supplies);
@@ -243,9 +241,9 @@ static const struct drm_panel_funcs hitachi_tx10d07vm0baa_panel_funcs = {
.get_modes = hitachi_tx10d07vm0baa_get_modes,
};
-static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
+static int hitachi_tx10d07vm0baa_probe(struct mipi_dbi_device *dbidev)
{
- struct device *dev = &pdev->dev;
+ struct device *dev = &dbidev->dev;
struct hitachi_tx10d07vm0baa *priv;
int ret;
@@ -264,6 +262,9 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
"Failed to get reset gpio\n");
+ priv->dbidev = dbidev;
+ mipi_dbi_set_drvdata(dbidev, priv);
+
ret = drm_panel_of_backlight(&priv->panel);
if (ret)
return dev_err_probe(dev, ret, "Failed to get backlight\n");
@@ -272,9 +273,7 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret, "Failed to add panel\n");
- platform_set_drvdata(pdev, priv);
-
- return 0;
+ return devm_mipi_dbi_attach(dev, dbidev);
}
static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
@@ -283,14 +282,14 @@ static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
};
MODULE_DEVICE_TABLE(of, hitachi_tx10d07vm0baa_of_match);
-static struct platform_driver hitachi_tx10d07vm0baa_driver = {
+static struct mipi_dbi_driver hitachi_tx10d07vm0baa_driver = {
.driver = {
.name = "panel-hitachi-tx10d07vm0baa",
.of_match_table = hitachi_tx10d07vm0baa_of_match,
},
.probe = hitachi_tx10d07vm0baa_probe,
};
-module_platform_driver(hitachi_tx10d07vm0baa_driver);
+module_mipi_dbi_driver(hitachi_tx10d07vm0baa_driver);
MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>");
MODULE_DESCRIPTION("HITACHI TX10D07VM0BAA MIPI DBI Type B panel driver");
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* Re: [PATCH v8 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus
2026-11-22 8:18 ` [PATCH v8 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus Svyatoslav Ryhel
@ 2026-11-27 4:23 ` Mikko Perttunen
2026-11-27 9:10 ` Svyatoslav Ryhel
0 siblings, 1 reply; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 4:23 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Svyatoslav Ryhel, devicetree
Cc: dri-devel, devicetree, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> Switch from a generic platform driver to a dedicated MIPI DBI Type B
> driver.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> .../drm/panel/panel-hitachi-tx10d07vm0baa.c | 25 +++++++++----------
> 1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> index 83c2af1be9755..318ece68b7806 100644
> --- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> +++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> @@ -14,6 +14,7 @@
> #include <video/mipi_display.h>
>
> #include <drm/drm_mipi_dbi.h>
> +#include <drm/drm_mipi_dbi_bus.h>
> #include <drm/drm_modes.h>
> #include <drm/drm_of.h>
> #include <drm/drm_panel.h>
You should now be able to get rid of includes of of_platform.h
(replacing with of.h) and platform_device.h. Agent says drm_of.h and
property.h are also unused.
> @@ -25,7 +26,7 @@ static const struct regulator_bulk_data hitachi_tx10d07vm0baa_supplies[] = {
>
> struct hitachi_tx10d07vm0baa {
> struct drm_panel panel;
> - struct mipi_dbi *dbi;
> + struct mipi_dbi_device *dbidev;
>
> struct regulator_bulk_data *supplies;
> struct gpio_desc *reset_gpio;
> @@ -40,9 +41,10 @@ static inline struct hitachi_tx10d07vm0baa *to_hitachi_tx10d07vm0baa(struct drm_
> ({ \
> const u8 d[] = { seq }; \
> struct drm_panel *panel = &(priv)->panel; \
> + struct mipi_dbi_device *dbidev = (priv)->dbidev; \
> struct device *dev = panel->dev; \
> int ret; \
> - ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); \
> + ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
> if (ret) \
> dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
> ret; \
> @@ -54,10 +56,6 @@ static int hitachi_tx10d07vm0baa_prepare(struct drm_panel *panel)
> struct device *dev = panel->dev;
> int ret;
>
> - priv->dbi = dev_get_drvdata(dev->parent);
> - if (!priv->dbi)
> - return -ENODEV;
> -
> gpiod_set_value_cansleep(priv->reset_gpio, 1);
>
> ret = regulator_bulk_enable(ARRAY_SIZE(hitachi_tx10d07vm0baa_supplies), priv->supplies);
> @@ -243,9 +241,9 @@ static const struct drm_panel_funcs hitachi_tx10d07vm0baa_panel_funcs = {
> .get_modes = hitachi_tx10d07vm0baa_get_modes,
> };
Unnecessary semicolon here.
>
> -static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> +static int hitachi_tx10d07vm0baa_probe(struct mipi_dbi_device *dbidev)
> {
> - struct device *dev = &pdev->dev;
> + struct device *dev = &dbidev->dev;
> struct hitachi_tx10d07vm0baa *priv;
> int ret;
>
> @@ -264,6 +262,9 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
> "Failed to get reset gpio\n");
>
> + priv->dbidev = dbidev;
> + mipi_dbi_set_drvdata(dbidev, priv);
> +
> ret = drm_panel_of_backlight(&priv->panel);
> if (ret)
> return dev_err_probe(dev, ret, "Failed to get backlight\n");
> @@ -272,9 +273,7 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> if (ret)
> return dev_err_probe(dev, ret, "Failed to add panel\n");
>
> - platform_set_drvdata(pdev, priv);
> -
> - return 0;
> + return devm_mipi_dbi_attach(dev, dbidev);
> }
>
> static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
> @@ -283,14 +282,14 @@ static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
> };
> MODULE_DEVICE_TABLE(of, hitachi_tx10d07vm0baa_of_match);
>
> -static struct platform_driver hitachi_tx10d07vm0baa_driver = {
> +static struct mipi_dbi_driver hitachi_tx10d07vm0baa_driver = {
> .driver = {
> .name = "panel-hitachi-tx10d07vm0baa",
> .of_match_table = hitachi_tx10d07vm0baa_of_match,
> },
> .probe = hitachi_tx10d07vm0baa_probe,
> };
> -module_platform_driver(hitachi_tx10d07vm0baa_driver);
> +module_mipi_dbi_driver(hitachi_tx10d07vm0baa_driver);
>
> MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>");
> MODULE_DESCRIPTION("HITACHI TX10D07VM0BAA MIPI DBI Type B panel driver");
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus
2026-11-27 4:23 ` Mikko Perttunen
@ 2026-11-27 9:10 ` Svyatoslav Ryhel
2026-11-27 12:16 ` Mikko Perttunen
0 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-27 9:10 UTC (permalink / raw)
To: Mikko Perttunen
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel
пт, 27 лист. 2026 р. о 06:23 Mikko Perttunen <mperttunen@nvidia.com> пише:
>
> On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > Switch from a generic platform driver to a dedicated MIPI DBI Type B
> > driver.
> >
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > ---
> > .../drm/panel/panel-hitachi-tx10d07vm0baa.c | 25 +++++++++----------
> > 1 file changed, 12 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> > index 83c2af1be9755..318ece68b7806 100644
> > --- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> > +++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> > @@ -14,6 +14,7 @@
> > #include <video/mipi_display.h>
> >
> > #include <drm/drm_mipi_dbi.h>
> > +#include <drm/drm_mipi_dbi_bus.h>
> > #include <drm/drm_modes.h>
> > #include <drm/drm_of.h>
> > #include <drm/drm_panel.h>
>
> You should now be able to get rid of includes of of_platform.h
> (replacing with of.h) and platform_device.h. Agent says drm_of.h and
> property.h are also unused.
>
> > @@ -25,7 +26,7 @@ static const struct regulator_bulk_data hitachi_tx10d07vm0baa_supplies[] = {
> >
> > struct hitachi_tx10d07vm0baa {
> > struct drm_panel panel;
> > - struct mipi_dbi *dbi;
> > + struct mipi_dbi_device *dbidev;
> >
> > struct regulator_bulk_data *supplies;
> > struct gpio_desc *reset_gpio;
> > @@ -40,9 +41,10 @@ static inline struct hitachi_tx10d07vm0baa *to_hitachi_tx10d07vm0baa(struct drm_
> > ({ \
> > const u8 d[] = { seq }; \
> > struct drm_panel *panel = &(priv)->panel; \
> > + struct mipi_dbi_device *dbidev = (priv)->dbidev; \
> > struct device *dev = panel->dev; \
> > int ret; \
> > - ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); \
> > + ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
> > if (ret) \
> > dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
> > ret; \
> > @@ -54,10 +56,6 @@ static int hitachi_tx10d07vm0baa_prepare(struct drm_panel *panel)
> > struct device *dev = panel->dev;
> > int ret;
> >
> > - priv->dbi = dev_get_drvdata(dev->parent);
> > - if (!priv->dbi)
> > - return -ENODEV;
> > -
> > gpiod_set_value_cansleep(priv->reset_gpio, 1);
> >
> > ret = regulator_bulk_enable(ARRAY_SIZE(hitachi_tx10d07vm0baa_supplies), priv->supplies);
> > @@ -243,9 +241,9 @@ static const struct drm_panel_funcs hitachi_tx10d07vm0baa_panel_funcs = {
> > .get_modes = hitachi_tx10d07vm0baa_get_modes,
> > };
>
> Unnecessary semicolon here.
>
> >
> > -static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> > +static int hitachi_tx10d07vm0baa_probe(struct mipi_dbi_device *dbidev)
> > {
> > - struct device *dev = &pdev->dev;
> > + struct device *dev = &dbidev->dev;
> > struct hitachi_tx10d07vm0baa *priv;
> > int ret;
> >
> > @@ -264,6 +262,9 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> > return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
> > "Failed to get reset gpio\n");
> >
> > + priv->dbidev = dbidev;
> > + mipi_dbi_set_drvdata(dbidev, priv);
> > +
> > ret = drm_panel_of_backlight(&priv->panel);
> > if (ret)
> > return dev_err_probe(dev, ret, "Failed to get backlight\n");
> > @@ -272,9 +273,7 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> > if (ret)
> > return dev_err_probe(dev, ret, "Failed to add panel\n");
> >
> > - platform_set_drvdata(pdev, priv);
> > -
> > - return 0;
> > + return devm_mipi_dbi_attach(dev, dbidev);
> > }
> >
> > static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
> > @@ -283,14 +282,14 @@ static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
> > };
> > MODULE_DEVICE_TABLE(of, hitachi_tx10d07vm0baa_of_match);
> >
> > -static struct platform_driver hitachi_tx10d07vm0baa_driver = {
> > +static struct mipi_dbi_driver hitachi_tx10d07vm0baa_driver = {
> > .driver = {
> > .name = "panel-hitachi-tx10d07vm0baa",
> > .of_match_table = hitachi_tx10d07vm0baa_of_match,
> > },
> > .probe = hitachi_tx10d07vm0baa_probe,
> > };
> > -module_platform_driver(hitachi_tx10d07vm0baa_driver);
> > +module_mipi_dbi_driver(hitachi_tx10d07vm0baa_driver);
> >
> > MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>");
> > MODULE_DESCRIPTION("HITACHI TX10D07VM0BAA MIPI DBI Type B panel driver");
> > --
> > 2.53.0
> >
> >
I agree that your suggestions are ok, but they are out of scope of
this patch. They would require either dedicated commits or can be sent
as followups later on since they do not cause bugs.
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus
2026-11-27 9:10 ` Svyatoslav Ryhel
@ 2026-11-27 12:16 ` Mikko Perttunen
2026-11-27 13:08 ` Svyatoslav Ryhel
0 siblings, 1 reply; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 12:16 UTC (permalink / raw)
To: devicetree
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Friday, November 27, 2026 6:10 PM Svyatoslav Ryhel wrote:
> пт, 27 лист. 2026 р. о 06:23 Mikko Perttunen <mperttunen@nvidia.com> пише:
> >
> > On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > > Switch from a generic platform driver to a dedicated MIPI DBI Type B
> > > driver.
> > >
> > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > ---
> > > .../drm/panel/panel-hitachi-tx10d07vm0baa.c | 25 +++++++++----------
> > > 1 file changed, 12 insertions(+), 13 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> > > index 83c2af1be9755..318ece68b7806 100644
> > > --- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> > > +++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> > > @@ -14,6 +14,7 @@
> > > #include <video/mipi_display.h>
> > >
> > > #include <drm/drm_mipi_dbi.h>
> > > +#include <drm/drm_mipi_dbi_bus.h>
> > > #include <drm/drm_modes.h>
> > > #include <drm/drm_of.h>
> > > #include <drm/drm_panel.h>
> >
> > You should now be able to get rid of includes of of_platform.h
> > (replacing with of.h) and platform_device.h. Agent says drm_of.h and
> > property.h are also unused.
> >
> > > @@ -25,7 +26,7 @@ static const struct regulator_bulk_data hitachi_tx10d07vm0baa_supplies[] = {
> > >
> > > struct hitachi_tx10d07vm0baa {
> > > struct drm_panel panel;
> > > - struct mipi_dbi *dbi;
> > > + struct mipi_dbi_device *dbidev;
> > >
> > > struct regulator_bulk_data *supplies;
> > > struct gpio_desc *reset_gpio;
> > > @@ -40,9 +41,10 @@ static inline struct hitachi_tx10d07vm0baa *to_hitachi_tx10d07vm0baa(struct drm_
> > > ({ \
> > > const u8 d[] = { seq }; \
> > > struct drm_panel *panel = &(priv)->panel; \
> > > + struct mipi_dbi_device *dbidev = (priv)->dbidev; \
> > > struct device *dev = panel->dev; \
> > > int ret; \
> > > - ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); \
> > > + ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
> > > if (ret) \
> > > dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
> > > ret; \
> > > @@ -54,10 +56,6 @@ static int hitachi_tx10d07vm0baa_prepare(struct drm_panel *panel)
> > > struct device *dev = panel->dev;
> > > int ret;
> > >
> > > - priv->dbi = dev_get_drvdata(dev->parent);
> > > - if (!priv->dbi)
> > > - return -ENODEV;
> > > -
> > > gpiod_set_value_cansleep(priv->reset_gpio, 1);
> > >
> > > ret = regulator_bulk_enable(ARRAY_SIZE(hitachi_tx10d07vm0baa_supplies), priv->supplies);
> > > @@ -243,9 +241,9 @@ static const struct drm_panel_funcs hitachi_tx10d07vm0baa_panel_funcs = {
> > > .get_modes = hitachi_tx10d07vm0baa_get_modes,
> > > };
> >
> > Unnecessary semicolon here.
> >
> > >
> > > -static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> > > +static int hitachi_tx10d07vm0baa_probe(struct mipi_dbi_device *dbidev)
> > > {
> > > - struct device *dev = &pdev->dev;
> > > + struct device *dev = &dbidev->dev;
> > > struct hitachi_tx10d07vm0baa *priv;
> > > int ret;
> > >
> > > @@ -264,6 +262,9 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> > > return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
> > > "Failed to get reset gpio\n");
> > >
> > > + priv->dbidev = dbidev;
> > > + mipi_dbi_set_drvdata(dbidev, priv);
> > > +
> > > ret = drm_panel_of_backlight(&priv->panel);
> > > if (ret)
> > > return dev_err_probe(dev, ret, "Failed to get backlight\n");
> > > @@ -272,9 +273,7 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> > > if (ret)
> > > return dev_err_probe(dev, ret, "Failed to add panel\n");
> > >
> > > - platform_set_drvdata(pdev, priv);
> > > -
> > > - return 0;
> > > + return devm_mipi_dbi_attach(dev, dbidev);
> > > }
> > >
> > > static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
> > > @@ -283,14 +282,14 @@ static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
> > > };
> > > MODULE_DEVICE_TABLE(of, hitachi_tx10d07vm0baa_of_match);
> > >
> > > -static struct platform_driver hitachi_tx10d07vm0baa_driver = {
> > > +static struct mipi_dbi_driver hitachi_tx10d07vm0baa_driver = {
> > > .driver = {
> > > .name = "panel-hitachi-tx10d07vm0baa",
> > > .of_match_table = hitachi_tx10d07vm0baa_of_match,
> > > },
> > > .probe = hitachi_tx10d07vm0baa_probe,
> > > };
> > > -module_platform_driver(hitachi_tx10d07vm0baa_driver);
> > > +module_mipi_dbi_driver(hitachi_tx10d07vm0baa_driver);
> > >
> > > MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>");
> > > MODULE_DESCRIPTION("HITACHI TX10D07VM0BAA MIPI DBI Type B panel driver");
> > > --
> > > 2.53.0
> > >
> > >
>
> I agree that your suggestions are ok, but they are out of scope of
> this patch. They would require either dedicated commits or can be sent
> as followups later on since they do not cause bugs.
I don't see why the include changes are out of scope. The platform
driver was including platform includes but now it's no longer a platform
driver so it shouldn't include platform driver stuff. The rest are minor
enough that I think they can be included as well.
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus
2026-11-27 12:16 ` Mikko Perttunen
@ 2026-11-27 13:08 ` Svyatoslav Ryhel
0 siblings, 0 replies; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-27 13:08 UTC (permalink / raw)
To: Mikko Perttunen
Cc: devicetree, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Jonathan Hunter, Neil Armstrong,
Jessica Zhang, dri-devel, linux-tegra, linux-kernel
пт, 27 лист. 2026 р. о 14:20 Mikko Perttunen <mperttunen@nvidia.com> пише:
>
> On Friday, November 27, 2026 6:10 PM Svyatoslav Ryhel wrote:
> > пт, 27 лист. 2026 р. о 06:23 Mikko Perttunen <mperttunen@nvidia.com> пише:
> > >
> > > On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > > > Switch from a generic platform driver to a dedicated MIPI DBI Type B
> > > > driver.
> > > >
> > > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > ---
> > > > .../drm/panel/panel-hitachi-tx10d07vm0baa.c | 25 +++++++++----------
> > > > 1 file changed, 12 insertions(+), 13 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> > > > index 83c2af1be9755..318ece68b7806 100644
> > > > --- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> > > > +++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> > > > @@ -14,6 +14,7 @@
> > > > #include <video/mipi_display.h>
> > > >
> > > > #include <drm/drm_mipi_dbi.h>
> > > > +#include <drm/drm_mipi_dbi_bus.h>
> > > > #include <drm/drm_modes.h>
> > > > #include <drm/drm_of.h>
> > > > #include <drm/drm_panel.h>
> > >
> > > You should now be able to get rid of includes of of_platform.h
> > > (replacing with of.h) and platform_device.h. Agent says drm_of.h and
> > > property.h are also unused.
> > >
> > > > @@ -25,7 +26,7 @@ static const struct regulator_bulk_data hitachi_tx10d07vm0baa_supplies[] = {
> > > >
> > > > struct hitachi_tx10d07vm0baa {
> > > > struct drm_panel panel;
> > > > - struct mipi_dbi *dbi;
> > > > + struct mipi_dbi_device *dbidev;
> > > >
> > > > struct regulator_bulk_data *supplies;
> > > > struct gpio_desc *reset_gpio;
> > > > @@ -40,9 +41,10 @@ static inline struct hitachi_tx10d07vm0baa *to_hitachi_tx10d07vm0baa(struct drm_
> > > > ({ \
> > > > const u8 d[] = { seq }; \
> > > > struct drm_panel *panel = &(priv)->panel; \
> > > > + struct mipi_dbi_device *dbidev = (priv)->dbidev; \
> > > > struct device *dev = panel->dev; \
> > > > int ret; \
> > > > - ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); \
> > > > + ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
> > > > if (ret) \
> > > > dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
> > > > ret; \
> > > > @@ -54,10 +56,6 @@ static int hitachi_tx10d07vm0baa_prepare(struct drm_panel *panel)
> > > > struct device *dev = panel->dev;
> > > > int ret;
> > > >
> > > > - priv->dbi = dev_get_drvdata(dev->parent);
> > > > - if (!priv->dbi)
> > > > - return -ENODEV;
> > > > -
> > > > gpiod_set_value_cansleep(priv->reset_gpio, 1);
> > > >
> > > > ret = regulator_bulk_enable(ARRAY_SIZE(hitachi_tx10d07vm0baa_supplies), priv->supplies);
> > > > @@ -243,9 +241,9 @@ static const struct drm_panel_funcs hitachi_tx10d07vm0baa_panel_funcs = {
> > > > .get_modes = hitachi_tx10d07vm0baa_get_modes,
> > > > };
> > >
> > > Unnecessary semicolon here.
> > >
> > > >
> > > > -static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> > > > +static int hitachi_tx10d07vm0baa_probe(struct mipi_dbi_device *dbidev)
> > > > {
> > > > - struct device *dev = &pdev->dev;
> > > > + struct device *dev = &dbidev->dev;
> > > > struct hitachi_tx10d07vm0baa *priv;
> > > > int ret;
> > > >
> > > > @@ -264,6 +262,9 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> > > > return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
> > > > "Failed to get reset gpio\n");
> > > >
> > > > + priv->dbidev = dbidev;
> > > > + mipi_dbi_set_drvdata(dbidev, priv);
> > > > +
> > > > ret = drm_panel_of_backlight(&priv->panel);
> > > > if (ret)
> > > > return dev_err_probe(dev, ret, "Failed to get backlight\n");
> > > > @@ -272,9 +273,7 @@ static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
> > > > if (ret)
> > > > return dev_err_probe(dev, ret, "Failed to add panel\n");
> > > >
> > > > - platform_set_drvdata(pdev, priv);
> > > > -
> > > > - return 0;
> > > > + return devm_mipi_dbi_attach(dev, dbidev);
> > > > }
> > > >
> > > > static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
> > > > @@ -283,14 +282,14 @@ static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
> > > > };
> > > > MODULE_DEVICE_TABLE(of, hitachi_tx10d07vm0baa_of_match);
> > > >
> > > > -static struct platform_driver hitachi_tx10d07vm0baa_driver = {
> > > > +static struct mipi_dbi_driver hitachi_tx10d07vm0baa_driver = {
> > > > .driver = {
> > > > .name = "panel-hitachi-tx10d07vm0baa",
> > > > .of_match_table = hitachi_tx10d07vm0baa_of_match,
> > > > },
> > > > .probe = hitachi_tx10d07vm0baa_probe,
> > > > };
> > > > -module_platform_driver(hitachi_tx10d07vm0baa_driver);
> > > > +module_mipi_dbi_driver(hitachi_tx10d07vm0baa_driver);
> > > >
> > > > MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>");
> > > > MODULE_DESCRIPTION("HITACHI TX10D07VM0BAA MIPI DBI Type B panel driver");
> > > > --
> > > > 2.53.0
> > > >
> > > >
> >
> > I agree that your suggestions are ok, but they are out of scope of
> > this patch. They would require either dedicated commits or can be sent
> > as followups later on since they do not cause bugs.
>
> I don't see why the include changes are out of scope. The platform
> driver was including platform includes but now it's no longer a platform
> driver so it shouldn't include platform driver stuff. The rest are minor
> enough that I think they can be included as well.
>
I can remove headers, sure. Regarding semicolon, here is a bigger code fragment
static const struct drm_panel_funcs hitachi_tx10d07vm0baa_panel_funcs = {
.prepare = hitachi_tx10d07vm0baa_prepare,
.enable = hitachi_tx10d07vm0baa_enable,
.disable = hitachi_tx10d07vm0baa_disable,
.unprepare = hitachi_tx10d07vm0baa_unprepare,
.get_modes = hitachi_tx10d07vm0baa_get_modes,
};
- static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
+ static int hitachi_tx10d07vm0baa_probe(struct mipi_dbi_device *dbidev)
{
- struct device *dev = &pdev->dev;
+struct device *dev = &dbidev->dev;
struct hitachi_tx10d07vm0baa *priv;
int ret;
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 03/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi()
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
2026-11-22 8:18 ` [PATCH v8 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
2026-11-22 8:18 ` [PATCH v8 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-27 4:40 ` Mikko Perttunen
2026-11-22 8:18 ` [PATCH v8 04/12] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus Svyatoslav Ryhel
` (8 subsequent siblings)
11 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
Switch from the internal panel command-sending macro to a generic one
to improve code reuse.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
.../drm/panel/panel-hitachi-tx10d07vm0baa.c | 213 +++++++++---------
1 file changed, 101 insertions(+), 112 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
index 318ece68b7806..c5b59a7341d8e 100644
--- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
+++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
@@ -37,19 +37,6 @@ static inline struct hitachi_tx10d07vm0baa *to_hitachi_tx10d07vm0baa(struct drm_
return container_of(panel, struct hitachi_tx10d07vm0baa, panel);
}
-#define panel_dbi_command(priv, cmd, seq...) \
-({ \
- const u8 d[] = { seq }; \
- struct drm_panel *panel = &(priv)->panel; \
- struct mipi_dbi_device *dbidev = (priv)->dbidev; \
- struct device *dev = panel->dev; \
- int ret; \
- ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
- if (ret) \
- dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
- ret; \
-})
-
static int hitachi_tx10d07vm0baa_prepare(struct drm_panel *panel)
{
struct hitachi_tx10d07vm0baa *priv = to_hitachi_tx10d07vm0baa(panel);
@@ -76,118 +63,120 @@ static int hitachi_tx10d07vm0baa_prepare(struct drm_panel *panel)
static int hitachi_tx10d07vm0baa_enable(struct drm_panel *panel)
{
struct hitachi_tx10d07vm0baa *priv = to_hitachi_tx10d07vm0baa(panel);
-
- panel_dbi_command(priv, MIPI_DCS_SET_PARTIAL_ROWS, 0x00, 0x00, 0x03, 0x1f);
- panel_dbi_command(priv, MIPI_DCS_SET_SCROLL_AREA, 0x00, 0x00, 0x03, 0x20,
- 0x00, 0x00);
-
- panel_dbi_command(priv, MIPI_DCS_SET_ADDRESS_MODE, 0x0a);
- panel_dbi_command(priv, MIPI_DCS_SET_SCROLL_START, 0x00, 0x00);
-
- panel_dbi_command(priv, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT);
- panel_dbi_command(priv, MIPI_DCS_SET_TEAR_SCANLINE, 0x00, 0x00);
-
- panel_dbi_command(priv, 0x71, 0x00); /* Ex_Vsync_en */
-
- panel_dbi_command(priv, 0xb2, 0x00); /* VCSEL */
- panel_dbi_command(priv, 0xb4, 0xaa); /* setvgmpm */
- panel_dbi_command(priv, 0xb5, 0x33); /* rbias1 */
- panel_dbi_command(priv, 0xb6, 0x03); /* rbias2 */
-
- panel_dbi_command(priv, 0xb7, 0x1a, 0x33, 0x03, 0x03,
- 0x03, 0x00, 0x00, 0x01, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x01, 0x01, 0x01); /* set_ddvdhp */
- panel_dbi_command(priv, 0xb8, 0x1c, 0x53, 0x03, 0x03,
- 0x00, 0x01, 0x02, 0x00, 0x00, 0x04,
- 0x00, 0x01, 0x01); /* set_ddvdhm */
-
- panel_dbi_command(priv, 0xb9, 0x0a, 0x01, 0x01, 0x00,
- 0x00, 0x00, 0x02, 0x00, 0x02, 0x01); /* set_vgh */
- panel_dbi_command(priv, 0xba, 0x0f, 0x01, 0x01, 0x00,
- 0x00, 0x00, 0x02, 0x00, 0x02, 0x01); /* set_vgl */
- panel_dbi_command(priv, 0xbb, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x02, 0x01); /* set_vcl */
-
- panel_dbi_command(priv, 0xc1, 0x01); /* number of lines */
- panel_dbi_command(priv, 0xc2, 0x08); /* number of fp lines */
- panel_dbi_command(priv, 0xc3, 0x04); /* gateset(1) */
- panel_dbi_command(priv, 0xc4, 0x4c); /* 1h period */
- panel_dbi_command(priv, 0xc5, 0x03); /* source precharge */
- panel_dbi_command(priv, 0xc6, 0xc4, 0x04); /* source precharge timing */
- panel_dbi_command(priv, 0xc7, 0x00); /* source level */
- panel_dbi_command(priv, 0xc8, 0x02); /* number of bp lines */
- panel_dbi_command(priv, 0xc9, 0x10); /* gateset(2) */
- panel_dbi_command(priv, 0xca, 0x04, 0x04); /* gateset(3) */
- panel_dbi_command(priv, 0xcb, 0x03); /* gateset(4) */
- panel_dbi_command(priv, 0xcc, 0x12); /* gateset(5) */
- panel_dbi_command(priv, 0xcd, 0x12); /* gateset(6) */
- panel_dbi_command(priv, 0xce, 0x30); /* gateset(7) */
- panel_dbi_command(priv, 0xcf, 0x30); /* gateset(8) */
- panel_dbi_command(priv, 0xd0, 0x40); /* gateset(9) */
- panel_dbi_command(priv, 0xd1, 0x22); /* flhw */
- panel_dbi_command(priv, 0xd2, 0x22); /* vckhw */
- panel_dbi_command(priv, 0xd3, 0x04); /* flt */
- panel_dbi_command(priv, 0xd4, 0x14); /* tctrl */
- panel_dbi_command(priv, 0xd6, 0x02); /* dotinv */
- panel_dbi_command(priv, 0xd7, 0x00); /* on/off sequence period */
-
- panel_dbi_command(priv, 0xd8, 0x01, 0x05, 0x06, 0x0d,
- 0x18, 0x09, 0x22, 0x23, 0x00); /* ponseqa */
- panel_dbi_command(priv, 0xd9, 0x24, 0x01); /* ponseqb */
- panel_dbi_command(priv, 0xde, 0x09, 0x0f, 0x21, 0x12,
- 0x04); /* ponseqc */
-
- panel_dbi_command(priv, 0xdf, 0x02, 0x06, 0x06, 0x06,
- 0x06, 0x00); /* pofseqa */
- panel_dbi_command(priv, 0xe0, 0x01); /* pofseqb */
-
- panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff);
- panel_dbi_command(priv, MIPI_DCS_WRITE_CONTROL_DISPLAY, 0x40);
-
- panel_dbi_command(priv, 0xe2, 0x00, 0x00); /* cabc pwm */
- panel_dbi_command(priv, 0xe3, 0x03); /* cabc */
- panel_dbi_command(priv, 0xe4, 0x66, 0x7b, 0x90, 0xa5,
- 0xbb, 0xc7, 0xe1, 0xe5); /* cabc brightness */
- panel_dbi_command(priv, 0xe5, 0xc5, 0xc5, 0xc9, 0xc9,
- 0xd1, 0xe1, 0xf1, 0xfe); /* cabc brightness */
- panel_dbi_command(priv, 0xe7, 0x2a); /* cabc */
- panel_dbi_command(priv, 0xe8, 0x00); /* brt_rev */
- panel_dbi_command(priv, 0xe9, 0x00); /* tefreq */
-
- panel_dbi_command(priv, 0xea, 0x01); /* high speed ram */
-
- panel_dbi_command(priv, 0xeb, 0x00, 0x33, 0x0e, 0x15,
- 0xb7, 0x78, 0x88, 0x0f); /* gamma setting r pos */
- panel_dbi_command(priv, 0xec, 0x00, 0x33, 0x0e, 0x15,
- 0xb7, 0x78, 0x88, 0x0f); /* gamma setting r neg */
- panel_dbi_command(priv, 0xed, 0x00, 0x33, 0x0e, 0x15,
- 0xb7, 0x78, 0x88, 0x0f); /* gamma setting g pos */
- panel_dbi_command(priv, 0xee, 0x00, 0x33, 0x0e, 0x15,
- 0xb7, 0x78, 0x88, 0x0f); /* gamma setting g neg */
- panel_dbi_command(priv, 0xef, 0x00, 0x33, 0x0e, 0x15,
- 0xb7, 0x78, 0x88, 0x0f); /* gamma setting b pos */
- panel_dbi_command(priv, 0xf0, 0x00, 0x33, 0x0e, 0x15,
- 0xb7, 0x78, 0x88, 0x0f); /* gamma setting b neg */
-
- panel_dbi_command(priv, MIPI_DCS_EXIT_SLEEP_MODE);
+ struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev };
+
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PARTIAL_ROWS, 0x00, 0x00, 0x03, 0x1f);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_SCROLL_AREA, 0x00, 0x00, 0x03, 0x20,
+ 0x00, 0x00);
+
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_ADDRESS_MODE, 0x0a);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_SCROLL_START, 0x00, 0x00);
+
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_TEAR_SCANLINE, 0x00, 0x00);
+
+ mipi_dbi_write_seq_multi(&ctx, 0x71, 0x00); /* Ex_Vsync_en */
+
+ mipi_dbi_write_seq_multi(&ctx, 0xb2, 0x00); /* VCSEL */
+ mipi_dbi_write_seq_multi(&ctx, 0xb4, 0xaa); /* setvgmpm */
+ mipi_dbi_write_seq_multi(&ctx, 0xb5, 0x33); /* rbias1 */
+ mipi_dbi_write_seq_multi(&ctx, 0xb6, 0x03); /* rbias2 */
+
+ mipi_dbi_write_seq_multi(&ctx, 0xb7, 0x1a, 0x33, 0x03, 0x03,
+ 0x03, 0x00, 0x00, 0x01, 0x02, 0x00,
+ 0x00, 0x04, 0x00, 0x01, 0x01, 0x01); /* set_ddvdhp */
+ mipi_dbi_write_seq_multi(&ctx, 0xb8, 0x1c, 0x53, 0x03, 0x03,
+ 0x00, 0x01, 0x02, 0x00, 0x00, 0x04,
+ 0x00, 0x01, 0x01); /* set_ddvdhm */
+
+ mipi_dbi_write_seq_multi(&ctx, 0xb9, 0x0a, 0x01, 0x01, 0x00,
+ 0x00, 0x00, 0x02, 0x00, 0x02, 0x01); /* set_vgh */
+ mipi_dbi_write_seq_multi(&ctx, 0xba, 0x0f, 0x01, 0x01, 0x00,
+ 0x00, 0x00, 0x02, 0x00, 0x02, 0x01); /* set_vgl */
+ mipi_dbi_write_seq_multi(&ctx, 0xbb, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x02, 0x01); /* set_vcl */
+
+ mipi_dbi_write_seq_multi(&ctx, 0xc1, 0x01); /* number of lines */
+ mipi_dbi_write_seq_multi(&ctx, 0xc2, 0x08); /* number of fp lines */
+ mipi_dbi_write_seq_multi(&ctx, 0xc3, 0x04); /* gateset(1) */
+ mipi_dbi_write_seq_multi(&ctx, 0xc4, 0x4c); /* 1h period */
+ mipi_dbi_write_seq_multi(&ctx, 0xc5, 0x03); /* source precharge */
+ mipi_dbi_write_seq_multi(&ctx, 0xc6, 0xc4, 0x04); /* source precharge timing */
+ mipi_dbi_write_seq_multi(&ctx, 0xc7, 0x00); /* source level */
+ mipi_dbi_write_seq_multi(&ctx, 0xc8, 0x02); /* number of bp lines */
+ mipi_dbi_write_seq_multi(&ctx, 0xc9, 0x10); /* gateset(2) */
+ mipi_dbi_write_seq_multi(&ctx, 0xca, 0x04, 0x04); /* gateset(3) */
+ mipi_dbi_write_seq_multi(&ctx, 0xcb, 0x03); /* gateset(4) */
+ mipi_dbi_write_seq_multi(&ctx, 0xcc, 0x12); /* gateset(5) */
+ mipi_dbi_write_seq_multi(&ctx, 0xcd, 0x12); /* gateset(6) */
+ mipi_dbi_write_seq_multi(&ctx, 0xce, 0x30); /* gateset(7) */
+ mipi_dbi_write_seq_multi(&ctx, 0xcf, 0x30); /* gateset(8) */
+ mipi_dbi_write_seq_multi(&ctx, 0xd0, 0x40); /* gateset(9) */
+ mipi_dbi_write_seq_multi(&ctx, 0xd1, 0x22); /* flhw */
+ mipi_dbi_write_seq_multi(&ctx, 0xd2, 0x22); /* vckhw */
+ mipi_dbi_write_seq_multi(&ctx, 0xd3, 0x04); /* flt */
+ mipi_dbi_write_seq_multi(&ctx, 0xd4, 0x14); /* tctrl */
+ mipi_dbi_write_seq_multi(&ctx, 0xd6, 0x02); /* dotinv */
+ mipi_dbi_write_seq_multi(&ctx, 0xd7, 0x00); /* on/off sequence period */
+
+ mipi_dbi_write_seq_multi(&ctx, 0xd8, 0x01, 0x05, 0x06, 0x0d,
+ 0x18, 0x09, 0x22, 0x23, 0x00); /* ponseqa */
+ mipi_dbi_write_seq_multi(&ctx, 0xd9, 0x24, 0x01); /* ponseqb */
+ mipi_dbi_write_seq_multi(&ctx, 0xde, 0x09, 0x0f, 0x21, 0x12,
+ 0x04); /* ponseqc */
+
+ mipi_dbi_write_seq_multi(&ctx, 0xdf, 0x02, 0x06, 0x06, 0x06,
+ 0x06, 0x00); /* pofseqa */
+ mipi_dbi_write_seq_multi(&ctx, 0xe0, 0x01); /* pofseqb */
+
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_WRITE_CONTROL_DISPLAY, 0x40);
+
+ mipi_dbi_write_seq_multi(&ctx, 0xe2, 0x00, 0x00); /* cabc pwm */
+ mipi_dbi_write_seq_multi(&ctx, 0xe3, 0x03); /* cabc */
+ mipi_dbi_write_seq_multi(&ctx, 0xe4, 0x66, 0x7b, 0x90, 0xa5,
+ 0xbb, 0xc7, 0xe1, 0xe5); /* cabc brightness */
+ mipi_dbi_write_seq_multi(&ctx, 0xe5, 0xc5, 0xc5, 0xc9, 0xc9,
+ 0xd1, 0xe1, 0xf1, 0xfe); /* cabc brightness */
+ mipi_dbi_write_seq_multi(&ctx, 0xe7, 0x2a); /* cabc */
+ mipi_dbi_write_seq_multi(&ctx, 0xe8, 0x00); /* brt_rev */
+ mipi_dbi_write_seq_multi(&ctx, 0xe9, 0x00); /* tefreq */
+
+ mipi_dbi_write_seq_multi(&ctx, 0xea, 0x01); /* high speed ram */
+
+ mipi_dbi_write_seq_multi(&ctx, 0xeb, 0x00, 0x33, 0x0e, 0x15,
+ 0xb7, 0x78, 0x88, 0x0f); /* gamma setting r pos */
+ mipi_dbi_write_seq_multi(&ctx, 0xec, 0x00, 0x33, 0x0e, 0x15,
+ 0xb7, 0x78, 0x88, 0x0f); /* gamma setting r neg */
+ mipi_dbi_write_seq_multi(&ctx, 0xed, 0x00, 0x33, 0x0e, 0x15,
+ 0xb7, 0x78, 0x88, 0x0f); /* gamma setting g pos */
+ mipi_dbi_write_seq_multi(&ctx, 0xee, 0x00, 0x33, 0x0e, 0x15,
+ 0xb7, 0x78, 0x88, 0x0f); /* gamma setting g neg */
+ mipi_dbi_write_seq_multi(&ctx, 0xef, 0x00, 0x33, 0x0e, 0x15,
+ 0xb7, 0x78, 0x88, 0x0f); /* gamma setting b pos */
+ mipi_dbi_write_seq_multi(&ctx, 0xf0, 0x00, 0x33, 0x0e, 0x15,
+ 0xb7, 0x78, 0x88, 0x0f); /* gamma setting b neg */
+
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_EXIT_SLEEP_MODE);
msleep(110);
- panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_ON);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_ON);
- return 0;
+ return ctx.accum_err;
}
static int hitachi_tx10d07vm0baa_disable(struct drm_panel *panel)
{
struct hitachi_tx10d07vm0baa *priv = to_hitachi_tx10d07vm0baa(panel);
+ struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev };
- panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_OFF);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_OFF);
msleep(35);
- panel_dbi_command(priv, MIPI_DCS_ENTER_SLEEP_MODE);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_ENTER_SLEEP_MODE);
msleep(50);
- return 0;
+ return ctx.accum_err;
}
static int hitachi_tx10d07vm0baa_unprepare(struct drm_panel *panel)
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* Re: [PATCH v8 03/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi()
2026-11-22 8:18 ` [PATCH v8 03/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
@ 2026-11-27 4:40 ` Mikko Perttunen
0 siblings, 0 replies; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 4:40 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Svyatoslav Ryhel, devicetree
Cc: dri-devel, devicetree, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> Switch from the internal panel command-sending macro to a generic one
> to improve code reuse.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> .../drm/panel/panel-hitachi-tx10d07vm0baa.c | 213 +++++++++---------
> 1 file changed, 101 insertions(+), 112 deletions(-)
>
> diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> index 318ece68b7806..c5b59a7341d8e 100644
> --- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> +++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
> @@ -37,19 +37,6 @@ static inline struct hitachi_tx10d07vm0baa *to_hitachi_tx10d07vm0baa(struct drm_
> return container_of(panel, struct hitachi_tx10d07vm0baa, panel);
> }
>
> -#define panel_dbi_command(priv, cmd, seq...) \
> -({ \
> - const u8 d[] = { seq }; \
> - struct drm_panel *panel = &(priv)->panel; \
> - struct mipi_dbi_device *dbidev = (priv)->dbidev; \
> - struct device *dev = panel->dev; \
> - int ret; \
> - ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
> - if (ret) \
> - dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
> - ret; \
> -})
> -
> static int hitachi_tx10d07vm0baa_prepare(struct drm_panel *panel)
> {
> struct hitachi_tx10d07vm0baa *priv = to_hitachi_tx10d07vm0baa(panel);
> @@ -76,118 +63,120 @@ static int hitachi_tx10d07vm0baa_prepare(struct drm_panel *panel)
> static int hitachi_tx10d07vm0baa_enable(struct drm_panel *panel)
> {
> struct hitachi_tx10d07vm0baa *priv = to_hitachi_tx10d07vm0baa(panel);
> -
> - panel_dbi_command(priv, MIPI_DCS_SET_PARTIAL_ROWS, 0x00, 0x00, 0x03, 0x1f);
> - panel_dbi_command(priv, MIPI_DCS_SET_SCROLL_AREA, 0x00, 0x00, 0x03, 0x20,
> - 0x00, 0x00);
> -
> - panel_dbi_command(priv, MIPI_DCS_SET_ADDRESS_MODE, 0x0a);
> - panel_dbi_command(priv, MIPI_DCS_SET_SCROLL_START, 0x00, 0x00);
> -
> - panel_dbi_command(priv, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT);
> - panel_dbi_command(priv, MIPI_DCS_SET_TEAR_SCANLINE, 0x00, 0x00);
> -
> - panel_dbi_command(priv, 0x71, 0x00); /* Ex_Vsync_en */
> -
> - panel_dbi_command(priv, 0xb2, 0x00); /* VCSEL */
> - panel_dbi_command(priv, 0xb4, 0xaa); /* setvgmpm */
> - panel_dbi_command(priv, 0xb5, 0x33); /* rbias1 */
> - panel_dbi_command(priv, 0xb6, 0x03); /* rbias2 */
> -
> - panel_dbi_command(priv, 0xb7, 0x1a, 0x33, 0x03, 0x03,
> - 0x03, 0x00, 0x00, 0x01, 0x02, 0x00,
> - 0x00, 0x04, 0x00, 0x01, 0x01, 0x01); /* set_ddvdhp */
> - panel_dbi_command(priv, 0xb8, 0x1c, 0x53, 0x03, 0x03,
> - 0x00, 0x01, 0x02, 0x00, 0x00, 0x04,
> - 0x00, 0x01, 0x01); /* set_ddvdhm */
> -
> - panel_dbi_command(priv, 0xb9, 0x0a, 0x01, 0x01, 0x00,
> - 0x00, 0x00, 0x02, 0x00, 0x02, 0x01); /* set_vgh */
> - panel_dbi_command(priv, 0xba, 0x0f, 0x01, 0x01, 0x00,
> - 0x00, 0x00, 0x02, 0x00, 0x02, 0x01); /* set_vgl */
> - panel_dbi_command(priv, 0xbb, 0x00, 0x00, 0x00, 0x00,
> - 0x01, 0x02, 0x01); /* set_vcl */
> -
> - panel_dbi_command(priv, 0xc1, 0x01); /* number of lines */
> - panel_dbi_command(priv, 0xc2, 0x08); /* number of fp lines */
> - panel_dbi_command(priv, 0xc3, 0x04); /* gateset(1) */
> - panel_dbi_command(priv, 0xc4, 0x4c); /* 1h period */
> - panel_dbi_command(priv, 0xc5, 0x03); /* source precharge */
> - panel_dbi_command(priv, 0xc6, 0xc4, 0x04); /* source precharge timing */
> - panel_dbi_command(priv, 0xc7, 0x00); /* source level */
> - panel_dbi_command(priv, 0xc8, 0x02); /* number of bp lines */
> - panel_dbi_command(priv, 0xc9, 0x10); /* gateset(2) */
> - panel_dbi_command(priv, 0xca, 0x04, 0x04); /* gateset(3) */
> - panel_dbi_command(priv, 0xcb, 0x03); /* gateset(4) */
> - panel_dbi_command(priv, 0xcc, 0x12); /* gateset(5) */
> - panel_dbi_command(priv, 0xcd, 0x12); /* gateset(6) */
> - panel_dbi_command(priv, 0xce, 0x30); /* gateset(7) */
> - panel_dbi_command(priv, 0xcf, 0x30); /* gateset(8) */
> - panel_dbi_command(priv, 0xd0, 0x40); /* gateset(9) */
> - panel_dbi_command(priv, 0xd1, 0x22); /* flhw */
> - panel_dbi_command(priv, 0xd2, 0x22); /* vckhw */
> - panel_dbi_command(priv, 0xd3, 0x04); /* flt */
> - panel_dbi_command(priv, 0xd4, 0x14); /* tctrl */
> - panel_dbi_command(priv, 0xd6, 0x02); /* dotinv */
> - panel_dbi_command(priv, 0xd7, 0x00); /* on/off sequence period */
> -
> - panel_dbi_command(priv, 0xd8, 0x01, 0x05, 0x06, 0x0d,
> - 0x18, 0x09, 0x22, 0x23, 0x00); /* ponseqa */
> - panel_dbi_command(priv, 0xd9, 0x24, 0x01); /* ponseqb */
> - panel_dbi_command(priv, 0xde, 0x09, 0x0f, 0x21, 0x12,
> - 0x04); /* ponseqc */
> -
> - panel_dbi_command(priv, 0xdf, 0x02, 0x06, 0x06, 0x06,
> - 0x06, 0x00); /* pofseqa */
> - panel_dbi_command(priv, 0xe0, 0x01); /* pofseqb */
> -
> - panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff);
> - panel_dbi_command(priv, MIPI_DCS_WRITE_CONTROL_DISPLAY, 0x40);
> -
> - panel_dbi_command(priv, 0xe2, 0x00, 0x00); /* cabc pwm */
> - panel_dbi_command(priv, 0xe3, 0x03); /* cabc */
> - panel_dbi_command(priv, 0xe4, 0x66, 0x7b, 0x90, 0xa5,
> - 0xbb, 0xc7, 0xe1, 0xe5); /* cabc brightness */
> - panel_dbi_command(priv, 0xe5, 0xc5, 0xc5, 0xc9, 0xc9,
> - 0xd1, 0xe1, 0xf1, 0xfe); /* cabc brightness */
> - panel_dbi_command(priv, 0xe7, 0x2a); /* cabc */
> - panel_dbi_command(priv, 0xe8, 0x00); /* brt_rev */
> - panel_dbi_command(priv, 0xe9, 0x00); /* tefreq */
> -
> - panel_dbi_command(priv, 0xea, 0x01); /* high speed ram */
> -
> - panel_dbi_command(priv, 0xeb, 0x00, 0x33, 0x0e, 0x15,
> - 0xb7, 0x78, 0x88, 0x0f); /* gamma setting r pos */
> - panel_dbi_command(priv, 0xec, 0x00, 0x33, 0x0e, 0x15,
> - 0xb7, 0x78, 0x88, 0x0f); /* gamma setting r neg */
> - panel_dbi_command(priv, 0xed, 0x00, 0x33, 0x0e, 0x15,
> - 0xb7, 0x78, 0x88, 0x0f); /* gamma setting g pos */
> - panel_dbi_command(priv, 0xee, 0x00, 0x33, 0x0e, 0x15,
> - 0xb7, 0x78, 0x88, 0x0f); /* gamma setting g neg */
> - panel_dbi_command(priv, 0xef, 0x00, 0x33, 0x0e, 0x15,
> - 0xb7, 0x78, 0x88, 0x0f); /* gamma setting b pos */
> - panel_dbi_command(priv, 0xf0, 0x00, 0x33, 0x0e, 0x15,
> - 0xb7, 0x78, 0x88, 0x0f); /* gamma setting b neg */
> -
> - panel_dbi_command(priv, MIPI_DCS_EXIT_SLEEP_MODE);
> + struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev };
> +
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PARTIAL_ROWS, 0x00, 0x00, 0x03, 0x1f);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_SCROLL_AREA, 0x00, 0x00, 0x03, 0x20,
> + 0x00, 0x00);
> +
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_ADDRESS_MODE, 0x0a);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_SCROLL_START, 0x00, 0x00);
> +
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_TEAR_SCANLINE, 0x00, 0x00);
> +
> + mipi_dbi_write_seq_multi(&ctx, 0x71, 0x00); /* Ex_Vsync_en */
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xb2, 0x00); /* VCSEL */
> + mipi_dbi_write_seq_multi(&ctx, 0xb4, 0xaa); /* setvgmpm */
> + mipi_dbi_write_seq_multi(&ctx, 0xb5, 0x33); /* rbias1 */
> + mipi_dbi_write_seq_multi(&ctx, 0xb6, 0x03); /* rbias2 */
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xb7, 0x1a, 0x33, 0x03, 0x03,
> + 0x03, 0x00, 0x00, 0x01, 0x02, 0x00,
> + 0x00, 0x04, 0x00, 0x01, 0x01, 0x01); /* set_ddvdhp */
> + mipi_dbi_write_seq_multi(&ctx, 0xb8, 0x1c, 0x53, 0x03, 0x03,
> + 0x00, 0x01, 0x02, 0x00, 0x00, 0x04,
> + 0x00, 0x01, 0x01); /* set_ddvdhm */
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xb9, 0x0a, 0x01, 0x01, 0x00,
> + 0x00, 0x00, 0x02, 0x00, 0x02, 0x01); /* set_vgh */
> + mipi_dbi_write_seq_multi(&ctx, 0xba, 0x0f, 0x01, 0x01, 0x00,
> + 0x00, 0x00, 0x02, 0x00, 0x02, 0x01); /* set_vgl */
> + mipi_dbi_write_seq_multi(&ctx, 0xbb, 0x00, 0x00, 0x00, 0x00,
> + 0x01, 0x02, 0x01); /* set_vcl */
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xc1, 0x01); /* number of lines */
> + mipi_dbi_write_seq_multi(&ctx, 0xc2, 0x08); /* number of fp lines */
> + mipi_dbi_write_seq_multi(&ctx, 0xc3, 0x04); /* gateset(1) */
> + mipi_dbi_write_seq_multi(&ctx, 0xc4, 0x4c); /* 1h period */
> + mipi_dbi_write_seq_multi(&ctx, 0xc5, 0x03); /* source precharge */
> + mipi_dbi_write_seq_multi(&ctx, 0xc6, 0xc4, 0x04); /* source precharge timing */
> + mipi_dbi_write_seq_multi(&ctx, 0xc7, 0x00); /* source level */
> + mipi_dbi_write_seq_multi(&ctx, 0xc8, 0x02); /* number of bp lines */
> + mipi_dbi_write_seq_multi(&ctx, 0xc9, 0x10); /* gateset(2) */
> + mipi_dbi_write_seq_multi(&ctx, 0xca, 0x04, 0x04); /* gateset(3) */
> + mipi_dbi_write_seq_multi(&ctx, 0xcb, 0x03); /* gateset(4) */
> + mipi_dbi_write_seq_multi(&ctx, 0xcc, 0x12); /* gateset(5) */
> + mipi_dbi_write_seq_multi(&ctx, 0xcd, 0x12); /* gateset(6) */
> + mipi_dbi_write_seq_multi(&ctx, 0xce, 0x30); /* gateset(7) */
> + mipi_dbi_write_seq_multi(&ctx, 0xcf, 0x30); /* gateset(8) */
> + mipi_dbi_write_seq_multi(&ctx, 0xd0, 0x40); /* gateset(9) */
> + mipi_dbi_write_seq_multi(&ctx, 0xd1, 0x22); /* flhw */
> + mipi_dbi_write_seq_multi(&ctx, 0xd2, 0x22); /* vckhw */
> + mipi_dbi_write_seq_multi(&ctx, 0xd3, 0x04); /* flt */
> + mipi_dbi_write_seq_multi(&ctx, 0xd4, 0x14); /* tctrl */
> + mipi_dbi_write_seq_multi(&ctx, 0xd6, 0x02); /* dotinv */
> + mipi_dbi_write_seq_multi(&ctx, 0xd7, 0x00); /* on/off sequence period */
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xd8, 0x01, 0x05, 0x06, 0x0d,
> + 0x18, 0x09, 0x22, 0x23, 0x00); /* ponseqa */
> + mipi_dbi_write_seq_multi(&ctx, 0xd9, 0x24, 0x01); /* ponseqb */
> + mipi_dbi_write_seq_multi(&ctx, 0xde, 0x09, 0x0f, 0x21, 0x12,
> + 0x04); /* ponseqc */
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xdf, 0x02, 0x06, 0x06, 0x06,
> + 0x06, 0x00); /* pofseqa */
> + mipi_dbi_write_seq_multi(&ctx, 0xe0, 0x01); /* pofseqb */
> +
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_WRITE_CONTROL_DISPLAY, 0x40);
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xe2, 0x00, 0x00); /* cabc pwm */
> + mipi_dbi_write_seq_multi(&ctx, 0xe3, 0x03); /* cabc */
> + mipi_dbi_write_seq_multi(&ctx, 0xe4, 0x66, 0x7b, 0x90, 0xa5,
> + 0xbb, 0xc7, 0xe1, 0xe5); /* cabc brightness */
> + mipi_dbi_write_seq_multi(&ctx, 0xe5, 0xc5, 0xc5, 0xc9, 0xc9,
> + 0xd1, 0xe1, 0xf1, 0xfe); /* cabc brightness */
> + mipi_dbi_write_seq_multi(&ctx, 0xe7, 0x2a); /* cabc */
> + mipi_dbi_write_seq_multi(&ctx, 0xe8, 0x00); /* brt_rev */
> + mipi_dbi_write_seq_multi(&ctx, 0xe9, 0x00); /* tefreq */
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xea, 0x01); /* high speed ram */
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xeb, 0x00, 0x33, 0x0e, 0x15,
> + 0xb7, 0x78, 0x88, 0x0f); /* gamma setting r pos */
> + mipi_dbi_write_seq_multi(&ctx, 0xec, 0x00, 0x33, 0x0e, 0x15,
> + 0xb7, 0x78, 0x88, 0x0f); /* gamma setting r neg */
> + mipi_dbi_write_seq_multi(&ctx, 0xed, 0x00, 0x33, 0x0e, 0x15,
> + 0xb7, 0x78, 0x88, 0x0f); /* gamma setting g pos */
> + mipi_dbi_write_seq_multi(&ctx, 0xee, 0x00, 0x33, 0x0e, 0x15,
> + 0xb7, 0x78, 0x88, 0x0f); /* gamma setting g neg */
> + mipi_dbi_write_seq_multi(&ctx, 0xef, 0x00, 0x33, 0x0e, 0x15,
> + 0xb7, 0x78, 0x88, 0x0f); /* gamma setting b pos */
> + mipi_dbi_write_seq_multi(&ctx, 0xf0, 0x00, 0x33, 0x0e, 0x15,
> + 0xb7, 0x78, 0x88, 0x0f); /* gamma setting b neg */
> +
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_EXIT_SLEEP_MODE);
> msleep(110);
>
> - panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_ON);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_ON);
>
> - return 0;
> + return ctx.accum_err;
> }
>
> static int hitachi_tx10d07vm0baa_disable(struct drm_panel *panel)
> {
> struct hitachi_tx10d07vm0baa *priv = to_hitachi_tx10d07vm0baa(panel);
> + struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev };
>
> - panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_OFF);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_OFF);
> msleep(35);
>
> - panel_dbi_command(priv, MIPI_DCS_ENTER_SLEEP_MODE);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_ENTER_SLEEP_MODE);
> msleep(50);
>
> - return 0;
> + return ctx.accum_err;
> }
>
> static int hitachi_tx10d07vm0baa_unprepare(struct drm_panel *panel)
> --
> 2.53.0
>
>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 04/12] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
` (2 preceding siblings ...)
2026-11-22 8:18 ` [PATCH v8 03/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-22 8:18 ` [PATCH v8 05/12] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
` (7 subsequent siblings)
11 siblings, 0 replies; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
Switch from a generic platform driver to a dedicated MIPI DBI Type B
driver.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/gpu/drm/panel/panel-lg-lh400wv3.c | 27 +++++++++++------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
index 557bcb6f2ca70..63efeb434be13 100644
--- a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
+++ b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
@@ -14,6 +14,7 @@
#include <video/mipi_display.h>
#include <drm/drm_mipi_dbi.h>
+#include <drm/drm_mipi_dbi_bus.h>
#include <drm/drm_modes.h>
#include <drm/drm_of.h>
#include <drm/drm_panel.h>
@@ -25,7 +26,7 @@ static const struct regulator_bulk_data lg_lh400wv3_supplies[] = {
struct lg_lh400wv3 {
struct drm_panel panel;
- struct mipi_dbi *dbi;
+ struct mipi_dbi_device *dbidev;
struct regulator_bulk_data *supplies;
struct gpio_desc *reset_gpio;
@@ -40,9 +41,10 @@ static inline struct lg_lh400wv3 *to_lg_lh400wv3(struct drm_panel *panel)
({ \
const u8 d[] = { seq }; \
struct drm_panel *panel = &(priv)->panel; \
+ struct mipi_dbi_device *dbidev = (priv)->dbidev; \
struct device *dev = panel->dev; \
int ret; \
- ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); \
+ ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
if (ret) \
dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
ret; \
@@ -54,10 +56,6 @@ static int lg_lh400wv3_prepare(struct drm_panel *panel)
struct device *dev = panel->dev;
int ret;
- priv->dbi = dev_get_drvdata(dev->parent);
- if (!priv->dbi)
- return -ENODEV;
-
gpiod_set_value_cansleep(priv->reset_gpio, 1);
ret = regulator_bulk_enable(ARRAY_SIZE(lg_lh400wv3_supplies), priv->supplies);
@@ -129,7 +127,7 @@ static int lg_lh400wv3_disable(struct drm_panel *panel)
usleep_range(10000, 11000);
return 0;
-};
+}
static int lg_lh400wv3_unprepare(struct drm_panel *panel)
{
@@ -182,9 +180,9 @@ static const struct drm_panel_funcs lg_lh400wv3_panel_funcs = {
.get_modes = lg_lh400wv3_get_modes,
};
-static int lg_lh400wv3_probe(struct platform_device *pdev)
+static int lg_lh400wv3_probe(struct mipi_dbi_device *dbidev)
{
- struct device *dev = &pdev->dev;
+ struct device *dev = &dbidev->dev;
struct lg_lh400wv3 *priv;
int ret;
@@ -203,6 +201,9 @@ static int lg_lh400wv3_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
"Failed to get reset gpio\n");
+ priv->dbidev = dbidev;
+ mipi_dbi_set_drvdata(dbidev, priv);
+
ret = drm_panel_of_backlight(&priv->panel);
if (ret)
return dev_err_probe(dev, ret, "Failed to get backlight\n");
@@ -211,9 +212,7 @@ static int lg_lh400wv3_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret, "Failed to add panel\n");
- platform_set_drvdata(pdev, priv);
-
- return 0;
+ return devm_mipi_dbi_attach(dev, dbidev);
}
static const struct of_device_id lg_lh400wv3_of_match[] = {
@@ -222,14 +221,14 @@ static const struct of_device_id lg_lh400wv3_of_match[] = {
};
MODULE_DEVICE_TABLE(of, lg_lh400wv3_of_match);
-static struct platform_driver lg_lh400wv3_driver = {
+static struct mipi_dbi_driver lg_lh400wv3_driver = {
.driver = {
.name = "panel-lg-lh400wv3",
.of_match_table = lg_lh400wv3_of_match,
},
.probe = lg_lh400wv3_probe,
};
-module_platform_driver(lg_lh400wv3_driver);
+module_mipi_dbi_driver(lg_lh400wv3_driver);
MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>");
MODULE_DESCRIPTION("LG LH400WV3-SD04 MIPI DBI Type B panel driver");
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* [PATCH v8 05/12] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi()
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
` (3 preceding siblings ...)
2026-11-22 8:18 ` [PATCH v8 04/12] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-27 4:40 ` Mikko Perttunen
2026-11-22 8:18 ` [PATCH v8 06/12] drm/tegra: dc: Add elements required by Tegra MIPI DBI Svyatoslav Ryhel
` (6 subsequent siblings)
11 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
Switch from the internal panel command-sending macro to a generic one to
improve code reuse.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/gpu/drm/panel/panel-lg-lh400wv3.c | 91 ++++++++++-------------
1 file changed, 40 insertions(+), 51 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
index 63efeb434be13..02150330f1735 100644
--- a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
+++ b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
@@ -37,19 +37,6 @@ static inline struct lg_lh400wv3 *to_lg_lh400wv3(struct drm_panel *panel)
return container_of(panel, struct lg_lh400wv3, panel);
}
-#define panel_dbi_command(priv, cmd, seq...) \
-({ \
- const u8 d[] = { seq }; \
- struct drm_panel *panel = &(priv)->panel; \
- struct mipi_dbi_device *dbidev = (priv)->dbidev; \
- struct device *dev = panel->dev; \
- int ret; \
- ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
- if (ret) \
- dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
- ret; \
-})
-
static int lg_lh400wv3_prepare(struct drm_panel *panel)
{
struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
@@ -76,57 +63,59 @@ static int lg_lh400wv3_prepare(struct drm_panel *panel)
static int lg_lh400wv3_enable(struct drm_panel *panel)
{
struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
-
- panel_dbi_command(priv, MIPI_DCS_EXIT_INVERT_MODE);
- panel_dbi_command(priv, MIPI_DCS_SET_TEAR_ON);
-
- panel_dbi_command(priv, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT |
- MIPI_DCS_PIXEL_FMT_24BIT << 4);
-
- panel_dbi_command(priv, 0xb2, 0x00, 0xc8);
- panel_dbi_command(priv, 0xb3, 0x00);
- panel_dbi_command(priv, 0xb4, 0x04);
- panel_dbi_command(priv, 0xb5, 0x42, 0x10, 0x10, 0x00, 0x20);
- panel_dbi_command(priv, 0xb6, 0x0b, 0x0f, 0x3c, 0x13, 0x13, 0xe8);
- panel_dbi_command(priv, 0xb7, 0x4c, 0x06, 0x0c, 0x00, 0x00);
-
- panel_dbi_command(priv, 0xc0, 0x01, 0x11);
- panel_dbi_command(priv, 0xc3, 0x07, 0x03, 0x04, 0x04, 0x04);
- panel_dbi_command(priv, 0xc4, 0x12, 0x24, 0x18, 0x18, 0x02, 0x49);
- panel_dbi_command(priv, 0xc5, 0x65);
- panel_dbi_command(priv, 0xc6, 0x41, 0x63);
-
- panel_dbi_command(priv, 0xd0, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
- panel_dbi_command(priv, 0xd1, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
- panel_dbi_command(priv, 0xd2, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
- panel_dbi_command(priv, 0xd3, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
- panel_dbi_command(priv, 0xd4, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
- panel_dbi_command(priv, 0xd5, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
-
- panel_dbi_command(priv, MIPI_DCS_SET_COLUMN_ADDRESS, 0x00, 0x00, 0x01, 0xdf);
- panel_dbi_command(priv, MIPI_DCS_SET_PAGE_ADDRESS, 0x00, 0x00, 0x03, 0x1f);
-
- panel_dbi_command(priv, MIPI_DCS_EXIT_SLEEP_MODE);
+ struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev };
+
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_EXIT_INVERT_MODE);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_TEAR_ON);
+
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT |
+ MIPI_DCS_PIXEL_FMT_24BIT << 4);
+
+ mipi_dbi_write_seq_multi(&ctx, 0xb2, 0x00, 0xc8);
+ mipi_dbi_write_seq_multi(&ctx, 0xb3, 0x00);
+ mipi_dbi_write_seq_multi(&ctx, 0xb4, 0x04);
+ mipi_dbi_write_seq_multi(&ctx, 0xb5, 0x42, 0x10, 0x10, 0x00, 0x20);
+ mipi_dbi_write_seq_multi(&ctx, 0xb6, 0x0b, 0x0f, 0x3c, 0x13, 0x13, 0xe8);
+ mipi_dbi_write_seq_multi(&ctx, 0xb7, 0x4c, 0x06, 0x0c, 0x00, 0x00);
+
+ mipi_dbi_write_seq_multi(&ctx, 0xc0, 0x01, 0x11);
+ mipi_dbi_write_seq_multi(&ctx, 0xc3, 0x07, 0x03, 0x04, 0x04, 0x04);
+ mipi_dbi_write_seq_multi(&ctx, 0xc4, 0x12, 0x24, 0x18, 0x18, 0x02, 0x49);
+ mipi_dbi_write_seq_multi(&ctx, 0xc5, 0x65);
+ mipi_dbi_write_seq_multi(&ctx, 0xc6, 0x41, 0x63);
+
+ mipi_dbi_write_seq_multi(&ctx, 0xd0, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
+ mipi_dbi_write_seq_multi(&ctx, 0xd1, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
+ mipi_dbi_write_seq_multi(&ctx, 0xd2, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
+ mipi_dbi_write_seq_multi(&ctx, 0xd3, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
+ mipi_dbi_write_seq_multi(&ctx, 0xd4, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
+ mipi_dbi_write_seq_multi(&ctx, 0xd5, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
+
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_COLUMN_ADDRESS, 0x00, 0x00, 0x01, 0xdf);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PAGE_ADDRESS, 0x00, 0x00, 0x03, 0x1f);
+
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_EXIT_SLEEP_MODE);
msleep(120);
- panel_dbi_command(priv, MIPI_DCS_WRITE_MEMORY_START);
- panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_ON);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_WRITE_MEMORY_START);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_ON);
- return 0;
+ return ctx.accum_err;
}
static int lg_lh400wv3_disable(struct drm_panel *panel)
{
struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
+ struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev };
- panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_OFF);
- panel_dbi_command(priv, MIPI_DCS_ENTER_SLEEP_MODE);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_OFF);
+ mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_ENTER_SLEEP_MODE);
msleep(150);
- panel_dbi_command(priv, 0xc1, 0x01);
+ mipi_dbi_write_seq_multi(&ctx, 0xc1, 0x01);
usleep_range(10000, 11000);
- return 0;
+ return ctx.accum_err;
}
static int lg_lh400wv3_unprepare(struct drm_panel *panel)
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* Re: [PATCH v8 05/12] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi()
2026-11-22 8:18 ` [PATCH v8 05/12] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
@ 2026-11-27 4:40 ` Mikko Perttunen
0 siblings, 0 replies; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 4:40 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Svyatoslav Ryhel, devicetree
Cc: dri-devel, devicetree, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> Switch from the internal panel command-sending macro to a generic one to
> improve code reuse.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> drivers/gpu/drm/panel/panel-lg-lh400wv3.c | 91 ++++++++++-------------
> 1 file changed, 40 insertions(+), 51 deletions(-)
>
> diff --git a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
> index 63efeb434be13..02150330f1735 100644
> --- a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
> +++ b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
> @@ -37,19 +37,6 @@ static inline struct lg_lh400wv3 *to_lg_lh400wv3(struct drm_panel *panel)
> return container_of(panel, struct lg_lh400wv3, panel);
> }
>
> -#define panel_dbi_command(priv, cmd, seq...) \
> -({ \
> - const u8 d[] = { seq }; \
> - struct drm_panel *panel = &(priv)->panel; \
> - struct mipi_dbi_device *dbidev = (priv)->dbidev; \
> - struct device *dev = panel->dev; \
> - int ret; \
> - ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
> - if (ret) \
> - dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \
> - ret; \
> -})
> -
> static int lg_lh400wv3_prepare(struct drm_panel *panel)
> {
> struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
> @@ -76,57 +63,59 @@ static int lg_lh400wv3_prepare(struct drm_panel *panel)
> static int lg_lh400wv3_enable(struct drm_panel *panel)
> {
> struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
> -
> - panel_dbi_command(priv, MIPI_DCS_EXIT_INVERT_MODE);
> - panel_dbi_command(priv, MIPI_DCS_SET_TEAR_ON);
> -
> - panel_dbi_command(priv, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT |
> - MIPI_DCS_PIXEL_FMT_24BIT << 4);
> -
> - panel_dbi_command(priv, 0xb2, 0x00, 0xc8);
> - panel_dbi_command(priv, 0xb3, 0x00);
> - panel_dbi_command(priv, 0xb4, 0x04);
> - panel_dbi_command(priv, 0xb5, 0x42, 0x10, 0x10, 0x00, 0x20);
> - panel_dbi_command(priv, 0xb6, 0x0b, 0x0f, 0x3c, 0x13, 0x13, 0xe8);
> - panel_dbi_command(priv, 0xb7, 0x4c, 0x06, 0x0c, 0x00, 0x00);
> -
> - panel_dbi_command(priv, 0xc0, 0x01, 0x11);
> - panel_dbi_command(priv, 0xc3, 0x07, 0x03, 0x04, 0x04, 0x04);
> - panel_dbi_command(priv, 0xc4, 0x12, 0x24, 0x18, 0x18, 0x02, 0x49);
> - panel_dbi_command(priv, 0xc5, 0x65);
> - panel_dbi_command(priv, 0xc6, 0x41, 0x63);
> -
> - panel_dbi_command(priv, 0xd0, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
> - panel_dbi_command(priv, 0xd1, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
> - panel_dbi_command(priv, 0xd2, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
> - panel_dbi_command(priv, 0xd3, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
> - panel_dbi_command(priv, 0xd4, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
> - panel_dbi_command(priv, 0xd5, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
> -
> - panel_dbi_command(priv, MIPI_DCS_SET_COLUMN_ADDRESS, 0x00, 0x00, 0x01, 0xdf);
> - panel_dbi_command(priv, MIPI_DCS_SET_PAGE_ADDRESS, 0x00, 0x00, 0x03, 0x1f);
> -
> - panel_dbi_command(priv, MIPI_DCS_EXIT_SLEEP_MODE);
> + struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev };
> +
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_EXIT_INVERT_MODE);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_TEAR_ON);
> +
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT |
> + MIPI_DCS_PIXEL_FMT_24BIT << 4);
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xb2, 0x00, 0xc8);
> + mipi_dbi_write_seq_multi(&ctx, 0xb3, 0x00);
> + mipi_dbi_write_seq_multi(&ctx, 0xb4, 0x04);
> + mipi_dbi_write_seq_multi(&ctx, 0xb5, 0x42, 0x10, 0x10, 0x00, 0x20);
> + mipi_dbi_write_seq_multi(&ctx, 0xb6, 0x0b, 0x0f, 0x3c, 0x13, 0x13, 0xe8);
> + mipi_dbi_write_seq_multi(&ctx, 0xb7, 0x4c, 0x06, 0x0c, 0x00, 0x00);
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xc0, 0x01, 0x11);
> + mipi_dbi_write_seq_multi(&ctx, 0xc3, 0x07, 0x03, 0x04, 0x04, 0x04);
> + mipi_dbi_write_seq_multi(&ctx, 0xc4, 0x12, 0x24, 0x18, 0x18, 0x02, 0x49);
> + mipi_dbi_write_seq_multi(&ctx, 0xc5, 0x65);
> + mipi_dbi_write_seq_multi(&ctx, 0xc6, 0x41, 0x63);
> +
> + mipi_dbi_write_seq_multi(&ctx, 0xd0, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
> + mipi_dbi_write_seq_multi(&ctx, 0xd1, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04);
> + mipi_dbi_write_seq_multi(&ctx, 0xd2, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
> + mipi_dbi_write_seq_multi(&ctx, 0xd3, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04);
> + mipi_dbi_write_seq_multi(&ctx, 0xd4, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
> + mipi_dbi_write_seq_multi(&ctx, 0xd5, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04);
> +
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_COLUMN_ADDRESS, 0x00, 0x00, 0x01, 0xdf);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PAGE_ADDRESS, 0x00, 0x00, 0x03, 0x1f);
> +
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_EXIT_SLEEP_MODE);
> msleep(120);
>
> - panel_dbi_command(priv, MIPI_DCS_WRITE_MEMORY_START);
> - panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_ON);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_WRITE_MEMORY_START);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_ON);
>
> - return 0;
> + return ctx.accum_err;
> }
>
> static int lg_lh400wv3_disable(struct drm_panel *panel)
> {
> struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel);
> + struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev };
>
> - panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_OFF);
> - panel_dbi_command(priv, MIPI_DCS_ENTER_SLEEP_MODE);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_OFF);
> + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_ENTER_SLEEP_MODE);
> msleep(150);
>
> - panel_dbi_command(priv, 0xc1, 0x01);
> + mipi_dbi_write_seq_multi(&ctx, 0xc1, 0x01);
> usleep_range(10000, 11000);
>
> - return 0;
> + return ctx.accum_err;
> }
>
> static int lg_lh400wv3_unprepare(struct drm_panel *panel)
> --
> 2.53.0
>
>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 06/12] drm/tegra: dc: Add elements required by Tegra MIPI DBI
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
` (4 preceding siblings ...)
2026-11-22 8:18 ` [PATCH v8 05/12] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-27 4:56 ` Mikko Perttunen
2026-11-22 8:18 ` [PATCH v8 07/12] dt-bindings: display: tegra: Document Tegra20 DSI port Svyatoslav Ryhel
` (5 subsequent siblings)
11 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
Add DC register definitions with additional fields in preparation for
adding the 8-bit CPU interface (MIPI DBI).
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/gpu/drm/tegra/dc.h | 194 ++++++++++++++++++++++++++++++++++---
1 file changed, 183 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/tegra/dc.h b/drivers/gpu/drm/tegra/dc.h
index 0cb0515968b35..e8913c5530a2d 100644
--- a/drivers/gpu/drm/tegra/dc.h
+++ b/drivers/gpu/drm/tegra/dc.h
@@ -272,14 +272,150 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
#define DC_COM_CRC_CONTROL_WAIT (1 << 1)
#define DC_COM_CRC_CONTROL_ENABLE (1 << 0)
#define DC_COM_CRC_CHECKSUM 0x301
-#define DC_COM_PIN_OUTPUT_ENABLE(x) (0x302 + (x))
-#define DC_COM_PIN_OUTPUT_POLARITY(x) (0x306 + (x))
-#define LVS_OUTPUT_POLARITY_LOW (1 << 28)
-#define LHS_OUTPUT_POLARITY_LOW (1 << 30)
-#define DC_COM_PIN_OUTPUT_DATA(x) (0x30a + (x))
-#define DC_COM_PIN_INPUT_ENABLE(x) (0x30e + (x))
-#define DC_COM_PIN_INPUT_DATA(x) (0x312 + (x))
-#define DC_COM_PIN_OUTPUT_SELECT(x) (0x314 + (x))
+
+#define DC_COM_PIN_OUTPUT_ENABLE(x) (0x302 + (x))
+#define DC_COM_PIN_OUTPUT_POLARITY(x) (0x306 + (x))
+#define LVS_OUTPUT_POLARITY_LOW BIT(28)
+#define LHS_OUTPUT_POLARITY_LOW BIT(30)
+#define DC_COM_PIN_OUTPUT_DATA(x) (0x30a + (x))
+/* Pin unmask is 1 bit above position of the pin in the OUTPUT_DATA register */
+#define PIN_UNMASK(x) BIT((x) + 1)
+#define DC_COM_PIN_INPUT_ENABLE(x) (0x30e + (x))
+
+/*
+ * The definitions below describe pin positions in the DC_COM_PIN_OUTPUT_ENABLE(x),
+ * DC_COM_PIN_OUTPUT_POLARITY(x), DC_COM_PIN_OUTPUT_DATA(x), and
+ * DC_COM_PIN_INPUT_ENABLE(x) registers. The comment before each group indicates
+ * the index of the register (the x value).
+ */
+
+/* 0 */
+#define PIN_LD0 0
+#define PIN_LD1 2
+#define PIN_LD2 4
+#define PIN_LD3 6
+#define PIN_LD4 8
+#define PIN_LD5 10
+#define PIN_LD6 12
+#define PIN_LD7 14
+#define PIN_LD8 16
+#define PIN_LD9 18
+#define PIN_LD10 20
+#define PIN_LD11 22
+#define PIN_LD12 24
+#define PIN_LD13 26
+#define PIN_LD14 28
+#define PIN_LD15 30
+
+/* 1 */
+#define PIN_LD16 0
+#define PIN_LD17 2
+#define PIN_LPW0 16
+#define PIN_LPW1 18
+#define PIN_LPW2 20
+#define PIN_LSC0 24
+#define PIN_LSC1 26
+#define PIN_LVS 28
+#define PIN_LHS 30
+
+/* 2 */
+#define PIN_LHP0 0
+#define PIN_LHP1 2
+#define PIN_LHP2 4
+#define PIN_LVP0 8
+#define PIN_LVP1 10
+#define PIN_LM0 16
+#define PIN_LM1 18
+#define PIN_LDI 20
+#define PIN_LPP 22
+
+/* 3 */
+#define PIN_LSCK 0
+#define PIN_LSDA 2
+#define PIN_LCSN 4
+#define PIN_LDC 6
+#define PIN_LSPI 8
+#define PIN_LSDI 10
+
+#define DC_COM_PIN_INPUT_DATA(x) (0x312 + (x))
+
+/*
+ * DC_COM_PIN_OUTPUT_SELECT(x) is a set of 7 registers that allow selecting
+ * one of 7 functions for each pin using 3 bits. Clearing all bits sets
+ * the pin to its primary function, while setting them to 1 configures it
+ * as a GPIO output. Other functions are unique to each pin. For details,
+ * check "23.7.17 DC_COM_PIN_OUTPUT_SELECT0_0" in the Tegra30 TRM.
+ */
+#define DC_COM_PIN_OUTPUT_SELECT(x) (0x314 + (x))
+#define PIN_OUTPUT_SELECT_MASK(x) (0x7 << (x))
+#define PIN_OUTPUT_SELECT_PRIM(x) (0 << (x))
+#define PIN_OUTPUT_SELECT_OUT(x) (1 << (x))
+#define PIN_OUTPUT_SELECT_F2(x) (2 << (x))
+#define PIN_OUTPUT_SELECT_F3(x) (3 << (x))
+#define PIN_OUTPUT_SELECT_F4(x) (4 << (x))
+#define PIN_OUTPUT_SELECT_F5(x) (5 << (x))
+#define PIN_OUTPUT_SELECT_F6(x) (6 << (x))
+#define PIN_OUTPUT_SELECT_F7(x) (7 << (x))
+
+/*
+ * The definitions below describe pin offset in the DC_COM_PIN_OUTPUT_SELECT(x)
+ * registers. The comment before each group indicates the index of the register
+ * (the x value).
+ */
+
+/* 0 */
+#define PIN_OUTPUT_SELECT_LD0 0
+#define PIN_OUTPUT_SELECT_LD1 4
+#define PIN_OUTPUT_SELECT_LD2 8
+#define PIN_OUTPUT_SELECT_LD3 12
+#define PIN_OUTPUT_SELECT_LD4 16
+#define PIN_OUTPUT_SELECT_LD5 20
+#define PIN_OUTPUT_SELECT_LD6 24
+#define PIN_OUTPUT_SELECT_LD7 28
+
+/* 1 */
+#define PIN_OUTPUT_SELECT_LD8 0
+#define PIN_OUTPUT_SELECT_LD9 4
+#define PIN_OUTPUT_SELECT_LD10 8
+#define PIN_OUTPUT_SELECT_LD11 12
+#define PIN_OUTPUT_SELECT_LD12 16
+#define PIN_OUTPUT_SELECT_LD13 20
+#define PIN_OUTPUT_SELECT_LD14 24
+#define PIN_OUTPUT_SELECT_LD15 28
+
+/* 2 */
+#define PIN_OUTPUT_SELECT_LD16 0
+#define PIN_OUTPUT_SELECT_LD17 4
+
+/* 3 */
+#define PIN_OUTPUT_SELECT_LPW0 0
+#define PIN_OUTPUT_SELECT_LPW1 4
+#define PIN_OUTPUT_SELECT_LPW2 8
+#define PIN_OUTPUT_SELECT_LSC0 16
+#define PIN_OUTPUT_SELECT_LSC1 20
+#define PIN_OUTPUT_SELECT_LVS 24
+#define PIN_OUTPUT_SELECT_LHS 28
+
+/* 4 */
+#define PIN_OUTPUT_SELECT_LHP0 0
+#define PIN_OUTPUT_SELECT_LHP1 4
+#define PIN_OUTPUT_SELECT_LHP2 8
+#define PIN_OUTPUT_SELECT_LVP0 16
+#define PIN_OUTPUT_SELECT_LVP1 20
+
+/* 5 */
+#define PIN_OUTPUT_SELECT_LM0 0
+#define PIN_OUTPUT_SELECT_LM1 4
+#define PIN_OUTPUT_SELECT_LDI 8
+#define PIN_OUTPUT_SELECT_LPP 12
+
+/* 6 */
+#define PIN_OUTPUT_SELECT_LSCK 0
+#define PIN_OUTPUT_SELECT_LSDA 4
+#define PIN_OUTPUT_SELECT_LCSN 8
+#define PIN_OUTPUT_SELECT_LDC 12
+#define PIN_OUTPUT_SELECT_LSPI 16
+#define PIN_OUTPUT_SELECT_LSDI 20
#define DC_COM_PIN_MISC_CONTROL 0x31b
#define DC_COM_PIN_PM0_CONTROL 0x31c
@@ -303,9 +439,15 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
#define UNDERFLOW_REPORT_ENABLE (1 << 0)
#define DC_DISP_DISP_SIGNAL_OPTIONS0 0x400
-#define H_PULSE0_ENABLE (1 << 8)
-#define H_PULSE1_ENABLE (1 << 10)
-#define H_PULSE2_ENABLE (1 << 12)
+#define H_PULSE0_ENABLE BIT(8)
+#define H_PULSE1_ENABLE BIT(10)
+#define H_PULSE2_ENABLE BIT(12)
+#define V_PULSE0_ENABLE BIT(16)
+#define V_PULSE1_ENABLE BIT(18)
+#define V_PULSE2_ENABLE BIT(19)
+#define V_PULSE3_ENABLE BIT(20)
+#define M0_ENABLE BIT(24)
+#define M1_ENABLE BIT(26)
#define DC_DISP_DISP_SIGNAL_OPTIONS1 0x401
@@ -456,6 +598,22 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
#define DC_DISP_SHIFT_CLOCK_OPTIONS 0x431
#define SC1_H_QUALIFIER_NONE (1 << 16)
#define SC0_H_QUALIFIER_NONE (1 << 0)
+#define SC0_H_QUALIFIER(x) (((x) & 0x7) << 0)
+#define SC1_H_QUALIFIER(x) (((x) & 0x7) << 16)
+#define SC_H_QUALIFIER_DISABLE 0
+#define SC_H_QUALIFIER_NONE 1
+#define SC_H_QUALIFIER_HACTIVE 2
+#define SC_H_QUALIFIER_EXT_HACTIVE 3
+#define SC_H_QUALIFIER_HPULSE 4
+#define SC_H_QUALIFIER_EXT_HPULSE 5
+#define SC0_V_QUALIFIER(x) (((x) & 0x7) << 3)
+#define SC1_V_QUALIFIER(x) (((x) & 0x7) << 19)
+#define SC_V_QUALIFIER_NONE 0
+#define SC_V_QUALIFIER_RSVD 1
+#define SC_V_QUALIFIER_VACTIVE 2
+#define SC_V_QUALIFIER_EXT_VACTIVE 3
+#define SC_V_QUALIFIER_VPULSE 4
+#define SC_V_QUALIFIER_EXT_VPULSE 5
#define DC_DISP_DATA_ENABLE_OPTIONS 0x432
#define DE_SELECT_ACTIVE_BLANK (0 << 0)
@@ -493,6 +651,20 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
#define DC_DISP_CURSOR_POSITION_NS 0x441
#define DC_DISP_INIT_SEQ_CONTROL 0x442
+#define SEND_INIT_SEQUENCE BIT(0)
+#define INIT_SEQUENCE_MODE_SPI BIT(1)
+#define INIT_SEQUENCE_MODE_PLCD 0
+#define INIT_SEQ_DC_SIGNAL_SHIFT 4
+#define INIT_SEQ_DC_SIGNAL_MASK (0x7 << INIT_SEQ_DC_SIGNAL_SHIFT)
+#define NO_DC_SIGNAL 0
+#define DC_SIGNAL_VSYNC 1
+#define DC_SIGNAL_VPULSE0 2
+#define DC_SIGNAL_VPULSE1 3
+#define DC_SIGNAL_VPULSE2 4
+#define DC_SIGNAL_VPULSE3 5
+#define INIT_SEQ_DC_CONTROL_SHIFT 7
+#define FRAME_INIT_SEQ_CYCLES_SHIFT 8
+
#define DC_DISP_SPI_INIT_SEQ_DATA_A 0x443
#define DC_DISP_SPI_INIT_SEQ_DATA_B 0x444
#define DC_DISP_SPI_INIT_SEQ_DATA_C 0x445
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* Re: [PATCH v8 06/12] drm/tegra: dc: Add elements required by Tegra MIPI DBI
2026-11-22 8:18 ` [PATCH v8 06/12] drm/tegra: dc: Add elements required by Tegra MIPI DBI Svyatoslav Ryhel
@ 2026-11-27 4:56 ` Mikko Perttunen
2026-11-27 9:16 ` Svyatoslav Ryhel
0 siblings, 1 reply; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 4:56 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Svyatoslav Ryhel, devicetree
Cc: dri-devel, devicetree, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> Add DC register definitions with additional fields in preparation for
> adding the 8-bit CPU interface (MIPI DBI).
Maybe also mention that some whitespace cleanup has been done.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> drivers/gpu/drm/tegra/dc.h | 194 ++++++++++++++++++++++++++++++++++---
> 1 file changed, 183 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/dc.h b/drivers/gpu/drm/tegra/dc.h
> index 0cb0515968b35..e8913c5530a2d 100644
> --- a/drivers/gpu/drm/tegra/dc.h
> +++ b/drivers/gpu/drm/tegra/dc.h
> @@ -272,14 +272,150 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
> #define DC_COM_CRC_CONTROL_WAIT (1 << 1)
> #define DC_COM_CRC_CONTROL_ENABLE (1 << 0)
> #define DC_COM_CRC_CHECKSUM 0x301
> -#define DC_COM_PIN_OUTPUT_ENABLE(x) (0x302 + (x))
> -#define DC_COM_PIN_OUTPUT_POLARITY(x) (0x306 + (x))
> -#define LVS_OUTPUT_POLARITY_LOW (1 << 28)
> -#define LHS_OUTPUT_POLARITY_LOW (1 << 30)
> -#define DC_COM_PIN_OUTPUT_DATA(x) (0x30a + (x))
> -#define DC_COM_PIN_INPUT_ENABLE(x) (0x30e + (x))
> -#define DC_COM_PIN_INPUT_DATA(x) (0x312 + (x))
> -#define DC_COM_PIN_OUTPUT_SELECT(x) (0x314 + (x))
> +
> +#define DC_COM_PIN_OUTPUT_ENABLE(x) (0x302 + (x))
> +#define DC_COM_PIN_OUTPUT_POLARITY(x) (0x306 + (x))
> +#define LVS_OUTPUT_POLARITY_LOW BIT(28)
> +#define LHS_OUTPUT_POLARITY_LOW BIT(30)
> +#define DC_COM_PIN_OUTPUT_DATA(x) (0x30a + (x))
> +/* Pin unmask is 1 bit above position of the pin in the OUTPUT_DATA register */
> +#define PIN_UNMASK(x) BIT((x) + 1)
> +#define DC_COM_PIN_INPUT_ENABLE(x) (0x30e + (x))
> +
> +/*
> + * The definitions below describe pin positions in the DC_COM_PIN_OUTPUT_ENABLE(x),
> + * DC_COM_PIN_OUTPUT_POLARITY(x), DC_COM_PIN_OUTPUT_DATA(x), and
> + * DC_COM_PIN_INPUT_ENABLE(x) registers. The comment before each group indicates
> + * the index of the register (the x value).
> + */
> +
> +/* 0 */
> +#define PIN_LD0 0
> +#define PIN_LD1 2
> +#define PIN_LD2 4
> +#define PIN_LD3 6
> +#define PIN_LD4 8
> +#define PIN_LD5 10
> +#define PIN_LD6 12
> +#define PIN_LD7 14
> +#define PIN_LD8 16
> +#define PIN_LD9 18
> +#define PIN_LD10 20
> +#define PIN_LD11 22
> +#define PIN_LD12 24
> +#define PIN_LD13 26
> +#define PIN_LD14 28
> +#define PIN_LD15 30
> +
> +/* 1 */
> +#define PIN_LD16 0
> +#define PIN_LD17 2
> +#define PIN_LPW0 16
> +#define PIN_LPW1 18
> +#define PIN_LPW2 20
> +#define PIN_LSC0 24
> +#define PIN_LSC1 26
> +#define PIN_LVS 28
> +#define PIN_LHS 30
> +
> +/* 2 */
> +#define PIN_LHP0 0
> +#define PIN_LHP1 2
> +#define PIN_LHP2 4
> +#define PIN_LVP0 8
> +#define PIN_LVP1 10
> +#define PIN_LM0 16
> +#define PIN_LM1 18
> +#define PIN_LDI 20
> +#define PIN_LPP 22
> +
> +/* 3 */
> +#define PIN_LSCK 0
> +#define PIN_LSDA 2
> +#define PIN_LCSN 4
> +#define PIN_LDC 6
> +#define PIN_LSPI 8
> +#define PIN_LSDI 10
> +
> +#define DC_COM_PIN_INPUT_DATA(x) (0x312 + (x))
> +
> +/*
> + * DC_COM_PIN_OUTPUT_SELECT(x) is a set of 7 registers that allow selecting
> + * one of 7 functions for each pin using 3 bits. Clearing all bits sets
> + * the pin to its primary function, while setting them to 1 configures it
> + * as a GPIO output. Other functions are unique to each pin. For details,
> + * check "23.7.17 DC_COM_PIN_OUTPUT_SELECT0_0" in the Tegra30 TRM.
> + */
> +#define DC_COM_PIN_OUTPUT_SELECT(x) (0x314 + (x))
> +#define PIN_OUTPUT_SELECT_MASK(x) (0x7 << (x))
> +#define PIN_OUTPUT_SELECT_PRIM(x) (0 << (x))
> +#define PIN_OUTPUT_SELECT_OUT(x) (1 << (x))
> +#define PIN_OUTPUT_SELECT_F2(x) (2 << (x))
> +#define PIN_OUTPUT_SELECT_F3(x) (3 << (x))
> +#define PIN_OUTPUT_SELECT_F4(x) (4 << (x))
> +#define PIN_OUTPUT_SELECT_F5(x) (5 << (x))
> +#define PIN_OUTPUT_SELECT_F6(x) (6 << (x))
> +#define PIN_OUTPUT_SELECT_F7(x) (7 << (x))
> +
> +/*
> + * The definitions below describe pin offset in the DC_COM_PIN_OUTPUT_SELECT(x)
> + * registers. The comment before each group indicates the index of the register
> + * (the x value).
> + */
> +
> +/* 0 */
> +#define PIN_OUTPUT_SELECT_LD0 0
> +#define PIN_OUTPUT_SELECT_LD1 4
> +#define PIN_OUTPUT_SELECT_LD2 8
> +#define PIN_OUTPUT_SELECT_LD3 12
> +#define PIN_OUTPUT_SELECT_LD4 16
> +#define PIN_OUTPUT_SELECT_LD5 20
> +#define PIN_OUTPUT_SELECT_LD6 24
> +#define PIN_OUTPUT_SELECT_LD7 28
> +
> +/* 1 */
> +#define PIN_OUTPUT_SELECT_LD8 0
> +#define PIN_OUTPUT_SELECT_LD9 4
> +#define PIN_OUTPUT_SELECT_LD10 8
> +#define PIN_OUTPUT_SELECT_LD11 12
> +#define PIN_OUTPUT_SELECT_LD12 16
> +#define PIN_OUTPUT_SELECT_LD13 20
> +#define PIN_OUTPUT_SELECT_LD14 24
> +#define PIN_OUTPUT_SELECT_LD15 28
> +
> +/* 2 */
> +#define PIN_OUTPUT_SELECT_LD16 0
> +#define PIN_OUTPUT_SELECT_LD17 4
> +
> +/* 3 */
> +#define PIN_OUTPUT_SELECT_LPW0 0
> +#define PIN_OUTPUT_SELECT_LPW1 4
> +#define PIN_OUTPUT_SELECT_LPW2 8
> +#define PIN_OUTPUT_SELECT_LSC0 16
> +#define PIN_OUTPUT_SELECT_LSC1 20
> +#define PIN_OUTPUT_SELECT_LVS 24
> +#define PIN_OUTPUT_SELECT_LHS 28
> +
> +/* 4 */
> +#define PIN_OUTPUT_SELECT_LHP0 0
> +#define PIN_OUTPUT_SELECT_LHP1 4
> +#define PIN_OUTPUT_SELECT_LHP2 8
> +#define PIN_OUTPUT_SELECT_LVP0 16
> +#define PIN_OUTPUT_SELECT_LVP1 20
> +
> +/* 5 */
> +#define PIN_OUTPUT_SELECT_LM0 0
> +#define PIN_OUTPUT_SELECT_LM1 4
> +#define PIN_OUTPUT_SELECT_LDI 8
> +#define PIN_OUTPUT_SELECT_LPP 12
> +
> +/* 6 */
> +#define PIN_OUTPUT_SELECT_LSCK 0
> +#define PIN_OUTPUT_SELECT_LSDA 4
> +#define PIN_OUTPUT_SELECT_LCSN 8
> +#define PIN_OUTPUT_SELECT_LDC 12
> +#define PIN_OUTPUT_SELECT_LSPI 16
> +#define PIN_OUTPUT_SELECT_LSDI 20
It becomes apparent here that the PIN_* and PIN_OUTPUT_SELECT_* are kind
of redundant as the pins are in the same order, the stride (and thus
register indexing) is just different. Hence, I think it would be cleaner
to have ..
#define PIN_LD0 0
#define PIN_LD1 1
...
and then
#define PIN_REGISTER_INDEX(pin) ((pin) / 16)
#define PIN_SHIFT(pin) (((pin) % 16) * 2)
#define PIN_SELECT_REGISTER_INDEX(pin) ((pin) / 8)
#define PIN_SELECT_SHIFT(pin) (((pin) % 8) * 4)
This will also simplify the tegra_dbi_idx tables since they can just
store the pin index, and the register index (and shift) can be
calculated based on that.
>
> #define DC_COM_PIN_MISC_CONTROL 0x31b
> #define DC_COM_PIN_PM0_CONTROL 0x31c
> @@ -303,9 +439,15 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
> #define UNDERFLOW_REPORT_ENABLE (1 << 0)
>
> #define DC_DISP_DISP_SIGNAL_OPTIONS0 0x400
> -#define H_PULSE0_ENABLE (1 << 8)
> -#define H_PULSE1_ENABLE (1 << 10)
> -#define H_PULSE2_ENABLE (1 << 12)
> +#define H_PULSE0_ENABLE BIT(8)
> +#define H_PULSE1_ENABLE BIT(10)
> +#define H_PULSE2_ENABLE BIT(12)
> +#define V_PULSE0_ENABLE BIT(16)
> +#define V_PULSE1_ENABLE BIT(18)
> +#define V_PULSE2_ENABLE BIT(19)
> +#define V_PULSE3_ENABLE BIT(20)
> +#define M0_ENABLE BIT(24)
> +#define M1_ENABLE BIT(26)
>
> #define DC_DISP_DISP_SIGNAL_OPTIONS1 0x401
>
> @@ -456,6 +598,22 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
> #define DC_DISP_SHIFT_CLOCK_OPTIONS 0x431
> #define SC1_H_QUALIFIER_NONE (1 << 16)
> #define SC0_H_QUALIFIER_NONE (1 << 0)
> +#define SC0_H_QUALIFIER(x) (((x) & 0x7) << 0)
> +#define SC1_H_QUALIFIER(x) (((x) & 0x7) << 16)
> +#define SC_H_QUALIFIER_DISABLE 0
> +#define SC_H_QUALIFIER_NONE 1
> +#define SC_H_QUALIFIER_HACTIVE 2
> +#define SC_H_QUALIFIER_EXT_HACTIVE 3
> +#define SC_H_QUALIFIER_HPULSE 4
> +#define SC_H_QUALIFIER_EXT_HPULSE 5
> +#define SC0_V_QUALIFIER(x) (((x) & 0x7) << 3)
> +#define SC1_V_QUALIFIER(x) (((x) & 0x7) << 19)
> +#define SC_V_QUALIFIER_NONE 0
> +#define SC_V_QUALIFIER_RSVD 1
> +#define SC_V_QUALIFIER_VACTIVE 2
> +#define SC_V_QUALIFIER_EXT_VACTIVE 3
> +#define SC_V_QUALIFIER_VPULSE 4
> +#define SC_V_QUALIFIER_EXT_VPULSE 5
>
> #define DC_DISP_DATA_ENABLE_OPTIONS 0x432
> #define DE_SELECT_ACTIVE_BLANK (0 << 0)
> @@ -493,6 +651,20 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
> #define DC_DISP_CURSOR_POSITION_NS 0x441
>
> #define DC_DISP_INIT_SEQ_CONTROL 0x442
> +#define SEND_INIT_SEQUENCE BIT(0)
> +#define INIT_SEQUENCE_MODE_SPI BIT(1)
> +#define INIT_SEQUENCE_MODE_PLCD 0
> +#define INIT_SEQ_DC_SIGNAL_SHIFT 4
> +#define INIT_SEQ_DC_SIGNAL_MASK (0x7 << INIT_SEQ_DC_SIGNAL_SHIFT)
> +#define NO_DC_SIGNAL 0
> +#define DC_SIGNAL_VSYNC 1
> +#define DC_SIGNAL_VPULSE0 2
> +#define DC_SIGNAL_VPULSE1 3
> +#define DC_SIGNAL_VPULSE2 4
> +#define DC_SIGNAL_VPULSE3 5
> +#define INIT_SEQ_DC_CONTROL_SHIFT 7
> +#define FRAME_INIT_SEQ_CYCLES_SHIFT 8
> +
> #define DC_DISP_SPI_INIT_SEQ_DATA_A 0x443
> #define DC_DISP_SPI_INIT_SEQ_DATA_B 0x444
> #define DC_DISP_SPI_INIT_SEQ_DATA_C 0x445
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v8 06/12] drm/tegra: dc: Add elements required by Tegra MIPI DBI
2026-11-27 4:56 ` Mikko Perttunen
@ 2026-11-27 9:16 ` Svyatoslav Ryhel
0 siblings, 0 replies; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-27 9:16 UTC (permalink / raw)
To: Mikko Perttunen
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel
пт, 27 лист. 2026 р. о 06:56 Mikko Perttunen <mperttunen@nvidia.com> пише:
>
> On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > Add DC register definitions with additional fields in preparation for
> > adding the 8-bit CPU interface (MIPI DBI).
>
> Maybe also mention that some whitespace cleanup has been done.
>
sure
> >
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > ---
> > drivers/gpu/drm/tegra/dc.h | 194 ++++++++++++++++++++++++++++++++++---
> > 1 file changed, 183 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/tegra/dc.h b/drivers/gpu/drm/tegra/dc.h
> > index 0cb0515968b35..e8913c5530a2d 100644
> > --- a/drivers/gpu/drm/tegra/dc.h
> > +++ b/drivers/gpu/drm/tegra/dc.h
> > @@ -272,14 +272,150 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
> > #define DC_COM_CRC_CONTROL_WAIT (1 << 1)
> > #define DC_COM_CRC_CONTROL_ENABLE (1 << 0)
> > #define DC_COM_CRC_CHECKSUM 0x301
> > -#define DC_COM_PIN_OUTPUT_ENABLE(x) (0x302 + (x))
> > -#define DC_COM_PIN_OUTPUT_POLARITY(x) (0x306 + (x))
> > -#define LVS_OUTPUT_POLARITY_LOW (1 << 28)
> > -#define LHS_OUTPUT_POLARITY_LOW (1 << 30)
> > -#define DC_COM_PIN_OUTPUT_DATA(x) (0x30a + (x))
> > -#define DC_COM_PIN_INPUT_ENABLE(x) (0x30e + (x))
> > -#define DC_COM_PIN_INPUT_DATA(x) (0x312 + (x))
> > -#define DC_COM_PIN_OUTPUT_SELECT(x) (0x314 + (x))
> > +
> > +#define DC_COM_PIN_OUTPUT_ENABLE(x) (0x302 + (x))
> > +#define DC_COM_PIN_OUTPUT_POLARITY(x) (0x306 + (x))
> > +#define LVS_OUTPUT_POLARITY_LOW BIT(28)
> > +#define LHS_OUTPUT_POLARITY_LOW BIT(30)
> > +#define DC_COM_PIN_OUTPUT_DATA(x) (0x30a + (x))
> > +/* Pin unmask is 1 bit above position of the pin in the OUTPUT_DATA register */
> > +#define PIN_UNMASK(x) BIT((x) + 1)
> > +#define DC_COM_PIN_INPUT_ENABLE(x) (0x30e + (x))
> > +
> > +/*
> > + * The definitions below describe pin positions in the DC_COM_PIN_OUTPUT_ENABLE(x),
> > + * DC_COM_PIN_OUTPUT_POLARITY(x), DC_COM_PIN_OUTPUT_DATA(x), and
> > + * DC_COM_PIN_INPUT_ENABLE(x) registers. The comment before each group indicates
> > + * the index of the register (the x value).
> > + */
> > +
> > +/* 0 */
> > +#define PIN_LD0 0
> > +#define PIN_LD1 2
> > +#define PIN_LD2 4
> > +#define PIN_LD3 6
> > +#define PIN_LD4 8
> > +#define PIN_LD5 10
> > +#define PIN_LD6 12
> > +#define PIN_LD7 14
> > +#define PIN_LD8 16
> > +#define PIN_LD9 18
> > +#define PIN_LD10 20
> > +#define PIN_LD11 22
> > +#define PIN_LD12 24
> > +#define PIN_LD13 26
> > +#define PIN_LD14 28
> > +#define PIN_LD15 30
> > +
> > +/* 1 */
> > +#define PIN_LD16 0
> > +#define PIN_LD17 2
> > +#define PIN_LPW0 16
> > +#define PIN_LPW1 18
> > +#define PIN_LPW2 20
> > +#define PIN_LSC0 24
> > +#define PIN_LSC1 26
> > +#define PIN_LVS 28
> > +#define PIN_LHS 30
> > +
> > +/* 2 */
> > +#define PIN_LHP0 0
> > +#define PIN_LHP1 2
> > +#define PIN_LHP2 4
> > +#define PIN_LVP0 8
> > +#define PIN_LVP1 10
> > +#define PIN_LM0 16
> > +#define PIN_LM1 18
> > +#define PIN_LDI 20
> > +#define PIN_LPP 22
> > +
> > +/* 3 */
> > +#define PIN_LSCK 0
> > +#define PIN_LSDA 2
> > +#define PIN_LCSN 4
> > +#define PIN_LDC 6
> > +#define PIN_LSPI 8
> > +#define PIN_LSDI 10
> > +
> > +#define DC_COM_PIN_INPUT_DATA(x) (0x312 + (x))
> > +
> > +/*
> > + * DC_COM_PIN_OUTPUT_SELECT(x) is a set of 7 registers that allow selecting
> > + * one of 7 functions for each pin using 3 bits. Clearing all bits sets
> > + * the pin to its primary function, while setting them to 1 configures it
> > + * as a GPIO output. Other functions are unique to each pin. For details,
> > + * check "23.7.17 DC_COM_PIN_OUTPUT_SELECT0_0" in the Tegra30 TRM.
> > + */
> > +#define DC_COM_PIN_OUTPUT_SELECT(x) (0x314 + (x))
> > +#define PIN_OUTPUT_SELECT_MASK(x) (0x7 << (x))
> > +#define PIN_OUTPUT_SELECT_PRIM(x) (0 << (x))
> > +#define PIN_OUTPUT_SELECT_OUT(x) (1 << (x))
> > +#define PIN_OUTPUT_SELECT_F2(x) (2 << (x))
> > +#define PIN_OUTPUT_SELECT_F3(x) (3 << (x))
> > +#define PIN_OUTPUT_SELECT_F4(x) (4 << (x))
> > +#define PIN_OUTPUT_SELECT_F5(x) (5 << (x))
> > +#define PIN_OUTPUT_SELECT_F6(x) (6 << (x))
> > +#define PIN_OUTPUT_SELECT_F7(x) (7 << (x))
> > +
> > +/*
> > + * The definitions below describe pin offset in the DC_COM_PIN_OUTPUT_SELECT(x)
> > + * registers. The comment before each group indicates the index of the register
> > + * (the x value).
> > + */
> > +
> > +/* 0 */
> > +#define PIN_OUTPUT_SELECT_LD0 0
> > +#define PIN_OUTPUT_SELECT_LD1 4
> > +#define PIN_OUTPUT_SELECT_LD2 8
> > +#define PIN_OUTPUT_SELECT_LD3 12
> > +#define PIN_OUTPUT_SELECT_LD4 16
> > +#define PIN_OUTPUT_SELECT_LD5 20
> > +#define PIN_OUTPUT_SELECT_LD6 24
> > +#define PIN_OUTPUT_SELECT_LD7 28
> > +
> > +/* 1 */
> > +#define PIN_OUTPUT_SELECT_LD8 0
> > +#define PIN_OUTPUT_SELECT_LD9 4
> > +#define PIN_OUTPUT_SELECT_LD10 8
> > +#define PIN_OUTPUT_SELECT_LD11 12
> > +#define PIN_OUTPUT_SELECT_LD12 16
> > +#define PIN_OUTPUT_SELECT_LD13 20
> > +#define PIN_OUTPUT_SELECT_LD14 24
> > +#define PIN_OUTPUT_SELECT_LD15 28
> > +
> > +/* 2 */
> > +#define PIN_OUTPUT_SELECT_LD16 0
> > +#define PIN_OUTPUT_SELECT_LD17 4
> > +
> > +/* 3 */
> > +#define PIN_OUTPUT_SELECT_LPW0 0
> > +#define PIN_OUTPUT_SELECT_LPW1 4
> > +#define PIN_OUTPUT_SELECT_LPW2 8
> > +#define PIN_OUTPUT_SELECT_LSC0 16
> > +#define PIN_OUTPUT_SELECT_LSC1 20
> > +#define PIN_OUTPUT_SELECT_LVS 24
> > +#define PIN_OUTPUT_SELECT_LHS 28
> > +
> > +/* 4 */
> > +#define PIN_OUTPUT_SELECT_LHP0 0
> > +#define PIN_OUTPUT_SELECT_LHP1 4
> > +#define PIN_OUTPUT_SELECT_LHP2 8
> > +#define PIN_OUTPUT_SELECT_LVP0 16
> > +#define PIN_OUTPUT_SELECT_LVP1 20
> > +
> > +/* 5 */
> > +#define PIN_OUTPUT_SELECT_LM0 0
> > +#define PIN_OUTPUT_SELECT_LM1 4
> > +#define PIN_OUTPUT_SELECT_LDI 8
> > +#define PIN_OUTPUT_SELECT_LPP 12
> > +
> > +/* 6 */
> > +#define PIN_OUTPUT_SELECT_LSCK 0
> > +#define PIN_OUTPUT_SELECT_LSDA 4
> > +#define PIN_OUTPUT_SELECT_LCSN 8
> > +#define PIN_OUTPUT_SELECT_LDC 12
> > +#define PIN_OUTPUT_SELECT_LSPI 16
> > +#define PIN_OUTPUT_SELECT_LSDI 20
>
> It becomes apparent here that the PIN_* and PIN_OUTPUT_SELECT_* are kind
> of redundant as the pins are in the same order, the stride (and thus
> register indexing) is just different. Hence, I think it would be cleaner
> to have ..
>
> #define PIN_LD0 0
> #define PIN_LD1 1
> ...
>
> and then
>
> #define PIN_REGISTER_INDEX(pin) ((pin) / 16)
> #define PIN_SHIFT(pin) (((pin) % 16) * 2)
>
> #define PIN_SELECT_REGISTER_INDEX(pin) ((pin) / 8)
> #define PIN_SELECT_SHIFT(pin) (((pin) % 8) * 4)
>
> This will also simplify the tegra_dbi_idx tables since they can just
> store the pin index, and the register index (and shift) can be
> calculated based on that.
>
I will look into this. Thanks
> >
> > #define DC_COM_PIN_MISC_CONTROL 0x31b
> > #define DC_COM_PIN_PM0_CONTROL 0x31c
> > @@ -303,9 +439,15 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
> > #define UNDERFLOW_REPORT_ENABLE (1 << 0)
> >
> > #define DC_DISP_DISP_SIGNAL_OPTIONS0 0x400
> > -#define H_PULSE0_ENABLE (1 << 8)
> > -#define H_PULSE1_ENABLE (1 << 10)
> > -#define H_PULSE2_ENABLE (1 << 12)
> > +#define H_PULSE0_ENABLE BIT(8)
> > +#define H_PULSE1_ENABLE BIT(10)
> > +#define H_PULSE2_ENABLE BIT(12)
> > +#define V_PULSE0_ENABLE BIT(16)
> > +#define V_PULSE1_ENABLE BIT(18)
> > +#define V_PULSE2_ENABLE BIT(19)
> > +#define V_PULSE3_ENABLE BIT(20)
> > +#define M0_ENABLE BIT(24)
> > +#define M1_ENABLE BIT(26)
> >
> > #define DC_DISP_DISP_SIGNAL_OPTIONS1 0x401
> >
> > @@ -456,6 +598,22 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
> > #define DC_DISP_SHIFT_CLOCK_OPTIONS 0x431
> > #define SC1_H_QUALIFIER_NONE (1 << 16)
> > #define SC0_H_QUALIFIER_NONE (1 << 0)
> > +#define SC0_H_QUALIFIER(x) (((x) & 0x7) << 0)
> > +#define SC1_H_QUALIFIER(x) (((x) & 0x7) << 16)
> > +#define SC_H_QUALIFIER_DISABLE 0
> > +#define SC_H_QUALIFIER_NONE 1
> > +#define SC_H_QUALIFIER_HACTIVE 2
> > +#define SC_H_QUALIFIER_EXT_HACTIVE 3
> > +#define SC_H_QUALIFIER_HPULSE 4
> > +#define SC_H_QUALIFIER_EXT_HPULSE 5
> > +#define SC0_V_QUALIFIER(x) (((x) & 0x7) << 3)
> > +#define SC1_V_QUALIFIER(x) (((x) & 0x7) << 19)
> > +#define SC_V_QUALIFIER_NONE 0
> > +#define SC_V_QUALIFIER_RSVD 1
> > +#define SC_V_QUALIFIER_VACTIVE 2
> > +#define SC_V_QUALIFIER_EXT_VACTIVE 3
> > +#define SC_V_QUALIFIER_VPULSE 4
> > +#define SC_V_QUALIFIER_EXT_VPULSE 5
> >
> > #define DC_DISP_DATA_ENABLE_OPTIONS 0x432
> > #define DE_SELECT_ACTIVE_BLANK (0 << 0)
> > @@ -493,6 +651,20 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
> > #define DC_DISP_CURSOR_POSITION_NS 0x441
> >
> > #define DC_DISP_INIT_SEQ_CONTROL 0x442
> > +#define SEND_INIT_SEQUENCE BIT(0)
> > +#define INIT_SEQUENCE_MODE_SPI BIT(1)
> > +#define INIT_SEQUENCE_MODE_PLCD 0
> > +#define INIT_SEQ_DC_SIGNAL_SHIFT 4
> > +#define INIT_SEQ_DC_SIGNAL_MASK (0x7 << INIT_SEQ_DC_SIGNAL_SHIFT)
> > +#define NO_DC_SIGNAL 0
> > +#define DC_SIGNAL_VSYNC 1
> > +#define DC_SIGNAL_VPULSE0 2
> > +#define DC_SIGNAL_VPULSE1 3
> > +#define DC_SIGNAL_VPULSE2 4
> > +#define DC_SIGNAL_VPULSE3 5
> > +#define INIT_SEQ_DC_CONTROL_SHIFT 7
> > +#define FRAME_INIT_SEQ_CYCLES_SHIFT 8
> > +
> > #define DC_DISP_SPI_INIT_SEQ_DATA_A 0x443
> > #define DC_DISP_SPI_INIT_SEQ_DATA_B 0x444
> > #define DC_DISP_SPI_INIT_SEQ_DATA_C 0x445
> > --
> > 2.53.0
> >
> >
>
>
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 07/12] dt-bindings: display: tegra: Document Tegra20 DSI port
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
` (5 preceding siblings ...)
2026-11-22 8:18 ` [PATCH v8 06/12] drm/tegra: dc: Add elements required by Tegra MIPI DBI Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-22 8:18 ` [PATCH v8 08/12] drm/tegra: output: Make panel parsing configurable Svyatoslav Ryhel
` (4 subsequent siblings)
11 siblings, 0 replies; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
Document the optional port node, which is required for correctly modeling
a dual-mode panel.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
.../bindings/display/tegra/nvidia,tegra20-dsi.yaml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dsi.yaml b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dsi.yaml
index 59e1dc0813e73..0f4837648d179 100644
--- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dsi.yaml
+++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dsi.yaml
@@ -83,6 +83,12 @@ properties:
gang up with in order to support up to 8 data lanes
$ref: /schemas/types.yaml#/definitions/phandle
+ port:
+ description: specifies the connection port for the dual-mode panel
+ and is required only when the panel is operating in dual-mode
+ configuration.
+ $ref: /schemas/graph.yaml#/properties/port
+
allOf:
- $ref: ../dsi-controller.yaml#
- if:
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* [PATCH v8 08/12] drm/tegra: output: Make panel parsing configurable
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
` (6 preceding siblings ...)
2026-11-22 8:18 ` [PATCH v8 07/12] dt-bindings: display: tegra: Document Tegra20 DSI port Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-27 5:01 ` Mikko Perttunen
2026-11-22 8:18 ` [PATCH v8 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs Svyatoslav Ryhel
` (3 subsequent siblings)
11 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
The tegra_output_probe() function performs panel parsing unconditionally,
even for devices that do not require it or that handle panel parsing on
their own (like DSI).
This causes devices with dual DSI panels to fail, because they rely on the
OF graph to find the secondary DSI controller, whereas
tegra_output_probe() treats this port as a direct connection to the panel.
An example of such a device is the Xiaomi Mi Pad. Make panel parsing
configurable.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/gpu/drm/tegra/drm.h | 2 +-
drivers/gpu/drm/tegra/dsi.c | 2 +-
drivers/gpu/drm/tegra/hdmi.c | 2 +-
drivers/gpu/drm/tegra/output.c | 52 ++++++++++++++++++----------------
drivers/gpu/drm/tegra/rgb.c | 2 +-
drivers/gpu/drm/tegra/sor.c | 2 +-
6 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index bc720ae8d95e1..e53fe68161cb8 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -156,7 +156,7 @@ static inline struct tegra_output *connector_to_output(struct drm_connector *c)
}
/* from output.c */
-int tegra_output_probe(struct tegra_output *output);
+int tegra_output_probe(struct tegra_output *output, bool get_panel);
void tegra_output_remove(struct tegra_output *output);
int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
void tegra_output_exit(struct tegra_output *output);
diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
index b5806a53e75ac..6d6adc485e51e 100644
--- a/drivers/gpu/drm/tegra/dsi.c
+++ b/drivers/gpu/drm/tegra/dsi.c
@@ -1617,7 +1617,7 @@ static int tegra_dsi_probe(struct platform_device *pdev)
if (err < 0)
return err;
- err = tegra_output_probe(&dsi->output);
+ err = tegra_output_probe(&dsi->output, false);
if (err < 0)
return err;
diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
index 3a94968bd983a..e8c4347f09e69 100644
--- a/drivers/gpu/drm/tegra/hdmi.c
+++ b/drivers/gpu/drm/tegra/hdmi.c
@@ -1855,7 +1855,7 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
hdmi->output.dev = &pdev->dev;
- err = tegra_output_probe(&hdmi->output);
+ err = tegra_output_probe(&hdmi->output, true);
if (err < 0)
return err;
diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index eebf0ec0eea0a..d7d7f6ce0a8c3 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -93,7 +93,7 @@ static irqreturn_t hpd_irq(int irq, void *data)
return IRQ_HANDLED;
}
-int tegra_output_probe(struct tegra_output *output)
+int tegra_output_probe(struct tegra_output *output, bool get_panel)
{
struct device_node *ddc, *panel;
const void *edid;
@@ -103,31 +103,33 @@ int tegra_output_probe(struct tegra_output *output)
if (!output->of_node)
output->of_node = output->dev->of_node;
- err = drm_of_find_panel_or_bridge(output->of_node, -1, -1,
- &output->panel, &output->bridge);
- if (err && err != -ENODEV)
- return err;
-
- panel = of_parse_phandle(output->of_node, "nvidia,panel", 0);
- if (panel) {
- /*
- * Don't mix nvidia,panel phandle with the graph in a
- * device-tree.
- */
- WARN_ON(output->panel || output->bridge);
-
- if (output->panel) {
- drm_panel_put(output->panel);
- output->panel = NULL;
- }
-
- output->panel = of_drm_find_panel(panel);
- of_node_put(panel);
-
- if (IS_ERR(output->panel)) {
- err = PTR_ERR(output->panel);
- output->panel = NULL;
+ if (get_panel) {
+ err = drm_of_find_panel_or_bridge(output->of_node, -1, -1,
+ &output->panel, &output->bridge);
+ if (err && err != -ENODEV)
return err;
+
+ panel = of_parse_phandle(output->of_node, "nvidia,panel", 0);
+ if (panel) {
+ /*
+ * Don't mix nvidia,panel phandle with the graph in a
+ * device-tree.
+ */
+ WARN_ON(output->panel || output->bridge);
+
+ if (output->panel) {
+ drm_panel_put(output->panel);
+ output->panel = NULL;
+ }
+
+ output->panel = of_drm_find_panel(panel);
+ of_node_put(panel);
+
+ if (IS_ERR(output->panel)) {
+ err = PTR_ERR(output->panel);
+ output->panel = NULL;
+ return err;
+ }
}
}
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index 40a02cf5939aa..227a178f761bd 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -236,7 +236,7 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
rgb->output.of_node = np;
rgb->dc = dc;
- err = tegra_output_probe(&rgb->output);
+ err = tegra_output_probe(&rgb->output, true);
if (err < 0)
return err;
diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 061c5dbb738be..ebac9068b670f 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -3803,7 +3803,7 @@ static int tegra_sor_probe(struct platform_device *pdev)
if (err < 0)
goto put_aux;
- err = tegra_output_probe(&sor->output);
+ err = tegra_output_probe(&sor->output, true);
if (err < 0) {
dev_err_probe(&pdev->dev, err, "failed to probe output\n");
goto put_aux;
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* Re: [PATCH v8 08/12] drm/tegra: output: Make panel parsing configurable
2026-11-22 8:18 ` [PATCH v8 08/12] drm/tegra: output: Make panel parsing configurable Svyatoslav Ryhel
@ 2026-11-27 5:01 ` Mikko Perttunen
0 siblings, 0 replies; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 5:01 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Svyatoslav Ryhel, devicetree
Cc: dri-devel, devicetree, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> The tegra_output_probe() function performs panel parsing unconditionally,
> even for devices that do not require it or that handle panel parsing on
> their own (like DSI).
>
> This causes devices with dual DSI panels to fail, because they rely on the
> OF graph to find the secondary DSI controller, whereas
> tegra_output_probe() treats this port as a direct connection to the panel.
> An example of such a device is the Xiaomi Mi Pad. Make panel parsing
> configurable.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> drivers/gpu/drm/tegra/drm.h | 2 +-
> drivers/gpu/drm/tegra/dsi.c | 2 +-
> drivers/gpu/drm/tegra/hdmi.c | 2 +-
> drivers/gpu/drm/tegra/output.c | 52 ++++++++++++++++++----------------
> drivers/gpu/drm/tegra/rgb.c | 2 +-
> drivers/gpu/drm/tegra/sor.c | 2 +-
> 6 files changed, 32 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
> index bc720ae8d95e1..e53fe68161cb8 100644
> --- a/drivers/gpu/drm/tegra/drm.h
> +++ b/drivers/gpu/drm/tegra/drm.h
> @@ -156,7 +156,7 @@ static inline struct tegra_output *connector_to_output(struct drm_connector *c)
> }
>
> /* from output.c */
> -int tegra_output_probe(struct tegra_output *output);
> +int tegra_output_probe(struct tegra_output *output, bool get_panel);
> void tegra_output_remove(struct tegra_output *output);
> int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
> void tegra_output_exit(struct tegra_output *output);
> diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
> index b5806a53e75ac..6d6adc485e51e 100644
> --- a/drivers/gpu/drm/tegra/dsi.c
> +++ b/drivers/gpu/drm/tegra/dsi.c
> @@ -1617,7 +1617,7 @@ static int tegra_dsi_probe(struct platform_device *pdev)
> if (err < 0)
> return err;
>
> - err = tegra_output_probe(&dsi->output);
> + err = tegra_output_probe(&dsi->output, false);
> if (err < 0)
> return err;
>
> diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
> index 3a94968bd983a..e8c4347f09e69 100644
> --- a/drivers/gpu/drm/tegra/hdmi.c
> +++ b/drivers/gpu/drm/tegra/hdmi.c
> @@ -1855,7 +1855,7 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
>
> hdmi->output.dev = &pdev->dev;
>
> - err = tegra_output_probe(&hdmi->output);
> + err = tegra_output_probe(&hdmi->output, true);
> if (err < 0)
> return err;
>
> diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
> index eebf0ec0eea0a..d7d7f6ce0a8c3 100644
> --- a/drivers/gpu/drm/tegra/output.c
> +++ b/drivers/gpu/drm/tegra/output.c
> @@ -93,7 +93,7 @@ static irqreturn_t hpd_irq(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> -int tegra_output_probe(struct tegra_output *output)
> +int tegra_output_probe(struct tegra_output *output, bool get_panel)
> {
> struct device_node *ddc, *panel;
> const void *edid;
> @@ -103,31 +103,33 @@ int tegra_output_probe(struct tegra_output *output)
> if (!output->of_node)
> output->of_node = output->dev->of_node;
>
> - err = drm_of_find_panel_or_bridge(output->of_node, -1, -1,
> - &output->panel, &output->bridge);
> - if (err && err != -ENODEV)
> - return err;
> -
> - panel = of_parse_phandle(output->of_node, "nvidia,panel", 0);
> - if (panel) {
> - /*
> - * Don't mix nvidia,panel phandle with the graph in a
> - * device-tree.
> - */
> - WARN_ON(output->panel || output->bridge);
> -
> - if (output->panel) {
> - drm_panel_put(output->panel);
> - output->panel = NULL;
> - }
> -
> - output->panel = of_drm_find_panel(panel);
> - of_node_put(panel);
> -
> - if (IS_ERR(output->panel)) {
> - err = PTR_ERR(output->panel);
> - output->panel = NULL;
> + if (get_panel) {
> + err = drm_of_find_panel_or_bridge(output->of_node, -1, -1,
> + &output->panel, &output->bridge);
> + if (err && err != -ENODEV)
> return err;
> +
> + panel = of_parse_phandle(output->of_node, "nvidia,panel", 0);
> + if (panel) {
> + /*
> + * Don't mix nvidia,panel phandle with the graph in a
> + * device-tree.
> + */
> + WARN_ON(output->panel || output->bridge);
> +
> + if (output->panel) {
> + drm_panel_put(output->panel);
> + output->panel = NULL;
> + }
> +
> + output->panel = of_drm_find_panel(panel);
> + of_node_put(panel);
> +
> + if (IS_ERR(output->panel)) {
> + err = PTR_ERR(output->panel);
> + output->panel = NULL;
> + return err;
> + }
> }
> }
>
> diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> index 40a02cf5939aa..227a178f761bd 100644
> --- a/drivers/gpu/drm/tegra/rgb.c
> +++ b/drivers/gpu/drm/tegra/rgb.c
> @@ -236,7 +236,7 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
> rgb->output.of_node = np;
> rgb->dc = dc;
>
> - err = tegra_output_probe(&rgb->output);
> + err = tegra_output_probe(&rgb->output, true);
> if (err < 0)
> return err;
>
> diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
> index 061c5dbb738be..ebac9068b670f 100644
> --- a/drivers/gpu/drm/tegra/sor.c
> +++ b/drivers/gpu/drm/tegra/sor.c
> @@ -3803,7 +3803,7 @@ static int tegra_sor_probe(struct platform_device *pdev)
> if (err < 0)
> goto put_aux;
>
> - err = tegra_output_probe(&sor->output);
> + err = tegra_output_probe(&sor->output, true);
> if (err < 0) {
> dev_err_probe(&pdev->dev, err, "failed to probe output\n");
> goto put_aux;
> --
> 2.53.0
>
>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
` (7 preceding siblings ...)
2026-11-22 8:18 ` [PATCH v8 08/12] drm/tegra: output: Make panel parsing configurable Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-27 5:24 ` Mikko Perttunen
2026-11-22 8:18 ` [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags Svyatoslav Ryhel
` (2 subsequent siblings)
11 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
Switch to using the atomic versions of the enable() and disable()
operations.
This is required for acquiring the next bridge state without causing
crashes, in order to properly set up the encoder.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/gpu/drm/tegra/dsi.c | 20 +++++++++++++++-----
drivers/gpu/drm/tegra/hdmi.c | 20 +++++++++++++++-----
drivers/gpu/drm/tegra/rgb.c | 23 +++++++++++++++++------
drivers/gpu/drm/tegra/sor.c | 18 +++++++++++++-----
4 files changed, 60 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
index 6d6adc485e51e..cd61070072beb 100644
--- a/drivers/gpu/drm/tegra/dsi.c
+++ b/drivers/gpu/drm/tegra/dsi.c
@@ -855,7 +855,8 @@ static void tegra_dsi_unprepare(struct tegra_dsi *dsi)
dev_err(dsi->dev, "failed to suspend: %d\n", err);
}
-static void tegra_dsi_encoder_disable(struct drm_encoder *encoder)
+static void tegra_dsi_encoder_disable(struct drm_encoder *encoder,
+ struct drm_atomic_commit *comm_state)
{
struct tegra_output *output = encoder_to_output(encoder);
struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
@@ -919,16 +920,25 @@ static int tegra_dsi_prepare(struct tegra_dsi *dsi)
return 0;
}
-static void tegra_dsi_encoder_enable(struct drm_encoder *encoder)
+static void tegra_dsi_encoder_enable(struct drm_encoder *encoder,
+ struct drm_atomic_commit *comm_state)
{
- struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
struct tegra_output *output = encoder_to_output(encoder);
struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
+ struct drm_connector_state *conn_state;
struct tegra_dsi *dsi = to_dsi(output);
+ struct drm_crtc_state *crtc_state;
+ struct drm_connector *connector;
struct tegra_dsi_state *state;
+ struct drm_display_mode *mode;
u32 value;
int err;
+ connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
+ conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
+ crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
+ mode = &crtc_state->adjusted_mode;
+
err = tegra_dsi_prepare(dsi);
if (err < 0) {
dev_err(dsi->dev, "failed to prepare: %d\n", err);
@@ -1059,8 +1069,8 @@ static const struct drm_encoder_funcs tegra_dsi_encoder_funcs = {
};
static const struct drm_encoder_helper_funcs tegra_dsi_encoder_helper_funcs = {
- .disable = tegra_dsi_encoder_disable,
- .enable = tegra_dsi_encoder_enable,
+ .atomic_disable = tegra_dsi_encoder_disable,
+ .atomic_enable = tegra_dsi_encoder_enable,
.atomic_check = tegra_dsi_encoder_atomic_check,
};
diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
index e8c4347f09e69..a78279810dd82 100644
--- a/drivers/gpu/drm/tegra/hdmi.c
+++ b/drivers/gpu/drm/tegra/hdmi.c
@@ -1166,7 +1166,8 @@ tegra_hdmi_connector_helper_funcs = {
.mode_valid = tegra_hdmi_connector_mode_valid,
};
-static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder)
+static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder,
+ struct drm_atomic_commit *comm_state)
{
struct tegra_output *output = encoder_to_output(encoder);
struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
@@ -1209,18 +1210,27 @@ static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder)
dev_err(hdmi->dev, "failed to suspend: %d\n", err);
}
-static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder)
+static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder,
+ struct drm_atomic_commit *comm_state)
{
- struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
unsigned int h_sync_width, h_front_porch, h_back_porch, i, rekey;
struct tegra_output *output = encoder_to_output(encoder);
struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
struct tegra_hdmi *hdmi = to_hdmi(output);
+ struct drm_connector_state *conn_state;
+ struct drm_crtc_state *crtc_state;
unsigned int pulse_start, div82;
+ struct drm_connector *connector;
+ struct drm_display_mode *mode;
int retries = 1000;
u32 value;
int err;
+ connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
+ conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
+ crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
+ mode = &crtc_state->adjusted_mode;
+
err = host1x_client_resume(&hdmi->client);
if (err < 0) {
dev_err(hdmi->dev, "failed to resume: %d\n", err);
@@ -1460,8 +1470,8 @@ tegra_hdmi_encoder_atomic_check(struct drm_encoder *encoder,
}
static const struct drm_encoder_helper_funcs tegra_hdmi_encoder_helper_funcs = {
- .disable = tegra_hdmi_encoder_disable,
- .enable = tegra_hdmi_encoder_enable,
+ .atomic_disable = tegra_hdmi_encoder_disable,
+ .atomic_enable = tegra_hdmi_encoder_enable,
.atomic_check = tegra_hdmi_encoder_atomic_check,
};
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index 227a178f761bd..d48d498068ac8 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -90,7 +90,8 @@ static void tegra_dc_write_regs(struct tegra_dc *dc,
tegra_dc_writel(dc, table[i].value, table[i].offset);
}
-static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
+static void tegra_rgb_encoder_disable(struct drm_encoder *encoder,
+ struct drm_atomic_commit *state)
{
struct tegra_output *output = encoder_to_output(encoder);
struct tegra_rgb *rgb = to_rgb(output);
@@ -99,12 +100,22 @@ static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
tegra_dc_commit(rgb->dc);
}
-static void tegra_rgb_encoder_enable(struct drm_encoder *encoder)
+static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
+ struct drm_atomic_commit *state)
{
- struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
struct tegra_output *output = encoder_to_output(encoder);
struct tegra_rgb *rgb = to_rgb(output);
- u32 value;
+ struct drm_connector_state *conn_state;
+ struct drm_crtc_state *crtc_state;
+ struct drm_connector *connector;
+ struct drm_display_mode *mode;
+ u32 bus_flags, value;
+
+ /* Get mode flags */
+ connector = drm_atomic_get_new_connector_for_encoder(state, encoder);
+ conn_state = drm_atomic_get_new_connector_state(state, connector);
+ crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
+ mode = &crtc_state->adjusted_mode;
tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
@@ -201,8 +212,8 @@ static const struct drm_encoder_funcs tegra_rgb_encoder_funcs = {
};
static const struct drm_encoder_helper_funcs tegra_rgb_encoder_helper_funcs = {
- .disable = tegra_rgb_encoder_disable,
- .enable = tegra_rgb_encoder_enable,
+ .atomic_disable = tegra_rgb_encoder_disable,
+ .atomic_enable = tegra_rgb_encoder_enable,
.atomic_check = tegra_rgb_encoder_atomic_check,
};
diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index ebac9068b670f..45a9ea94c4355 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -2203,7 +2203,8 @@ static void tegra_sor_hdmi_scdc_start(struct tegra_sor *sor)
}
}
-static void tegra_sor_hdmi_disable(struct drm_encoder *encoder)
+static void tegra_sor_hdmi_disable(struct drm_encoder *encoder,
+ struct drm_atomic_commit *comm_state)
{
struct tegra_output *output = encoder_to_output(encoder);
struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
@@ -2244,13 +2245,17 @@ static void tegra_sor_hdmi_disable(struct drm_encoder *encoder)
host1x_client_suspend(&sor->client);
}
-static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
+static void tegra_sor_hdmi_enable(struct drm_encoder *encoder,
+ struct drm_atomic_commit *comm_state)
{
struct tegra_output *output = encoder_to_output(encoder);
unsigned int h_ref_to_sync = 1, pulse_start, max_ac;
struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
struct tegra_sor_hdmi_settings *settings;
+ struct drm_connector_state *conn_state;
struct tegra_sor *sor = to_sor(output);
+ struct drm_crtc_state *crtc_state;
+ struct drm_connector *connector;
struct tegra_sor_state *state;
struct drm_display_mode *mode;
unsigned long rate, pclk;
@@ -2259,7 +2264,10 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
int err;
state = to_sor_state(output->connector.state);
- mode = &encoder->crtc->state->adjusted_mode;
+ connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
+ conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
+ crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
+ mode = &crtc_state->adjusted_mode;
pclk = mode->clock * 1000;
err = host1x_client_resume(&sor->client);
@@ -2657,8 +2665,8 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
}
static const struct drm_encoder_helper_funcs tegra_sor_hdmi_helpers = {
- .disable = tegra_sor_hdmi_disable,
- .enable = tegra_sor_hdmi_enable,
+ .atomic_disable = tegra_sor_hdmi_disable,
+ .atomic_enable = tegra_sor_hdmi_enable,
.atomic_check = tegra_sor_encoder_atomic_check,
};
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* Re: [PATCH v8 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs
2026-11-22 8:18 ` [PATCH v8 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs Svyatoslav Ryhel
@ 2026-11-27 5:24 ` Mikko Perttunen
2026-11-27 9:17 ` Svyatoslav Ryhel
0 siblings, 1 reply; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 5:24 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Svyatoslav Ryhel, devicetree
Cc: dri-devel, devicetree, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> Switch to using the atomic versions of the enable() and disable()
> operations.
>
> This is required for acquiring the next bridge state without causing
> crashes, in order to properly set up the encoder.
This is a bit vague. I'd make an explicit reference to RGB needing
access to the bridge state, which is not possible with the non-atomic
functions, and then explaining that DSI / HDMI / SOR are converted for
consistency.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> drivers/gpu/drm/tegra/dsi.c | 20 +++++++++++++++-----
> drivers/gpu/drm/tegra/hdmi.c | 20 +++++++++++++++-----
> drivers/gpu/drm/tegra/rgb.c | 23 +++++++++++++++++------
> drivers/gpu/drm/tegra/sor.c | 18 +++++++++++++-----
> 4 files changed, 60 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
> index 6d6adc485e51e..cd61070072beb 100644
> --- a/drivers/gpu/drm/tegra/dsi.c
> +++ b/drivers/gpu/drm/tegra/dsi.c
> @@ -855,7 +855,8 @@ static void tegra_dsi_unprepare(struct tegra_dsi *dsi)
> dev_err(dsi->dev, "failed to suspend: %d\n", err);
> }
>
> -static void tegra_dsi_encoder_disable(struct drm_encoder *encoder)
> +static void tegra_dsi_encoder_disable(struct drm_encoder *encoder,
> + struct drm_atomic_commit *comm_state)
> {
> struct tegra_output *output = encoder_to_output(encoder);
> struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> @@ -919,16 +920,25 @@ static int tegra_dsi_prepare(struct tegra_dsi *dsi)
> return 0;
> }
>
> -static void tegra_dsi_encoder_enable(struct drm_encoder *encoder)
> +static void tegra_dsi_encoder_enable(struct drm_encoder *encoder,
> + struct drm_atomic_commit *comm_state)
> {
> - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> struct tegra_output *output = encoder_to_output(encoder);
> struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> + struct drm_connector_state *conn_state;
> struct tegra_dsi *dsi = to_dsi(output);
> + struct drm_crtc_state *crtc_state;
> + struct drm_connector *connector;
> struct tegra_dsi_state *state;
> + struct drm_display_mode *mode;
> u32 value;
> int err;
>
> + connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
> + conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
> + crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
> + mode = &crtc_state->adjusted_mode;
> +
> err = tegra_dsi_prepare(dsi);
> if (err < 0) {
> dev_err(dsi->dev, "failed to prepare: %d\n", err);
The function also uses encoder->crtc and tegra_dsi_get_state. Should
these be changed to conn_state->crtc and to_dsi_state(conn_state)?
Similarly for HDMI / SOR.
> @@ -1059,8 +1069,8 @@ static const struct drm_encoder_funcs tegra_dsi_encoder_funcs = {
> };
>
> static const struct drm_encoder_helper_funcs tegra_dsi_encoder_helper_funcs = {
> - .disable = tegra_dsi_encoder_disable,
> - .enable = tegra_dsi_encoder_enable,
> + .atomic_disable = tegra_dsi_encoder_disable,
> + .atomic_enable = tegra_dsi_encoder_enable,
> .atomic_check = tegra_dsi_encoder_atomic_check,
> };
>
> diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
> index e8c4347f09e69..a78279810dd82 100644
> --- a/drivers/gpu/drm/tegra/hdmi.c
> +++ b/drivers/gpu/drm/tegra/hdmi.c
> @@ -1166,7 +1166,8 @@ tegra_hdmi_connector_helper_funcs = {
> .mode_valid = tegra_hdmi_connector_mode_valid,
> };
>
> -static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder)
> +static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder,
> + struct drm_atomic_commit *comm_state)
> {
> struct tegra_output *output = encoder_to_output(encoder);
> struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> @@ -1209,18 +1210,27 @@ static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder)
> dev_err(hdmi->dev, "failed to suspend: %d\n", err);
> }
>
> -static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder)
> +static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder,
> + struct drm_atomic_commit *comm_state)
> {
> - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> unsigned int h_sync_width, h_front_porch, h_back_porch, i, rekey;
> struct tegra_output *output = encoder_to_output(encoder);
> struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> struct tegra_hdmi *hdmi = to_hdmi(output);
> + struct drm_connector_state *conn_state;
> + struct drm_crtc_state *crtc_state;
> unsigned int pulse_start, div82;
> + struct drm_connector *connector;
> + struct drm_display_mode *mode;
> int retries = 1000;
> u32 value;
> int err;
>
> + connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
> + conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
> + crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
> + mode = &crtc_state->adjusted_mode;
> +
> err = host1x_client_resume(&hdmi->client);
> if (err < 0) {
> dev_err(hdmi->dev, "failed to resume: %d\n", err);
> @@ -1460,8 +1470,8 @@ tegra_hdmi_encoder_atomic_check(struct drm_encoder *encoder,
> }
>
> static const struct drm_encoder_helper_funcs tegra_hdmi_encoder_helper_funcs = {
> - .disable = tegra_hdmi_encoder_disable,
> - .enable = tegra_hdmi_encoder_enable,
> + .atomic_disable = tegra_hdmi_encoder_disable,
> + .atomic_enable = tegra_hdmi_encoder_enable,
> .atomic_check = tegra_hdmi_encoder_atomic_check,
> };
>
> diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> index 227a178f761bd..d48d498068ac8 100644
> --- a/drivers/gpu/drm/tegra/rgb.c
> +++ b/drivers/gpu/drm/tegra/rgb.c
> @@ -90,7 +90,8 @@ static void tegra_dc_write_regs(struct tegra_dc *dc,
> tegra_dc_writel(dc, table[i].value, table[i].offset);
> }
>
> -static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
> +static void tegra_rgb_encoder_disable(struct drm_encoder *encoder,
> + struct drm_atomic_commit *state)
> {
> struct tegra_output *output = encoder_to_output(encoder);
> struct tegra_rgb *rgb = to_rgb(output);
> @@ -99,12 +100,22 @@ static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
> tegra_dc_commit(rgb->dc);
> }
>
> -static void tegra_rgb_encoder_enable(struct drm_encoder *encoder)
> +static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> + struct drm_atomic_commit *state)
> {
> - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> struct tegra_output *output = encoder_to_output(encoder);
> struct tegra_rgb *rgb = to_rgb(output);
> - u32 value;
> + struct drm_connector_state *conn_state;
> + struct drm_crtc_state *crtc_state;
> + struct drm_connector *connector;
> + struct drm_display_mode *mode;
> + u32 bus_flags, value;
> +
> + /* Get mode flags */
> + connector = drm_atomic_get_new_connector_for_encoder(state, encoder);
> + conn_state = drm_atomic_get_new_connector_state(state, connector);
> + crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> + mode = &crtc_state->adjusted_mode;
>
> tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
>
> @@ -201,8 +212,8 @@ static const struct drm_encoder_funcs tegra_rgb_encoder_funcs = {
> };
>
> static const struct drm_encoder_helper_funcs tegra_rgb_encoder_helper_funcs = {
> - .disable = tegra_rgb_encoder_disable,
> - .enable = tegra_rgb_encoder_enable,
> + .atomic_disable = tegra_rgb_encoder_disable,
> + .atomic_enable = tegra_rgb_encoder_enable,
> .atomic_check = tegra_rgb_encoder_atomic_check,
> };
>
> diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
> index ebac9068b670f..45a9ea94c4355 100644
> --- a/drivers/gpu/drm/tegra/sor.c
> +++ b/drivers/gpu/drm/tegra/sor.c
> @@ -2203,7 +2203,8 @@ static void tegra_sor_hdmi_scdc_start(struct tegra_sor *sor)
> }
> }
>
> -static void tegra_sor_hdmi_disable(struct drm_encoder *encoder)
> +static void tegra_sor_hdmi_disable(struct drm_encoder *encoder,
> + struct drm_atomic_commit *comm_state)
> {
> struct tegra_output *output = encoder_to_output(encoder);
> struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> @@ -2244,13 +2245,17 @@ static void tegra_sor_hdmi_disable(struct drm_encoder *encoder)
> host1x_client_suspend(&sor->client);
> }
>
> -static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
> +static void tegra_sor_hdmi_enable(struct drm_encoder *encoder,
> + struct drm_atomic_commit *comm_state)
> {
> struct tegra_output *output = encoder_to_output(encoder);
> unsigned int h_ref_to_sync = 1, pulse_start, max_ac;
> struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> struct tegra_sor_hdmi_settings *settings;
> + struct drm_connector_state *conn_state;
> struct tegra_sor *sor = to_sor(output);
> + struct drm_crtc_state *crtc_state;
> + struct drm_connector *connector;
> struct tegra_sor_state *state;
> struct drm_display_mode *mode;
> unsigned long rate, pclk;
> @@ -2259,7 +2264,10 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
> int err;
>
> state = to_sor_state(output->connector.state);
> - mode = &encoder->crtc->state->adjusted_mode;
> + connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
> + conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
> + crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
> + mode = &crtc_state->adjusted_mode;
> pclk = mode->clock * 1000;
>
> err = host1x_client_resume(&sor->client);
> @@ -2657,8 +2665,8 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
> }
>
> static const struct drm_encoder_helper_funcs tegra_sor_hdmi_helpers = {
> - .disable = tegra_sor_hdmi_disable,
> - .enable = tegra_sor_hdmi_enable,
> + .atomic_disable = tegra_sor_hdmi_disable,
> + .atomic_enable = tegra_sor_hdmi_enable,
> .atomic_check = tegra_sor_encoder_atomic_check,
> };
>
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs
2026-11-27 5:24 ` Mikko Perttunen
@ 2026-11-27 9:17 ` Svyatoslav Ryhel
0 siblings, 0 replies; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-27 9:17 UTC (permalink / raw)
To: Mikko Perttunen
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel
пт, 27 лист. 2026 р. о 07:24 Mikko Perttunen <mperttunen@nvidia.com> пише:
>
> On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > Switch to using the atomic versions of the enable() and disable()
> > operations.
> >
> > This is required for acquiring the next bridge state without causing
> > crashes, in order to properly set up the encoder.
>
> This is a bit vague. I'd make an explicit reference to RGB needing
> access to the bridge state, which is not possible with the non-atomic
> functions, and then explaining that DSI / HDMI / SOR are converted for
> consistency.
>
Noted
> >
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > ---
> > drivers/gpu/drm/tegra/dsi.c | 20 +++++++++++++++-----
> > drivers/gpu/drm/tegra/hdmi.c | 20 +++++++++++++++-----
> > drivers/gpu/drm/tegra/rgb.c | 23 +++++++++++++++++------
> > drivers/gpu/drm/tegra/sor.c | 18 +++++++++++++-----
> > 4 files changed, 60 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
> > index 6d6adc485e51e..cd61070072beb 100644
> > --- a/drivers/gpu/drm/tegra/dsi.c
> > +++ b/drivers/gpu/drm/tegra/dsi.c
> > @@ -855,7 +855,8 @@ static void tegra_dsi_unprepare(struct tegra_dsi *dsi)
> > dev_err(dsi->dev, "failed to suspend: %d\n", err);
> > }
> >
> > -static void tegra_dsi_encoder_disable(struct drm_encoder *encoder)
> > +static void tegra_dsi_encoder_disable(struct drm_encoder *encoder,
> > + struct drm_atomic_commit *comm_state)
> > {
> > struct tegra_output *output = encoder_to_output(encoder);
> > struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > @@ -919,16 +920,25 @@ static int tegra_dsi_prepare(struct tegra_dsi *dsi)
> > return 0;
> > }
> >
> > -static void tegra_dsi_encoder_enable(struct drm_encoder *encoder)
> > +static void tegra_dsi_encoder_enable(struct drm_encoder *encoder,
> > + struct drm_atomic_commit *comm_state)
> > {
> > - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> > struct tegra_output *output = encoder_to_output(encoder);
> > struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > + struct drm_connector_state *conn_state;
> > struct tegra_dsi *dsi = to_dsi(output);
> > + struct drm_crtc_state *crtc_state;
> > + struct drm_connector *connector;
> > struct tegra_dsi_state *state;
> > + struct drm_display_mode *mode;
> > u32 value;
> > int err;
> >
> > + connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
> > + conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
> > + crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
> > + mode = &crtc_state->adjusted_mode;
> > +
> > err = tegra_dsi_prepare(dsi);
> > if (err < 0) {
> > dev_err(dsi->dev, "failed to prepare: %d\n", err);
>
> The function also uses encoder->crtc and tegra_dsi_get_state. Should
> these be changed to conn_state->crtc and to_dsi_state(conn_state)?
>
> Similarly for HDMI / SOR.
>
I must have missed that. Good catch
> > @@ -1059,8 +1069,8 @@ static const struct drm_encoder_funcs tegra_dsi_encoder_funcs = {
> > };
> >
> > static const struct drm_encoder_helper_funcs tegra_dsi_encoder_helper_funcs = {
> > - .disable = tegra_dsi_encoder_disable,
> > - .enable = tegra_dsi_encoder_enable,
> > + .atomic_disable = tegra_dsi_encoder_disable,
> > + .atomic_enable = tegra_dsi_encoder_enable,
> > .atomic_check = tegra_dsi_encoder_atomic_check,
> > };
> >
> > diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
> > index e8c4347f09e69..a78279810dd82 100644
> > --- a/drivers/gpu/drm/tegra/hdmi.c
> > +++ b/drivers/gpu/drm/tegra/hdmi.c
> > @@ -1166,7 +1166,8 @@ tegra_hdmi_connector_helper_funcs = {
> > .mode_valid = tegra_hdmi_connector_mode_valid,
> > };
> >
> > -static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder)
> > +static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder,
> > + struct drm_atomic_commit *comm_state)
> > {
> > struct tegra_output *output = encoder_to_output(encoder);
> > struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > @@ -1209,18 +1210,27 @@ static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder)
> > dev_err(hdmi->dev, "failed to suspend: %d\n", err);
> > }
> >
> > -static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder)
> > +static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder,
> > + struct drm_atomic_commit *comm_state)
> > {
> > - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> > unsigned int h_sync_width, h_front_porch, h_back_porch, i, rekey;
> > struct tegra_output *output = encoder_to_output(encoder);
> > struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > struct tegra_hdmi *hdmi = to_hdmi(output);
> > + struct drm_connector_state *conn_state;
> > + struct drm_crtc_state *crtc_state;
> > unsigned int pulse_start, div82;
> > + struct drm_connector *connector;
> > + struct drm_display_mode *mode;
> > int retries = 1000;
> > u32 value;
> > int err;
> >
> > + connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
> > + conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
> > + crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
> > + mode = &crtc_state->adjusted_mode;
> > +
> > err = host1x_client_resume(&hdmi->client);
> > if (err < 0) {
> > dev_err(hdmi->dev, "failed to resume: %d\n", err);
> > @@ -1460,8 +1470,8 @@ tegra_hdmi_encoder_atomic_check(struct drm_encoder *encoder,
> > }
> >
> > static const struct drm_encoder_helper_funcs tegra_hdmi_encoder_helper_funcs = {
> > - .disable = tegra_hdmi_encoder_disable,
> > - .enable = tegra_hdmi_encoder_enable,
> > + .atomic_disable = tegra_hdmi_encoder_disable,
> > + .atomic_enable = tegra_hdmi_encoder_enable,
> > .atomic_check = tegra_hdmi_encoder_atomic_check,
> > };
> >
> > diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> > index 227a178f761bd..d48d498068ac8 100644
> > --- a/drivers/gpu/drm/tegra/rgb.c
> > +++ b/drivers/gpu/drm/tegra/rgb.c
> > @@ -90,7 +90,8 @@ static void tegra_dc_write_regs(struct tegra_dc *dc,
> > tegra_dc_writel(dc, table[i].value, table[i].offset);
> > }
> >
> > -static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
> > +static void tegra_rgb_encoder_disable(struct drm_encoder *encoder,
> > + struct drm_atomic_commit *state)
> > {
> > struct tegra_output *output = encoder_to_output(encoder);
> > struct tegra_rgb *rgb = to_rgb(output);
> > @@ -99,12 +100,22 @@ static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
> > tegra_dc_commit(rgb->dc);
> > }
> >
> > -static void tegra_rgb_encoder_enable(struct drm_encoder *encoder)
> > +static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> > + struct drm_atomic_commit *state)
> > {
> > - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> > struct tegra_output *output = encoder_to_output(encoder);
> > struct tegra_rgb *rgb = to_rgb(output);
> > - u32 value;
> > + struct drm_connector_state *conn_state;
> > + struct drm_crtc_state *crtc_state;
> > + struct drm_connector *connector;
> > + struct drm_display_mode *mode;
> > + u32 bus_flags, value;
> > +
> > + /* Get mode flags */
> > + connector = drm_atomic_get_new_connector_for_encoder(state, encoder);
> > + conn_state = drm_atomic_get_new_connector_state(state, connector);
> > + crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> > + mode = &crtc_state->adjusted_mode;
> >
> > tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
> >
> > @@ -201,8 +212,8 @@ static const struct drm_encoder_funcs tegra_rgb_encoder_funcs = {
> > };
> >
> > static const struct drm_encoder_helper_funcs tegra_rgb_encoder_helper_funcs = {
> > - .disable = tegra_rgb_encoder_disable,
> > - .enable = tegra_rgb_encoder_enable,
> > + .atomic_disable = tegra_rgb_encoder_disable,
> > + .atomic_enable = tegra_rgb_encoder_enable,
> > .atomic_check = tegra_rgb_encoder_atomic_check,
> > };
> >
> > diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
> > index ebac9068b670f..45a9ea94c4355 100644
> > --- a/drivers/gpu/drm/tegra/sor.c
> > +++ b/drivers/gpu/drm/tegra/sor.c
> > @@ -2203,7 +2203,8 @@ static void tegra_sor_hdmi_scdc_start(struct tegra_sor *sor)
> > }
> > }
> >
> > -static void tegra_sor_hdmi_disable(struct drm_encoder *encoder)
> > +static void tegra_sor_hdmi_disable(struct drm_encoder *encoder,
> > + struct drm_atomic_commit *comm_state)
> > {
> > struct tegra_output *output = encoder_to_output(encoder);
> > struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > @@ -2244,13 +2245,17 @@ static void tegra_sor_hdmi_disable(struct drm_encoder *encoder)
> > host1x_client_suspend(&sor->client);
> > }
> >
> > -static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
> > +static void tegra_sor_hdmi_enable(struct drm_encoder *encoder,
> > + struct drm_atomic_commit *comm_state)
> > {
> > struct tegra_output *output = encoder_to_output(encoder);
> > unsigned int h_ref_to_sync = 1, pulse_start, max_ac;
> > struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > struct tegra_sor_hdmi_settings *settings;
> > + struct drm_connector_state *conn_state;
> > struct tegra_sor *sor = to_sor(output);
> > + struct drm_crtc_state *crtc_state;
> > + struct drm_connector *connector;
> > struct tegra_sor_state *state;
> > struct drm_display_mode *mode;
> > unsigned long rate, pclk;
> > @@ -2259,7 +2264,10 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
> > int err;
> >
> > state = to_sor_state(output->connector.state);
> > - mode = &encoder->crtc->state->adjusted_mode;
> > + connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
> > + conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
> > + crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
> > + mode = &crtc_state->adjusted_mode;
> > pclk = mode->clock * 1000;
> >
> > err = host1x_client_resume(&sor->client);
> > @@ -2657,8 +2665,8 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
> > }
> >
> > static const struct drm_encoder_helper_funcs tegra_sor_hdmi_helpers = {
> > - .disable = tegra_sor_hdmi_disable,
> > - .enable = tegra_sor_hdmi_enable,
> > + .atomic_disable = tegra_sor_hdmi_disable,
> > + .atomic_enable = tegra_sor_hdmi_enable,
> > .atomic_check = tegra_sor_encoder_atomic_check,
> > };
> >
> > --
> > 2.53.0
> >
> >
>
>
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
` (8 preceding siblings ...)
2026-11-22 8:18 ` [PATCH v8 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-27 6:22 ` Mikko Perttunen
2026-11-22 8:18 ` [PATCH v8 11/12] dt-bindings: display: tegra: Document 8-bit CPU parallel interface Svyatoslav Ryhel
2026-11-22 8:18 ` [PATCH v8 12/12] drm/tegra: Add support for 8-bit CPU interface Svyatoslav Ryhel
11 siblings, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
Parameterize configuration based on bus flags passed from the bridge or
panel. The list of supported flags includes now pixel clock polarity,
display enable (DE) polarity, and data alignment.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/gpu/drm/tegra/rgb.c | 39 +++++++++++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index d48d498068ac8..faecd6f94359f 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -5,6 +5,7 @@
*/
#include <linux/clk.h>
+#include <linux/media-bus-format.h>
#include <linux/of.h>
#include <drm/drm_atomic_helper.h>
@@ -106,6 +107,7 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
struct tegra_output *output = encoder_to_output(encoder);
struct tegra_rgb *rgb = to_rgb(output);
struct drm_connector_state *conn_state;
+ struct drm_bridge_state *bridge_state;
struct drm_crtc_state *crtc_state;
struct drm_connector *connector;
struct drm_display_mode *mode;
@@ -117,12 +119,21 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
mode = &crtc_state->adjusted_mode;
+ /* Get but flags from the bridge state. */
+ bridge_state = drm_atomic_get_new_bridge_state(state, output->bridge);
+ if (bridge_state)
+ bus_flags = bridge_state->input_bus_cfg.flags;
+ else
+ bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE |
+ DRM_BUS_FLAG_DE_HIGH |
+ DRM_BUS_FLAG_DATA_MSB_TO_LSB;
+
tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
tegra_dc_writel(rgb->dc, value, DC_DISP_DATA_ENABLE_OPTIONS);
- /* configure H- and V-sync signal polarities */
+ /* configure H- and V-sync and pixel clock signal polarities */
value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(1));
if (mode->flags & DRM_MODE_FLAG_NHSYNC)
@@ -135,11 +146,31 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
else
value &= ~LVS_OUTPUT_POLARITY_LOW;
+ if (bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
+ value &= ~BIT(PIN_LSC0);
+ else
+ value |= BIT(PIN_LSC0);
+
tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(1));
- /* XXX: parameterize? */
- value = DISP_DATA_FORMAT_DF1P1C | DISP_ALIGNMENT_MSB |
- DISP_ORDER_RED_BLUE;
+ /* configure DE signal polarities */
+ value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(3));
+
+ if (bus_flags & DRM_BUS_FLAG_DE_LOW)
+ value |= BIT(PIN_LSPI);
+ else
+ value &= ~BIT(PIN_LSPI);
+
+ tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(3));
+
+ /* configure DATA order and alignment */
+ value = DISP_DATA_FORMAT_DF1P1C | DISP_ORDER_RED_BLUE;
+
+ if (bus_flags & DRM_BUS_FLAG_DATA_LSB_TO_MSB)
+ value |= DISP_ALIGNMENT_LSB;
+ else
+ value &= ~DISP_ALIGNMENT_LSB;
+
tegra_dc_writel(rgb->dc, value, DC_DISP_DISP_INTERFACE_CONTROL);
tegra_dc_commit(rgb->dc);
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* Re: [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags
2026-11-22 8:18 ` [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags Svyatoslav Ryhel
@ 2026-11-27 6:22 ` Mikko Perttunen
2026-11-27 9:21 ` Svyatoslav Ryhel
0 siblings, 1 reply; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 6:22 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Svyatoslav Ryhel, devicetree
Cc: dri-devel, devicetree, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> Parameterize configuration based on bus flags passed from the bridge or
> panel. The list of supported flags includes now pixel clock polarity,
> display enable (DE) polarity, and data alignment.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> drivers/gpu/drm/tegra/rgb.c | 39 +++++++++++++++++++++++++++++++++----
> 1 file changed, 35 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> index d48d498068ac8..faecd6f94359f 100644
> --- a/drivers/gpu/drm/tegra/rgb.c
> +++ b/drivers/gpu/drm/tegra/rgb.c
> @@ -5,6 +5,7 @@
> */
>
> #include <linux/clk.h>
> +#include <linux/media-bus-format.h>
> #include <linux/of.h>
>
> #include <drm/drm_atomic_helper.h>
> @@ -106,6 +107,7 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> struct tegra_output *output = encoder_to_output(encoder);
> struct tegra_rgb *rgb = to_rgb(output);
> struct drm_connector_state *conn_state;
> + struct drm_bridge_state *bridge_state;
> struct drm_crtc_state *crtc_state;
> struct drm_connector *connector;
> struct drm_display_mode *mode;
> @@ -117,12 +119,21 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> mode = &crtc_state->adjusted_mode;
>
> + /* Get but flags from the bridge state. */
s/but/bus/
> + bridge_state = drm_atomic_get_new_bridge_state(state, output->bridge);
> + if (bridge_state)
> + bus_flags = bridge_state->input_bus_cfg.flags;
> + else
> + bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE |
> + DRM_BUS_FLAG_DE_HIGH |
> + DRM_BUS_FLAG_DATA_MSB_TO_LSB;
> +
> tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
>
> value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
> tegra_dc_writel(rgb->dc, value, DC_DISP_DATA_ENABLE_OPTIONS);
>
> - /* configure H- and V-sync signal polarities */
> + /* configure H- and V-sync and pixel clock signal polarities */
> value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(1));
>
> if (mode->flags & DRM_MODE_FLAG_NHSYNC)
> @@ -135,11 +146,31 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> else
> value &= ~LVS_OUTPUT_POLARITY_LOW;
>
> + if (bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
> + value &= ~BIT(PIN_LSC0);
> + else
> + value |= BIT(PIN_LSC0);
I think this is the wrong way around: SAMPLE_POSEDGE means that the
pixel data is sampled on a rising edge. That is, it should be driven on
the low edge so it's ready for sampling in time for the rising edge.
LSC0_OUTPUT_POLARITY says that the value "LOW" (a bit confusingly, 1)
corresponds to a data transition on the falling edge, i.e. sampling on
the rising edge.
Section 31.9.6 states this a bit more clearly: "an active low pixel
clock means that the data changes on the falling edge of the clock, to
be latched on the rising edge".
> +
> tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(1));
>
> - /* XXX: parameterize? */
> - value = DISP_DATA_FORMAT_DF1P1C | DISP_ALIGNMENT_MSB |
> - DISP_ORDER_RED_BLUE;
> + /* configure DE signal polarities */
> + value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(3));
> +
> + if (bus_flags & DRM_BUS_FLAG_DE_LOW)
> + value |= BIT(PIN_LSPI);
> + else
> + value &= ~BIT(PIN_LSPI);
> +
> + tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(3));
> +
> + /* configure DATA order and alignment */
> + value = DISP_DATA_FORMAT_DF1P1C | DISP_ORDER_RED_BLUE;
> +
> + if (bus_flags & DRM_BUS_FLAG_DATA_LSB_TO_MSB)
> + value |= DISP_ALIGNMENT_LSB;
> + else
> + value &= ~DISP_ALIGNMENT_LSB;
DRM_BUS_FLAG_DATA_LSB_TO_MSB does not seem the correct thing to check
here. According to the TRM, DISP_ALIGNMENT doesn't swap between LSB/MSB
bit ordering in a classical way, instead:
// DISP_DATA_ALIGNMENT = 0 (MSB)
LD[23:0] = {R[1:0], G[1:0], B[1:0],
R[7:2], G[7:2], B[7:2]};
// DISP_DATA_ALIGNMENT = 1 (LSB)
LD[23:0] = {R[7:0], G[7:0], B[7:0]};
I suppose MSB is more natural for 18-bit panels and LSB for 24-bit
panels depending on the layout. So the correct value depends on how the
panel is wired to the SoC on the board. Hence, I think we should
describe this with a new property in device tree under rgb/dbi or
endpoint node. Something like 'nvidia,rgb888-wiring' for LSB? And
document that this means the above kind of wiring - not all RGB888
panels use it.
> +
> tegra_dc_writel(rgb->dc, value, DC_DISP_DISP_INTERFACE_CONTROL);
>
> tegra_dc_commit(rgb->dc);
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags
2026-11-27 6:22 ` Mikko Perttunen
@ 2026-11-27 9:21 ` Svyatoslav Ryhel
2026-11-27 9:41 ` Svyatoslav Ryhel
2026-11-27 12:35 ` Mikko Perttunen
0 siblings, 2 replies; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-27 9:21 UTC (permalink / raw)
To: Mikko Perttunen
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel
пт, 27 лист. 2026 р. о 08:22 Mikko Perttunen <mperttunen@nvidia.com> пише:
>
> On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > Parameterize configuration based on bus flags passed from the bridge or
> > panel. The list of supported flags includes now pixel clock polarity,
> > display enable (DE) polarity, and data alignment.
> >
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > ---
> > drivers/gpu/drm/tegra/rgb.c | 39 +++++++++++++++++++++++++++++++++----
> > 1 file changed, 35 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> > index d48d498068ac8..faecd6f94359f 100644
> > --- a/drivers/gpu/drm/tegra/rgb.c
> > +++ b/drivers/gpu/drm/tegra/rgb.c
> > @@ -5,6 +5,7 @@
> > */
> >
> > #include <linux/clk.h>
> > +#include <linux/media-bus-format.h>
> > #include <linux/of.h>
> >
> > #include <drm/drm_atomic_helper.h>
> > @@ -106,6 +107,7 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> > struct tegra_output *output = encoder_to_output(encoder);
> > struct tegra_rgb *rgb = to_rgb(output);
> > struct drm_connector_state *conn_state;
> > + struct drm_bridge_state *bridge_state;
> > struct drm_crtc_state *crtc_state;
> > struct drm_connector *connector;
> > struct drm_display_mode *mode;
> > @@ -117,12 +119,21 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> > crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> > mode = &crtc_state->adjusted_mode;
> >
> > + /* Get but flags from the bridge state. */
>
> s/but/bus/
>
> > + bridge_state = drm_atomic_get_new_bridge_state(state, output->bridge);
> > + if (bridge_state)
> > + bus_flags = bridge_state->input_bus_cfg.flags;
> > + else
> > + bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE |
> > + DRM_BUS_FLAG_DE_HIGH |
> > + DRM_BUS_FLAG_DATA_MSB_TO_LSB;
> > +
> > tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
> >
> > value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
> > tegra_dc_writel(rgb->dc, value, DC_DISP_DATA_ENABLE_OPTIONS);
> >
> > - /* configure H- and V-sync signal polarities */
> > + /* configure H- and V-sync and pixel clock signal polarities */
> > value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(1));
> >
> > if (mode->flags & DRM_MODE_FLAG_NHSYNC)
> > @@ -135,11 +146,31 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> > else
> > value &= ~LVS_OUTPUT_POLARITY_LOW;
> >
> > + if (bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
> > + value &= ~BIT(PIN_LSC0);
> > + else
> > + value |= BIT(PIN_LSC0);
>
> I think this is the wrong way around: SAMPLE_POSEDGE means that the
> pixel data is sampled on a rising edge. That is, it should be driven on
> the low edge so it's ready for sampling in time for the rising edge.
>
> LSC0_OUTPUT_POLARITY says that the value "LOW" (a bit confusingly, 1)
> corresponds to a data transition on the falling edge, i.e. sampling on
> the rising edge.
>
> Section 31.9.6 states this a bit more clearly: "an active low pixel
> clock means that the data changes on the falling edge of the clock, to
> be latched on the rising edge".
>
DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE
Should I replace with DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE?
> > +
> > tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(1));
> >
> > - /* XXX: parameterize? */
> > - value = DISP_DATA_FORMAT_DF1P1C | DISP_ALIGNMENT_MSB |
> > - DISP_ORDER_RED_BLUE;
> > + /* configure DE signal polarities */
> > + value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(3));
> > +
> > + if (bus_flags & DRM_BUS_FLAG_DE_LOW)
> > + value |= BIT(PIN_LSPI);
> > + else
> > + value &= ~BIT(PIN_LSPI);
> > +
> > + tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(3));
> > +
> > + /* configure DATA order and alignment */
> > + value = DISP_DATA_FORMAT_DF1P1C | DISP_ORDER_RED_BLUE;
> > +
> > + if (bus_flags & DRM_BUS_FLAG_DATA_LSB_TO_MSB)
> > + value |= DISP_ALIGNMENT_LSB;
> > + else
> > + value &= ~DISP_ALIGNMENT_LSB;
>
> DRM_BUS_FLAG_DATA_LSB_TO_MSB does not seem the correct thing to check
> here. According to the TRM, DISP_ALIGNMENT doesn't swap between LSB/MSB
> bit ordering in a classical way, instead:
>
> // DISP_DATA_ALIGNMENT = 0 (MSB)
> LD[23:0] = {R[1:0], G[1:0], B[1:0],
> R[7:2], G[7:2], B[7:2]};
>
> // DISP_DATA_ALIGNMENT = 1 (LSB)
> LD[23:0] = {R[7:0], G[7:0], B[7:0]};
>
> I suppose MSB is more natural for 18-bit panels and LSB for 24-bit
> panels depending on the layout. So the correct value depends on how the
> panel is wired to the SoC on the board. Hence, I think we should
> describe this with a new property in device tree under rgb/dbi or
> endpoint node. Something like 'nvidia,rgb888-wiring' for LSB? And
> document that this means the above kind of wiring - not all RGB888
> panels use it.
>
Ugh, why is this so confusing...
> > +
> > tegra_dc_writel(rgb->dc, value, DC_DISP_DISP_INTERFACE_CONTROL);
> >
> > tegra_dc_commit(rgb->dc);
> > --
> > 2.53.0
> >
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags
2026-11-27 9:21 ` Svyatoslav Ryhel
@ 2026-11-27 9:41 ` Svyatoslav Ryhel
2026-11-27 12:26 ` Mikko Perttunen
2026-11-27 12:35 ` Mikko Perttunen
1 sibling, 1 reply; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-27 9:41 UTC (permalink / raw)
To: Mikko Perttunen
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel
пт, 27 лист. 2026 р. о 11:21 Svyatoslav Ryhel <clamor95@gmail.com> пише:
>
> пт, 27 лист. 2026 р. о 08:22 Mikko Perttunen <mperttunen@nvidia.com> пише:
> >
> > On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > > Parameterize configuration based on bus flags passed from the bridge or
> > > panel. The list of supported flags includes now pixel clock polarity,
> > > display enable (DE) polarity, and data alignment.
> > >
> > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > ---
...
> > > + /* configure DATA order and alignment */
> > > + value = DISP_DATA_FORMAT_DF1P1C | DISP_ORDER_RED_BLUE;
> > > +
> > > + if (bus_flags & DRM_BUS_FLAG_DATA_LSB_TO_MSB)
> > > + value |= DISP_ALIGNMENT_LSB;
> > > + else
> > > + value &= ~DISP_ALIGNMENT_LSB;
> >
> > DRM_BUS_FLAG_DATA_LSB_TO_MSB does not seem the correct thing to check
> > here. According to the TRM, DISP_ALIGNMENT doesn't swap between LSB/MSB
> > bit ordering in a classical way, instead:
> >
> > // DISP_DATA_ALIGNMENT = 0 (MSB)
> > LD[23:0] = {R[1:0], G[1:0], B[1:0],
> > R[7:2], G[7:2], B[7:2]};
> >
> > // DISP_DATA_ALIGNMENT = 1 (LSB)
> > LD[23:0] = {R[7:0], G[7:0], B[7:0]};
> >
> > I suppose MSB is more natural for 18-bit panels and LSB for 24-bit
> > panels depending on the layout. So the correct value depends on how the
> > panel is wired to the SoC on the board. Hence, I think we should
> > describe this with a new property in device tree under rgb/dbi or
> > endpoint node. Something like 'nvidia,rgb888-wiring' for LSB? And
> > document that this means the above kind of wiring - not all RGB888
> > panels use it.
> >
>
> Ugh, why is this so confusing...
>
Using 'nvidia,rgb888-wiring' may be confusing since as you mentioned
not all RGB888 panels use it. I can add 'nvidia,data-alignment' to rgb
properties and set 0 to msb (default) and 1 to lsb, or directly set
boolean `nvidia,data-alignment-lsb`. Let me know which is preferred.
> > > +
> > > tegra_dc_writel(rgb->dc, value, DC_DISP_DISP_INTERFACE_CONTROL);
> > >
> > > tegra_dc_commit(rgb->dc);
> > > --
> > > 2.53.0
> > >
^ permalink raw reply [flat|nested] 33+ messages in thread* Re: [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags
2026-11-27 9:41 ` Svyatoslav Ryhel
@ 2026-11-27 12:26 ` Mikko Perttunen
0 siblings, 0 replies; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 12:26 UTC (permalink / raw)
To: devicetree
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Friday, November 27, 2026 6:41 PM Svyatoslav Ryhel wrote:
> пт, 27 лист. 2026 р. о 11:21 Svyatoslav Ryhel <clamor95@gmail.com> пише:
> >
> > пт, 27 лист. 2026 р. о 08:22 Mikko Perttunen <mperttunen@nvidia.com> пише:
> > >
> > > On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > > > Parameterize configuration based on bus flags passed from the bridge or
> > > > panel. The list of supported flags includes now pixel clock polarity,
> > > > display enable (DE) polarity, and data alignment.
> > > >
> > > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > ---
> ...
> > > > + /* configure DATA order and alignment */
> > > > + value = DISP_DATA_FORMAT_DF1P1C | DISP_ORDER_RED_BLUE;
> > > > +
> > > > + if (bus_flags & DRM_BUS_FLAG_DATA_LSB_TO_MSB)
> > > > + value |= DISP_ALIGNMENT_LSB;
> > > > + else
> > > > + value &= ~DISP_ALIGNMENT_LSB;
> > >
> > > DRM_BUS_FLAG_DATA_LSB_TO_MSB does not seem the correct thing to check
> > > here. According to the TRM, DISP_ALIGNMENT doesn't swap between LSB/MSB
> > > bit ordering in a classical way, instead:
> > >
> > > // DISP_DATA_ALIGNMENT = 0 (MSB)
> > > LD[23:0] = {R[1:0], G[1:0], B[1:0],
> > > R[7:2], G[7:2], B[7:2]};
> > >
> > > // DISP_DATA_ALIGNMENT = 1 (LSB)
> > > LD[23:0] = {R[7:0], G[7:0], B[7:0]};
> > >
> > > I suppose MSB is more natural for 18-bit panels and LSB for 24-bit
> > > panels depending on the layout. So the correct value depends on how the
> > > panel is wired to the SoC on the board. Hence, I think we should
> > > describe this with a new property in device tree under rgb/dbi or
> > > endpoint node. Something like 'nvidia,rgb888-wiring' for LSB? And
> > > document that this means the above kind of wiring - not all RGB888
> > > panels use it.
> > >
> >
> > Ugh, why is this so confusing...
> >
>
> Using 'nvidia,rgb888-wiring' may be confusing since as you mentioned
> not all RGB888 panels use it. I can add 'nvidia,data-alignment' to rgb
> properties and set 0 to msb (default) and 1 to lsb, or directly set
> boolean `nvidia,data-alignment-lsb`. Let me know which is preferred.
data-alignment is a very ambiguous name if one isn't deeply familiar
with the hardware, hence I was thinking something a bit clearer would be
better.
I agree nvidia,rgb888-wiring isn't the best either, but I'm not sure
what would be the best choice here, off-hand.
>
> > > > +
> > > > tegra_dc_writel(rgb->dc, value, DC_DISP_DISP_INTERFACE_CONTROL);
> > > >
> > > > tegra_dc_commit(rgb->dc);
> > > > --
> > > > 2.53.0
> > > >
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags
2026-11-27 9:21 ` Svyatoslav Ryhel
2026-11-27 9:41 ` Svyatoslav Ryhel
@ 2026-11-27 12:35 ` Mikko Perttunen
1 sibling, 0 replies; 33+ messages in thread
From: Mikko Perttunen @ 2026-11-27 12:35 UTC (permalink / raw)
To: devicetree
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
devicetree, dri-devel, linux-tegra, linux-kernel,
Svyatoslav Ryhel
On Friday, November 27, 2026 6:21 PM Svyatoslav Ryhel wrote:
> пт, 27 лист. 2026 р. о 08:22 Mikko Perttunen <mperttunen@nvidia.com> пише:
> >
> > On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > > Parameterize configuration based on bus flags passed from the bridge or
> > > panel. The list of supported flags includes now pixel clock polarity,
> > > display enable (DE) polarity, and data alignment.
> > >
> > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > ---
> > > drivers/gpu/drm/tegra/rgb.c | 39 +++++++++++++++++++++++++++++++++----
> > > 1 file changed, 35 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> > > index d48d498068ac8..faecd6f94359f 100644
> > > --- a/drivers/gpu/drm/tegra/rgb.c
> > > +++ b/drivers/gpu/drm/tegra/rgb.c
> > > @@ -5,6 +5,7 @@
> > > */
> > >
> > > #include <linux/clk.h>
> > > +#include <linux/media-bus-format.h>
> > > #include <linux/of.h>
> > >
> > > #include <drm/drm_atomic_helper.h>
> > > @@ -106,6 +107,7 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> > > struct tegra_output *output = encoder_to_output(encoder);
> > > struct tegra_rgb *rgb = to_rgb(output);
> > > struct drm_connector_state *conn_state;
> > > + struct drm_bridge_state *bridge_state;
> > > struct drm_crtc_state *crtc_state;
> > > struct drm_connector *connector;
> > > struct drm_display_mode *mode;
> > > @@ -117,12 +119,21 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> > > crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> > > mode = &crtc_state->adjusted_mode;
> > >
> > > + /* Get but flags from the bridge state. */
> >
> > s/but/bus/
> >
> > > + bridge_state = drm_atomic_get_new_bridge_state(state, output->bridge);
> > > + if (bridge_state)
> > > + bus_flags = bridge_state->input_bus_cfg.flags;
> > > + else
> > > + bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE |
> > > + DRM_BUS_FLAG_DE_HIGH |
> > > + DRM_BUS_FLAG_DATA_MSB_TO_LSB;
> > > +
> > > tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
> > >
> > > value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
> > > tegra_dc_writel(rgb->dc, value, DC_DISP_DATA_ENABLE_OPTIONS);
> > >
> > > - /* configure H- and V-sync signal polarities */
> > > + /* configure H- and V-sync and pixel clock signal polarities */
> > > value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(1));
> > >
> > > if (mode->flags & DRM_MODE_FLAG_NHSYNC)
> > > @@ -135,11 +146,31 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> > > else
> > > value &= ~LVS_OUTPUT_POLARITY_LOW;
> > >
> > > + if (bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
> > > + value &= ~BIT(PIN_LSC0);
> > > + else
> > > + value |= BIT(PIN_LSC0);
> >
> > I think this is the wrong way around: SAMPLE_POSEDGE means that the
> > pixel data is sampled on a rising edge. That is, it should be driven on
> > the low edge so it's ready for sampling in time for the rising edge.
> >
> > LSC0_OUTPUT_POLARITY says that the value "LOW" (a bit confusingly, 1)
> > corresponds to a data transition on the falling edge, i.e. sampling on
> > the rising edge.
> >
> > Section 31.9.6 states this a bit more clearly: "an active low pixel
> > clock means that the data changes on the falling edge of the clock, to
> > be latched on the rising edge".
> >
>
> DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE
>
> Should I replace with DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE?
No -- with the current code, let's say
DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE is set. I.e. the panel tells us that
it will be sampling pixel data on the positive (rising) edge.
LSC0_OUTPUT_POLARITY will be set to 0. The TRM documents the value 0 as
"active high", and "means that rising edge coincides with data
transition". That is, the display controller will change the output pin
state to color data on the rising edge. So the SoC pins will change
state at the rising edge, and the panel will sample at the rising edge.
But the pins will take some time to take their new values, so this might
not work or could be unreliable depending on all kinds of timing
factors. So if the panel is sampling as the rising edge, the SoC should
be driving the pins at the falling edge, that way there is time for the
pins to settle before the panel samples them.
So the value written to LSC0_OUTPUT_POLARITY should be the opposite of
what it's now. If that breaks the panel, either it's reporting the
incorrect DRM_BUS_FLAG_PIXDATA_SAMPLE_* value or something else is
incorrect.
>
> > > +
> > > tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(1));
> > >
> > > - /* XXX: parameterize? */
> > > - value = DISP_DATA_FORMAT_DF1P1C | DISP_ALIGNMENT_MSB |
> > > - DISP_ORDER_RED_BLUE;
> > > + /* configure DE signal polarities */
> > > + value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(3));
> > > +
> > > + if (bus_flags & DRM_BUS_FLAG_DE_LOW)
> > > + value |= BIT(PIN_LSPI);
> > > + else
> > > + value &= ~BIT(PIN_LSPI);
> > > +
> > > + tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(3));
> > > +
> > > + /* configure DATA order and alignment */
> > > + value = DISP_DATA_FORMAT_DF1P1C | DISP_ORDER_RED_BLUE;
> > > +
> > > + if (bus_flags & DRM_BUS_FLAG_DATA_LSB_TO_MSB)
> > > + value |= DISP_ALIGNMENT_LSB;
> > > + else
> > > + value &= ~DISP_ALIGNMENT_LSB;
> >
> > DRM_BUS_FLAG_DATA_LSB_TO_MSB does not seem the correct thing to check
> > here. According to the TRM, DISP_ALIGNMENT doesn't swap between LSB/MSB
> > bit ordering in a classical way, instead:
> >
> > // DISP_DATA_ALIGNMENT = 0 (MSB)
> > LD[23:0] = {R[1:0], G[1:0], B[1:0],
> > R[7:2], G[7:2], B[7:2]};
> >
> > // DISP_DATA_ALIGNMENT = 1 (LSB)
> > LD[23:0] = {R[7:0], G[7:0], B[7:0]};
> >
> > I suppose MSB is more natural for 18-bit panels and LSB for 24-bit
> > panels depending on the layout. So the correct value depends on how the
> > panel is wired to the SoC on the board. Hence, I think we should
> > describe this with a new property in device tree under rgb/dbi or
> > endpoint node. Something like 'nvidia,rgb888-wiring' for LSB? And
> > document that this means the above kind of wiring - not all RGB888
> > panels use it.
> >
>
> Ugh, why is this so confusing...
>
> > > +
> > > tegra_dc_writel(rgb->dc, value, DC_DISP_DISP_INTERFACE_CONTROL);
> > >
> > > tegra_dc_commit(rgb->dc);
> > > --
> > > 2.53.0
> > >
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 11/12] dt-bindings: display: tegra: Document 8-bit CPU parallel interface
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
` (9 preceding siblings ...)
2026-11-22 8:18 ` [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
2026-11-22 8:18 ` [PATCH v8 12/12] drm/tegra: Add support for 8-bit CPU interface Svyatoslav Ryhel
11 siblings, 0 replies; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
Document 8-bit CPU parallel MIPI DBI Type B interface provided by
Tegra20/30 SoCs display controller.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
.../display/tegra/nvidia,tegra20-dbi.yaml | 108 ++++++++++++++++++
.../display/tegra/nvidia,tegra20-dc.yaml | 15 +++
2 files changed, 123 insertions(+)
create mode 100644 Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dbi.yaml
diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dbi.yaml b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dbi.yaml
new file mode 100644
index 0000000000000..6a34202f80765
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dbi.yaml
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/tegra/nvidia,tegra20-dbi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nvidia Tegra Display Controller based MIPI DBI Type B interface
+
+maintainers:
+ - Svyatoslav Ryhel <clamor95@gmail.com>
+
+description: The display controller in Tegra20/30 SoCs features an
+ 8-bit SPI interface that closely resembles the MIPI DBI Type B
+ protocol and is referred to as '8-bit CPU'. Each display controller
+ provides two such interfaces, which can be used to send MIPI DCS
+ commands to initialize and control the panel while image data is
+ transmitted via 16/18/24-line RGB.
+
+properties:
+ nvidia,interface:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description:
+ Number of DBI interface used, 0 - primary, 1 - secondary. If
+ property is not set, primary will be used.
+ enum: [ 0, 1 ]
+
+ panel:
+ type: object
+ description: Node of supported panel driven by the bridge.
+
+ ports:
+ $ref: /schemas/graph.yaml#/properties/ports
+
+ properties:
+ port@0:
+ $ref: /schemas/graph.yaml#/$defs/port-base
+ unevaluatedProperties: false
+ description: Video port for RGB input.
+
+ properties:
+ endpoint:
+ $ref: /schemas/graph.yaml#/$defs/endpoint-base
+ unevaluatedProperties: false
+
+ properties:
+ bus-width:
+ enum: [ 16, 18, 24 ]
+
+ port@1:
+ $ref: /schemas/graph.yaml#/properties/port
+ description: Video port for DBI output (panel or connector).
+
+ required:
+ - port@0
+ - port@1
+
+required:
+ - panel
+ - ports
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+
+ dbi {
+ nvidia,interface = <0>;
+
+ panel {
+ compatible = "hit,tx10d07vm0baa";
+
+ reset-gpios = <&gpio 175 GPIO_ACTIVE_LOW>;
+
+ avci-supply = <&vcc_2v8_lcd>;
+ iovcc-supply = <&iovcc_1v8_lcd>;
+
+ backlight = <&backlight>;
+
+ port {
+ panel_input: endpoint {
+ remote-endpoint = <&bridge_output>;
+ };
+ };
+ };
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+
+ bridge_input: endpoint {
+ remote-endpoint = <&dpi_output>;
+ bus-width = <24>;
+ };
+ };
+
+ port@1 {
+ reg = <1>;
+
+ bridge_output: endpoint {
+ remote-endpoint = <&panel_input>;
+ };
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml
index 69be95afd5627..a014bf0dd508d 100644
--- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml
+++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml
@@ -76,6 +76,9 @@ properties:
$ref: /schemas/types.yaml#/definitions/phandle-array
description: A list of phandles of outputs that this display controller can drive.
+ dbi:
+ $ref: /schemas/display/tegra/nvidia,tegra20-dbi.yaml#
+
rgb:
type: object
@@ -155,6 +158,18 @@ allOf:
- const: wind
- const: wint
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - nvidia,tegra114-dc
+ - nvidia,tegra124-dc
+ - nvidia,tegra210-dc
+ then:
+ properties:
+ dbi: false
+
additionalProperties: false
required:
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread* [PATCH v8 12/12] drm/tegra: Add support for 8-bit CPU interface
2026-11-22 8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
` (10 preceding siblings ...)
2026-11-22 8:18 ` [PATCH v8 11/12] dt-bindings: display: tegra: Document 8-bit CPU parallel interface Svyatoslav Ryhel
@ 2026-11-22 8:18 ` Svyatoslav Ryhel
11 siblings, 0 replies; 33+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-22 8:18 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Thierry Reding, Jonathan Hunter, Neil Armstrong, Jessica Zhang,
Mikko Perttunen, Svyatoslav Ryhel
Cc: dri-devel, devicetree, linux-tegra, linux-kernel
The display controller in Tegra20/30 SoCs features an 8-bit SPI interface
that closely resembles the MIPI DBI Type B protocol and is referred to as
'8-bit CPU'. Each display controller provides two such interfaces, which
can be used to send MIPI DCS commands to initialize and control the panel
while image data is transmitted via 16/18/24-line RGB.
The '8-bit CPU', although being the DC interface, is modeled using a
bridge framework for flexibility and convenience. This implementation does
not change the existing codebase besides registering the bus.
Suggested-by: Mikko Perttunen <mperttunen@nvidia.com> # DC command transfer
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/gpu/drm/tegra/Kconfig | 1 +
drivers/gpu/drm/tegra/Makefile | 1 +
drivers/gpu/drm/tegra/dbi.c | 592 +++++++++++++++++++++++++++++++++
drivers/gpu/drm/tegra/dc.c | 4 +
drivers/gpu/drm/tegra/dc.h | 3 +
5 files changed, 601 insertions(+)
create mode 100644 drivers/gpu/drm/tegra/dbi.c
diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
index 8a3b16aac5d68..6f57fd3985edc 100644
--- a/drivers/gpu/drm/tegra/Kconfig
+++ b/drivers/gpu/drm/tegra/Kconfig
@@ -12,6 +12,7 @@ config DRM_TEGRA
select DRM_BRIDGE_CONNECTOR
select DRM_DISPLAY_DP_AUX_BUS
select DRM_KMS_HELPER
+ select DRM_MIPI_DBI
select DRM_MIPI_DSI
select DRM_PANEL
select FB_DMAMEM_HELPERS if DRM_FBDEV_EMULATION
diff --git a/drivers/gpu/drm/tegra/Makefile b/drivers/gpu/drm/tegra/Makefile
index e399b40d64a1d..ae7fccb3d6421 100644
--- a/drivers/gpu/drm/tegra/Makefile
+++ b/drivers/gpu/drm/tegra/Makefile
@@ -18,6 +18,7 @@ tegra-drm-y := \
hdmi.o \
mipi-phy.o \
dsi.o \
+ dbi.o \
sor.o \
dpaux.o \
gr2d.o \
diff --git a/drivers/gpu/drm/tegra/dbi.c b/drivers/gpu/drm/tegra/dbi.c
new file mode 100644
index 0000000000000..8929f0013462a
--- /dev/null
+++ b/drivers/gpu/drm/tegra/dbi.c
@@ -0,0 +1,592 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Nvidia Tegra20/30 MIPI-DBI Type B host driver
+ *
+ * Copyright (C) 2026 Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <linux/bitfield.h>
+#include <linux/cleanup.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/iopoll.h>
+#include <linux/kernel.h>
+#include <linux/media-bus-format.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/property.h>
+#include <linux/platform_device.h>
+#include <linux/string.h>
+
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_bridge.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_mipi_dbi.h>
+#include <drm/drm_mipi_dbi_bus.h>
+#include <drm/drm_of.h>
+
+#include <video/mipi_display.h>
+
+#include "dc.h"
+
+enum tegra_dbi_dc_signal {
+ TEGRA_DBI_COMMAND,
+ TEGRA_DBI_DATA
+};
+
+#define TEGRA_DBI_DATA_PINS_MAX 8
+#define TEGRA_DBI_DEFAULT_BUS_WIDTH 24
+
+static const u32 tegra_dbi_pin_regs[] = {
+ DC_COM_PIN_OUTPUT_ENABLE(0),
+ DC_COM_PIN_OUTPUT_ENABLE(1),
+ DC_COM_PIN_OUTPUT_ENABLE(2),
+ DC_COM_PIN_OUTPUT_ENABLE(3),
+ DC_COM_PIN_OUTPUT_POLARITY(0),
+ DC_COM_PIN_OUTPUT_POLARITY(1),
+ DC_COM_PIN_OUTPUT_POLARITY(2),
+ DC_COM_PIN_OUTPUT_POLARITY(3),
+ DC_COM_PIN_OUTPUT_DATA(0),
+ DC_COM_PIN_OUTPUT_DATA(1),
+ DC_COM_PIN_OUTPUT_DATA(2),
+ DC_COM_PIN_OUTPUT_DATA(3),
+ DC_COM_PIN_OUTPUT_SELECT(0),
+ DC_COM_PIN_OUTPUT_SELECT(1),
+ DC_COM_PIN_OUTPUT_SELECT(2),
+ DC_COM_PIN_OUTPUT_SELECT(3),
+ DC_COM_PIN_OUTPUT_SELECT(4),
+ DC_COM_PIN_OUTPUT_SELECT(5),
+ DC_COM_PIN_OUTPUT_SELECT(6),
+};
+
+struct tegra_dbi_priv {
+ struct device *dev;
+ struct tegra_dc *dc;
+
+ struct mipi_dbi dbi;
+ struct mipi_dbi_host dbi_host;
+
+ struct drm_bridge bridge;
+ struct drm_bridge *next_bridge;
+
+ const struct tegra_dbi_interface *interface;
+ u32 com_pin_backup[ARRAY_SIZE(tegra_dbi_pin_regs)];
+
+ u32 bus_width;
+ bool active;
+};
+
+struct tegra_dbi_pin {
+ u32 reg;
+ u32 pos;
+};
+
+struct tegra_dbi_interface {
+ struct tegra_dbi_pin dc;
+ struct tegra_dbi_pin rw;
+ struct tegra_dbi_pin cs;
+ struct tegra_dbi_pin data[TEGRA_DBI_DATA_PINS_MAX];
+ void (*init)(struct tegra_dbi_priv *priv);
+};
+
+static inline struct tegra_dbi_priv *mipi_dbi_to_tegra_dbi(struct mipi_dbi *dbi)
+{
+ return container_of(dbi, struct tegra_dbi_priv, dbi);
+}
+
+static inline struct tegra_dbi_priv *dbi_host_to_tegra_dbi(struct mipi_dbi_host *host)
+{
+ return container_of(host, struct tegra_dbi_priv, dbi_host);
+}
+
+static inline struct tegra_dbi_priv *bridge_to_tegra_dbi(struct drm_bridge *bridge)
+{
+ return container_of(bridge, struct tegra_dbi_priv, bridge);
+}
+
+static void tegra_dbi_pin_set(struct tegra_dc *dc, const struct tegra_dbi_pin *pin, bool value)
+{
+ u32 val = PIN_UNMASK(pin->pos);
+
+ if (value)
+ val |= BIT(pin->pos);
+
+ tegra_dc_writel(dc, val, pin->reg);
+}
+
+static void tegra_dbi_write(struct tegra_dbi_priv *priv,
+ enum tegra_dbi_dc_signal signal, u8 value)
+{
+ struct tegra_dc *dc = priv->dc;
+ const struct tegra_dbi_interface *interface = priv->interface;
+
+ tegra_dbi_pin_set(dc, &interface->dc, signal);
+
+ tegra_dbi_pin_set(dc, &interface->cs, 0);
+ tegra_dbi_pin_set(dc, &interface->rw, 0);
+
+ for (int i = 0; i < TEGRA_DBI_DATA_PINS_MAX; i++)
+ tegra_dbi_pin_set(dc, &interface->data[i], field_get(BIT(i), value));
+
+ tegra_dbi_pin_set(dc, &interface->cs, 1);
+ tegra_dbi_pin_set(dc, &interface->rw, 1);
+}
+
+static int tegra_dbi_dbi_command(struct mipi_dbi *dbi, u8 *cmd, u8 *param, size_t num)
+{
+ struct tegra_dbi_priv *priv = mipi_dbi_to_tegra_dbi(dbi);
+ u8 command = *cmd;
+
+ /* Blocks all commands when interface is not active */
+ if (!priv->active)
+ return -ENODEV;
+
+ tegra_dbi_write(priv, TEGRA_DBI_COMMAND, command);
+
+ for (int i = 0; i < num; i++)
+ tegra_dbi_write(priv, TEGRA_DBI_DATA, param[i]);
+
+ return 0;
+}
+
+static int tegra_dbi_host_attach(struct mipi_dbi_host *host, struct mipi_dbi_device *dbidev)
+{
+ struct tegra_dbi_priv *priv = dbi_host_to_tegra_dbi(host);
+ struct drm_bridge *bridge;
+ struct device_node *ep;
+
+ bridge = of_drm_get_bridge_by_endpoint(priv->bridge.of_node, 1, -1);
+ if (IS_ERR(bridge))
+ return PTR_ERR(bridge);
+
+ bridge->type = DRM_MODE_CONNECTOR_DPI;
+ priv->next_bridge = bridge;
+ priv->bus_width = TEGRA_DBI_DEFAULT_BUS_WIDTH;
+
+ /* get input ep (port0/endpoint0) */
+ ep = of_graph_get_endpoint_by_regs(priv->bridge.of_node, 0, 0);
+ if (ep) {
+ of_property_read_u32(ep, "bus-width", &priv->bus_width);
+ of_node_put(ep);
+ }
+
+ return 0;
+}
+
+static void tegra_dbi_host_detach(struct mipi_dbi_host *host, struct mipi_dbi_device *dbidev)
+{
+ struct tegra_dbi_priv *priv = dbi_host_to_tegra_dbi(host);
+
+ drm_bridge_clear_and_put(&priv->next_bridge);
+}
+
+static const struct mipi_dbi_host_ops tegra_dbi_host_ops = {
+ .attach = tegra_dbi_host_attach,
+ .detach = tegra_dbi_host_detach,
+};
+
+static void tegra_dbi_atomic_enable(struct drm_bridge *bridge,
+ struct drm_atomic_commit *state)
+{
+ struct tegra_dbi_priv *priv = bridge_to_tegra_dbi(bridge);
+ struct drm_bridge *next_bridge = priv->next_bridge;
+ struct tegra_dc *dc = priv->dc;
+ void __iomem *disp_cmd = dc->regs + (DC_CMD_DISPLAY_COMMAND << 2);
+ u32 value;
+ int ret;
+
+ value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
+ value &= ~DISP_CTRL_MODE_MASK;
+ tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
+
+ /* Disable all options except cursor if enabled */
+ value = tegra_dc_readl(dc, DC_DISP_DISP_WIN_OPTIONS);
+ value &= CURSOR_ENABLE;
+ tegra_dc_writel(dc, value, DC_DISP_DISP_WIN_OPTIONS);
+
+ tegra_dc_commit(dc);
+
+ /* Ensure the DC is fully idle before reconfiguring pins */
+ tegra_dc_writel(dc, READ_MUX, DC_CMD_STATE_ACCESS);
+
+ ret = readl_relaxed_poll_timeout(disp_cmd, value,
+ !(value & DISP_CTRL_MODE_MASK), 1000,
+ 100000);
+
+ tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);
+ if (ret) {
+ dev_err(priv->dev, "timeout waiting for DC to become idle\n");
+ return;
+ }
+
+ tegra_dc_writel(dc, V_PULSE1_ENABLE, DC_DISP_DISP_SIGNAL_OPTIONS0);
+ tegra_dc_writel(dc, PULSE_POLARITY_LOW, DC_DISP_V_PULSE1_CONTROL);
+
+ tegra_dc_writel(dc, PULSE_END(1), DC_DISP_V_PULSE1_POSITION_A);
+ tegra_dc_writel(dc, 0, DC_DISP_V_PULSE1_POSITION_B);
+ tegra_dc_writel(dc, 0, DC_DISP_V_PULSE1_POSITION_C);
+
+ value = 1 << FRAME_INIT_SEQ_CYCLES_SHIFT |
+ DC_SIGNAL_VPULSE1 << INIT_SEQ_DC_SIGNAL_SHIFT |
+ INIT_SEQUENCE_MODE_PLCD | SEND_INIT_SEQUENCE;
+ tegra_dc_writel(dc, value, DC_DISP_INIT_SEQ_CONTROL);
+
+ /* Init cycle 1: WRITE_MEMORY_START, set LCD_PCLK and COMMAND */
+ tegra_dc_writel(dc, MIPI_DCS_WRITE_MEMORY_START, DC_DISP_SPI_INIT_SEQ_DATA_A);
+ tegra_dc_writel(dc, 0x0, DC_DISP_SPI_INIT_SEQ_DATA_B);
+ tegra_dc_writel(dc, 0x0, DC_DISP_SPI_INIT_SEQ_DATA_C);
+ tegra_dc_writel(dc, BIT(12) | BIT(14), DC_DISP_SPI_INIT_SEQ_DATA_D);
+
+ /* Set LDC pin to V Pulse 1 */
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_SELECT(6));
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LDC);
+ value |= PIN_OUTPUT_SELECT_F4(PIN_OUTPUT_SELECT_LDC);
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(6));
+
+ value = SC1_H_QUALIFIER(SC_H_QUALIFIER_NONE) |
+ SC0_V_QUALIFIER(SC_V_QUALIFIER_VACTIVE) |
+ SC0_H_QUALIFIER(SC_H_QUALIFIER_HACTIVE);
+ tegra_dc_writel(dc, value, DC_DISP_SHIFT_CLOCK_OPTIONS);
+
+ value = tegra_dc_readl(dc, DC_DISP_DISP_COLOR_CONTROL);
+ value &= ~BASE_COLOR_SIZE_MASK;
+
+ switch (priv->bus_width) {
+ case 16:
+ value |= BASE_COLOR_SIZE_565;
+ break;
+ case 18:
+ value |= BASE_COLOR_SIZE_666;
+ break;
+ case 24:
+ value |= BASE_COLOR_SIZE_888;
+ break;
+ default:
+ WARN(1, "%u bus width not supported\n", priv->bus_width);
+ value |= BASE_COLOR_SIZE_888;
+ break;
+ }
+
+ tegra_dc_writel(dc, value, DC_DISP_DISP_COLOR_CONTROL);
+
+ /*
+ * Backup registers before unshadowing since actual register values
+ * may differ and their state backed up now is the correct one.
+ */
+ for (int i = 0; i < ARRAY_SIZE(tegra_dbi_pin_regs); i++)
+ priv->com_pin_backup[i] = tegra_dc_readl(dc, tegra_dbi_pin_regs[i]);
+
+ /* Unshadow to set up command and data pins */
+ tegra_dc_writel(dc, WRITE_MUX | READ_MUX, DC_CMD_STATE_ACCESS);
+
+ priv->interface->init(priv);
+ priv->active = true;
+
+ /*
+ * DBI requires that the next bridge be enabled here in order to
+ * send DCS commands, since the interface pins will subsequently be
+ * reconfigured for video data.
+ *
+ * Using the prepare_prev_first flag in the panel will not work,
+ * because the DBI bridge requires the panel to be enabled beforehand
+ * for proper configuration.
+ */
+ if (next_bridge->funcs && next_bridge->funcs->atomic_enable)
+ next_bridge->funcs->atomic_enable(next_bridge, state);
+
+ tegra_dbi_pin_set(dc, &priv->interface->cs, 0);
+
+ priv->active = false;
+
+ tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);
+
+ for (int i = 0; i < ARRAY_SIZE(tegra_dbi_pin_regs); i++)
+ tegra_dc_writel(dc, priv->com_pin_backup[i],
+ tegra_dbi_pin_regs[i]);
+
+ tegra_dc_commit(dc);
+
+ value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
+ value &= ~DISP_CTRL_MODE_MASK;
+ value |= DISP_CTRL_MODE_C_DISPLAY;
+ tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
+}
+
+static void tegra_dbi_atomic_disable(struct drm_bridge *bridge,
+ struct drm_atomic_commit *state)
+{
+ struct tegra_dbi_priv *priv = bridge_to_tegra_dbi(bridge);
+ struct drm_bridge *next_bridge = priv->next_bridge;
+ struct tegra_dc *dc = priv->dc;
+
+ for (int i = 0; i < ARRAY_SIZE(tegra_dbi_pin_regs); i++)
+ priv->com_pin_backup[i] = tegra_dc_readl(dc, tegra_dbi_pin_regs[i]);
+
+ tegra_dc_writel(dc, WRITE_MUX | READ_MUX, DC_CMD_STATE_ACCESS);
+
+ priv->interface->init(priv);
+ priv->active = true;
+
+ /*
+ * DBI requires that the next bridge be disabled here in order to
+ * send DCS commands, since the interface pins will subsequently be
+ * reconfigured for video data and tegra_rgb_encoder_disable() will
+ * be called before drm_panel_unprepare() runs in post_disable.
+ */
+ if (next_bridge->funcs && next_bridge->funcs->atomic_disable)
+ next_bridge->funcs->atomic_disable(next_bridge, state);
+
+ priv->active = false;
+
+ tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);
+
+ for (int i = 0; i < ARRAY_SIZE(tegra_dbi_pin_regs); i++)
+ tegra_dc_writel(dc, priv->com_pin_backup[i],
+ tegra_dbi_pin_regs[i]);
+
+ tegra_dc_commit(dc);
+}
+
+static int tegra_dbi_atomic_check(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state)
+{
+ struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
+
+ /* Set safe default bus flags if panel does not specify them */
+ if (!bridge_state->input_bus_cfg.flags)
+ bridge_state->input_bus_cfg.flags = bridge->timings->input_bus_flags;
+
+ /* Default to positive sync */
+ if (!(adjusted_mode->flags &
+ (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC)))
+ adjusted_mode->flags |= DRM_MODE_FLAG_PHSYNC;
+
+ if (!(adjusted_mode->flags &
+ (DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC)))
+ adjusted_mode->flags |= DRM_MODE_FLAG_PVSYNC;
+
+ return 0;
+}
+
+static int tegra_dbi_attach(struct drm_bridge *bridge,
+ struct drm_encoder *encoder,
+ enum drm_bridge_attach_flags flags)
+{
+ struct tegra_dbi_priv *priv = bridge_to_tegra_dbi(bridge);
+
+ if (!priv->next_bridge)
+ return -EPROBE_DEFER;
+
+ return drm_bridge_attach(bridge->encoder, priv->next_bridge, bridge,
+ flags);
+}
+
+static enum drm_mode_status tegra_dbi_mode_valid(struct drm_bridge *bridge,
+ const struct drm_display_info *info,
+ const struct drm_display_mode *mode)
+{
+ if (mode->hdisplay > 800)
+ return MODE_H_ILLEGAL;
+
+ if (mode->vdisplay > 800)
+ return MODE_V_ILLEGAL;
+
+ return MODE_OK;
+}
+
+static const struct drm_bridge_funcs tegra_dbi_funcs = {
+ .attach = tegra_dbi_attach,
+ .mode_valid = tegra_dbi_mode_valid,
+
+ .atomic_enable = tegra_dbi_atomic_enable,
+ .atomic_disable = tegra_dbi_atomic_disable,
+ .atomic_check = tegra_dbi_atomic_check,
+
+ .atomic_create_state = drm_atomic_helper_bridge_create_state,
+ .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+ .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+};
+
+static void tegra_dbi_init_primary_interface(struct tegra_dbi_priv *priv)
+{
+ struct tegra_dc *dc = priv->dc;
+ u32 value;
+
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_ENABLE(3));
+ value &= ~(BIT(PIN_LCSN) | BIT(PIN_LDC));
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_ENABLE(3));
+
+ /* Set LSC0/LCSN/LDC output polarity HIGH */
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_POLARITY(1));
+ value &= ~BIT(PIN_LSC0);
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_POLARITY(1));
+
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_POLARITY(3));
+ value &= ~(BIT(PIN_LCSN) | BIT(PIN_LDC));
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_POLARITY(3));
+
+ value = PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LD0) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LD1) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LD2) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LD3) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LD4) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LD5) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LD6) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LD7);
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(0));
+
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_SELECT(3));
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LSC0);
+ value |= PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LSC0);
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(3));
+
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_SELECT(6));
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LCSN);
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LDC);
+ value |= PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LCSN) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LDC);
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(6));
+}
+
+static void tegra_dbi_init_secondary_interface(struct tegra_dbi_priv *priv)
+{
+ struct tegra_dc *dc = priv->dc;
+ u32 value;
+
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_ENABLE(2));
+ value &= ~(BIT(PIN_LDI) | BIT(PIN_LPP));
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_ENABLE(2));
+
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_SELECT(3));
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LPW0);
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LPW2);
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LSC1);
+ value |= PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LPW0) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LPW2) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LSC1);
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(3));
+
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_SELECT(4));
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LHP0);
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LHP1);
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LVP0);
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LVP1);
+ value |= PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LHP0) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LHP1) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LVP0) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LVP1);
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(4));
+
+ value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_SELECT(5));
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LM0);
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LM1);
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LDI);
+ value &= ~PIN_OUTPUT_SELECT_MASK(PIN_OUTPUT_SELECT_LPP);
+ value |= PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LM0) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LM1) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LDI) |
+ PIN_OUTPUT_SELECT_OUT(PIN_OUTPUT_SELECT_LPP);
+ tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(5));
+}
+
+static const struct tegra_dbi_interface tegra_dbi_idx[] = {
+ /* Nvidia Primary 8-bit CPU interface configuration */
+ {
+ .dc = { DC_COM_PIN_OUTPUT_DATA(3), PIN_LDC },
+ .rw = { DC_COM_PIN_OUTPUT_DATA(1), PIN_LSC0 },
+ .cs = { DC_COM_PIN_OUTPUT_DATA(3), PIN_LCSN },
+ .data = {
+ { DC_COM_PIN_OUTPUT_DATA(0), PIN_LD0 },
+ { DC_COM_PIN_OUTPUT_DATA(0), PIN_LD1 },
+ { DC_COM_PIN_OUTPUT_DATA(0), PIN_LD2 },
+ { DC_COM_PIN_OUTPUT_DATA(0), PIN_LD3 },
+ { DC_COM_PIN_OUTPUT_DATA(0), PIN_LD4 },
+ { DC_COM_PIN_OUTPUT_DATA(0), PIN_LD5 },
+ { DC_COM_PIN_OUTPUT_DATA(0), PIN_LD6 },
+ { DC_COM_PIN_OUTPUT_DATA(0), PIN_LD7 },
+ },
+ .init = tegra_dbi_init_primary_interface,
+ },
+ /* Nvidia Secondary 8-bit CPU interface configuration */
+ {
+ .dc = { DC_COM_PIN_OUTPUT_DATA(2), PIN_LVP0 },
+ .rw = { DC_COM_PIN_OUTPUT_DATA(1), PIN_LSC1 },
+ .cs = { DC_COM_PIN_OUTPUT_DATA(2), PIN_LM0 },
+ .data = {
+ { DC_COM_PIN_OUTPUT_DATA(2), PIN_LHP1 },
+ { DC_COM_PIN_OUTPUT_DATA(2), PIN_LM1 },
+ { DC_COM_PIN_OUTPUT_DATA(2), PIN_LDI },
+ { DC_COM_PIN_OUTPUT_DATA(2), PIN_LPP },
+ { DC_COM_PIN_OUTPUT_DATA(1), PIN_LPW0 },
+ { DC_COM_PIN_OUTPUT_DATA(1), PIN_LPW2 },
+ { DC_COM_PIN_OUTPUT_DATA(2), PIN_LVP1 },
+ { DC_COM_PIN_OUTPUT_DATA(2), PIN_LHP0 },
+ },
+ .init = tegra_dbi_init_secondary_interface,
+ },
+};
+
+static const struct drm_bridge_timings default_tegra_dbi_timings = {
+ .input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE |
+ DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE |
+ DRM_BUS_FLAG_DE_HIGH,
+};
+
+int tegra_dc_dbi_probe(struct tegra_dc *dc)
+{
+ struct device *dev = dc->dev;
+ struct device_node *dbi_np __free(device_node) =
+ of_get_available_child_by_name(dev_of_node(dev), "dbi");
+ struct mipi_dbi_device *dbidev;
+ struct tegra_dbi_priv *priv;
+ struct device_node *np;
+ u32 interface = 0;
+ int ret;
+
+ /* Missing node means that DBI is not used, continue DC probe */
+ if (!dbi_np)
+ return 0;
+
+ of_property_read_u32(dbi_np, "nvidia,interface", &interface);
+ if (interface != 0 && interface != 1)
+ return dev_err_probe(dev, -EINVAL, "Wrong interface value: %d\n", interface);
+
+ priv = devm_drm_bridge_alloc(dev, struct tegra_dbi_priv, bridge,
+ &tegra_dbi_funcs);
+ if (IS_ERR(priv))
+ return PTR_ERR(priv);
+
+ priv->dc = dc;
+ priv->dev = dev;
+ priv->interface = &tegra_dbi_idx[interface];
+
+ /* Initialize MIPI DBI interface */
+ mutex_init(&priv->dbi.cmdlock);
+ priv->dbi.command = tegra_dbi_dbi_command;
+
+ priv->dbi_host.dev = dev;
+ priv->dbi_host.dbi = &priv->dbi;
+ priv->dbi_host.ops = &tegra_dbi_host_ops;
+
+ priv->bridge.of_node = dbi_np;
+ priv->bridge.timings = &default_tegra_dbi_timings;
+
+ ret = devm_drm_bridge_add(dev, &priv->bridge);
+ if (ret)
+ return ret;
+
+ np = of_graph_get_remote_node(dbi_np, 1, -1);
+ if (!np)
+ return -EINVAL;
+
+ dbidev = devm_mipi_dbi_device_register(dev, &priv->dbi_host, np);
+ of_node_put(np);
+ if (IS_ERR(dbidev))
+ return dev_err_probe(dev, PTR_ERR(dbidev),
+ "Failed to register DBI device\n");
+
+ return 0;
+}
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index c9df14544ced0..b491aa00bd101 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -3381,6 +3381,10 @@ static int tegra_dc_probe(struct platform_device *pdev)
}
}
+ err = tegra_dc_dbi_probe(dc);
+ if (err)
+ return dev_err_probe(&pdev->dev, err, "failed to probe DBI\n");
+
err = tegra_dc_rgb_probe(dc);
if (err < 0 && err != -ENODEV)
return dev_err_probe(&pdev->dev, err,
diff --git a/drivers/gpu/drm/tegra/dc.h b/drivers/gpu/drm/tegra/dc.h
index e8913c5530a2d..2847affa2532f 100644
--- a/drivers/gpu/drm/tegra/dc.h
+++ b/drivers/gpu/drm/tegra/dc.h
@@ -177,6 +177,9 @@ void tegra_dc_rgb_remove(struct tegra_dc *dc);
int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc);
int tegra_dc_rgb_exit(struct tegra_dc *dc);
+/* from dbi.c */
+int tegra_dc_dbi_probe(struct tegra_dc *dc);
+
#define DC_CMD_GENERAL_INCR_SYNCPT 0x000
#define DC_CMD_GENERAL_INCR_SYNCPT_CNTRL 0x001
#define SYNCPT_CNTRL_NO_STALL (1 << 8)
--
2.53.0
^ permalink raw reply related [flat|nested] 33+ messages in thread