Skip to content

Commit

Permalink
watchdog: orion: Introduce a SoC-specific RSTOUT mapping
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ezequiel Garcia authored and Wim Van Sebroeck committed Jun 10, 2014
1 parent aaaac9e commit 92d4fc1
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions drivers/watchdog/orion_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@ static void __iomem *orion_wdt_ioremap_rstout(struct platform_device *pdev,
return devm_ioremap(&pdev->dev, res->start,
resource_size(res));

/* This workaround works only for "orion-wdt", DT-enabled */
if (!of_device_is_compatible(pdev->dev.of_node, "marvell,orion-wdt"))
return NULL;

rstout = internal_regs + ORION_RSTOUT_MASK_OFFSET;

WARN(1, FW_BUG "falling back to harcoded RSTOUT reg %pa\n", &rstout);
Expand Down Expand Up @@ -316,6 +312,7 @@ MODULE_DEVICE_TABLE(of, orion_wdt_of_match_table);
static int orion_wdt_get_regs(struct platform_device *pdev,
struct orion_watchdog *dev)
{
struct device_node *node = pdev->dev.of_node;
struct resource *res;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Expand All @@ -326,10 +323,26 @@ static int orion_wdt_get_regs(struct platform_device *pdev,
if (!dev->reg)
return -ENOMEM;

dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start &
INTERNAL_REGS_MASK);
if (!dev->rstout)
/* Each supported compatible has some RSTOUT register quirk */
if (of_device_is_compatible(node, "marvell,orion-wdt")) {

dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start &
INTERNAL_REGS_MASK);
if (!dev->rstout)
return -ENODEV;

} else if (of_device_is_compatible(node, "marvell,armada-370-wdt") ||
of_device_is_compatible(node, "marvell,armada-xp-wdt")) {

/* Dedicated RSTOUT register, can be requested. */
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
dev->rstout = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(dev->rstout))
return PTR_ERR(dev->rstout);

} else {
return -ENODEV;
}

return 0;
}
Expand Down

0 comments on commit 92d4fc1

Please sign in to comment.