Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp581677imb; Fri, 1 Mar 2019 08:23:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwnkFyyPRFK93iNHYC0CHcYLs/JUkXr4VwDyxjvpVdah8gv6vS5ngYFhVef7vkpsgfr02q6 X-Received: by 2002:a17:902:1347:: with SMTP id r7mr6317070ple.82.1551457420045; Fri, 01 Mar 2019 08:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551457420; cv=none; d=google.com; s=arc-20160816; b=Zz1SBYePgcId/7kxZQ8FCBoQTv3PMM3BDo+BWgAKyW+pkQ1z3gExuvBfNU41nKnW56 naQEchZy+3U410Sfe2+X1Jolo4v/C4F5lYT4JAYfnm9TIIl3EMggcNxMMsHmBRLN+EUT 9jcII+ektJh6lJZ7pyUyFf+073rByZ1ZdTuQhC6NAlmMjTxmJLAbj1KgT1QrWWKUq9S6 ZbUIvWHp5I8pUEzfLQqwLM9BfZ4Jup2DmxC1lzGwr+/xH/rwt7L526mcmgaj5SC5qs3c 3si91XpWopLw7KBIoS06Wk52/tpux7m/qvuNFeAX6M36frm5jIgSZmIuQWQxm05HNvNK 4urw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=kVLZu0Rl+hIUVKA7Nak4rY2/ExNkxS2beWQ0xzhzPvY=; b=fBKrmVEv4be0TD+HKyilGxyhDrjSAdOEXJh8liEtNtRqjwaCR6x1iWMOxtGLPwikP4 s0l5c+OwK+ErqbkqigW7NpvC+vr6/oJtFRvFxC7tNEBpXz//0+wSdv6lCnHqjGSgys2L o0KfUqKN8jKM4JP40MqY2o4/Uc35H83e8ILSZngD2i3iCIU5f+CG9KKcozApOMfuB0ZS nnbMpv2Df+BWUtRubXC5QhHkPGGFcNs8OH3HSgwWEAFJRDthvY9T6Hoy8UAlnasjATE5 80U7Cfk8a81pogPXX4IAKxkBhl+Wn46u6hZbSZYK0dFXQUY4kiNYCEEjVdS6DXrvjgmv T0uA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u26si20077731pfh.113.2019.03.01.08.23.25; Fri, 01 Mar 2019 08:23:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389158AbfCAQWE convert rfc822-to-8bit (ORCPT + 99 others); Fri, 1 Mar 2019 11:22:04 -0500 Received: from vegas.theobroma-systems.com ([144.76.126.164]:60526 "EHLO mail.theobroma-systems.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389010AbfCAQWC (ORCPT ); Fri, 1 Mar 2019 11:22:02 -0500 Received: from ip092042140082.rev.nessus.at ([92.42.140.82]:56208 helo=[10.2.146.249]) by mail.theobroma-systems.com with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gzkun-0005mY-B6; Fri, 01 Mar 2019 17:21:37 +0100 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: [PATCH 1/3] phy: rockchip-emmc: Allow to set drive impedance via DTS. From: =?utf-8?Q?Christoph_M=C3=BCllner?= In-Reply-To: <2706069.0FZLJLT2V8@phil> Date: Fri, 1 Mar 2019 17:21:36 +0100 Cc: robh+dt@kernel.org, mark.rutland@arm.com, shawn.lin@rock-chips.com, Philipp Tomsich , Kishon Vijay Abraham I , Enric Balletbo i Serra , Klaus Goger , Douglas Anderson , Viresh Kumar , Matthias Brugger , Emil Renner Berthing , Tony Xie , Randy Li , Vicente Bergas , Ezequiel Garcia , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <32D33089-37C4-4086-88B1-5408A0782917@theobroma-systems.com> References: <20190301153348.29870-1-christoph.muellner@theobroma-systems.com> <2706069.0FZLJLT2V8@phil> To: Heiko Stuebner X-Mailer: Apple Mail (2.3445.9.1) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Heiko, > On 01.03.2019, at 16:59, Heiko Stuebner wrote: > > Hi Christoph, > > Am Freitag, 1. März 2019, 16:33:43 CET schrieb Christoph Muellner: >> The rockchip-emmc PHY can be configured with different >> drive impedance values. Currenlty a value of 50 Ohm is >> hard coded into the driver. >> >> This patch introduces the DTS property 'drive-impedance-ohm' >> for the rockchip-emmc phy node, which uses the value from the DTS >> to setup the drive impedance accordingly. >> >> Signed-off-by: Christoph Muellner >> Signed-off-by: Philipp Tomsich >> --- >> drivers/phy/rockchip/phy-rockchip-emmc.c | 38 ++++++++++++++++++++++++++++++-- > > looks good on first glance, but is missing an addition to the emmc-phy > devicetree binding in > Documentation/devicetree/bindings/phy/rockchip-emmc-phy.txt you are right. I've just sent that in a separate patch (DT doc changes need to be in a separate commit anyways). Thanks, Christoph > > > Heiko > >> 1 file changed, 36 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/phy/rockchip/phy-rockchip-emmc.c b/drivers/phy/rockchip/phy-rockchip-emmc.c >> index 19bf84f0bc67..5413fa73dd45 100644 >> --- a/drivers/phy/rockchip/phy-rockchip-emmc.c >> +++ b/drivers/phy/rockchip/phy-rockchip-emmc.c >> @@ -87,6 +87,7 @@ struct rockchip_emmc_phy { >> unsigned int reg_offset; >> struct regmap *reg_base; >> struct clk *emmcclk; >> + unsigned int drive_impedance; >> }; >> >> static int rockchip_emmc_phy_power(struct phy *phy, bool on_off) >> @@ -281,10 +282,10 @@ static int rockchip_emmc_phy_power_on(struct phy *phy) >> { >> struct rockchip_emmc_phy *rk_phy = phy_get_drvdata(phy); >> >> - /* Drive impedance: 50 Ohm */ >> + /* Drive impedance: from DTS */ >> 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)); >> >> @@ -314,6 +315,28 @@ static const struct phy_ops ops = { >> .owner = THIS_MODULE, >> }; >> >> +static u32 convert_drive_impedance_ohm(struct platform_device *pdev, u32 dr_ohm) >> +{ >> + switch (dr_ohm) { >> + case 100: >> + return PHYCTRL_DR_100OHM; >> + case 66: >> + return PHYCTRL_DR_66OHM; >> + case 50: >> + return PHYCTRL_DR_50OHM; >> + case 40: >> + return PHYCTRL_DR_40OHM; >> + case 33: >> + return PHYCTRL_DR_33OHM; >> + } >> + >> + dev_warn(&pdev->dev, >> + "Invalid value %u for drive-impedance-ohm. " >> + "Falling back to 50 Ohm.\n", >> + dr_ohm); >> + return PHYCTRL_DR_50OHM; >> +} >> + >> static int rockchip_emmc_phy_probe(struct platform_device *pdev) >> { >> struct device *dev = &pdev->dev; >> @@ -322,6 +345,7 @@ static int rockchip_emmc_phy_probe(struct platform_device *pdev) >> struct phy_provider *phy_provider; >> struct regmap *grf; >> unsigned int reg_offset; >> + u32 val; >> >> if (!dev->parent || !dev->parent->of_node) >> return -ENODEV; >> @@ -345,6 +369,16 @@ static int rockchip_emmc_phy_probe(struct platform_device *pdev) >> rk_phy->reg_offset = reg_offset; >> rk_phy->reg_base = grf; >> >> + if (of_property_read_u32(dev->of_node, "drive-impedance-ohm", &val)) { >> + dev_info(dev, >> + "Missing drive-impedance-ohm property in node %s " >> + "Falling back to 50 Ohm.\n", >> + dev->of_node->name); >> + rk_phy->drive_impedance = PHYCTRL_DR_50OHM; >> + } else { >> + rk_phy->drive_impedance = convert_drive_impedance_ohm(pdev, val); >> + } >> + >> generic_phy = devm_phy_create(dev, dev->of_node, &ops); >> if (IS_ERR(generic_phy)) { >> dev_err(dev, "failed to create PHY\n"); >> > > > >