]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
Extension of status LED code for IVML24, IVMS8 (and other systems
authorwdenk <wdenk>
Thu, 8 Feb 2001 01:21:44 +0000 (01:21 +0000)
committerwdenk <wdenk>
Thu, 8 Feb 2001 01:21:44 +0000 (01:21 +0000)
with more than just one LED)

CHANGELOG
common/board.c
common/cmd_ide.c
cpu/mpc8xx/status_led.c
include/config_IVML24.h
include/config_IVMS8.h
include/config_TQM850L.h
include/config_TQM860L.h
include/status_led.h
net/bootp.c

index ae895647ee4c23fb81031a55d6752fa830a73b1f..4fd0ad3310c4d27904703d515f95a71f5dc2a5f7 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -61,6 +61,9 @@ To do:
 Modifications for 0.8.2:
 ======================================================================
 
+* extension of status LED code for IVML24, IVMS8 (and other systems
+  with more than just one LED)
+
 * If we power on the 12V disk drive voltage, we must allow for at
   least 500 ms for everything to stabilize and come up (IVML24)
 
index 1b6ab8291bfea8daac7947935b0ae38106e63882..654de3d945a1367f47efc00aecf201b6846742bb 100644 (file)
@@ -519,7 +519,7 @@ void    board_init_r  (bd_t *bd, ulong dest_addr)
      */
     interrupt_init (bd);
 #ifdef CONFIG_STATUS_LED
-    status_led_set (STATUS_LED_BLINKING);
+    status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
 #endif
 
     udelay(20);
index 774276f1386524a069c05ac06f07b5704039ce42..942b4ce7aa20b6768be75a4d89b2e04fd974ffc5 100644 (file)
@@ -39,6 +39,9 @@
 #include <cmd_disk.h>
 #include <cmd_pcmcia.h>
 #include <mpc8xx.h>
+#ifdef CONFIG_STATUS_LED
+#include <status_led.h>
+#endif
 
 /* stdlib.h causes some compatibility problems; should fixe these! -- wd */
 #ifndef __ldiv_t_defined
@@ -972,17 +975,15 @@ static void ide_reset (void)
 #endif /* CFG_PC_IDE_RESET */
 
 #ifdef CFG_PB_12V_ENABLE
-       immr->im_cpm.cp_pbdat |=   CFG_PB_12V_ENABLE;   /* 12V Enable output ON */
-       immr->im_cpm.cp_pbpar &= ~(CFG_PB_12V_ENABLE);
-       immr->im_cpm.cp_pbodr &= ~(CFG_PB_12V_ENABLE);
-       immr->im_cpm.cp_pbdir |=   CFG_PB_12V_ENABLE;
-
        /* We must wait at least 500 ms for the voltage to stabilize;
-        * this is an additional 250 ms to the 250 m,s we already wait below
         */
-       for (i=0; i<25; ++i) {
+       for (i=0; i<50; ++i) {
                udelay (10000);
        }
+       immr->im_cpm.cp_pbdat |=   CFG_PB_12V_ENABLE;   /* 12V Enable output ON */
+       immr->im_cpm.cp_pbpar &= ~(CFG_PB_12V_ENABLE);
+       immr->im_cpm.cp_pbodr &= ~(CFG_PB_12V_ENABLE);
+       immr->im_cpm.cp_pbdir |=   CFG_PB_12V_ENABLE;
 #endif /* CFG_PB_12V_ENABLE */
 
 #ifdef CFG_PB_IDE_MOTOR
@@ -991,6 +992,14 @@ static void ide_reset (void)
        immr->im_cpm.cp_pbdir &= ~(CFG_PB_IDE_MOTOR); /* input */
        if ((immr->im_cpm.cp_pbdat & CFG_PB_IDE_MOTOR) == 0) {
                printf ("\nWarning: 5V for IDE Motor missing\n");
+# ifdef CONFIG_STATUS_LED
+#  ifdef STATUS_LED_YELLOW
+               status_led_set  (STATUS_LED_YELLOW, STATUS_LED_ON );
+#  endif
+#  ifdef STATUS_LED_GREEN
+               status_led_set  (STATUS_LED_GREEN,  STATUS_LED_OFF);
+#  endif
+# endif        /* CONFIG_STATUS_LED */
        }
 #endif /* CFG_PB_IDE_MOTOR */
 
index 759fb097b5587c36f62b1a2562cbb4fca80eafb5..9ee741b581e86be741546e1cadc4a3295fc74cb2 100644 (file)
 
 #ifdef CONFIG_STATUS_LED
 
-static int status_led_state;
+typedef struct {
+       ulong   mask;
+       int     state;
+       int     period;
+       int     cnt;
+} led_dev_t;
+
+led_dev_t led_dev[] = {
+    {  STATUS_LED_BIT,
+       STATUS_LED_STATE,
+       STATUS_LED_PERIOD,
+       0,
+    },
+#if defined(STATUS_LED_BIT1)
+    {  STATUS_LED_BIT1,
+       STATUS_LED_STATE1,
+       STATUS_LED_PERIOD1,
+       0,
+    },
+#endif
+#if defined(STATUS_LED_BIT2)
+    {  STATUS_LED_BIT2,
+       STATUS_LED_STATE2,
+       STATUS_LED_PERIOD2,
+       0,
+    },
+#endif
+};
+
+#define MAX_LED_DEV    (sizeof(led_dev)/sizeof(led_dev_t))
+
 static int status_led_init_done = 0;
 
 static void status_led_init (void)
 {
     volatile immap_t *immr = (immap_t *)CFG_IMMR;
+    int i;
 
-    immr->STATUS_LED_PAR &= ~(STATUS_LED_BIT);
+    for (i=0; i<MAX_LED_DEV; ++i) {
+       led_dev_t *ld = &led_dev[i];
+
+       immr->STATUS_LED_PAR &= ~(ld->mask);
 #ifdef STATUS_LED_ODR
-    immr->STATUS_LED_ODR &= ~(STATUS_LED_BIT);
+       immr->STATUS_LED_ODR &= ~(ld->mask);
 #endif
-#if (STATUS_LED_ACTIVE == 0)                   /* start with LED off */
-    immr->STATUS_LED_DAT |=   STATUS_LED_BIT ;
+#if (STATUS_LED_ACTIVE == 0)
+       if (ld->state == STATUS_LED_ON)
+               immr->STATUS_LED_DAT &= ~(ld->mask);
+       else
+               immr->STATUS_LED_DAT |=   ld->mask ;
 #else
-    immr->STATUS_LED_DAT &= ~(STATUS_LED_BIT);
+       if (ld->state == STATUS_LED_ON)
+               immr->STATUS_LED_DAT |=   ld->mask ;
+       else
+               immr->STATUS_LED_DAT &= ~(ld->mask);
 #endif
-    immr->STATUS_LED_DIR |=   STATUS_LED_BIT ;
-    status_led_state     = STATUS_LED_BLINKING;
+       immr->STATUS_LED_DIR |=   ld->mask ;
+    }
+
     status_led_init_done  = 1;
 }
 
 void status_led_tick (ulong timestamp)
 {
     volatile immap_t *immr = (immap_t *)CFG_IMMR;
-
-    if (status_led_state != STATUS_LED_BLINKING)
-       return;
+    int i;
 
     if (!status_led_init_done)
        status_led_init();
 
-    if ((timestamp % STATUS_LED_PERIOD) == 0) {
-       immr->STATUS_LED_DAT ^= STATUS_LED_BIT;
+    for (i=0; i<MAX_LED_DEV; ++i) {
+       led_dev_t *ld = &led_dev[i];
+
+       if (ld->state != STATUS_LED_BLINKING)
+               continue;
+
+       if (++(ld->cnt) >= ld->period) {
+               immr->STATUS_LED_DAT ^= ld->mask;
+               ld->cnt -= ld->period;
+       }
     }
 }
 
-void status_led_set (int state)
+void status_led_set (int led, int state)
 {
     volatile immap_t *immr = (immap_t *)CFG_IMMR;
+    led_dev_t *ld;
+
+    if (led < 0 || led >= MAX_LED_DEV)
+       return;
 
     if (!status_led_init_done)
        status_led_init();
 
+    ld = &led_dev[led];
+
     switch (state) {
     default:
        return;
     case STATUS_LED_BLINKING:
-       break;
+       ld->cnt = 0;            /* always start with full period        */
+       /* fall through */      /* always start with LED _ON_           */
     case STATUS_LED_ON:
 #if (STATUS_LED_ACTIVE == 0)
-       immr->STATUS_LED_DAT &= ~(STATUS_LED_BIT);
+       immr->STATUS_LED_DAT &= ~(ld->mask);
 #else
-       immr->STATUS_LED_DAT |=   STATUS_LED_BIT ;
+       immr->STATUS_LED_DAT |=   ld->mask ;
 #endif
        break;
     case STATUS_LED_OFF:
 #if (STATUS_LED_ACTIVE == 0)
-       immr->STATUS_LED_DAT |=   STATUS_LED_BIT ;
+       immr->STATUS_LED_DAT |=   ld->mask ;
 #else
-       immr->STATUS_LED_DAT &= ~(STATUS_LED_BIT);
+       immr->STATUS_LED_DAT &= ~(ld->mask);
 #endif
        break;
     }
-    status_led_state = state;
+    ld->state = state;
 }
 
 #endif /* CONFIG_STATUS_LED */
index 6e573b717612086e6a55a6a5b8f313eda718c106..3a37720091b3e11b44edad79d8799c4567333472 100644 (file)
@@ -56,6 +56,8 @@
 
 #undef CONFIG_WATCHDOG                 /* watchdog disabled            */
 
+#define        CONFIG_STATUS_LED       1       /* Status LED enabled           */
+
 #define CONFIG_COMMANDS                (CONFIG_CMD_DFL | CFG_CMD_IDE)
 
 #define CONFIG_BOOTP_MASK \
  *-----------------------------------------------------------------------
  */
 #define CONFIG_IDE_PCMCIA      1       /* PCMCIA interface required    */
-#if 0
-#define CONFIG_IDE_LED         1       /* LED   for ide supported      */
-#endif
 #define CONFIG_IDE_RESET       1       /* reset for ide supported      */
 
 #define CFG_IDE_MAXBUS         1       /* The IVML24 has only 1 IDE bus*/
index 3fef731974dc693104926e7bdb5e4e00cdd0d64f..e3cb02d534c5cef0b6dc47e3a9f0b885179b3791 100644 (file)
@@ -56,6 +56,8 @@
 
 #undef CONFIG_WATCHDOG                 /* watchdog disabled            */
 
+#define        CONFIG_STATUS_LED       1       /* Status LED enabled           */
+
 #define CONFIG_COMMANDS                (CONFIG_CMD_DFL | CFG_CMD_IDE)
 
 #define CONFIG_BOOTP_MASK \
  *-----------------------------------------------------------------------
  */
 #define CONFIG_IDE_PCMCIA      1       /* PCMCIA interface required    */
-#if 0
-#define CONFIG_IDE_LED         1       /* LED   for ide supported      */
-#endif
 #define CONFIG_IDE_RESET       1       /* reset for ide supported      */
 
 #define CFG_IDE_MAXBUS         1       /* The IVMS8 has only 1 IDE bus */
index c029e44f056fc6a4266a0f2431c57defec544827..a534bcca5938b54f60d6da33c43843af8b94ba00 100644 (file)
 
 #undef CONFIG_WATCHDOG                 /* watchdog disabled            */
 
-#define        CONFIG_STATUS_LED       1       /* Status LED enabled           */
+//#define      CONFIG_STATUS_LED       1       /* Status LED enabled           */
 
 #define CONFIG_BOOTP_MASK      (CONFIG_BOOTP_DEFAULT | CONFIG_BOOTP_BOOTFILESIZE)
 
+#define CONFIG_COMMANDS        (CONFIG_CMD_DFL & ~CFG_CMD_CACHE)
+
 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <cmd_confdefs.h>
 
index be042c350ae011297671f6d44f62e4aeadfa25dd..0ea13ffc40cbe55774f99be5133e9fc03bdb554b 100644 (file)
@@ -62,6 +62,8 @@
 
 #define CONFIG_BOOTP_MASK      (CONFIG_BOOTP_DEFAULT | CONFIG_BOOTP_BOOTFILESIZE)
 
+#define CONFIG_COMMANDS        (CONFIG_CMD_DFL & ~CFG_CMD_CACHE)
+
 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <cmd_confdefs.h>
 
index bfd389cf0e0c01fdb492bc68002c456d7d5458e4..1df32ff1c6ef9e8399ccd1a83e28f65a6bf9fd49 100644 (file)
 # endif
 #endif
 
+#define STATUS_LED_OFF         0
+#define STATUS_LED_BLINKING    1
+#define STATUS_LED_ON          2
+
+void status_led_tick (unsigned long timestamp);
+void status_led_set  (int led, int state);
+
+/*****  TQM8xxL  ********************************************************/
 #if defined(CONFIG_TQM8xxL)
 # define STATUS_LED_PAR                im_cpm.cp_pbpar
 # define STATUS_LED_DIR                im_cpm.cp_pbdir
 # define STATUS_LED_DAT                im_cpm.cp_pbdat
 
 # define STATUS_LED_BIT                0x00000001
-# define STATUS_LED_ACTIVE     1               /* LED on for bit == 1 */
+# define STATUS_LED_PERIOD     (CFG_HZ / 2)
+# define STATUS_LED_STATE      STATUS_LED_BLINKING
 
-# define STATUS_LED_PERIOD     500
+# define STATUS_LED_ACTIVE     1               /* LED on for bit == 1  */
 
+# define STATUS_LED_BOOT       0               /* LED 0 used for boot status */
+
+/*****  ETX_094  ********************************************************/
 #elif defined(CONFIG_ETX094)
 
 # define STATUS_LED_PAR                im_ioport.iop_pdpar
 # define STATUS_LED_DAT                im_ioport.iop_pddat
 
 # define STATUS_LED_BIT                0x00000001
-# define STATUS_LED_ACTIVE     0               /* LED on for bit == 0 */
+# define STATUS_LED_PERIOD     (CFG_HZ / 2)
+# define STATUS_LED_STATE      STATUS_LED_BLINKING
+
+# define STATUS_LED_ACTIVE     0               /* LED on for bit == 0  */
+
+# define STATUS_LED_BOOT       0               /* LED 0 used for boot status */
+
+/*****  IVMS8  **********************************************************/
+#elif defined(CONFIG_IVMS8)
+
+# define STATUS_LED_PAR                im_cpm.cp_pbpar
+# define STATUS_LED_DIR                im_cpm.cp_pbdir
+# define STATUS_LED_ODR                im_cpm.cp_pbodr
+# define STATUS_LED_DAT                im_cpm.cp_pbdat
+
+# define STATUS_LED_BIT                0x00000010      /* LED 0 is on PB.27    */
+# define STATUS_LED_PERIOD     (1 * CFG_HZ)
+# define STATUS_LED_STATE      STATUS_LED_OFF
+# define STATUS_LED_BIT1       0x00000020      /* LED 1 is on PB.26    */
+# define STATUS_LED_PERIOD1    (1 * CFG_HZ)
+# define STATUS_LED_STATE1     STATUS_LED_OFF
+# define STATUS_LED_BIT2       0x00000008      /* LED 2 is on PB.28    */
+/* IDE LED usable for other purposes, too */
+# define STATUS_LED_PERIOD2    (1 * CFG_HZ)
+# define STATUS_LED_STATE2     STATUS_LED_OFF
+
+# define STATUS_LED_ACTIVE     1               /* LED on for bit == 1  */
+
+# define STATUS_ILOCK_SWITCH   0x00800000      /* ILOCK switch in IRQ4 */ 
 
-# define STATUS_LED_PERIOD     500
+# define STATUS_ILOCK_PERIOD   (CFG_HZ / 10)   /* about every 100 ms   */ 
 
+# define STATUS_LED_YELLOW     0
+# define STATUS_LED_GREEN      1
+# define STATUS_LED_BOOT       2               /* IDE LED used for boot status */
+
+/*****  IVML24  *********************************************************/
+#elif defined(CONFIG_IVML24)
+
+# define STATUS_LED_PAR                im_cpm.cp_pbpar
+# define STATUS_LED_DIR                im_cpm.cp_pbdir
+# define STATUS_LED_ODR                im_cpm.cp_pbodr
+# define STATUS_LED_DAT                im_cpm.cp_pbdat
+
+# define STATUS_LED_BIT                0x00000010      /* LED 0 is on PB.27    */
+# define STATUS_LED_PERIOD     (1 * CFG_HZ)
+# define STATUS_LED_STATE      STATUS_LED_OFF
+# define STATUS_LED_BIT1       0x00000020      /* LED 1 is on PB.26    */
+# define STATUS_LED_PERIOD1    (1 * CFG_HZ)
+# define STATUS_LED_STATE1     STATUS_LED_OFF
+/* IDE LED usable for other purposes, too */
+# define STATUS_LED_BIT2       0x00000008      /* LED 2 is on PB.28    */
+# define STATUS_LED_PERIOD2    (1 * CFG_HZ)
+# define STATUS_LED_STATE2     STATUS_LED_OFF
+
+# define STATUS_LED_ACTIVE     1               /* LED on for bit == 1  */
+
+# define STATUS_ILOCK_SWITCH   0x00004000      /* ILOCK is on PB.17    */
+
+# define STATUS_ILOCK_PERIOD   (CFG_HZ / 10)   /* about every 100 ms   */ 
+
+# define STATUS_LED_YELLOW     0
+# define STATUS_LED_GREEN      1
+# define STATUS_LED_BOOT       2               /* IDE LED used for boot status */
+
+/************************************************************************/
 #else
 # error Status LED configuration missing
 #endif
+/************************************************************************/
 
-#define        STATUS_LED_OFF          0
-#define STATUS_LED_BLINKING    1
-#define STATUS_LED_ON          2
-
-void status_led_tick (unsigned long timestamp);
-void status_led_set  (int state);
-
-#endif /* CONFIG_STATUS_LED */
+#endif /* CONFIG_STATUS_LED    */
 
-#endif /* _STATUS_LED_H_ */
+#endif /* _STATUS_LED_H_       */
index ba83d7c1580059bf930ad9c752013a593e1d12ce..f67c49eb5b02791d1e8d408391603670292ea845 100644 (file)
@@ -204,7 +204,7 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
         *      Got a good BOOTP reply.  Copy the data into our variables.
         */
 #ifdef CONFIG_STATUS_LED
-       status_led_set (STATUS_LED_OFF);
+       status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
 #endif
        NetOurIP = bp->bp_yiaddr;
        NetServerIP = bp->bp_siaddr;