Skip to content

Commit e34212c

Browse files
digetxthierryreding
authored andcommitted
memory: tegra: Introduce Tegra30 EMC driver
Introduce driver for the External Memory Controller (EMC) found on Tegra30 chips, it controls the external DRAM on the board. The purpose of this driver is to program memory timing for external memory on the EMC clock rate change. Acked-by: Peter De Schrijver <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Tested-by: Peter Geis <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 88c5bfe commit e34212c

File tree

7 files changed

+1311
-15
lines changed

7 files changed

+1311
-15
lines changed

drivers/memory/tegra/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ config TEGRA20_EMC
1717
This driver is required to change memory timings / clock rate for
1818
external memory.
1919

20+
config TEGRA30_EMC
21+
bool "NVIDIA Tegra30 External Memory Controller driver"
22+
default y
23+
depends on TEGRA_MC && ARCH_TEGRA_3x_SOC
24+
help
25+
This driver is for the External Memory Controller (EMC) found on
26+
Tegra30 chips. The EMC controls the external DRAM on the board.
27+
This driver is required to change memory timings / clock rate for
28+
external memory.
29+
2030
config TEGRA124_EMC
2131
bool "NVIDIA Tegra124 External Memory Controller driver"
2232
default y

drivers/memory/tegra/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ tegra-mc-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o
1111
obj-$(CONFIG_TEGRA_MC) += tegra-mc.o
1212

1313
obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o
14+
obj-$(CONFIG_TEGRA30_EMC) += tegra30-emc.o
1415
obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o
1516
obj-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186.o

drivers/memory/tegra/mc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@
4949
#define MC_EMEM_ADR_CFG 0x54
5050
#define MC_EMEM_ADR_CFG_EMEM_NUMDEV BIT(0)
5151

52-
#define MC_TIMING_CONTROL 0xfc
53-
#define MC_TIMING_UPDATE BIT(0)
54-
5552
static const struct of_device_id tegra_mc_of_match[] = {
5653
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
5754
{ .compatible = "nvidia,tegra20-mc-gart", .data = &tegra20_mc_soc },
@@ -308,7 +305,7 @@ static int tegra_mc_setup_latency_allowance(struct tegra_mc *mc)
308305
return 0;
309306
}
310307

311-
void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate)
308+
int tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate)
312309
{
313310
unsigned int i;
314311
struct tegra_mc_timing *timing = NULL;
@@ -323,11 +320,13 @@ void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate)
323320
if (!timing) {
324321
dev_err(mc->dev, "no memory timing registered for rate %lu\n",
325322
rate);
326-
return;
323+
return -EINVAL;
327324
}
328325

329326
for (i = 0; i < mc->soc->num_emem_regs; ++i)
330327
mc_writel(mc, timing->emem_data[i], mc->soc->emem_regs[i]);
328+
329+
return 0;
331330
}
332331

333332
unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc)

drivers/memory/tegra/mc.h

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,32 @@
66
#ifndef MEMORY_TEGRA_MC_H
77
#define MEMORY_TEGRA_MC_H
88

9+
#include <linux/bits.h>
910
#include <linux/io.h>
1011
#include <linux/types.h>
1112

1213
#include <soc/tegra/mc.h>
1314

14-
#define MC_INT_DECERR_MTS (1 << 16)
15-
#define MC_INT_SECERR_SEC (1 << 13)
16-
#define MC_INT_DECERR_VPR (1 << 12)
17-
#define MC_INT_INVALID_APB_ASID_UPDATE (1 << 11)
18-
#define MC_INT_INVALID_SMMU_PAGE (1 << 10)
19-
#define MC_INT_ARBITRATION_EMEM (1 << 9)
20-
#define MC_INT_SECURITY_VIOLATION (1 << 8)
21-
#define MC_INT_INVALID_GART_PAGE (1 << 7)
22-
#define MC_INT_DECERR_EMEM (1 << 6)
15+
#define MC_INT_DECERR_MTS BIT(16)
16+
#define MC_INT_SECERR_SEC BIT(13)
17+
#define MC_INT_DECERR_VPR BIT(12)
18+
#define MC_INT_INVALID_APB_ASID_UPDATE BIT(11)
19+
#define MC_INT_INVALID_SMMU_PAGE BIT(10)
20+
#define MC_INT_ARBITRATION_EMEM BIT(9)
21+
#define MC_INT_SECURITY_VIOLATION BIT(8)
22+
#define MC_INT_INVALID_GART_PAGE BIT(7)
23+
#define MC_INT_DECERR_EMEM BIT(6)
24+
25+
#define MC_EMEM_ARB_OUTSTANDING_REQ 0x94
26+
#define MC_EMEM_ARB_OUTSTANDING_REQ_MAX_MASK 0x1ff
27+
#define MC_EMEM_ARB_OUTSTANDING_REQ_HOLDOFF_OVERRIDE BIT(30)
28+
#define MC_EMEM_ARB_OUTSTANDING_REQ_LIMIT_ENABLE BIT(31)
29+
30+
#define MC_EMEM_ARB_OVERRIDE 0xe8
31+
#define MC_EMEM_ARB_OVERRIDE_EACK_MASK 0x3
32+
33+
#define MC_TIMING_CONTROL 0xfc
34+
#define MC_TIMING_UPDATE BIT(0)
2335

2436
static inline u32 mc_readl(struct tegra_mc *mc, unsigned long offset)
2537
{

0 commit comments

Comments
 (0)