drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface
Subsystems (6)
v7 cover drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface
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
Please, keep in mind that this series must be applied on top of
https://gitlab.freedesktop.org/drm/misc/kernel.git (drm-misc-next)
---
Svyatoslav Ryhel (12):
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: Drop redundant disable()
operation
drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus drm/panel: panel-lg-lh400wv3: Drop redundant disable() operation 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 drm/tegra: rgb: Parameterize configuration based on bus flags
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 | 15 + .../display/tegra/nvidia,tegra20-dsi.yaml | 6 + drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_mipi_dbi_bus.c | 258 ++++++++ .../drm/panel/panel-hitachi-tx10d07vm0baa.c | 35 +- drivers/gpu/drm/panel/panel-lg-lh400wv3.c | 35 +- drivers/gpu/drm/tegra/Kconfig | 1 + drivers/gpu/drm/tegra/Makefile | 1 + drivers/gpu/drm/tegra/dbi.c | 551 ++++++++++++++++++ drivers/gpu/drm/tegra/dc.c | 4 + drivers/gpu/drm/tegra/dc.h | 197 ++++++- drivers/gpu/drm/tegra/drm.h | 2 +- drivers/gpu/drm/tegra/dsi.c | 22 +- drivers/gpu/drm/tegra/hdmi.c | 22 +- drivers/gpu/drm/tegra/output.c | 52 +- drivers/gpu/drm/tegra/rgb.c | 64 +- drivers/gpu/drm/tegra/sor.c | 20 +- include/drm/drm_mipi_dbi_bus.h | 113 ++++ 19 files changed, 1397 insertions(+), 111 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
Signature · 1 line
2.53.0
PATCH v7 1/12 drm: Add MIPI DBI bus support for MIPI DBI Type A and B
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.
--- drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_mipi_dbi_bus.c | 258 +++++++++++++++++++++++++++++ include/drm/drm_mipi_dbi_bus.h | 113 +++++++++++++ 3 files changed, 372 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/drm_mipi_dbi_bus.c create mode 100644 include/drm/drm_mipi_dbi_bus.h
drivers/gpu/drm/Makefile +1 -1
@@ -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/
drivers/gpu/drm/drm_mipi_dbi_bus.c new file +258 -0
258 lines not on this page · raw message
include/drm/drm_mipi_dbi_bus.h new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v7 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm: unbalanced of_node_put() in mipi_dbi_device_release() - [Low] drm: mismatched Return kernel-doc…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] drm: unbalanced of_node_put() in mipi_dbi_device_release()
- [Low] drm: mismatched Return kernel-doc in drm_mipi_dbi_bus.c --
commit 3fe40d87109b802b6b8c4ac15ef288e1fecb74a0
Author: Svyatoslav Ryhel <[email protected]>
drm: Add MIPI DBI bus support for MIPI DBI Type A and B
This commit introduces a MIPI DBI bus and driver model infrastructure to support MIPI DBI Type A and Type B hosts and peripheral devices.
Quoted 5 lines
drivers/gpu/drm/drm_mipi_dbi_bus.c new file +0
-0
[ ... ]
Quoted 71 lines
drivers/gpu/drm/drm_mipi_dbi_bus.c new file +71
-0+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 (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);
drivers/gpu/drm/drm_mipi_dbi_bus.c line 151
Quoted 10 lines
drivers/gpu/drm/drm_mipi_dbi_bus.c new file +10
-0+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); +}
[Severity: High]
Does mipi_dbi_device_release() drop a reference on dev->of_node that devm_mipi_dbi_device_register() never acquired?
device_set_node(&dbidev->dev, of_fwnode_handle(np)) does not call of_node_get(np), and callers are documented as still owning their reference to np. When put_device() runs on error unwind or when mipi_dbi_device_unregister() later unregisters the device, mipi_dbi_device_release() calls of_node_put(dev->of_node) and underflows the device_node refcount. Should devm_mipi_dbi_device_register() call of_node_get(np) when associating np with dbidev->dev?
[ ... ]
Quoted 7 lines
drivers/gpu/drm/drm_mipi_dbi_bus.c new file +7
-0+/** +* 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)
[ ... ]
Quoted 7 lines
drivers/gpu/drm/drm_mipi_dbi_bus.c new file +7
-0+/** +* mipi_dbi_driver_unregister() - unregister a driver for MIPI DBI Type A or B devices. +* @drv: DBI driver structure +* +* Return: 0 on success or a negative error code on failure. +*/ +void mipi_dbi_driver_unregister (struct mipi_dbi_driver *drv)
[ ... ]
Quoted 5 lines
include/drm/drm_mipi_dbi_bus.h new file +0
-0
[ ... ]
Quoted 8 lines
include/drm/drm_mipi_dbi_bus.h new file +8
-0+/** +* 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. +*
include/drm/drm_mipi_dbi_bus.h line 59
Quoted 10 lines
include/drm/drm_mipi_dbi_bus.h new file +10
-0+* 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 {
[Severity: Low]
This isn't a bug, but the Return: kernel-doc line on mipi_dbi_driver_unregister() (which returns void) looks like it belongs on devm_mipi_dbi_attach(), which returns int and has no Return: section. Also, in struct mipi_dbi_device, the extended description paragraphs appear before the @member entries without a blank comment line after the one-line summary.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v7 2/12 drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus
In reply to Svyatoslav RyhelSwitch from a generic platform driver to a dedicated MIPI DBI Type B driver.
--- .../drm/panel/panel-hitachi-tx10d07vm0baa.c | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c +12 -13
@@ -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 <[email protected]>" );MODULE_DESCRIPTION ("HITACHI TX10D07VM0BAA MIPI DBI Type B panel driver" );
Signature · 1 line
2.53.0
PATCH v7 3/12 drm/panel: panel-hitachi-tx10d07vm0baa: Drop redundant disable() operation
In reply to Svyatoslav RyhelSquash the disable() and unprepare() functions, since there is no need for host adjustments between them.
--- drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c +1 -9
@@ -177,7 +177,7 @@ static int hitachi_tx10d07vm0baa_enable(struct drm_panel *panel)return 0 ; } -static int hitachi_tx10d07vm0baa_disable (struct drm_panel *panel) +static int hitachi_tx10d07vm0baa_unprepare (struct drm_panel *panel) {struct hitachi_tx10d07vm0baa *priv =to_hitachi_tx10d07vm0baa (panel);
@@ -187,13 +187,6 @@ static int hitachi_tx10d07vm0baa_disable(struct drm_panel *panel)panel_dbi_command (priv,MIPI_DCS_ENTER_SLEEP_MODE );msleep (50 ); -return 0 ; -} - -static int hitachi_tx10d07vm0baa_unprepare (struct drm_panel *panel) -{ -struct hitachi_tx10d07vm0baa *priv =to_hitachi_tx10d07vm0baa (panel); -gpiod_set_value_cansleep (priv->reset_gpio,1 );regulator_bulk_disable (ARRAY_SIZE (hitachi_tx10d07vm0baa_supplies), priv->supplies);
@@ -236,7 +229,6 @@ static int hitachi_tx10d07vm0baa_get_modes(struct drm_panel *panel,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, };
Signature · 1 line
2.53.0
PATCH v7 4/12 drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus
In reply to Svyatoslav RyhelSwitch from a generic platform driver to a dedicated MIPI DBI Type B driver.
--- drivers/gpu/drm/panel/panel-lg-lh400wv3.c | 27 +++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/gpu/drm/panel/panel-lg-lh400wv3.c +13 -14
@@ -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 <[email protected]>" );MODULE_DESCRIPTION ("LG LH400WV3-SD04 MIPI DBI Type B panel driver" );
Signature · 1 line
2.53.0
PATCH v7 5/12 drm/panel: panel-lg-lh400wv3: Drop redundant disable() operation
In reply to Svyatoslav RyhelSquash the disable() and unprepare() functions, since there is no need for host adjustments between them.
--- drivers/gpu/drm/panel/panel-lg-lh400wv3.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/drm/panel/panel-lg-lh400wv3.c +1 -9
@@ -115,7 +115,7 @@ static int lg_lh400wv3_enable(struct drm_panel *panel)return 0 ; } -static int lg_lh400wv3_disable (struct drm_panel *panel) +static int lg_lh400wv3_unprepare (struct drm_panel *panel) {struct lg_lh400wv3 *priv =to_lg_lh400wv3 (panel);
@@ -126,13 +126,6 @@ static int lg_lh400wv3_disable(struct drm_panel *panel)panel_dbi_command (priv,0xc1 ,0x01 );usleep_range (10000 ,11000 ); -return 0 ; -} - -static int lg_lh400wv3_unprepare (struct drm_panel *panel) -{ -struct lg_lh400wv3 *priv =to_lg_lh400wv3 (panel); -gpiod_set_value_cansleep (priv->reset_gpio,1 );regulator_bulk_disable (ARRAY_SIZE (lg_lh400wv3_supplies), priv->supplies);
@@ -175,7 +168,6 @@ static int lg_lh400wv3_get_modes(struct drm_panel *panel,static const struct drm_panel_funcs lg_lh400wv3_panel_funcs = { .prepare = lg_lh400wv3_prepare, .enable = lg_lh400wv3_enable, - .disable = lg_lh400wv3_disable, .unprepare = lg_lh400wv3_unprepare, .get_modes = lg_lh400wv3_get_modes, };
Signature · 1 line
2.53.0
PATCH v7 6/12 drm/tegra: dc: Add elements required by Tegra MIPI DBI
In reply to Svyatoslav RyhelAdd DC register definitions with additional fields in preparation for adding the 8-bit CPU interface (MIPI DBI).
--- drivers/gpu/drm/tegra/dc.h | 194 ++++++++++++++++++++++++++++++++++--- 1 file changed, 183 insertions(+), 11 deletions(-)
drivers/gpu/drm/tegra/dc.h +183 -11
@@ -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
Signature · 1 line
2.53.0
PATCH v7 7/12 dt-bindings: display: tegra: Document Tegra20 DSI port
In reply to Svyatoslav RyhelDocument the optional port node, which is required for correctly modeling a dual-mode panel.
--- .../bindings/display/tegra/nvidia,tegra20-dsi.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dsi.yaml +6 -0
@@ -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:
Signature · 1 line
2.53.0
PATCH v7 8/12 drm/tegra: output: Make panel parsing configurable
In reply to Svyatoslav RyhelThe 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.
--- 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(-)
drivers/gpu/drm/tegra/drm.h +1 -1
@@ -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);
drivers/gpu/drm/tegra/dsi.c +1 -1
@@ -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;
drivers/gpu/drm/tegra/hdmi.c +1 -1
@@ -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;
drivers/gpu/drm/tegra/output.c +27 -25
65 lines not on this page · raw message
drivers/gpu/drm/tegra/rgb.c +1 -1
@@ -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;
drivers/gpu/drm/tegra/sor.c +1 -1
@@ -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;
Signature · 1 line
2.53.0
PATCH v7 9/12 drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs
In reply to Svyatoslav RyhelSwitch 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.
--- 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(-)
drivers/gpu/drm/tegra/dsi.c +15 -5
@@ -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, };
drivers/gpu/drm/tegra/hdmi.c +15 -5
@@ -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, };
drivers/gpu/drm/tegra/rgb.c +17 -6
@@ -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, };
drivers/gpu/drm/tegra/sor.c +13 -5
@@ -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, };
Signature · 1 line
2.53.0
PATCH v7 10/12 drm/tegra: rgb: Parameterize configuration based on bus flags
In reply to Svyatoslav RyhelParameterize 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.
--- drivers/gpu/drm/tegra/rgb.c | 39 +++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-)
drivers/gpu/drm/tegra/rgb.c +35 -4
@@ -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);
Signature · 1 line
2.53.0
PATCH v7 11/12 dt-bindings: display: tegra: Document 8-bit CPU parallel interface
In reply to Svyatoslav RyhelDocument 8-bit CPU parallel MIPI DBI Type B interface provided by Tegra20/30 SoCs display controller.
--- .../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
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dbi.yaml new file +108 -0
@@ -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 <[email protected]> + +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>; + }; + }; + }; + };
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +15 -0
@@ -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:
Signature · 1 line
2.53.0
PATCH v7 12/12 drm/tegra: Add support for 8-bit CPU interface
In reply to Svyatoslav RyhelThe 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.
--- drivers/gpu/drm/tegra/Kconfig | 1 + drivers/gpu/drm/tegra/Makefile | 1 + drivers/gpu/drm/tegra/dbi.c | 551 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/tegra/dc.c | 4 + drivers/gpu/drm/tegra/dc.h | 3 + 5 files changed, 560 insertions(+) create mode 100644 drivers/gpu/drm/tegra/dbi.c
drivers/gpu/drm/tegra/Kconfig +1 -0
@@ -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
drivers/gpu/drm/tegra/Makefile +1 -0
@@ -18,6 +18,7 @@ tegra-drm-y := \ hdmi.o \ mipi-phy.o \ dsi.o \ + dbi.o \ sor.o \ dpaux.o \ gr2d.o \
drivers/gpu/drm/tegra/dbi.c new file +551 -0
551 lines not on this page · raw message
drivers/gpu/drm/tegra/dc.c +4 -0
@@ -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,
drivers/gpu/drm/tegra/dc.h +3 -0
@@ -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)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v7 12/12] drm/tegra: Add support for 8-bit CPU interface
Thank you for your contribution! Sashiko AI review found 8 potential issues to consider: - [High] drm/tegra: broken disable sequence and active state in tegra_dbi_atomic_disable() - [High]…
Thank you for your contribution! Sashiko AI review found 8 potential issues to consider:
- [High] drm/tegra: broken disable sequence and active state in tegra_dbi_atomic_disable()
- [High] drm/tegra: premature bridge add and NULL next_bridge in tegra_dbi_attach()
- [Medium] drm/tegra: duplicate next_bridge enable call in tegra_dbi_atomic_enable()
- [Medium] drm/tegra: dangling priv->next_bridge pointer in tegra_dbi_host_detach()
- [Medium] drm/tegra: device_node refcount leak on dbi_np in tegra_dc_dbi_probe()
- [Medium] drm/tegra: unbalanced of_node_put() on remote panel node in tegra_dc_dbi_probe()
- [Medium] drm/tegra: dbi: missing idle wait after stopping DC in tegra_dbi_atomic_enable()
- [Medium] drm/tegra: unconditional PIN_LDC muxing in tegra_dbi_atomic_enable()
--
commit c9bf1d91683f8b29d2b2a60164a0b606d5716c0d
Author: Svyatoslav Ryhel <[email protected]>
drm/tegra: Add support for 8-bit CPU interface
This commit adds a MIPI DBI host and DRM bridge driver for the 8-bit CPU display controller interface on Tegra20 and Tegra30 SoCs, and hooks its probe into tegra_dc_probe().
Quoted 5 lines
drivers/gpu/drm/tegra/dbi.c new file +0
-0
[ ... ]
drivers/gpu/drm/tegra/dbi.c line 181
Quoted 6 lines
drivers/gpu/drm/tegra/dbi.c new file +6
-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_put (priv->next_bridge); +}
[Severity: Medium]
Does tegra_dbi_host_detach() leave a dangling pointer in priv->next_bridge after dropping its reference? If the DBI peripheral driver is unbound, later accesses in tegra_dbi_atomic_enable() or tegra_dbi_attach() will dereference the freed bridge unless priv->next_bridge is cleared (for example with drm_bridge_clear_and_put()).
[ ... ]
Quoted 8 lines
drivers/gpu/drm/tegra/dbi.c new file +8
-0+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; +
drivers/gpu/drm/tegra/dbi.c line 205
Quoted 10 lines
drivers/gpu/drm/tegra/dbi.c new file +10
-0+ 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);
[Severity: Medium]
Should tegra_dbi_atomic_enable() wait for the display controller to become idle after committing DISP_CTRL_MODE_STOP?
tegra_crtc_atomic_enable() has already started DISP_CTRL_MODE_C_DISPLAY and tegra_rgb_encoder_enable() has committed rgb_enable, so GENERAL_ACT_REQ is deferred until the next frame boundary rather than latching immediately. Because panel enable callbacks sleep across multiple frames while bit-banging DCS commands, the pending frame-boundary latch can overwrite the active DC_COM_PIN_OUTPUT_* GPIO settings with the shadowed video-mode values mid-transfer.
[ ... ]
drivers/gpu/drm/tegra/dbi.c line 229
Quoted 5 lines
drivers/gpu/drm/tegra/dbi.c new file +5
-0+/* 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 ));
[Severity: Medium]
Does this unconditionally mux V_PULSE1 onto the primary interface D/C pin (PIN_LDC) even when the secondary 8-bit CPU interface is used?
On the secondary interface (nvidia,interface = 1), the D/C signal is on PIN_LVP0 in DC_COM_PIN_OUTPUT_SELECT(4), which tegra_rgb_encoder_enable() leaves set to PIN_OUTPUT_SELECT_OUT (0x00210222). Restoring com_pin_backup therefore leaves PIN_LVP0 in fixed GPIO output mode during scanout instead of driving per-frame MIPI_DCS_WRITE_MEMORY_START commands.
[ ... ]
Quoted 8 lines
drivers/gpu/drm/tegra/dbi.c new file +8
-0+/* 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; + +/*
drivers/gpu/drm/tegra/dbi.c line 281
Quoted 10 lines
drivers/gpu/drm/tegra/dbi.c new file +10
-0+* 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);
[Severity: Medium]
As reported by Mikko Perttunen on v5 [1], does calling next_bridge->funcs->atomic_enable() here cause it to run twice on every modeset?
Because tegra_dbi_attach() links priv->next_bridge into encoder->bridge_chain after priv->bridge, drm_atomic_bridge_chain_enable() immediately advances to priv->next_bridge and calls its atomic_enable callback a second time while priv->active is false. For panel_bridge, this triggers the "Skipping enable of already enabled panel" warning in drm_panel_enable(), and any downstream bridge that sends DBI commands in the second call fails with -ENODEV.
Quoted 4 lines
drivers/gpu/drm/tegra/dbi.c new file +4
-0+ +tegra_dbi_pin_set (dc, &priv->interface->cs,0 ); + + priv->active = false;
[ ... ]
drivers/gpu/drm/tegra/dbi.c line 311
Quoted 11 lines
drivers/gpu/drm/tegra/dbi.c new file +11
-0+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 tegra_dc *dc = priv->dc; + +tegra_dc_writel (dc,WRITE_MUX |READ_MUX ,DC_CMD_STATE_ACCESS ); + + priv->interface->init (priv); + priv->active = true; +}
[Severity: High]
Does running this setup in atomic_disable prevent panel power-down commands from working and leave the interface marked active after CRTC disable?
During disable_outputs(), drm_atomic_bridge_chain_disable() walks the chain in reverse, so next_bridge->funcs->atomic_disable() runs before tegra_dbi_atomic_disable() while priv->active is still false. Immediately after tegra_dbi_atomic_disable() configures the DBI pins with WRITE_MUX | READ_MUX enabled, drm_atomic_helper_commit_encoder_bridge_disable() calls tegra_rgb_encoder_disable(), which writes rgb_disable directly to the active DC_COM_PIN_OUTPUT_SELECT and DC_COM_PIN_OUTPUT_ENABLE registers and tristates the pins before drm_panel_unprepare() runs in post_disable. In addition, nothing clears priv->active or DC_CMD_STATE_ACCESS afterward, so tegra_dbi_dbi_command() remains open for MMIO writes after the display controller is suspended and unclocked.
[ ... ]
drivers/gpu/drm/tegra/dbi.c line 344
Quoted 9 lines
drivers/gpu/drm/tegra/dbi.c new file +9
-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); + +return drm_bridge_attach (bridge->encoder, priv->next_bridge, bridge, + flags); +}
[Severity: High]
What happens if tegra_dbi_attach() runs before the MIPI DBI panel driver has bound and called tegra_dbi_host_attach()?
tegra_dc_dbi_probe() publishes priv->bridge via devm_drm_bridge_add() before devm_mipi_dbi_device_register(), and device_add() succeeds even when the panel driver has not probed yet or deferred probe (for instance, drivers/gpu/drm/Makefile links tegra/ before panel/). In that case priv->next_bridge is still NULL when host1x_drm_probe() calls tegra_dbi_attach(), so drm_bridge_attach() returns -EINVAL instead of -EPROBE_DEFER and aborts DRM initialization permanently.
[ ... ]
drivers/gpu/drm/tegra/dbi.c line 538
Quoted 6 lines
drivers/gpu/drm/tegra/dbi.c new file +6
-0+ priv->bridge.of_node =of_node_get (dbi_np); + priv->bridge.timings = &default_tegra_dbi_timings; + + ret =devm_drm_bridge_add (dev, &priv->bridge); +if (ret) +return ret;
[Severity: Medium]
Does of_node_get(dbi_np) leak a reference to the dbi device_node?
dbi_np is already managed with __free(device_node), and neither the DRM bridge core nor a devm action releases the extra reference stored in priv->bridge.of_node on error, probe deferral, or driver unbind.
drivers/gpu/drm/tegra/dbi.c line 545
Quoted 7 lines
drivers/gpu/drm/tegra/dbi.c new file +7
-0+ + 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);
[Severity: Medium]
Does calling of_node_put(np) here cause an of_node refcount underflow when dbidev is released?
devm_mipi_dbi_device_register() attaches np to dbidev->dev via device_set_node() without taking its own reference, and mipi_dbi_device_release() calls of_node_put(dev->of_node) when the device is freed:
drivers/gpu/drm/drm_mipi_dbi_bus.c:devm_mipi_dbi_device_register() {
...
dbidev->dev.release = mipi_dbi_device_release;
device_set_node(&dbidev->dev, of_fwnode_handle(np));
...
}Dropping np's only reference right after registration leaves dbidev->dev.of_node unreferenced and results in a double of_node_put() on error unwind or device removal.
[1] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12