linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Lin <shawn.lin@rock-chips.com>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	devicetree@vger.kernel.org, linux-rockchip@lists.infradead.org,
	Heiko Stuebner <heiko@sntech.de>,
	Douglas Anderson <dianders@chromium.org>,
	linux-kernel@vger.kernel.org,
	Shawn Lin <shawn.lin@rock-chips.com>
Subject: [PATCH 2/2] phy: rockchip-emmc: try to get drive impedance from DT
Date: Thu,  5 Jan 2017 17:31:22 +0800	[thread overview]
Message-ID: <1483608682-226716-2-git-send-email-shawn.lin@rock-chips.com> (raw)
In-Reply-To: <1483608682-226716-1-git-send-email-shawn.lin@rock-chips.com>

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 <shawn.lin@rock-chips.com>
---

 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;
 
-- 
1.9.1

  reply	other threads:[~2017-01-05  9:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05  9:31 [PATCH 1/2] Documentation: phy: introduce new optional property to specify drive impedance Shawn Lin
2017-01-05  9:31 ` Shawn Lin [this message]
2017-01-06  0:51   ` [PATCH 2/2] phy: rockchip-emmc: try to get drive impedance from DT Doug Anderson
2017-01-06  1:09     ` Shawn Lin
2017-01-06 18:29       ` Doug Anderson
2017-01-05 11:15 ` [PATCH 1/2] Documentation: phy: introduce new optional property to specify drive impedance Heiko Stübner
2017-01-06  0:44   ` Shawn Lin
2017-01-09 18:06 ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1483608682-226716-2-git-send-email-shawn.lin@rock-chips.com \
    --to=shawn.lin@rock-chips.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=heiko@sntech.de \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).