summaryrefslogtreecommitdiff
path: root/drivers/memory
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2019-12-22 17:10:28 +0300
committerThierry Reding <treding@nvidia.com>2020-01-09 21:12:40 +0300
commit6d3ba7616347d3787f361bd7f2fcf8f01bf52c2a (patch)
treec969f17866f0441ff792858bdd0486224cd956e6 /drivers/memory
parent7d723c03e07bd8ec84a9c639c9b037f46d8b7b09 (diff)
downloadlinux-6d3ba7616347d3787f361bd7f2fcf8f01bf52c2a.tar.xz
memory: tegra: Extract memory client SID programming
Move programming of the memory client to SID mapping into a separate function so that it can be reused from multiple call sites. Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/memory')
-rw-r--r--drivers/memory/tegra/tegra186.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c
index ad5c353dba6e..57895116c8e5 100644
--- a/drivers/memory/tegra/tegra186.c
+++ b/drivers/memory/tegra/tegra186.c
@@ -32,6 +32,32 @@ struct tegra186_mc {
const struct tegra186_mc_soc *soc;
};
+static void tegra186_mc_program_sid(struct tegra186_mc *mc)
+{
+ unsigned int i;
+
+ for (i = 0; i < mc->soc->num_clients; i++) {
+ const struct tegra186_mc_client *client = &mc->soc->clients[i];
+ u32 override, security;
+
+ override = readl(mc->regs + client->regs.override);
+ security = readl(mc->regs + client->regs.security);
+
+ dev_dbg(mc->dev, "client %s: override: %x security: %x\n",
+ client->name, override, security);
+
+ dev_dbg(mc->dev, "setting SID %u for %s\n", client->sid,
+ client->name);
+ writel(client->sid, mc->regs + client->regs.override);
+
+ override = readl(mc->regs + client->regs.override);
+ security = readl(mc->regs + client->regs.security);
+
+ dev_dbg(mc->dev, "client %s: override: %x security: %x\n",
+ client->name, override, security);
+ }
+}
+
static const struct tegra186_mc_client tegra186_mc_clients[] = {
{
.name = "ptcr",
@@ -549,7 +575,6 @@ static int tegra186_mc_probe(struct platform_device *pdev)
{
struct tegra186_mc *mc;
struct resource *res;
- unsigned int i;
int err;
mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL);
@@ -565,28 +590,8 @@ static int tegra186_mc_probe(struct platform_device *pdev)
mc->dev = &pdev->dev;
- for (i = 0; i < mc->soc->num_clients; i++) {
- const struct tegra186_mc_client *client = &mc->soc->clients[i];
- u32 override, security;
-
- override = readl(mc->regs + client->regs.override);
- security = readl(mc->regs + client->regs.security);
-
- dev_dbg(&pdev->dev, "client %s: override: %x security: %x\n",
- client->name, override, security);
-
- dev_dbg(&pdev->dev, "setting SID %u for %s\n", client->sid,
- client->name);
- writel(client->sid, mc->regs + client->regs.override);
-
- override = readl(mc->regs + client->regs.override);
- security = readl(mc->regs + client->regs.security);
-
- dev_dbg(&pdev->dev, "client %s: override: %x security: %x\n",
- client->name, override, security);
- }
-
platform_set_drvdata(pdev, mc);
+ tegra186_mc_program_sid(mc);
return err;
}