Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp512445pxu; Sun, 22 Nov 2020 17:25:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyd8MRdp6SDJxBjd6nMF9crMJ4QfYmkEkQQqWW0iQ9w2HMoUrHzwdk9TAUhmGxj00EnUFLP X-Received: by 2002:a17:906:90c3:: with SMTP id v3mr15075055ejw.433.1606094739441; Sun, 22 Nov 2020 17:25:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606094739; cv=none; d=google.com; s=arc-20160816; b=B6YLp9dBoPBZpkuCsm0KtvjtIam8js3Oo7zaN7I/NbQKp2THMZ43GUq7LjJdC65XZV cIyO+4zrDfVIrrQjkwEh+fn4rZAYQGtQbFSM7OZNOiXWwLYO914dwH1sVAqzo1ODMywm 8B3iy0CqG/XeEflazu21toVwjwnltCpxZGzb+da20rMlFZLltY2KNSl1aTFpJ/94pmtW 73H9ByqUpitGULW5NCYJd86cuAqsmS2oQBqh5apn5OjaXjlmRF3mK/PnVqJ0gkYrYluV HdT0gCGK7K0I2VPdrvp9MkoIkAEncoQKLZpldbaxX6sm/2F9FuOc2mS7m1bARcHs/X0O DbiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wD654qs0k//gW+67LA4ZZp/K3+FDPI5u/Ahc0zUQPLo=; b=LlCwmvslSMtUhLN+G23m6i+fzlobjZ4OC0s4uvU9muODgh7IoB8y6octXICXX37jRd 24Iw1JVEM5PV/Suf4A2srvUw5sneuhYy66D5N9wU78XtJC51MlApFsuw+jJBK5n3W1dZ 3O85BPSfCC1aDAjbm1dzXeykm6vGDxCFWAwOPUtCa1FcrEKy5KS8NtUWUVFJWWy0QyyG 2xos+awJM7+Bb3EDnQCx5JL2Ptv+InZ5mFPtqZy05FNA+kVsw/iIY1LkAHGzMVCtYNEj HrEebnEHyhUpu1iVkyYWR41tDm6aQcvxGDMEnYhfP/l0b91UMYSVAzm1upGRIajdgli9 P11Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nmzXQTBS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c26si5651877eja.409.2020.11.22.17.25.15; Sun, 22 Nov 2020 17:25:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nmzXQTBS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726903AbgKWAbS (ORCPT + 99 others); Sun, 22 Nov 2020 19:31:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgKWAbR (ORCPT ); Sun, 22 Nov 2020 19:31:17 -0500 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 227CEC0613CF; Sun, 22 Nov 2020 16:31:17 -0800 (PST) Received: by mail-lf1-x144.google.com with SMTP id u18so21416127lfd.9; Sun, 22 Nov 2020 16:31:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wD654qs0k//gW+67LA4ZZp/K3+FDPI5u/Ahc0zUQPLo=; b=nmzXQTBSItX6nvR/ymQPcHulpl/uluIocXFTViVY4SBvamuAiAs0yXnHmv+x+kNhYd ZJ0NC0wqLlXFrSzo6YSu4PhkuIqfQM2wvV/tm07css+e6ayxe5riMQKkmjG0J/MmhrgU p/C5+4SWOY3pGzaekXX3GiEXyvv1v8PkVzZZ3Il1bdpJdZBkcBPt8vxVHy0dr657cdZq bQLPYd/Q5gr0qzeFHMg37igAHuUR0FGNHSK2aPsys39F7bhoHMIUmijt0A6tW3lEkhzj f88uuVoffgBqRf0DcWL5KMmRF0oSAQP67BT3P2Elu/vflED1G3HqNLNhLgV9unjhqoIi 46oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wD654qs0k//gW+67LA4ZZp/K3+FDPI5u/Ahc0zUQPLo=; b=UHNbtRhERhIK83ToDsR/DCXQ74LnDuTV6kjNhiq59V40hmkYPmHcqNvR3edgCQtNQP wkrMBno88eeFaapj8l4C3j0AWBe6zo68ZKICx9nQqpPHNygl21bsftfGuWwTWHtONvCx 4sAbM5kwuZC7zxE9oOX0WYaDv2MgT8jnXEj6udzJ/73SYKtk7iTZuV7TiaAv6Zdhi5cP qkopKExaYE0PPlYxDB62Kzq59kKC+gziNTOJFkAosWy49d6LusDBv/MBs0mOVKn33c0a Zl5Ka+0BKEl0o290ohFf6A0R8DSyT5IXbPBg3O/beeHr6dowhlwgh5wefVAxA7ga9Yw4 j5fQ== X-Gm-Message-State: AOAM531kl3syP8u2HKT2xAhr5gTGXf07CL5Wi+mbqaC8f7LyRGgRmJGm X1RT+6+roFJhsJm8thNc5QI= X-Received: by 2002:a19:fc03:: with SMTP id a3mr13106796lfi.472.1606091475657; Sun, 22 Nov 2020 16:31:15 -0800 (PST) Received: from localhost.localdomain (109-252-193-159.dynamic.spd-mgts.ru. [109.252.193.159]) by smtp.gmail.com with ESMTPSA id r27sm1225823lfn.290.2020.11.22.16.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2020 16:31:15 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Georgi Djakov , Rob Herring , Michael Turquette , Stephen Boyd , Peter De Schrijver , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Mikko Perttunen , Viresh Kumar , Peter Geis , Nicolas Chauvet , Krzysztof Kozlowski Cc: linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v10 02/19] memory: tegra20: Support hardware versioning and clean up OPP table initialization Date: Mon, 23 Nov 2020 03:27:06 +0300 Message-Id: <20201123002723.28463-3-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123002723.28463-1-digetx@gmail.com> References: <20201123002723.28463-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support hardware versioning, which is now required for Tegra20 EMC OPP. Clean up OPP table initialization by using a error code returned by OPP API for judging about the OPP table presence in a device-tree and remove OPP regulator initialization because we're now going to use power domain instead of a raw regulator. This puts Tegra20 EMC OPP preparation on par with the Tegra30/124 EMC drivers. Signed-off-by: Dmitry Osipenko --- drivers/memory/tegra/tegra20-emc.c | 48 +++++++++++++----------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c index 0320d9df4a20..686aaf477d8a 100644 --- a/drivers/memory/tegra/tegra20-emc.c +++ b/drivers/memory/tegra/tegra20-emc.c @@ -910,43 +910,36 @@ static int tegra_emc_interconnect_init(struct tegra_emc *emc) static int tegra_emc_opp_table_init(struct tegra_emc *emc) { - struct opp_table *reg_opp_table = NULL, *clk_opp_table; - const char *rname = "core"; + u32 hw_version = BIT(tegra_sku_info.soc_process_id); + struct opp_table *clk_opp_table, *hw_opp_table; int err; - /* - * Legacy device-trees don't have OPP table and EMC driver isn't - * useful in this case. - */ - if (!device_property_present(emc->dev, "operating-points-v2")) { - dev_err(emc->dev, - "OPP table not found, please update your device tree\n"); - return -ENODEV; - } - - /* voltage scaling is optional */ - if (device_property_present(emc->dev, "core-supply")) { - reg_opp_table = dev_pm_opp_set_regulators(emc->dev, &rname, 1); - if (IS_ERR(reg_opp_table)) - return dev_err_probe(emc->dev, PTR_ERR(reg_opp_table), - "failed to set OPP regulator\n"); - } - clk_opp_table = dev_pm_opp_set_clkname(emc->dev, NULL); err = PTR_ERR_OR_ZERO(clk_opp_table); if (err) { dev_err(emc->dev, "failed to set OPP clk: %d\n", err); - goto put_reg_table; + return err; } - err = dev_pm_opp_of_add_table(emc->dev); + hw_opp_table = dev_pm_opp_set_supported_hw(emc->dev, &hw_version, 1); + err = PTR_ERR_OR_ZERO(hw_opp_table); if (err) { - dev_err(emc->dev, "failed to add OPP table: %d\n", err); + dev_err(emc->dev, "failed to set OPP supported HW: %d\n", err); goto put_clk_table; } - dev_info(emc->dev, "current clock rate %lu MHz\n", - clk_get_rate(emc->clk) / 1000000); + err = dev_pm_opp_of_add_table(emc->dev); + if (err) { + if (err == -ENODEV) + dev_err(emc->dev, "OPP table not found, please update your device tree\n"); + else + dev_err(emc->dev, "failed to add OPP table: %d\n", err); + + goto put_hw_table; + } + + dev_info(emc->dev, "OPP HW ver. 0x%x, current clock rate %lu MHz\n", + hw_version, clk_get_rate(emc->clk) / 1000000); /* first dummy rate-set initializes voltage state */ err = dev_pm_opp_set_rate(emc->dev, clk_get_rate(emc->clk)); @@ -959,11 +952,10 @@ static int tegra_emc_opp_table_init(struct tegra_emc *emc) remove_table: dev_pm_opp_of_remove_table(emc->dev); +put_hw_table: + dev_pm_opp_put_supported_hw(hw_opp_table); put_clk_table: dev_pm_opp_put_clkname(clk_opp_table); -put_reg_table: - if (reg_opp_table) - dev_pm_opp_put_regulators(reg_opp_table); return err; } -- 2.29.2