memory: tegra: Rename tegra_mc to tegra186_mc on Tegra186
Subsystems (2)
PATCH 1/4 memory: tegra: Rename tegra_mc to tegra186_mc on Tegra186
From: Thierry Reding <[email protected]>
This is just for consistency with the rest of the driver.
--- drivers/memory/tegra/tegra186.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/memory/tegra/tegra186.c +10 -4
@@ -15,7 +15,7 @@ struct tegra_mc {void __iomem *regs; }; -struct tegra_mc_client { +struct tegra186_mc_client {const char *name;unsigned int sid;struct {
@@ -24,7 +24,13 @@ struct tegra_mc_client { } regs; }; -static const struct tegra_mc_client tegra186_mc_clients[] = { +struct tegra186_mc { +struct memory_controller base; +struct device *dev; +void __iomem *regs; +}; + +static const struct tegra186_mc_client tegra186_mc_clients[] = { { .name ="ptcr" , .sid =TEGRA186_SID_PASSTHROUGH ,
@@ -534,8 +540,8 @@ static const struct tegra_mc_client tegra186_mc_clients[] = {static int tegra186_mc_probe (struct platform_device *pdev) { +struct tegra186_mc *mc;struct resource *res; -struct tegra_mc *mc;unsigned int i;int err =0 ;
@@ -551,7 +557,7 @@ static int tegra186_mc_probe(struct platform_device *pdev) mc->dev = &pdev->dev;for (i =0 ; i <ARRAY_SIZE (tegra186_mc_clients); i++) { -const struct tegra_mc_client *client = &tegra186_mc_clients[i]; +const struct tegra186_mc_client *client = &tegra186_mc_clients[i];u32 override, security; override =readl (mc->regs + client->regs.override);
Signature · 1 line
2.23.0
PATCH 2/4 memory: tegra: Add per-SoC data for Tegra186
From: Thierry Reding <[email protected]>
Instead of hard-coding the memory client table, use per-SoC data in preparation for adding support for other SoCs.
--- drivers/memory/tegra/tegra186.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/memory/tegra/tegra186.c +19 -10
@@ -6,15 +6,11 @@#include <linux/io.h> #include <linux/module.h> #include <linux/mod_devicetable.h> +#include <linux/of_device.h> #include <linux/platform_device.h> #include <dt-bindings/memory/tegra186-mc.h> -struct tegra_mc { -struct device *dev; -void __iomem *regs; -}; -struct tegra186_mc_client {const char *name;unsigned int sid;
@@ -24,10 +20,16 @@ struct tegra186_mc_client { } regs; }; +struct tegra186_mc_soc { +const struct tegra186_mc_client *clients; +unsigned int num_clients; +}; +struct tegra186_mc { -struct memory_controller base;struct device *dev;void __iomem *regs; + +const struct tegra186_mc_soc *soc; };static const struct tegra186_mc_client tegra186_mc_clients[] = {
@@ -538,17 +540,24 @@ static const struct tegra186_mc_client tegra186_mc_clients[] = { }, }; +static const struct tegra186_mc_soc tegra186_mc_soc = { + .num_clients =ARRAY_SIZE (tegra186_mc_clients), + .clients = tegra186_mc_clients, +}; +static int tegra186_mc_probe (struct platform_device *pdev) {struct tegra186_mc *mc;struct resource *res;unsigned int i; -int err =0 ; +int err; mc =devm_kzalloc (&pdev->dev,sizeof (*mc),GFP_KERNEL );if (!mc)return -ENOMEM ; + mc->soc =of_device_get_match_data (&pdev->dev); + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); mc->regs =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (mc->regs))
@@ -556,8 +565,8 @@ static int tegra186_mc_probe(struct platform_device *pdev) mc->dev = &pdev->dev; -for (i =0 ; i <ARRAY_SIZE (tegra186_mc_clients); i++) { -const struct tegra186_mc_client *client = &tegra186_mc_clients[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);
@@ -583,7 +592,7 @@ static int tegra186_mc_probe(struct platform_device *pdev) }static const struct of_device_id tegra186_mc_of_match[] = { - { .compatible ="nvidia,tegra186-mc" , }, + { .compatible ="nvidia,tegra186-mc" , .data = &tegra186_mc_soc }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, tegra186_mc_of_match);
Signature · 1 line
2.23.0
PATCH 3/4 memory: tegra: Extract memory client SID programming
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Move programming of the memory client to SID mapping into a separate function so that it can be reused from multiple call sites.
--- drivers/memory/tegra/tegra186.c | 49 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-)
drivers/memory/tegra/tegra186.c +27 -22
@@ -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; }
Signature · 1 line
2.23.0
PATCH 4/4 memory: tegra: Add system sleep support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Add system suspend/resume support for the memory controller found on Tegra186 and later. This is required so that the SID registers can be reprogrammed after their content was lost during system sleep.
--- drivers/memory/tegra/tegra186.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/memory/tegra/tegra186.c +19 -0
@@ -602,10 +602,29 @@ static const struct of_device_id tegra186_mc_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra186_mc_of_match); +static int tegra186_mc_suspend (struct device *dev) +{ +return 0 ; +} + +static int tegra186_mc_resume (struct device *dev) +{ +struct tegra186_mc *mc =dev_get_drvdata (dev); + +tegra186_mc_program_sid (mc); + +return 0 ; +} + +static const struct dev_pm_ops tegra186_mc_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (tegra186_mc_suspend, tegra186_mc_resume) +}; +static struct platform_driver tegra186_mc_driver = { .driver = { .name ="tegra186-mc" , .of_match_table = tegra186_mc_of_match, + .pm = &tegra186_mc_pm_ops, .suppress_bind_attrs = true, }, .prevent_deferred_probe = true,
Signature · 1 line
2.23.0