1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2017 NVIDIA CORPORATION. All rights reserved.
7 #include <linux/module.h>
8 #include <linux/mod_devicetable.h>
9 #include <linux/platform_device.h>
11 #include <dt-bindings/memory/tegra186-mc.h>
18 struct tegra_mc_client
{
22 unsigned int override
;
23 unsigned int security
;
27 static const struct tegra_mc_client tegra186_mc_clients
[] = {
30 .sid
= TEGRA186_SID_PASSTHROUGH
,
37 .sid
= TEGRA186_SID_AFI
,
44 .sid
= TEGRA186_SID_HDA
,
51 .sid
= TEGRA186_SID_HOST1X
,
58 .sid
= TEGRA186_SID_NVENC
,
65 .sid
= TEGRA186_SID_SATA
,
72 .sid
= TEGRA186_SID_PASSTHROUGH
,
79 .sid
= TEGRA186_SID_NVENC
,
86 .sid
= TEGRA186_SID_AFI
,
93 .sid
= TEGRA186_SID_HDA
,
100 .sid
= TEGRA186_SID_PASSTHROUGH
,
107 .sid
= TEGRA186_SID_SATA
,
114 .sid
= TEGRA186_SID_ISP
,
121 .sid
= TEGRA186_SID_ISP
,
128 .sid
= TEGRA186_SID_ISP
,
134 .name
= "xusb_hostr",
135 .sid
= TEGRA186_SID_XUSB_HOST
,
141 .name
= "xusb_hostw",
142 .sid
= TEGRA186_SID_XUSB_HOST
,
149 .sid
= TEGRA186_SID_XUSB_DEV
,
156 .sid
= TEGRA186_SID_XUSB_DEV
,
163 .sid
= TEGRA186_SID_TSEC
,
170 .sid
= TEGRA186_SID_TSEC
,
177 .sid
= TEGRA186_SID_GPU
,
184 .sid
= TEGRA186_SID_GPU
,
191 .sid
= TEGRA186_SID_SDMMC1
,
198 .sid
= TEGRA186_SID_SDMMC2
,
205 .sid
= TEGRA186_SID_SDMMC3
,
212 .sid
= TEGRA186_SID_SDMMC4
,
219 .sid
= TEGRA186_SID_SDMMC1
,
226 .sid
= TEGRA186_SID_SDMMC2
,
233 .sid
= TEGRA186_SID_SDMMC3
,
240 .sid
= TEGRA186_SID_SDMMC4
,
247 .sid
= TEGRA186_SID_VIC
,
254 .sid
= TEGRA186_SID_VIC
,
261 .sid
= TEGRA186_SID_VI
,
268 .sid
= TEGRA186_SID_NVDEC
,
275 .sid
= TEGRA186_SID_NVDEC
,
282 .sid
= TEGRA186_SID_APE
,
289 .sid
= TEGRA186_SID_APE
,
296 .sid
= TEGRA186_SID_NVJPG
,
303 .sid
= TEGRA186_SID_NVJPG
,
310 .sid
= TEGRA186_SID_SE
,
317 .sid
= TEGRA186_SID_SE
,
324 .sid
= TEGRA186_SID_ETR
,
331 .sid
= TEGRA186_SID_ETR
,
338 .sid
= TEGRA186_SID_TSECB
,
345 .sid
= TEGRA186_SID_TSECB
,
352 .sid
= TEGRA186_SID_GPU
,
359 .sid
= TEGRA186_SID_GPU
,
366 .sid
= TEGRA186_SID_GPCDMA_0
,
373 .sid
= TEGRA186_SID_GPCDMA_0
,
380 .sid
= TEGRA186_SID_EQOS
,
387 .sid
= TEGRA186_SID_EQOS
,
394 .sid
= TEGRA186_SID_UFSHC
,
401 .sid
= TEGRA186_SID_UFSHC
,
407 .name
= "nvdisplayr",
408 .sid
= TEGRA186_SID_NVDISPLAY
,
415 .sid
= TEGRA186_SID_BPMP
,
422 .sid
= TEGRA186_SID_BPMP
,
429 .sid
= TEGRA186_SID_BPMP
,
436 .sid
= TEGRA186_SID_BPMP
,
443 .sid
= TEGRA186_SID_AON
,
450 .sid
= TEGRA186_SID_AON
,
457 .sid
= TEGRA186_SID_AON
,
464 .sid
= TEGRA186_SID_AON
,
471 .sid
= TEGRA186_SID_SCE
,
478 .sid
= TEGRA186_SID_SCE
,
485 .sid
= TEGRA186_SID_SCE
,
492 .sid
= TEGRA186_SID_SCE
,
499 .sid
= TEGRA186_SID_APE
,
506 .sid
= TEGRA186_SID_APE
,
512 .name
= "nvdisplayr1",
513 .sid
= TEGRA186_SID_NVDISPLAY
,
520 .sid
= TEGRA186_SID_VIC
,
527 .sid
= TEGRA186_SID_NVDEC
,
535 static int tegra186_mc_probe(struct platform_device
*pdev
)
537 struct resource
*res
;
542 mc
= devm_kzalloc(&pdev
->dev
, sizeof(*mc
), GFP_KERNEL
);
546 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
547 mc
->regs
= devm_ioremap_resource(&pdev
->dev
, res
);
548 if (IS_ERR(mc
->regs
))
549 return PTR_ERR(mc
->regs
);
551 mc
->dev
= &pdev
->dev
;
553 for (i
= 0; i
< ARRAY_SIZE(tegra186_mc_clients
); i
++) {
554 const struct tegra_mc_client
*client
= &tegra186_mc_clients
[i
];
555 u32 override
, security
;
557 override
= readl(mc
->regs
+ client
->regs
.override
);
558 security
= readl(mc
->regs
+ client
->regs
.security
);
560 dev_dbg(&pdev
->dev
, "client %s: override: %x security: %x\n",
561 client
->name
, override
, security
);
563 dev_dbg(&pdev
->dev
, "setting SID %u for %s\n", client
->sid
,
565 writel(client
->sid
, mc
->regs
+ client
->regs
.override
);
567 override
= readl(mc
->regs
+ client
->regs
.override
);
568 security
= readl(mc
->regs
+ client
->regs
.security
);
570 dev_dbg(&pdev
->dev
, "client %s: override: %x security: %x\n",
571 client
->name
, override
, security
);
574 platform_set_drvdata(pdev
, mc
);
579 static const struct of_device_id tegra186_mc_of_match
[] = {
580 { .compatible
= "nvidia,tegra186-mc", },
583 MODULE_DEVICE_TABLE(of
, tegra186_mc_of_match
);
585 static struct platform_driver tegra186_mc_driver
= {
587 .name
= "tegra186-mc",
588 .of_match_table
= tegra186_mc_of_match
,
589 .suppress_bind_attrs
= true,
591 .prevent_deferred_probe
= true,
592 .probe
= tegra186_mc_probe
,
594 module_platform_driver(tegra186_mc_driver
);
596 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
597 MODULE_DESCRIPTION("NVIDIA Tegra186 Memory Controller driver");
598 MODULE_LICENSE("GPL v2");