1 The RDC321x MFD southbridge driver will pass a reference to the southbridge
2 PCI device which should be used by the watchdog driver for its operations.
3 This patch converts the watchdog driver to use the pci_dev pointer and make use
4 of the base register resource which is passed along with the platform device.
6 Acked-by: Wim Van Sebroeck <wim@iguana.be>
7 Signed-off-by: Florian Fainelli <florian@openwrt.org>
10 - replaced rdc321x_pci_{read,write}
11 - use the pci_dev pointer passed as platform_data
13 Index: linux-2.6.30.10/drivers/watchdog/rdc321x_wdt.c
14 ===================================================================
15 --- linux-2.6.30.10.orig/drivers/watchdog/rdc321x_wdt.c 2009-12-04 07:00:07.000000000 +0100
16 +++ linux-2.6.30.10/drivers/watchdog/rdc321x_wdt.c 2010-04-28 10:17:46.000000000 +0200
19 * RDC321x watchdog driver
21 - * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
22 + * Copyright (C) 2007-2010 Florian Fainelli <florian@openwrt.org>
24 * This driver is highly inspired from the cpu5_wdt driver
27 #include <linux/watchdog.h>
29 #include <linux/uaccess.h>
31 -#include <asm/rdc321x_defs.h>
32 +#include <linux/mfd/rdc321x.h>
34 #define RDC_WDT_MASK 0x80000000 /* Mask */
35 #define RDC_WDT_EN 0x00800000 /* Enable bit */
40 + struct pci_dev *sb_pdev;
44 /* generic helper functions */
46 static void rdc321x_wdt_trigger(unsigned long unused)
51 if (rdc321x_wdt_device.running)
54 /* keep watchdog alive */
55 spin_lock_irqsave(&rdc321x_wdt_device.lock, flags);
56 - outl(RDC_WDT_EN | inl(RDC3210_CFGREG_DATA),
57 - RDC3210_CFGREG_DATA);
58 + pci_read_config_dword(rdc321x_wdt_device.sb_pdev,
59 + rdc321x_wdt_device.base_reg, &val);
61 + pci_write_config_dword(rdc321x_wdt_device.sb_pdev,
62 + rdc321x_wdt_device.base_reg, val);
63 spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags);
69 spin_lock_irqsave(&rdc321x_wdt_device.lock, flags);
70 - outl(RDC_CLS_TMR, RDC3210_CFGREG_ADDR);
71 + pci_write_config_dword(rdc321x_wdt_device.sb_pdev,
72 + rdc321x_wdt_device.base_reg, RDC_CLS_TMR);
74 /* Enable watchdog and set the timeout to 81.92 us */
75 - outl(RDC_WDT_EN | RDC_WDT_CNT, RDC3210_CFGREG_DATA);
76 + pci_write_config_dword(rdc321x_wdt_device.sb_pdev,
77 + rdc321x_wdt_device.base_reg,
78 + RDC_WDT_EN | RDC_WDT_CNT);
79 spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags);
81 mod_timer(&rdc321x_wdt_device.timer,
85 void __user *argp = (void __user *)arg;
88 static struct watchdog_info ident = {
89 .options = WDIOF_CARDRESET,
90 .identity = "RDC321x WDT",
93 /* Read the value from the DATA register */
94 spin_lock_irqsave(&rdc321x_wdt_device.lock, flags);
95 - value = inl(RDC3210_CFGREG_DATA);
96 + pci_read_config_dword(rdc321x_wdt_device.sb_pdev,
97 + rdc321x_wdt_device.base_reg, &value);
98 spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags);
99 - if (copy_to_user(argp, &value, sizeof(int)))
100 + if (copy_to_user(argp, &value, sizeof(u32)))
103 case WDIOC_GETSUPPORT:
104 @@ -219,17 +228,35 @@
105 static int __devinit rdc321x_wdt_probe(struct platform_device *pdev)
108 + struct resource *r;
109 + struct rdc321x_wdt_pdata *pdata;
111 + pdata = pdev->dev.platform_data;
113 + dev_err(&pdev->dev, "no platform data supplied\n");
117 + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wdt-reg");
119 + dev_err(&pdev->dev, "failed to get wdt-reg resource\n");
123 + rdc321x_wdt_device.sb_pdev = pdata->sb_pdev;
124 + rdc321x_wdt_device.base_reg = r->start;
126 err = misc_register(&rdc321x_wdt_misc);
128 - printk(KERN_ERR PFX "watchdog misc_register failed\n");
129 + dev_err(&pdev->dev, "misc_register failed\n");
133 spin_lock_init(&rdc321x_wdt_device.lock);
135 /* Reset the watchdog */
136 - outl(RDC_WDT_RST, RDC3210_CFGREG_DATA);
137 + pci_write_config_dword(rdc321x_wdt_device.sb_pdev,
138 + rdc321x_wdt_device.base_reg, RDC_WDT_RST);
140 init_completion(&rdc321x_wdt_device.stop);
141 rdc321x_wdt_device.queue = 0;
144 rdc321x_wdt_device.default_ticks = ticks;
146 - printk(KERN_INFO PFX "watchdog init success\n");
147 + dev_info(&pdev->dev, "watchdog init success\n");