Watchdog driver for AT32AP700X devices
PATCH 1/1 Watchdog driver for AT32AP700X devices
This patch adds support for the built in watchdog in AT32AP700X devices.
Tested on AT32AP7000 and ATSTK1000.
Hardware documentation can be found in the AT32AP7000 datasheet.
--- drivers/char/watchdog/Kconfig | 20 ++ drivers/char/watchdog/Makefile | 3 + drivers/char/watchdog/at32ap700x_wdt.c | 313 ++++++++++++++++++++++++++++++++ 3 files changed, 336 insertions(+), 0 deletions(-)
drivers/char/watchdog/Kconfig +20 -0
@@ -183,6 +183,26 @@ config PNX4008_WATCHDOG Say N if you are unsure. +# AVR32 Architecture + +config AT32AP700X_WDT + tristate "AT32AP700x watchdog" + depends on WATCHDOG && CPU_AT32AP7000 + help + Watchdog timer embedded into AT32AP700x devices. This will reboot + your system when the timeout is reached. + +config AT32AP700X_WDT_TIMEOUT + int "Timeout value for AT32AP700x watchdog" + depends on AT32AP700X_WDT + default "2" + range 1 2 + help + Sets the timeout value for the watchdog in AT32AP700x devices. + Limited by hardware to be 1 or 2 seconds. + + Set to 2 seconds by default. + # X86 (i386 + ia64 + x86_64) Architecture config ACQUIRE_WDT
drivers/char/watchdog/Makefile +3 -0
@@ -35,6 +35,9 @@ obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o +# AVR32 Architecture +obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o + # X86 (i386 + ia64 + x86_64) Architecture obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o
drivers/char/watchdog/at32ap700x_wdt.c new file +313 -0
313 lines not on this page · raw message
Signature · 1 line
1.4.4.2
Quoted 21 lines · On Wed, 6 Jun 2007 16:04:07 +0200 Hans-Christian Egtvedt…
This patch adds support for the built in watchdog in AT32AP700X devices.
Tested on AT32AP7000 and ATSTK1000.
Hardware documentation can be found in the AT32AP7000 datasheet.
...
drivers/char/watchdog/at32ap700x_wdt.c new file +13
-0+static int __init at32_wdt_probe (struct platform_device *pdev) +{ +struct resource *regs; +int ret; + +if (wdt) { +dev_dbg (&pdev->dev,"only 1 wdt instance supported.\n" ); +return -EBUSY ; + } + + regs =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!regs) { +dev_dbg (&pdev->dev,"missing mmio resource\n" );
drivers/char/watchdog/at32ap700x_wdt.c line 222
Quoted 10 lines
drivers/char/watchdog/at32ap700x_wdt.c new file +10
-0+return -ENXIO ; + } + + wdt =kzalloc (sizeof (struct wdt_at32ap700x ),GFP_KERNEL ); +if (!wdt) { +dev_dbg (&pdev->dev,"no memory for wdt structure\n" ); +return -ENOMEM ; + } + + wdt->regs =ioremap (regs->start, regs->end - regs->start +1 );
I see an ioremap(), but there are no iounmap()s anywhere.
Quoted 5 lines · Andrew Morton
Quoted 2 lines · On Wed, 6 Jun 2007 16:04:07 +0200 Hans-Christian Egtvedt…
This patch adds support for the built in watchdog in AT32AP700X devices.
Quoted 8 lines
Review
Quoted 8 lines
Tested on AT32AP7000 and ATSTK1000.
Hardware documentation can be found in the AT32AP7000 datasheet.
...
(quoted diff) +2
-0+static int __init at32_wdt_probe(struct platform_device *pdev) +{
<cut start of _probe>
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ wdt->regs = ioremap(regs->start, regs->end - regs->start + 1);I see an
ioremap(), but there are no iounmap()s anywhere.
Hmm, that would be my fault, please see the attach patch, it should apply clean to -mm after your two -fix{1,2} patches.
Signature · 4 lines
With kind regards, Hans-Christian Egtvedt, siv.ing. (M.Sc.) Applications Engineer - AVR32 System Solutions - Atmel Norway
Quoted 1 line
From
628847bb359162d2ea3a32a212f098406371119cMon Sep 17 00:00:00 2001
From: Hans-Christian Egtvedt <[email protected]>
Date: Fri, 8 Jun 2007 08:04:43 +0200
Subject: [PATCH 1/1] at32ap700x-wdt: add missing iounmap in _remove
--- drivers/char/watchdog/at32ap700x_wdt.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/char/watchdog/at32ap700x_wdt.c +1 -0
@@ -257,6 +257,7 @@ static int __exit at32_wdt_remove(struct platform_device *pdev) {if (wdt &&platform_get_drvdata (pdev) == wdt) {misc_deregister (&wdt->miscdev); +iounmap (wdt->regs);kfree (wdt); wdt =NULL ;platform_set_drvdata (pdev,NULL );
Signature · 1 line
1.4.4.2
Quoted 17 lines · Hans-Christian Egtvedt
Quoted 5 lines · Andrew Morton
Quoted 2 lines · On Wed, 6 Jun 2007 16:04:07 +0200 Hans-Christian Egtvedt…
This patch adds support for the built in watchdog in AT32AP700X devices.
Quoted 8 lines
Review
Quoted 8 lines
Tested on AT32AP7000 and ATSTK1000.
Hardware documentation can be found in the AT32AP7000 datasheet.
...
(quoted diff) +2
-0+static int __init at32_wdt_probe(struct platform_device *pdev) +{<cut start of
_probe>
Quoted 6 lines
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ wdt->regs = ioremap(regs->start, regs->end - regs->start + 1);I see an
ioremap(), but there are no iounmap()s anywhere.Hmm, that would be my fault, please see the attach patch, it should apply clean to -mm after your two -fix{1,2} patches.
I missed iounmap if the probe function fails, the included patch corrects this. Applies after the previous patches.
Do you want me to fold all five patches? original + fix1 and fix2 + iounmap patches.
Sorry for the minor fixes.
Signature · 4 lines
With kind regards, Hans-Christian Egtvedt, siv.ing. (M.Sc.) Applications Engineer - AVR32 System Solutions - Atmel Norway
Quoted 1 line
From
9618b7b2f49f3d5cb628741e4022097c8836a06aMon Sep 17 00:00:00 2001
From: Hans-Christian Egtvedt <[email protected]>
Date: Fri, 8 Jun 2007 13:17:13 +0200
Subject: [PATCH 1/1] at32ap700x-wdt: add iounmap if probe function fails
--- drivers/char/watchdog/at32ap700x_wdt.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
drivers/char/watchdog/at32ap700x_wdt.c +9 -2
@@ -223,6 +223,11 @@ static int __init at32_wdt_probe(struct platform_device *pdev) } wdt->regs =ioremap (regs->start, regs->end - regs->start +1 ); +if (!wdt->regs) { + ret = -ENOMEM ; +dev_dbg (&pdev->dev,"could not map I/O memory\n" ); + goto err_free; + } wdt->users =0 ; wdt->miscdev.minor =WATCHDOG_MINOR ; wdt->miscdev.name ="watchdog" ;
@@ -238,7 +243,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev) ret =misc_register (&wdt->miscdev);if (ret) {dev_dbg (&pdev->dev,"failed to register wdt miscdev\n" ); - goto err_register; + goto err_iounmap; }platform_set_drvdata (pdev, wdt);
@@ -247,7 +252,9 @@ static int __init at32_wdt_probe(struct platform_device *pdev)return 0 ; -err_register: +err_iounmap: +iounmap (wdt->regs); +err_free:kfree (wdt); wdt =NULL ;return ret;
Signature · 1 line
1.4.4.2
Quoted 2 lines
Do you want me to fold all five patches? original + fix1 and fix2 + iounmap patches.
Th original driver + the 5 fixes have been added to the linux-2.6-watchdog-mm git tree. I'll review the driver later this week.
Greetings,
Wim.