summaryrefslogtreecommitdiff
path: root/board/eNET
diff options
context:
space:
mode:
authorGraeme Russ <graeme.russ@gmail.com>2010-04-24 00:05:58 +1000
committerWolfgang Denk <wd@denx.de>2010-05-06 00:20:04 +0200
commit880c59e5add3681bd4dca14d2fd20152bee7ad14 (patch)
treed75ea0db9107aab9398f3a40d65ac1de32896fbd /board/eNET
parentf2a55055e9b19f3eba9de97ff454cf8bfef25468 (diff)
downloadu-boot-imx-880c59e5add3681bd4dca14d2fd20152bee7ad14.zip
u-boot-imx-880c59e5add3681bd4dca14d2fd20152bee7ad14.tar.gz
u-boot-imx-880c59e5add3681bd4dca14d2fd20152bee7ad14.tar.bz2
eNET: Implement eNET Watchdog
Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
Diffstat (limited to 'board/eNET')
-rw-r--r--board/eNET/eNET.c45
-rw-r--r--board/eNET/hardware.h1
2 files changed, 46 insertions, 0 deletions
diff --git a/board/eNET/eNET.c b/board/eNET/eNET.c
index ad71f7e..7f0e257 100644
--- a/board/eNET/eNET.c
+++ b/board/eNET/eNET.c
@@ -45,6 +45,9 @@ DECLARE_GLOBAL_DATA_PTR;
unsigned long monitor_flash_len = CONFIG_SYS_MONITOR_LEN;
+static void enet_timer_isr(void);
+static void enet_toggle_run_led(void);
+
void init_sc520_enet (void)
{
/* Set CPU Speed to 100MHz */
@@ -160,6 +163,10 @@ int last_stage_init(void)
major = minor = 0;
+ outb(0x00, LED_LATCH_ADDRESS);
+
+ register_timer_isr (enet_timer_isr);
+
printf("Serck Controls eNET\n");
return 0;
@@ -218,3 +225,41 @@ void setup_pcat_compatibility()
writeb(SC520_IRQ_DISABLED, &sc520_mmcr->wpvmap);
writeb(SC520_IRQ_DISABLED, &sc520_mmcr->icemap);
}
+
+void enet_timer_isr(void)
+{
+ static long enet_ticks = 0;
+
+ enet_ticks++;
+
+ /* Toggle Watchdog every 100ms */
+ if ((enet_ticks % 100) == 0)
+ hw_watchdog_reset();
+
+ /* Toggle Run LED every 500ms */
+ if ((enet_ticks % 500) == 0)
+ enet_toggle_run_led();
+}
+
+void hw_watchdog_reset(void)
+{
+ /* Watchdog Reset must be atomic */
+ long flag = disable_interrupts();
+
+ if (sc520_mmcr->piodata15_0 & WATCHDOG_PIO_BIT)
+ sc520_mmcr->pioclr15_0 = WATCHDOG_PIO_BIT;
+ else
+ sc520_mmcr->pioset15_0 = WATCHDOG_PIO_BIT;
+
+ if (flag)
+ enable_interrupts();
+}
+
+void enet_toggle_run_led(void)
+{
+ unsigned char leds_state= inb(LED_LATCH_ADDRESS);
+ if (leds_state & LED_RUN_BITMASK)
+ outb(leds_state &~ LED_RUN_BITMASK, LED_LATCH_ADDRESS);
+ else
+ outb(leds_state | LED_RUN_BITMASK, LED_LATCH_ADDRESS);
+}
diff --git a/board/eNET/hardware.h b/board/eNET/hardware.h
index 42474a6..dec2cd8 100644
--- a/board/eNET/hardware.h
+++ b/board/eNET/hardware.h
@@ -31,5 +31,6 @@
#define LED_RX_BITMASK 0x08
#define LED_TX_BITMASK 0x10
#define LED_ERR_BITMASK 0x20
+#define WATCHDOG_PIO_BIT 0x8000
#endif /* HARDWARE_H_ */