20 #include <linux/kernel.h>
21 #include <linux/module.h>
27 #define DRV_NAME "tegra30-mc"
29 #define MC_INTSTATUS 0x0
30 #define MC_INTMASK 0x4
32 #define MC_INT_ERR_SHIFT 6
33 #define MC_INT_ERR_MASK (0x1f << MC_INT_ERR_SHIFT)
34 #define MC_INT_DECERR_EMEM BIT(MC_INT_ERR_SHIFT)
35 #define MC_INT_SECURITY_VIOLATION BIT(MC_INT_ERR_SHIFT + 2)
36 #define MC_INT_ARBITRATION_EMEM BIT(MC_INT_ERR_SHIFT + 3)
37 #define MC_INT_INVALID_SMMU_PAGE BIT(MC_INT_ERR_SHIFT + 4)
39 #define MC_ERR_STATUS 0x8
40 #define MC_ERR_ADR 0xc
42 #define MC_ERR_TYPE_SHIFT 28
43 #define MC_ERR_TYPE_MASK (7 << MC_ERR_TYPE_SHIFT)
44 #define MC_ERR_TYPE_DECERR_EMEM 2
45 #define MC_ERR_TYPE_SECURITY_TRUSTZONE 3
46 #define MC_ERR_TYPE_SECURITY_CARVEOUT 4
47 #define MC_ERR_TYPE_INVALID_SMMU_PAGE 6
49 #define MC_ERR_INVALID_SMMU_PAGE_SHIFT 25
50 #define MC_ERR_INVALID_SMMU_PAGE_MASK (7 << MC_ERR_INVALID_SMMU_PAGE_SHIFT)
51 #define MC_ERR_RW_SHIFT 16
52 #define MC_ERR_RW BIT(MC_ERR_RW_SHIFT)
53 #define MC_ERR_SECURITY BIT(MC_ERR_RW_SHIFT + 1)
55 #define SECURITY_VIOLATION_TYPE BIT(30)
57 #define MC_EMEM_ARB_CFG 0x90
58 #define MC_EMEM_ARB_OUTSTANDING_REQ 0x94
59 #define MC_EMEM_ARB_TIMING_RCD 0x98
60 #define MC_EMEM_ARB_TIMING_RP 0x9c
61 #define MC_EMEM_ARB_TIMING_RC 0xa0
62 #define MC_EMEM_ARB_TIMING_RAS 0xa4
63 #define MC_EMEM_ARB_TIMING_FAW 0xa8
64 #define MC_EMEM_ARB_TIMING_RRD 0xac
65 #define MC_EMEM_ARB_TIMING_RAP2PRE 0xb0
66 #define MC_EMEM_ARB_TIMING_WAP2PRE 0xb4
67 #define MC_EMEM_ARB_TIMING_R2R 0xb8
68 #define MC_EMEM_ARB_TIMING_W2W 0xbc
69 #define MC_EMEM_ARB_TIMING_R2W 0xc0
70 #define MC_EMEM_ARB_TIMING_W2R 0xc4
72 #define MC_EMEM_ARB_DA_TURNS 0xd0
73 #define MC_EMEM_ARB_DA_COVERS 0xd4
74 #define MC_EMEM_ARB_MISC0 0xd8
75 #define MC_EMEM_ARB_MISC1 0xdc
77 #define MC_EMEM_ARB_RING3_THROTTLE 0xe4
78 #define MC_EMEM_ARB_OVERRIDE 0xe8
80 #define MC_TIMING_CONTROL 0xfc
82 #define MC_CLIENT_ID_MASK 0x7f
84 #define NUM_MC_REG_BANKS 4
98 else if (offs < 0x1f0)
100 else if (offs < 0x228)
102 else if (offs < 0x400)
112 else if (offs < 0x1f0)
114 else if (offs < 0x228)
116 else if (offs < 0x400)
120 static const char *
const tegra30_mc_client[] = {
189 static void tegra30_mc_decode(
struct tegra30_mc *mc,
int n)
192 const char *
const mc_int_err[] = {
196 "MC_ARBITRATION_EMEM",
199 const char *
const err_type[] = {
203 "SECURITY_TRUSTZONE",
211 const char *
client =
"Unknown";
214 if ((idx < 0) || (idx >=
ARRAY_SIZE(mc_int_err)) || (idx == 1)) {
227 (perm &
BIT(2)) ?
'R' :
'-',
228 (perm &
BIT(1)) ?
'W' :
'-',
229 (perm &
BIT(0)) ?
'S' :
'-');
235 client = tegra30_mc_client[
cid];
240 mc_int_err[idx], err, addr, client,
243 err_type[type], attr);
246 static const u32 tegra30_mc_ctx[] = {
270 static int tegra30_mc_suspend(
struct device *
dev)
275 for (i = 0; i <
ARRAY_SIZE(tegra30_mc_ctx); i++)
276 mc->
ctx[i] = mc_readl(mc, tegra30_mc_ctx[i]);
280 static int tegra30_mc_resume(
struct device *dev)
285 for (i = 0; i <
ARRAY_SIZE(tegra30_mc_ctx); i++)
286 mc_writel(mc, mc->
ctx[i], tegra30_mc_ctx[i]);
296 tegra30_mc_resume,
NULL);
299 { .compatible =
"nvidia,tegra30-mc", },
313 while ((bit =
ffs(mask)) != 0)
314 tegra30_mc_decode(mc, bit - 1);
327 bytes =
sizeof(*mc) +
sizeof(
u32) *
ARRAY_SIZE(tegra30_mc_ctx);
347 err = devm_request_irq(&pdev->
dev, irq->
start, tegra30_mc_isr,
352 platform_set_drvdata(pdev, mc);
361 .probe = tegra30_mc_probe,
365 .of_match_table = tegra30_mc_of_match,
366 .pm = &tegra30_mc_pm,