diff mbox

[2/2] phy: rockchip-emmc: try to get drive impedance from DT

Message ID 1483608682-226716-2-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shawn Lin Jan. 5, 2017, 9:31 a.m. UTC
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(-)

Comments

Doug Anderson Jan. 6, 2017, 12:51 a.m. UTC | #1
Hi,

On Thu, Jan 5, 2017 at 1:31 AM, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> 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(-)

I could have sworn that you somehow needed to make sure that the eMMC
part itself needed to also be updated to be told the matching drive
impedance so you don't get a mismatch.  How do you make that work?
...or am I just confused.  I meant to try to dig more, but ran out of
time today.  :(

-Doug
Shawn Lin Jan. 6, 2017, 1:09 a.m. UTC | #2
On 2017/1/6 8:51, Doug Anderson wrote:
> Hi,
>
> On Thu, Jan 5, 2017 at 1:31 AM, Shawn Lin <shawn.lin@rock-chips.com> wrote:
>> 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(-)
>
> I could have sworn that you somehow needed to make sure that the eMMC
> part itself needed to also be updated to be told the matching drive
> impedance so you don't get a mismatch.  How do you make that work?

No I didn't. So that means the eMMC part itself still couldn't be
updated. The intention for me to introduce this only for emmc phy is
that I got report that the default drive impedance of one eMMC is not
50ohms, so now we haven't been able to update it for eMMC part but maybe
we could just update it for the phy itself to match them in between.


> ...or am I just confused.  I meant to try to dig more, but ran out of
> time today.  :(
>
> -Doug
>
>
>
Doug Anderson Jan. 6, 2017, 6:29 p.m. UTC | #3
Hi,

On Thu, Jan 5, 2017 at 5:09 PM, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> On 2017/1/6 8:51, Doug Anderson wrote:
>>
>> Hi,
>>
>> On Thu, Jan 5, 2017 at 1:31 AM, Shawn Lin <shawn.lin@rock-chips.com>
>> wrote:
>>>
>>> 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(-)
>>
>>
>> I could have sworn that you somehow needed to make sure that the eMMC
>> part itself needed to also be updated to be told the matching drive
>> impedance so you don't get a mismatch.  How do you make that work?
>
>
> No I didn't. So that means the eMMC part itself still couldn't be
> updated. The intention for me to introduce this only for emmc phy is
> that I got report that the default drive impedance of one eMMC is not
> 50ohms, so now we haven't been able to update it for eMMC part but maybe
> we could just update it for the phy itself to match them in between.

Interesting.  ...the eMMC spec says that 50 Ohm is mandatory, so we
know that 50 Ohm must be supported.

...and even if the default isn't 50 Ohm then wouldn't it get set to 50
OHm when we set the HS_TIMING ?


-Doug
diff mbox

Patch

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;