aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Hunter <jonathanh@nvidia.com>2017-03-28 08:42:55 -0400
committerThierry Reding <treding@nvidia.com>2017-04-04 09:49:46 -0400
commit841fd94c43a4034f08eb830ef7b93a441b4d7378 (patch)
tree2141529ff48037ecce7e3c98c8ab3d6b96b5365e
parent7e10cf743634a6b0f3cf63046c49294b38254fe9 (diff)
soc/tegra: flowctrl: Add basic platform driver
Add a simple platform driver for the flowctrl module so that it gets registered as a proper device. Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/soc/tegra/flowctrl.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/drivers/soc/tegra/flowctrl.c b/drivers/soc/tegra/flowctrl.c
index 3a5a1cb9ae90..25eddfc8475d 100644
--- a/drivers/soc/tegra/flowctrl.c
+++ b/drivers/soc/tegra/flowctrl.c
@@ -24,6 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/of.h> 25#include <linux/of.h>
26#include <linux/of_address.h> 26#include <linux/of_address.h>
27#include <linux/platform_device.h>
27 28
28#include <soc/tegra/common.h> 29#include <soc/tegra/common.h>
29#include <soc/tegra/flowctrl.h> 30#include <soc/tegra/flowctrl.h>
@@ -47,7 +48,7 @@ static void __iomem *tegra_flowctrl_base;
47 48
48static void flowctrl_update(u8 offset, u32 value) 49static void flowctrl_update(u8 offset, u32 value)
49{ 50{
50 if (WARN_ONCE(!tegra_flowctrl_base, 51 if (WARN_ONCE(IS_ERR_OR_NULL(tegra_flowctrl_base),
51 "Tegra flowctrl not initialised!\n")) 52 "Tegra flowctrl not initialised!\n"))
52 return; 53 return;
53 54
@@ -62,7 +63,7 @@ u32 flowctrl_read_cpu_csr(unsigned int cpuid)
62{ 63{
63 u8 offset = flowctrl_offset_cpu_csr[cpuid]; 64 u8 offset = flowctrl_offset_cpu_csr[cpuid];
64 65
65 if (WARN_ONCE(!tegra_flowctrl_base, 66 if (WARN_ONCE(IS_ERR_OR_NULL(tegra_flowctrl_base),
66 "Tegra flowctrl not initialised!\n")) 67 "Tegra flowctrl not initialised!\n"))
67 return 0; 68 return 0;
68 69
@@ -148,7 +149,22 @@ void flowctrl_cpu_suspend_exit(unsigned int cpuid)
148 flowctrl_write_cpu_csr(cpuid, reg); 149 flowctrl_write_cpu_csr(cpuid, reg);
149} 150}
150 151
151static const struct of_device_id matches[] __initconst = { 152static int tegra_flowctrl_probe(struct platform_device *pdev)
153{
154 void __iomem *base = tegra_flowctrl_base;
155 struct resource *res;
156
157 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
158 tegra_flowctrl_base = devm_ioremap_resource(&pdev->dev, res);
159 if (IS_ERR(tegra_flowctrl_base))
160 return PTR_ERR(base);
161
162 iounmap(base);
163
164 return 0;
165}
166
167static const struct of_device_id tegra_flowctrl_match[] = {
152 { .compatible = "nvidia,tegra124-flowctrl" }, 168 { .compatible = "nvidia,tegra124-flowctrl" },
153 { .compatible = "nvidia,tegra114-flowctrl" }, 169 { .compatible = "nvidia,tegra114-flowctrl" },
154 { .compatible = "nvidia,tegra30-flowctrl" }, 170 { .compatible = "nvidia,tegra30-flowctrl" },
@@ -156,6 +172,16 @@ static const struct of_device_id matches[] __initconst = {
156 { } 172 { }
157}; 173};
158 174
175static struct platform_driver tegra_flowctrl_driver = {
176 .driver = {
177 .name = "tegra-flowctrl",
178 .suppress_bind_attrs = true,
179 .of_match_table = tegra_flowctrl_match,
180 },
181 .probe = tegra_flowctrl_probe,
182};
183builtin_platform_driver(tegra_flowctrl_driver);
184
159static int __init tegra_flowctrl_init(void) 185static int __init tegra_flowctrl_init(void)
160{ 186{
161 /* hardcoded fallback if device tree node is missing */ 187 /* hardcoded fallback if device tree node is missing */
@@ -166,7 +192,7 @@ static int __init tegra_flowctrl_init(void)
166 if (!soc_is_tegra()) 192 if (!soc_is_tegra())
167 return 0; 193 return 0;
168 194
169 np = of_find_matching_node(NULL, matches); 195 np = of_find_matching_node(NULL, tegra_flowctrl_match);
170 if (np) { 196 if (np) {
171 struct resource res; 197 struct resource res;
172 198