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)
*/
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);
#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
#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
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 */
#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 */
#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*/
#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 */
#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>
#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>
# 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_ */
* 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;