From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miquel Raynal Subject: [PATCH v3 01/10] usb: core: comply to PHY framework Date: Mon, 21 Jan 2019 12:23:27 +0100 Message-ID: <20190121112336.23489-2-miquel.raynal@bootlin.com> References: <20190121112336.23489-1-miquel.raynal@bootlin.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190121112336.23489-1-miquel.raynal@bootlin.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Gregory Clement , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Kishon Vijay Abraham I , Rob Herring , Mark Rutland , Greg Kroah-Hartman , Mathias Nyman , Alan Stern Cc: devicetree@vger.kernel.org, Antoine Tenart , linux-usb@vger.kernel.org, Maxime Chevallier , Nadav Haklai , Thomas Petazzoni , Miquel Raynal , linux-arm-kernel@lists.infradead.org List-Id: devicetree@vger.kernel.org Current implementation of the USB core does not take into account the new PHY framework. Correct the situation by adding a call to phy_set_mode() before phy_power_on(). Signed-off-by: Miquel Raynal --- drivers/usb/core/hcd.c | 5 +++++ drivers/usb/core/phy.c | 28 ++++++++++++++++++++++++++++ drivers/usb/core/phy.h | 2 ++ 3 files changed, 35 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 015b126ce455..86f39e44f98a 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2736,6 +2736,11 @@ int usb_add_hcd(struct usb_hcd *hcd, if (retval) return retval; + retval = usb_phy_roothub_set_mode(hcd->phy_roothub, + PHY_MODE_USB_HOST_SS); + if (retval) + goto err_usb_phy_roothub_power_on; + retval = usb_phy_roothub_power_on(hcd->phy_roothub); if (retval) goto err_usb_phy_roothub_power_on; diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c index 38b2c776c4b4..7580493b867a 100644 --- a/drivers/usb/core/phy.c +++ b/drivers/usb/core/phy.c @@ -123,6 +123,34 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub) } EXPORT_SYMBOL_GPL(usb_phy_roothub_exit); +int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, + enum phy_mode mode) +{ + struct usb_phy_roothub *roothub_entry; + struct list_head *head; + int err; + + if (!phy_roothub) + return 0; + + head = &phy_roothub->list; + + list_for_each_entry(roothub_entry, head, list) { + err = phy_set_mode(roothub_entry->phy, mode); + if (err) + goto err_out; + } + + return 0; + +err_out: + list_for_each_entry_continue_reverse(roothub_entry, head, list) + phy_power_off(roothub_entry->phy); + + return err; +} +EXPORT_SYMBOL_GPL(usb_phy_roothub_set_mode); + int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub) { struct usb_phy_roothub *roothub_entry; diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h index 88a3c037e9df..dad564e2d2d4 100644 --- a/drivers/usb/core/phy.h +++ b/drivers/usb/core/phy.h @@ -16,6 +16,8 @@ struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev); int usb_phy_roothub_init(struct usb_phy_roothub *phy_roothub); int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub); +int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, + enum phy_mode mode); int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub); void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub); -- 2.19.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Subject: [v3,01/10] usb: core: comply to PHY framework From: Miquel Raynal Message-Id: <20190121112336.23489-2-miquel.raynal@bootlin.com> Date: Mon, 21 Jan 2019 12:23:27 +0100 To: Gregory Clement , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Kishon Vijay Abraham I , Rob Herring , Mark Rutland , Greg Kroah-Hartman , Mathias Nyman , Alan Stern Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org, Thomas Petazzoni , Antoine Tenart , Maxime Chevallier , Nadav Haklai , Miquel Raynal List-ID: Q3VycmVudCBpbXBsZW1lbnRhdGlvbiBvZiB0aGUgVVNCIGNvcmUgZG9lcyBub3QgdGFrZSBpbnRv IGFjY291bnQgdGhlCm5ldyBQSFkgZnJhbWV3b3JrLiBDb3JyZWN0IHRoZSBzaXR1YXRpb24gYnkg YWRkaW5nIGEgY2FsbCB0bwpwaHlfc2V0X21vZGUoKSBiZWZvcmUgcGh5X3Bvd2VyX29uKCkuCgpT aWduZWQtb2ZmLWJ5OiBNaXF1ZWwgUmF5bmFsIDxtaXF1ZWwucmF5bmFsQGJvb3RsaW4uY29tPgot LS0KIGRyaXZlcnMvdXNiL2NvcmUvaGNkLmMgfCAgNSArKysrKwogZHJpdmVycy91c2IvY29yZS9w aHkuYyB8IDI4ICsrKysrKysrKysrKysrKysrKysrKysrKysrKysKIGRyaXZlcnMvdXNiL2NvcmUv cGh5LmggfCAgMiArKwogMyBmaWxlcyBjaGFuZ2VkLCAzNSBpbnNlcnRpb25zKCspCgpkaWZmIC0t Z2l0IGEvZHJpdmVycy91c2IvY29yZS9oY2QuYyBiL2RyaXZlcnMvdXNiL2NvcmUvaGNkLmMKaW5k ZXggMDE1YjEyNmNlNDU1Li44NmYzOWU0NGY5OGEgMTAwNjQ0Ci0tLSBhL2RyaXZlcnMvdXNiL2Nv cmUvaGNkLmMKKysrIGIvZHJpdmVycy91c2IvY29yZS9oY2QuYwpAQCAtMjczNiw2ICsyNzM2LDEx IEBAIGludCB1c2JfYWRkX2hjZChzdHJ1Y3QgdXNiX2hjZCAqaGNkLAogCQlpZiAocmV0dmFsKQog CQkJcmV0dXJuIHJldHZhbDsKIAorCQlyZXR2YWwgPSB1c2JfcGh5X3Jvb3RodWJfc2V0X21vZGUo aGNkLT5waHlfcm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jvb3RodWIsCisJCQkgICAgIGVudW0gcGh5X21v ZGUgbW9kZSk7CiBpbnQgdXNiX3BoeV9yb290aHViX3Bvd2VyX29uKHN0cnVjdCB1c2JfcGh5X3Jv b3RodWIgKnBoeV9yb290aHViKTsKIHZvaWQgdXNiX3BoeV9yb290aHViX3Bvd2VyX29mZihzdHJ1 Y3QgdXNiX3BoeV9yb290aHViICpwaHlfcm9vdGh1Yik7CiAK From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2D02C7112F for ; Mon, 21 Jan 2019 11:23:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B90E720663 for ; Mon, 21 Jan 2019 11:23:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="I7PT2cPd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B90E720663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bmMybbGTV0hLZZrnPRqf0X/Xbp/eKkLMw2bTPKMW0Dc=; b=I7PT2cPdTiV7iq UVRVD4w8emPVN7nLW/jIX0iKW+qc5EDOa+pTUHkAJwsBNMoN8bTuO/ltZFEcMnOWw5vz3iRvhE1vE vkfSY/kUdSYzV1w29ZRUVk1nYI9DFB621JmC2Y3CixdpfNizqiYRy+ixtbVlnlnS3D84Lfr41urEq 9bESpOJsw8+JWD050pr+QaMfKffSRhyQhkJvZN3QFgFHSIkI9CXXhjXoy6Fb0i0OXMtqeutXjUJc/ yZ+0jkjKG4MjQBnKYlJVg4GmdSN0SGK9EDGEVlgBoHz8AS0aKAybZ8KdgmtDmGYP8wxItqM37RXxa t8GRVBtweskJ1oZri3/A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1glXg7-0001IQ-1y; Mon, 21 Jan 2019 11:23:43 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1glXg3-0001GA-G5 for linux-arm-kernel@lists.infradead.org; Mon, 21 Jan 2019 11:23:41 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 29458209BF; Mon, 21 Jan 2019 12:23:38 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-37-87.w90-88.abo.wanadoo.fr [90.88.156.87]) by mail.bootlin.com (Postfix) with ESMTPSA id B1E1F206DC; Mon, 21 Jan 2019 12:23:37 +0100 (CET) From: Miquel Raynal To: Gregory Clement , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Kishon Vijay Abraham I , Rob Herring , Mark Rutland , Greg Kroah-Hartman , Mathias Nyman , Alan Stern Subject: [PATCH v3 01/10] usb: core: comply to PHY framework Date: Mon, 21 Jan 2019 12:23:27 +0100 Message-Id: <20190121112336.23489-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190121112336.23489-1-miquel.raynal@bootlin.com> References: <20190121112336.23489-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190121_032339_842695_9F341A6E X-CRM114-Status: GOOD ( 15.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Antoine Tenart , linux-usb@vger.kernel.org, Maxime Chevallier , Nadav Haklai , Thomas Petazzoni , Miquel Raynal , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Current implementation of the USB core does not take into account the new PHY framework. Correct the situation by adding a call to phy_set_mode() before phy_power_on(). Signed-off-by: Miquel Raynal --- drivers/usb/core/hcd.c | 5 +++++ drivers/usb/core/phy.c | 28 ++++++++++++++++++++++++++++ drivers/usb/core/phy.h | 2 ++ 3 files changed, 35 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 015b126ce455..86f39e44f98a 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2736,6 +2736,11 @@ int usb_add_hcd(struct usb_hcd *hcd, if (retval) return retval; + retval = usb_phy_roothub_set_mode(hcd->phy_roothub, + PHY_MODE_USB_HOST_SS); + if (retval) + goto err_usb_phy_roothub_power_on; + retval = usb_phy_roothub_power_on(hcd->phy_roothub); if (retval) goto err_usb_phy_roothub_power_on; diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c index 38b2c776c4b4..7580493b867a 100644 --- a/drivers/usb/core/phy.c +++ b/drivers/usb/core/phy.c @@ -123,6 +123,34 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub) } EXPORT_SYMBOL_GPL(usb_phy_roothub_exit); +int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, + enum phy_mode mode) +{ + struct usb_phy_roothub *roothub_entry; + struct list_head *head; + int err; + + if (!phy_roothub) + return 0; + + head = &phy_roothub->list; + + list_for_each_entry(roothub_entry, head, list) { + err = phy_set_mode(roothub_entry->phy, mode); + if (err) + goto err_out; + } + + return 0; + +err_out: + list_for_each_entry_continue_reverse(roothub_entry, head, list) + phy_power_off(roothub_entry->phy); + + return err; +} +EXPORT_SYMBOL_GPL(usb_phy_roothub_set_mode); + int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub) { struct usb_phy_roothub *roothub_entry; diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h index 88a3c037e9df..dad564e2d2d4 100644 --- a/drivers/usb/core/phy.h +++ b/drivers/usb/core/phy.h @@ -16,6 +16,8 @@ struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev); int usb_phy_roothub_init(struct usb_phy_roothub *phy_roothub); int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub); +int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, + enum phy_mode mode); int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub); void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub); -- 2.19.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel