From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2F1BC43381 for ; Fri, 1 Mar 2019 15:59:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D9252084F for ; Fri, 1 Mar 2019 15:59:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jCetTsRM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D9252084F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sntech.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B/MI3hrSm/w3SZw4tEWHlTmMPTqX9N6R4a5T1ZRZFGc=; b=jCetTsRMIKKO3D v5laaOaTQpN7l7PxkI6e0TjEIFs2Jgz06Hw0DFR711cv69ZGTzFXgwA992QYnz3gIvlN7T/AXSAe1 dRRL1jbCstuWP5P8LKhS1Nfeh4xP7LqkoStGH7bhCnEEbpYbzVChcSXd4/QeNdr3H3nPTYi954Ll/ jpdV5AwMVmlE5Lf9lvBlAIntKZ/Pcrvnj0uTwZ+kE/DRmf6WLuooJF1Af5bJV59yue92ZyThhlUJM 7dw8y4oUI+W2odjtFI+h3bQtFygGt4zXFptNzqGqb7o1hf7OFt/52jy+sUaTADsAjMGHtGPk8uotK 4sQ19DyHIbaXMzDBbLCQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzkZl-000850-Nj; Fri, 01 Mar 2019 15:59:53 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzkZh-00084L-GU; Fri, 01 Mar 2019 15:59:51 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_075949_702498_B8B67CBC X-CRM114-Status: GOOD ( 21.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Matthias Brugger , linux-kernel@vger.kernel.org, Emil Renner Berthing , Tony Xie , Viresh Kumar , shawn.lin@rock-chips.com, Randy Li , Douglas Anderson , Vicente Bergas , Kishon Vijay Abraham I , linux-rockchip@lists.infradead.org, robh+dt@kernel.org, Klaus Goger , Enric Balletbo i Serra , Philipp Tomsich , Ezequiel Garcia , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Christoph, Am Freitag, 1. M=E4rz 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/rockc= hip/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 *p= hy) > { > struct rockchip_emmc_phy *rk_phy =3D 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 =3D { > .owner =3D 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 =3D &pdev->dev; > @@ -322,6 +345,7 @@ static int rockchip_emmc_phy_probe(struct platform_de= vice *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_d= evice *pdev) > rk_phy->reg_offset =3D reg_offset; > rk_phy->reg_base =3D 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 =3D PHYCTRL_DR_50OHM; > + } else { > + rk_phy->drive_impedance =3D convert_drive_impedance_ohm(pdev, val); > + } > + > generic_phy =3D devm_phy_create(dev, dev->of_node, &ops); > if (IS_ERR(generic_phy)) { > dev_err(dev, "failed to create PHY\n"); > = _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel