Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755062AbdGSUbv (ORCPT ); Wed, 19 Jul 2017 16:31:51 -0400 Received: from anholt.net ([50.246.234.109]:36994 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754988AbdGSUbu (ORCPT ); Wed, 19 Jul 2017 16:31:50 -0400 From: Eric Anholt To: dri-devel@lists.freedesktop.org, Archit Taneja , Andrzej Hajda , Laurent Pinchart , Thierry Reding Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 4/6] drm: Allow DSI devices to be registered before the host registers. In-Reply-To: <20170718210510.12229-4-eric@anholt.net> References: <20170718210510.12229-1-eric@anholt.net> <20170718210510.12229-4-eric@anholt.net> User-Agent: Notmuch/0.22.2+1~gb0bcfaa (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Wed, 19 Jul 2017 13:31:47 -0700 Message-ID: <87pocwdv7w.fsf@eliezer.anholt.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3574 Lines: 93 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Eric Anholt writes: > When 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 node= s. > > 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. > > v2: Cleanly error out if one attempts to mipi_dsi_attach() without a > host. Fix handling of DSI with multiple devices, and OF node > refcounting. > > Signed-off-by: Eric Anholt > --- > drivers/gpu/drm/drm_mipi_dsi.c | 63 ++++++++++++++++++++++++++++++++++--= ------ > include/drm/drm_mipi_dsi.h | 3 ++ > 2 files changed, 54 insertions(+), 12 deletions(-) > > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_ds= i.c > index 1160a579e0dc..77d439254da6 100644 > --- a/drivers/gpu/drm/drm_mipi_dsi.c > +++ b/drivers/gpu/drm/drm_mipi_dsi.c > @@ -295,6 +308,27 @@ int mipi_dsi_host_register(struct mipi_dsi_host *hos= t) >=20=20 > 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) { > + struct device_node *host_node =3D of_get_parent(dsi->dev.of_node); > + > + if (!of_node_cmp(host_node->name, "ports")) > + host_node =3D of_get_next_parent(host_node); > + > + if (host_node =3D=3D host->dev->of_node) { > + dsi->host =3D host; > + dsi->dev.parent =3D host->dev; > + device_initialize(&dsi->dev); > + > + mipi_dsi_device_add(dsi); > + list_del_init(&dsi->list); > + } > + > + of_node_put(host_node); > + } Kbuild test caught that of_get_next_parent() isn't defined for !CONFIG_OF, so I've put this loop under IS_ENABLED(CONFIG_OF) for v3. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAllvwbMACgkQtdYpNtH8 nuju5A//ayhdmOCItl2IdnRgy1pkRJRzk4SzkW2daJxHWvWqgZjZvtnSZZ+CWGpV BtvRFkF+sRFNKHbkQDJ8bveyos507ZYPWfTkWS9paS3gIu/ylFaxS1Sddk7qHeWb EjEoN97suNJqEqzTNCKXy0n67SS6x949JaTvyjKUBKZf0hItQFJC/w6pXjOUTPX9 OMMX/q8Iv6V4TBQTj5COq53GiskZlhiwcO7jDr/mjNuDHpiXk4Uy5b5x6NIX0wGE vtW0Hv2d7BSzE/MfbIAQgk34A5mgCMzXwg8V1ZEObAQ/MuI9JwJvkTDGCsXCmzWI h/z4tfui7mMG3sAV15FrwGEmHkc+0eGfN9rthK9CfX23Hndcr3yq3W+c2yToQhrS rkilujMrgOVjo0uO4iYfs8eRKQuB2sEicZSRJQawHgt5NRD9xMi7NtsWYNZkSVk+ pJm8s1ZhHsPVgbekCPTtqmuCL/Iyme1QpLswdupuDS7yJZhtofu2WgpY7LQtqsvA rKvFsAudWrC43+hAU5EJ0HW2V9dFbsZLgctsK8Wub/fYYBc14w54R2Bqa3dNJz8G 17WL4KSQ8Ym1mcf0au3vSqblvP3qls9Rzv06MObNn5zCVolm1/22vgR5YzAyRbxt F0UvpKHYpfzxXBiObHFEpee6AAsYS23/Yb6PyAeMh4DVpu+0XJI= =88S6 -----END PGP SIGNATURE----- --=-=-=--