linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurentp@cse-semaphore.com>
To: linuxppc-dev@ozlabs.org
Cc: Sean MacLennan <smaclennan@pikatech.com>
Subject: Re: [PATCH 5/5] WDT driver
Date: Mon, 14 Apr 2008 10:33:27 +0200	[thread overview]
Message-ID: <200804141033.29929.laurentp@cse-semaphore.com> (raw)
In-Reply-To: <20080412141146.3050e521@lappy.seanm.ca>

[-- Attachment #1: Type: text/plain, Size: 4455 bytes --]

On Saturday 12 April 2008 20:11, Sean MacLennan wrote:
> Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
> 
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 254d115..e73a3ea 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -697,6 +697,14 @@ config BOOKE_WDT
>  	  Please see Documentation/watchdog/watchdog-api.txt for
>  	  more information.
>  
> +config PIKA_WDT
> +	tristate "PIKA FPGA Watchdog"
> +	depends on WARP
> +	default y
> +	help
> +	 This enables the watchdog in the PIKA FPGA. Currently used on
> +	 the Warp platform.
> +
>  # PPC64 Architecture
>  
>  config WATCHDOG_RTAS
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index f3fb170..09758c5 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -105,6 +105,7 @@ obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o
>  obj-$(CONFIG_83xx_WDT) += mpc83xx_wdt.o
>  obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
>  obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
> +obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
>  
>  # PPC64 Architecture
>  obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
> diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
> new file mode 100644
> index 0000000..b84ac07
> --- /dev/null
> +++ b/drivers/watchdog/pika_wdt.c
> @@ -0,0 +1,113 @@
> +/*
> + * PIKA FPGA based Watchdog Timer
> + *
> + * Copyright (c) 2008 PIKA Technologies
> + *   Sean MacLennan <smaclennan at pikatech.com>
> + */
> +
> +#include <linux/module.h>
> +#include <linux/fs.h>
> +#include <linux/miscdevice.h>
> +#include <linux/reboot.h>
> +#include <linux/uaccess.h>
> +#include <linux/io.h>
> +#include <linux/of_platform.h>
> +#include <linux/watchdog.h>
> +
> +
> +static void __iomem *pikawdt_fpga;
> +
> +
> +static inline void pikawdt_ping(void)
> +{
> +	unsigned reset = in_be32(pikawdt_fpga + 0x14);
> +	reset |= 0xf80; /* enable with max timeout - 15 seconds */
> +	out_be32(pikawdt_fpga + 0x14, reset);

What about

setbits32((u32 __iomem *)(pikawdt_fpga + 0x14), 0xf80);

> +}
> +
> +static int pikawdt_open(struct inode *inode, struct file *file)
> +{
> +	printk(KERN_INFO "PIKA WDT started...\n");
> +
> +	pikawdt_ping();
> +
> +	return 0;
> +}
> +
> +static int pikawdt_release(struct inode *inode, struct file *file)
> +{
> +	pikawdt_ping(); /* one last time */
> +	return 0;
> +}
> +
> +static ssize_t pikawdt_write(struct file *file, const char __user *buf,
> +			     size_t count, loff_t *ppos)
> +{
> +	pikawdt_ping();
> +	return count;
> +}
> +
> +/* We support the bare minimum to be conformant. */
> +static int pikawdt_ioctl(struct inode *inode, struct file *file,
> +			 unsigned int cmd, unsigned long arg)
> +{
> +	if (cmd == WDIOC_KEEPALIVE) {
> +		pikawdt_ping();
> +		return 0;
> +	} else
> +		return -EINVAL;
> +}
> +
> +static const struct file_operations pikawdt_fops = {
> +	.owner		= THIS_MODULE,
> +	.open		= pikawdt_open,
> +	.release	= pikawdt_release,
> +	.write		= pikawdt_write,
> +	.ioctl		= pikawdt_ioctl,
> +};
> +
> +static struct miscdevice pikawdt_miscdev = {
> +	.minor	= WATCHDOG_MINOR,
> +	.name	= "watchdog",
> +	.fops	= &pikawdt_fops,
> +};
> +
> +static int __init pikawdt_init(void)
> +{
> +	struct device_node *np;
> +	int ret;
> +
> +	np = of_find_compatible_node(NULL, NULL, "pika,fpga");
> +	if (np == NULL) {
> +		printk(KERN_ERR "pikawdt: Unable to find fpga.\n");
> +		return -ENOENT;
> +	}
> +
> +	pikawdt_fpga = of_iomap(np, 0);
> +
> +	of_node_put(np);
> +
> +	if (pikawdt_fpga == NULL) {
> +		printk(KERN_ERR "pikawdt: Unable to map fpga.\n");
> +		return -ENOENT;
> +	}
> +
> +	ret = misc_register(&pikawdt_miscdev);
> +	if (ret) {
> +		iounmap(pikawdt_fpga);
> +		printk(KERN_ERR "pikawdt: Unable to register miscdev.\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +module_init(pikawdt_init);
> +
> +
> +static void __exit pikawdt_exit(void)
> +{
> +	misc_deregister(&pikawdt_miscdev);
> +
> +	iounmap(pikawdt_fpga);
> +}
> +module_exit(pikawdt_exit);
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
> 
> 

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2008-04-14  8:33 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-12 17:48 Warp patches for 2.6.26 Sean MacLennan
2008-04-12 18:01 ` [PATCH 1/5] Boot code Sean MacLennan
2008-04-13  0:49   ` Josh Boyer
2008-04-13  2:06     ` Sean MacLennan
2008-04-12 18:03 ` PATCH 2/5] Platform code Sean MacLennan
2008-04-13  3:15   ` Sean MacLennan
2008-04-14 16:00   ` David Woodhouse
2008-04-12 18:09 ` [PATCH 3/5] Defconfig Sean MacLennan
2008-04-12 18:10 ` [PATCH 4/5] LED driver Sean MacLennan
2008-04-13  0:41   ` Josh Boyer
2008-04-17 17:32     ` Sean MacLennan
2008-04-13 12:28   ` Peter Korsgaard
2008-04-13 16:51     ` Sean MacLennan
2008-04-13 17:34       ` Peter Korsgaard
2008-04-13 17:51         ` Sean MacLennan
2008-04-12 18:11 ` [PATCH 5/5] WDT driver Sean MacLennan
2008-04-13  0:40   ` Josh Boyer
2008-04-14  8:33   ` Laurent Pinchart [this message]
2008-04-14 15:40     ` Sean MacLennan
2008-04-13  0:44 ` Warp patches for 2.6.26 Stephen Rothwell
2008-04-13  0:50   ` Josh Boyer
2008-04-13  1:55   ` Sean MacLennan
2008-04-13  2:09     ` Grant Likely
2008-04-13  2:38       ` Sean MacLennan
2008-04-13  3:13         ` Dale Farnsworth
2008-04-17 15:50           ` Sean MacLennan
2008-04-17 16:08             ` Dale Farnsworth
2008-04-17 17:26               ` Sean MacLennan
2008-04-17 18:11                 ` Dale Farnsworth
2008-04-13  1:11 ` Paul Mackerras
2008-04-13  2:24 ` Josh Boyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200804141033.29929.laurentp@cse-semaphore.com \
    --to=laurentp@cse-semaphore.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=smaclennan@pikatech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).