Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757081AbbLAUiu (ORCPT ); Tue, 1 Dec 2015 15:38:50 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:60508 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756938AbbLAUis (ORCPT ); Tue, 1 Dec 2015 15:38:48 -0500 From: Felipe Balbi To: Heikki Krogerus , Chanwoo Choi , Greg Kroah-Hartman CC: MyungJoo Ham , David Cohen , Lu Baolu , Mathias Nyman , , Subject: Re: [PATCH 2/2] usb: pci-quirks: register USB mux found on Cherrytrail SOC In-Reply-To: <1448976758-35807-3-git-send-email-heikki.krogerus@linux.intel.com> References: <1448976758-35807-1-git-send-email-heikki.krogerus@linux.intel.com> <1448976758-35807-3-git-send-email-heikki.krogerus@linux.intel.com> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Tue, 1 Dec 2015 14:38:38 -0600 Message-ID: <87oae9zyy9.fsf@saruman.tx.rr.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3986 Lines: 107 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Heikki Krogerus writes: > Intel Braswell/Cherrytrail has an internal mux that shares > one USB port between USB Device Controller and xHCI. The > same mux is found on several SOCs from Intel, but only on > a few Cherrytrail based platforms the OS is expected to > configure it. Normally BIOS takes care of it. > > The driver for the mux is an "extcon" driver. With this we > only register the mux if it's detected. > > Suggested-by: Lu Baolu > Signed-off-by: Heikki Krogerus > --- > drivers/usb/host/pci-quirks.c | 30 +++++++++++++++++++++++++++++- > 1 file changed, 29 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c > index f940056..4e3016a 100644 > --- a/drivers/usb/host/pci-quirks.c > +++ b/drivers/usb/host/pci-quirks.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > #include "pci-quirks.h" > #include "xhci-ext-caps.h" >=20=20 > @@ -1029,9 +1030,36 @@ static void quirk_usb_handoff_xhci(struct pci_dev = *pdev) > writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET); >=20=20 > hc_init: > - if (pdev->vendor =3D=3D PCI_VENDOR_ID_INTEL) > + if (pdev->vendor =3D=3D PCI_VENDOR_ID_INTEL) { > usb_enable_intel_xhci_ports(pdev); >=20=20 > + /* > + * Initialize the internal mux that shares a port between USB > + * Device Controller and xHCI on platforms that have it. > + */ > +#define XHCI_INTEL_VENDOR_CAPS 192 > +#define XHCI_INTEL_USB_MUX_OFFSET 0x80d8 > + ext_cap_offset =3D xhci_find_next_cap_offset(base, > + XHCI_HCC_PARAMS_OFFSET); > + ext_cap_offset =3D xhci_find_ext_cap_by_id(base, ext_cap_offset, > + XHCI_INTEL_VENDOR_CAPS); > + if (ext_cap_offset) { > + struct intel_usb_mux *mux; > + struct resource r; > + > + r.start =3D pci_resource_start(pdev, 0) + > + XHCI_INTEL_USB_MUX_OFFSET; > + r.end =3D r.start + 8; > + r.flags =3D IORESOURCE_MEM; > + > + mux =3D intel_usb_mux_register(&pdev->dev, &r); > + if (IS_ERR(mux) && PTR_ERR(mux) =3D=3D -ENOTSUPP) > + dev_dbg(&pdev->dev, "USB mux not supported\n"); > + else if (IS_ERR(mux)) > + dev_err(&pdev->dev, "failed to register mux\n"); IMHO, this should be creating a child device instead of calling intel_usb_mux_register() directly. That way, your mux driver could actually _be_ a driver. Seems like all you need to do from this point is a register a simple platform_device which is a child of xhci, see platform_device_register_simple() for how to do this. Or rather, platform_device_register_rsndata() passing xhci's device pointer as parent. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWXgVPAAoJEIaOsuA1yqRErjAP/A8+MDA9EYvlVMmABSftARqr iQ2zfcjmFdmCQlMHeNcJW2iveFbkPHpXBU/Kb7Mk4Ta60qQjcsKzLmeRhFQmUti4 oig3AvtDdPVN5lUM8S+/XTlbH3HcpxOCwlrhJaM8AUiklS/yft054uRhh5Z0PJ2c 0NsbgGRIkd2qm6B6zzAHzjYr4BSFrG7wVWjQE6QQRNMA7E6cgONaW3Lf1ipAgjLQ jwwraYSBOgGsZV0mDJp7v5fuY34P3FWmqoL9s8JRahiaDsU6GX6GUbvFxPwtf/wI p+V2UsUuCmnkfXc9C41W870ezaUP0uF6TBuCylckFcX4icZcWYcRpL+M6bCCsT0S D21U0zJdalL+VdkfeXlbWuA7qYug7/hbbSMSZJGSNHTozyyXNwcududch96wpBVS Ec/09cLbCztgfLRTXInrMlbSGKLrCoVlYt9Idz+KITL6S//47OSEUjTbYXIYx2X3 giDhL+bn0Kodf5UbCnAREW3OOjmkajhZJLYvBO76sFBRpcIUrApRTaQA1dHtMgk1 1DXx8P0voa+Z6zZo10KLBgd67YXC4rTrIoSqknaq2ef3ibwB5OjwsE5GwicjawWV 2MHFbL33najhk6grRtsb5mt1j4h76R7ApC7td46rARmP/rKLHhQdAhIgwpsAX0rs Xil+Za2raCe9f22G1GfO =cu7e -----END PGP SIGNATURE----- --=-=-=-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/