From patchwork Wed Apr 13 20:51:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 8828511 Return-Path: X-Original-To: patchwork-linux-arm@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 8D5D6C0553 for ; Wed, 13 Apr 2016 20:53:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0FC120131 for ; Wed, 13 Apr 2016 20:53:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6A2320122 for ; Wed, 13 Apr 2016 20:53:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aqRlE-0003uI-Sn; Wed, 13 Apr 2016 20:51:40 +0000 Received: from vern.gendns.com ([206.190.152.46]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aqRlC-0003q9-Ui for linux-arm-kernel@lists.infradead.org; Wed, 13 Apr 2016 20:51:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject; bh=YaKZ9OL9n8WlgHMXOwuPbSHjOISwIxqttnYPWFHpEQ8=; b=vthnnL8AOk+v4154H/5o6jkUFg M2BW1XmYtdC+AyRVFHZXJLt9Fc7wWZkZqfDf90XEnBuPrwVQf/lJr0kalez3qhAPZZpm4Ee6gMslZ g5qwaW4loVdXypvVhRcXxoqSXsjIBiS2sthXDlf2ZoM11yiw+HnqokANRw+qKLIe+2LfRQXFDsjWN jAky2BWKmYqdmeqdY2adgE3DbsiwSfEj9rjcFOfbiGQlK0mU6Om+ddKiOuO3NPuQBM6MkwRB3G9/I MWy0Lj8+xVUfUI0Q6JWRcThfcBP0XNDovC9wVhkHc2nGRE3chGMiWktjh3+3UsLaJ17+GB5FHsv7r x4c4rDmw==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:52872 helo=[192.168.0.113]) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_1) (envelope-from ) id 1aqRkm-003bA3-3M; Wed, 13 Apr 2016 16:51:12 -0400 Subject: Re: [PATCH v2 06/11] phy: da8xx-usb: new driver for DA8XX SoC USB PHY To: Kishon Vijay Abraham I References: <1458181615-27782-1-git-send-email-david@lechnology.com> <1458181615-27782-7-git-send-email-david@lechnology.com> <56FE74AC.6080303@ti.com> From: David Lechner Message-ID: <570EB143.4060309@lechnology.com> Date: Wed, 13 Apr 2016 15:51:15 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56FE74AC.6080303@ti.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160413_135139_056068_9329E23D X-CRM114-Status: GOOD ( 13.90 ) X-Spam-Score: -2.0 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, linux-usb@vger.kernel.org, Russell King , Sergei Shtylyov , Pawel Moll , Ian Campbell , Tony Lindgren , Greg Kroah-Hartman , Kevin Hilman , Sekhar Nori , linux-kernel@vger.kernel.org, =?UTF-8?Q?Andreas_F=c3=a4rber?= , Petr Kulhavy , Rob Herring , Alan Stern , Kumar Gala , Robert Jarzmik , Bin Liu , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 On 04/01/2016 08:16 AM, Kishon Vijay Abraham I wrote: >> +EXPORT_SYMBOL_GPL(da8xx_usb20_phy_set_mode); > > Don't prefer export symbols from PHY driver. That'll create unnecessary > dependencies between the controller and the PHY. > > I think it'll be better to create a new attribute and use it? > Just having an attribute that keeps track of state does not work. I need a callback to poke registers. Would this be acceptable instead? -----8<------ diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index e7e574d..a13c7e4 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -342,6 +342,36 @@ int phy_power_off(struct phy *phy) } EXPORT_SYMBOL_GPL(phy_power_off); +int phy_get_mode(struct phy *phy, enum phy_mode *mode) +{ + int ret; + + if (!phy || !phy->ops->get_mode) + return 0; + + mutex_lock(&phy->mutex); + ret = phy->ops->get_mode(phy, mode); + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_get_mode); + +int phy_set_mode(struct phy *phy, enum phy_mode mode) +{ + int ret; + + if (!phy || !phy->ops->set_mode) + return 0; + + mutex_lock(&phy->mutex); + ret = phy->ops->set_mode(phy, mode); + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_set_mode); + /** * _of_phy_get() - lookup and obtain a reference to a phy by phandle * @np: device_node for which to get the phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 8cf05e3..12c1986 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -22,12 +22,21 @@ struct phy; +enum phy_mode { + PHY_MODE_INVALID, + PHY_MODE_USB_HOST, + PHY_MODE_USB_DEVICE, + PHY_MODE_USB_OTG, +}; + /** * struct phy_ops - set of function pointers for performing phy operations * @init: operation to be performed for initializing phy * @exit: operation to be performed while exiting * @power_on: powering on the phy * @power_off: powering off the phy + * @get_mode: get the current mode of the phy + * @set_mode: set the mode of the phy * @owner: the module owner containing the ops */ struct phy_ops { @@ -35,6 +44,8 @@ struct phy_ops { int (*exit)(struct phy *phy); int (*power_on)(struct phy *phy); int (*power_off)(struct phy *phy); + int (*get_mode)(struct phy *phy, enum phy_mode *mode); + int (*set_mode)(struct phy *phy, enum phy_mode mode); struct module *owner; }; @@ -119,6 +130,8 @@ int phy_init(struct phy *phy); int phy_exit(struct phy *phy); int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); +int phy_get_mode(struct phy *phy, enum phy_mode *mode); +int phy_set_mode(struct phy *phy, enum phy_mode mode); static inline int phy_get_bus_width(struct phy *phy) { return phy->attrs.bus_width; @@ -224,6 +237,16 @@ static inline int phy_power_off(struct phy *phy) return -ENOSYS; } +static inline int phy_get_mode(struct phy *phy, enum phy_mode *mode) +{ + return 0; +} + +static inline int phy_set_mode(struct phy *phy, enum phy_mode mode) +{ + return 0; +} + static inline int phy_get_bus_width(struct phy *phy) { return -ENOSYS;