From patchwork Thu Jan 5 09:31:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 9498785 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 9A4E060235 for ; Thu, 5 Jan 2017 09:33:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7638E28156 for ; Thu, 5 Jan 2017 09:33:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B24328173; Thu, 5 Jan 2017 09:33:27 +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=-2.0 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM,URIBL_BLACK autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1434228156 for ; Thu, 5 Jan 2017 09:33:17 +0000 (UTC) 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 1cP4Q8-0001g4-Sq; Thu, 05 Jan 2017 09:33:16 +0000 Received: from lucky1.263xmail.com ([211.157.147.135]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cP4Q5-0001SC-Qv for linux-rockchip@lists.infradead.org; Thu, 05 Jan 2017 09:33:16 +0000 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.11]) by lucky1.263xmail.com (Postfix) with ESMTP id 0DEB39CE; Thu, 5 Jan 2017 17:32:49 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 95D8342A; Thu, 5 Jan 2017 17:32:45 +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: <8c9528db280d41a5705c915d551df547> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 16642PBYVJT; Thu, 05 Jan 2017 17:32:46 +0800 (CST) From: Shawn Lin To: Kishon Vijay Abraham I Subject: [PATCH 2/2] phy: rockchip-emmc: try to get drive impedance from DT Date: Thu, 5 Jan 2017 17:31:22 +0800 Message-Id: <1483608682-226716-2-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483608682-226716-1-git-send-email-shawn.lin@rock-chips.com> References: <1483608682-226716-1-git-send-email-shawn.lin@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170105_013314_803312_44135C53 X-CRM114-Status: UNSURE ( 7.97 ) 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: devicetree@vger.kernel.org, Heiko Stuebner , Shawn Lin , Douglas Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Rob Herring 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 Try to get drive impedance from DT and use it, otherwise use 50ohm by default in order not to break the existing boards as 50ohm works fine for them already. Signed-off-by: Shawn Lin --- drivers/phy/phy-rockchip-emmc.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/phy/phy-rockchip-emmc.c b/drivers/phy/phy-rockchip-emmc.c index f1b24f1..7fd4a3e 100644 --- a/drivers/phy/phy-rockchip-emmc.c +++ b/drivers/phy/phy-rockchip-emmc.c @@ -78,6 +78,7 @@ struct rockchip_emmc_phy { unsigned int reg_offset; + unsigned int drive_impedance; struct regmap *reg_base; struct clk *emmcclk; }; @@ -288,7 +289,7 @@ static int rockchip_emmc_phy_power_on(struct phy *phy) /* Drive impedance: 50 Ohm */ regmap_write(rk_phy->reg_base, rk_phy->reg_offset + GRF_EMMCPHY_CON6, - HIWORD_UPDATE(PHYCTRL_DR_50OHM, + HIWORD_UPDATE(rk_phy->drive_impedance, PHYCTRL_DR_MASK, PHYCTRL_DR_SHIFT)); @@ -346,6 +347,32 @@ static int rockchip_emmc_phy_probe(struct platform_device *pdev) return -EINVAL; } + rk_phy->drive_impedance = PHYCTRL_DR_50OHM; + if (!of_property_read_u32(dev->of_node, "drive_impedance", + &rk_phy->drive_impedance)) { + switch (rk_phy->drive_impedance) { + case 33: + rk_phy->drive_impedance = PHYCTRL_DR_33OHM; + break; + case 40: + rk_phy->drive_impedance = PHYCTRL_DR_40OHM; + break; + case 50: + rk_phy->drive_impedance = PHYCTRL_DR_50OHM; + break; + case 66: + rk_phy->drive_impedance = PHYCTRL_DR_66OHM; + break; + case 100: + rk_phy->drive_impedance = PHYCTRL_DR_100OHM; + break; + default: + dev_info(dev, "invalid drive impedance.\n"); + rk_phy->drive_impedance = PHYCTRL_DR_50OHM; + break; + } + } + rk_phy->reg_offset = reg_offset; rk_phy->reg_base = grf;