mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
memory: tegra: Add per-SoC data for Tegra186
Instead of hard-coding the memory client table, use per-SoC data in preparation for adding support for other SoCs. Signed-off-by: Thierry Reding <treding@nvidia.com>
This commit is contained in:
@@ -6,15 +6,11 @@
|
|||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/mod_devicetable.h>
|
#include <linux/mod_devicetable.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
|
||||||
#include <dt-bindings/memory/tegra186-mc.h>
|
#include <dt-bindings/memory/tegra186-mc.h>
|
||||||
|
|
||||||
struct tegra_mc {
|
|
||||||
struct device *dev;
|
|
||||||
void __iomem *regs;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct tegra186_mc_client {
|
struct tegra186_mc_client {
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned int sid;
|
unsigned int sid;
|
||||||
@@ -24,10 +20,16 @@ struct tegra186_mc_client {
|
|||||||
} regs;
|
} regs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct tegra186_mc_soc {
|
||||||
|
const struct tegra186_mc_client *clients;
|
||||||
|
unsigned int num_clients;
|
||||||
|
};
|
||||||
|
|
||||||
struct tegra186_mc {
|
struct tegra186_mc {
|
||||||
struct memory_controller base;
|
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
void __iomem *regs;
|
void __iomem *regs;
|
||||||
|
|
||||||
|
const struct tegra186_mc_soc *soc;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct tegra186_mc_client tegra186_mc_clients[] = {
|
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)
|
static int tegra186_mc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct tegra186_mc *mc;
|
struct tegra186_mc *mc;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL);
|
mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL);
|
||||||
if (!mc)
|
if (!mc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
mc->soc = of_device_get_match_data(&pdev->dev);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
mc->regs = devm_ioremap_resource(&pdev->dev, res);
|
mc->regs = devm_ioremap_resource(&pdev->dev, res);
|
||||||
if (IS_ERR(mc->regs))
|
if (IS_ERR(mc->regs))
|
||||||
@@ -556,8 +565,8 @@ static int tegra186_mc_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
mc->dev = &pdev->dev;
|
mc->dev = &pdev->dev;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(tegra186_mc_clients); i++) {
|
for (i = 0; i < mc->soc->num_clients; i++) {
|
||||||
const struct tegra186_mc_client *client = &tegra186_mc_clients[i];
|
const struct tegra186_mc_client *client = &mc->soc->clients[i];
|
||||||
u32 override, security;
|
u32 override, security;
|
||||||
|
|
||||||
override = readl(mc->regs + client->regs.override);
|
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[] = {
|
static const struct of_device_id tegra186_mc_of_match[] = {
|
||||||
{ .compatible = "nvidia,tegra186-mc", },
|
{ .compatible = "nvidia,tegra186-mc", .data = &tegra186_mc_soc },
|
||||||
{ /* sentinel */ }
|
{ /* sentinel */ }
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, tegra186_mc_of_match);
|
MODULE_DEVICE_TABLE(of, tegra186_mc_of_match);
|
||||||
|
Reference in New Issue
Block a user