#include <commproc.h>
#include <i2c.h>
#include <command.h>
-#include <cmd_bsp.h>
#include <malloc.h>
#include <post.h>
/*------------------------ Local prototypes ---------------------------*/
static long int dram_size (long int, long int *, long int);
+static void kbd_init (void);
+static int compare_magic (uchar *kbd_data, uchar *str);
/*--------------------- Local macros and constants --------------------*/
#define _NOT_USED_ 0xFFFFFFFF
+#ifdef CONFIG_MODEM_SUPPORT
+static int key_pressed(void);
+extern void disable_putc(void);
+#endif /* CONFIG_MODEM_SUPPORT */
+
/*
* 66 MHz SDRAM access using UPM A
*/
/*
* SDRAM Initialization (offset 5 in UPM RAM)
*
- * This is no UPM entry point. The following definition uses
- * the remaining space to establish an initialization
- * sequence, which is executed by a RUN command.
+ * This is no UPM entry point. The following definition uses
+ * the remaining space to establish an initialization
+ * sequence, which is executed by a RUN command.
*
*/
0x1FF5FC34, 0xEFEABC34, 0x1FB57C35, /* last */
/*
* SDRAM Initialization (offset 5 in UPM RAM)
*
- * This is no UPM entry point. The following definition uses
- * the remaining space to establish an initialization
- * sequence, which is executed by a RUN command.
+ * This is no UPM entry point. The following definition uses
+ * the remaining space to establish an initialization
+ * sequence, which is executed by a RUN command.
*
*/
0x1FF5FC34, 0xEFEABC34, 0x1FB57C35, /* last */
*/
0x0E2DBC04, 0x10AF7C04, 0xF0AFFC00, 0xF0AFFC00,
0xF1AFFC00, 0xEFBAFC00, 0x1FF5FC47, /* last */
- _NOT_USED_,
+ _NOT_USED_,
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
/*
*/
0x0E29BC04, 0x10A77C00, 0xF0AFFC00, 0xF0AFFC00,
0xE1BAFC04, 0x1FF5FC47, /* last */
- _NOT_USED_, _NOT_USED_,
+ _NOT_USED_, _NOT_USED_,
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
/*
***********************************************************************/
int checkboard (void)
{
- puts ("Board: Litronic Monitor IV\n");
+ puts ("Board: LICCON Konsole LCD2\n");
return (0);
}
udelay (1); /* 0x80006106 */
memctl->memc_mcr = MCR_OP_RUN | MCR_MB_CS3 | MCR_MLCF (1) | MCR_MAD (0x06);
- memctl->memc_mamr |= MAMR_PTBE; /* refresh enabled */
+ memctl->memc_mamr |= MAMR_PTAE; /* refresh enabled */
udelay (200);
if (size8 < size9) { /* leave configuration at 9 columns */
size_b0 = size9;
- memctl->memc_mamr = CFG_MAMR_9COL | MAMR_PTBE;
+ memctl->memc_mamr = CFG_MAMR_9COL | MAMR_PTAE;
udelay (500);
} else { /* back to 8 columns */
size_b0 = size8;
- memctl->memc_mamr = CFG_MAMR_8COL | MAMR_PTBE;
+ memctl->memc_mamr = CFG_MAMR_8COL | MAMR_PTAE;
udelay (500);
}
{
volatile immap_t *immr = (immap_t *) CFG_IMMR;
volatile memctl8xx_t *memctl = &immr->im_memctl;
- volatile long int *addr;
- ulong cnt, val;
- ulong save[32]; /* to make test non-destructive */
- unsigned char i = 0;
memctl->memc_mamr = mamr_value;
- for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) {
- addr = base + cnt; /* pointer arith! */
-
- save[i++] = *addr;
- *addr = ~cnt;
- }
-
- /* write 0 to base address */
- addr = base;
- save[i] = *addr;
- *addr = 0;
-
- /* check at base address */
- if ((val = *addr) != 0) {
- *addr = save[i];
- return (0);
- }
-
- for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) {
- addr = base + cnt; /* pointer arith! */
-
- val = *addr;
- *addr = save[--i];
-
- if (val != (~cnt)) {
- return (cnt * sizeof (long));
- }
- }
- return (maxsize);
+ return (get_ram_size(base, maxsize));
}
/* ------------------------------------------------------------------------- */
#endif
/***********************************************************************
-F* Function: int board_pre_init (void) P*A*Z*
+F* Function: int board_early_init_f (void) P*A*Z*
*
P* Parameters: none
P*
P* Returnvalue: int
P* - 0 is always returned.
*
-Z* Intention: This function is the board_pre_init() method implementation
+Z* Intention: This function is the board_early_init_f() method implementation
Z* for the lwmon board.
Z* Disable Ethernet TENA on Port B.
*
C* Coding: wd@denx.de
V* Verification: dzu@denx.de
***********************************************************************/
-int board_pre_init (void)
+int board_early_init_f (void)
{
volatile immap_t *immr = (immap_t *) CFG_IMMR;
immr->im_cpm.cp_pbodr &= ~PB_ENET_TENA;
immr->im_cpm.cp_pbdat &= ~PB_ENET_TENA; /* set to 0 = disabled */
immr->im_cpm.cp_pbdir |= PB_ENET_TENA;
+
return (0);
}
#define KEYBD_SET_DEBUGMODE '#' /* Magic key to enable debug output */
/***********************************************************************
-F* Function: int misc_init_r (void) P*A*Z*
+F* Function: int board_postclk_init (void) P*A*Z*
*
P* Parameters: none
P*
P* Returnvalue: int
-P* - 0 is always returned, even in the case of a keyboard
-P* error.
+P* - 0 is always returned.
*
-Z* Intention: This function is the misc_init_r() method implementation
+Z* Intention: This function is the board_postclk_init() method implementation
Z* for the lwmon board.
-Z* The keyboard controller is initialized and the result
-Z* of a read copied to the environment variable "keybd".
-Z* If KEYBD_SET_DEBUGMODE is defined, a check is made for
-Z* this key, and if found display to the LCD will be enabled.
-Z* The keys in "keybd" are checked against the magic
-Z* keycommands defined in the environment.
-Z* See also key_match().
*
-D* Design: wd@denx.de
-C* Coding: wd@denx.de
-V* Verification: dzu@denx.de
***********************************************************************/
-int misc_init_r (void)
+int board_postclk_init (void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+
+ kbd_init();
+
+#ifdef CONFIG_MODEM_SUPPORT
+ if (key_pressed()) {
+ disable_putc(); /* modem doesn't understand banner etc */
+ gd->do_mdm_init = 1;
+ }
+#endif
+
+ return (0);
+}
+
+static void kbd_init (void)
{
+ DECLARE_GLOBAL_DATA_PTR;
+
uchar kbd_data[KEYBD_DATALEN];
uchar tmp_data[KEYBD_DATALEN];
- uchar keybd_env[2 * KEYBD_DATALEN + 1];
uchar val, errcd;
- uchar *str;
int i;
i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
+ gd->kbd_status = 0;
+
+ /* Forced by PIC. Delays <= 175us loose */
+ udelay(1000);
+
/* Read initial keyboard error code */
val = KEYBD_CMD_READ_STATUS;
i2c_write (kbd_addr, 0, 0, &val, 1);
/* clear "irrelevant" bits. Recommended by Martin Rajek, LWN */
errcd &= ~(KEYBD_STATUS_H_RESET|KEYBD_STATUS_BROWNOUT);
if (errcd) {
- printf ("KEYBD: Error %02X\n", errcd);
+ gd->kbd_status |= errcd << 8;
}
/* Reset error code and verify */
val = KEYBD_CMD_RESET_ERRORS;
val &= KEYBD_STATUS_MASK; /* clear unused bits */
if (val) { /* permanent error, report it */
- printf ("*** Keyboard error code %02X ***\n", val);
- sprintf (keybd_env, "%02X", val);
- setenv ("keybd", keybd_env);
- return 0;
+ gd->kbd_status |= val;
+ return;
}
- /*
- * Now we know that we have a working keyboard, so disable
- * all output to the LCD except when a key press is detected.
- */
-
- if ((console_assign (stdout, "serial") < 0) ||
- (console_assign (stderr, "serial") < 0)) {
- printf ("Can't assign serial port as output device\n");
- }
-
- /* Read Version */
- val = KEYBD_CMD_READ_VERSION;
- i2c_write (kbd_addr, 0, 0, &val, 1);
- i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_VERSIONLEN);
- printf ("KEYBD: Version %d.%d\n", kbd_data[0], kbd_data[1]);
-
/*
* Read current keyboard state.
*
- * After the error reset it may take some time before the
- * keyboard PIC picks up a valid keyboard scan - the total
- * scan time is approx. 1.6 ms (information by Martin Rajek,
- * 28 Sep 2002). We read a couple of times for the keyboard
- * to stabilize, using a big enough delay.
- * 10 times should be enough. If the data is still changing,
- * we use what we get :-(
+ * After the error reset it may take some time before the
+ * keyboard PIC picks up a valid keyboard scan - the total
+ * scan time is approx. 1.6 ms (information by Martin Rajek,
+ * 28 Sep 2002). We read a couple of times for the keyboard
+ * to stabilize, using a big enough delay.
+ * 10 times should be enough. If the data is still changing,
+ * we use what we get :-(
*/
memset (tmp_data, 0xFF, KEYBD_DATALEN); /* impossible value */
memcpy (tmp_data, kbd_data, KEYBD_DATALEN);
udelay (5000);
}
+}
+
+/***********************************************************************
+F* Function: int misc_init_r (void) P*A*Z*
+ *
+P* Parameters: none
+P*
+P* Returnvalue: int
+P* - 0 is always returned, even in the case of a keyboard
+P* error.
+ *
+Z* Intention: This function is the misc_init_r() method implementation
+Z* for the lwmon board.
+Z* The keyboard controller is initialized and the result
+Z* of a read copied to the environment variable "keybd".
+Z* If KEYBD_SET_DEBUGMODE is defined, a check is made for
+Z* this key, and if found display to the LCD will be enabled.
+Z* The keys in "keybd" are checked against the magic
+Z* keycommands defined in the environment.
+Z* See also key_match().
+ *
+D* Design: wd@denx.de
+C* Coding: wd@denx.de
+V* Verification: dzu@denx.de
+ ***********************************************************************/
+int misc_init_r (void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+
+ uchar kbd_data[KEYBD_DATALEN];
+ uchar keybd_env[2 * KEYBD_DATALEN + 1];
+ uchar kbd_init_status = gd->kbd_status >> 8;
+ uchar kbd_status = gd->kbd_status;
+ uchar val;
+ uchar *str;
+ int i;
+
+ if (kbd_init_status) {
+ printf ("KEYBD: Error %02X\n", kbd_init_status);
+ }
+ if (kbd_status) { /* permanent error, report it */
+ printf ("*** Keyboard error code %02X ***\n", kbd_status);
+ sprintf (keybd_env, "%02X", kbd_status);
+ setenv ("keybd", keybd_env);
+ return 0;
+ }
+
+ /*
+ * Now we know that we have a working keyboard, so disable
+ * all output to the LCD except when a key press is detected.
+ */
+
+ if ((console_assign (stdout, "serial") < 0) ||
+ (console_assign (stderr, "serial") < 0)) {
+ printf ("Can't assign serial port as output device\n");
+ }
+
+ /* Read Version */
+ val = KEYBD_CMD_READ_VERSION;
+ i2c_write (kbd_addr, 0, 0, &val, 1);
+ i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_VERSIONLEN);
+ printf ("KEYBD: Version %d.%d\n", kbd_data[0], kbd_data[1]);
+
+ /* Read current keyboard state */
+ val = KEYBD_CMD_READ_KEYS;
+ i2c_write (kbd_addr, 0, 0, &val, 1);
+ i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN);
for (i = 0; i < KEYBD_DATALEN; ++i) {
sprintf (keybd_env + i + i, "%02X", kbd_data[i]);
static uchar kbd_magic_prefix[] = "key_magic";
static uchar kbd_command_prefix[] = "key_cmd";
+static int compare_magic (uchar *kbd_data, uchar *str)
+{
+ uchar compare[KEYBD_DATALEN-1];
+ uchar *nxt;
+ int i;
+
+ /* Don't include modifier byte */
+ memcpy (compare, kbd_data+1, KEYBD_DATALEN-1);
+
+ for (; str != NULL; str = (*nxt) ? nxt+1 : nxt) {
+ uchar c;
+ int k;
+
+ c = (uchar) simple_strtoul (str, (char **) (&nxt), 16);
+
+ if (str == nxt) { /* invalid character */
+ break;
+ }
+
+ /*
+ * Check if this key matches the input.
+ * Set matches to zero, so they match only once
+ * and we can find duplicates or extra keys
+ */
+ for (k = 0; k < sizeof(compare); ++k) {
+ if (compare[k] == '\0') /* only non-zero entries */
+ continue;
+ if (c == compare[k]) { /* found matching key */
+ compare[k] = '\0';
+ break;
+ }
+ }
+ if (k == sizeof(compare)) {
+ return -1; /* unmatched key */
+ }
+ }
+
+ /*
+ * A full match leaves no keys in the `compare' array,
+ */
+ for (i = 0; i < sizeof(compare); ++i) {
+ if (compare[i])
+ {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
/***********************************************************************
F* Function: static uchar *key_match (uchar *kbd_data) P*A*Z*
*
***********************************************************************/
static uchar *key_match (uchar *kbd_data)
{
- uchar compare[KEYBD_DATALEN-1];
uchar magic[sizeof (kbd_magic_prefix) + 1];
- uchar extra;
- uchar *str, *nxt, *suffix;
+ uchar *suffix;
uchar *kbd_magic_keys;
- int i;
/*
* The following string defines the characters that can pe appended
#if 0
printf ("### Check magic \"%s\"\n", magic);
#endif
- /* Don't include modifier byte */
- memcpy (compare, kbd_data+1, KEYBD_DATALEN-1);
-
- extra = 0;
-
- for (str= getenv(magic); str != NULL; str = (*nxt) ? nxt+1 : nxt) {
- uchar c;
- int k;
-
- c = (uchar) simple_strtoul (str, (char **) (&nxt), 16);
-
- if (str == nxt) { /* invalid character */
- break;
- }
-
- /*
- * Check if this key matches the input.
- * Set matches to zero, so they match only once
- * and we can find duplicates or extra keys
- */
- for (k = 0; k < sizeof(compare); ++k) {
- if (compare[k] == '\0') /* only non-zero entries */
- continue;
- if (c == compare[k]) { /* found matching key */
- compare[k] = '\0';
- break;
- }
- }
- if (k == sizeof(compare)) {
- extra = 1; /* unmatched key */
- }
- }
-
- /*
- * A full match leaves no keys in the `compare' array,
- * and has no extra keys
- */
-
- for (i = 0; i < sizeof(compare); ++i) {
- if (compare[i])
- break;
- }
-
- if ((i == sizeof(compare)) && (extra == 0)) {
+ if (compare_magic(kbd_data, getenv(magic)) == 0) {
uchar cmd_name[sizeof (kbd_command_prefix) + 1];
char *cmd;
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
+U_BOOT_CMD(
+ pic, 4, 1, do_pic,
+ "pic - read and write PIC registers\n",
+ "read reg - read PIC register `reg'\n"
+ "pic write reg val - write value `val' to PIC register `reg'\n"
+);
/***********************************************************************
F* Function: int do_kbd (cmd_tbl_t *cmdtp, int flag,
uchar val;
int i;
+#if 0 /* Done in kbd_init */
i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
+#endif
/* Read keys */
val = KEYBD_CMD_READ_KEYS;
return 0;
}
+U_BOOT_CMD(
+ kbd, 1, 1, do_kbd,
+ "kbd - read keyboard status\n",
+ NULL
+);
+
/* Read and set LSB switch */
#define CFG_PC_TXD1_ENA 0x0008 /* PC.12 */
return 1;
}
+U_BOOT_CMD(
+ lsb, 2, 1, do_lsb,
+ "lsb - check and set LSB switch\n",
+ "on - switch LSB on\n"
+ "lsb off - switch LSB off\n"
+ "lsb - print current setting\n"
+);
+
#endif /* CFG_CMD_BSP */
/*----------------------------- Utilities -----------------------------*/
while (1);
}
+
+#ifdef CONFIG_MODEM_SUPPORT
+static int key_pressed(void)
+{
+ uchar kbd_data[KEYBD_DATALEN];
+ uchar val;
+
+ /* Read keys */
+ val = KEYBD_CMD_READ_KEYS;
+ i2c_write (kbd_addr, 0, 0, &val, 1);
+ i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN);
+
+ return (compare_magic(kbd_data, CONFIG_MODEM_KEY_MAGIC) == 0);
+}
+#endif /* CONFIG_MODEM_SUPPORT */
+
+#ifdef CONFIG_POST
+/*
+ * Returns 1 if keys pressed to start the power-on long-running tests
+ * Called from board_init_f().
+ */
+int post_hotkeys_pressed(void)
+{
+ uchar kbd_data[KEYBD_DATALEN];
+ uchar val;
+
+ /* Read keys */
+ val = KEYBD_CMD_READ_KEYS;
+ i2c_write (kbd_addr, 0, 0, &val, 1);
+ i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN);
+
+ return (compare_magic(kbd_data, CONFIG_POST_KEY_MAGIC) == 0);
+}
+#endif