diff options
author | Wolfgang Denk <wd@pollux.denx.de> | 2005-08-30 13:04:12 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@pollux.denx.de> | 2005-08-30 13:04:12 +0200 |
commit | 9f96ae44c6ff7a441544584814078a6536ba6594 (patch) | |
tree | 42e86371522ce061b8c5c5112f18170fa7602c86 | |
parent | 7bc5ee0785a528962bffc586f7d447d79e2642b4 (diff) | |
download | u-boot-imx-9f96ae44c6ff7a441544584814078a6536ba6594.zip u-boot-imx-9f96ae44c6ff7a441544584814078a6536ba6594.tar.gz u-boot-imx-9f96ae44c6ff7a441544584814078a6536ba6594.tar.bz2 |
Add keyboard and dot matrix display support for HMI1001 board.
-rw-r--r-- | board/hmi1001/hmi1001.c | 118 | ||||
-rw-r--r-- | common/Makefile | 9 | ||||
-rw-r--r-- | common/cmd_display.c | 82 | ||||
-rw-r--r-- | include/cmd_confdefs.h | 3 | ||||
-rw-r--r-- | include/configs/hmi1001.h | 19 |
5 files changed, 224 insertions, 7 deletions
diff --git a/board/hmi1001/hmi1001.c b/board/hmi1001/hmi1001.c index fca11d0..6b1fbfd 100644 --- a/board/hmi1001/hmi1001.c +++ b/board/hmi1001/hmi1001.c @@ -156,8 +156,126 @@ int checkboard (void) return 0; } +#ifdef CONFIG_PREBOOT + +static uchar kbd_magic_prefix[] = "key_magic"; +static uchar kbd_command_prefix[] = "key_cmd"; + +#define S1_ROT 0xf0 +#define S2_Q 0x40 +#define S2_M 0x20 + +struct kbd_data_t { + char s1; + char s2; +}; + +struct kbd_data_t* get_keys (struct kbd_data_t *kbd_data) +{ + kbd_data->s1 = *((volatile uchar*)(CFG_STATUS1_BASE)); + kbd_data->s2 = *((volatile uchar*)(CFG_STATUS2_BASE)); + + return kbd_data; +} + +static int compare_magic (struct kbd_data_t *kbd_data, uchar *str) +{ + char s1 = str[0]; + char s2; + + if (s1 >= '0' && s1 <= '9') + s1 -= '0'; + else if (s1 >= 'a' && s1 <= 'f') + s1 = s1 - 'a' + 10; + else if (s1 >= 'A' && s1 <= 'F') + s1 = s1 - 'A' + 10; + else + return -1; + + if (((S1_ROT & kbd_data->s1) >> 4) != s1) + return -1; + + s2 = (S2_Q | S2_M) & kbd_data->s2; + + switch (str[1]) { + case 'q': + case 'Q': + if (s2 == S2_Q) + return -1; + break; + case 'm': + case 'M': + if (s2 == S2_M) + return -1; + break; + case '\0': + if (s2 == (S2_Q | S2_M)) + return 0; + default: + return -1; + } + + if (str[2]) + return -1; + + return 0; +} + +static uchar *key_match (const struct kbd_data_t *kbd_data) +{ + uchar magic[sizeof (kbd_magic_prefix) + 1]; + uchar *suffix; + uchar *kbd_magic_keys; + + /* + * The following string defines the characters that can be appended + * to "key_magic" to form the names of environment variables that + * hold "magic" key codes, i. e. such key codes that can cause + * pre-boot actions. If the string is empty (""), then only + * "key_magic" is checked (old behaviour); the string "125" causes + * checks for "key_magic1", "key_magic2" and "key_magic5", etc. + */ + if ((kbd_magic_keys = getenv ("magic_keys")) == NULL) + kbd_magic_keys = ""; + + /* loop over all magic keys; + * use '\0' suffix in case of empty string + */ + for (suffix = kbd_magic_keys; *suffix || + suffix == kbd_magic_keys; ++suffix) { + sprintf (magic, "%s%c", kbd_magic_prefix, *suffix); + + if (compare_magic(kbd_data, getenv(magic)) == 0) { + uchar cmd_name[sizeof (kbd_command_prefix) + 1]; + char *cmd; + + sprintf (cmd_name, "%s%c", kbd_command_prefix, *suffix); + cmd = getenv (cmd_name); + + return (cmd); + } + } + + return (NULL); +} + +#endif /* CONFIG_PREBOOT */ + int misc_init_f (void) { +} + +int misc_init_r (void) +{ +#ifdef CONFIG_PREBOOT + struct kbd_data_t kbd_data; + /* Decode keys */ + uchar *str = strdup (key_match (get_keys (&kbd_data))); + /* Set or delete definition */ + setenv ("preboot", str); + free (str); +#endif /* CONFIG_PREBOOT */ + return 0; } diff --git a/common/Makefile b/common/Makefile index 209e17d..b5396ce 100644 --- a/common/Makefile +++ b/common/Makefile @@ -31,7 +31,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o \ cmd_ace.o cmd_autoscript.o \ cmd_bdinfo.o cmd_bedbug.o cmd_bmp.o cmd_boot.o cmd_bootm.o \ cmd_cache.o cmd_console.o \ - cmd_date.o cmd_dcr.o cmd_diag.o cmd_doc.o cmd_dtt.o \ + cmd_date.o cmd_dcr.o cmd_diag.o cmd_display.o cmd_doc.o cmd_dtt.o \ cmd_eeprom.o cmd_elf.o cmd_ext2.o \ cmd_fat.o cmd_fdc.o cmd_fdos.o cmd_flash.o cmd_fpga.o \ cmd_i2c.o cmd_ide.o cmd_immap.o cmd_itest.o cmd_jffs2.o \ @@ -39,10 +39,13 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o \ cmd_mem.o cmd_mii.o cmd_misc.o cmd_mmc.o \ cmd_nand.o cmd_net.o cmd_nvedit.o \ cmd_pci.o cmd_pcmcia.o cmd_portio.o \ - cmd_reginfo.o cmd_reiser.o cmd_scsi.o cmd_spi.o cmd_universe.o cmd_usb.o cmd_vfd.o \ + cmd_reginfo.o cmd_reiser.o cmd_scsi.o cmd_spi.o cmd_universe.o \ + cmd_usb.o cmd_vfd.o \ command.o console.o devices.o dlmalloc.o docecc.o \ environment.o env_common.o \ - env_nand.o env_dataflash.o env_flash.o env_eeprom.o env_nvram.o env_nowhere.o exports.o \ + env_nand.o env_dataflash.o env_flash.o env_eeprom.o \ + env_nvram.o env_nowhere.o \ + exports.o \ flash.o fpga.o \ hush.o kgdb.o lcd.o lists.o lynxkdi.o \ memsize.o miiphybb.o miiphyutil.o \ diff --git a/common/cmd_display.c b/common/cmd_display.c new file mode 100644 index 0000000..abee844 --- /dev/null +++ b/common/cmd_display.c @@ -0,0 +1,82 @@ +/* + * (C) Copyright 2005 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <command.h> + +#if (CONFIG_COMMANDS & CFG_CMD_DISPLAY) + +#undef DEBUG_DISP + +#define DISP_SIZE 8 +#define CWORD_CLEAR 0x80 +#define CLEAR_DELAY (110 * 2) + +int do_display (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int i; + int pos; + + /* Clear display */ + *((volatile char*)(CFG_DISP_CWORD)) = CWORD_CLEAR; + udelay(1000 * CLEAR_DELAY); + + if (argc < 2) + return (0); + + for (pos = 0, i = 1; i < argc && pos < DISP_SIZE; i++) { + char *p = argv[i], c; + + if (i > 1) { + *((volatile uchar *) (CFG_DISP_CHR_RAM + pos++)) = ' '; +#ifdef DEBUG_DISP + putc(' '); +#endif + } + + while ((c = *p++) != '\0' && pos < DISP_SIZE) { + *((volatile uchar *) (CFG_DISP_CHR_RAM + pos++)) = c; +#ifdef DEBUG_DISP + putc(c); +#endif + } + } + +#ifdef DEBUG_DISP + putc('\n'); +#endif + + return (0); +} + +/***************************************************/ + +U_BOOT_CMD( + display, CFG_MAXARGS, 1, do_display, + "display- display string on dot matrix display\n", + "[<string>]\n" + " - with <string> argument: display <string> on dot matrix display\n" + " - without arguments: clear dot matrix display\n" +); + +#endif /* CFG_CMD_DISPLAY */ diff --git a/include/cmd_confdefs.h b/include/cmd_confdefs.h index 7d62685..448b9d5 100644 --- a/include/cmd_confdefs.h +++ b/include/cmd_confdefs.h @@ -91,8 +91,9 @@ #define CFG_CMD_CDP 0x0200000000000000ULL /* Cisco Discovery Protocol */ #define CFG_CMD_XIMG 0x0400000000000000ULL /* Load part of Multi Image */ #define CFG_CMD_UNIVERSE 0x0800000000000000ULL /* Tundra Universe Support */ -#define CFG_CMD_EXT2 0x1000000000000000ULL /* EXT2 Support */ +#define CFG_CMD_EXT2 0x1000000000000000ULL /* EXT2 Support */ #define CFG_CMD_SNTP 0x2000000000000000ULL /* SNTP support */ +#define CFG_CMD_DISPLAY 0x4000000000000000ULL /* Display support */ #define CFG_CMD_ALL 0xFFFFFFFFFFFFFFFFULL /* ALL commands */ diff --git a/include/configs/hmi1001.h b/include/configs/hmi1001.h index 9da15ed..d79eafe 100644 --- a/include/configs/hmi1001.h +++ b/include/configs/hmi1001.h @@ -60,13 +60,14 @@ */ #define CONFIG_COMMANDS (CONFIG_CMD_DFL | \ CFG_CMD_DATE | \ + CFG_CMD_DISPLAY | \ CFG_CMD_DHCP | \ CFG_CMD_EEPROM | \ CFG_CMD_I2C | \ CFG_CMD_IDE | \ CFG_CMD_NFS | \ CFG_CMD_PCI | \ - CFG_CMD_SNTP) + CFG_CMD_SNTP ) /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ #include <cmd_confdefs.h> @@ -104,6 +105,8 @@ #define CONFIG_BOOTCOMMAND "run net_nfs" +#define CONFIG_MISC_INIT_R 1 + /* * IPB Bus clocking configuration. */ @@ -166,6 +169,9 @@ #define CFG_MBAR 0xF0000000 #define CFG_SDRAM_BASE 0x00000000 #define CFG_DEFAULT_MBAR 0x80000000 +#define CFG_DISPLAY_BASE 0x80600000 +#define CFG_STATUS1_BASE 0x80600200 +#define CFG_STATUS2_BASE 0x80600300 /* Settings for XLB = 132 MHz */ #define SDRAM_DDR 1 @@ -269,8 +275,8 @@ /* Display H1, Status Inputs, EPLD @0x80600000 */ #define CFG_CS3_START 0x80600000 -#define CFG_CS3_SIZE 0x00000210 -#define CFG_CS3_CFG 0x9800 +#define CFG_CS3_SIZE 0x00100000 +#define CFG_CS3_CFG 0xffff9830 #define CFG_CS_BURST 0x00000000 #define CFG_CS_DEADCYCLE 0x33333333 @@ -325,4 +331,11 @@ #define CONFIG_PCI_IO_PHYS CONFIG_PCI_IO_BUS #define CONFIG_PCI_IO_SIZE 0x01000000 +/*---------------------------------------------------------------------*/ +/* Display addresses */ +/*---------------------------------------------------------------------*/ + +#define CFG_DISP_CHR_RAM (CFG_DISPLAY_BASE + 0x38) +#define CFG_DISP_CWORD (CFG_DISPLAY_BASE + 0x30) + #endif /* __CONFIG_H */ |