Skip to contentSkip to conversation

Get watchdog reboot working on efika smartbook

PATCH New Arnaud Patard (Rtp) 4 participants 7 messages Mar 2, 2011 – Mar 3, 2011

lore
Share & tools
lore
#0 lore raw

v2 cover Get watchdog reboot working on efika smartbook

Hi,

With current patches in Sascha Hauer's tree, the efika smartbook is powering off when rebooting. The cause of this bug is the default behaviour of the mc13892 pmic. This patchset allows to configure the mc13892 to reboot the system as expected by imx system.c throught platform_data and enables the watchdog on the efika mx/sb systems.

Arnaud

v2:
- make the mc13892 behaviour configurable
- modify main mc13xxx driver instead of mc13892 regulator
- reorder Kconfig entry.

#2 lore raw

PATCH v2 1/2 mc13892: reboot on wdi event

Hello Arnaud,

include/linux/mfd/mc13xxx.h

Quoted 52 lines · Arnaud Patard

By default, on wdi (watchdog input) event the mc13892 is powering off. This patch allows to change this behaviour throught platform_data.

v2:
- move to mc13xxx-core
- make it configurable

Index: linux-2.6-submit/drivers/mfd/mc13xxx-core.c
===================================================================

drivers/mfd/mc13xxx-core.c +13 -0
@@ -136,6 +136,9 @@
 #define MC13XXX_REVISION_FAB		(0x03 << 11)
 #define MC13XXX_REVISION_ICIDCODE	(0x3f << 13)
 
+#define MC13892_POWERCTL2		15
+#define MC13892_POWERCTL2_WDIRESET	(1<<12)
+
 #define MC13783_ADC1		44
 #define MC13783_ADC1_ADEN		(1 << 0)
 #define MC13783_ADC1_RAND		(1 << 1)
@@ -715,6 +718,7 @@
 	struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev);
 	enum mc13xxx_id id;
 	int ret;
+	unsigned int val;
 
 	mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL);
 	if (!mc13xxx)
@@ -734,6 +738,15 @@
 	if (ret || id == MC13XXX_ID_INVALID)
 		goto err_revision;
 
+	if ((id == MC13XXX_ID_MC13892) && pdata->wdi_reboot) {
+		/* allows to reboot on wdi event */
+		ret = mc13xxx_reg_read(mc13xxx, MC13892_POWERCTL2, &val);
+		if (!ret) {
+			val |= MC13892_POWERCTL2_WDIRESET;
+			mc13xxx_reg_write(mc13xxx, MC13892_POWERCTL2, val);
+		}
+	}
+
 	/* mask all irqs */
 	ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK0, 0x00ffffff);
 	if (ret)

Index: linux-2.6-submit/include/linux/mfd/mc13xxx.h
===================================================================

include/linux/mfd/mc13xxx.h +0 -0
@@ -149,6 +149,8 @@

git diff provide some info about the context after the @@ hunk header. I consider this really useful. GNU diff is able to do this, too (option -p).

include/linux/mfd/mc13xxx.h line 153

Quoted 5 lines
include/linux/mfd/mc13xxx.h +2 -0
 	int num_regulators;
 	struct mc13xxx_regulator_init_data *regulators;
 	struct mc13xxx_leds_platform_data *leds;
+
+	unsigned int wdi_reboot;

there is already a member .flags. What about defining another bit for that?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#3 lore raw

PATCH v2 1/2 mc13892: reboot on wdi event

Uwe Kleine-K?nig <[email protected]> writes:

Hi,

Quoted 50 lines

Hello Arnaud,

Quoted 47 lines · Arnaud Patard

By default, on wdi (watchdog input) event the mc13892 is powering off. This patch allows to change this behaviour throught platform_data.

v2:
- move to mc13xxx-core
- make it configurable

Index: linux-2.6-submit/drivers/mfd/mc13xxx-core.c
===================================================================

drivers/mfd/mc13xxx-core.c +13 -0
@@ -136,6 +136,9 @@
 #define MC13XXX_REVISION_FAB		(0x03 << 11)
 #define MC13XXX_REVISION_ICIDCODE	(0x3f << 13)
 
+#define MC13892_POWERCTL2		15
+#define MC13892_POWERCTL2_WDIRESET	(1<<12)
+
 #define MC13783_ADC1		44
 #define MC13783_ADC1_ADEN		(1 << 0)
 #define MC13783_ADC1_RAND		(1 << 1)
@@ -715,6 +718,7 @@
 	struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev);
 	enum mc13xxx_id id;
 	int ret;
+	unsigned int val;
 
 	mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL);
 	if (!mc13xxx)
@@ -734,6 +738,15 @@
 	if (ret || id == MC13XXX_ID_INVALID)
 		goto err_revision;
 
+	if ((id == MC13XXX_ID_MC13892) && pdata->wdi_reboot) {
+		/* allows to reboot on wdi event */
+		ret = mc13xxx_reg_read(mc13xxx, MC13892_POWERCTL2, &val);
+		if (!ret) {
+			val |= MC13892_POWERCTL2_WDIRESET;
+			mc13xxx_reg_write(mc13xxx, MC13892_POWERCTL2, val);
+		}
+	}
+
 	/* mask all irqs */
 	ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK0, 0x00ffffff);
 	if (ret)
Quoted 9 lines

include/linux/mfd/mc13xxx.h

Quoted 5 lines

Index: linux-2.6-submit/include/linux/mfd/mc13xxx.h
===================================================================

include/linux/mfd/mc13xxx.h +0 -0
@@ -149,6 +149,8 @@

git diff provide some info about the context after the @@ hunk header. I consider this really useful. GNU diff is able to do this, too (option -p).

hmm... I forgot to configure quilt to do that. sorry.

Quoted 8 lines

include/linux/mfd/mc13xxx.h line 153

Quoted 5 lines
include/linux/mfd/mc13xxx.h +2 -0
 	int num_regulators;
 	struct mc13xxx_regulator_init_data *regulators;
 	struct mc13xxx_leds_platform_data *leds;
+
+	unsigned int wdi_reboot;

there is already a member .flags. What about defining another bit for that?

I thought that using the .flags member for that was kind of misusing it as for now, it's only used to enable or disable some mc13xxx sub device.

Arnaud

#4 lore raw

PATCH v2 1/2 mc13892: reboot on wdi event

In reply to Arnaud Patard (Rtp)

Hello.

Quoted 2 lines · Arnaud Patard (Rtp)

By default, on wdi (watchdog input) event the mc13892 is powering off. This patch allows to change this behaviour throught platform_data.

Er, for some reason, this patch was in attachment...

Quoted 11 lines

v2:
- move to mc13xxx-core
- make it configurable

Index: linux-2.6-submit/drivers/mfd/mc13xxx-core.c
===================================================================

drivers/mfd/mc13xxx-core.c line 140

Quoted 5 lines
drivers/mfd/mc13xxx-core.c +2 -0
@@ -136,6 +136,9 @@
  #define MC13XXX_REVISION_FAB		(0x03 << 11)
  #define MC13XXX_REVISION_ICIDCODE	(0x3f << 13)
 
+#define MC13892_POWERCTL2		15
+#define MC13892_POWERCTL2_WDIRESET	(1<<12)

Please add spaces around << to@least be consistent with the code above
and below.

Quoted 4 lines
drivers/mfd/mc13xxx-core.c +1 -0
+
  #define MC13783_ADC1		44
  #define MC13783_ADC1_ADEN		(1 << 0)
  #define MC13783_ADC1_RAND		(1 << 1)

[...]

drivers/mfd/mc13xxx-core.c line 741

Quoted 5 lines
drivers/mfd/mc13xxx-core.c +1 -0
@@ -734,6 +738,15 @@
  	if (ret || id == MC13XXX_ID_INVALID)
  		goto err_revision;
 
+	if ((id == MC13XXX_ID_MC13892) && pdata->wdi_reboot) {
    Parens around == not necessary.

WBR, Sergei

#6 lore raw

PATCH v2 2/2 efika mx/sb: enable watchdog

Arnaud,

Quoted 1 line · Arnaud Patard

Register watchdog for efika mx and sb systems.

I promised myself to keep a better eye on patches I can't take because they have dependencies to other subsystems. This patch is one of those as it depends on the wdi_reboot field in the platform data. Can you please resend this once the other patches have hit mainline?

Sascha

Quoted 42 lines

v2:
- reorder Kconfig entry
- set wdi_reboot in mc13xxx platform data

Index: linux-2.6-submit/arch/arm/mach-mx5/mx51_efika.c
===================================================================

arch/arm/mach-mx5/mx51_efika.c +2 -0
@@ -574,6 +574,7 @@
 	.flags = MC13XXX_USE_RTC | MC13XXX_USE_REGULATOR,
 	.num_regulators = ARRAY_SIZE(mx51_efika_regulators),
 	.regulators = mx51_efika_regulators,
+	.wdi_reboot = 1,
 };
 
 static struct spi_board_info mx51_efika_spi_board_info[] __initdata = {
@@ -611,6 +612,7 @@
 					ARRAY_SIZE(mx51efika_pads));
 	imx51_add_imx_uart(0, &uart_pdata);
 	mx51_efika_usb();
+	imx51_add_imx2_wdt(0, NULL);
 	imx51_add_sdhci_esdhc_imx(0, NULL);
 
 	/* FIXME: comes from original code. check this. */

Index: linux-2.6-submit/arch/arm/mach-mx5/Kconfig
===================================================================

arch/arm/mach-mx5/Kconfig +1 -0
@@ -116,6 +116,7 @@
 config MX51_EFIKA_COMMON
 	bool
 	select SOC_IMX51
+	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
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 |