mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-17 01:34:00 +08:00
watchdog: sa1100: use platform device registration
Rather than relying on machine specific headers to pass down the reboot status and the register locations, use resources and platform_data. Aside from this, keep the changes to a minimum. Cc: Wim Van Sebroeck <wim@linux-watchdog.org> Cc: linux-watchdog@vger.kernel.org Acked-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
parent
ee84cbd5df
commit
e86bd43bcf
@ -24,6 +24,8 @@
|
||||
#include <linux/platform_data/mmp_dma.h>
|
||||
#include <linux/platform_data/mtd-nand-pxa3xx.h>
|
||||
|
||||
#include <mach/regs-ost.h>
|
||||
#include <mach/reset.h>
|
||||
#include "devices.h"
|
||||
#include "generic.h"
|
||||
|
||||
@ -1118,3 +1120,12 @@ void __init pxa2xx_set_dmac_info(struct mmp_dma_platdata *dma_pdata)
|
||||
{
|
||||
pxa_register_device(&pxa2xx_pxa_dma, dma_pdata);
|
||||
}
|
||||
|
||||
void __init pxa_register_wdt(unsigned int reset_status)
|
||||
{
|
||||
struct resource res = DEFINE_RES_MEM(OST_PHYS, OST_LEN);
|
||||
|
||||
reset_status &= RESET_STATUS_WATCHDOG;
|
||||
platform_device_register_resndata(NULL, "sa1100_wdt", -1, &res, 1,
|
||||
&reset_status, sizeof(reset_status));
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
/*
|
||||
* OS Timer & Match Registers
|
||||
*/
|
||||
#define OST_PHYS 0x40A00000
|
||||
#define OST_LEN 0x00000020
|
||||
|
||||
#define OSMR0 io_p2v(0x40A00000) /* */
|
||||
#define OSMR1 io_p2v(0x40A00004) /* */
|
||||
|
@ -8,8 +8,8 @@
|
||||
#define RESET_STATUS_GPIO (1 << 3) /* GPIO Reset */
|
||||
#define RESET_STATUS_ALL (0xf)
|
||||
|
||||
extern unsigned int reset_status;
|
||||
extern void clear_reset_status(unsigned int mask);
|
||||
extern void pxa_register_wdt(unsigned int reset_status);
|
||||
|
||||
/**
|
||||
* init_gpio_reset() - register GPIO as reset generator
|
||||
|
@ -240,7 +240,7 @@ static int __init pxa25x_init(void)
|
||||
|
||||
if (cpu_is_pxa25x()) {
|
||||
|
||||
reset_status = RCSR;
|
||||
pxa_register_wdt(RCSR);
|
||||
|
||||
pxa25x_init_pm();
|
||||
|
||||
|
@ -337,7 +337,7 @@ static int __init pxa27x_init(void)
|
||||
|
||||
if (cpu_is_pxa27x()) {
|
||||
|
||||
reset_status = RCSR;
|
||||
pxa_register_wdt(RCSR);
|
||||
|
||||
pxa27x_init_pm();
|
||||
|
||||
|
@ -463,7 +463,7 @@ static int __init pxa3xx_init(void)
|
||||
|
||||
if (cpu_is_pxa3xx()) {
|
||||
|
||||
reset_status = ARSR;
|
||||
pxa_register_wdt(ARSR);
|
||||
|
||||
/*
|
||||
* clear RDH bit every time after reset
|
||||
|
@ -11,9 +11,6 @@
|
||||
#include <mach/reset.h>
|
||||
#include <mach/smemc.h>
|
||||
|
||||
unsigned int reset_status;
|
||||
EXPORT_SYMBOL(reset_status);
|
||||
|
||||
static void do_hw_reset(void);
|
||||
|
||||
static int reset_gpio = -1;
|
||||
|
@ -39,9 +39,6 @@
|
||||
#include "generic.h"
|
||||
#include <clocksource/pxa.h>
|
||||
|
||||
unsigned int reset_status;
|
||||
EXPORT_SYMBOL(reset_status);
|
||||
|
||||
#define NR_FREQS 16
|
||||
|
||||
/*
|
||||
@ -319,10 +316,13 @@ static struct platform_device *sa11x0_devices[] __initdata = {
|
||||
|
||||
static int __init sa1100_init(void)
|
||||
{
|
||||
struct resource wdt_res = DEFINE_RES_MEM(0x90000000, 0x20);
|
||||
pm_power_off = sa1100_power_off;
|
||||
|
||||
regulator_has_full_constraints();
|
||||
|
||||
platform_device_register_simple("sa1100_wdt", -1, &wdt_res, 1);
|
||||
|
||||
return platform_add_devices(sa11x0_devices, ARRAY_SIZE(sa11x0_devices));
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#define RESET_STATUS_GPIO (1 << 3) /* GPIO Reset */
|
||||
#define RESET_STATUS_ALL (0xf)
|
||||
|
||||
extern unsigned int reset_status;
|
||||
static inline void clear_reset_status(unsigned int mask)
|
||||
{
|
||||
RCSR = mask;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/watchdog.h>
|
||||
#include <linux/init.h>
|
||||
@ -30,16 +31,42 @@
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/timex.h>
|
||||
|
||||
#ifdef CONFIG_ARCH_PXA
|
||||
#include <mach/regs-ost.h>
|
||||
#endif
|
||||
#define REG_OSMR0 0x0000 /* OS timer Match Reg. 0 */
|
||||
#define REG_OSMR1 0x0004 /* OS timer Match Reg. 1 */
|
||||
#define REG_OSMR2 0x0008 /* OS timer Match Reg. 2 */
|
||||
#define REG_OSMR3 0x000c /* OS timer Match Reg. 3 */
|
||||
#define REG_OSCR 0x0010 /* OS timer Counter Reg. */
|
||||
#define REG_OSSR 0x0014 /* OS timer Status Reg. */
|
||||
#define REG_OWER 0x0018 /* OS timer Watch-dog Enable Reg. */
|
||||
#define REG_OIER 0x001C /* OS timer Interrupt Enable Reg. */
|
||||
|
||||
#include <mach/reset.h>
|
||||
#define OSSR_M3 (1 << 3) /* Match status channel 3 */
|
||||
#define OSSR_M2 (1 << 2) /* Match status channel 2 */
|
||||
#define OSSR_M1 (1 << 1) /* Match status channel 1 */
|
||||
#define OSSR_M0 (1 << 0) /* Match status channel 0 */
|
||||
|
||||
#define OWER_WME (1 << 0) /* Watchdog Match Enable */
|
||||
|
||||
#define OIER_E3 (1 << 3) /* Interrupt enable channel 3 */
|
||||
#define OIER_E2 (1 << 2) /* Interrupt enable channel 2 */
|
||||
#define OIER_E1 (1 << 1) /* Interrupt enable channel 1 */
|
||||
#define OIER_E0 (1 << 0) /* Interrupt enable channel 0 */
|
||||
|
||||
static unsigned long oscr_freq;
|
||||
static unsigned long sa1100wdt_users;
|
||||
static unsigned int pre_margin;
|
||||
static int boot_status;
|
||||
static void __iomem *reg_base;
|
||||
|
||||
static inline void sa1100_wr(u32 val, u32 offset)
|
||||
{
|
||||
writel_relaxed(val, reg_base + offset);
|
||||
}
|
||||
|
||||
static inline u32 sa1100_rd(u32 offset)
|
||||
{
|
||||
return readl_relaxed(reg_base + offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allow only one person to hold it open
|
||||
@ -50,10 +77,10 @@ static int sa1100dog_open(struct inode *inode, struct file *file)
|
||||
return -EBUSY;
|
||||
|
||||
/* Activate SA1100 Watchdog timer */
|
||||
writel_relaxed(readl_relaxed(OSCR) + pre_margin, OSMR3);
|
||||
writel_relaxed(OSSR_M3, OSSR);
|
||||
writel_relaxed(OWER_WME, OWER);
|
||||
writel_relaxed(readl_relaxed(OIER) | OIER_E3, OIER);
|
||||
sa1100_wr(sa1100_rd(REG_OSCR) + pre_margin, REG_OSMR3);
|
||||
sa1100_wr(OSSR_M3, REG_OSSR);
|
||||
sa1100_wr(OWER_WME, REG_OWER);
|
||||
sa1100_wr(sa1100_rd(REG_OIER) | OIER_E3, REG_OIER);
|
||||
return stream_open(inode, file);
|
||||
}
|
||||
|
||||
@ -61,7 +88,7 @@ static int sa1100dog_open(struct inode *inode, struct file *file)
|
||||
* The watchdog cannot be disabled.
|
||||
*
|
||||
* Previous comments suggested that turning off the interrupt by
|
||||
* clearing OIER[E3] would prevent the watchdog timing out but this
|
||||
* clearing REG_OIER[E3] would prevent the watchdog timing out but this
|
||||
* does not appear to be true (at least on the PXA255).
|
||||
*/
|
||||
static int sa1100dog_release(struct inode *inode, struct file *file)
|
||||
@ -76,7 +103,7 @@ static ssize_t sa1100dog_write(struct file *file, const char __user *data,
|
||||
{
|
||||
if (len)
|
||||
/* Refresh OSMR3 timer. */
|
||||
writel_relaxed(readl_relaxed(OSCR) + pre_margin, OSMR3);
|
||||
sa1100_wr(sa1100_rd(REG_OSCR) + pre_margin, REG_OSMR3);
|
||||
return len;
|
||||
}
|
||||
|
||||
@ -110,7 +137,7 @@ static long sa1100dog_ioctl(struct file *file, unsigned int cmd,
|
||||
break;
|
||||
|
||||
case WDIOC_KEEPALIVE:
|
||||
writel_relaxed(readl_relaxed(OSCR) + pre_margin, OSMR3);
|
||||
sa1100_wr(sa1100_rd(REG_OSCR) + pre_margin, REG_OSMR3);
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
@ -125,7 +152,7 @@ static long sa1100dog_ioctl(struct file *file, unsigned int cmd,
|
||||
}
|
||||
|
||||
pre_margin = oscr_freq * time;
|
||||
writel_relaxed(readl_relaxed(OSCR) + pre_margin, OSMR3);
|
||||
sa1100_wr(sa1100_rd(REG_OSCR) + pre_margin, REG_OSMR3);
|
||||
fallthrough;
|
||||
|
||||
case WDIOC_GETTIMEOUT:
|
||||
@ -151,12 +178,22 @@ static struct miscdevice sa1100dog_miscdev = {
|
||||
.fops = &sa1100dog_fops,
|
||||
};
|
||||
|
||||
static int margin __initdata = 60; /* (secs) Default is 1 minute */
|
||||
static int margin = 60; /* (secs) Default is 1 minute */
|
||||
static struct clk *clk;
|
||||
|
||||
static int __init sa1100dog_init(void)
|
||||
static int sa1100dog_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret;
|
||||
int *platform_data;
|
||||
struct resource *res;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res)
|
||||
return -ENXIO;
|
||||
reg_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
|
||||
ret = PTR_ERR_OR_ZERO(reg_base);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
clk = clk_get(NULL, "OSTIMER0");
|
||||
if (IS_ERR(clk)) {
|
||||
@ -174,13 +211,9 @@ static int __init sa1100dog_init(void)
|
||||
|
||||
oscr_freq = clk_get_rate(clk);
|
||||
|
||||
/*
|
||||
* Read the reset status, and save it for later. If
|
||||
* we suspend, RCSR will be cleared, and the watchdog
|
||||
* reset reason will be lost.
|
||||
*/
|
||||
boot_status = (reset_status & RESET_STATUS_WATCHDOG) ?
|
||||
WDIOF_CARDRESET : 0;
|
||||
platform_data = pdev->dev.platform_data;
|
||||
if (platform_data && *platform_data)
|
||||
boot_status = WDIOF_CARDRESET;
|
||||
pre_margin = oscr_freq * margin;
|
||||
|
||||
ret = misc_register(&sa1100dog_miscdev);
|
||||
@ -196,15 +229,21 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit sa1100dog_exit(void)
|
||||
static int sa1100dog_remove(struct platform_device *pdev)
|
||||
{
|
||||
misc_deregister(&sa1100dog_miscdev);
|
||||
clk_disable_unprepare(clk);
|
||||
clk_put(clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(sa1100dog_init);
|
||||
module_exit(sa1100dog_exit);
|
||||
struct platform_driver sa1100dog_driver = {
|
||||
.driver.name = "sa1100_wdt",
|
||||
.probe = sa1100dog_probe,
|
||||
.remove = sa1100dog_remove,
|
||||
};
|
||||
module_platform_driver(sa1100dog_driver);
|
||||
|
||||
MODULE_AUTHOR("Oleg Drokin <green@crimea.edu>");
|
||||
MODULE_DESCRIPTION("SA1100/PXA2xx Watchdog");
|
||||
|
Loading…
Reference in New Issue
Block a user