From patchwork Mon Jan 6 18:10:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loc Ho X-Patchwork-Id: 307398 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 3FFED2C00BC for ; Tue, 7 Jan 2014 05:11:25 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755477AbaAFSLX (ORCPT ); Mon, 6 Jan 2014 13:11:23 -0500 Received: from exprod5og106.obsmtp.com ([64.18.0.182]:49490 "HELO exprod5og106.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755907AbaAFSLW (ORCPT ); Mon, 6 Jan 2014 13:11:22 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]) (using TLSv1) by exprod5ob106.postini.com ([64.18.4.12]) with SMTP ID DSNKUsrxyicHHDxgGHHxanKi/khJQdg5j9R0@postini.com; Mon, 06 Jan 2014 10:11:22 PST Received: by mail-pd0-f169.google.com with SMTP id v10so18423671pde.14 for ; Mon, 06 Jan 2014 10:11:21 -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=dvb6iezlhJkCpD620F1rVbongxttl2P7qDAXVaDWwvk=; b=hftuoj3xF4ngUkm3Ono2bv6+j/Xa4Bfdw6Iya08C/oMTXk+Pmv63m0nFy5WWEFFN+E mERI2gnwscTW8djC599PAaPOX02sA4TAb2BUbOfRuRGfrD/EYP9LVgu1lc90EPhWSbxk pCSDig9HZEZNcNbocr4BDibE/f4OrRsJE32xplTsXRpwoLU+vq/w8CDtB8OZEQbH+rrZ PsS1lCSvS3J/DFM4cRg3Y+NjPdgr7/nBZ3qvWwdru3+OwEZFt2NsgvvzSajO6DATGhTt eovRbIkir4fi3ZrHwr97TOsEz8EHonHpZzab6Cwv47nds7AaE0SbkIL56q5U/akdo8rn 1sVQ== X-Gm-Message-State: ALoCoQnehw0Fgq4lL3rf366XigQIW2T5jN1GVxzwhBD/RafUCgJOAx4t7eftmbHguu2AZc7EGrSH1ms+ZYjOQb7AzD4l5+BoP4jY3wBfyi3I9V9bU6DtuRJMoacRmcHg5FRtUDHGCNPFJCnEgD8AYU4/+9//Qb5nMdza/jxWZqEDZUcU0sZm09E= X-Received: by 10.66.248.130 with SMTP id ym2mr300219pac.9.1389031881726; Mon, 06 Jan 2014 10:11:21 -0800 (PST) X-Received: by 10.66.248.130 with SMTP id ym2mr300203pac.9.1389031881644; Mon, 06 Jan 2014 10:11:21 -0800 (PST) Received: from localhost ([198.137.200.11]) by mx.google.com with ESMTPSA id q7sm130396608pbc.20.2014.01.06.10.11.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 06 Jan 2014 10:11:20 -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, jcm@redhat.com, patches@apm.com, Loc Ho Subject: [PATCH v6 1/4] PHY: Add function set_speed to generic PHY framework Date: Mon, 6 Jan 2014 11:10:59 -0700 Message-Id: <1389031862-4285-2-git-send-email-lho@apm.com> X-Mailer: git-send-email 1.5.5 In-Reply-To: <1389031862-4285-1-git-send-email-lho@apm.com> References: <1389031862-4285-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 03cf8fb..b525e72 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -239,6 +239,27 @@ out: } 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 6d72269..ed2b897 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; }; @@ -127,6 +129,7 @@ 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_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); @@ -199,6 +202,11 @@ static inline int phy_power_off(struct phy *phy) return -ENOSYS; } +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);