Skip to content

Commit e38da7d

Browse files
henning-schildlag-linaro
authored andcommitted
watchdog: simatic-ipc-wdt: convert to use P2SB accessor
Since we have a common P2SB accessor in tree we may use it instead of open coded variants. Replace custom code by p2sb_bar() call. Signed-off-by: Henning Schild <[email protected]> Acked-by: Guenter Roeck <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent 7b2db70 commit e38da7d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

drivers/watchdog/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,7 @@ config SIEMENS_SIMATIC_IPC_WDT
16471647
tristate "Siemens Simatic IPC Watchdog"
16481648
depends on SIEMENS_SIMATIC_IPC
16491649
select WATCHDOG_CORE
1650+
select P2SB
16501651
help
16511652
This driver adds support for several watchdogs found in Industrial
16521653
PCs from Siemens.

drivers/watchdog/simatic-ipc-wdt.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/kernel.h>
1717
#include <linux/module.h>
1818
#include <linux/pci.h>
19+
#include <linux/platform_data/x86/p2sb.h>
1920
#include <linux/platform_data/x86/simatic-ipc-base.h>
2021
#include <linux/platform_device.h>
2122
#include <linux/sizes.h>
@@ -54,9 +55,9 @@ static struct resource io_resource_trigger =
5455
DEFINE_RES_IO_NAMED(WD_TRIGGER_IOADR, SZ_1,
5556
KBUILD_MODNAME " WD_TRIGGER_IOADR");
5657

57-
/* the actual start will be discovered with pci, 0 is a placeholder */
58+
/* the actual start will be discovered with p2sb, 0 is a placeholder */
5859
static struct resource mem_resource =
59-
DEFINE_RES_MEM_NAMED(0, SZ_4, "WD_RESET_BASE_ADR");
60+
DEFINE_RES_MEM_NAMED(0, 0, "WD_RESET_BASE_ADR");
6061

6162
static u32 wd_timeout_table[] = {2, 4, 6, 8, 16, 32, 48, 64 };
6263
static void __iomem *wd_reset_base_addr;
@@ -150,6 +151,7 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev)
150151
struct simatic_ipc_platform *plat = pdev->dev.platform_data;
151152
struct device *dev = &pdev->dev;
152153
struct resource *res;
154+
int ret;
153155

154156
switch (plat->devmode) {
155157
case SIMATIC_IPC_DEVICE_227E:
@@ -190,15 +192,14 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev)
190192
if (plat->devmode == SIMATIC_IPC_DEVICE_427E) {
191193
res = &mem_resource;
192194

193-
/* get GPIO base from PCI */
194-
res->start = simatic_ipc_get_membase0(PCI_DEVFN(0x1f, 1));
195-
if (res->start == 0)
196-
return -ENODEV;
195+
ret = p2sb_bar(NULL, 0, res);
196+
if (ret)
197+
return ret;
197198

198199
/* do the final address calculation */
199200
res->start = res->start + (GPIO_COMMUNITY0_PORT_ID << 16) +
200201
PAD_CFG_DW0_GPP_A_23;
201-
res->end += res->start;
202+
res->end = res->start + SZ_4 - 1;
202203

203204
wd_reset_base_addr = devm_ioremap_resource(dev, res);
204205
if (IS_ERR(wd_reset_base_addr))

0 commit comments

Comments
 (0)