Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 97319
b: refs/heads/master
c: 656a3f7
h: refs/heads/master
i:
  97317: e9cae87
  97315: b6d1189
  97311: 748830a
v: v3
  • Loading branch information
Gabriel C authored and Sam Ravnborg committed May 25, 2008
1 parent 53a753f commit 0031b4a
Show file tree
Hide file tree
Showing 16 changed files with 122 additions and 521 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c8ff99a7c2fb23a0f1165f3821fd66fd65f30264
refs/heads/master: 656a3f797889dafcce2f5b8b222ad66e9974b6f7
13 changes: 0 additions & 13 deletions trunk/drivers/watchdog/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,6 @@ config ALIM7101_WDT

Most people will say N.

config GEODE_WDT
tristate "AMD Geode CS5535/CS5536 Watchdog"
depends on MGEODE_LX
help
This driver enables a watchdog capability built into the
CS5535/CS5536 companion chips for the AMD Geode GX and LX
processors. This watchdog watches your kernel to make sure
it doesn't freeze, and if it does, it reboots your computer after
a certain amount of time.

You can compile this driver directly into the kernel, or use
it as a module. The module will be called geodewdt.

config SC520_WDT
tristate "AMD Elan SC520 processor Watchdog"
depends on X86
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/watchdog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o
obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o
obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o
obj-$(CONFIG_GEODE_WDT) += geodewdt.o
obj-$(CONFIG_SC520_WDT) += sc520_wdt.o
obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o
obj-$(CONFIG_IB700_WDT) += ib700wdt.o
Expand Down
111 changes: 40 additions & 71 deletions trunk/drivers/watchdog/bfin_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@

#define stamp(fmt, args...) pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args)
#define stampit() stamp("here i am")
#define pr_devinit(fmt, args...) ({ static const __devinitconst char __fmt[] = fmt; printk(__fmt, ## args); })
#define pr_init(fmt, args...) ({ static const __initconst char __fmt[] = fmt; printk(__fmt, ## args); })
#define pr_init(fmt, args...) ({ static const __initdata char __fmt[] = fmt; printk(__fmt, ## args); })

#define WATCHDOG_NAME "bfin-wdt"
#define PFX WATCHDOG_NAME ": "
Expand Down Expand Up @@ -378,6 +377,20 @@ static int bfin_wdt_resume(struct platform_device *pdev)
# define bfin_wdt_resume NULL
#endif

static struct platform_device bfin_wdt_device = {
.name = WATCHDOG_NAME,
.id = -1,
};

static struct platform_driver bfin_wdt_driver = {
.driver = {
.name = WATCHDOG_NAME,
.owner = THIS_MODULE,
},
.suspend = bfin_wdt_suspend,
.resume = bfin_wdt_resume,
};

static const struct file_operations bfin_wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
Expand All @@ -404,67 +417,11 @@ static struct notifier_block bfin_wdt_notifier = {
.notifier_call = bfin_wdt_notify_sys,
};

/**
* bfin_wdt_probe - Initialize module
*
* Registers the misc device and notifier handler. Actual device
* initialization is handled by bfin_wdt_open().
*/
static int __devinit bfin_wdt_probe(struct platform_device *pdev)
{
int ret;

ret = register_reboot_notifier(&bfin_wdt_notifier);
if (ret) {
pr_devinit(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret);
return ret;
}

ret = misc_register(&bfin_wdt_miscdev);
if (ret) {
pr_devinit(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret);
unregister_reboot_notifier(&bfin_wdt_notifier);
return ret;
}

pr_devinit(KERN_INFO PFX "initialized: timeout=%d sec (nowayout=%d)\n",
timeout, nowayout);

return 0;
}

/**
* bfin_wdt_remove - Initialize module
*
* Unregisters the misc device and notifier handler. Actual device
* deinitialization is handled by bfin_wdt_close().
*/
static int __devexit bfin_wdt_remove(struct platform_device *pdev)
{
misc_deregister(&bfin_wdt_miscdev);
unregister_reboot_notifier(&bfin_wdt_notifier);
return 0;
}

static struct platform_device *bfin_wdt_device;

static struct platform_driver bfin_wdt_driver = {
.probe = bfin_wdt_probe,
.remove = __devexit_p(bfin_wdt_remove),
.suspend = bfin_wdt_suspend,
.resume = bfin_wdt_resume,
.driver = {
.name = WATCHDOG_NAME,
.owner = THIS_MODULE,
},
};

/**
* bfin_wdt_init - Initialize module
*
* Checks the module params and registers the platform device & driver.
* Real work is in the platform probe function.
* Registers the device and notifier handler. Actual device
* initialization is handled by bfin_wdt_open().
*/
static int __init bfin_wdt_init(void)
{
Expand All @@ -479,32 +436,44 @@ static int __init bfin_wdt_init(void)
/* Since this is an on-chip device and needs no board-specific
* resources, we'll handle all the platform device stuff here.
*/
ret = platform_driver_register(&bfin_wdt_driver);
ret = platform_device_register(&bfin_wdt_device);
if (ret)
return ret;

ret = platform_driver_probe(&bfin_wdt_driver, NULL);
if (ret)
return ret;

ret = register_reboot_notifier(&bfin_wdt_notifier);
if (ret) {
pr_init(KERN_ERR PFX "unable to register driver\n");
pr_init(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret);
return ret;
}

bfin_wdt_device = platform_device_register_simple(WATCHDOG_NAME, -1, NULL, 0);
if (IS_ERR(bfin_wdt_device)) {
pr_init(KERN_ERR PFX "unable to register device\n");
platform_driver_unregister(&bfin_wdt_driver);
return PTR_ERR(bfin_wdt_device);
ret = misc_register(&bfin_wdt_miscdev);
if (ret) {
pr_init(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret);
unregister_reboot_notifier(&bfin_wdt_notifier);
return ret;
}

pr_init(KERN_INFO PFX "initialized: timeout=%d sec (nowayout=%d)\n",
timeout, nowayout);

return 0;
}

/**
* bfin_wdt_exit - Deinitialize module
*
* Back out the platform device & driver steps. Real work is in the
* platform remove function.
* Unregisters the device and notifier handler. Actual device
* deinitialization is handled by bfin_wdt_close().
*/
static void __exit bfin_wdt_exit(void)
{
platform_device_unregister(bfin_wdt_device);
platform_driver_unregister(&bfin_wdt_driver);
misc_deregister(&bfin_wdt_miscdev);
unregister_reboot_notifier(&bfin_wdt_notifier);
}

module_init(bfin_wdt_init);
Expand Down
88 changes: 48 additions & 40 deletions trunk/drivers/watchdog/booke_wdt.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/*
* drivers/char/watchdog/booke_wdt.c
*
* Watchdog timer for PowerPC Book-E systems
*
* Author: Matthew McClintock
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
*
* Copyright 2005, 2008 Freescale Semiconductor Inc.
* Copyright 2005 Freescale Semiconductor Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
Expand All @@ -14,7 +16,6 @@

#include <linux/module.h>
#include <linux/fs.h>
#include <linux/smp.h>
#include <linux/miscdevice.h>
#include <linux/notifier.h>
#include <linux/watchdog.h>
Expand All @@ -37,7 +38,7 @@
#define WDT_PERIOD_DEFAULT 3 /* Refer to the PPC40x and PPC4xx manuals */
#endif /* for timing information */

u32 booke_wdt_enabled;
u32 booke_wdt_enabled = 0;
u32 booke_wdt_period = WDT_PERIOD_DEFAULT;

#ifdef CONFIG_FSL_BOOKE
Expand All @@ -46,51 +47,57 @@ u32 booke_wdt_period = WDT_PERIOD_DEFAULT;
#define WDTP(x) (TCR_WP(x))
#endif

static DEFINE_SPINLOCK(booke_wdt_lock);

static void __booke_wdt_ping(void *data)
/*
* booke_wdt_ping:
*/
static __inline__ void booke_wdt_ping(void)
{
mtspr(SPRN_TSR, TSR_ENW|TSR_WIS);
}

static void booke_wdt_ping(void)
{
on_each_cpu(__booke_wdt_ping, NULL, 0, 0);
}

static void __booke_wdt_enable(void *data)
/*
* booke_wdt_enable:
*/
static __inline__ void booke_wdt_enable(void)
{
u32 val;

/* clear status before enabling watchdog */
__booke_wdt_ping(NULL);
booke_wdt_ping();
val = mfspr(SPRN_TCR);
val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period));

mtspr(SPRN_TCR, val);
}

static ssize_t booke_wdt_write(struct file *file, const char __user *buf,
/*
* booke_wdt_write:
*/
static ssize_t booke_wdt_write (struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
booke_wdt_ping();
return count;
}

static struct watchdog_info ident = {
.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
.identity = "PowerPC Book-E Watchdog",
.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
.firmware_version = 0,
.identity = "PowerPC Book-E Watchdog",
};

static int booke_wdt_ioctl(struct inode *inode, struct file *file,
/*
* booke_wdt_ioctl:
*/
static int booke_wdt_ioctl (struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
u32 tmp = 0;
u32 __user *p = (u32 __user *)arg;

switch (cmd) {
case WDIOC_GETSUPPORT:
if (copy_to_user((struct watchdog_info __user *)arg, &ident,
if (copy_to_user ((struct watchdog_info __user *) arg, &ident,
sizeof(struct watchdog_info)))
return -EFAULT;
case WDIOC_GETSTATUS:
Expand Down Expand Up @@ -125,61 +132,62 @@ static int booke_wdt_ioctl(struct inode *inode, struct file *file,

return 0;
}

static int booke_wdt_open(struct inode *inode, struct file *file)
/*
* booke_wdt_open:
*/
static int booke_wdt_open (struct inode *inode, struct file *file)
{
spin_lock(&booke_wdt_lock);
if (booke_wdt_enabled == 0) {
booke_wdt_enabled = 1;
on_each_cpu(__booke_wdt_enable, NULL, 0, 0);
printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled "
"(wdt_period=%d)\n", booke_wdt_period);
booke_wdt_enable();
printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n",
booke_wdt_period);
}
spin_unlock(&booke_wdt_lock);

return nonseekable_open(inode, file);
}

static const struct file_operations booke_wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = booke_wdt_write,
.ioctl = booke_wdt_ioctl,
.open = booke_wdt_open,
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = booke_wdt_write,
.ioctl = booke_wdt_ioctl,
.open = booke_wdt_open,
};

static struct miscdevice booke_wdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &booke_wdt_fops,
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &booke_wdt_fops,
};

static void __exit booke_wdt_exit(void)
{
misc_deregister(&booke_wdt_miscdev);
}

/*
* booke_wdt_init:
*/
static int __init booke_wdt_init(void)
{
int ret = 0;

printk(KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n");
printk (KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n");
ident.firmware_version = cur_cpu_spec->pvr_value;

ret = misc_register(&booke_wdt_miscdev);
if (ret) {
printk(KERN_CRIT "Cannot register miscdev on minor=%d: %d\n",
printk (KERN_CRIT "Cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret);
return ret;
}

spin_lock(&booke_wdt_lock);
if (booke_wdt_enabled == 1) {
printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled "
"(wdt_period=%d)\n", booke_wdt_period);
on_each_cpu(__booke_wdt_enable, NULL, 0, 0);
printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n",
booke_wdt_period);
booke_wdt_enable();
}
spin_unlock(&booke_wdt_lock);

return ret;
}
Expand Down
Loading

0 comments on commit 0031b4a

Please sign in to comment.