diff options
author | Ezequiel Garcia <ezequiel.garcia@free-electrons.com> | 2014-03-15 14:17:57 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2014-06-10 15:44:06 -0400 |
commit | 92d4fc1a1f56a12fa09c92d8c89873509a8012c9 (patch) | |
tree | 3759aeeae801787401f0c7d0db04533574cf4411 /drivers/watchdog | |
parent | aaaac9ec79b7c4e21741df35d2247a1187836129 (diff) |
watchdog: orion: Introduce a SoC-specific RSTOUT mapping
Separate the RSTOUT register mapping for the different compatible strings
supported by the driver. This allows to use devm_ioremap on SoC variants that
share the RSTOUT register, and devm_ioremap_resource (which requests the MMIO
region) on SoCs that have a dedicated RSTOUT register.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Tested-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r-- | drivers/watchdog/orion_wdt.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index afa38314fb18..75f623f5e6c3 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c | |||
@@ -262,10 +262,6 @@ static void __iomem *orion_wdt_ioremap_rstout(struct platform_device *pdev, | |||
262 | return devm_ioremap(&pdev->dev, res->start, | 262 | return devm_ioremap(&pdev->dev, res->start, |
263 | resource_size(res)); | 263 | resource_size(res)); |
264 | 264 | ||
265 | /* This workaround works only for "orion-wdt", DT-enabled */ | ||
266 | if (!of_device_is_compatible(pdev->dev.of_node, "marvell,orion-wdt")) | ||
267 | return NULL; | ||
268 | |||
269 | rstout = internal_regs + ORION_RSTOUT_MASK_OFFSET; | 265 | rstout = internal_regs + ORION_RSTOUT_MASK_OFFSET; |
270 | 266 | ||
271 | WARN(1, FW_BUG "falling back to harcoded RSTOUT reg %pa\n", &rstout); | 267 | WARN(1, FW_BUG "falling back to harcoded RSTOUT reg %pa\n", &rstout); |
@@ -316,6 +312,7 @@ MODULE_DEVICE_TABLE(of, orion_wdt_of_match_table); | |||
316 | static int orion_wdt_get_regs(struct platform_device *pdev, | 312 | static int orion_wdt_get_regs(struct platform_device *pdev, |
317 | struct orion_watchdog *dev) | 313 | struct orion_watchdog *dev) |
318 | { | 314 | { |
315 | struct device_node *node = pdev->dev.of_node; | ||
319 | struct resource *res; | 316 | struct resource *res; |
320 | 317 | ||
321 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 318 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -326,10 +323,26 @@ static int orion_wdt_get_regs(struct platform_device *pdev, | |||
326 | if (!dev->reg) | 323 | if (!dev->reg) |
327 | return -ENOMEM; | 324 | return -ENOMEM; |
328 | 325 | ||
329 | dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start & | 326 | /* Each supported compatible has some RSTOUT register quirk */ |
330 | INTERNAL_REGS_MASK); | 327 | if (of_device_is_compatible(node, "marvell,orion-wdt")) { |
331 | if (!dev->rstout) | 328 | |
329 | dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start & | ||
330 | INTERNAL_REGS_MASK); | ||
331 | if (!dev->rstout) | ||
332 | return -ENODEV; | ||
333 | |||
334 | } else if (of_device_is_compatible(node, "marvell,armada-370-wdt") || | ||
335 | of_device_is_compatible(node, "marvell,armada-xp-wdt")) { | ||
336 | |||
337 | /* Dedicated RSTOUT register, can be requested. */ | ||
338 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
339 | dev->rstout = devm_ioremap_resource(&pdev->dev, res); | ||
340 | if (IS_ERR(dev->rstout)) | ||
341 | return PTR_ERR(dev->rstout); | ||
342 | |||
343 | } else { | ||
332 | return -ENODEV; | 344 | return -ENODEV; |
345 | } | ||
333 | 346 | ||
334 | return 0; | 347 | return 0; |
335 | } | 348 | } |