From patchwork Wed Jun 1 08:02:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9146273 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 BD2EF60757 for ; Wed, 1 Jun 2016 08:06:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE3DB20072 for ; Wed, 1 Jun 2016 08:06:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2B9F20265; Wed, 1 Jun 2016 08:06:46 +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 77F6820072 for ; Wed, 1 Jun 2016 08:06:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757541AbcFAIDR (ORCPT ); Wed, 1 Jun 2016 04:03:17 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:31126 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757549AbcFAIDA (ORCPT ); Wed, 1 Jun 2016 04:03:00 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O8300B3Q2CRJ840@mailout1.w1.samsung.com>; Wed, 01 Jun 2016 09:02:51 +0100 (BST) X-AuditID: cbfec7f5-f792a6d000001302-0d-574e96ab60df Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 4C.1E.04866.BA69E475; Wed, 1 Jun 2016 09:02:51 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O830012K2CGIS90@eusync3.samsung.com>; Wed, 01 Jun 2016 09:02:51 +0100 (BST) From: Krzysztof Kozlowski To: hzpeterchen@gmail.com, Ulf Hansson , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Krzysztof Kozlowski , Javier Martinez Canillas , linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-pm@vger.kernel.or, Alan Stern , linux-usb@vger.kernel.org, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Kukjin Kim , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz Subject: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree Date: Wed, 01 Jun 2016 10:02:18 +0200 Message-id: <1464768141-25420-10-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1464768141-25420-1-git-send-email-k.kozlowski@samsung.com> References: <1464768141-25420-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeLIzCtJLcpLzFFi42I5/e/4Vd3V0/zCDb6161lsnLGe1WLSk/fM FvOPnGO1mLhyMrNF/5uFrBbNi9ezWXRd3cRmce7VSkaLN2/XMFm8fmFo0f/4NbPFpsfXWC0u 75rDZnHkfz+jxcyLq1ksZpzfx2SxaFkrs8XS6xeZLCZMX8ti0br3CLvF6d0lFhN+X2CzOL42 3EHcY828NYwel/t6mTx2zrrL7rFy+Rc2j80rtDw2repk87hzbQ+bx/65a9g9Ni+p99jSD1Qw ++4PRo++LasYPY58nc7i8XmTXABfFJdNSmpOZllqkb5dAlfGos+bmQteCVT8mL+brYHxM28X IyeHhICJxJvn29kgbDGJC/fWA9lcHEICSxkltv69zQ7hNDJJnHz2gh2kik3AWGLz8iVgVSIC HWwSm7a+AUswC2RLnLr3nrWLkYNDWCBK4uiPGJAwi4CqxPuJx1lBbF4BD4lJHXMYIbbJSZw8 NhkszgkUPzHhP1hcSMBdonHaZNYJjLwLGBlWMYqmliYXFCel5xrpFSfmFpfmpesl5+duYoTE 0dcdjEuPWR1iFOBgVOLhrbjsGy7EmlhWXJl7iFGCg1lJhFdwsl+4EG9KYmVValF+fFFpTmrx IUZpDhYlcd6Zu96HCAmkJ5akZqemFqQWwWSZODilGhjLjvGvO3FZ3PefUpPChjYTYe2SDpup knpqq9vZfDf+MTh3utG1JHvbiw7PX86FuVumpnxSudbx8X53Y8GiBWpJyjI7Tus6aC8x/XXT yEBtV6SHo4XolEty2/IaS5Z+dNzptPpmrmfu8Wrlg5HB9Uozp0v3NOT+fNe97emajqL/E+9o TDvCbKbEUpyRaKjFXFScCAC4L2P0nwIAAA== 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 | 15 +++++++++++++++ 2 files changed, 18 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..89b9bdfc7061 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,14 @@ 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)) { + device_unregister(&port_dev->dev); + return PTR_ERR(port_dev->pwrseq); + } + find_and_link_peer(hub, port1); /* @@ -567,8 +577,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); }