Received: by 10.192.165.148 with SMTP id m20csp178694imm; Thu, 19 Apr 2018 19:01:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx48VNO0lMSfatIyFFWDHSm4e3O98GeIs63nITxK3JxuAVYuR2So3Svje417+byG/FkgI9ipj X-Received: by 10.99.176.8 with SMTP id h8mr6928554pgf.448.1524189700201; Thu, 19 Apr 2018 19:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524189700; cv=none; d=google.com; s=arc-20160816; b=lwF7R6CjZferu1YpqOMpro+faJF42LuaxMXi81GjL6lyrwKm52Q4u485qjUPizH1vO UfLWqR5Y0sIVhtXtONX9SUKwlFW5TthxTKnFvVW9lyEFhhn66NYH0iByNFYopgDffQIa e6ZQnBN48scrtxHKbebHJ4feq9obkpXL+nhCZi3mfKT+mjIXmhN/1lGxTB4rBOxPmFQ5 7d8hEaiykpNm3ywqa2o9kzve0k7eXgcwjsvFARQJu/+2v3ptGIliWoUl1YXCn5MRO5Ds RxFlOJs0r7Fvj9vIRJQi+LdN63WwkVUOpVXvhz5g6uJs5J7jp87OhXwrlMP2/NFUYAe6 1nVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=+DCjWb08r8Gp3BM0FxQ5Au4uHvu0h9NJL/i58/IsfK4=; b=LAqD9DotHflUZYa2mrZJQkOKyU3L1IX+ZCtYA0iCf//zgR5gv+z7I6zasrjA801FF7 2NWwsB75+/keoMDRZmyYYoLXJlQ/PzUUPRomF0DWRj+fWK+l/K7M/T6RKQCmIduC4Ivb 0XxpgXJ7rZNWyoJ7DEJto3j4q00YQ+8yy9kV5NAnfN+cEda1+T5H9OIrNAr3WnUeXErk 81ltTyQrAWRwJrroIl8MJAzJnyy0TE1s3YJV+JNNwtmV4mld0KnryixZBpumSF2OQzD+ IeY1p5UHQ5M2UCXIR1R3ZhuWvvSiWl+xCIvUJrxfPmHuL+YUaxLmrTCqZJdxucsAP32l X63Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=xbRdHxcZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2-v6si4806152pli.427.2018.04.19.19.01.24; Thu, 19 Apr 2018 19:01:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=xbRdHxcZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754013AbeDTCAO (ORCPT + 99 others); Thu, 19 Apr 2018 22:00:14 -0400 Received: from mail-ve1eur01on0071.outbound.protection.outlook.com ([104.47.1.71]:51504 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753784AbeDTCAM (ORCPT ); Thu, 19 Apr 2018 22:00:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+DCjWb08r8Gp3BM0FxQ5Au4uHvu0h9NJL/i58/IsfK4=; b=xbRdHxcZlSjXyrNOvpcRnPLQc+po++d4LveJwmXjdwnxeYzFK+u1ob+G/00XCYYDnBuTrCYshW5fbZZBGNbdxTZrNlqjH5Hj6nBdZLWULDsc+7lf8I8fQb6jvabHsh2lxgkgSY/OI04Ue/C157ARZp18b0PmQsQx/RPXEYKBFOw= Received: from HE1PR04MB1450.eurprd04.prod.outlook.com (10.163.176.12) by HE1PR04MB1498.eurprd04.prod.outlook.com (10.163.176.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.14; Fri, 20 Apr 2018 02:00:08 +0000 Received: from HE1PR04MB1450.eurprd04.prod.outlook.com ([fe80::d161:29b5:cd62:6594]) by HE1PR04MB1450.eurprd04.prod.outlook.com ([fe80::d161:29b5:cd62:6594%13]) with mapi id 15.20.0675.016; Fri, 20 Apr 2018 02:00:08 +0000 From: Peter Chen To: Yossi Mansharoff , Greg Kroah-Hartman , "open list:CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER" , open list CC: "robh@kernel.org" , "swboyd@chromium.org" , Peter Rosin , "devicetree@vger.kernel.org" , Stephen Boyd Subject: RE: [PATCH v2] usb: chipidea: Hook into mux framework to toggle usb switch Thread-Topic: [PATCH v2] usb: chipidea: Hook into mux framework to toggle usb switch Thread-Index: AQHT1lN0/EEznR23NUSUmIox/rpIi6QI53Fw Date: Fri, 20 Apr 2018 02:00:08 +0000 Message-ID: References: <1523973148-2094-1-git-send-email-yossim@codeaurora.org> In-Reply-To: <1523973148-2094-1-git-send-email-yossim@codeaurora.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: codeaurora.org; dkim=none (message not signed) header.d=none;codeaurora.org; dmarc=none action=none header.from=nxp.com; x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;HE1PR04MB1498;7:Kj7yRYPw7a7dykz25P6cTDn41WMSYjUWvXZSb+fg8Venyj/VRpBaGsB3ZGWn5xRjwZvAORL4mQk2v4TnOvyQA6r3cpNDfe4+vmR9gtHVpvkSahl42UXhOvNu4EXMl8cPT9crLJ4dvlVdT8SiyZvIHf5XdLY/sLSK+DHyeOCxpe2aS3lihVyV/V/h9uBOLCoKDofOgpH3PXXaZ7LbbndpzeU0VMQVIRAHtze0Evrv5XtElqX8f6gaDo+Q9hmjPr9n x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020);SRVR:HE1PR04MB1498; x-ms-traffictypediagnostic: HE1PR04MB1498: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231232)(944501327)(52105095)(6055026)(6041310)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011);SRVR:HE1PR04MB1498;BCL:0;PCL:0;RULEID:;SRVR:HE1PR04MB1498; x-forefront-prvs: 0648FCFFA8 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(376002)(39380400002)(396003)(346002)(39860400002)(476003)(446003)(5660300001)(11346002)(76176011)(8936002)(8676002)(66066001)(81166006)(54906003)(316002)(7736002)(229853002)(102836004)(7696005)(5250100002)(44832011)(110136005)(6246003)(3846002)(25786009)(478600001)(74316002)(53936002)(55016002)(186003)(26005)(4326008)(6116002)(33656002)(86362001)(9686003)(2900100001)(2906002)(305945005)(6436002)(6506007)(3280700002)(3660700001);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR04MB1498;H:HE1PR04MB1450.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;MLV:sfv; x-microsoft-antispam-message-info: +Maod2YLn3zZYLhOwD2yygANdk7KykfMyo1630knCTLca46buYMUvWdef5f10pRw0uv8ZTpoZZ5GCyDrg7Pe7egjT0hdS8Dom+Q7+Yxls9tA3ChmQHIzBegx2D/9ujJ1GCvtkF5gPMwmYaz1YL60Q/SVQenvwNHkNsr2UAtry/jMfd/jUAF7qrmzZkiyUTq+ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 8fcfa9b0-0958-4dc1-0193-08d5a662718d X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8fcfa9b0-0958-4dc1-0193-08d5a662718d X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2018 02:00:08.3615 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1498 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =20 =20 > --- a/drivers/usb/chipidea/Kconfig > +++ b/drivers/usb/chipidea/Kconfig > @@ -3,6 +3,8 @@ config USB_CHIPIDEA > depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD > && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA > select EXTCON > select RESET_CONTROLLER > + select MULTIPLEXER > + select MUX_GPIO The above two configurations are only used at your specific platforms, plea= se add them at either your platform defconfig or the related hardware driver's Kco= nfig.=20 > help > Say Y here if your system has a dual role high speed USB > controller based on ChipIdea silicon IP. It supports: > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c in= dex > 33ae87f..8fa0991 100644 > --- a/drivers/usb/chipidea/core.c > +++ b/drivers/usb/chipidea/core.c > @@ -61,6 +61,7 @@ > #include > #include > #include > +#include >=20 > #include "ci.h" > #include "udc.h" > @@ -687,6 +688,10 @@ static int ci_get_platdata(struct device *dev, > if (of_find_property(dev->of_node, "non-zero-ttctrl-ttha", NULL)) > platdata->flags |=3D CI_HDRC_SET_NON_ZERO_TTHA; >=20 > + platdata->usb_switch =3D devm_mux_control_get_optional(dev, "usb_switch= "); > + if (IS_ERR(platdata->usb_switch)) > + return PTR_ERR(platdata->usb_switch); > + > ext_id =3D ERR_PTR(-ENODEV); > ext_vbus =3D ERR_PTR(-ENODEV); > if (of_property_read_bool(dev->of_node, "extcon")) { diff --git > a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index af45aa3= 2..d9d2d00 > 100644 > --- a/drivers/usb/chipidea/host.c > +++ b/drivers/usb/chipidea/host.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include >=20 > #include "../host/ehci.h" >=20 > @@ -161,6 +162,10 @@ static int host_start(struct ci_hdrc *ci) > if (ci_otg_is_fsm_mode(ci)) { > otg->host =3D &hcd->self; > hcd->self.otg_port =3D 1; > + } else { > + ret =3D mux_control_select(ci->platdata->usb_switch, 1); > + if (ret) > + goto disable_reg; What will happen if ci->platdata->usb_switch is NULL? > } > } >=20 > @@ -181,6 +186,8 @@ static void host_stop(struct ci_hdrc *ci) > struct usb_hcd *hcd =3D ci->hcd; >=20 > if (hcd) { > + if (!ci_otg_is_fsm_mode(ci)) > + mux_control_deselect(ci->platdata->usb_switch); Ditto. > if (ci->platdata->notify_event) > ci->platdata->notify_event(ci, > CI_HDRC_CONTROLLER_STOPPED_EVENT); > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c inde= x > 9852ec5..209d3f6 100644 > --- a/drivers/usb/chipidea/udc.c > +++ b/drivers/usb/chipidea/udc.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include >=20 > #include "ci.h" > #include "udc.h" > @@ -1965,16 +1966,26 @@ void ci_hdrc_gadget_destroy(struct ci_hdrc *ci) >=20 > static int udc_id_switch_for_device(struct ci_hdrc *ci) { > + int ret =3D 0; > + > if (ci->is_otg) > /* Clear and enable BSV irq */ > hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE, > OTGSC_BSVIS | OTGSC_BSVIE); >=20 > - return 0; > + if (!ci_otg_is_fsm_mode(ci)) > + ret =3D mux_control_select(ci->platdata->usb_switch, 0); > + Ditto > + if (ci->is_otg && ret) > + hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, > OTGSC_BSVIS); > + > + return ret; > } >=20 > static void udc_id_switch_for_host(struct ci_hdrc *ci) { > + mux_control_deselect(ci->platdata->usb_switch); > + > /* > * host doesn't care B_SESSION_VALID event > * so clear and disbale BSV irq > diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h = index > 07f9936..9ea55a1 100644 > --- a/include/linux/usb/chipidea.h > +++ b/include/linux/usb/chipidea.h > @@ -10,6 +10,7 @@ > #include >=20 > struct ci_hdrc; > +struct mux_control; >=20 > /** > * struct ci_hdrc_cable - structure for external connector cable state t= racking @@ - > 76,6 +77,7 @@ struct ci_hdrc_platform_data { > /* VBUS and ID signal state tracking, using extcon framework */ > struct ci_hdrc_cable vbus_extcon; > struct ci_hdrc_cable id_extcon; > + struct mux_control *usb_switch; > u32 phy_clkgate_delay_us; =20 If CONFIG_USB_CHIPIDEA_HOST is not defined, it may cause build error Peter =20