dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9 00/13] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface
@ 2026-11-30 11:41 Svyatoslav Ryhel
  2026-11-30 11:41 ` [PATCH v9 01/13] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-30 11:41 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'.

Add MIPI DBI bus support along with 2 DBI Type B panels used in
LG Optimus 2X which work with the 8-bit CPU interface.

Convert rgb, dsi, hdmi and sor to use atomic versions of
drm_encoder_helper_funcs needed for bridge state requesting.
Refactor and expand DC header. Add DC parametrization options
needed for fine tuning by bridges. Make panel parsing by
tegra_output_probe() optional and document optional DSI port. 
Add 8-bit CPU interface in form of a bridge linking to RGB port.

---
Changes in v2:
- convert enums in the dc header into definitions list
- add check in RGB if bridge_state is not NULL, if yes, use default flags
- inverted FLAG_PIXDATA_SAMPLE flag setup logic since default value is set to
  be on NEGEDGE while v1 set default to be on POSEDGE
- 8bit-cpu schema renamed to dbi, removed compaible and set as DC child
- expanded list of required properties
- 8bit-cpu bridge remodelled into dbi interface as DC child
- improve gpio handling
- rework attach to get drvdata from parent
- add panel supplies description
- split panel driver into per-panel drivers
- get DBI interface from the patent directly

I have deliberately left GPIO parsing from device tree since it seems to
be the most convenient and mainstream method of working with GPIOs.

Changes in v3:
- rgb: fix default bus_flags to match original behavior
- dbi-schema: remove compatible from required props
  remove dc@54200000 wrapper from example
  restrict dbi nodes for tegra20/tegra30 only
- dbi: remove unused idx from tegra_dbi_priv
  wrap dbi registration in dc with devm_add_action_or_reset()
  separate dbi into separate object
  export tegra_dc_commit() and trace_dc_readl()/dc_readl()

Changes in v4:
- reorder patches to avoid errors on checking dbi schema
- dbi schema renamed to nvidia,tegra20-dbi for consistency
- fix DC_DISP_V_PULSE0_POSITION_* > DC_DISP_V_PULSE1_POSITION_*
- add MODULE_ALIAS
- swap width and height in panels
- dropped use of init-sequence and gpios
- dbi driver reworked to use only DC to operate pins

Changes in v5:
- added commit modelling DBI bus (suggested by Mikko Perttunen)
- hitachi and lg panels converted to mipi_dbi_driver
- dc header refactored and completed
- added commit documenting DSI controller port
- added commit which converts drm_encoder_helper_funcs to use atomic
  enable/disable
- added commit which makes panel parsing in tegra_output_probe() optional
- dbi command/data converted to enum
- dc com pins are now backed up into drivers private structure
- magic numbers replaced with pin defines
- dropped tegra_dc_readl() from tegra_dbi_pin_set
- tegra_dbi_pin_set() accepts boolean third argument
- tegra_dbi_write() second argument converted to use tegra_dbi_dc_signal enum
- used field_get() to extract pin value
- extended comment regarding init sequence
- nvidia,index > generic reg property
- adjusted tegra_dbi_atomic_enable() to properly handle shadowed registers
- switched to use of_drm_get_bridge_by_endpoint() since panels are auto-wrapped
  into bridge now
- added support for mipi_dbi_host_ops
- added resource managed helper to register DBI device and provided to DC via
  header
- dbi.o built with all other tegra drm files

Changes in v6:
- improved descriptions of new framework
- mipi dbi bus commit authorship was changed with Mikko's permission
- panel commits swapped with mipi dbi panel conversion commits
- fixed tegra_output_probe() for hdmi
- added CONFIG_DRM_MIPI_DBI select into CONFIG_DRM_TEGRA
- devm_drm_bridge_add() moved into bridge probe to avoid possible issues with
  deferred panel probing
- setting LDC pin to V Pulse 1 moved before GPIO pin reconfiguration
- DC_CMD_STATE_ACCESS is set to read and write in tegra_dbi_atomic_disable()
- platform_driver_register() does not error out if driver is registered

Changes in v7:
- reduce changes in the panels when converting to mipi dbi
- dropped of_node_get() in devm_mipi_dbi_device_register
- remove enable()/disable() operations and add prep prev bridge flag
- drop add DC header changes, add only strictly needed by the dbi
- dropped tegra_dbi_iface and reg_entry enums
- dropped reg from struct tegra_dbi_priv, com_pin_backup converted to u32
- interface dropped from struct tegra_dbi_interface and init call added
- BIT macro converted to PIN_UNMASK in the tegra_dbi_pin_set()
- init functions and tegra_dbi_interface structure moved before probe
- tegra_dbi_atomic_enable() split into pre_enable() and enable() phases
  to squeeze interface into existing framework
- DC_CMD_STATE_ACCESS and setting active true moved into init functions
- reg reading moved before bridge allocation
- reg renamed to nvidia,interface

Changes in v8:
- return of_node_get() in devm_mipi_dbi_device_register
- add mipi_dbi_write_buffer_multi() and mipi_dbi_write_seq_multi()
- remove return doc from void function
- replace disable() removal in panel with mipi_dbi_write_seq_multi() conversion
- removed of_node_get() in tegra_dc_dbi_probe() for dbi node
- switch to drm_bridge_clear_and_put() in tegra_dbi_host_detach()
- add check if DC is idle before reconfiguring pins
- restored original tegra_dbi_atomic_disable() operation from v5

Changes in v9:
- store dbi node pointed in the driver's private structure
- add tegra_dbi_stop_dc() helper
- clarify "Set LDC pin to V Pulse 1" comment
- add check for next_bridge != NULL in enable and disable 
- add probe, remove and shutdown directly into mipi_dbi_device_pm_ops
- removed match and uevent wrappers
- fixed function documentation
- switched to imroved PIN macros (suggested by Mikko Perttunen)
- switched encoder->crtc into conn_state->crtc
- switched struct tegra_dbi_pin to plain u32
- added unified tegra_dbi_init_interface()
- added and documented nvidia,contiguous-rgb-pins property
---

Svyatoslav Ryhel (13):
  drm: Add MIPI DBI bus support for MIPI DBI Type A and B
  drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus
  drm/panel: panel-hitachi-tx10d07vm0baa: Convert to
    mipi_dbi_write_seq_multi()
  drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus
  drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi()
  drm/tegra: dc: Add elements required by Tegra MIPI DBI
  dt-bindings: display: tegra: Document Tegra20 DSI port
  drm/tegra: output: Make panel parsing configurable
  drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs
  dt-bindings: display: tegra: Document nvidia,contiguous-rgb-pins
    property
  drm/tegra: rgb: Parameterize configuration based on bus flags and DT
    property
  dt-bindings: display: tegra: Document 8-bit CPU parallel interface
  drm/tegra: Add support for 8-bit CPU interface

 .../display/tegra/nvidia,tegra20-dbi.yaml     | 108 ++++
 .../display/tegra/nvidia,tegra20-dc.yaml      |  27 +
 .../display/tegra/nvidia,tegra20-dsi.yaml     |   6 +
 drivers/gpu/drm/Makefile                      |   2 +-
 drivers/gpu/drm/drm_mipi_dbi_bus.c            | 265 +++++++++
 .../drm/panel/panel-hitachi-tx10d07vm0baa.c   | 241 ++++----
 drivers/gpu/drm/panel/panel-lg-lh400wv3.c     | 121 ++--
 drivers/gpu/drm/tegra/Kconfig                 |   1 +
 drivers/gpu/drm/tegra/Makefile                |   1 +
 drivers/gpu/drm/tegra/dbi.c                   | 561 ++++++++++++++++++
 drivers/gpu/drm/tegra/dc.c                    |   4 +
 drivers/gpu/drm/tegra/dc.h                    | 129 +++-
 drivers/gpu/drm/tegra/drm.h                   |   2 +-
 drivers/gpu/drm/tegra/dsi.c                   |  57 +-
 drivers/gpu/drm/tegra/hdmi.c                  |  33 +-
 drivers/gpu/drm/tegra/output.c                |  52 +-
 drivers/gpu/drm/tegra/rgb.c                   |  68 ++-
 drivers/gpu/drm/tegra/sor.c                   |  64 +-
 include/drm/drm_mipi_dbi_bus.h                | 148 +++++
 19 files changed, 1604 insertions(+), 286 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dbi.yaml
 create mode 100644 drivers/gpu/drm/drm_mipi_dbi_bus.c
 create mode 100644 drivers/gpu/drm/tegra/dbi.c
 create mode 100644 include/drm/drm_mipi_dbi_bus.h

-- 
2.53.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v9 01/13] drm: Add MIPI DBI bus support for MIPI DBI Type A and B
  2026-11-30 11:41 [PATCH v9 00/13] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
@ 2026-11-30 11:41 ` Svyatoslav Ryhel
  2026-11-30 11:55   ` sashiko-bot
  2026-11-30 11:41 ` [PATCH v9 03/13] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 12+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-30 11:41 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 | 265 +++++++++++++++++++++++++++++
 include/drm/drm_mipi_dbi_bus.h     | 148 ++++++++++++++++
 3 files changed, 414 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..0c9b93d72021b
--- /dev/null
+++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c
@@ -0,0 +1,265 @@
+// 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_bus_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);
+
+	if (!drv->probe)
+		return 0;
+
+	return drv->probe(dbidev);
+}
+
+static void mipi_dbi_bus_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);
+
+	if (drv->remove)
+		drv->remove(dbidev);
+}
+
+static void mipi_dbi_bus_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);
+
+	if (drv->shutdown)
+		drv->shutdown(dbidev);
+}
+
+static const struct bus_type mipi_dbi_bus_type = {
+	.name = "mipi-dbi",
+	.match = of_driver_match_device,
+	.uevent = of_device_uevent_modalias,
+	.probe = mipi_dbi_bus_probe,
+	.remove = mipi_dbi_bus_remove,
+	.shutdown = mipi_dbi_bus_shutdown,
+};
+
+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, 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
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+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;
+	int 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);
+
+/**
+ * __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;
+
+	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..559793a31c0a1
--- /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 DCS 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_H__ */
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v9 03/13] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi()
  2026-11-30 11:41 [PATCH v9 00/13] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
  2026-11-30 11:41 ` [PATCH v9 01/13] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
@ 2026-11-30 11:41 ` Svyatoslav Ryhel
  2026-11-30 11:41 ` [PATCH v9 04/13] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus Svyatoslav Ryhel
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-30 11:41 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.

Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
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 8c17132728807..37bbd93edd8d0 100644
--- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
+++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
@@ -34,19 +34,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);
@@ -73,118 +60,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] 12+ messages in thread

* [PATCH v9 04/13] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus
  2026-11-30 11:41 [PATCH v9 00/13] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
  2026-11-30 11:41 ` [PATCH v9 01/13] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
  2026-11-30 11:41 ` [PATCH v9 03/13] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
@ 2026-11-30 11:41 ` Svyatoslav Ryhel
  2026-11-30 11:41 ` [PATCH v9 05/13] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-30 11:41 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 | 34 ++++++++++-------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
index 557bcb6f2ca70..6fe9654a7c3e8 100644
--- a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
+++ b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
@@ -6,16 +6,14 @@
 #include <linux/gpio/consumer.h>
 #include <linux/media-bus-format.h>
 #include <linux/module.h>
-#include <linux/of_platform.h>
-#include <linux/platform_device.h>
-#include <linux/property.h>
+#include <linux/of.h>
 #include <linux/regulator/consumer.h>
 
 #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>
 #include <drm/drm_probe_helper.h>
 
@@ -25,7 +23,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 +38,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 +53,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);
@@ -73,7 +68,7 @@ static int lg_lh400wv3_prepare(struct drm_panel *panel)
 	usleep_range(10000, 11000);
 
 	return 0;
-};
+}
 
 static int lg_lh400wv3_enable(struct drm_panel *panel)
 {
@@ -129,7 +124,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 +177,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 +198,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 +209,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 +218,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] 12+ messages in thread

* [PATCH v9 05/13] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi()
  2026-11-30 11:41 [PATCH v9 00/13] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
                   ` (2 preceding siblings ...)
  2026-11-30 11:41 ` [PATCH v9 04/13] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus Svyatoslav Ryhel
@ 2026-11-30 11:41 ` Svyatoslav Ryhel
  2026-11-30 11:41 ` [PATCH v9 06/13] drm/tegra: dc: Add elements required by Tegra MIPI DBI Svyatoslav Ryhel
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-30 11:41 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.

Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
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 6fe9654a7c3e8..f2dad3a6a2b7e 100644
--- a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
+++ b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
@@ -34,19 +34,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);
@@ -73,57 +60,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] 12+ messages in thread

* [PATCH v9 06/13] drm/tegra: dc: Add elements required by Tegra MIPI DBI
  2026-11-30 11:41 [PATCH v9 00/13] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
                   ` (3 preceding siblings ...)
  2026-11-30 11:41 ` [PATCH v9 05/13] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
@ 2026-11-30 11:41 ` Svyatoslav Ryhel
  2026-11-30 11:41 ` [PATCH v9 10/13] dt-bindings: display: tegra: Document nvidia, contiguous-rgb-pins property Svyatoslav Ryhel
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-30 11:41 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). Perform some cleanups and
alignments within the scope of this change.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/gpu/drm/tegra/dc.h | 126 +++++++++++++++++++++++++++++++++----
 1 file changed, 115 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.h b/drivers/gpu/drm/tegra/dc.h
index 0cb0515968b35..9ff57969dd59b 100644
--- a/drivers/gpu/drm/tegra/dc.h
+++ b/drivers/gpu/drm/tegra/dc.h
@@ -272,14 +272,82 @@ 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))
+#define DC_COM_PIN_INPUT_ENABLE(x)		(0x30e + (x))
+#define PIN_REGISTER_INDEX(pin)			((pin) / 16)
+#define PIN_SHIFT(pin)				(((pin) % 16) * 2)
+#define PIN_POS(pin)				BIT(PIN_SHIFT(pin))
+/* Pin unmask is 1 bit above position of the pin in the OUTPUT_DATA register */
+#define PIN_POS_UNMASK(pin)			BIT(PIN_SHIFT(pin) + 1)
+
+#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))
+
+#define PIN_SELECT_REGISTER_INDEX(pin)		((pin) / 8)
+#define PIN_SELECT_SHIFT(pin)			(((pin) % 8) * 4)
+
+#define PIN_LD0					0
+#define PIN_LD1					1
+#define PIN_LD2					2
+#define PIN_LD3					3
+#define PIN_LD4					4
+#define PIN_LD5					5
+#define PIN_LD6					6
+#define PIN_LD7					7
+#define PIN_LD8					8
+#define PIN_LD9					9
+#define PIN_LD10				10
+#define PIN_LD11				11
+#define PIN_LD12				12
+#define PIN_LD13				13
+#define PIN_LD14				14
+#define PIN_LD15				15
+#define PIN_LD16				16
+#define PIN_LD17				17
+#define PIN_LPW0				24
+#define PIN_LPW1				25
+#define PIN_LPW2				26
+#define PIN_LSC0				28
+#define PIN_LSC1				29
+#define PIN_LVS					30
+#define PIN_LHS					31
+#define PIN_LHP0				32
+#define PIN_LHP1				33
+#define PIN_LHP2				34
+#define PIN_LVP0				36
+#define PIN_LVP1				37
+#define PIN_LM0					40
+#define PIN_LM1					41
+#define PIN_LDI					42
+#define PIN_LPP					43
+#define PIN_LSCK				48
+#define PIN_LSDA				49
+#define PIN_LCSN				50
+#define PIN_LDC					51
+#define PIN_LSPI				52
+#define PIN_LSDI				53
 
 #define DC_COM_PIN_MISC_CONTROL			0x31b
 #define DC_COM_PIN_PM0_CONTROL			0x31c
@@ -303,9 +371,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 +530,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 +583,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] 12+ messages in thread

* [PATCH v9 10/13] dt-bindings: display: tegra: Document nvidia, contiguous-rgb-pins property
  2026-11-30 11:41 [PATCH v9 00/13] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
                   ` (4 preceding siblings ...)
  2026-11-30 11:41 ` [PATCH v9 06/13] drm/tegra: dc: Add elements required by Tegra MIPI DBI Svyatoslav Ryhel
@ 2026-11-30 11:41 ` Svyatoslav Ryhel
       [not found] ` <20261130114155.72920-10-clamor95@gmail.com>
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-30 11:41 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 nvidia,contiguous-rgb-pins, which describes the type of panel
wiring used for RGB.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 .../bindings/display/tegra/nvidia,tegra20-dc.yaml    | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml
index 69be95afd5627..4d14fae3d606a 100644
--- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml
+++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml
@@ -127,6 +127,18 @@ allOf:
               $ref: /schemas/types.yaml#/definitions/phandle
               description: phandle of a display panel
 
+            nvidia,contiguous-rgb-pins:
+              type: boolean
+              description: |
+                Type of panel wiring used on the board.
+
+                Default is MSB, which corresponds to:
+                LD[23:0] = {R[1:0], G[1:0], B[1:0],
+                            R[7:2], G[7:2], B[7:2]}
+
+                If the property is set, corresponds to LSB:
+                LD[23:0] = {R[7:0], G[7:0], B[7:0]}
+
   - if:
       properties:
         compatible:
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v9 09/13] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs
       [not found] ` <20261130114155.72920-10-clamor95@gmail.com>
@ 2026-11-30 11:53   ` sashiko-bot
  0 siblings, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-11-30 11:53 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: dri-devel, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/tegra: NULL dereference from new state lookup in
  atomic_disable()
- [Low] drm/tegra: redundant tegra_dsi_get_state() in
  tegra_dsi_encoder_enable()
--

commit 74ebbfecbca273aa0938d93154bb9f25f3ba63aa
Author: Svyatoslav Ryhel <clamor95@gmail.com>

drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs

This commit converts the Tegra DSI, HDMI, RGB, and SOR encoder helpers from
the legacy enable() and disable() callbacks to atomic_enable() and
atomic_disable().

> diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
> index 6d6adc485e51e..dd3fc09f57487 100644
> --- a/drivers/gpu/drm/tegra/dsi.c
> +++ b/drivers/gpu/drm/tegra/dsi.c

[ ... ]

> @@ -855,14 +863,21 @@ 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);
>  	struct tegra_dsi *dsi = to_dsi(output);
> +	struct drm_connector_state *conn_state;
> +	struct drm_connector *connector;
> +	struct tegra_dc *dc;
>  	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);
> +	dc = to_tegra_dc(conn_state->crtc);

[Severity: High]
Does looking up the new connector state in atomic_disable() cause a NULL
pointer dereference when disabling an output?

When an output is disabled, update_connector_routing() clears
new_conn_state->best_encoder to NULL before the commit phase runs
atomic_disable().  drm_atomic_get_new_connector_for_encoder() then returns
NULL, and drm_atomic_get_new_connector_state() dereferences connector->index.
Even if the connector were being moved to another CRTC, the new state would
point to the new CRTC rather than the old CRTC that was driving this encoder.

The same regression is present in tegra_hdmi_encoder_disable(),
tegra_sor_hdmi_disable(), and tegra_sor_dp_disable().  These disable
callbacks should query the old state via
drm_atomic_get_old_connector_for_encoder() and
drm_atomic_get_old_connector_state() (or drm_atomic_get_old_crtc_for_encoder()).

> @@ -919,16 +934,26 @@ 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 tegra_dsi *dsi = to_dsi(output);
> +	struct drm_connector_state *conn_state;
> +	struct drm_crtc_state *crtc_state;
> +	struct drm_connector *connector;
>  	struct tegra_dsi_state *state;
> +	struct drm_display_mode *mode;
> +	struct tegra_dc *dc;
>  	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);
> +	dc = to_tegra_dc(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);
> @@ -944,7 +969,7 @@ static void tegra_dsi_encoder_enable(struct drm_encoder *encoder)
>  	if (value & DSI_POWER_CONTROL_ENABLE)
>  		tegra_dsi_disable(dsi);
>  
> -	state = tegra_dsi_get_state(dsi);
> +	state = tegra_dsi_get_state(dsi, comm_state);
>  
>  	tegra_dsi_set_timeout(dsi, state->bclk, state->vrefresh);
>  
> @@ -957,7 +982,7 @@ static void tegra_dsi_encoder_enable(struct drm_encoder *encoder)
>  	if (output->panel)
>  		drm_panel_prepare(output->panel);
>  
> -	tegra_dsi_configure(dsi, dc->pipe, mode);
> +	tegra_dsi_configure(dsi, dc->pipe, mode, comm_state);

[Severity: Low]
As reported by Mikko Perttunen on v8 [1], since tegra_dsi_encoder_enable()
already retrieves conn_state via drm_atomic_get_new_connector_state(), can it
use to_dsi_state(conn_state) directly and pass struct tegra_dsi_state * into
tegra_dsi_configure() so tegra_dsi_get_state() can be dropped?

[1] https://lore.kernel.org/r/mxfdX1kqQz209wWYqFOofg@nvidia.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130114155.72920-1-clamor95@gmail.com?part=9

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v9 01/13] drm: Add MIPI DBI bus support for MIPI DBI Type A and B
  2026-11-30 11:41 ` [PATCH v9 01/13] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
@ 2026-11-30 11:55   ` sashiko-bot
  0 siblings, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-11-30 11:55 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: dri-devel, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm: NULL pointer dereference in mipi_dbi_bus_shutdown() on
  unbound device
--

commit a575546c0815e7093e5a3e166f417f51579ae7fa
Author: Svyatoslav Ryhel <clamor95@gmail.com>

drm: Add MIPI DBI bus support for MIPI DBI Type A and B

This commit adds a Linux driver model bus and helpers for MIPI DBI Type A
and Type B hosts and peripherals.

> 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..0c9b93d72021b
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> @@ -0,0 +1,265 @@

[ ... ]

> +static void mipi_dbi_bus_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);
> +
> +	if (drv->shutdown)
> +		drv->shutdown(dbidev);
> +}
> +
> +static const struct bus_type mipi_dbi_bus_type = {
> +	.name = "mipi-dbi",
> +	.match = of_driver_match_device,
> +	.uevent = of_device_uevent_modalias,
> +	.probe = mipi_dbi_bus_probe,
> +	.remove = mipi_dbi_bus_remove,
> +	.shutdown = mipi_dbi_bus_shutdown,
> +};

[Severity: High]
Can mipi_dbi_bus_shutdown() cause a NULL pointer dereference when a
registered mipi_dbi_device has no bound driver?

device_shutdown() invokes dev->bus->shutdown(dev) unconditionally without
checking whether dev->driver is set:

drivers/base/core.c:device_shutdown() {
    ...
		if (dev->bus && dev->bus->shutdown) {
			if (initcall_debug)
				dev_info(dev, "shutdown\n");
			dev->bus->shutdown(dev);
		} else if (dev->driver && dev->driver->shutdown) {
    ...
}

Because driver is the first member of struct mipi_dbi_driver,
to_mipi_dbi_driver(NULL) evaluates to NULL and checking drv->shutdown
dereferences NULL during system shutdown if a peripheral driver was not
loaded, deferred probing, or was unbound.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130114155.72920-1-clamor95@gmail.com?part=1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v9 11/13] drm/tegra: rgb: Parameterize configuration based on bus flags and DT property
       [not found] ` <20261130114155.72920-12-clamor95@gmail.com>
@ 2026-11-30 11:59   ` sashiko-bot
  0 siblings, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-11-30 11:59 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: dri-devel, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/tegra: rgb: inverted default pclk polarity in
  tegra_rgb_encoder_enable()
--

commit 4442e43504544159a06f87b67bae36bb5b0f8fcf
Author: Svyatoslav Ryhel <clamor95@gmail.com>

drm/tegra: rgb: Parameterize configuration based on bus flags and DT property

This commit configures Tegra RGB pixel clock and display enable signal
polarities from the bridge input bus flags and adds support for the
"nvidia,contiguous-rgb-pins" device tree property.

> diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> index d48d498068ac8..c311f4e2c44bb 100644
> --- a/drivers/gpu/drm/tegra/rgb.c
> +++ b/drivers/gpu/drm/tegra/rgb.c
[ ... ]
> @@ -106,6 +109,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 +121,20 @@ 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_POSEDGE |
> +			    DRM_BUS_FLAG_DE_HIGH;
> +
>  	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 +147,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 |= PIN_POS(PIN_LSC0);
> +	else
> +		value &= ~PIN_POS(PIN_LSC0);

[Severity: High]
As reported by Mikko Perttunen on v8 [1], does this invert the default
pixel clock polarity when bridge_state is present but neither
DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE nor
DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE is set in
bridge_state->input_bus_cfg.flags?

rgb_enable[] initializes DC_COM_PIN_OUTPUT_POLARITY(1) with
PIN_POS(PIN_LSC0) (0x01000000) set.  Because panel_bridge and bridge
drivers such as lvds-codec allocate atomic bridge state, bridge_state is
non-NULL, while existing Tegra panels (such as auo_b101aw03 in
panel-simple.c) only set DRM_BUS_FLAG_DE_HIGH and omit pixel clock
sampling flags.  Taking the else branch clears PIN_POS(PIN_LSC0) and
flips the pixel clock sampling edge on existing Tegra20 and Tegra30
boards.

Testing for DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE to clear
PIN_POS(PIN_LSC0) and setting PIN_POS(PIN_LSC0) otherwise would preserve
positive-edge sampling as the default when no pixel clock sampling flag is
specified.

[1] https://lore.kernel.org/r/TYDAsh0fQ52x0yM4_wAp5A@nvidia.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130114155.72920-1-clamor95@gmail.com?part=11

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v9 13/13] drm/tegra: Add support for 8-bit CPU interface
       [not found] ` <20261130114155.72920-14-clamor95@gmail.com>
@ 2026-11-30 12:11   ` sashiko-bot
  0 siblings, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-11-30 12:11 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: dri-devel, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/tegra: duplicate and out-of-order next_bridge
  enable/disable calls
- [Medium] drm/tegra: unconditional PIN_LDC muxing in
  tegra_dbi_atomic_enable()
--

commit 38f73e44f1c5bf7df4c07a00d683e9382cb4da10
Author: Svyatoslav Ryhel <clamor95@gmail.com>

drm/tegra: Add support for 8-bit CPU interface

This commit adds a DRM bridge and MIPI DBI host driver for the Tegra20/30
display controller's 8-bit CPU interface to transfer MIPI DCS commands
before switching the pins to RGB scanout.

> diff --git a/drivers/gpu/drm/tegra/dbi.c b/drivers/gpu/drm/tegra/dbi.c
> new file mode 100644
> index 0000000000000..a33e2c1147122
> --- /dev/null
> +++ b/drivers/gpu/drm/tegra/dbi.c

[ ... ]

> +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;
> +	u32 value, reg_idx;
> +	int ret;

[ ... ]

> +	/*
> +	 * Set the LDC pin to V Pulse 1. The secondary interface may require
> +	 * LVP0 to be set to function 6 (V Pulse 1), but this is not confirmed.
> +	 * TODO: parameterize this if needed.
> +	 */
> +	reg_idx = PIN_SELECT_REGISTER_INDEX(PIN_LDC);
> +	value = tegra_dc_readl(dc, DC_COM_PIN_OUTPUT_SELECT(reg_idx));
> +	value &= ~PIN_OUTPUT_SELECT_MASK(PIN_SELECT_SHIFT(PIN_LDC));
> +	value |= PIN_OUTPUT_SELECT_F4(PIN_SELECT_SHIFT(PIN_LDC));
> +	tegra_dc_writel(dc, value, DC_COM_PIN_OUTPUT_SELECT(reg_idx));

[Severity: Medium]
Does this break per-frame D/C signaling when the secondary interface
(nvidia,interface = <1>) is selected?

tegra_dc_dbi_probe() accepts both interface 0 (where dc_pin is PIN_LDC)
and interface 1 (where dc_pin is PIN_LVP0), but tegra_dbi_atomic_enable()
unconditionally muxes V_PULSE1 onto PIN_LDC before saving
tegra_dbi_pin_regs[] into com_pin_backup.  When interface 1 is used,
PIN_LDC is clobbered while PIN_LVP0 in DC_COM_PIN_OUTPUT_SELECT(4) keeps
the PIN_OUTPUT_SELECT_OUT setting programmed by tegra_rgb_encoder_enable(),
leaving PIN_LVP0 in static GPIO output mode once com_pin_backup is
restored for active scanout.

[ ... ]

> +	/* Unshadow to set up command and data pins */
> +	tegra_dc_writel(dc, WRITE_MUX | READ_MUX, DC_CMD_STATE_ACCESS);
> +
> +	tegra_dbi_init_interface(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 && next_bridge->funcs && next_bridge->funcs->atomic_enable)
> +		next_bridge->funcs->atomic_enable(next_bridge, state);
> +
> +	tegra_dbi_pin_set(dc, priv->interface->cs_pin, 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;
> +	int ret;
> +
> +	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]);
> +
> +	ret = tegra_dbi_stop_dc(priv);
> +	if (ret)
> +		return;
> +
> +	tegra_dc_writel(dc, WRITE_MUX | READ_MUX, DC_CMD_STATE_ACCESS);
> +
> +	tegra_dbi_init_interface(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 && next_bridge->funcs && next_bridge->funcs->atomic_disable)
> +		next_bridge->funcs->atomic_disable(next_bridge, state);

[Severity: High]
As reported by Mikko Perttunen on v5 [1], does manually calling
next_bridge->funcs->atomic_enable() and atomic_disable() cause duplicate
and out-of-order execution with drm_atomic_bridge_chain_enable() and
drm_atomic_bridge_chain_disable()?

Because tegra_dbi_attach() attaches priv->next_bridge to
encoder->bridge_chain, the DRM bridge helpers already walk both bridges:

1. On enable, drm_atomic_bridge_chain_enable() calls
   tegra_dbi_atomic_enable() (which manually runs
   next_bridge->funcs->atomic_enable() while priv->active is true) and
   then advances to next_bridge and calls its atomic_enable() a second
   time while priv->active is false, triggering the "Skipping enable of
   already enabled panel" warning in drm_panel_enable().

2. On disable, drm_atomic_bridge_chain_disable() walks
   encoder->bridge_chain in reverse order and calls
   next_bridge->funcs->atomic_disable() before tegra_dbi_atomic_disable()
   has stopped the DC, configured the pins for DBI output, or set
   priv->active = true.  During that first call, tegra_dbi_dbi_command()
   rejects every DCS shutdown command with -ENODEV while the panel driver
   still runs its msleep() delays; tegra_dbi_atomic_disable() then runs
   next_bridge->funcs->atomic_disable() a second time.

[1] https://lore.kernel.org/r/weWUeY3nRGCfNVcl2RuY5g@nvidia.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130114155.72920-1-clamor95@gmail.com?part=13

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v9 12/13] dt-bindings: display: tegra: Document 8-bit CPU parallel interface
       [not found] ` <20261130114155.72920-13-clamor95@gmail.com>
@ 2026-11-30 13:59   ` Rob Herring (Arm)
  0 siblings, 0 replies; 12+ messages in thread
From: Rob Herring (Arm) @ 2026-11-30 13:59 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Thomas Zimmermann, Conor Dooley, Thierry Reding, Jonathan Hunter,
	Neil Armstrong, linux-tegra, Krzysztof Kozlowski, Jessica Zhang,
	David Airlie, Mikko Perttunen, devicetree, Maxime Ripard,
	linux-kernel, Simona Vetter, dri-devel, Maarten Lankhorst


On Mon, 30 Nov 2026 13:41:53 +0200, Svyatoslav Ryhel wrote:
> 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
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dbi.example.dtb: /example-0/dbi/panel: failed to match any schema with compatible: ['hit,tx10d07vm0baa']

doc reference errors (make refcheckdocs):

See https://patchwork.kernel.org/project/devicetree/patch/20261130114155.72920-13-clamor95@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-11-30 13:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 11:41 [PATCH v9 00/13] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
2026-11-30 11:41 ` [PATCH v9 01/13] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
2026-11-30 11:55   ` sashiko-bot
2026-11-30 11:41 ` [PATCH v9 03/13] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
2026-11-30 11:41 ` [PATCH v9 04/13] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus Svyatoslav Ryhel
2026-11-30 11:41 ` [PATCH v9 05/13] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
2026-11-30 11:41 ` [PATCH v9 06/13] drm/tegra: dc: Add elements required by Tegra MIPI DBI Svyatoslav Ryhel
2026-11-30 11:41 ` [PATCH v9 10/13] dt-bindings: display: tegra: Document nvidia, contiguous-rgb-pins property Svyatoslav Ryhel
     [not found] ` <20261130114155.72920-10-clamor95@gmail.com>
2026-11-30 11:53   ` [PATCH v9 09/13] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs sashiko-bot
     [not found] ` <20261130114155.72920-12-clamor95@gmail.com>
2026-11-30 11:59   ` [PATCH v9 11/13] drm/tegra: rgb: Parameterize configuration based on bus flags and DT property sashiko-bot
     [not found] ` <20261130114155.72920-14-clamor95@gmail.com>
2026-11-30 12:11   ` [PATCH v9 13/13] drm/tegra: Add support for 8-bit CPU interface sashiko-bot
     [not found] ` <20261130114155.72920-13-clamor95@gmail.com>
2026-11-30 13:59   ` [PATCH v9 12/13] dt-bindings: display: tegra: Document 8-bit CPU parallel interface Rob Herring (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox