From patchwork Thu May 5 12:34:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9023931 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5B71ABF440 for ; Thu, 5 May 2016 12:36:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EDFC20220 for ; Thu, 5 May 2016 12:36:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70BDD203B8 for ; Thu, 5 May 2016 12:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755541AbcEEMfq (ORCPT ); Thu, 5 May 2016 08:35:46 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:29325 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755555AbcEEMfE (ORCPT ); Thu, 5 May 2016 08:35:04 -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 <0O6P002IMEYC7460@mailout1.w1.samsung.com>; Thu, 05 May 2016 13:35:00 +0100 (BST) X-AuditID: cbfec7f5-f792a6d000001302-19-572b3df3f21a Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 3B.41.04866.3FD3B275; Thu, 5 May 2016 13:34:59 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O6P00KEEEXN8E00@eusync4.samsung.com>; Thu, 05 May 2016 13:34:59 +0100 (BST) From: Krzysztof Kozlowski To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-mmc@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, Ulf Hansson , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Greg Kroah-Hartman , Mark Brown Cc: tjakobi@math.uni-bielefeld.de, m.szyprowski@samsung.com, hverkuil@xs4all.nl, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [RFC v2 11/13] usb: port: Parse pwrseq phandle from Device Tree Date: Thu, 05 May 2016 14:34:24 +0200 Message-id: <1462451666-17945-12-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1462451666-17945-1-git-send-email-k.kozlowski@samsung.com> References: <1462451666-17945-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLLMWRmVeSWpSXmKPExsVy+t/xa7qfbbXDDXY80LXYOGM9q8XUh0/Y LCY9ec9sMf/IOVaLiSsnM1s0L17PZnFq8jMmi9cvDC02Pb7GanF51xw2iyP/+xktPvceYbSY cX4fk8WiZa3MFmuP3GW3OL27xKJt9QdWi+Nrwx2EPHbOusvusXmFlsemVZ1sHneu7WHz2D93 DVBoSb3Hv2PsHn1bVjF6fN4k53Hq62f2AK4oLpuU1JzMstQifbsErozzR28xF3wWqLhx5gxj A2MTXxcjB4eEgInE56WiXYycQKaYxIV769lAbCGBpYwSr04ZdzFyAdmNTBKHG9uZQBJsAsYS m5cvYQNJiAjcYJZ4tXMyM4jDLLCDUeLvsjssIFXCAh4SC24eYwLZwCKgKrH/sxZImBcovP74 NTaIbXISJ49NZgWxOYHiZ3/NZ4XY7C5x6Pd0xgmMvAsYGVYxiqaWJhcUJ6XnGukVJ+YWl+al 6yXn525ihAT61x2MS49ZHWIU4GBU4uHNmKsVLsSaWFZcmXuIUYKDWUmEVx4YJ0K8KYmVValF +fFFpTmpxYcYpTlYlMR5Z+56HyIkkJ5YkpqdmlqQWgSTZeLglGpg1Jzu8ilNYrVJRPWqt+cL H7DsCDpiacZWd0nzKPPrU5bnD8p+817QYpi3c9tS4x3Ox6qZcnxiVb1fHtH/nqT6QVVI3Lpk dv7xnmUZHPv17DbVX7639LV9P5vNv3SnT5v/fJq8+8w03vdS+SnHd/51spwqWRCiwVeRXhf7 5rGEBfOte7Mm5lUaKbEUZyQaajEXFScCABPqGqtwAgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.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 Reviewed-by: Javier Martinez Canillas --- 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 14718a9ffcfb..a875bd342452 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -18,6 +18,8 @@ #include #include +#include +#include #include "hub.h" @@ -532,6 +534,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(hub->hdev->dev.of_node, port1); + port_dev->pwrseq = pwrseq_alloc(&port_dev->dev); + if (IS_ERR(port_dev->pwrseq)) { + device_unregister(&port_dev->dev); + /* TODO: what about EPROBE_DEFER? */ + return PTR_ERR(port_dev->pwrseq); + } + find_and_link_peer(hub, port1); /* @@ -573,8 +583,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); }