2 * Copyright (C) 2017 NVIDIA CORPORATION. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
10 #include <linux/module.h>
11 #include <linux/platform_device.h>
13 #include <dt-bindings/memory/tegra186-mc.h>
20 struct tegra_mc_client
{
24 unsigned int override
;
25 unsigned int security
;
29 static const struct tegra_mc_client tegra186_mc_clients
[] = {
32 .sid
= TEGRA186_SID_PASSTHROUGH
,
39 .sid
= TEGRA186_SID_AFI
,
46 .sid
= TEGRA186_SID_HDA
,
53 .sid
= TEGRA186_SID_HOST1X
,
60 .sid
= TEGRA186_SID_NVENC
,
67 .sid
= TEGRA186_SID_SATA
,
74 .sid
= TEGRA186_SID_PASSTHROUGH
,
81 .sid
= TEGRA186_SID_NVENC
,
88 .sid
= TEGRA186_SID_AFI
,
95 .sid
= TEGRA186_SID_HDA
,
102 .sid
= TEGRA186_SID_PASSTHROUGH
,
109 .sid
= TEGRA186_SID_SATA
,
116 .sid
= TEGRA186_SID_ISP
,
123 .sid
= TEGRA186_SID_ISP
,
130 .sid
= TEGRA186_SID_ISP
,
136 .name
= "xusb_hostr",
137 .sid
= TEGRA186_SID_XUSB_HOST
,
143 .name
= "xusb_hostw",
144 .sid
= TEGRA186_SID_XUSB_HOST
,
151 .sid
= TEGRA186_SID_XUSB_DEV
,
158 .sid
= TEGRA186_SID_XUSB_DEV
,
165 .sid
= TEGRA186_SID_TSEC
,
172 .sid
= TEGRA186_SID_TSEC
,
179 .sid
= TEGRA186_SID_GPU
,
186 .sid
= TEGRA186_SID_GPU
,
193 .sid
= TEGRA186_SID_SDMMC1
,
200 .sid
= TEGRA186_SID_SDMMC2
,
207 .sid
= TEGRA186_SID_SDMMC3
,
214 .sid
= TEGRA186_SID_SDMMC4
,
221 .sid
= TEGRA186_SID_SDMMC1
,
228 .sid
= TEGRA186_SID_SDMMC2
,
235 .sid
= TEGRA186_SID_SDMMC3
,
242 .sid
= TEGRA186_SID_SDMMC4
,
249 .sid
= TEGRA186_SID_VIC
,
256 .sid
= TEGRA186_SID_VIC
,
263 .sid
= TEGRA186_SID_VI
,
270 .sid
= TEGRA186_SID_NVDEC
,
277 .sid
= TEGRA186_SID_NVDEC
,
284 .sid
= TEGRA186_SID_APE
,
291 .sid
= TEGRA186_SID_APE
,
298 .sid
= TEGRA186_SID_NVJPG
,
305 .sid
= TEGRA186_SID_NVJPG
,
312 .sid
= TEGRA186_SID_SE
,
319 .sid
= TEGRA186_SID_SE
,
326 .sid
= TEGRA186_SID_ETR
,
333 .sid
= TEGRA186_SID_ETR
,
340 .sid
= TEGRA186_SID_TSECB
,
347 .sid
= TEGRA186_SID_TSECB
,
354 .sid
= TEGRA186_SID_GPU
,
361 .sid
= TEGRA186_SID_GPU
,
368 .sid
= TEGRA186_SID_GPCDMA_0
,
375 .sid
= TEGRA186_SID_GPCDMA_0
,
382 .sid
= TEGRA186_SID_EQOS
,
389 .sid
= TEGRA186_SID_EQOS
,
396 .sid
= TEGRA186_SID_UFSHC
,
403 .sid
= TEGRA186_SID_UFSHC
,
409 .name
= "nvdisplayr",
410 .sid
= TEGRA186_SID_NVDISPLAY
,
417 .sid
= TEGRA186_SID_BPMP
,
424 .sid
= TEGRA186_SID_BPMP
,
431 .sid
= TEGRA186_SID_BPMP
,
438 .sid
= TEGRA186_SID_BPMP
,
445 .sid
= TEGRA186_SID_AON
,
452 .sid
= TEGRA186_SID_AON
,
459 .sid
= TEGRA186_SID_AON
,
466 .sid
= TEGRA186_SID_AON
,
473 .sid
= TEGRA186_SID_SCE
,
480 .sid
= TEGRA186_SID_SCE
,
487 .sid
= TEGRA186_SID_SCE
,
494 .sid
= TEGRA186_SID_SCE
,
501 .sid
= TEGRA186_SID_APE
,
508 .sid
= TEGRA186_SID_APE
,
514 .name
= "nvdisplayr1",
515 .sid
= TEGRA186_SID_NVDISPLAY
,
522 .sid
= TEGRA186_SID_VIC
,
529 .sid
= TEGRA186_SID_NVDEC
,
537 static int tegra186_mc_probe(struct platform_device
*pdev
)
539 struct resource
*res
;
544 mc
= devm_kzalloc(&pdev
->dev
, sizeof(*mc
), GFP_KERNEL
);
548 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
549 mc
->regs
= devm_ioremap_resource(&pdev
->dev
, res
);
550 if (IS_ERR(mc
->regs
))
551 return PTR_ERR(mc
->regs
);
553 mc
->dev
= &pdev
->dev
;
555 for (i
= 0; i
< ARRAY_SIZE(tegra186_mc_clients
); i
++) {
556 const struct tegra_mc_client
*client
= &tegra186_mc_clients
[i
];
557 u32 override
, security
;
559 override
= readl(mc
->regs
+ client
->regs
.override
);
560 security
= readl(mc
->regs
+ client
->regs
.security
);
562 dev_dbg(&pdev
->dev
, "client %s: override: %x security: %x\n",
563 client
->name
, override
, security
);
565 dev_dbg(&pdev
->dev
, "setting SID %u for %s\n", client
->sid
,
567 writel(client
->sid
, mc
->regs
+ client
->regs
.override
);
569 override
= readl(mc
->regs
+ client
->regs
.override
);
570 security
= readl(mc
->regs
+ client
->regs
.security
);
572 dev_dbg(&pdev
->dev
, "client %s: override: %x security: %x\n",
573 client
->name
, override
, security
);
576 platform_set_drvdata(pdev
, mc
);
581 static const struct of_device_id tegra186_mc_of_match
[] = {
582 { .compatible
= "nvidia,tegra186-mc", },
585 MODULE_DEVICE_TABLE(of
, tegra186_mc_of_match
);
587 static struct platform_driver tegra186_mc_driver
= {
589 .name
= "tegra186-mc",
590 .of_match_table
= tegra186_mc_of_match
,
591 .suppress_bind_attrs
= true,
593 .prevent_deferred_probe
= true,
594 .probe
= tegra186_mc_probe
,
596 module_platform_driver(tegra186_mc_driver
);
598 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
599 MODULE_DESCRIPTION("NVIDIA Tegra186 Memory Controller driver");
600 MODULE_LICENSE("GPL v2");