Skip to contentSkip to conversation

watchdog: Add support for the Freescale MXC watchdog

PATCH New Vladimir Zapolskiy 4 participants 11 messages Mar 19, 2010 – Mar 22, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 watchdog: Add support for the Freescale MXC watchdog

Add driver for the Freescale MXC SoCs built-in watchdog.

Cc Wim Van Sebroeck <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Uwe Kleine-K?nig <[email protected]>
---
 drivers/watchdog/Kconfig   |   10 ++
 drivers/watchdog/Makefile  |    1 +
 drivers/watchdog/mxc_wdt.c |  385 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 396 insertions(+), 0 deletions(-)
 create mode 100644 drivers/watchdog/mxc_wdt.c
drivers/watchdog/Kconfig +10 -0
index 088f32f..985d067 100644
@@ -289,6 +289,16 @@ config ADX_WATCHDOG
 	  Say Y here if you want support for the watchdog timer on Avionic
 	  Design Xanthos boards.
 
+config MXC_WATCHDOG
+	tristate "MXC watchdog"
+	depends on ARCH_MXC
+        select WATCHDOG_NOWAYOUT
+	help
+	  Say Y here if to include support for the watchdog timer
+	  in Freescale MXC SoCs.
+	  To compile this driver as a module, choose M here: the
+	  module will be called mxc_wdt.
+
 # AVR32 Architecture
 
 config AT32AP700X_WDT
drivers/watchdog/Makefile +1 -0
index 475c611..347c227 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o
 obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
 obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
 obj-$(CONFIG_ADX_WATCHDOG) += adx_wdt.o
+obj-$(CONFIG_MXC_WATCHDOG) += mxc_wdt.o
 
 # AVR32 Architecture
 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
drivers/watchdog/mxc_wdt.c new file +385 -0

385 lines not on this page · raw message

Signature · 1 line
1.6.6.1
#1 lore raw

PATCH 2/3 imx3: Add watchdog platform device support

This patch adds support for build-in watchdog device found on Freescale imx31 and imx35 SoCs.

Cc Sascha Hauer <[email protected]>
Cc Uwe Kleine-K?nig <[email protected]>
---
 arch/arm/mach-mx3/devices.c |   19 ++++++++++++++++++-
 arch/arm/mach-mx3/devices.h |    3 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)
arch/arm/mach-mx3/devices.c +18 -1
index 6adb586..f891115 100644
@@ -575,11 +575,26 @@ struct platform_device imx_ssi_device1 = {
 	.resource = imx_ssi_resources1,
 };
 
-static int mx3_devices_init(void)
+static struct resource imx_wdt_resources[] = {
+	{
+		.flags = IORESOURCE_MEM,
+	},
+};
+
+struct platform_device imx_wdt_device0 = {
+	.name           = "imx-wdt",
+	.id             = 0,
+	.num_resources  = ARRAY_SIZE(imx_wdt_resources),
+	.resource       = imx_wdt_resources,
+};
+
+static int __init mx3_devices_init(void)
 {
 	if (cpu_is_mx31()) {
 		mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
 		mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
+		imx_wdt_resources[0].start = MX31_WDOG_BASE_ADDR;
+		imx_wdt_resources[0].end = MX31_WDOG_BASE_ADDR + 0x3fff;
 		mxc_register_device(&mxc_rnga_device, NULL);
 	}
 	if (cpu_is_mx35()) {
@@ -597,6 +612,8 @@ static int mx3_devices_init(void)
 		imx_ssi_resources0[1].end = MX35_INT_SSI1;
 		imx_ssi_resources1[1].start = MX35_INT_SSI2;
 		imx_ssi_resources1[1].end = MX35_INT_SSI2;
+		imx_wdt_resources[0].start = MX35_WDOG_BASE_ADDR;
+		imx_wdt_resources[0].end = MX35_WDOG_BASE_ADDR + 0x3fff;
 	}
 
 	return 0;
arch/arm/mach-mx3/devices.h +2 -1
index 42cf175..4f77eb5 100644
@@ -25,4 +25,5 @@ extern struct platform_device mxc_spi_device1;
 extern struct platform_device mxc_spi_device2;
 extern struct platform_device imx_ssi_device0;
 extern struct platform_device imx_ssi_device1;
-
+extern struct platform_device imx_ssi_device1;
+extern struct platform_device imx_wdt_device0;
Signature · 1 line
1.6.6.1
maintainer
#2 lore raw

PATCH 2/3 imx3: Add watchdog platform device support

Quoted 2 lines · Vladimir Zapolskiy

This patch adds support for build-in watchdog device found on Freescale imx31 and imx35 SoCs.

Added to mxc-master.

Sascha

Quoted 65 lines
Cc Sascha Hauer <[email protected]>
Cc Uwe Kleine-K?nig <[email protected]>
---
 arch/arm/mach-mx3/devices.c |   19 ++++++++++++++++++-
 arch/arm/mach-mx3/devices.h |    3 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)
arch/arm/mach-mx3/devices.c +18 -1
index 6adb586..f891115 100644
@@ -575,11 +575,26 @@ struct platform_device imx_ssi_device1 = {
 	.resource = imx_ssi_resources1,
 };
 
-static int mx3_devices_init(void)
+static struct resource imx_wdt_resources[] = {
+	{
+		.flags = IORESOURCE_MEM,
+	},
+};
+
+struct platform_device imx_wdt_device0 = {
+	.name           = "imx-wdt",
+	.id             = 0,
+	.num_resources  = ARRAY_SIZE(imx_wdt_resources),
+	.resource       = imx_wdt_resources,
+};
+
+static int __init mx3_devices_init(void)
 {
 	if (cpu_is_mx31()) {
 		mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
 		mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
+		imx_wdt_resources[0].start = MX31_WDOG_BASE_ADDR;
+		imx_wdt_resources[0].end = MX31_WDOG_BASE_ADDR + 0x3fff;
 		mxc_register_device(&mxc_rnga_device, NULL);
 	}
 	if (cpu_is_mx35()) {
@@ -597,6 +612,8 @@ static int mx3_devices_init(void)
 		imx_ssi_resources0[1].end = MX35_INT_SSI1;
 		imx_ssi_resources1[1].start = MX35_INT_SSI2;
 		imx_ssi_resources1[1].end = MX35_INT_SSI2;
+		imx_wdt_resources[0].start = MX35_WDOG_BASE_ADDR;
+		imx_wdt_resources[0].end = MX35_WDOG_BASE_ADDR + 0x3fff;
 	}
 
 	return 0;
arch/arm/mach-mx3/devices.h +2 -1
index 42cf175..4f77eb5 100644
@@ -25,4 +25,5 @@ extern struct platform_device mxc_spi_device1;
 extern struct platform_device mxc_spi_device2;
 extern struct platform_device imx_ssi_device0;
 extern struct platform_device imx_ssi_device1;
-
+extern struct platform_device imx_ssi_device1;
+extern struct platform_device imx_wdt_device0;
Signature · 1 line
1.6.6.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#3 lore raw

PATCH 3/3 imx31: add watchdog device on litekit board.

In reply to Vladimir Zapolskiy

This patch adds support for SoC build-in watchdog device on litekit board.

Cc Uwe Kleine-K?nig <[email protected]>
Cc Sascha Hauer <[email protected]>
---
 arch/arm/mach-mx3/mx31lite-db.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-mx3/mx31lite-db.c +1 -0
index ccd8742..0201683 100644
@@ -206,5 +206,6 @@ void __init mx31lite_db_init(void)
 	mxc_register_device(&mxcsdhc_device0, &mmc_pdata);
 	mxc_register_device(&mxc_spi_device0, &spi0_pdata);
 	platform_device_register(&litekit_led_device);
+	mxc_register_device(&imx_wdt_device0, NULL);
 }
 
Signature · 1 line
1.6.6.1
maintainer
#4 lore raw

PATCH 3/3 imx31: add watchdog device on litekit board.

Quoted 2 lines · Vladimir Zapolskiy

This patch adds support for SoC build-in watchdog device on litekit board.

Added to mxc-master.

Sascha

Quoted 23 lines
Cc Uwe Kleine-K?nig <[email protected]>
Cc Sascha Hauer <[email protected]>
---
 arch/arm/mach-mx3/mx31lite-db.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-mx3/mx31lite-db.c +1 -0
index ccd8742..0201683 100644
@@ -206,5 +206,6 @@ void __init mx31lite_db_init(void)
 	mxc_register_device(&mxcsdhc_device0, &mmc_pdata);
 	mxc_register_device(&mxc_spi_device0, &spi0_pdata);
 	platform_device_register(&litekit_led_device);
+	mxc_register_device(&imx_wdt_device0, NULL);
 }
 
Signature · 1 line
1.6.6.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#5 lore raw

PATCH 1/3 watchdog: Add support for the Freescale MXC watchdog

In reply to Vladimir Zapolskiy
Quoted 1 line · Vladimir Zapolskiy

Add driver for the Freescale MXC SoCs built-in watchdog.

Any improvements over/differences to this one?

http://article.gmane.org/gmane.linux.ports.arm.kernel/70753

(Read the thread for the comments I received)

Coincidence, I wanted to pick up my version and finish it next week. We have to agree how to continue. I like mine a tad better (there are some mixups of MX1/2+ capabilities in yours, e.g. SETTIMEOUT) and it also got review already, but of course I am biased ;) What do you suggest?

Regards,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100320/dddf8ec8/attachment.sig>
#6 lore raw

PATCH 1/3 watchdog: Add support for the Freescale MXC watchdog

Quoted 9 lines · Wolfram Sang
Quoted 1 line · Vladimir Zapolskiy

Add driver for the Freescale MXC SoCs built-in watchdog.

Any improvements over/differences to this one?

http://article.gmane.org/gmane.linux.ports.arm.kernel/70753

(Read the thread for the comments I received)

Quoted 8 lines

Coincidence, I wanted to pick up my version and finish it next week. We have to agree how to continue. I like mine a tad better (there are some mixups of MX1/2+ capabilities in yours, e.g. SETTIMEOUT) and it also got review already, but of course I am biased ;) What do you suggest?

Regards,

Wolfram

Hi Wolfram,

that's a surprise for me, haven't noticed your version of the driver in the maillist, and wrote one more watchdog driver :)

The driver is extremely simple, so from my biased position only minor benefits can be found in my version:
* introduced spinlock to protect concurrent write to registers
* SETTIMEOUT option is present and it works well on imx31
* correct zero byte write()
* clock enabled only when watchdog node is opened
* dynamic wdt structure, which potentially simplifies future support of several watchdogs found on imx51 and imx37 IIRC
* no critical message on close with unset NOWAYOUT on non-imx1 SoCs

Your pretty good version supports imx1, and I cann't test my version on imx1, because I don't have such hardware on hand.

Obviously better to update your reviewed one, and I hope some comments or even updates from my side could be accepted by you :)

With best wishes,
Vladimir

#7 lore raw

PATCH 1/3 watchdog: Add support for the Freescale MXC watchdog

Hi Vladimir,

Quoted 10 lines · Vladimir Zapolskiy

The driver is extremely simple, so from my biased position only minor benefits can be found in my version:
* introduced spinlock to protect concurrent write to registers
* SETTIMEOUT option is present and it works well on imx31
* correct zero byte write()
* clock enabled only when watchdog node is opened
* dynamic wdt structure, which potentially simplifies future support of several watchdogs found on imx51 and imx37 IIRC
* no critical message on close with unset NOWAYOUT on non-imx1 SoCs

Quoted 5 lines

Your pretty good version supports imx1, and I cann't test my version on imx1, because I don't have such hardware on hand.

Obviously better to update your reviewed one, and I hope some comments or even updates from my side could be accepted by you :)

Thanks for agreeing on the procedure and pointing out the benefits of your driver. I will surely have a look at them and don't be surprised if you will find this or that incorporated ;) I haven't really started yet, so I might be missing something: What races do you want to protect against with the spinlock? The ping?

Regards,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100321/56fe7884/attachment.sig>
#8 lore raw

PATCH 1/3 watchdog: Add support for the Freescale MXC watchdog

Wolfram Sang <[email protected]> writes:

Hi,

Quoted 17 lines

Hi Vladimir,

Quoted 13 lines · Vladimir Zapolskiy

The driver is extremely simple, so from my biased position only minor benefits can be found in my version:
* introduced spinlock to protect concurrent write to registers
* SETTIMEOUT option is present and it works well on imx31
* correct zero byte write()
* clock enabled only when watchdog node is opened
* dynamic wdt structure, which potentially simplifies future support of several watchdogs found on imx51 and imx37 IIRC
* no critical message on close with unset NOWAYOUT on non-imx1 SoCs

Your pretty good version supports imx1, and I cann't test my version on imx1, because I don't have such hardware on hand.

Quoted 9 lines
Quoted 2 lines

Obviously better to update your reviewed one, and I hope some comments or even updates from my side could be accepted by you :)

Thanks for agreeing on the procedure and pointing out the benefits of your driver. I will surely have a look at them and don't be surprised if you will find this or that incorporated ;) I haven't really started yet, so I might be missing something: What races do you want to protect against with the spinlock? The ping?

locking was added in analogy with other watchdog drivers. Just checked imx1, imx3 and imx5 reference manuals, for all chips "any number of instructions can be executed between two writes" to WSR. I understand this that only ping/ping races can influence the watchdog, and that kind of race does not look harmful.

So the locking could be omitted.

With best wishes,
Vladimir

#9 lore raw

PATCH 1/3 watchdog: Add support for the Freescale MXC watchdog

In reply to Vladimir Zapolskiy
Quoted 4 lines · Vladimir Zapolskiy
drivers/watchdog/mxc_wdt.c new file +4 -0
+/* The watchdog found on MXC chips cannot be disabled. */
+static int mxc_wdt_release(struct inode *inode, struct file *file)
+{
+        struct mxc_wdt *wdt = file->private_data;

drivers/watchdog/mxc_wdt.c line 160

Quoted 10 lines
drivers/watchdog/mxc_wdt.c new file +10 -0
+
+        /* disable the watchdog timer unless NOWAYOUT is defined. */
+#ifndef CONFIG_WATCHDOG_NOWAYOUT
+        mxc_wdt_disable(wdt);
+#else
+        printk(KERN_CRIT "MXC watchdog: unexpected close, timer will not stop\n");
+#endif
+        clear_bit(0, &wdt->status);
+
+        clk_disable(wdt->clk);

You're sure that disabling the watchdog clock won't disable the watchdog itself?

#10 lore raw

PATCH 1/3 watchdog: Add support for the Freescale MXC watchdog

Hi,
I have tested this on imx31, and unfortunately watchdog timeout expires even after clock disable. I would be happy to be mistaken about this to get rid of WATCHDOG_NOWAYOUT forced dependency for imx2, imx3 and imx5.

With best wishes,
Vladimir