From: Peter De Schrijver <pdeschrijver@nvidia.com>
To: <linux-clk@vger.kernel.org>
Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Subject: [RFC 06/14] memory: tegra: mc: Add support for scaled LA
Date: Sat, 15 Sep 2018 00:48:07 +0300 [thread overview]
Message-ID: <1536961695-27809-7-git-send-email-pdeschrijver@nvidia.com> (raw)
In-Reply-To: <1536961695-27809-1-git-send-email-pdeschrijver@nvidia.com>
Besides for each memory client, Tegra210 also has a number of 'scaled latency
allowance' registers. Add support for them.
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
---
drivers/memory/tegra/mc.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++
include/soc/tegra/mc.h | 6 ++++++
2 files changed, 60 insertions(+)
diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
index af4bf29..a7ed8e1 100644
--- a/drivers/memory/tegra/mc.c
+++ b/drivers/memory/tegra/mc.c
@@ -138,6 +138,38 @@ void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate)
for (i = 0; i < mc->soc->num_emem_regs; ++i)
mc_writel(mc, timing->emem_data[i], mc->soc->emem_regs[i]);
+
+}
+
+void tegra_mc_write_scaled_la_configuration(struct tegra_mc *mc,
+ unsigned long rate)
+{
+ unsigned int i, idx;
+ struct tegra_mc_timing *timing = NULL;
+
+ if (!mc->soc->has_scaled_la)
+ return;
+
+ timing = find_mc_timing(mc, rate);
+ if (!timing) {
+ dev_err(mc->dev, "no memory timing registered for rate %lu\n",
+ rate);
+ return;
+ }
+
+ idx = 0;
+ for (i = 0; i < mc->soc->num_clients; i++) {
+ const struct tegra_mc_la *la = &mc->soc->clients[i].la;
+ mc_modifyl(mc, la->reg, timing->scaled_la_data[idx++],
+ la->shift, la->mask);
+ }
+
+ for (i = 0; i < mc->soc->num_scaled_la_regs; i++) {
+ mc_modifyl(mc, mc->soc->scaled_la_regs[i],
+ timing->scaled_la_data[idx++], 0, 0xff);
+ mc_modifyl(mc, mc->soc->scaled_la_regs[i],
+ timing->scaled_la_data[idx++], 16, 0xff);
+ }
}
unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc)
@@ -181,6 +213,28 @@ static int load_one_timing(struct tegra_mc *mc,
return err;
}
+ if (mc->soc->has_scaled_la) {
+ unsigned int num_scaled_la_regs;
+
+ num_scaled_la_regs = mc->soc->num_clients;
+ /* each scaled LA register has a HI and a LO allowance value */
+ num_scaled_la_regs += mc->soc->num_scaled_la_regs * 2;
+ timing->scaled_la_data = devm_kcalloc(mc->dev,
+ num_scaled_la_regs, sizeof(u8), GFP_KERNEL);
+ if (!timing->scaled_la_data)
+ return -ENOMEM;
+
+ err = of_property_read_u8_array(node,
+ "nvidia,scale-la-configuration",
+ timing->scaled_la_data, num_scaled_la_regs);
+ if (err) {
+ dev_err(mc->dev,
+ "timing %s: failed to read scaled LA configuration\n",
+ node->name);
+ return err;
+ }
+ }
+
return 0;
}
diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h
index 44202ff..fce457c 100644
--- a/include/soc/tegra/mc.h
+++ b/include/soc/tegra/mc.h
@@ -24,6 +24,7 @@ struct tegra_mc_timing {
unsigned long rate;
u32 *emem_data;
+ u8 *scaled_la_data;
};
/* latency allowance */
@@ -93,12 +94,16 @@ struct tegra_mc_soc {
const unsigned long *emem_regs;
unsigned int num_emem_regs;
+ const unsigned long *scaled_la_regs;
+ unsigned int num_scaled_la_regs;
+
unsigned int num_address_bits;
unsigned int atom_size;
u8 client_id_mask;
const struct tegra_smmu_soc *smmu;
+ bool has_scaled_la;
};
struct tegra_mc {
@@ -117,5 +122,6 @@ struct tegra_mc {
void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
+void tegra_mc_write_scaled_la_configuration(struct tegra_mc *mc, unsigned long rate);
#endif /* __SOC_TEGRA_MC_H__ */
--
1.9.1
next prev parent reply other threads:[~2018-09-15 3:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-14 21:48 [RFC 00/14] Tegra210 EMC scaling Peter De Schrijver
2018-09-14 21:48 ` [RFC 01/14] memory: tegra: mc: Add Tegra210 MC emem registers Peter De Schrijver
2018-09-14 21:48 ` [RFC 02/14] clk: tegra: rename emc timing functions Peter De Schrijver
2018-09-14 21:48 ` [RFC 03/14] clk: tegra: emc: simplify parent matching Peter De Schrijver
2018-09-14 21:48 ` [RFC 04/14] clk: tegra: emc: prepare for Tegra210 parent table Peter De Schrijver
2018-09-14 21:48 ` [RFC 05/14] memory: tegra: mc: Introduce helpers Peter De Schrijver
2018-09-14 21:48 ` Peter De Schrijver [this message]
2018-09-14 21:48 ` [RFC 07/14] memory: tegra: scaled LA register for Tegra210 Peter De Schrijver
2018-09-14 21:48 ` [RFC 08/14] clk: tegra: clock changes for emc scaling Peter De Schrijver
2018-09-14 21:48 ` [RFC 09/14] memory: tegra: Add definitions shared by Tegra210 EMC scaling code Peter De Schrijver
2018-09-14 21:48 ` [RFC 10/14] memory: tegra: Add Tegra210 EMC scaling sequence Peter De Schrijver
2018-09-14 21:48 ` [RFC 11/14] memory: tegra: parse DT and costruct timing tables Peter De Schrijver
2018-09-14 21:48 ` [RFC 12/14] memory: tegra: Tegra210 EMC memory driver Peter De Schrijver
2018-09-14 21:48 ` [RFC 13/14] memory: tegra: enable Tegra210 EMC scaling driver Peter De Schrijver
2018-09-14 21:48 ` [RFC 14/14] dt-bindings: tegra: Add Tegra210 EMC binding Peter De Schrijver
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=1536961695-27809-7-git-send-email-pdeschrijver@nvidia.com \
--to=pdeschrijver@nvidia.com \
--cc=linux-clk@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox