RPi touchscreen panel driver v4
Subsystems (7)
cover RPi touchscreen panel driver v4
The review for v3 was basically "no, the panel should probe first so that we have the connector by the time KMS is done initializing." To do this, I needed to be able to register the custom (non-OF-generated) DSI device without the host being present (patch 6). Also check out patch 4 for a new cleanup to panel-bridge.
Eric Anholt (8):
drm/vc4: Fix DSI T_INIT timing.
drm/vc4: Fix misleading name of the continuous flag. drm/vc4: Use drm_mode_vrefresh() in DSI fixup, in case vrefresh is 0. drm/bridge: Add a devm_ allocator for panel bridge. drm/vc4: Delay DSI host registration until the panel has probed.
drm: Allow DSI devices to be registered before the host registers.
dt-bindings: Document the Raspberry Pi Touchscreen nodes. drm/panel: Add support for the Raspberry Pi 7" Touchscreen.
.../panel/raspberrypi,7inch-touchscreen.txt | 49 ++ drivers/gpu/drm/bridge/panel.c | 30 ++ drivers/gpu/drm/drm_mipi_dsi.c | 49 +- drivers/gpu/drm/panel/Kconfig | 8 + drivers/gpu/drm/panel/Makefile | 1 + .../gpu/drm/panel/panel-raspberrypi-touchscreen.c | 505 +++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_dsi.c | 64 +-- include/drm/drm_bridge.h | 3 + include/drm/drm_mipi_dsi.h | 3 + 9 files changed, 671 insertions(+), 41 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/panel/raspberrypi,7inch-touchscreen.txt create mode 100644 drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/8 drm/vc4: Fix DSI T_INIT timing.
The DPHY spec requires a much larger T_INIT than I was specifying before. In the absence of clear specs from the slave of what their timing is, just use the value that the firmware was using.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_dsi.c +11 -1
@@ -1035,7 +1035,17 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) DSI_HS_DLT4_TRAIL) | VC4_SET_FIELD(0, DSI_HS_DLT4_ANLAT)); -DSI_PORT_WRITE (HS_DLT5 ,VC4_SET_FIELD (dsi_hs_timing (ui_ns,1000 ,5000 ), +/* T_INIT is how long STOP is driven after power-up to +* indicate to the slave (also coming out of power-up) that +* master init is complete, and should be greater than the +* maximum of two value: T_INIT,MASTER and T_INIT,SLAVE. The +* D-PHY spec gives a minimum 100us for T_INIT,MASTER and +* T_INIT,SLAVE, while allowing protocols on top of it to give +* greater minimums. The vc4 firmware uses an extremely +* conservative 5ms, and we maintain that here. +*/ +DSI_PORT_WRITE (HS_DLT5 ,VC4_SET_FIELD (dsi_hs_timing (ui_ns, +5 *1000 *1000 ,0 ),DSI_HS_DLT5_INIT )); DSI_PORT_WRITE(HS_DLT6,
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/8] drm/vc4: Fix DSI T_INIT timing.
Quoted 5 lines · Eric Anholt
The DPHY spec requires a much larger
T_INITthan I was specifying before. In the absence of clear specs from the slave of what their timing is, just use the value that the firmware was using.Signed-off-by Eric Anholt <[email protected]>
--
Regards
Andrzej
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/8 drm/vc4: Fix misleading name of the continuous flag.
In reply to Eric AnholtThe logic was all right in the end, the name was just backwards.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_dsi.c +4 -4
@@ -736,18 +736,18 @@ static void vc4_dsi_latch_ulps(struct vc4_dsi *dsi, bool latch)/* Enters or exits Ultra Low Power State. */ static void vc4_dsi_ulps (struct vc4_dsi *dsi,bool ulps) { -bool continuous = dsi->mode_flags &MIPI_DSI_CLOCK_NON_CONTINUOUS ; -u32 phyc_ulps = ((continuous ?DSI_PORT_BIT (PHYC_CLANE_ULPS ) :0 ) | +bool non_continuous = dsi->mode_flags &MIPI_DSI_CLOCK_NON_CONTINUOUS ; +u32 phyc_ulps = ((non_continuous ?DSI_PORT_BIT (PHYC_CLANE_ULPS ) :0 ) |DSI_PHYC_DLANE0_ULPS | (dsi->lanes >1 ?DSI_PHYC_DLANE1_ULPS :0 ) | (dsi->lanes >2 ?DSI_PHYC_DLANE2_ULPS :0 ) | (dsi->lanes >3 ?DSI_PHYC_DLANE3_ULPS :0 )); -u32 stat_ulps = ((continuous ?DSI1_STAT_PHY_CLOCK_ULPS :0 ) | +u32 stat_ulps = ((non_continuous ?DSI1_STAT_PHY_CLOCK_ULPS :0 ) |DSI1_STAT_PHY_D0_ULPS | (dsi->lanes >1 ?DSI1_STAT_PHY_D1_ULPS :0 ) | (dsi->lanes >2 ?DSI1_STAT_PHY_D2_ULPS :0 ) | (dsi->lanes >3 ?DSI1_STAT_PHY_D3_ULPS :0 )); - u32 stat_stop = ((continuous ? DSI1_STAT_PHY_CLOCK_STOP : 0) | + u32 stat_stop = ((non_continuous ? DSI1_STAT_PHY_CLOCK_STOP : 0) | DSI1_STAT_PHY_D0_STOP | (dsi->lanes > 1 ? DSI1_STAT_PHY_D1_STOP : 0) | (dsi->lanes > 2 ? DSI1_STAT_PHY_D2_STOP : 0) |
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/8] drm/vc4: Fix misleading name of the continuous flag.
Quoted 3 lines · Eric Anholt
The logic was all right in the end, the name was just backwards.
Signed-off-by Eric Anholt <[email protected]>
--
Regards
Andrzej
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/8 drm/vc4: Use drm_mode_vrefresh() in DSI fixup, in case vrefresh is 0.
In reply to Eric AnholtI'm not sure what changed where I started getting vrefresh=0 from the mode to be fixed up.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_dsi.c +3 -1
@@ -866,7 +866,9 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, adjusted_mode->clock = pixel_clock_hz /1000 +1 ;/* Given the new pixel clock, adjust HFP to keep vrefresh the same. */ - adjusted_mode->htotal = pixel_clock_hz / (mode->vrefresh * mode->vtotal); + adjusted_mode->htotal = pixel_clock_hz / (drm_mode_vrefresh (mode) * + mode->vtotal); + adjusted_mode->hsync_end += adjusted_mode->htotal - mode->htotal; adjusted_mode->hsync_start += adjusted_mode->htotal - mode->htotal;
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/8] drm/vc4: Use drm_mode_vrefresh() in DSI fixup, in case vrefresh is 0.
Quoted 2 lines · Eric Anholt
I'm not sure what changed where I started getting vrefresh=0 from the mode to be fixed up.
It can be a case of low pixel_clock value, maybe it should be investigated further, unless there is execution path with forgotten mode->vrefresh =
drm_mode_vrefresh(mode)
Quoted 11 lines
Signed-off-by Eric Anholt <[email protected]>--- drivers/gpu/drm/vc4/vc4_dsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_dsi.c +0
-0
drivers/gpu/drm/vc4/vc4_dsi.c static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, · line 871
Quoted 7 lines
drivers/gpu/drm/vc4/vc4_dsi.c +3
-1@@ -866,7 +866,9 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, adjusted_mode->clock = pixel_clock_hz /1000 +1 ;/* Given the new pixel clock, adjust HFP to keep vrefresh the same. */ - adjusted_mode->htotal = pixel_clock_hz / (mode->vrefresh * mode->vtotal); + adjusted_mode->htotal = pixel_clock_hz / (drm_mode_vrefresh (mode) * + mode->vtotal); +
I am not sure but I guess division by zero is also possible here. I do not know if you need to handle interlaced/dblscan/vscan modes, but maybe it would be safer to calculate adjusted_htotal according to:
adjusted_mode->htotal = pixel_clock_hz * mode->htotal / (mode->clock * 1000)
or sth similar.
Regards
Andrzej
drivers/gpu/drm/vc4/vc4_dsi.c static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, · line 874
Quoted 3 lines
drivers/gpu/drm/vc4/vc4_dsi.c +0
-0adjusted_mode->hsync_end += adjusted_mode->htotal - mode->htotal; adjusted_mode->hsync_start += adjusted_mode->htotal - mode->htotal;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/8 drm/bridge: Add a devm_ allocator for panel bridge.
In reply to Eric AnholtThis will let drivers reduce the error cleanup they need, in particular the "is_panel_bridge" flag.
--- drivers/gpu/drm/bridge/panel.c | 30 ++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 3 +++ 2 files changed, 33 insertions(+)
drivers/gpu/drm/bridge/panel.c +30 -0
@@ -198,3 +198,33 @@ void drm_panel_bridge_remove(struct drm_bridge *bridge)devm_kfree (panel_bridge->panel->dev, bridge); }EXPORT_SYMBOL (drm_panel_bridge_remove); + +static void devm_drm_panel_bridge_release (struct device *dev,void *res) +{ +struct drm_bridge *bridge = *(struct drm_bridge **)res; + +drm_panel_bridge_remove (bridge); +} + +struct drm_bridge *devm_drm_panel_bridge_add (struct device *dev, +struct drm_panel *panel, +u32 connector_type) +{ +struct drm_bridge **ptr, *bridge; + + ptr =devres_alloc (devm_drm_panel_bridge_release,sizeof (*ptr), +GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + bridge =drm_panel_bridge_add (panel, connector_type); +if (!IS_ERR (bridge)) { + *ptr = bridge; +devres_add (dev, ptr); + }else { +devres_free (ptr); + } + +return bridge; +} +EXPORT_SYMBOL (devm_drm_panel_bridge_add);
include/drm/drm_bridge.h +3 -0
@@ -268,6 +268,9 @@ void drm_bridge_enable(struct drm_bridge *bridge);struct drm_bridge *drm_panel_bridge_add (struct drm_panel *panel,u32 connector_type);void drm_panel_bridge_remove (struct drm_bridge *bridge); +struct drm_bridge *devm_drm_panel_bridge_add (struct device *dev, +struct drm_panel *panel, +u32 connector_type);#endif #endif
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/8] drm/bridge: Add a devm_ allocator for panel bridge.
Quoted 14 lines · Eric Anholt
This will let drivers reduce the error cleanup they need, in particular the "
is_panel_bridge" flag.Signed-off-by Eric Anholt <[email protected]>--- drivers/gpu/drm/bridge/panel.c | 30 ++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 3 +++ 2 files changed, 33 insertions(+)drivers/gpu/drm/bridge/panel.c +0
-0
drivers/gpu/drm/bridge/panel.c void drm_panel_bridge_remove(struct drm_bridge *bridge) · line 206
Quoted 9 lines
drivers/gpu/drm/bridge/panel.c +6
-0@@ -198,3 +198,33 @@ void drm_panel_bridge_remove(struct drm_bridge *bridge)devm_kfree (panel_bridge->panel->dev, bridge); }EXPORT_SYMBOL (drm_panel_bridge_remove); + +static void devm_drm_panel_bridge_release (struct device *dev,void *res) +{ +struct drm_bridge *bridge = *(struct drm_bridge **)res; + +drm_panel_bridge_remove (bridge);
I guess more elegant would be:
struct drm_bridge **bridge = res;
drm_panel_bridge_remove(*bridge);I am still not convinced to the idea of this panel_bridge stuff, but this is different issue :)
Anyway:
--
Regards
Andrzej
Quoted 29 lines
drivers/gpu/drm/bridge/panel.c +24
-0+} + +struct drm_bridge *devm_drm_panel_bridge_add (struct device *dev, +struct drm_panel *panel, +u32 connector_type) +{ +struct drm_bridge **ptr, *bridge; + + ptr =devres_alloc (devm_drm_panel_bridge_release,sizeof (*ptr), +GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + bridge =drm_panel_bridge_add (panel, connector_type); +if (!IS_ERR (bridge)) { + *ptr = bridge; +devres_add (dev, ptr); + }else { +devres_free (ptr); + } + +return bridge; +} +EXPORT_SYMBOL (devm_drm_panel_bridge_add);include/drm/drm_bridge.h +0
-0
include/drm/drm_bridge.h void drm_bridge_enable(struct drm_bridge *bridge); · line 276
Quoted 9 lines
include/drm/drm_bridge.h +3
-0@@ -268,6 +268,9 @@ void drm_bridge_enable(struct drm_bridge *bridge);struct drm_bridge *drm_panel_bridge_add (struct drm_panel *panel,u32 connector_type);void drm_panel_bridge_remove (struct drm_bridge *bridge); +struct drm_bridge *devm_drm_panel_bridge_add (struct device *dev, +struct drm_panel *panel, +u32 connector_type);#endif #endif
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/8 drm/vc4: Delay DSI host registration until the panel has probed.
In reply to Eric AnholtThe vc4 driver was unusual in that it was delaying the panel lookup until the attach step, while most DSI hosts will -EPROBE_DEFER until they get a panel.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-)
drivers/gpu/drm/vc4/vc4_dsi.c +16 -24
@@ -33,6 +33,7 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_edid.h> #include <drm/drm_mipi_dsi.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <linux/clk.h> #include <linux/clk-provider.h>
@@ -504,7 +505,6 @@ struct vc4_dsi {struct mipi_dsi_host dsi_host;struct drm_encoder *encoder;struct drm_bridge *bridge; -bool is_panel_bridge;void __iomem *regs;
@@ -1290,7 +1290,6 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) {struct vc4_dsi *dsi =host_to_dsi (host); -int ret =0 ; dsi->lanes = device->lanes; dsi->channel = device->channel;
@@ -1325,34 +1324,12 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host,return 0 ; } - dsi->bridge =of_drm_find_bridge (device->dev.of_node); -if (!dsi->bridge) { -struct drm_panel *panel = -of_drm_find_panel (device->dev.of_node); - - dsi->bridge =drm_panel_bridge_add (panel, -DRM_MODE_CONNECTOR_DSI ); -if (IS_ERR (dsi->bridge)) { - ret =PTR_ERR (dsi->bridge); - dsi->bridge =NULL ; -return ret; - } - dsi->is_panel_bridge = true; - } -return drm_bridge_attach (dsi->encoder, dsi->bridge,NULL ); }static int vc4_dsi_host_detach (struct mipi_dsi_host *host,struct mipi_dsi_device *device) { -struct vc4_dsi *dsi =host_to_dsi (host); - -if (dsi->is_panel_bridge) { -drm_panel_bridge_remove (dsi->bridge); - dsi->bridge =NULL ; - } -return 0 ; }
@@ -1496,6 +1473,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)struct vc4_dev *vc4 =to_vc4_dev (drm);struct vc4_dsi *dsi;struct vc4_dsi_encoder *vc4_dsi_encoder; +struct drm_panel *panel;const struct of_device_id *match;dma_cap_mask_t dma_mask;int ret;
@@ -1599,6 +1577,20 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)return ret; } + ret =drm_of_find_panel_or_bridge (dev->of_node,0 ,0 , + &panel, &dsi->bridge); +if (ret) { +dev_info (dev,"find panel: %d\n" , ret); +return ret; + } + +if (panel) { + dsi->bridge =devm_drm_panel_bridge_add (dev, panel, +DRM_MODE_CONNECTOR_DSI ); +if (IS_ERR (dsi->bridge)) +return PTR_ERR (dsi->bridge); + } +/* The esc clock rate is supposed to always be 100Mhz. */ ret =clk_set_rate (dsi->escape_clock,100 *1000000 );if (ret) {
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/8] drm/vc4: Delay DSI host registration until the panel has probed.
Quoted 81 lines · Eric Anholt
The vc4 driver was unusual in that it was delaying the panel lookup until the attach step, while most DSI hosts will -EPROBE_DEFER until they get a panel.
Signed-off-by Eric Anholt <[email protected]>--- drivers/gpu/drm/vc4/vc4_dsi.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-)drivers/gpu/drm/vc4/vc4_dsi.c +2
-24@@ -33,6 +33,7 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_edid.h> #include <drm/drm_mipi_dsi.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <linux/clk.h> #include <linux/clk-provider.h> @@ -504,7 +505,6 @@ struct vc4_dsi {struct mipi_dsi_host dsi_host;struct drm_encoder *encoder;struct drm_bridge *bridge; -bool is_panel_bridge;void __iomem *regs;@@ -1290,7 +1290,6 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) {struct vc4_dsi *dsi =host_to_dsi (host); -int ret =0 ; dsi->lanes = device->lanes; dsi->channel = device->channel;@@ -1325,34 +1324,12 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host,return 0 ; } - dsi->bridge =of_drm_find_bridge (device->dev.of_node); -if (!dsi->bridge) { -struct drm_panel *panel = -of_drm_find_panel (device->dev.of_node); - - dsi->bridge =drm_panel_bridge_add (panel, -DRM_MODE_CONNECTOR_DSI ); -if (IS_ERR (dsi->bridge)) { - ret =PTR_ERR (dsi->bridge); - dsi->bridge =NULL ; -return ret; - } - dsi->is_panel_bridge = true; - } -return drm_bridge_attach (dsi->encoder, dsi->bridge,NULL ); }static int vc4_dsi_host_detach (struct mipi_dsi_host *host,struct mipi_dsi_device *device) { -struct vc4_dsi *dsi =host_to_dsi (host); - -if (dsi->is_panel_bridge) { -drm_panel_bridge_remove (dsi->bridge); - dsi->bridge =NULL ; - } -return 0 ; }@@ -1496,6 +1473,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)struct vc4_dev *vc4 =to_vc4_dev (drm);struct vc4_dsi *dsi;struct vc4_dsi_encoder *vc4_dsi_encoder; +struct drm_panel *panel;const struct of_device_id *match;dma_cap_mask_t dma_mask;int ret;
drivers/gpu/drm/vc4/vc4_dsi.c static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) · line 1583
Quoted 7 lines
drivers/gpu/drm/vc4/vc4_dsi.c +4
-0@@ -1599,6 +1577,20 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)return ret; } + ret =drm_of_find_panel_or_bridge (dev->of_node,0 ,0 , + &panel, &dsi->bridge); +if (ret) { +dev_info (dev,"find panel: %d\n" , ret);
Message should probably mention also bridge.
Beside this:
--
Regards
Andrzej
drivers/gpu/drm/vc4/vc4_dsi.c static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) · line 1596
Quoted 13 lines
drivers/gpu/drm/vc4/vc4_dsi.c +10
-0+return ret; + } + +if (panel) { + dsi->bridge =devm_drm_panel_bridge_add (dev, panel, +DRM_MODE_CONNECTOR_DSI ); +if (IS_ERR (dsi->bridge)) +return PTR_ERR (dsi->bridge); + } +/* The esc clock rate is supposed to always be 100Mhz. */ ret =clk_set_rate (dsi->escape_clock,100 *1000000 );if (ret) {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/8 drm: Allow DSI devices to be registered before the host registers.
In reply to Eric AnholtWhen a mipi_dsi_host is registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers are mipi_dsi_drivers that attach to those nodes.
There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the mipi_dsi_host and registers the mipi_dsi_device (for its own stub mipi_dsi_driver).
For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's attach() step like adv7533 uses means that we aren't able to delay the mipi_dsi_device creation until the mipi_dsi_host is present.
To fix this, we extend mipi_dsi_device_register_full() to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.
--- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++---------- include/drm/drm_mipi_dsi.h | 3 +++ 2 files changed, 41 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_mipi_dsi.c +38 -11
@@ -45,6 +45,13 @@* subset of the MIPI DCS command set. */ +static DEFINE_MUTEX (host_lock); +static LIST_HEAD (host_list); +/* List of struct mipi_dsi_device which were registered while no host +* was available. +*/ +static LIST_HEAD (unattached_device_list); +static int mipi_dsi_device_match (struct device *dev,struct device_driver *drv) {struct mipi_dsi_device *dsi =to_mipi_dsi_device (dev);
@@ -138,10 +145,12 @@ static struct mipi_dsi_device *mipi_dsi_device_alloc(struct mipi_dsi_host *host) dsi->host = host; dsi->dev.bus = &mipi_dsi_bus_type; - dsi->dev.parent = host->dev; dsi->dev.type = &mipi_dsi_device_type; -device_initialize (&dsi->dev); +if (dsi->host) { + dsi->dev.parent = host->dev; +device_initialize (&dsi->dev); + }return dsi; }
@@ -206,7 +215,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, const struct mipi_dsi_device_info *info) {struct mipi_dsi_device *dsi; -struct device *dev = host->dev; +struct device *dev = host ? host->dev :NULL ;int ret;if (!info) {
@@ -230,11 +239,17 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, dsi->channel = info->channel;strlcpy (dsi->name, info->type,sizeof (dsi->name)); - ret =mipi_dsi_device_add (dsi); -if (ret) { -dev_err (dev,"failed to add DSI device %d\n" , ret); -kfree (dsi); -return ERR_PTR (ret); +if (!dsi->host) { +mutex_lock (&host_lock); +list_add (&dsi->list, &unattached_device_list); +mutex_unlock (&host_lock); + }else { + ret =mipi_dsi_device_add (dsi); +if (ret) { +dev_err (dev,"failed to add DSI device %d\n" , ret); +kfree (dsi); +return ERR_PTR (ret); + } }return dsi;
@@ -251,9 +266,6 @@ void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi) }EXPORT_SYMBOL (mipi_dsi_device_unregister); -static DEFINE_MUTEX (host_lock); -static LIST_HEAD (host_list); -/** * of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a * device tree node
@@ -285,6 +297,7 @@ EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);int mipi_dsi_host_register (struct mipi_dsi_host *host) {struct device_node *node; +struct mipi_dsi_device *dsi, *temp;for_each_available_child_of_node (host->dev->of_node, node) {/* skip nodes without reg property */
@@ -295,6 +308,20 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)mutex_lock (&host_lock);list_add_tail (&host->list, &host_list); + +/* If any DSI devices were registered under our OF node, then +* connect our host to it and probe them now. +*/ +list_for_each_entry_safe (dsi, temp, &unattached_device_list, list) { +if (of_get_parent (dsi->dev.of_node) == host->dev->of_node) { + dsi->host = host; + dsi->dev.parent = host->dev; +device_initialize (&dsi->dev); + +mipi_dsi_device_add (dsi); +list_del_init (&dsi->list); + } + }mutex_unlock (&host_lock);return 0 ;
include/drm/drm_mipi_dsi.h +3 -0
@@ -178,6 +178,9 @@ struct mipi_dsi_device {unsigned int lanes;enum mipi_dsi_pixel_format format;unsigned long mode_flags; + +/* Entry on the unattached_device_list */ +struct list_head list; };#define MIPI_DSI_MODULE_PREFIX "mipi-dsi:"
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.
Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.
This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (mipi_dsi_devs) and non-child nodes (i2c control bus).
For DSI children expressed in DT, the of_node in info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.
Thanks,
Archit
Quoted 126 lines
Signed-off-by Eric Anholt <[email protected]>--- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++---------- include/drm/drm_mipi_dsi.h | 3 +++ 2 files changed, 41 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_mipi_dsi.c +38
-11@@ -45,6 +45,13 @@* subset of the MIPI DCS command set. */ +static DEFINE_MUTEX (host_lock); +static LIST_HEAD (host_list); +/* List of struct mipi_dsi_device which were registered while no host +* was available. +*/ +static LIST_HEAD (unattached_device_list); +static int mipi_dsi_device_match (struct device *dev,struct device_driver *drv) {struct mipi_dsi_device *dsi =to_mipi_dsi_device (dev);@@ -138,10 +145,12 @@ static struct mipi_dsi_device *mipi_dsi_device_alloc(struct mipi_dsi_host *host) dsi->host = host; dsi->dev.bus = &mipi_dsi_bus_type; - dsi->dev.parent = host->dev; dsi->dev.type = &mipi_dsi_device_type; -device_initialize (&dsi->dev); +if (dsi->host) { + dsi->dev.parent = host->dev; +device_initialize (&dsi->dev); + }return dsi; }@@ -206,7 +215,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, const struct mipi_dsi_device_info *info) {struct mipi_dsi_device *dsi; -struct device *dev = host->dev; +struct device *dev = host ? host->dev :NULL ;int ret;if (!info) {@@ -230,11 +239,17 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, dsi->channel = info->channel;strlcpy (dsi->name, info->type,sizeof (dsi->name)); - ret =mipi_dsi_device_add (dsi); -if (ret) { -dev_err (dev,"failed to add DSI device %d\n" , ret); -kfree (dsi); -return ERR_PTR (ret); +if (!dsi->host) { +mutex_lock (&host_lock); +list_add (&dsi->list, &unattached_device_list); +mutex_unlock (&host_lock); + }else { + ret =mipi_dsi_device_add (dsi); +if (ret) { +dev_err (dev,"failed to add DSI device %d\n" , ret); +kfree (dsi); +return ERR_PTR (ret); + } }return dsi;@@ -251,9 +266,6 @@ void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi) }EXPORT_SYMBOL (mipi_dsi_device_unregister); -static DEFINE_MUTEX (host_lock); -static LIST_HEAD (host_list); -/** * of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a * device tree node @@ -285,6 +297,7 @@ EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);int mipi_dsi_host_register (struct mipi_dsi_host *host) {struct device_node *node; +struct mipi_dsi_device *dsi, *temp;for_each_available_child_of_node (host->dev->of_node, node) {/* skip nodes without reg property */ @@ -295,6 +308,20 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)mutex_lock (&host_lock);list_add_tail (&host->list, &host_list); + +/* If any DSI devices were registered under our OF node, then +* connect our host to it and probe them now. +*/ +list_for_each_entry_safe (dsi, temp, &unattached_device_list, list) { +if (of_get_parent (dsi->dev.of_node) == host->dev->of_node) { + dsi->host = host; + dsi->dev.parent = host->dev; +device_initialize (&dsi->dev); + +mipi_dsi_device_add (dsi); +list_del_init (&dsi->list); + } + }mutex_unlock (&host_lock);return 0 ;include/drm/drm_mipi_dsi.h +3
-0@@ -178,6 +178,9 @@ struct mipi_dsi_device {unsigned int lanes;enum mipi_dsi_pixel_format format;unsigned long mode_flags; + +/* Entry on the unattached_device_list */ +struct list_head list; };#define MIPI_DSI_MODULE_PREFIX "mipi-dsi:"
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
Quoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).
Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.
Field abuse is not a biggest issue.
This patch changes totally semantic of mipi_dsi_device_register_full. Currently semantic of *_device_register* function is to create and add device to existing bus, ie after return we have device attached to bus, so it can be instantly used. With this change function can return some unattached device, without warranty it will be ever attached - kind of hidden deferring. Such change looks for me quite dangerous, even if it looks convenient in this case.
As discussed in other thread more appealing solution for me would be:
1. host creates dsi bus, but doesn't call component_add as it does not have all required resources.
2. host waits for all required dsi devs attached, gets registered panels or bridges and calls component_add after that.
3. in bind phase it has all it needs, hasn't it?
I did not spent much time on this idea, so I cannot guarantee it has not fundamental issues :)
Regards
Andrzej
Quoted 127 lines
Thanks,
ArchitQuoted 123 lines
Signed-off-by Eric Anholt <[email protected]>--- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++---------- include/drm/drm_mipi_dsi.h | 3 +++ 2 files changed, 41 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_mipi_dsi.c +38
-11@@ -45,6 +45,13 @@* subset of the MIPI DCS command set. */ +static DEFINE_MUTEX (host_lock); +static LIST_HEAD (host_list); +/* List of struct mipi_dsi_device which were registered while no host +* was available. +*/ +static LIST_HEAD (unattached_device_list); +static int mipi_dsi_device_match (struct device *dev,struct device_driver *drv) {struct mipi_dsi_device *dsi =to_mipi_dsi_device (dev);@@ -138,10 +145,12 @@ static struct mipi_dsi_device *mipi_dsi_device_alloc(struct mipi_dsi_host *host) dsi->host = host; dsi->dev.bus = &mipi_dsi_bus_type; - dsi->dev.parent = host->dev; dsi->dev.type = &mipi_dsi_device_type; -device_initialize (&dsi->dev); +if (dsi->host) { + dsi->dev.parent = host->dev; +device_initialize (&dsi->dev); + }return dsi; }@@ -206,7 +215,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, const struct mipi_dsi_device_info *info) {struct mipi_dsi_device *dsi; -struct device *dev = host->dev; +struct device *dev = host ? host->dev :NULL ;int ret;if (!info) {@@ -230,11 +239,17 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, dsi->channel = info->channel;strlcpy (dsi->name, info->type,sizeof (dsi->name)); - ret =mipi_dsi_device_add (dsi); -if (ret) { -dev_err (dev,"failed to add DSI device %d\n" , ret); -kfree (dsi); -return ERR_PTR (ret); +if (!dsi->host) { +mutex_lock (&host_lock); +list_add (&dsi->list, &unattached_device_list); +mutex_unlock (&host_lock); + }else { + ret =mipi_dsi_device_add (dsi); +if (ret) { +dev_err (dev,"failed to add DSI device %d\n" , ret); +kfree (dsi); +return ERR_PTR (ret); + } }return dsi;@@ -251,9 +266,6 @@ void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi) }EXPORT_SYMBOL (mipi_dsi_device_unregister); -static DEFINE_MUTEX (host_lock); -static LIST_HEAD (host_list); -/** * of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a * device tree node @@ -285,6 +297,7 @@ EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);int mipi_dsi_host_register (struct mipi_dsi_host *host) {struct device_node *node; +struct mipi_dsi_device *dsi, *temp;for_each_available_child_of_node (host->dev->of_node, node) {/* skip nodes without reg property */ @@ -295,6 +308,20 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)mutex_lock (&host_lock);list_add_tail (&host->list, &host_list); + +/* If any DSI devices were registered under our OF node, then +* connect our host to it and probe them now. +*/ +list_for_each_entry_safe (dsi, temp, &unattached_device_list, list) { +if (of_get_parent (dsi->dev.of_node) == host->dev->of_node) { + dsi->host = host; + dsi->dev.parent = host->dev; +device_initialize (&dsi->dev); + +mipi_dsi_device_add (dsi); +list_del_init (&dsi->list); + } + }mutex_unlock (&host_lock);return 0 ;include/drm/drm_mipi_dsi.h +3
-0@@ -178,6 +178,9 @@ struct mipi_dsi_device {unsigned int lanes;enum mipi_dsi_pixel_format format;unsigned long mode_flags; + +/* Entry on the unattached_device_list */ +struct list_head list; };
Quoted 2 lines
include/drm/drm_mipi_dsi.h struct mipi_dsi_device { · line 186
Quoted 2 lines
include/drm/drm_mipi_dsi.h +0
-0#define MIPI_DSI_MODULE_PREFIX "mipi-dsi:"
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
Quoted 33 lines · Andrzej Hajda
Quoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.Field abuse is not a biggest issue.
Quoted 7 lines
This patch changes totally semantic of
mipi_dsi_device_register_full. Currently semantic of *_device_register* function is to create and add device to existing bus, ie after return we have device attached to bus, so it can be instantly used. With this change function can return some unattached device, without warranty it will be ever attached - kind of hidden deferring. Such change looks for me quite dangerous, even if it looks convenient in this case.
It only changes the semantic if you past in a NULL host, from "oops" to "do something useful".
Quoted 9 lines
As discussed in other thread more appealing solution for me would be:
1. host creates dsi bus, but doesn't callcomponent_addas it does not have all required resources.
2. host waits for all required dsi devs attached, gets registered panels or bridges and callscomponent_addafter that.
3. in bind phase it has all it needs, hasn't it?I did not spent much time on this idea, so I cannot guarantee it has not fundamental issues :)
If component_add() isn't called during probe, then DSI would just get skipped during bind as far as I know.
I *think* what you're thinking is moving DSI host register to probe, and then panel lookup stays in bind. That seems much more risky to me -- do we know for sure that no mipi_dsi_device will do any DSI transactions during its probe? I would expect some of them to.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
Quoted 50 lines · Eric Anholt
Quoted 31 lines · Andrzej Hajda
Quoted 23 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.Field abuse is not a biggest issue.
Quoted 7 lines
This patch changes totally semantic of
mipi_dsi_device_register_full. Currently semantic of *_device_register* function is to create and add device to existing bus, ie after return we have device attached to bus, so it can be instantly used. With this change function can return some unattached device, without warranty it will be ever attached - kind of hidden deferring. Such change looks for me quite dangerous, even if it looks convenient in this case.It only changes the semantic if you past in a NULL host, from "oops" to "do something useful".
Quoted 7 lines
As discussed in other thread more appealing solution for me would be:
1. host creates dsi bus, but doesn't callcomponent_addas it does not have all required resources.
2. host waits for all required dsi devs attached, gets registered panels or bridges and callscomponent_addafter that.
3. in bind phase it has all it needs, hasn't it?
Quoted 4 lines
Quoted 2 lines
I did not spent much time on this idea, so I cannot guarantee it has not fundamental issues :)
If
component_add()isn't called during probe, then DSI would just get skipped during bind as far as I know.
No, drm master will wait till all components are present.
Quoted 2 lines
I *think* what you're thinking is moving DSI host register to probe,
yes, this way you will allow to create dsi devices.
Quoted 2 lines
and
then panel lookup stays in bind.
no, panel lookup will be performed in dsi_host attach callback, and component_add will be called also there, if all required panels/bridges are get.
Quoted 3 lines
That seems much more risky to me -- do
we know for sure that nomipi_dsi_devicewill do any DSI transactions during its probe? I would expect some of them to.
I think it is irrelevant, with the current design only transactions between prepare/unprepare callbacks have chances to succeed.
Andrzej
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
In reply to Andrzej HajdaQuoted 41 lines · Andrzej Hajda
Quoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.Field abuse is not a biggest issue.
This patch changes totally semantic of
mipi_dsi_device_register_full. Currently semantic of *_device_register* function is to create and add device to existing bus, ie after return we have device attached to bus, so it can be instantly used. With this change function can return some unattached device, without warranty it will be ever attached - kind of hidden deferring. Such change looks for me quite dangerous, even if it looks convenient in this case.
Quoted 6 lines
As discussed in other thread more appealing solution for me would be:
1. host creates dsi bus, but doesn't callcomponent_addas it does not have all required resources.
2. host waits for all required dsi devs attached, gets registered panels or bridges and callscomponent_addafter that.
3. in bind phase it has all it needs, hasn't it?
This seems like it would work, but would require KMS drivers to restructure themselves around this approach. For KMS drivers that don't even use the component stuff, it might be asking too much.
We could maybe consider Eric's patch as an intermediate solution, we should definitely put WARN_ON(!dsi->host) like checks for all the existing mipi_dsi_*() API.
About the solution that you and Boris discussed in the other thread, I'll give this a try on the msm driver and see how it does.
Thanks,
Archit
Quoted 137 lines
I did not spent much time on this idea, so I cannot guarantee it has not fundamental issues :)
Regards
AndrzejQuoted 129 lines
Thanks,
ArchitQuoted 125 lines
Signed-off-by Eric Anholt <[email protected]>--- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++---------- include/drm/drm_mipi_dsi.h | 3 +++ 2 files changed, 41 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_mipi_dsi.c +38
-11@@ -45,6 +45,13 @@* subset of the MIPI DCS command set. */ +static DEFINE_MUTEX (host_lock); +static LIST_HEAD (host_list); +/* List of struct mipi_dsi_device which were registered while no host +* was available. +*/ +static LIST_HEAD (unattached_device_list); +static int mipi_dsi_device_match (struct device *dev,struct device_driver *drv) {struct mipi_dsi_device *dsi =to_mipi_dsi_device (dev);@@ -138,10 +145,12 @@ static struct mipi_dsi_device *mipi_dsi_device_alloc(struct mipi_dsi_host *host) dsi->host = host; dsi->dev.bus = &mipi_dsi_bus_type; - dsi->dev.parent = host->dev; dsi->dev.type = &mipi_dsi_device_type; -device_initialize (&dsi->dev); +if (dsi->host) { + dsi->dev.parent = host->dev; +device_initialize (&dsi->dev); + }return dsi; }@@ -206,7 +215,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, const struct mipi_dsi_device_info *info) {struct mipi_dsi_device *dsi; -struct device *dev = host->dev; +struct device *dev = host ? host->dev :NULL ;int ret;if (!info) {@@ -230,11 +239,17 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, dsi->channel = info->channel;strlcpy (dsi->name, info->type,sizeof (dsi->name)); - ret =mipi_dsi_device_add (dsi); -if (ret) { -dev_err (dev,"failed to add DSI device %d\n" , ret); -kfree (dsi); -return ERR_PTR (ret); +if (!dsi->host) { +mutex_lock (&host_lock); +list_add (&dsi->list, &unattached_device_list); +mutex_unlock (&host_lock); + }else { + ret =mipi_dsi_device_add (dsi); +if (ret) { +dev_err (dev,"failed to add DSI device %d\n" , ret); +kfree (dsi); +return ERR_PTR (ret); + } }return dsi;@@ -251,9 +266,6 @@ void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi) }EXPORT_SYMBOL (mipi_dsi_device_unregister); -static DEFINE_MUTEX (host_lock); -static LIST_HEAD (host_list); -/** * of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a * device tree node @@ -285,6 +297,7 @@ EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);int mipi_dsi_host_register (struct mipi_dsi_host *host) {struct device_node *node; +struct mipi_dsi_device *dsi, *temp;for_each_available_child_of_node (host->dev->of_node, node) {/* skip nodes without reg property */ @@ -295,6 +308,20 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)mutex_lock (&host_lock);list_add_tail (&host->list, &host_list); + +/* If any DSI devices were registered under our OF node, then +* connect our host to it and probe them now. +*/ +list_for_each_entry_safe (dsi, temp, &unattached_device_list, list) { +if (of_get_parent (dsi->dev.of_node) == host->dev->of_node) { + dsi->host = host; + dsi->dev.parent = host->dev; +device_initialize (&dsi->dev); + +mipi_dsi_device_add (dsi); +list_del_init (&dsi->list); + } + }mutex_unlock (&host_lock);return 0 ;include/drm/drm_mipi_dsi.h +3
-0@@ -178,6 +178,9 @@ struct mipi_dsi_device {unsigned int lanes;enum mipi_dsi_pixel_format format;unsigned long mode_flags; + +/* Entry on the unattached_device_list */ +struct list_head list; };#define MIPI_DSI_MODULE_PREFIX "mipi-dsi:"
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
Quoted 49 lines · Archit Taneja
Quoted 41 lines · Andrzej Hajda
Quoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.Field abuse is not a biggest issue.
This patch changes totally semantic of
mipi_dsi_device_register_full. Currently semantic of *_device_register* function is to create and add device to existing bus, ie after return we have device attached to bus, so it can be instantly used. With this change function can return some unattached device, without warranty it will be ever attached - kind of hidden deferring. Such change looks for me quite dangerous, even if it looks convenient in this case.Quoted 6 lines
As discussed in other thread more appealing solution for me would be:
1. host creates dsi bus, but doesn't callcomponent_addas it does not have all required resources.
2. host waits for all required dsi devs attached, gets registered panels or bridges and callscomponent_addafter that.
3. in bind phase it has all it needs, hasn't it?
Quoted 7 lines
This seems like it would work, but would require KMS drivers to restructure themselves around this approach. For KMS drivers that don't even use the component stuff, it might be asking too much.
We could maybe consider Eric's patch as an intermediate solution, we should definitely put
WARN_ON(!dsi->host)like checks for all the existing mipi_dsi_*() API.
Could you clarify which entrypoints you'd like a warning on? Is it just "everything that gets the host ops"?
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
Quoted 55 lines · Eric Anholt
Quoted 53 lines · Archit Taneja
Quoted 41 lines · Andrzej Hajda
Quoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.Field abuse is not a biggest issue.
This patch changes totally semantic of
mipi_dsi_device_register_full. Currently semantic of *_device_register* function is to create and add device to existing bus, ie after return we have device attached to bus, so it can be instantly used. With this change function can return some unattached device, without warranty it will be ever attached - kind of hidden deferring. Such change looks for me quite dangerous, even if it looks convenient in this case.Quoted 6 lines
As discussed in other thread more appealing solution for me would be:
1. host creates dsi bus, but doesn't callcomponent_addas it does not have all required resources.
2. host waits for all required dsi devs attached, gets registered panels or bridges and callscomponent_addafter that.
3. in bind phase it has all it needs, hasn't it?This seems like it would work, but would require KMS drivers to restructure themselves around this approach. For KMS drivers that don't even use the component stuff, it might be asking too much.
Quoted 6 lines
Quoted 3 lines
We could maybe consider Eric's patch as an intermediate solution, we should definitely put
WARN_ON(!dsi->host)like checks for all the existing mipi_dsi_*() API.Could you clarify which entrypoints you'd like a warning on? Is it just "everything that gets the host ops"?
Sorry, all API was a bad suggestion.
I think a warning and early bail in mipi_dsi_attach() should be sufficient. A panel/bridge DSI device shouldn't use any other API if it hasn't called mipi_dsi_attach().
Thanks,
Archit
Quoted 1 line
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
In reply to Archit TanejaQuoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).
Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.
I think maybe you misread the patch? We're using of_get_parent(dsi->dev.node), which came from info->node, to compare to host->dev->of_node().
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
Quoted 32 lines · Eric Anholt
Quoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.
Quoted 3 lines
I think maybe you misread the patch? We're using
of_get_parent(dsi->dev.node), which came frominfo->node, to compare tohost->dev->of_node().
I think I did misread it.
Although, I'm not entirely clear what we should be setting info.node to. In patch #8, info.node is set by:
endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); info.node = of_graph_get_remote_port(endpoint);
Looking at the dt bindings in patch #7, it looks like info.node is set to the 'port' device node in dsi@7e700000, is that right?
I suppose 'port' here seems like a reasonable representation of dsi->dev.node, I wonder how it would work if the dsi host had multiple ports underneath it. I.e:
dsi@7e700000 {
...
...
ports {
port@0 {
...
dsi_out_port: endpoint {
remote-endpoint = <&panel_dsi_port>;
};
};
port@1 {
...
...
};
};
};Here, we would need to set info.node to the 'ports' node, so that of_get_parent(dsi->dev.of_node) equals host->dev->of_node. That doesn't seem correct.
Ideally, a dev's 'of_node' should be left to NULL if we don't have a corresponding OF node. We're sort of overriding it here since we don't have any other place to store this information in the mipi_dsi_device struct.
Maybe we could add a 'host_node' entry in mipi_dsi_device itself, which is exclusively used cases where the DSI device doesn't have a DT node. Our check in mipi_dsi_host_register() could then be something like:
if (dsi->host_node) == host->dev->of_node) {
...
...
}Since Thierry also reviews drm_mipi_dsi.c changes, it would nice to get some comments from him too.
Thanks,
Archit
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
Quoted 39 lines · Archit Taneja
Quoted 32 lines · Eric Anholt
Quoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.Quoted 3 lines
I think maybe you misread the patch? We're using
of_get_parent(dsi->dev.node), which came frominfo->node, to compare tohost->dev->of_node().I think I did misread it.
Quoted 8 lines
Although, I'm not entirely clear what we should be setting info.node to. In patch #8, info.node is set by:
endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); info.node = of_graph_get_remote_port(endpoint);Looking at the dt bindings in patch #7, it looks like info.node is set to the 'port' device node in dsi@7e700000, is that right?
Yeah.
Quoted 25 lines
I suppose 'port' here seems like a reasonable representation of
dsi->dev.node, I wonder how it would work if the dsi host had multiple ports underneath it. I.e:dsi@7e700000 { ... ... ports { port@0 { ... dsi_out_port: endpoint { remote-endpoint = <&panel_dsi_port>; }; }; port@1 { ... ... }; }; };Here, we would need to set info.node to the 'ports' node, so that
of_get_parent(dsi->dev.of_node)equalshost->dev->of_node. That doesn't seem correct.
Quoted 8 lines
Ideally, a dev's '
of_node' should be left to NULL if we don't have a corresponding OF node. We're sort of overriding it here since we don't have any other place to store this information in themipi_dsi_devicestruct.Maybe we could add a '
host_node' entry inmipi_dsi_deviceitself, which is exclusively used cases where the DSI device doesn't have a DT node. Our check inmipi_dsi_host_register()could then be something like:
I think instead of extending the struct, we can just walk to the parent similarly to how of_graph_get_remove_port_parent() does. And fix some node refcounting at the same time:
drivers/gpu/drm/drm_mipi_dsi.c +8 -1
@@ -313,7 +313,12 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)* connect our host to it and probe them now. */ list_for_each_entry_safe (dsi, temp, &unattached_device_list, list) { -if (of_get_parent (dsi->dev.of_node) == host->dev->of_node) { +struct device_node *host_node =of_get_parent (dsi->dev.of_node); + +if (!of_node_cmp (host_node->name,"ports" )) + host_node =of_get_next_parent (host_node); + +if (host_node == host->dev->of_node) { dsi->host = host; dsi->dev.parent = host->dev;device_initialize (&dsi->dev);
@@ -321,6 +326,8 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)mipi_dsi_device_add (dsi);list_del_init (&dsi->list); } + +of_node_put (host_node); }mutex_unlock (&host_lock);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Archit Taneja
Reviewed-byRe: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
Quoted 83 lines · Eric Anholt
Quoted 39 lines · Archit Taneja
Quoted 32 lines · Eric Anholt
Quoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.Quoted 3 lines
I think maybe you misread the patch? We're using
of_get_parent(dsi->dev.node), which came frominfo->node, to compare tohost->dev->of_node().I think I did misread it.
Quoted 8 lines
Although, I'm not entirely clear what we should be setting info.node to. In patch #8, info.node is set by:
endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); info.node = of_graph_get_remote_port(endpoint);Looking at the dt bindings in patch #7, it looks like info.node is set to the 'port' device node in dsi@7e700000, is that right?
Yeah.
Quoted 30 lines
I suppose 'port' here seems like a reasonable representation of
dsi->dev.node, I wonder how it would work if the dsi host had multiple ports underneath it. I.e:dsi@7e700000 { ... ... ports { port@0 { ... dsi_out_port: endpoint { remote-endpoint = <&panel_dsi_port>; }; }; port@1 { ... ... }; }; };Here, we would need to set info.node to the 'ports' node, so that
of_get_parent(dsi->dev.of_node)equalshost->dev->of_node. That doesn't seem correct.Ideally, a dev's '
of_node' should be left to NULL if we don't have a corresponding OF node. We're sort of overriding it here since we don't have any other place to store this information in themipi_dsi_devicestruct.
Quoted 7 lines
Quoted 3 lines
Maybe we could add a '
host_node' entry inmipi_dsi_deviceitself, which is exclusively used cases where the DSI device doesn't have a DT node. Our check inmipi_dsi_host_register()could then be something like:I think instead of extending the struct, we can just walk to the parent similarly to how
of_graph_get_remove_port_parent()does. And fix some node refcounting at the same time:
Yeah, I guess this works. The only thing that's a slight irritant is that we're setting an 'of_node' to a device that doesn't have a DT representation. But I don't have any strong feelings against it.
Quoted 29 lines
drivers/gpu/drm/drm_mipi_dsi.c +8
-1@@ -313,7 +313,12 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)* connect our host to it and probe them now. */ list_for_each_entry_safe (dsi, temp, &unattached_device_list, list) { -if (of_get_parent (dsi->dev.of_node) == host->dev->of_node) { +struct device_node *host_node =of_get_parent (dsi->dev.of_node); + +if (!of_node_cmp (host_node->name,"ports" )) + host_node =of_get_next_parent (host_node); + +if (host_node == host->dev->of_node) { dsi->host = host; dsi->dev.parent = host->dev;device_initialize (&dsi->dev);@@ -321,6 +326,8 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)mipi_dsi_device_add (dsi);list_del_init (&dsi->list); } + +of_node_put (host_node); }mutex_unlock (&host_lock);
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm: Allow DSI devices to be registered before the host registers.
In reply to Eric AnholtHi all,
Sorry to enter the discussion so late in the review process.
Eric, I'm replying here because this is where the initial discussion happened, but I actually reviewed v5 of your patchset.
Quoted 44 lines · On Tue, 18 Jul 2017 13:13:04 -0700 Eric Anholt <[email protected]> wrote:
Quoted 42 lines · Archit Taneja
Quoted 32 lines · Eric Anholt
Quoted 24 lines · Archit Taneja
Quoted 14 lines · Eric Anholt
When a
mipi_dsi_hostis registered, the DT is walked to find any child nodes with compatible strings. Those get registered as DSI devices, and most DSI panel drivers aremipi_dsi_driversthat attach to those nodes.There is one special case currently, the adv7533 bridge, where the bridge probes on I2C, and during the bridge attach step it looks up the
mipi_dsi_hostand registers themipi_dsi_device(for its own stubmipi_dsi_driver).For the Raspberry Pi panel, though, we also need to attach on I2C (our control bus), but don't have a bridge driver. The lack of a bridge's
attach()step like adv7533 uses means that we aren't able to delay themipi_dsi_devicecreation until themipi_dsi_hostis present.Quoted 4 lines
To fix this, we extend
mipi_dsi_device_register_full()to allow being called with a NULL host, which puts the device on a queue waiting for a host to appear. When a new host is registered, we fill in the host value and finish the device creation process.This is quite a nice idea. The only bothering thing is the info.of_node usage varies between child nodes (
mipi_dsi_devs) and non-child nodes (i2c control bus).Quoted 5 lines
For DSI children expressed in DT, the
of_nodein info holds the DT node corresponding to the DSI child itself. For non-DT ones, this patch assumes that info.of_node stores the DSI host DT node. I think it should be okay as long as we mention the usage in a comment somewhere. The other option is to have a new info.host_node field to keep a track of the host DT node.Quoted 3 lines
I think maybe you misread the patch? We're using
of_get_parent(dsi->dev.node), which came frominfo->node, to compare tohost->dev->of_node().I think I did misread it.
Although, I'm not entirely clear what we should be setting info.node to. In patch #8, info.node is set by:
Quoted 33 lines
Quoted 5 lines
endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); info.node = of_graph_get_remote_port(endpoint);Looking at the dt bindings in patch #7, it looks like info.node is set to the 'port' device node in dsi@7e700000, is that right?
Yeah.
Quoted 24 lines
I suppose 'port' here seems like a reasonable representation of
dsi->dev.node, I wonder how it would work if the dsi host had multiple ports underneath it. I.e:dsi@7e700000 { ... ... ports { port@0 { ... dsi_out_port: endpoint { remote-endpoint = <&panel_dsi_port>; }; }; port@1 { ... ... }; }; };Here, we would need to set info.node to the 'ports' node, so that
of_get_parent(dsi->dev.of_node)equalshost->dev->of_node. That doesn't seem correct.
I agree. I think we're abusing dev->of_node here, which makes the whole thing even harder to understand.
Quoted 3 lines
Quoted 3 lines
Ideally, a dev's '
of_node' should be left to NULL if we don't have a corresponding OF node.
Well, there are cases where the device actually has a valid OF node, like the adv7533, but this device is defined under a different control bus (i2c in this case). So, to be accurate with the DT representation, dsi->dev.of_node should be set to the adv7533 OF node (the one under the I2C bus), right?
Quoted 6 lines
Quoted 6 lines
We're sort of overriding it here since we don't
have any other place to store this information in themipi_dsi_devicestruct.Maybe we could add a '
host_node' entry inmipi_dsi_deviceitself, which is exclusively used cases where the DSI device doesn't have a DT node.
I think that would be clearer.
Quoted 4 lines
Quoted 1 line
Our check in
mipi_dsi_host_register()could then be something like:I think instead of extending the struct, we can just walk to the parent similarly to how
of_graph_get_remove_port_parent()does.
It's working as long as dsi->dev.of_node points to one of the port node defined under the DSI host, but is this node really representing the DSI device?
Sure, your solution works, but it makes the whole DSI registration even harder to follow.
Quoted 22 lines
And fix some
node refcounting at the same time:drivers/gpu/drm/drm_mipi_dsi.c +6
-1@@ -313,7 +313,12 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)* connect our host to it and probe them now. */ list_for_each_entry_safe (dsi, temp, &unattached_device_list, list) { -if (of_get_parent (dsi->dev.of_node) == host->dev->of_node) { +struct device_node *host_node =of_get_parent (dsi->dev.of_node); + +if (!of_node_cmp (host_node->name,"ports" )) + host_node =of_get_next_parent (host_node); + +if (host_node == host->dev->of_node) { dsi->host = host; dsi->dev.parent = host->dev;device_initialize (&dsi->dev);
drivers/gpu/drm/drm_mipi_dsi.c int mipi_dsi_host_register(struct mipi_dsi_host *host) · line 333
Quoted 8 lines
drivers/gpu/drm/drm_mipi_dsi.c +2
-0@@ -321,6 +326,8 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)mipi_dsi_device_add (dsi);list_del_init (&dsi->list); } + +of_node_put (host_node); }mutex_unlock (&host_lock);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/8 dt-bindings: Document the Raspberry Pi Touchscreen nodes.
In reply to Eric AnholtThis doesn't yet cover input, but the driver does get the display working when the firmware is disabled from talking to our I2C lines.
--- .../panel/raspberrypi,7inch-touchscreen.txt | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/raspberrypi,7inch-touchscreen.txt
Documentation/devicetree/bindings/display/panel/raspberrypi,7inch-touchscreen.txt new file +49 -0
@@ -0,0 +1,49 @@ +This binding covers the official 7" (800x480) Raspberry Pi touchscreen +panel. + +This DSI panel contains: + +- TC358762 DSI->DPI bridge +- Atmel microcontroller on I2C for power sequencing the DSI bridge and + controlling backlight +- Touchscreen controller on I2C for touch input + +and this binding covers the DSI display parts but not its touch input. + +Required properties: +- compatible: Must be "raspberrypi,7inch-touchscreen-panel" +- reg: Must be "45" +- port: See panel-common.txt + +Example: + +dsi1: dsi@7e700000 { + #address-cells = <1>; + #size-cells = <0>; + <...> + + port { + dsi_out_port: endpoint { + remote-endpoint = <&panel_dsi_port>; + }; + }; +}; + +i2c_dsi: i2c { + compatible = "i2c-gpio"; + #address-cells = <1>; + #size-cells = <0>; + gpios = <&gpio 28 0 + &gpio 29 0>; + + lcd@45 { + compatible = "raspberrypi,7inch-touchscreen-panel"; + reg = <0x45>; + + port { + panel_dsi_port: endpoint { + remote-endpoint = <&dsi_out_port>; + }; + }; + }; +};
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/8 drm/panel: Add support for the Raspberry Pi 7" Touchscreen.
In reply to Eric AnholtThis driver communicates with the Atmel microcontroller for sequencing the poweron of the TC358762 DSI-DPI bridge and controlling the backlight PWM.
v2: Set the same default orientation as the closed source firmware
used, which is the best for viewing angle.
v3: Rewrite as an i2c client driver after bridge driver rejection.
v4: Finish probe without the DSI host, using the new delayed
registration, and attach to the host during mipi_dsi_driver probe.
--- drivers/gpu/drm/panel/Kconfig | 8 + drivers/gpu/drm/panel/Makefile | 1 + .../gpu/drm/panel/panel-raspberrypi-touchscreen.c | 505 +++++++++++++++++++++ 3 files changed, 514 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
drivers/gpu/drm/panel/Kconfig +8 -0
@@ -73,6 +73,14 @@ config DRM_PANEL_PANASONIC_VVX10F034N00 WUXGA (1920x1200) Novatek NT1397-based DSI panel as found in some Xperia Z2 tablets +config DRM_PANEL_RASPBERRYPI_TOUCHSCREEN + tristate "Raspberry Pi 7-inch touchscreen panel" + depends on DRM_MIPI_DSI + help + Say Y here if you want to enable support for the Raspberry + Pi 7" Touchscreen. To compile this driver as a module, + choose M here. + config DRM_PANEL_SAMSUNG_S6E3HA2 tristate "Samsung S6E3HA2 DSI video mode panel" depends on OF
drivers/gpu/drm/panel/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_DRM_PANEL_INNOLUX_P079ZCA) += panel-innolux-p079zca.o obj-$(CONFIG_DRM_PANEL_JDI_LT070ME05000) += panel-jdi-lt070me05000.o obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += panel-panasonic-vvx10f034n00.o +obj-$(CONFIG_DRM_PANEL_RASPBERRYPI_TOUCHSCREEN) += panel-raspberrypi-touchscreen.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c new file +505 -0
505 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel