From patchwork Fri Jun 16 08:17:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 9790827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0BF6F60326 for ; Fri, 16 Jun 2017 08:20:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F531FF22 for ; Fri, 16 Jun 2017 08:20:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD53F2860F; Fri, 16 Jun 2017 08:20:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F0F51FF22 for ; Fri, 16 Jun 2017 08:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=mekKPUF0vOX0VpnE16j01QK6bl+l6vbqeY8+/4HVAO8=; b=np2 Olh2LvFuKhQcXI9FvGnb7Ce7WM7GENw7iZWohC/A6VQsv1JWbNjIv+WBHvPInI8UOTQCheUiv8al+ b7KQPnQFRO8itFwLjuwjkTgCf72kEaj2xlezyrjgItOvJm2THkonVakhlp4PLqPkMV3PVm99N/y5V DC1WXY8UBM2m1L7RFXin6M5q3hnRQi8q7QooYVONsqWOFbEXtQUQdMdkIoJaT5ydt0Dm1K6jLzATX 3M4ptkHrMYtkr2vvTLQ6+83qN1D1MnOcmyk3lqcPgzgLdMs6ENF8T/779DT9vSBGxFgtSAhDWCe9c kqlhS7LvhKAylDB2JuRMolOPrSbxHzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dLmUn-0001Ho-Og; Fri, 16 Jun 2017 08:20:45 +0000 Received: from lucky1.263xmail.com ([211.157.147.130]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dLmUj-00016J-OG for linux-rockchip@lists.infradead.org; Fri, 16 Jun 2017 08:20:43 +0000 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.230]) by lucky1.263xmail.com (Postfix) with ESMTP id 2D2F41EEFC5; Fri, 16 Jun 2017 16:20:16 +0800 (CST) X-263anti-spam: X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id DF11F393; Fri, 16 Jun 2017 16:20:15 +0800 (CST) X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: kishon@ti.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 21936NXT6U5; Fri, 16 Jun 2017 16:20:16 +0800 (CST) From: Shawn Lin To: Kishon Vijay Abraham I , Bjorn Helgaas Subject: [PATCH 1/2] phy-rockchip-pcie: add set_mode callback Date: Fri, 16 Jun 2017 16:17:47 +0800 Message-Id: <1497601068-181656-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170616_012042_187726_EAF49F0B X-CRM114-Status: UNSURE ( 9.63 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, Shawn Lin , Brian Norris , Heiko Stuebner , linux-pci@vger.kernel.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP phy_mode was added for switching USB mode purposely as well as phy_set_mode API. However other types of PHY could also have some miscellaneous setting/modes need to be handled. This patch is gonna support this callback for phy-rockchip-pcie and do some power-saving work there. Note that we just stuff in some other values other that the existing phy_mode and convert it in the coressponding driver instead, otherwise we should extend the phy_mode again which it doesn't make sense to add in new driver's specificed value. Overall it looks fine to me as the controller's driver and the phy's driver are paired so that the caller and the consumer should be able to keep the value(mode) in consistent. Signed-off-by: Shawn Lin --- drivers/phy/rockchip/phy-rockchip-pcie.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c index 6904633..9ffad15 100644 --- a/drivers/phy/rockchip/phy-rockchip-pcie.c +++ b/drivers/phy/rockchip/phy-rockchip-pcie.c @@ -255,11 +255,33 @@ static int rockchip_pcie_phy_exit(struct phy *phy) return 0; } +static int rockchip_pcie_phy_set_mode(struct phy *phy, enum phy_mode mode) +{ + struct rockchip_pcie_phy *rk_phy = phy_get_drvdata(phy); + u8 map = (u8)mode; + int i; + + for (i = 0; i < PHY_MAX_LANE_NUM; i++) { + if (map & BIT(i)) + continue; + + dev_dbg(&phy->dev, "idling lane %d\n", i); + regmap_write(rk_phy->reg_base, + rk_phy->phy_data->pcie_laneoff, + HIWORD_UPDATE(PHY_LANE_IDLE_OFF, + PHY_LANE_IDLE_MASK, + PHY_LANE_IDLE_A_SHIFT + i)); + } + + return 0; +} + static const struct phy_ops ops = { .init = rockchip_pcie_phy_init, .exit = rockchip_pcie_phy_exit, .power_on = rockchip_pcie_phy_power_on, .power_off = rockchip_pcie_phy_power_off, + .set_mode = rockchip_pcie_phy_set_mode, .owner = THIS_MODULE, };