Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4809812imb; Thu, 7 Mar 2019 00:44:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzlaKuRa5PlrLYbodavUaiZxkRNID1TrscHO9xhw7ocYPw6ldrLFIM3q3egsjmVKmcMjDQF X-Received: by 2002:a62:3001:: with SMTP id w1mr11716060pfw.59.1551948266437; Thu, 07 Mar 2019 00:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551948266; cv=none; d=google.com; s=arc-20160816; b=rZ7J2roa5t4tviwWuCConujuFzPF7lT61HeqsCVI3qtPjfEOwATMPTUkrOD0+KM9zu Veow1XMA1V+feYUgnUCnkEOcTcVZCRpmMPYPYsnY7m/UUf7faq8uEnzq3LVwTO3GNrR2 ZJbQ3Hf3RxDVQRON0a8iWJ3SerPLR6dOPWAoMLjX90VW2LlZZfqNf6HxrRDryoXse1sr uBYmS6YpW1/y5wHGzQyZ+BRYZS1hP4TWyAGbpUTFLVMxHkL/nxjFofY4W1UWiM2LyYy6 MUdsd512Im0kwlnTiJUGzc0SX0+2oXkqiNnk6QVyWBI92DZOist5eaMcbKNIf+m/BiCO mSMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=QB8mQH4dmJXh5olz/DbW/70jQBXX5Xe0WTXz+7bTpeg=; b=zcF9rLzdgyPDWnogG+dqA85mX/JPDRjOBnMJjydaOv9vHBVllVbTrHTXab/VcxH77J J7x2JOdX0tBTVtrbT/UlSab54PAIE6IJkuBuT4UtH5uuUz+7bIbPKPfu83y9x8BKYjeP JyBuztf0Mge+CG/zViRywENg5dGyHmywg8Ydsk5GiIJqNMmBrFBXrN0YU9Skt3OrYIMm JWbkLoAEmIZl3TgXpvr0leaYeLr8epOO/IveVzREnsID5CY2i4gj19DCb+xS+RRh6ygk S5iKQjtteB8ujhXqBjnpmwlpqOML0PiGgkRbsTjpyuwyJskdBfVD6ZjqbNiSP6M5bIlf j26Q== 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 n7si3707915plk.85.2019.03.07.00.44.11; Thu, 07 Mar 2019 00:44:26 -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 S1726395AbfCGImf (ORCPT + 99 others); Thu, 7 Mar 2019 03:42:35 -0500 Received: from vegas.theobroma-systems.com ([144.76.126.164]:34645 "EHLO mail.theobroma-systems.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbfCGImc (ORCPT ); Thu, 7 Mar 2019 03:42:32 -0500 Received: from ip092042140082.rev.nessus.at ([92.42.140.82]:54490 helo=purcell.lan) by mail.theobroma-systems.com with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1h1obO-000810-Fp; Thu, 07 Mar 2019 09:42:06 +0100 From: Christoph Muellner To: robh+dt@kernel.org, mark.rutland@arm.com, heiko@sntech.de, shawn.lin@rock-chips.com Cc: Christoph Muellner , Philipp Tomsich , Kishon Vijay Abraham I , Brian Norris , Matthias Brugger , Enric Balletbo i Serra , Klaus Goger , Douglas Anderson , Viresh Kumar , Jeffy Chen , Vicente Bergas , Randy Li , Tony Xie , Ezequiel Garcia , Lin Huang , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH v2 1/4] phy: rockchip-emmc: Allow to set drive impedance via DTS. Date: Thu, 7 Mar 2019 09:41:53 +0100 Message-Id: <20190307084159.25236-1-christoph.muellner@theobroma-systems.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-emmc.c b/drivers/phy/rockchip/phy-rockchip-emmc.c index 19bf84f0bc67..b804c6bf4b55 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,26 @@ 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.\n", + dr_ohm); + return PHYCTRL_DR_50OHM; +} + static int rockchip_emmc_phy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -322,6 +343,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; @@ -344,6 +366,10 @@ static int rockchip_emmc_phy_probe(struct platform_device *pdev) rk_phy->reg_offset = reg_offset; rk_phy->reg_base = grf; + rk_phy->drive_impedance = PHYCTRL_DR_50OHM; + + if (!of_property_read_u32(dev->of_node, "drive-impedance-ohm", &val)) + 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)) { -- 2.11.0