All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Georgi Djakov <georgi.djakov@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Peter De Schrijver <pdeschrijver@nvidia.com>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Mikko Perttunen <cyndis@kapsi.fi>
Cc: linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	devicetree@vger.kernel.org
Subject: [PATCH v5 09/36] memory: tegra20-emc: Initialize MC timings
Date: Fri, 14 Aug 2020 03:05:54 +0300	[thread overview]
Message-ID: <20200814000621.8415-10-digetx@gmail.com> (raw)
In-Reply-To: <20200814000621.8415-1-digetx@gmail.com>

We're going to add interconnect support to the EMC driver. Once this
support will be added, the Tegra20 devfreq driver will no longer be
able to use clk_round_rate(emc) for building up OPP table. It's quite
handy that struct tegra_mc contains memory timings which could be used
by the devfreq drivers instead of the clk rate-rounding. The tegra_mc
timings are populated by the MC driver only for Tegra30+ SoCs, hence
the Tegra20 EMC could populate timings by itself.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/memory/tegra/Kconfig       |  2 +-
 drivers/memory/tegra/tegra20-emc.c | 54 ++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/tegra/Kconfig b/drivers/memory/tegra/Kconfig
index c1cad4ce6251..5bf75b316a2f 100644
--- a/drivers/memory/tegra/Kconfig
+++ b/drivers/memory/tegra/Kconfig
@@ -10,7 +10,7 @@ config TEGRA_MC
 config TEGRA20_EMC
 	tristate "NVIDIA Tegra20 External Memory Controller driver"
 	default y
-	depends on ARCH_TEGRA_2x_SOC
+	depends on TEGRA_MC && ARCH_TEGRA_2x_SOC
 	help
 	  This driver is for the External Memory Controller (EMC) found on
 	  Tegra20 chips. The EMC controls the external DRAM on the board.
diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c
index 5aa3a1da2975..a02ffc09c39e 100644
--- a/drivers/memory/tegra/tegra20-emc.c
+++ b/drivers/memory/tegra/tegra20-emc.c
@@ -15,12 +15,15 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/sort.h>
 #include <linux/types.h>
 
 #include <soc/tegra/fuse.h>
 
+#include "mc.h"
+
 #define EMC_INTSTATUS				0x000
 #define EMC_INTMASK				0x004
 #define EMC_DBG					0x008
@@ -650,6 +653,45 @@ static void tegra_emc_debugfs_init(struct tegra_emc *emc)
 			    emc, &tegra_emc_debug_max_rate_fops);
 }
 
+static int tegra_emc_init_mc_timings(struct tegra_emc *emc)
+{
+	struct tegra_mc_timing *timing;
+	struct platform_device *pdev;
+	struct device_node *np;
+	struct tegra_mc *mc;
+	unsigned int i;
+
+	if (!emc->num_timings)
+		return 0;
+
+	np = of_find_compatible_node(NULL, NULL, "nvidia,tegra20-mc-gart");
+	if (!np)
+		return -ENOENT;
+
+	pdev = of_find_device_by_node(np);
+	of_node_put(np);
+	if (!pdev)
+		return -ENOENT;
+
+	mc = platform_get_drvdata(pdev);
+	if (!mc)
+		return -EPROBE_DEFER;
+
+	/* shouldn't happen */
+	WARN_ON(mc->num_timings);
+	WARN_ON(mc->timings);
+
+	mc->timings = devm_kcalloc(emc->dev, emc->num_timings, sizeof(*timing),
+				   GFP_KERNEL);
+	if (!mc->timings)
+		return -ENOMEM;
+
+	for (i = 0; i < emc->num_timings; i++, mc->num_timings++)
+		mc->timings[i].rate = emc->timings[i].rate;
+
+	return 0;
+}
+
 static int tegra_emc_probe(struct platform_device *pdev)
 {
 	struct device_node *np;
@@ -721,6 +763,18 @@ static int tegra_emc_probe(struct platform_device *pdev)
 		goto unset_cb;
 	}
 
+	/*
+	 * Only Tegra30+ SoCs are having Memory Controller timings initialized
+	 * by the MC driver. For Tegra20 we need to populate the MC timings
+	 * from here. The MC timings will be used by the Tegra20 devfreq driver.
+	 */
+	err = tegra_emc_init_mc_timings(emc);
+	if (err) {
+		dev_err(&pdev->dev, "failed to initialize mc timings: %d\n",
+			err);
+		goto unset_cb;
+	}
+
 	platform_set_drvdata(pdev, emc);
 	tegra_emc_debugfs_init(emc);
 
-- 
2.27.0


WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Georgi Djakov <georgi.djakov@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Peter De Schrijver <pdeschrijver@nvidia.com>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Mikko Perttunen <cyndis@kapsi.fi>
Cc: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-pm@vger.kernel.org
Subject: [PATCH v5 09/36] memory: tegra20-emc: Initialize MC timings
Date: Fri, 14 Aug 2020 03:05:54 +0300	[thread overview]
Message-ID: <20200814000621.8415-10-digetx@gmail.com> (raw)
In-Reply-To: <20200814000621.8415-1-digetx@gmail.com>

We're going to add interconnect support to the EMC driver. Once this
support will be added, the Tegra20 devfreq driver will no longer be
able to use clk_round_rate(emc) for building up OPP table. It's quite
handy that struct tegra_mc contains memory timings which could be used
by the devfreq drivers instead of the clk rate-rounding. The tegra_mc
timings are populated by the MC driver only for Tegra30+ SoCs, hence
the Tegra20 EMC could populate timings by itself.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/memory/tegra/Kconfig       |  2 +-
 drivers/memory/tegra/tegra20-emc.c | 54 ++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/tegra/Kconfig b/drivers/memory/tegra/Kconfig
index c1cad4ce6251..5bf75b316a2f 100644
--- a/drivers/memory/tegra/Kconfig
+++ b/drivers/memory/tegra/Kconfig
@@ -10,7 +10,7 @@ config TEGRA_MC
 config TEGRA20_EMC
 	tristate "NVIDIA Tegra20 External Memory Controller driver"
 	default y
-	depends on ARCH_TEGRA_2x_SOC
+	depends on TEGRA_MC && ARCH_TEGRA_2x_SOC
 	help
 	  This driver is for the External Memory Controller (EMC) found on
 	  Tegra20 chips. The EMC controls the external DRAM on the board.
diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c
index 5aa3a1da2975..a02ffc09c39e 100644
--- a/drivers/memory/tegra/tegra20-emc.c
+++ b/drivers/memory/tegra/tegra20-emc.c
@@ -15,12 +15,15 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/sort.h>
 #include <linux/types.h>
 
 #include <soc/tegra/fuse.h>
 
+#include "mc.h"
+
 #define EMC_INTSTATUS				0x000
 #define EMC_INTMASK				0x004
 #define EMC_DBG					0x008
@@ -650,6 +653,45 @@ static void tegra_emc_debugfs_init(struct tegra_emc *emc)
 			    emc, &tegra_emc_debug_max_rate_fops);
 }
 
+static int tegra_emc_init_mc_timings(struct tegra_emc *emc)
+{
+	struct tegra_mc_timing *timing;
+	struct platform_device *pdev;
+	struct device_node *np;
+	struct tegra_mc *mc;
+	unsigned int i;
+
+	if (!emc->num_timings)
+		return 0;
+
+	np = of_find_compatible_node(NULL, NULL, "nvidia,tegra20-mc-gart");
+	if (!np)
+		return -ENOENT;
+
+	pdev = of_find_device_by_node(np);
+	of_node_put(np);
+	if (!pdev)
+		return -ENOENT;
+
+	mc = platform_get_drvdata(pdev);
+	if (!mc)
+		return -EPROBE_DEFER;
+
+	/* shouldn't happen */
+	WARN_ON(mc->num_timings);
+	WARN_ON(mc->timings);
+
+	mc->timings = devm_kcalloc(emc->dev, emc->num_timings, sizeof(*timing),
+				   GFP_KERNEL);
+	if (!mc->timings)
+		return -ENOMEM;
+
+	for (i = 0; i < emc->num_timings; i++, mc->num_timings++)
+		mc->timings[i].rate = emc->timings[i].rate;
+
+	return 0;
+}
+
 static int tegra_emc_probe(struct platform_device *pdev)
 {
 	struct device_node *np;
@@ -721,6 +763,18 @@ static int tegra_emc_probe(struct platform_device *pdev)
 		goto unset_cb;
 	}
 
+	/*
+	 * Only Tegra30+ SoCs are having Memory Controller timings initialized
+	 * by the MC driver. For Tegra20 we need to populate the MC timings
+	 * from here. The MC timings will be used by the Tegra20 devfreq driver.
+	 */
+	err = tegra_emc_init_mc_timings(emc);
+	if (err) {
+		dev_err(&pdev->dev, "failed to initialize mc timings: %d\n",
+			err);
+		goto unset_cb;
+	}
+
 	platform_set_drvdata(pdev, emc);
 	tegra_emc_debugfs_init(emc);
 
-- 
2.27.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-08-14  0:09 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14  0:05 [PATCH v5 00/36] Introduce memory interconnect for NVIDIA Tegra SoCs Dmitry Osipenko
2020-08-14  0:05 ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 01/36] clk: Export clk_hw_reparent() Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 02/36] clk: tegra: Remove Memory Controller lock Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 03/36] clk: tegra: Export Tegra20 EMC kernel symbols Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 04/36] memory: tegra20-emc: Make driver modular Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 05/36] memory: tegra30-emc: " Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 06/36] memory: tegra124-emc: " Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 07/36] memory: tegra124-emc: Use devm_platform_ioremap_resource Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 08/36] soc/tegra: fuse: Export tegra_read_ram_code() Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` Dmitry Osipenko [this message]
2020-08-14  0:05   ` [PATCH v5 09/36] memory: tegra20-emc: Initialize MC timings Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 10/36] PM / devfreq: tegra20: Silence deferred probe error Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 11/36] PM / devfreq: tegra30: " Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 12/36] PM / devfreq: tegra20: Use MC timings for building OPP table Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  1:00   ` Chanwoo Choi
2020-08-14  1:00     ` Chanwoo Choi
2020-08-14  0:05 ` [PATCH v5 13/36] PM / devfreq: tegra30: " Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  2:02   ` Chanwoo Choi
2020-08-14  2:02     ` Chanwoo Choi
2020-08-14 16:47     ` Dmitry Osipenko
2020-08-14 16:47       ` Dmitry Osipenko
2020-08-28  1:47       ` Chanwoo Choi
2020-08-28  1:47         ` Chanwoo Choi
2020-08-28  8:30         ` Dmitry Osipenko
2020-08-28  8:30           ` Dmitry Osipenko
2020-08-14  0:05 ` [PATCH v5 14/36] PM / devfreq: tegra20: Add error messages to tegra_devfreq_target() Dmitry Osipenko
2020-08-14  0:05   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 15/36] PM / devfreq: tegra30: " Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 16/36] PM / devfreq: tegra20: Adjust clocks conversion ratio and polling interval Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 17/36] PM / devfreq: tegra20: Relax Kconfig dependency Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 18/36] dt-bindings: memory: tegra20: mc: Document new interconnect property Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 19/36] dt-bindings: memory: tegra20: emc: " Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 20/36] dt-bindings: memory: tegra30: mc: " Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 21/36] dt-bindings: memory: tegra30: emc: " Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 22/36] dt-bindings: host1x: Document new interconnect properties Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-25  2:09   ` Rob Herring
2020-08-25  2:09     ` Rob Herring
2020-08-14  0:06 ` [PATCH v5 23/36] dt-bindings: memory: tegra20: Add memory client IDs Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 24/36] dt-bindings: memory: tegra30: " Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 25/36] ARM: tegra: Add interconnect properties to Tegra20 device-tree Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 26/36] ARM: tegra: Add interconnect properties to Tegra30 device-tree Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 27/36] memory: tegra-mc: Register as interconnect provider Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-09-09  8:31   ` Georgi Djakov
2020-09-09  8:31     ` Georgi Djakov
2020-09-09 21:15     ` Dmitry Osipenko
2020-09-09 21:15       ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 28/36] memory: tegra20-emc: Use devm_platform_ioremap_resource Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 29/36] memory: tegra20-emc: Continue probing if timings are missing in device-tree Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 30/36] memory: tegra20-emc: Register as interconnect provider Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-09-09  8:32   ` Georgi Djakov
2020-09-09  8:32     ` Georgi Djakov
2020-08-14  0:06 ` [PATCH v5 31/36] memory: tegra20-emc: Create tegra20-devfreq device Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 32/36] memory: tegra30-emc: Continue probing if timings are missing in device-tree Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 33/36] memory: tegra30-emc: Register as interconnect provider Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-09-09  8:32   ` Georgi Djakov
2020-09-09  8:32     ` Georgi Djakov
2020-08-14  0:06 ` [PATCH v5 34/36] drm/tegra: dc: Support memory bandwidth management Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 35/36] drm/tegra: dc: Tune up high priority request controls for Tegra20 Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko
2020-08-14  0:06 ` [PATCH v5 36/36] drm/tegra: dc: Extend debug stats with total number of events Dmitry Osipenko
2020-08-14  0:06   ` Dmitry Osipenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200814000621.8415-10-digetx@gmail.com \
    --to=digetx@gmail.com \
    --cc=cw00.choi@samsung.com \
    --cc=cyndis@kapsi.fi \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=georgi.djakov@linaro.org \
    --cc=jonathanh@nvidia.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.