Skip to content

Commit c7d0ff9

Browse files
committed
Merge tag 'tegra-for-5.9-memory' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into arm/drivers
memory: tegra: Changes for v5.9-rc1 This contains the Tegra210 EMC frequency scaling support that didn't make it into v5.8. In addition there are a couple of cleanups and minor fixes. * tag 'tegra-for-5.9-memory' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux: memory: tegra: Add Tegra132 compatible string match memory: tegra: Fix KCONFIG variables for Tegra186 and Tegra194 memory: tegra: Delete some dead code memory: tegra: Avoid unused function warnings memory: tegra: Drop <linux/clk-provider.h> memory: tegra: Fix an error handling path in tegra186_emc_probe() memory: tegra30-emc: Poll EMC-CaR handshake instead of waiting for interrupt memory: tegra20-emc: Poll EMC-CaR handshake instead of waiting for interrupt memory: tegra: Support derated timings on Tegra210 memory: tegra: Add EMC scaling sequence code for Tegra210 memory: tegra: Add EMC scaling support code for Tegra210 memory: tegra: Make debugfs permissions human-readable Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 68be222 + 46c0192 commit c7d0ff9

13 files changed

+5130
-112
lines changed

drivers/memory/tegra/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,17 @@ config TEGRA124_EMC
3636
Tegra124 chips. The EMC controls the external DRAM on the board.
3737
This driver is required to change memory timings / clock rate for
3838
external memory.
39+
40+
config TEGRA210_EMC_TABLE
41+
bool
42+
depends on ARCH_TEGRA_210_SOC
43+
44+
config TEGRA210_EMC
45+
tristate "NVIDIA Tegra210 External Memory Controller driver"
46+
depends on TEGRA_MC && ARCH_TEGRA_210_SOC
47+
select TEGRA210_EMC_TABLE
48+
help
49+
This driver is for the External Memory Controller (EMC) found on
50+
Tegra210 chips. The EMC controls the external DRAM on the board.
51+
This driver is required to change memory timings / clock rate for
52+
external memory.

drivers/memory/tegra/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ obj-$(CONFIG_TEGRA_MC) += tegra-mc.o
1313
obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o
1414
obj-$(CONFIG_TEGRA30_EMC) += tegra30-emc.o
1515
obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o
16+
obj-$(CONFIG_TEGRA210_EMC_TABLE) += tegra210-emc-table.o
17+
obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.o
1618
obj-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186.o tegra186-emc.o
1719
obj-$(CONFIG_ARCH_TEGRA_194_SOC) += tegra186.o tegra186-emc.o
20+
21+
tegra210-emc-y := tegra210-emc-core.o tegra210-emc-cc-r21021.o

drivers/memory/tegra/mc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define MC_EMEM_ARB_TIMING_W2W 0xbc
3535
#define MC_EMEM_ARB_TIMING_R2W 0xc0
3636
#define MC_EMEM_ARB_TIMING_W2R 0xc4
37+
#define MC_EMEM_ARB_MISC2 0xc8
3738
#define MC_EMEM_ARB_DA_TURNS 0xd0
3839
#define MC_EMEM_ARB_DA_COVERS 0xd4
3940
#define MC_EMEM_ARB_MISC0 0xd8

drivers/memory/tegra/tegra124-emc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ static int tegra_emc_load_timings_from_dt(struct tegra_emc *emc,
984984

985985
static const struct of_device_id tegra_emc_of_match[] = {
986986
{ .compatible = "nvidia,tegra124-emc" },
987+
{ .compatible = "nvidia,tegra132-emc" },
987988
{}
988989
};
989990

@@ -1178,11 +1179,11 @@ static void emc_debugfs_init(struct device *dev, struct tegra_emc *emc)
11781179
return;
11791180
}
11801181

1181-
debugfs_create_file("available_rates", S_IRUGO, emc->debugfs.root, emc,
1182+
debugfs_create_file("available_rates", 0444, emc->debugfs.root, emc,
11821183
&tegra_emc_debug_available_rates_fops);
1183-
debugfs_create_file("min_rate", S_IRUGO | S_IWUSR, emc->debugfs.root,
1184+
debugfs_create_file("min_rate", 0644, emc->debugfs.root,
11841185
emc, &tegra_emc_debug_min_rate_fops);
1185-
debugfs_create_file("max_rate", S_IRUGO | S_IWUSR, emc->debugfs.root,
1186+
debugfs_create_file("max_rate", 0644, emc->debugfs.root,
11861187
emc, &tegra_emc_debug_max_rate_fops);
11871188
}
11881189

drivers/memory/tegra/tegra186-emc.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static int tegra186_emc_probe(struct platform_device *pdev)
185185
if (IS_ERR(emc->clk)) {
186186
err = PTR_ERR(emc->clk);
187187
dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err);
188-
return err;
188+
goto put_bpmp;
189189
}
190190

191191
platform_set_drvdata(pdev, emc);
@@ -201,7 +201,7 @@ static int tegra186_emc_probe(struct platform_device *pdev)
201201
err = tegra_bpmp_transfer(emc->bpmp, &msg);
202202
if (err < 0) {
203203
dev_err(&pdev->dev, "failed to EMC DVFS pairs: %d\n", err);
204-
return err;
204+
goto put_bpmp;
205205
}
206206

207207
emc->debugfs.min_rate = ULONG_MAX;
@@ -211,8 +211,10 @@ static int tegra186_emc_probe(struct platform_device *pdev)
211211

212212
emc->dvfs = devm_kmalloc_array(&pdev->dev, emc->num_dvfs,
213213
sizeof(*emc->dvfs), GFP_KERNEL);
214-
if (!emc->dvfs)
215-
return -ENOMEM;
214+
if (!emc->dvfs) {
215+
err = -ENOMEM;
216+
goto put_bpmp;
217+
}
216218

217219
dev_dbg(&pdev->dev, "%u DVFS pairs:\n", emc->num_dvfs);
218220

@@ -237,15 +239,10 @@ static int tegra186_emc_probe(struct platform_device *pdev)
237239
"failed to set rate range [%lu-%lu] for %pC\n",
238240
emc->debugfs.min_rate, emc->debugfs.max_rate,
239241
emc->clk);
240-
return err;
242+
goto put_bpmp;
241243
}
242244

243245
emc->debugfs.root = debugfs_create_dir("emc", NULL);
244-
if (!emc->debugfs.root) {
245-
dev_err(&pdev->dev, "failed to create debugfs directory\n");
246-
return 0;
247-
}
248-
249246
debugfs_create_file("available_rates", S_IRUGO, emc->debugfs.root,
250247
emc, &tegra186_emc_debug_available_rates_fops);
251248
debugfs_create_file("min_rate", S_IRUGO | S_IWUSR, emc->debugfs.root,
@@ -254,6 +251,10 @@ static int tegra186_emc_probe(struct platform_device *pdev)
254251
emc, &tegra186_emc_debug_max_rate_fops);
255252

256253
return 0;
254+
255+
put_bpmp:
256+
tegra_bpmp_put(emc->bpmp);
257+
return err;
257258
}
258259

259260
static int tegra186_emc_remove(struct platform_device *pdev)
@@ -267,10 +268,10 @@ static int tegra186_emc_remove(struct platform_device *pdev)
267268
}
268269

269270
static const struct of_device_id tegra186_emc_of_match[] = {
270-
#if defined(CONFIG_ARCH_TEGRA186_SOC)
271+
#if defined(CONFIG_ARCH_TEGRA_186_SOC)
271272
{ .compatible = "nvidia,tegra186-emc" },
272273
#endif
273-
#if defined(CONFIG_ARCH_TEGRA194_SOC)
274+
#if defined(CONFIG_ARCH_TEGRA_194_SOC)
274275
{ .compatible = "nvidia,tegra194-emc" },
275276
#endif
276277
{ /* sentinel */ }

drivers/memory/tegra/tegra186.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,12 +1570,12 @@ static const struct of_device_id tegra186_mc_of_match[] = {
15701570
};
15711571
MODULE_DEVICE_TABLE(of, tegra186_mc_of_match);
15721572

1573-
static int tegra186_mc_suspend(struct device *dev)
1573+
static int __maybe_unused tegra186_mc_suspend(struct device *dev)
15741574
{
15751575
return 0;
15761576
}
15771577

1578-
static int tegra186_mc_resume(struct device *dev)
1578+
static int __maybe_unused tegra186_mc_resume(struct device *dev)
15791579
{
15801580
struct tegra186_mc *mc = dev_get_drvdata(dev);
15811581

drivers/memory/tegra/tegra20-emc.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
#include <linux/clk.h>
99
#include <linux/clk/tegra.h>
10-
#include <linux/completion.h>
1110
#include <linux/debugfs.h>
1211
#include <linux/err.h>
1312
#include <linux/interrupt.h>
1413
#include <linux/io.h>
14+
#include <linux/iopoll.h>
1515
#include <linux/kernel.h>
1616
#include <linux/module.h>
1717
#include <linux/of.h>
@@ -144,7 +144,6 @@ struct emc_timing {
144144

145145
struct tegra_emc {
146146
struct device *dev;
147-
struct completion clk_handshake_complete;
148147
struct notifier_block clk_nb;
149148
struct clk *clk;
150149
void __iomem *regs;
@@ -162,17 +161,13 @@ struct tegra_emc {
162161
static irqreturn_t tegra_emc_isr(int irq, void *data)
163162
{
164163
struct tegra_emc *emc = data;
165-
u32 intmask = EMC_REFRESH_OVERFLOW_INT | EMC_CLKCHANGE_COMPLETE_INT;
164+
u32 intmask = EMC_REFRESH_OVERFLOW_INT;
166165
u32 status;
167166

168167
status = readl_relaxed(emc->regs + EMC_INTSTATUS) & intmask;
169168
if (!status)
170169
return IRQ_NONE;
171170

172-
/* notify about EMC-CAR handshake completion */
173-
if (status & EMC_CLKCHANGE_COMPLETE_INT)
174-
complete(&emc->clk_handshake_complete);
175-
176171
/* notify about HW problem */
177172
if (status & EMC_REFRESH_OVERFLOW_INT)
178173
dev_err_ratelimited(emc->dev,
@@ -224,14 +219,13 @@ static int emc_prepare_timing_change(struct tegra_emc *emc, unsigned long rate)
224219
/* wait until programming has settled */
225220
readl_relaxed(emc->regs + emc_timing_registers[i - 1]);
226221

227-
reinit_completion(&emc->clk_handshake_complete);
228-
229222
return 0;
230223
}
231224

232225
static int emc_complete_timing_change(struct tegra_emc *emc, bool flush)
233226
{
234-
unsigned long timeout;
227+
int err;
228+
u32 v;
235229

236230
dev_dbg(emc->dev, "%s: flush %d\n", __func__, flush);
237231

@@ -242,11 +236,12 @@ static int emc_complete_timing_change(struct tegra_emc *emc, bool flush)
242236
return 0;
243237
}
244238

245-
timeout = wait_for_completion_timeout(&emc->clk_handshake_complete,
246-
msecs_to_jiffies(100));
247-
if (timeout == 0) {
248-
dev_err(emc->dev, "EMC-CAR handshake failed\n");
249-
return -EIO;
239+
err = readl_relaxed_poll_timeout_atomic(emc->regs + EMC_INTSTATUS, v,
240+
v & EMC_CLKCHANGE_COMPLETE_INT,
241+
1, 100);
242+
if (err) {
243+
dev_err(emc->dev, "emc-car handshake timeout: %d\n", err);
244+
return err;
250245
}
251246

252247
return 0;
@@ -412,7 +407,7 @@ tegra_emc_find_node_by_ram_code(struct device *dev)
412407

413408
static int emc_setup_hw(struct tegra_emc *emc)
414409
{
415-
u32 intmask = EMC_REFRESH_OVERFLOW_INT | EMC_CLKCHANGE_COMPLETE_INT;
410+
u32 intmask = EMC_REFRESH_OVERFLOW_INT;
416411
u32 emc_cfg, emc_dbg;
417412

418413
emc_cfg = readl_relaxed(emc->regs + EMC_CFG_2);
@@ -647,11 +642,11 @@ static void tegra_emc_debugfs_init(struct tegra_emc *emc)
647642
return;
648643
}
649644

650-
debugfs_create_file("available_rates", S_IRUGO, emc->debugfs.root,
645+
debugfs_create_file("available_rates", 0444, emc->debugfs.root,
651646
emc, &tegra_emc_debug_available_rates_fops);
652-
debugfs_create_file("min_rate", S_IRUGO | S_IWUSR, emc->debugfs.root,
647+
debugfs_create_file("min_rate", 0644, emc->debugfs.root,
653648
emc, &tegra_emc_debug_min_rate_fops);
654-
debugfs_create_file("max_rate", S_IRUGO | S_IWUSR, emc->debugfs.root,
649+
debugfs_create_file("max_rate", 0644, emc->debugfs.root,
655650
emc, &tegra_emc_debug_max_rate_fops);
656651
}
657652

@@ -686,7 +681,6 @@ static int tegra_emc_probe(struct platform_device *pdev)
686681
return -ENOMEM;
687682
}
688683

689-
init_completion(&emc->clk_handshake_complete);
690684
emc->clk_nb.notifier_call = tegra_emc_clk_change_notify;
691685
emc->dev = &pdev->dev;
692686

0 commit comments

Comments
 (0)