From patchwork Thu Jun 9 09:44:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9166509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C15C7607DA for ; Thu, 9 Jun 2016 09:46:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B07DC2830C for ; Thu, 9 Jun 2016 09:46:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4E5C28336; Thu, 9 Jun 2016 09:46:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C3A12830C for ; Thu, 9 Jun 2016 09:46:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423101AbcFIJpX (ORCPT ); Thu, 9 Jun 2016 05:45:23 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:27334 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751902AbcFIJpL (ORCPT ); Thu, 9 Jun 2016 05:45:11 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O8I00EHM0EYYP70@mailout3.w1.samsung.com>; Thu, 09 Jun 2016 10:44:58 +0100 (BST) X-AuditID: cbfec7f4-f796c6d000001486-a3-57593a992b07 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id ED.E6.05254.99A39575; Thu, 9 Jun 2016 10:44:57 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O8I006RA0EHZZ10@eusync1.samsung.com>; Thu, 09 Jun 2016 10:44:57 +0100 (BST) From: Krzysztof Kozlowski To: Ulf Hansson , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Krzysztof Kozlowski , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Liam Girdwood , Mark Brown , Greg Kroah-Hartman , Hans de Goede , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Heiko Stuebner , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, hzpeterchen@gmail.com Cc: Bartlomiej Zolnierkiewicz Subject: [RFC v4 11/14] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree Date: Thu, 09 Jun 2016 11:44:28 +0200 Message-id: <1465465471-28740-12-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1465465471-28740-1-git-send-email-k.kozlowski@samsung.com> References: <1465465471-28740-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRmVeSWpSXmKPExsVy+t/xy7qzrCLDDVYJWGycsZ7VYurDJ2wW k568Z7aYf+Qcq8XElZOZLfrfLGS1aF68ns3izfHpTBb/H71mtei6uonN4tyrlYwWr18YWny7 0sFksenxNVaLE30fWC0u75rDZnHkfz+jxefeI4wWM87vY7JYtKyV2WLp9YtMFhOmr2WxWPfw BZNF694j7Band5dYrJ9/i83i+NpwB2mPNfPWMHpc7utl8tg56y67x8rlX9g8Nq/Q8nh14Q6L x6ZVnWwed67tYfPYP3cNu8fmJfUe7/ddZfPo27KK0WP7tXnMHsdvbGfy+LxJLoA/issmJTUn syy1SN8ugSvjwzOzggbBirkdu5kbGJv5uhg5OSQETCSeH1rOBmGLSVy4tx7I5uIQEljKKPH5 7HYmCKeRSeLQrY1MIFVsAsYSm5cvAasSEbjELnHj0nawBLOAhcTWravZQWxhgQiJCxufMILY LAKqEq+2bQJbwSvgIXHm4WyodXISJ49NZgWxOYHij+49ZgaxhQTcJfYunsw2gZF3ASPDKkbR 1NLkguKk9FxDveLE3OLSvHS95PzcTYyQuPuyg3HxMatDjAIcjEo8vJopEeFCrIllxZW5hxgl OJiVRHh/mEeGC/GmJFZWpRblxxeV5qQWH2KU5mBREuedu+t9iJBAemJJanZqakFqEUyWiYNT qoFxRUly1p1bIXv7f7IkR5/tFdw4cUP78SJ3xQO8EksSjnP97vpy2Pdx4JWAV6YRItuOz58Z dk367Zt5gb8/dwh/ac78aO/NdvZm9MGWwmUXEt7krlvsECqjKpmQtyF/xfKA/j9PJrZ4fa04 WOf32/6B5IHb4iUtByPyVdSirPUeG2r/iZUtq+xVYinOSDTUYi4qTgQAbjiikLcCAAA= Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq device. The pwrseq device will be used by USB hub to cycle the power before activating ports. Signed-off-by: Krzysztof Kozlowski --- drivers/usb/core/hub.h | 3 +++ drivers/usb/core/port.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index 34c1a7e22aae..68ca89780d26 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h @@ -24,6 +24,8 @@ #include #include "usb.h" +struct pwrseq; + struct usb_hub { struct device *intfdev; /* the "interface" device */ struct usb_device *hdev; @@ -101,6 +103,7 @@ struct usb_port { struct usb_dev_state *port_owner; struct usb_port *peer; struct dev_pm_qos_request *req; + struct pwrseq *pwrseq; enum usb_port_connect_type connect_type; usb_port_location_t location; struct mutex status_lock; diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 460c855be0d0..4fce0250179c 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -18,6 +18,8 @@ #include #include +#include +#include #include "hub.h" @@ -526,6 +528,15 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1) return retval; } + port_dev->dev.of_node = usb_of_get_child_node(hdev->dev.parent->of_node, + port1); + port_dev->pwrseq = pwrseq_alloc(&port_dev->dev, "usb-pwrseq"); + if (IS_ERR(port_dev->pwrseq)) { + retval = PTR_ERR(port_dev->pwrseq); + device_unregister(&port_dev->dev); + return retval; + } + find_and_link_peer(hub, port1); /* @@ -567,8 +578,13 @@ void usb_hub_remove_port_device(struct usb_hub *hub, int port1) struct usb_port *port_dev = hub->ports[port1 - 1]; struct usb_port *peer; + pwrseq_power_off(port_dev->pwrseq); + peer = port_dev->peer; if (peer) unlink_peers(port_dev, peer); + + pwrseq_free(port_dev->pwrseq); + port_dev->pwrseq = NULL; device_unregister(&port_dev->dev); }