From patchwork Thu Feb 27 18:14:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loc Ho X-Patchwork-Id: 3735021 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 58C36BF13A for ; Thu, 27 Feb 2014 18:15:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6E50220221 for ; Thu, 27 Feb 2014 18:15:43 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C5C1201D3 for ; Thu, 27 Feb 2014 18:15:42 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJ5UE-0008Ty-R1; Thu, 27 Feb 2014 18:15:11 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJ5U5-0006rF-6b; Thu, 27 Feb 2014 18:15:01 +0000 Received: from exprod5og112.obsmtp.com ([64.18.0.24]) by merlin.infradead.org with smtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJ5Tr-0006oD-EF for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2014 18:14:48 +0000 Received: from mail-pa0-f42.google.com ([209.85.220.42]) (using TLSv1) by exprod5ob112.postini.com ([64.18.4.12]) with SMTP ID DSNKUw+AgS1uYoFl5i/4PMUAArpq6xwHFZOg@postini.com; Thu, 27 Feb 2014 10:14:47 PST Received: by mail-pa0-f42.google.com with SMTP id kl14so2858263pab.1 for ; Thu, 27 Feb 2014 10:14:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eCMM8Eojry4KQsS9gureP7YNKgE6MnbuQP4uO1XcM8w=; b=Pklprt/W9CBJdt9hL/bq021RnpQLPUXHKRnZgNDRdUtY+c9/IchJBmfMgoXX+12tkl Ql1BkKb5A5VuJtTFP4n6Nc/PT2fTvC+QjGMxCH4cYfa2rhiABrd44CXSBS/3D9PQaTn/ Ie4oZBv/XsNrLd+cnuDU7p3XvEr3P2x30/n6vmihMqYtA/N5Sua/+lu3iHz414gMPy92 cF7mP5sivaGSnImfklkVb5vdz7Fb+uR+OtUWAlvJZSp6csZZPsiCCq5UDv7UDwImyCc6 7+LQpKl7sTxeWj0N59BPYAcHzPgac5XO08vcwhIL8ZXrmVvTxS+nW1HxSuNJg4oflmba 3oDw== X-Gm-Message-State: ALoCoQn9gPk+huAT3kKKmmBI4pk+3Vlw4H99jNgOUV4rG3fQ6zOIechYskaFmx0cuPTqFW6S3GifhW/ZZ/c/+nYxerlFTTWcwymvPSak5zn5+2tpExjyuVBW4J0uEEEGvZNv+UfnnRy6ibNWlCBPg5zMjGkmNzPwTJJtOFUu9HACF+bi7Df2xuI1gdxHqzFVieUzj8uHk0/l X-Received: by 10.67.3.97 with SMTP id bv1mr16761178pad.54.1393524864603; Thu, 27 Feb 2014 10:14:24 -0800 (PST) X-Received: by 10.67.3.97 with SMTP id bv1mr16761166pad.54.1393524864483; Thu, 27 Feb 2014 10:14:24 -0800 (PST) Received: from localhost ([198.137.200.11]) by mx.google.com with ESMTPSA id ou9sm15738518pbc.30.2014.02.27.10.14.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 27 Feb 2014 10:14:23 -0800 (PST) From: Loc Ho To: kishon@ti.com, tj@kernel.org Subject: [PATCH v12 1/4] PHY: Add function set_speed to generic PHY framework Date: Thu, 27 Feb 2014 11:14:05 -0700 Message-Id: <1393524848-8207-2-git-send-email-lho@apm.com> X-Mailer: git-send-email 1.5.5 In-Reply-To: <1393524848-8207-1-git-send-email-lho@apm.com> References: <1393524848-8207-1-git-send-email-lho@apm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140227_131447_698512_7EEEEDF5 X-CRM114-Status: GOOD ( 14.07 ) X-Spam-Score: -1.1 (-) Cc: devicetree@vger.kernel.org, linux-scsi@vger.kernel.org, arnd@arndb.de, jcm@redhat.com, patches@apm.com, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, ddutile@redhat.com, Loc Ho , olof@lixom.net, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no 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 This patch adds function set_speed to the generic PHY framework operation structure. This function can be called to instruct the PHY underlying layer at specified lane to configure for specified speed in hertz. Signed-off-by: Loc Ho --- drivers/phy/phy-core.c | 30 ++++++++++++++++++++++++++++++ include/linux/phy/phy.h | 8 ++++++++ 2 files changed, 38 insertions(+), 0 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 645c867..5451b6d 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -258,6 +258,36 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** + * phy_set_speed - set an specified lane at an specified speed + * @phy: phy instance to be set + * @lane: zero-based lane index + * @speed: operating speed in hz + * + * Returns 0 if successful, -ENOTSUPP if not supported, + * -EINVAL if parameter out of range. + */ +int phy_set_speed(struct phy *phy, int lane, u64 speed) +{ + int ret = -ENOTSUPP; + + mutex_lock(&phy->mutex); + if (phy->ops->set_speed) { + ret = phy->ops->set_speed(phy, lane, speed); + if (ret < 0) { + dev_err(&phy->dev, "phy set speed failed --> %d\n", + ret); + goto out; + } + } + +out: + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_set_speed); + +/** * of_phy_get() - lookup and obtain a reference to a phy by phandle * @dev: device that requests this phy * @index: the index of the phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index e273e5a..4eb589c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -27,6 +27,7 @@ struct phy; * @exit: operation to be performed while exiting * @power_on: powering on the phy * @power_off: powering off the phy + * @set_speed: set operation speed in hz * @owner: the module owner containing the ops */ struct phy_ops { @@ -34,6 +35,7 @@ struct phy_ops { int (*exit)(struct phy *phy); int (*power_on)(struct phy *phy); int (*power_off)(struct phy *phy); + int (*set_speed)(struct phy *phy, int lane, u64 speed); struct module *owner; }; @@ -145,6 +147,7 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width) { phy->attrs.bus_width = bus_width; } +int phy_set_speed(struct phy *phy, int lane, u64 speed); struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); void phy_put(struct phy *phy); @@ -227,6 +230,11 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width) return; } +static inline int phy_set_speed(struct phy *phy, int lane, u64 speed) +{ + return -ENOSYS; +} + static inline struct phy *phy_get(struct device *dev, const char *string) { return ERR_PTR(-ENOSYS);