Skip to content

Commit a7cffa1

Browse files
ashishmhetre8krzk
authored andcommitted
memory: tegra: Add memory controller channels support
From Tegra186 onwards, the memory controller supports multiple channels. Add support for mapping the address spaces of these channels and specify the number of channels supported by Tegra186, Tegra194 and Tegra234. In case of old bindings, channels won't be present. If channels are not present then print a warning and continue so that backward compatibility will be preserved in driver. During error interrupts from memory controller, appropriate registers from these channels need to be accessed for logging error info. Signed-off-by: Ashish Mhetre <[email protected]> Reviewed-by: Dmitry Osipenko <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent cc3d696 commit a7cffa1

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

drivers/memory/tegra/tegra186.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,37 @@ static void tegra186_mc_program_sid(struct tegra_mc *mc)
4848

4949
static int tegra186_mc_probe(struct tegra_mc *mc)
5050
{
51+
struct platform_device *pdev = to_platform_device(mc->dev);
52+
unsigned int i;
53+
char name[8];
5154
int err;
5255

56+
mc->bcast_ch_regs = devm_platform_ioremap_resource_byname(pdev, "broadcast");
57+
if (IS_ERR(mc->bcast_ch_regs)) {
58+
if (PTR_ERR(mc->bcast_ch_regs) == -EINVAL) {
59+
dev_warn(&pdev->dev,
60+
"Broadcast channel is missing, please update your device-tree\n");
61+
mc->bcast_ch_regs = NULL;
62+
goto populate;
63+
}
64+
65+
return PTR_ERR(mc->bcast_ch_regs);
66+
}
67+
68+
mc->ch_regs = devm_kcalloc(mc->dev, mc->soc->num_channels, sizeof(*mc->ch_regs),
69+
GFP_KERNEL);
70+
if (!mc->ch_regs)
71+
return -ENOMEM;
72+
73+
for (i = 0; i < mc->soc->num_channels; i++) {
74+
snprintf(name, sizeof(name), "ch%u", i);
75+
76+
mc->ch_regs[i] = devm_platform_ioremap_resource_byname(pdev, name);
77+
if (IS_ERR(mc->ch_regs[i]))
78+
return PTR_ERR(mc->ch_regs[i]);
79+
}
80+
81+
populate:
5382
err = of_platform_populate(mc->dev->of_node, NULL, NULL, mc->dev);
5483
if (err < 0)
5584
return err;
@@ -875,6 +904,7 @@ const struct tegra_mc_soc tegra186_mc_soc = {
875904
.num_clients = ARRAY_SIZE(tegra186_mc_clients),
876905
.clients = tegra186_mc_clients,
877906
.num_address_bits = 40,
907+
.num_channels = 4,
878908
.ops = &tegra186_mc_ops,
879909
};
880910
#endif

drivers/memory/tegra/tegra194.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,5 +1347,6 @@ const struct tegra_mc_soc tegra194_mc_soc = {
13471347
.num_clients = ARRAY_SIZE(tegra194_mc_clients),
13481348
.clients = tegra194_mc_clients,
13491349
.num_address_bits = 40,
1350+
.num_channels = 16,
13501351
.ops = &tegra186_mc_ops,
13511352
};

drivers/memory/tegra/tegra234.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@ const struct tegra_mc_soc tegra234_mc_soc = {
9797
.num_clients = ARRAY_SIZE(tegra234_mc_clients),
9898
.clients = tegra234_mc_clients,
9999
.num_address_bits = 40,
100+
.num_channels = 16,
100101
.ops = &tegra186_mc_ops,
101102
};

include/soc/tegra/mc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ struct tegra_mc_soc {
194194
unsigned int atom_size;
195195

196196
u8 client_id_mask;
197+
u8 num_channels;
197198

198199
const struct tegra_smmu_soc *smmu;
199200

@@ -212,6 +213,8 @@ struct tegra_mc {
212213
struct tegra_smmu *smmu;
213214
struct gart_device *gart;
214215
void __iomem *regs;
216+
void __iomem *bcast_ch_regs;
217+
void __iomem **ch_regs;
215218
struct clk *clk;
216219
int irq;
217220

0 commit comments

Comments
 (0)