From patchwork Fri Feb 21 17:46:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loc Ho X-Patchwork-Id: 322967 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 65F6D2C0337 for ; Sat, 22 Feb 2014 04:47:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933120AbaBURq7 (ORCPT ); Fri, 21 Feb 2014 12:46:59 -0500 Received: from exprod5og107.obsmtp.com ([64.18.0.184]:52939 "HELO exprod5og107.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S933103AbaBURq5 (ORCPT ); Fri, 21 Feb 2014 12:46:57 -0500 Received: from mail-pb0-f49.google.com ([209.85.160.49]) (using TLSv1) by exprod5ob107.postini.com ([64.18.4.12]) with SMTP ID DSNKUweRENcQDGTOlZV+BrxQEDP+gDZkfuRr@postini.com; Fri, 21 Feb 2014 09:46:56 PST Received: by mail-pb0-f49.google.com with SMTP id up15so3697227pbc.8 for ; Fri, 21 Feb 2014 09:46:56 -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=4hTtLPQ2VszsxbKFBXcrk2w9oCat/lPzd7A99Gg24yM=; b=Pfb5GIn2fZ8MEM0Lr/oE3Y5BMXIIq60rbEsscE72eySZO2smaalypDsp8hPFww7Nkr dbe5YmiiZexcpIt9vk5jKEV8+5Abq4TXSnBcyukpKluZlwvcrccLOEMsn80mwiU/qqBj 77UkfQEuRk4o7OPG0HPfYVJvdcO1ZXrcxsPhqJxEr4lBwLyZJw3dpsXh4zwgQDgY1Z6Z 37/BXalMjywWtQHeR4rJfEov662Arc9Wnwe+T7WMWGsYRAAsHtiDZXQiiyGs8lX7edvY sCEn+jfasbFymbRTE2uqQ7+WdKt9o8ljFXU+kfF33SZffq8mL52j1QDm9pdPB06TzYbH D7EA== X-Gm-Message-State: ALoCoQk5qUkeejwpYYG5ksgjax1TKsDWzJ8cIz9eqPAjmPy/xJuQd2pBRe/cxtK//MjpohKnPlgJin1FUbvuKsmJP+npbJUayEEDZjVFlWxuuFIPcQ7X+n7IBn5YHp4h6giLol7ZGZcQ4GJObfE52EClTf5DTmZsSSjE5lsLC9diUSD7b07L+AM= X-Received: by 10.68.159.228 with SMTP id xf4mr10583903pbb.74.1393004816201; Fri, 21 Feb 2014 09:46:56 -0800 (PST) X-Received: by 10.68.159.228 with SMTP id xf4mr10583892pbb.74.1393004816120; Fri, 21 Feb 2014 09:46:56 -0800 (PST) Received: from localhost ([198.137.200.11]) by mx.google.com with ESMTPSA id e3sm23366268pbc.17.2014.02.21.09.46.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 21 Feb 2014 09:46:55 -0800 (PST) From: Loc Ho To: olof@lixom.net, tj@kernel.org, arnd@arndb.de Cc: linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ddutile@redhat.com, jcm@redhat.com, patches@apm.com, Loc Ho Subject: [PATCH v10 1/4] PHY: Add function set_speed to generic PHY framework Date: Fri, 21 Feb 2014 10:46:38 -0700 Message-Id: <1393004801-25970-2-git-send-email-lho@apm.com> X-Mailer: git-send-email 1.5.5 In-Reply-To: <1393004801-25970-1-git-send-email-lho@apm.com> References: <1393004801-25970-1-git-send-email-lho@apm.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org 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 | 21 +++++++++++++++++++++ include/linux/phy/phy.h | 8 ++++++++ 2 files changed, 29 insertions(+), 0 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 645c867..44f2f63 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -257,6 +257,27 @@ int phy_power_off(struct phy *phy) } EXPORT_SYMBOL_GPL(phy_power_off); +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 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);