Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp630295imb; Fri, 1 Mar 2019 09:39:25 -0800 (PST) X-Google-Smtp-Source: APXvYqwWx99r/vRU+FIycfitx8fq5K2/+34em3swolldlCSgDQB99uPaWjBwPk460TkJNrywY5v3 X-Received: by 2002:a63:d205:: with SMTP id a5mr5975526pgg.142.1551461965466; Fri, 01 Mar 2019 09:39:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551461965; cv=none; d=google.com; s=arc-20160816; b=s2WQvPJ4RyMuqLV2Tccg6d0vMUkIGkkuMgO5wHm8uvzW2Ikr3vOOjAgFSMNO9peWWk MsI/TwEDka9lbR/vfLtqFSgplkB5gjAZAeOjmKQ/ruSBZJGPiuomoxisfZyVKbLdiYpg H34contVEbRibMwhUD3rYajXQgZzXaauWjQah6lrgncwD32z0DfIllUsrnSUM/r+XaLW ffehM7bHl4za3ZRbNufVWHDXaZNZL77+045kNW4n4EPWVoHWwT6OZ58q5NhCaaWxJTOq Ukbq9KuuK88rIEpJL42Rz4PD0FYEGKZJ4ODiDsNe/tGyuw9cZ+CYEeENAtcJZ3AMggvq zqjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uvPxttk3j8KlAqzPjMKqJJ2MA1/eNg5r7Ob8uRilylA=; b=kQgv2qVcQqGmPae8YM8459xQJUFlZYK+Fgz0SDDTSjJDMDZMhUkkIeD01lNVXY0bJ8 kcnVyfptfbbPXVvOBf1xwk1Oh2C4OfTVzWy6QpcqjkZP+1sJLHKJ2dQR9Ej2dgbV0zzY bmbHLWJl2xEO/QmW4So/i565lt6Y5xNq4CPjTrZVZi5Mv92NUrkLmuqB46QH0yfOK1Ac gfpJjSV2zm6l985nTOvd+qZGwnWnsa7FtS6IFR4ml5SSKQu0OFp5OIme4QBTTeztcCRZ op+gGnqlMwGTZT7/Sh8EI0FrEapdM7tm9iNTEIxWldqH9juhv+zTIqM6CNIm5kyBPiae MQ1Q== 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 b15si21428189pfm.72.2019.03.01.09.39.10; Fri, 01 Mar 2019 09:39:25 -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 S2388295AbfCAP7t convert rfc822-to-8bit (ORCPT + 99 others); Fri, 1 Mar 2019 10:59:49 -0500 Received: from gloria.sntech.de ([185.11.138.130]:57310 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728300AbfCAP7t (ORCPT ); Fri, 1 Mar 2019 10:59:49 -0500 Received: from p57b77bb0.dip0.t-ipconnect.de ([87.183.123.176] helo=phil.localnet) by gloria.sntech.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gzkZL-0004qR-0V; Fri, 01 Mar 2019 16:59:27 +0100 From: Heiko Stuebner To: Christoph Muellner 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 Subject: Re: [PATCH 1/3] phy: rockchip-emmc: Allow to set drive impedance via DTS. Date: Fri, 01 Mar 2019 16:59:25 +0100 Message-ID: <2706069.0FZLJLT2V8@phil> In-Reply-To: <20190301153348.29870-1-christoph.muellner@theobroma-systems.com> References: <20190301153348.29870-1-christoph.muellner@theobroma-systems.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="iso-8859-1" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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"); >